Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Nov 27, 2023
1 parent c6ffb7f commit 80bcab3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 68 deletions.
62 changes: 25 additions & 37 deletions pragaProject/dialogMeteoComputation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,13 @@ DialogMeteoComputation::DialogMeteoComputation(QSettings *settings, bool isMeteo
}
}


show();
exec();

}


void DialogMeteoComputation::done(bool res)
{

if(res) // ok was pressed
{
if ( (!saveClima && !checkValidData()) || (saveClima && saveClimaLayout.getList().empty()) )
Expand Down Expand Up @@ -714,14 +711,12 @@ void DialogMeteoComputation::done(bool res)
QDialog::done(QDialog::Accepted);
return;
}

}
else // cancel, close or exc was pressed
{
QDialog::done(QDialog::Rejected);
return;
}

}


Expand All @@ -741,7 +736,6 @@ void DialogMeteoComputation::checkYears()

void DialogMeteoComputation::displayPeriod(const QString value)
{

if (value == "Daily")
{
elaborationList.setCurrentText("No elaboration available");
Expand Down Expand Up @@ -936,12 +930,10 @@ void DialogMeteoComputation::displayPeriod(const QString value)
nrYear.setText("0");
nrYear.setEnabled(true);
}

}


}


void DialogMeteoComputation::listElaboration(const QString value)
{

Expand Down Expand Up @@ -994,9 +986,9 @@ void DialogMeteoComputation::listElaboration(const QString value)
{
anomaly.AnomalySetVariableElab(variableList.currentText());
}

}


void DialogMeteoComputation::listSecondElab(const QString value)
{

Expand Down Expand Up @@ -1069,25 +1061,23 @@ void DialogMeteoComputation::listSecondElab(const QString value)
}
settings->endArray();
settings->endGroup();


}


void DialogMeteoComputation::activeSecondParameter(const QString value)
{

if ( MapElabWithParam.find(value.toStdString()) == MapElabWithParam.end())
{
elab2Parameter.clear();
elab2Parameter.setReadOnly(true);
}
else
{
elab2Parameter.setReadOnly(false);
}

if ( MapElabWithParam.find(value.toStdString()) == MapElabWithParam.end())
{
elab2Parameter.clear();
elab2Parameter.setReadOnly(true);
}
else
{
elab2Parameter.setReadOnly(false);
}
}


void DialogMeteoComputation::readParameter(int state)
{

Expand Down Expand Up @@ -1122,10 +1112,8 @@ void DialogMeteoComputation::readParameter(int state)
climateDbElabList.addItem(climateDbElab[i]);
}
}

}


elab1Parameter.clear();
elab1Parameter.setReadOnly(true);
}
Expand All @@ -1135,7 +1123,6 @@ void DialogMeteoComputation::readParameter(int state)
adjustSize();
elab1Parameter.setReadOnly(false);
}

}


Expand Down Expand Up @@ -1320,14 +1307,15 @@ bool DialogMeteoComputation::checkValidData()
}
}
return true;

}


QList<QString> DialogMeteoComputation::getElabSaveList()
{
return saveClimaLayout.getList();
}


