Skip to content

Commit

Permalink
Merge commit '72a26ed3385640e31b7a5582fe2d156d3e025c2f'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Aug 12, 2024
2 parents 8e052cb + 72a26ed commit 9b3a5b7
Show file tree
Hide file tree
Showing 133 changed files with 5,671 additions and 3,649 deletions.
4 changes: 2 additions & 2 deletions agrolib/climate/climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ float thomDailyMean(TObsDataH* hourlyValues, float minimumPercentage)
if ( (float(nData) / 24 * 100) < minimumPercentage)
thomDailyMean = NODATA;
else
thomDailyMean = statistics::mean(thomValues, nData);
thomDailyMean = statistics::mean(thomValues);


return thomDailyMean;
Expand Down Expand Up @@ -3826,7 +3826,7 @@ bool parseXMLElaboration(Crit3DElabList *listXMLElab, Crit3DAnomalyList *listXML
meteoVariable var = getKeyMeteoVarMeteoMap(MapMonthlyMeteoVarToString, variable.toStdString());
if (var != noMeteoVar)
{
listXMLDrought->updateVariable(var, listXMLDrought->listVariable().size() - 1); //change var
listXMLDrought->updateVariable(var, int(listXMLDrought->listVariable().size()) - 1); //change var
}
}
if (myTag == "EXPORT")
Expand Down
3 changes: 1 addition & 2 deletions agrolib/climate/climate.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@

void setMpValues(Crit3DMeteoPoint meteoPointGet, Crit3DMeteoPoint* meteoPointSet, QDate myDate, meteoVariable myVar, Crit3DMeteoSettings* meteoSettings);
meteoComputation getMeteoCompFromString(std::map<std::string, meteoComputation> map, std::string value);

//int getClimateIndexFromDate(QDate myDate, period periodType);


#endif // CLIMATE_H
79 changes: 61 additions & 18 deletions agrolib/commonChartElements/dialogChangeAxis.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,57 @@
#include "dialogChangeAxis.h"

