Skip to content

Commit

Permalink
fixes and mods for v0.9.19
Browse files Browse the repository at this point in the history
  • Loading branch information
rklasky committed Jun 25, 2021
1 parent 9d0cc92 commit 50c2afa
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 104 deletions.
5 changes: 3 additions & 2 deletions MSSPM_GuiDiagnostic/nmfDiagnosticTab01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,12 @@ nmfDiagnostic_Tab1::callback_RunPB()
std::pair<QString,double> parameterItem;
std::pair<QString,double> parameterItem1;
std::pair<QString,double> parameterItem2;
QStringList vectorParameterNames = m_DatabasePtr->getVectorParameterNames(m_Logger,m_ProjectSettingsConfig);
QString surfaceParameter1Name = getParameter1Name();
QString surfaceParameter2Name = getParameter2Name();
QProgressDialog* progressDlg = new QProgressDialog(
"\nProcessing parameter variations...\n",
"Cancel", 0, nmfConstantsMSSPM::VectorParameterNames.size(),
"Cancel", 0, vectorParameterNames.size(),
m_Diagnostic_Tabs);

m_Logger->logMsg(nmfConstants::Normal,"");
Expand Down Expand Up @@ -389,7 +390,7 @@ nmfDiagnostic_Tab1::callback_RunPB()

m_Diagnostic_Tabs->setCursor(Qt::WaitCursor);

