Skip to content

Commit

Permalink
Mods for 1.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
rklasky committed Oct 3, 2023
1 parent b8ae775 commit 1c08089
Show file tree
Hide file tree
Showing 13 changed files with 483 additions and 275 deletions.
43 changes: 35 additions & 8 deletions MSSPM_GuiEstimation/nmfEstimationTab01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,20 @@ nmfEstimation_Tab1::importSpeciesData(const QString& tableName,
if (loadOK && updateSetup) {
// Load signal with data to send to Species Setup tab
QList<QString> SpeciesNames;
QList<QString> SpeciesMinimumBiomass;
QList<QString> SpeciesInitBiomass;
QList<QString> SpeciesGrowthRate;
QList<QString> SpeciesK;
for (int row=0; row<m_SpeciesModel->rowCount(); ++row) {
SpeciesNames.push_back( m_SpeciesModel->item(row,m_ColumnMap["SpeName"])->text());
SpeciesMinimumBiomass.push_back(m_SpeciesModel->item(row,m_ColumnMap["MinimumBiomass"])->text().remove(","));
SpeciesInitBiomass.push_back(m_SpeciesModel->item(row,m_ColumnMap["InitBiomass"])->text().remove(","));
SpeciesGrowthRate.push_back( m_SpeciesModel->item(row,m_ColumnMap["GrowthRate"])->text());
SpeciesK.push_back( m_SpeciesModel->item(row,m_ColumnMap["SpeciesK"])->text().remove(","));
}

emit UpdateSpeciesSetupData(SpeciesNames,SpeciesGuilds,SpeciesInitBiomass,
emit UpdateSpeciesSetupData(SpeciesNames,SpeciesGuilds,
SpeciesMinimumBiomass,SpeciesInitBiomass,
SpeciesGrowthRate,SpeciesK);
QMessageBox::information(Estimation_Tabs, "Data Updated",
"\nSpecies/Guild table has been successfully updated.\n",
Expand Down Expand Up @@ -600,6 +603,7 @@ nmfEstimation_Tab1::checkSpeciesDataPrimary(bool showPopup)
{
double WeightVal = 0;
QString SpeName;
QString MinimumBiomass;
QString InitBiomass;
QString GrowthRate;
QString SpeciesK;
Expand All @@ -613,13 +617,15 @@ nmfEstimation_Tab1::checkSpeciesDataPrimary(bool showPopup)
WeightVal = Weight.toDouble();
index = m_SpeciesModel->index(i,m_ColumnMap["SpeName"]);
SpeName = index.data().toString().remove(",");
index = m_SpeciesModel->index(i,m_ColumnMap["MinimumBiomass"]);
MinimumBiomass = index.data().toString().remove(",");
index = m_SpeciesModel->index(i,m_ColumnMap["InitBiomass"]);
InitBiomass = index.data().toString().remove(",");
index = m_SpeciesModel->index(i,m_ColumnMap["GrowthRate"]);
GrowthRate = index.data().toString().remove(",");
index = m_SpeciesModel->index(i,m_ColumnMap["SpeciesK"]);
SpeciesK = index.data().toString().remove(",");
if (nmfUtilsQt::emptyField({Weight,SpeName,InitBiomass,GrowthRate,SpeciesK})) {
if (nmfUtilsQt::emptyField({Weight,SpeName,MinimumBiomass,InitBiomass,GrowthRate,SpeciesK})) {
checkAndShowEmptyFieldError(showPopup,"checkSpeciesDataPrimary");
return false;
}
Expand Down Expand Up @@ -701,6 +707,7 @@ nmfEstimation_Tab1::showAllColumns(QTableView* tv)
tv->setColumnHidden( i,false);
}
showCovariateColumns(tv,false); // Hide them for now as covariates are entered in their own tab (Tab 6)
showMinimumBiomassColumn(tv,false);
}

void
Expand All @@ -720,6 +727,19 @@ nmfEstimation_Tab1::showCovariateColumns(QTableView* tv, const bool& show)
}
}

void
nmfEstimation_Tab1::showMinimumBiomassColumn(QTableView* tv, const bool& show)
{
QString colName;
QStringList SpeciesSupp = {"MinimumBiomass"};

for (int i = 0; i < tv->model()->columnCount(); ++i) {
colName = tv->model()->headerData(i, Qt::Horizontal).toString();
if (SpeciesSupp.contains(colName)) {
tv->setColumnHidden(i,!show);
}
}
}

void
nmfEstimation_Tab1::showPrimaryColumns(QTableView* tv)
Expand Down Expand Up @@ -1561,7 +1581,8 @@ nmfEstimation_Tab1::callback_ExportPB()
QList<QString> GuildGrowthRate;
QList<QString> GuildK;
QList<QString> SpeciesName;
// QList<QString> SpeciesGuild;
// QList<QString> SpeciesGuild;
QList<QString> SpeciesMinimumBiomass;
QList<QString> SpeciesInitialBiomass;
QList<QString> SpeciesGrowthRate;
QList<QString> SpeciesK;
Expand All @@ -1572,8 +1593,10 @@ nmfEstimation_Tab1::callback_ExportPB()
saveGuildsCSVFile(tableNameStr,GuildName,GuildGrowthRate,GuildK);
} else {
emit LoadSpeciesGuild();
callback_SaveSpeciesCSVFile(tableNameStr,SpeciesName,m_SpeciesGuild,
SpeciesInitialBiomass,SpeciesGrowthRate,SpeciesK);
callback_SaveSpeciesCSVFile(
tableNameStr,SpeciesName,m_SpeciesGuild,
SpeciesMinimumBiomass,SpeciesInitialBiomass,
SpeciesGrowthRate,SpeciesK);
}
}
}
Expand All @@ -1590,6 +1613,7 @@ nmfEstimation_Tab1::callback_QueryAndSaveSpeciesCSVFile(
QString tableNameStr,
QList<QString> SpeciesName,
QList<QString> SpeciesGuild,
QList<QString> SpeciesMinimumBiomass,
QList<QString> SpeciesInitialBiomass,
QList<QString> SpeciesGrowthRate,
QList<QString> SpeciesK)
Expand All @@ -1600,6 +1624,7 @@ nmfEstimation_Tab1::callback_QueryAndSaveSpeciesCSVFile(
tableNameStr,
SpeciesName,
SpeciesGuild,
SpeciesMinimumBiomass,
SpeciesInitialBiomass,
SpeciesGrowthRate,
SpeciesK);
Expand All @@ -1611,6 +1636,7 @@ nmfEstimation_Tab1::callback_SaveSpeciesCSVFile(
QString tableName,
QList<QString> SpeciesName,
QList<QString> SpeciesGuild,
QList<QString> SpeciesMinimumBiomass,
QList<QString> SpeciesInitialBiomass,
QList<QString> SpeciesGrowthRate,
QList<QString> SpeciesK)
Expand All @@ -1626,7 +1652,8 @@ nmfEstimation_Tab1::callback_SaveSpeciesCSVFile(
smodel,
m_ColumnMap,
inputDataPath,tableNameStr,
SpeciesName,SpeciesGuild,SpeciesInitialBiomass,
SpeciesName,SpeciesGuild,
SpeciesMinimumBiomass,SpeciesInitialBiomass,
SpeciesGrowthRate,SpeciesK);

