Skip to content

Commit

Permalink
fix locale snow
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Oct 30, 2023
1 parent 28fc85d commit 57933bb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 38 deletions.
8 changes: 4 additions & 4 deletions agrolib/project/dialogInterpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ DialogInterpolation::DialogInterpolation(Project *myProject)
doubleValR2->setNotation(QDoubleValidator::StandardNotation);
minRegressionR2Edit.setFixedWidth(30);
minRegressionR2Edit.setValidator(doubleValR2);
minRegressionR2Edit.setText(QString::number(double(_interpolationSettings->getMinRegressionR2())));
minRegressionR2Edit.setText(QLocale().toString(_interpolationSettings->getMinRegressionR2()));
layoutR2->addWidget(labelMinR2);
layoutR2->addWidget(&minRegressionR2Edit);
layoutDetrending->addLayout(layoutR2);
Expand Down Expand Up @@ -130,7 +130,7 @@ DialogInterpolation::DialogInterpolation(Project *myProject)
QIntValidator *intValMinPoints = new QIntValidator(1, 1000, this);
minPointsLocalDetrendingEdit.setFixedWidth(30);
minPointsLocalDetrendingEdit.setValidator(intValMinPoints);
minPointsLocalDetrendingEdit.setText(QString::number(int(_interpolationSettings->getMinPointsLocalDetrending())));
minPointsLocalDetrendingEdit.setText(QString::number(_interpolationSettings->getMinPointsLocalDetrending()));
layoutDetrending->addWidget(labelMinPointsLocalDetrendingEdit);
layoutDetrending->addWidget(&minPointsLocalDetrendingEdit);

Expand Down Expand Up @@ -284,11 +284,11 @@ void DialogInterpolation::accept()
_interpolationSettings->setUseThermalInversion(thermalInversionEdit->isChecked());
_interpolationSettings->setUseDewPoint(useDewPointEdit->isChecked());
_interpolationSettings->setUseInterpolatedTForRH((useInterpolTForRH->isChecked()));
_interpolationSettings->setMinRegressionR2(minRegressionR2Edit.text().toFloat());
_interpolationSettings->setMinRegressionR2(QLocale().toFloat(minRegressionR2Edit.text()));
_interpolationSettings->setTopoDist_maxKh(maxTdMultiplierEdit.text().toInt());
_interpolationSettings->setMinPointsLocalDetrending(minPointsLocalDetrendingEdit.text().toInt());

_qualityInterpolationSettings->setMinRegressionR2(minRegressionR2Edit.text().toFloat());
_qualityInterpolationSettings->setMinRegressionR2(QLocale().toFloat(minRegressionR2Edit.text()));
_qualityInterpolationSettings->setTopoDist_maxKh(maxTdMultiplierEdit.text().toInt());
_qualityInterpolationSettings->setUseLapseRateCode(lapseRateCodeEdit->isChecked());
_qualityInterpolationSettings->setUseThermalInversion(thermalInversionEdit->isChecked());
Expand Down
83 changes: 49 additions & 34 deletions bin/CRITERIA3D/dialogSnowSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ void DialogSnowSettings::accept()
{
return;
}

}


bool DialogSnowSettings::checkEmptyValues()
{
if (rainfallThresholdValue->text().isEmpty())
Expand Down Expand Up @@ -129,128 +129,143 @@ bool DialogSnowSettings::checkEmptyValues()
return true;
}