DialogChangeAxis::DialogChangeAxis(bool isLeftAxis_)
DialogChangeAxis::DialogChangeAxis(int nrAxis, bool isDate_)
{
isLeftAxis = isLeftAxis_;
isDateAxis = isDate_;

QString title;
if (isLeftAxis)
if (nrAxis == 0)
{
title = "Change X Axis";
}
else if (nrAxis == 1)
{
title = "Change Left Axis";
}
else
else if (nrAxis == 2)
{
title = "Change Right Axis";
}
this->setWindowTitle(title);

QVBoxLayout* mainLayout = new QVBoxLayout;
this->resize(200, 100);

QHBoxLayout *layoutOk = new QHBoxLayout;
QHBoxLayout *layoutEdit = new QHBoxLayout;

QLabel minValueLabel("Minimum value:");
minValueLabel.setBuddy(&minVal);
minVal.setValidator(new QDoubleValidator(-999.0, 999.0, 3));
layoutEdit->addWidget(&minValueLabel);
if (isDateAxis)
{
minValueLabel.setBuddy(&minDate);
layoutEdit->addWidget(&minDate);
}
else
{
minValueLabel.setBuddy(&minVal);
minVal.setValidator(new QDoubleValidator(-9999.0, 9999.0, 3));
layoutEdit->addWidget(&minVal);
}

QLabel maxValueLabel("Maximum value:");
maxValueLabel.setBuddy(&maxVal);
maxVal.setValidator(new QDoubleValidator(-999.0, 999.0, 3));

layoutEdit->addWidget(&minValueLabel);
layoutEdit->addWidget(&minVal);
layoutEdit->addWidget(&maxValueLabel);
layoutEdit->addWidget(&maxVal);
if (isDateAxis)
{
minValueLabel.setBuddy(&maxDate);
layoutEdit->addWidget(&maxDate);
}
else
{
maxValueLabel.setBuddy(&maxVal);
maxVal.setValidator(new QDoubleValidator(-9999.0, 9999.0, 3));
layoutEdit->addWidget(&maxVal);
}

QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

Expand All @@ -55,16 +76,28 @@ void DialogChangeAxis::done(bool res)
{
if (res) // ok
{
if (minVal.text().isEmpty())
if (isDateAxis)
{
QMessageBox::information(nullptr, "Missing min value", "Insert min val");
return;
if (minDate.date() >= maxDate.date())
{
QMessageBox::warning(nullptr, "Wrong dates!", "Insert correct dates.");
return;
}
}
if (maxVal.text().isEmpty())
else
{
QMessageBox::information(nullptr, "Missing max value", "Insert max val");
return;
if (minVal.text().isEmpty())
{
QMessageBox::warning(nullptr, "Missing min value", "Insert minimum value.");
return;
}
if (maxVal.text().isEmpty())
{
QMessageBox::warning(nullptr, "Missing max value", "Insert maximum value.");
return;
}
}

QDialog::done(QDialog::Accepted);
return;
}
Expand All @@ -84,3 +117,13 @@ float DialogChangeAxis::getMaxVal() const
{
return maxVal.text().toFloat();
}

QDate DialogChangeAxis::getMinDate() const
{
return minDate.date();
}

QDate DialogChangeAxis::getMaxDate() const
{
return maxDate.date();
}
12 changes: 10 additions & 2 deletions agrolib/commonChartElements/dialogChangeAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@
Q_OBJECT

private:
bool isLeftAxis;
bool isDateAxis;

QDateEdit minDate;
QLineEdit minVal;

QDateEdit maxDate;
QLineEdit maxVal;

public:
DialogChangeAxis(bool isLeftAxis);
DialogChangeAxis(int nrAxis, bool isDate_);
~DialogChangeAxis() override;
void done(bool res);

float getMinVal() const;
float getMaxVal() const;

QDate getMinDate() const;
QDate getMaxDate() const;
};

#endif // DIALOGCHANGEAXIS_H
25 changes: 2 additions & 23 deletions agrolib/crit3dDate/crit3dDate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,31 +208,10 @@ Crit3DDate min(const Crit3DDate& myDate1, const Crit3DDate& myDate2)

Crit3DDate getDateFromDoy(int year, int doy)
{
if (doy < 1) return NO_DATE;
short month;

// before 29 february
if (doy <= 59)
{
month = (doy <= 31) ? 1 : 2;
return Crit3DDate(doy-doyMonth[month-1], month, year);
}

const short leap = isLeapYear(year) ? 1 : 0;
if (doy > (365 + leap)) return NO_DATE;

// 29 february
if (doy == 60 && leap == 1)
return Crit3DDate(29, 2, year);

// after
month = 3;
while (month <= 12 && doy > (doyMonth[month]+leap))
month++;

return Crit3DDate(doy-(doyMonth[month-1]+leap), month, year);
return Crit3DDate(1, 1, year).addDays(doy-1);
}


void Crit3DDate::setNullDate()
{
day = 0;
Expand Down
24 changes: 18 additions & 6 deletions agrolib/criteria1DWidget/criteria1DWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,23 @@ Criteria1DWidget::Criteria1DWidget()
waterContentGroup->setFixedWidth(this->width() * widthRatio);
carbonNitrogenGroup->setFixedWidth(this->width() * widthRatio);

infoCaseGroup->setTitle("Case");
infoCropGroup->setTitle("Crop");
QFont normalFont, boldFont;
boldFont.setBold(true);
normalFont.setBold(false);

infoCaseGroup->setFont(boldFont);
infoCaseGroup->setTitle("Case study");
infoMeteoGroup->setTitle("Meteo");
infoSoilGroup->setTitle("Soil");
infoCropGroup->setTitle("Crop");
laiParametersGroup->setTitle("Crop parameters");
rootParametersGroup->setTitle("Root parameters");
irrigationParametersGroup->setTitle("Irrigation parameters");
waterStressParametersGroup->setTitle("Water Stress parameters");
waterContentGroup->setTitle("Water Content variable");
carbonNitrogenGroup->setTitle("Carbon Nitrogen variable");

caseListComboBox.setFont(normalFont);
caseInfoLayout->addWidget(&caseListComboBox);

cropInfoLayout->addWidget(cropId, 0, 0);
Expand Down Expand Up @@ -435,9 +441,9 @@ Criteria1DWidget::Criteria1DWidget()
carbonNitrogenGroup->setLayout(carbonNitrogenLayout);

infoLayout->addWidget(infoCaseGroup);
infoLayout->addWidget(infoCropGroup);
infoLayout->addWidget(infoMeteoGroup);
infoLayout->addWidget(infoSoilGroup);
infoLayout->addWidget(infoCropGroup);
infoLayout->addWidget(laiParametersGroup);
infoLayout->addWidget(rootParametersGroup);
infoLayout->addWidget(irrigationParametersGroup);
Expand Down Expand Up @@ -594,6 +600,7 @@ void Criteria1DWidget::on_actionOpenProject()
this->lastYearListComboBox.blockSignals(false);

openComputationUnitsDB(myProject.dbComputationUnitsName);

viewMenu->setEnabled(true);
if (soilListComboBox.count() == 0)
{
Expand Down Expand Up @@ -1053,15 +1060,20 @@ void Criteria1DWidget::on_actionChooseCase()
// METEO
meteoListComboBox.setCurrentText(myProject.myCase.unit.idMeteo);

// CROP
// CROP ID
myProject.myCase.unit.idCrop = getIdCropFromClass(myProject.dbCrop, "crop_class", "id_class", myProject.myCase.unit.idCropClass, errorStr);
if (myProject.myCase.unit.idCrop != "")
if (myProject.myCase.unit.idCrop == "")
{
// it is a single crop, not a crop class
myProject.myCase.unit.idCrop = myProject.myCase.unit.idCropClass;
}
if ( cropListComboBox.findText(myProject.myCase.unit.idCrop) != -1 )
{
cropListComboBox.setCurrentText(myProject.myCase.unit.idCrop);
}
else
{
QMessageBox::critical(nullptr, "Error!", "Missing crop class: " + myProject.myCase.unit.idCropClass + "\n" + errorStr);
QMessageBox::critical(nullptr, "Error!", "Missing crop: " + myProject.myCase.unit.idCropClass + "\n" + errorStr);
}

// SOIL
Expand Down
Loading

0 comments on commit 9b3a5b7

Please sign in to comment.