QFileInfo fileInfo(tableNameStr);
Expand Down Expand Up @@ -1969,13 +1996,13 @@ nmfEstimation_Tab1::loadSpecies()
m_Logger->logMsg(nmfConstants::Normal,"nmfEstimation_Tab1::loadSpecies()");

// Load Population tableview
fields = {"Weight","SpeName","InitBiomass","InitBiomassMin","InitBiomassMax",
fields = {"Weight","SpeName","MinimumBiomass","InitBiomass","InitBiomassMin","InitBiomassMax",
"GrowthRate","GrowthRateMin","GrowthRateMax",
"GrowthRateShape","GrowthRateShapeMin","GrowthRateShapeMax",
"SpeciesK","SpeciesKMin","SpeciesKMax",
"SurveyQ","SurveyQMin","SurveyQMax","Catchability",
"CatchabilityMin","CatchabilityMax"};
queryStr = "SELECT Weight,SpeName,InitBiomass,InitBiomassMin,InitBiomassMax,";
queryStr = "SELECT Weight,SpeName,MinimumBiomass,InitBiomass,InitBiomassMin,InitBiomassMax,";
queryStr += "GrowthRate,GrowthRateMin,GrowthRateMax,";
queryStr += "GrowthRateShape,GrowthRateShapeMin,GrowthRateShapeMax,";
queryStr += "SpeciesK,SpeciesKMin,SpeciesKMax,";
Expand Down
7 changes: 7 additions & 0 deletions MSSPM_GuiEstimation/nmfEstimationTab01.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class nmfEstimation_Tab1: public QObject
void setupHelpSpecies();
void setupHelpGuilds();
void showCovariateColumns(QTableView* tv, const bool& show);
void showMinimumBiomassColumn(QTableView* tv, const bool& show);
void showNoColumns(QTableView* tv);
void showAllColumns(QTableView* tv);
void showPrimaryColumns(QTableView* tv);
Expand Down Expand Up @@ -212,13 +213,15 @@ class nmfEstimation_Tab1: public QObject
* @brief Signal sent so the Species Setup tab will be updated with the appropriate Species fields
* @param SpeciesNames : list of species names
* @param SpeciesGuilds : list of guilds that each species is in
* @param SpeciesMinimumBiomass : list of species minimum biomass values
* @param SpeciesInitBiomass : list of species initial biomass values
* @param SpeciesGrowthRate : list of species growth rates
* @param SpeciesK : list of species carrying capacities
*/
void UpdateSpeciesSetupData(
QList<QString> SpeciesNames,
QList<QString> SpeciesGuilds,
QList<QString> SpeciesMinimumBiomass,
QList<QString> SpeciesInitBiomass,
QList<QString> SpeciesGrowthRate,
QList<QString> SpeciesK);
Expand Down Expand Up @@ -342,6 +345,7 @@ public Q_SLOTS:
* @param TableName: name of table to save data from
* @param SpeciesName : list of species names
* @param SpeciesGuild : list of guilds that each species is a member of
* @param SpeciesMinimumBiomass : list of minimum biomass per species
* @param SpeciesInitialBiomass : list of initial biomass per species
* @param SpeciesGrowthRate : list of growth rate per species
* @param SpeciesK : list of carrying capacities per species
Expand All @@ -350,6 +354,7 @@ public Q_SLOTS:
QString TableName,
QList<QString> SpeciesName,
QList<QString> SpeciesGuild,
QList<QString> SpeciesMinimumBiomass,
QList<QString> SpeciesInitialBiomass,
QList<QString> SpeciesGrowthRate,
QList<QString> SpeciesK);
Expand Down Expand Up @@ -378,6 +383,7 @@ public Q_SLOTS:
* @param TableName: name of table to save data from
* @param SpeciesName : list of species names
* @param SpeciesGuild : list of guilds that each species is a member of
* @param SpeciesMinimumBiomass : list of minimum biomass per species
* @param SpeciesInitialBiomass : list of initial biomass per species
* @param SpeciesGrowthRate : list of growth rate per species
* @param SpeciesK : list of carrying capacities per species
Expand All @@ -386,6 +392,7 @@ public Q_SLOTS:
QString TableName,
QList<QString> SpeciesName,
QList<QString> SpeciesGuild,
QList<QString> SpeciesMinimumBiomass,
QList<QString> SpeciesInitialBiomass,
QList<QString> SpeciesGrowthRate,
QList<QString> SpeciesK);
Expand Down
21 changes: 13 additions & 8 deletions MSSPM_GuiEstimation/nmfEstimationTab06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ nmfEstimation_Tab6::loadCovariateInitialValuesAndRangesTable()
// QMessageBox::Ok);
return false;
}