bool DialogSnowSettings::checkWrongValues()
{
bool ok;
if (rainfallThresholdValue->text().toDouble(&ok) < 0.0 || rainfallThresholdValue->text().toDouble() > 4.0)
{
QMessageBox::information(nullptr, "Insert a valid value", "Max temp value with snow should be in [0:4]");
return false;
}

double rainfallThreshold = QLocale().toDouble(rainfallThresholdValue->text(), &ok);
if (!ok)
{
QMessageBox::information(nullptr, "Insert a valid value", "Max temp value with snow is not a number");
QMessageBox::information(nullptr, "Wrong value", "Max. temperature with snow value is not a number");
return false;
}
if (snowThresholdValue->text().toDouble(&ok) < -2.0 || snowThresholdValue->text().toDouble() > 1.0)
if ((rainfallThreshold < 0.0) || (rainfallThreshold > 4.0))
{
QMessageBox::information(nullptr, "Insert a valid value", "Min temp value with rain should be in [-2:1]");
QMessageBox::information(nullptr, "Wrong value", "Max. temperature with snow should be in [0:4]");
return false;
}

double snowThreshold = QLocale().toDouble(snowThresholdValue->text(), &ok);
if (!ok)
{
QMessageBox::information(nullptr, "Insert a valid value", "Min temp value with rain is not a number");
QMessageBox::information(nullptr, "Wrong value", "Min. temperature with rain value is not a number");
return false;
}
if (waterHoldingValue->text().toDouble(&ok) < 0 || waterHoldingValue->text().toDouble() > 1)
if ((snowThreshold < -2.0) || (snowThreshold > 1.0))
{
QMessageBox::information(nullptr, "Insert a valid value", "Water holding capacity should be in [0:1]");
QMessageBox::information(nullptr, "Wrong value", "Min. temperature with rain should be in [-2:1]");
return false;
}

double waterHolding = QLocale().toDouble(waterHoldingValue->text(), &ok);
if (!ok)
{
QMessageBox::information(nullptr, "Insert a valid value", "Water holding capacity is not a number");
QMessageBox::information(nullptr, "Wrong value", "Water holding capacity value is not a number");
return false;
}
if (surfaceThickValue->text().toDouble(&ok) < 0.001 || surfaceThickValue->text().toDouble() > 0.02)
if ((waterHolding < 0) || (waterHolding > 1))
{
QMessageBox::information(nullptr, "Insert a valid value", "Snow skin thickness should be in [0.001:0.02]");
QMessageBox::information(nullptr, "Wrong value", "Water holding capacity should be in [0:1]");
return false;
}

double surfaceThick = QLocale().toDouble(surfaceThickValue->text(), &ok);
if (!ok)
{
QMessageBox::information(nullptr, "Insert a valid value", "Snow skin thickness is not a number");
QMessageBox::information(nullptr, "Wrong value", "Snow skin thickness value is not a number");
return false;
}
if (vegetationHeightValue->text().toDouble(&ok) < 0 || vegetationHeightValue->text().toDouble() > 10)
if ((surfaceThick < 0.001) || (surfaceThick > 0.02))
{
QMessageBox::information(nullptr, "Insert a valid value", "Vegetation heigh should be in [0:10]");
QMessageBox::information(nullptr, "Wrong value", "Snow skin thickness should be in [0.001 : 0.02]");
return false;
}

double vegetationHeight = QLocale().toDouble(vegetationHeightValue->text(), &ok);
if (!ok)
{
QMessageBox::information(nullptr, "Insert a valid value", "Vegetation heigh is not a number");
QMessageBox::information(nullptr, "Wrong value", "Vegetation height value is not a number");
return false;
}
if (soilAlbedoValue->text().toDouble(&ok) < 0 || soilAlbedoValue->text().toDouble() > 1)
if ((vegetationHeight < 0) || (vegetationHeight > 10))
{
QMessageBox::information(nullptr, "Insert a valid value", "Soil albedo should be in [0:1]");
QMessageBox::information(nullptr, "Wrong value", "Vegetation height should be in [0:10]");
return false;
}

double soilAlbedo = QLocale().toDouble(soilAlbedoValue->text(), &ok);
if (!ok)
{
QMessageBox::information(nullptr, "Insert a valid value", "Soil albedo is not a number");
QMessageBox::information(nullptr, "Wrong value", "Soil albedo value is not a number");
return false;
}
if ((soilAlbedo < 0) || (soilAlbedo > 1))
{
QMessageBox::information(nullptr, "Wrong value", "Soil albedo should be in [0:1]");
return false;
}

return true;
}


double DialogSnowSettings::getRainfallThresholdValue() const
{
return rainfallThresholdValue->text().toDouble();
return QLocale().toDouble(rainfallThresholdValue->text());
}

void DialogSnowSettings::setRainfallThresholdValue(double value)
{
rainfallThresholdValue->setText(QString::number(value));
rainfallThresholdValue->setText(QLocale().toString(value));
}

double DialogSnowSettings::getSnowThresholdValue() const
{
return snowThresholdValue->text().toDouble();
return QLocale().toDouble(snowThresholdValue->text());
}

void DialogSnowSettings::setSnowThresholdValue(double value)
{
snowThresholdValue->setText(QString::number(value));
snowThresholdValue->setText(QLocale().toString(value));
}

double DialogSnowSettings::getWaterHoldingValue() const
{
return waterHoldingValue->text().toDouble();
return QLocale().toDouble(waterHoldingValue->text());
}

void DialogSnowSettings::setWaterHoldingValue(double value)
{
waterHoldingValue->setText(QString::number(value));
waterHoldingValue->setText(QLocale().toString(value));
}

double DialogSnowSettings::getSurfaceThickValue() const
{
return surfaceThickValue->text().toDouble();
return QLocale().toDouble(surfaceThickValue->text());
}

void DialogSnowSettings::setSurfaceThickValue(double value)
{
surfaceThickValue->setText(QString::number(value));
surfaceThickValue->setText(QLocale().toString(value));
}

double DialogSnowSettings::getVegetationHeightValue() const
{
return vegetationHeightValue->text().toDouble();
return QLocale().toDouble(vegetationHeightValue->text());
}

void DialogSnowSettings::setVegetationHeightValue(double value)
{
vegetationHeightValue->setText(QString::number(value));
vegetationHeightValue->setText(QLocale().toString(value));
}

double DialogSnowSettings::getSoilAlbedoValue() const
{
return soilAlbedoValue->text().toDouble();
return QLocale().toDouble(soilAlbedoValue->text());
}

void DialogSnowSettings::setSoilAlbedoValue(double value)
{
soilAlbedoValue->setText(QString::number(value));
soilAlbedoValue->setText(QLocale().toString(value));
}

0 comments on commit 57933bb

Please sign in to comment.