for (QString parameterName : nmfConstantsMSSPM::VectorParameterNames) {
for (QString parameterName : vectorParameterNames) {

nmfUtilsQt::updateProgressDlg(m_Logger,progressDlg,"Processing parameter: "+parameterName.toStdString(),pInc);

Expand Down
18 changes: 16 additions & 2 deletions MSSPM_GuiDiagnostic/nmfDiagnosticTab02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ nmfDiagnostic_Tab2::nmfDiagnostic_Tab2(QTabWidget* tabs,
m_Diagnostic_Tabs->addTab(m_Diagnostic_Tab2_Widget, tr("2. Retrospective Analysis"));

// Set default state of widgets
m_Diagnostic_Tab2_MinYearLE->setStyleSheet(nmfUtilsQt::ReadOnlyLineEditBgColor);
m_Diagnostic_Tab2_MaxYearLE->setStyleSheet(nmfUtilsQt::ReadOnlyLineEditBgColor);
m_Diagnostic_Tab2_MinYearLE->setStyleSheet(nmfUtilsQt::ReadOnlyLineEditBgColorLight);
m_Diagnostic_Tab2_MaxYearLE->setStyleSheet(nmfUtilsQt::ReadOnlyLineEditBgColorLight);
m_Diagnostic_Tab2_MinYearLE->setReadOnly(true);
m_Diagnostic_Tab2_MaxYearLE->setReadOnly(true);

Expand Down Expand Up @@ -291,3 +291,17 @@ std::cout << "range: " << StartYear << ", " << EndYear << std::endl;
emit RunDiagnosticEstimation(ranges);

}

void
nmfDiagnostic_Tab2::setWidgetsDark()
{
nmfUtilsQt::setBackgroundLineEdit(m_Diagnostic_Tab2_MinYearLE,nmfUtilsQt::ReadOnlyLineEditBgColorDark);
nmfUtilsQt::setBackgroundLineEdit(m_Diagnostic_Tab2_MaxYearLE,nmfUtilsQt::ReadOnlyLineEditBgColorDark);
}

void
nmfDiagnostic_Tab2::setWidgetsLight()
{
nmfUtilsQt::setBackgroundLineEdit(m_Diagnostic_Tab2_MinYearLE,nmfUtilsQt::ReadOnlyLineEditBgColorLight);
nmfUtilsQt::setBackgroundLineEdit(m_Diagnostic_Tab2_MaxYearLE,nmfUtilsQt::ReadOnlyLineEditBgColorLight);
}
3 changes: 3 additions & 0 deletions MSSPM_GuiDiagnostic/nmfDiagnosticTab02.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class nmfDiagnostic_Tab2: public QObject
*/
void setStartYearLE(int StartYear);

void setWidgetsDark();
void setWidgetsLight();

signals:
// void ResaveSystem();
/**
Expand Down
4 changes: 2 additions & 2 deletions MSSPM_GuiEstimation/nmfEstimationTab02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nmfEstimation_Tab2::nmfEstimation_Tab2(QTabWidget *tabs,

m_GroupBoxTitle["Catch"] = "Catch";
m_GroupBoxTitle["Effort"] = "Effort";
m_GroupBoxTitle["Exploitation"] = "Exploitation Rate";
m_GroupBoxTitle["Exploitation"] = nmfConstantsMSSPM::OutputChartExploitation.toStdString();

// Load ui as a widget from disk
QFile file(":/forms/Estimation/Estimation_Tab02.ui");
Expand All @@ -32,7 +32,7 @@ nmfEstimation_Tab2::nmfEstimation_Tab2(QTabWidget *tabs,
file.close();

// Add the loaded widget as the new tabbed page
Estimation_Tabs->addTab(Estimation_Tab2_Widget, tr("2. Harvest Parameters"));
Estimation_Tabs->addTab(Estimation_Tab2_Widget, tr("2. Harvest Data"));

Estimation_Tab2_HarvestTV = Estimation_Tabs->findChild<QTableView *>("Estimation_Tab2_HarvestTV");
Estimation_Tab2_HarvestGB = Estimation_Tabs->findChild<QGroupBox *>("Estimation_Tab2_HarvestGB");
Expand Down
31 changes: 22 additions & 9 deletions MSSPM_GuiEstimation/nmfEstimationTab05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ nmfEstimation_Tab5::nmfEstimation_Tab5(QTabWidget *tabs,
m_SModelAbsoluteBiomass = nullptr;
m_SModelRelativeBiomass = nullptr;
m_SModelCovariates = nullptr;
// assuming that the default is light.
m_IsDark = false;

m_Logger->logMsg(nmfConstants::Normal,"nmfEstimation_Tab5::nmfEstimation_Tab5");

Expand Down Expand Up @@ -119,9 +121,7 @@ nmfEstimation_Tab5::callback_ImportPB()
if (isAbsoluteBiomassChecked()) {
importAbsoluteBiomass();
} else {
// importScalarValues();
importRelativeBiomass();
// matchTableColumnWidths();
}
}

Expand Down Expand Up @@ -205,14 +205,15 @@ std::cout << "tableNameStr: " << tableNameStr.toStdString() << std::endl;
bool
nmfEstimation_Tab5::isAbsoluteBiomassChecked()
{
return getObsBiomassType().contains("Absolute Biomass");
return ! m_DatabasePtr->isARelativeBiomassModel(m_ProjectSettingsConfig);
// return getObsBiomassType().contains("Absolute Biomass");
}

QString
nmfEstimation_Tab5::getObsBiomassType()
{
return Estimation_Tab5_ObsBiomassTypeLBL->text();
}
//QString
//nmfEstimation_Tab5::getObsBiomassType()
//{
// return Estimation_Tab5_ObsBiomassTypeLBL->text();
//}

void
nmfEstimation_Tab5::setObsBiomassType(QString obsBiomassType)
Expand Down Expand Up @@ -724,7 +725,12 @@ nmfEstimation_Tab5::loadTableValuesFromDatabase(
// Make first row read-only
item->setEditable(i != 0);
if (i == 0) {
item->setBackground(QBrush(QColor(240,240,240)));
if (m_IsDark){
item->setBackground(QBrush(QColor(103,110,113)));
} else {
item->setBackground(QBrush(QColor(211,211,211)));
}
// item->setBackground(QBrush(QColor(240,240,240)));
flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
Expand Down Expand Up @@ -905,3 +911,10 @@ nmfEstimation_Tab5::callback_Rel2AbsScalarTVScrolled(int value)
Estimation_Tab5_RelativeBiomassTV->blockSignals(false);
}

void
nmfEstimation_Tab5::setIsDark(QString style){

m_IsDark = (style=="Dark");
loadWidgets();

}
10 changes: 8 additions & 2 deletions MSSPM_GuiEstimation/nmfEstimationTab05.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class nmfEstimation_Tab5: public QObject
nmfLogger* m_Logger;
std::string m_ProjectDir;
std::string m_ProjectSettingsConfig;
bool m_IsDark;
QStandardItemModel* m_SModelAbsoluteBiomass;
QStandardItemModel* m_SModelRelativeBiomass;
QStandardItemModel* m_SModelCovariates;
Expand Down Expand Up @@ -154,11 +155,16 @@ class nmfEstimation_Tab5: public QObject
* @return
*/
bool loadWidgets(QString MohnsRhoLabel);

// bool loadWidgetsFirstRow();
bool isTableValueOK(QString value);
QString getObsBiomassType();
// QString getObsBiomassType();
void setObsBiomassType(QString obsBiomassType);
/**
* @brief Updates the data member m_IsDark accordingly and refreshes the GUI
* @param style : the new light/dark preference setting
*
*/
void setIsDark(QString style);

signals:
/**
Expand Down
29 changes: 22 additions & 7 deletions MSSPM_GuiEstimation/nmfEstimationTab06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ nmfEstimation_Tab6::nmfEstimation_Tab6(QTabWidget* tabs,

callback_MinimizerTypeCMB(Estimation_Tab6_MinimizerTypeCMB->currentText());
callback_MinimizerAlgorithmCMB(Estimation_Tab6_MinimizerAlgorithmCMB->currentText());

}


Expand Down Expand Up @@ -1587,6 +1588,11 @@ nmfEstimation_Tab6::callback_EnsembleControlsGB(bool isChecked)
{
callback_EnsembleTotalRunsSB(Estimation_Tab6_EnsembleTotalRunsSB->value());
enableEnsembleWidgets(! isChecked);

if (isChecked) {
loadEnsembleFile(QString::fromStdString(nmfConstantsMSSPM::MultiRunFilename),
nmfConstantsMSSPM::VerboseOff);
}
}


Expand Down Expand Up @@ -1644,12 +1650,17 @@ nmfEstimation_Tab6::callback_EnsembleUsingPctPB()
void
nmfEstimation_Tab6::callback_EnsembleLoadPB()
{
loadEnsembleFile(QString::fromStdString(nmfConstantsMSSPM::MultiRunFilename));
loadEnsembleFile(QString::fromStdString(nmfConstantsMSSPM::MultiRunFilename),
nmfConstantsMSSPM::VerboseOn);
}
void
nmfEstimation_Tab6::loadEnsembleFile(QString ensembleFilename)


bool
nmfEstimation_Tab6::loadEnsembleFile(QString ensembleFilename,
const bool& verbose)
{
std::cout << "Loading: " << ensembleFilename.toStdString() << std::endl;
bool retv = true;
int TotalNumRuns = 0;
QString msg;
QString fullPath = QDir(QString::fromStdString(m_ProjectDir)).filePath("outputData");
Expand All @@ -1672,10 +1683,14 @@ std::cout << "Loading: " << ensembleFilename.toStdString() << std::endl;
enableEnsembleWidgets(false);
m_EnsembleDialog->loadWidgets(ensembleFilename);
} else {
QMessageBox::warning(Estimation_Tabs, "Warning",
"\nNo previous Multi-Run/Ensemble file found to load.\n",
QMessageBox::Ok);
if (verbose) {
QMessageBox::warning(Estimation_Tabs, "Warning",
"\nNo previous Multi-Run/Ensemble file found to load.\n",
QMessageBox::Ok);
}
retv = false;
}
return retv;
}

void
Expand Down Expand Up @@ -1746,8 +1761,8 @@ nmfEstimation_Tab6::callback_EnsembleSetAllPB()
int totalNumberOfRunsDesired = numRunsToAdd;
QString fullPath = "";

Estimation_Tab6_EnsembleRunsSetLE->setText(QString::number(Estimation_Tab6_EnsembleTotalRunsSB->value()));
if (addToMultiRunFile(numRunsToAdd,currentNumberOfRuns,totalNumberOfRunsDesired,fullPath)) {
Estimation_Tab6_EnsembleRunsSetLE->setText(QString::number(Estimation_Tab6_EnsembleTotalRunsSB->value()));
m_EnsembleDialog->loadWidgets(QString::fromStdString(m_EnsembleFilename));
if (numRunsToAdd+currentNumberOfRuns == totalNumberOfRunsDesired) {
QString msg = "\nSaved Mult-Run Parameter File to:\n\n" + fullPath + "\n";
Expand Down
3 changes: 2 additions & 1 deletion MSSPM_GuiEstimation/nmfEstimationTab06.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ class nmfEstimation_Tab6: public QObject
std::string getBeesNeighborhoodSize();
std::string getBeesNumberOfRuns();
std::string getEnsembleFilename();
void loadEnsembleFile(QString ensembleFile);
bool loadEnsembleFile(QString ensembleFile,
const bool& verbose);
void setEnsembleRuns(int value);
void setEnsembleRunsSet(int value);
bool isAMultiRun();
Expand Down
2 changes: 1 addition & 1 deletion MSSPM_GuiForecast/nmfForecastTab02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nmfForecast_Tab2::nmfForecast_Tab2(QTabWidget* tabs,
file.close();

// Add the loaded widget as the new tabbed page
Forecast_Tabs->addTab(Forecast_Tab2_Widget, tr("2. Harvest Parameters"));
Forecast_Tabs->addTab(Forecast_Tab2_Widget, tr("2. Harvest Data"));

Forecast_Tab2_HarvestTV = Forecast_Tabs->findChild<QTableView *>("Forecast_Tab2_HarvestTV");
Forecast_Tab2_HarvestGB = Forecast_Tabs->findChild<QGroupBox *>("Forecast_Tab2_HarvestGB");
Expand Down
2 changes: 1 addition & 1 deletion MSSPM_GuiForecast/nmfForecastTab02.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class nmfForecast_Tab2: public QObject

public:
/**
* @brief nmfForecast_Tab2 : class constructor for the Forecast Harvest parameters GUI page
* @brief nmfForecast_Tab2 : class constructor for the Forecast Harvest Data GUI page
* @param tabs : the tab widget into which this Forecast tab will be placed
* @param logger : pointer to the application logger
* @param databasePtr : pointer to the application database
Expand Down
16 changes: 8 additions & 8 deletions MSSPM_GuiManagerMode/REMORA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ REMORA::drawMultiSpeciesChart()
boost::numeric::ublas::matrix<double> ChartLine;
boost::numeric::ublas::matrix<double> Catch;
std::vector<std::string> SpeNames;
std::vector<bool> GridLines(true,true);
std::vector<bool> GridLines = {true,true};
std::vector<boost::numeric::ublas::matrix<double> > ForecastBiomass;
QList<QColor> LineColors;

Expand All @@ -217,7 +217,7 @@ REMORA::drawMultiSpeciesChart()
NumSpecies = SpeNames.size();

if (isFishingMortality) {
YLabel = "Fishing Mortality (C/Bc)";
YLabel = nmfConstantsMSSPM::OutputChartExploitationCatchTitle.toStdString();
if (! m_DatabasePtr->getTimeSeriesData(m_Widget,m_Logger,m_ProjectSettingsConfig,
"","","Catch",NumSpecies,NumObservedYears,Catch)) {
return;
Expand Down Expand Up @@ -477,7 +477,7 @@ REMORA::drawMSYLines(
const bool& ShowLegend,
const double& Pct)
{
bool isFishingMortality = (getForecastPlotType() == "Fishing Mortality");
bool isFishingMortality = (getForecastPlotType() == nmfConstantsMSSPM::OutputChartExploitation);
int Theme = 0;
double MSYValue;
double ScaleVal = 1.0;
Expand All @@ -488,7 +488,7 @@ REMORA::drawMSYLines(
boost::numeric::ublas::matrix<double> ChartMSYData;
std::map<std::string, std::vector<std::string> > dataMap;
std::vector<std::string> fields;
std::vector<bool> GridLines(true,true);
std::vector<bool> GridLines = {true,true};
QColor LineColor = QColor(nmfConstants::LineColors[0].c_str());

if (Pct != 1.0) {
Expand Down Expand Up @@ -624,7 +624,7 @@ REMORA::drawSingleSpeciesChart()
std::vector<boost::numeric::ublas::matrix<double> > ChartLinesMonteCarloMultiPlot;
std::vector<boost::numeric::ublas::matrix<double> > ChartLineSpans;
boost::numeric::ublas::matrix<double> Catch;
std::vector<bool> GridLines(true,true);
std::vector<bool> GridLines = {true,true};
std::vector<boost::numeric::ublas::matrix<double> > ForecastBiomass;
std::vector<boost::numeric::ublas::matrix<double> > ForecastBiomassMonteCarlo;
std::vector<std::string> SpeNames;
Expand All @@ -644,7 +644,7 @@ REMORA::drawSingleSpeciesChart()
NumObservedYears = EndYear-StartYear;

if (isFishingMortality) {
YLabel = "Fishing Mortality (C/Bc)";
YLabel = nmfConstantsMSSPM::OutputChartExploitationCatchTitle.toStdString();
if (! m_DatabasePtr->getTimeSeriesData(m_Widget,m_Logger,m_ProjectSettingsConfig,
"","","Catch",NumSpecies,NumObservedYears,Catch)) {
return;
Expand Down Expand Up @@ -1220,7 +1220,7 @@ REMORA::isDeterministic()
bool
REMORA::isFishingMortalityPlotType()
{
return (MModeForecastPlotTypeCMB->currentText() == "Fishing Mortality");
return (MModeForecastPlotTypeCMB->currentText() == nmfConstantsMSSPM::OutputChartExploitation);
}

bool
Expand Down Expand Up @@ -1977,7 +1977,7 @@ REMORA::callback_ForecastPlotTypeCMB(QString type)
MModeShowMSYCB->setChecked(false);
MModePctMSYCB->setEnabled(false);
MModePctMSYCB->setChecked(false);
} else if (type == "Fishing Mortality") {
} else if (type == nmfConstantsMSSPM::OutputChartExploitation) {
MModeShowMSYCB->setEnabled(showMSYCheckboxes);
MModePctMSYCB->setEnabled(showMSYCheckboxes);
}
Expand Down
Loading

0 comments on commit 50c2afa

Please sign in to comment.