int NumParameters = NumRecords/NumSpecies;
int m = -1;
int modelCol = 0;
Expand All @@ -676,14 +677,14 @@ nmfEstimation_Tab6::loadCovariateInitialValuesAndRangesTable()
++m;
modelCol += 3;
coeffValue = dataMap["CoeffValue"][m];
if (! QString::fromStdString(coeffValue).trimmed().isEmpty()) {
item = new QStandardItem(QString::fromStdString(coeffValue));
if (! QString::fromStdString(coeffValue).trimmed().isEmpty()) {
item = nmfUtilsQt::itemFixedOrScientific(std::stod(coeffValue));
item->setTextAlignment(Qt::AlignCenter);
smodelIR->setItem(species,modelCol+0,item);
item = new QStandardItem(QString::fromStdString(dataMap["CoeffMinValue"][m]));
item = nmfUtilsQt::itemFixedOrScientific(std::stod(dataMap["CoeffMinValue"][m]));
item->setTextAlignment(Qt::AlignCenter);
smodelIR->setItem(species,modelCol+1,item);
item = new QStandardItem(QString::fromStdString(dataMap["CoeffMaxValue"][m]));
item = nmfUtilsQt::itemFixedOrScientific(std::stod(dataMap["CoeffMaxValue"][m]));
item->setTextAlignment(Qt::AlignCenter);
smodelIR->setItem(species,modelCol+2,item);
} else {
Expand Down Expand Up @@ -1520,13 +1521,15 @@ nmfEstimation_Tab6::callback_SpeciesRangeSB(int pct)
valueWithoutComma = initialIndex.data().toString().remove(",");
if ((rangeType == "min/max") || (rangeType == "min only")) {
newValue = valueWithoutComma.toDouble()*(1.0-pctVal);
minItem = new QStandardItem(QString::number(newValue,'f',6));
// minItem = new QStandardItem(QString::number(newValue,'f',6));
minItem = nmfUtilsQt::itemFixedOrScientific(newValue);
minItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col+1,minItem);
}
if ((rangeType == "min/max") || (rangeType == "max only")) {
newValue = valueWithoutComma.toDouble()*(1.0+pctVal);
maxItem = new QStandardItem(QString::number(newValue,'f',6));
// maxItem = new QStandardItem(QString::number(newValue,'f',6));
maxItem = nmfUtilsQt::itemFixedOrScientific(newValue);
maxItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col+2,maxItem);
}
Expand All @@ -1545,7 +1548,8 @@ nmfEstimation_Tab6::callback_SpeciesRangeSB(int pct)
valueWithoutComma = initialIndex.data().toString().remove(",");
if ((rangeType == "min/max") || (rangeType == "min only")) {
newValue = valueWithoutComma.toDouble()*(1.0-pctVal);
minItem = new QStandardItem(QString::number(newValue,'f',6));
// minItem = new QStandardItem(QString::number(newValue,'f',6));
minItem = nmfUtilsQt::itemFixedOrScientific(newValue);
minItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col,minItem);
}
Expand All @@ -1555,7 +1559,8 @@ nmfEstimation_Tab6::callback_SpeciesRangeSB(int pct)
valueWithoutComma = initialIndex.data().toString().remove(",");
if ((rangeType == "min/max") || (rangeType == "max only")) {
newValue = valueWithoutComma.toDouble()*(1.0+pctVal);
maxItem = new QStandardItem(QString::number(newValue,'f',6));
// maxItem = new QStandardItem(QString::number(newValue,'f',6));
maxItem = nmfUtilsQt::itemFixedOrScientific(newValue);
maxItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col,maxItem);
}
Expand Down
5 changes: 5 additions & 0 deletions MSSPM_GuiOutput/nmfOutputControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,11 @@ nmfOutputControls::getGuilds(int& NumGuilds,
return true;
}