void DialogMeteoComputation::copyDataFromXML()
{
Crit3DElabList listXMLElab;
Expand Down Expand Up @@ -1376,6 +1364,7 @@ void DialogMeteoComputation::copyDataFromXML()
variableList.setCurrentText(QString::fromStdString(xmlVariable));
int elabIndex = elaborationList.findText(listXMLElab.listElab1()[index], Qt::MatchFixedString);
elaborationList.setCurrentIndex(elabIndex);

if ( (listXMLElab.listParam1()[index] != NODATA) && (!listXMLElab.listParam1IsClimate()[index]) )
{
elab1Parameter.setReadOnly(false);
Expand All @@ -1389,13 +1378,12 @@ void DialogMeteoComputation::copyDataFromXML()
climateDbElabList.setVisible(true);
adjustSize();

int index = climateDbElabList.findText(listXMLElab.listParam1ClimateField()[index], Qt::MatchFixedString);
if (index == -1)
int climateIndex = climateDbElabList.findText(listXMLElab.listParam1ClimateField()[index], Qt::MatchFixedString);
if (climateIndex == -1)
{
QMessageBox::information(nullptr, "climate field not found", "Check param1 climate field");
}
climateDbElabList.setCurrentIndex(index);

climateDbElabList.setCurrentIndex(climateIndex);
}
else
{
Expand Down Expand Up @@ -1474,12 +1462,12 @@ void DialogMeteoComputation::copyDataFromXML()
climateDbElabList.setVisible(true);
adjustSize();

int index = climateDbElabList.findText(listXMLAnomaly.listParam1ClimateField()[index], Qt::MatchFixedString);
if (index == -1)
int climateIndex = climateDbElabList.findText(listXMLAnomaly.listParam1ClimateField()[index], Qt::MatchFixedString);
if (climateIndex == -1)
{
QMessageBox::information(nullptr, "climate field not found", "Check param1 climate field");
}
climateDbElabList.setCurrentIndex(index);
climateDbElabList.setCurrentIndex(climateIndex);

}
else
Expand Down Expand Up @@ -1537,12 +1525,12 @@ void DialogMeteoComputation::copyDataFromXML()
{
anomaly.AnomalyReadParameter(1);

int index = climateDbElabList.findText(listXMLAnomaly.listRefParam1ClimateField()[index], Qt::MatchFixedString);
if (index == -1)
int climateIndex = climateDbElabList.findText(listXMLAnomaly.listRefParam1ClimateField()[index], Qt::MatchFixedString);
if (climateIndex == -1)
{
QMessageBox::information(nullptr, "climate field not found", "Check reference param1 climate field");
}
climateDbElabList.setCurrentIndex(index);
climateDbElabList.setCurrentIndex(climateIndex);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion pragaProject/pragaProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ bool PragaProject::interpolationMeteoGrid(meteoVariable myVar, frequencyType myF
}
else
{
if (! interpolationGridMain(myVar, myTime))
if (! interpolationGrid(myVar, myTime))
return false;
}

Expand Down
49 changes: 22 additions & 27 deletions project/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void Project::initializeProject()
proxyWidget = nullptr;
}


void Project::clearProject()
{
if (logFile.is_open()) logFile.close();
Expand Down Expand Up @@ -135,6 +136,7 @@ void Project::clearProject()
isProjectLoaded = false;
}


void Project::clearProxyDEM()
{
int index = interpolationSettings.getIndexHeight();
Expand Down Expand Up @@ -186,6 +188,7 @@ void Project::setProxyDEM()
}
}


bool Project::checkProxy(const Crit3DProxy &myProxy, QString* error)
{
std::string name_ = myProxy.getName();
Expand All @@ -207,6 +210,7 @@ bool Project::checkProxy(const Crit3DProxy &myProxy, QString* error)
return true;
}