void
nmfOutputControls::refreshBrightnessSlider()
{
OutputLineBrightnessSL->setValue(OutputLineBrightnessSL->value());
}

void
nmfOutputControls::callback_OutputLineBrightnessSL(int value)
Expand Down
4 changes: 4 additions & 0 deletions MSSPM_GuiOutput/nmfOutputControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ class nmfOutputControls: public QObject
* @brief Resets the Output Type widget as well as reloading the Scenario widget
*/
void refresh();
/**
* @brief Refreshes the current chart by resetting the brightness slider
*/
void refreshBrightnessSlider();
/**
* @brief Refreshes the current chart by flipping to another chart type and back to the current
*/
Expand Down
1 change: 1 addition & 0 deletions MSSPM_GuiSetup/nmfSetupTab02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ nmfSetup_Tab2::createTables(QString databaseName)
cmd = "CREATE TABLE IF NOT EXISTS " + fullTableName;
cmd += "(SpeName varchar(100) NOT NULL,";
cmd += " GuildName varchar(100) NULL,";
cmd += " MinimumBiomass double NULL,";
cmd += " InitBiomass double NULL,";
cmd += " SurveyQ float NULL,";
cmd += " SpeciesK double NULL,";
Expand Down
Loading

0 comments on commit 1c08089

Please sign in to comment.