bool Project::addProxyToProject(std::vector <Crit3DProxy> proxyList, std::deque <bool> proxyActive, std::vector <int> proxyOrder)
{
unsigned i, order;
Expand Down Expand Up @@ -235,7 +239,6 @@ bool Project::addProxyToProject(std::vector <Crit3DProxy> proxyList, std::deque
if (getProxyPragaName(interpolationSettings.getProxy(i)->getName()) == height) setProxyDEM();

return true;

}


Expand All @@ -252,6 +255,7 @@ void Project::addProxyGridSeries(QString name_, std::vector <QString> gridNames,
proxyGridSeries.push_back(mySeries);
}


bool Project::loadParameters(QString parametersFileName)
{
parametersFileName = getCompleteFileName(parametersFileName, PATH_SETTINGS);
Expand Down Expand Up @@ -2120,9 +2124,10 @@ bool Project::computeStatisticsCrossValidation(Crit3DTime myTime, meteoVariable
return true;
}


bool Project::interpolationCv(meteoVariable myVar, const Crit3DTime& myTime, crossValidationStatistics *myStats)
{
if (! checkInterpolationMain(myVar)) return false;
if (! checkInterpolation(myVar)) return false;

// check variables
if ( interpolationSettings.getUseDewPoint() &&
Expand Down Expand Up @@ -2373,7 +2378,8 @@ bool Project::interpolateDemRadiation(const Crit3DTime& myTime, gis::Crit3DRaste
return true;
}

bool Project::checkInterpolationMain(meteoVariable myVar)

bool Project::checkInterpolation(meteoVariable myVar)
{
if (! DEM.isLoaded)
{
Expand All @@ -2394,10 +2400,10 @@ bool Project::checkInterpolationMain(meteoVariable myVar)
}

return true;

}

bool Project::checkInterpolationMainSimple(meteoVariable myVar)

bool Project::checkInterpolationGrid(meteoVariable myVar)
{
if (nrMeteoPoints == 0)
{
Expand All @@ -2412,12 +2418,12 @@ bool Project::checkInterpolationMainSimple(meteoVariable myVar)
}

return true;

}


bool Project::interpolationDemMain(meteoVariable myVar, const Crit3DTime& myTime, gis::Crit3DRasterGrid *myRaster)
{
if (! checkInterpolationMain(myVar))
if (! checkInterpolation(myVar))
return false;

// solar radiation model
Expand Down Expand Up @@ -2465,8 +2471,12 @@ bool Project::meteoGridAggregateProxy(std::vector <gis::Crit3DRasterGrid*> &myGr
return true;
}


bool Project::interpolationGrid(meteoVariable myVar, const Crit3DTime& myTime)
{
if (! checkInterpolationGrid(myVar))
return false;

std::vector <Crit3DInterpolationDataPoint> interpolationPoints;

// check quality and pass data to interpolation
Expand Down Expand Up @@ -2582,21 +2592,6 @@ bool Project::interpolationGrid(meteoVariable myVar, const Crit3DTime& myTime)
return true;
}

bool Project::interpolationGridMain(meteoVariable myVar, const Crit3DTime& myTime)
{
if (! checkInterpolationMainSimple(myVar))
return false;

/* solar radiation model
if (myVar == globalIrradiance)
{
Crit3DTime halfHour = myTime.addSeconds(-1800);
return interpolateDemRadiation(halfHour, myRaster);
}*/

return interpolationGrid(myVar, myTime);
}


float Project::meteoDataConsistency(meteoVariable myVar, const Crit3DTime& timeIni, const Crit3DTime& timeFin)
{
Expand All @@ -2610,14 +2605,14 @@ float Project::meteoDataConsistency(meteoVariable myVar, const Crit3DTime& timeI

QString Project::getCompleteFileName(QString fileName, QString secondaryPath)
{
if (fileName == "") return fileName;
if (fileName.isEmpty()) return fileName;

if (getFilePath(fileName) == "")
{
QString completeFileName = this->getDefaultPath() + secondaryPath + fileName;
return QDir().cleanPath(completeFileName);
}
else if (fileName.left(1) == ".")
else if (fileName.at(0) == '.')
{
QString completeFileName = this->getProjectPath() + fileName;
return QDir().cleanPath(completeFileName);
Expand All @@ -2631,14 +2626,14 @@ QString Project::getCompleteFileName(QString fileName, QString secondaryPath)

QString Project::getRelativePath(QString fileName)
{
if (fileName != "" && fileName.left(1) != "." && getFilePath(fileName) != "")
if (!fileName.isEmpty() && fileName.at(0) != '.' && getFilePath(fileName) != "")
{
QDir projectDir(getProjectPath());
QString relativePath = projectDir.relativeFilePath(fileName);
if (relativePath != fileName)
{
fileName = relativePath;
if (fileName.left(1) != ".")
if (fileName.at(0) != '.')
{
fileName = "./" + relativePath;
}
Expand Down Expand Up @@ -2689,7 +2684,7 @@ bool Project::loadProjectSettings(QString settingsFileName)
{
// modify project path
QString newProjectPath;
if(myPath.left(1) == ".")
if (myPath.at(0) == '.')
{
newProjectPath = getProjectPath() + myPath;
}
Expand Down
5 changes: 2 additions & 3 deletions project/project.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@
bool loadTopographicDistanceMaps(bool onlyWithData, bool showInfo);
void passInterpolatedTemperatureToHumidityPoints(Crit3DTime myTime, Crit3DMeteoSettings *meteoSettings);

bool checkInterpolationMain(meteoVariable myVar);
bool checkInterpolationMainSimple(meteoVariable myVar);
bool interpolationGridMain(meteoVariable myVar, const Crit3DTime& myTime);
bool checkInterpolation(meteoVariable myVar);
bool checkInterpolationGrid(meteoVariable myVar);
bool interpolationGrid(meteoVariable myVar, const Crit3DTime& myTime);
bool interpolationDemMain(meteoVariable myVar, const Crit3DTime& myTime, gis::Crit3DRasterGrid *myRaster);
bool interpolationDem(meteoVariable myVar, const Crit3DTime& myTime, gis::Crit3DRasterGrid *myRaster);
Expand Down

0 comments on commit 80bcab3

Please sign in to comment.