Skip to content

Commit

Permalink
Merge commit '731db4f685513712036cbd81d66bab2896da23b2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Mar 11, 2024
2 parents b886f4d + 731db4f commit d9c84b1
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 5 deletions.
59 changes: 59 additions & 0 deletions agrolib/meteoWidget/dialogVariableToSum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "dialogVariableToSum.h"

DialogVariableToSum::DialogVariableToSum(QList<QString> variableList)
: variableList(variableList)
{
setWindowTitle("Choose variable to sum");
this->resize(400, 200);
QVBoxLayout *mainLayout = new QVBoxLayout();
QVBoxLayout *variableLayout = new QVBoxLayout;
QHBoxLayout *layoutOk = new QHBoxLayout;
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

layoutOk->addWidget(&buttonBox);
for (int i = 0; i<variableList.size(); i++)
{
QCheckBox* checkbox = new QCheckBox(variableList[i], this);
checkList.append(checkbox);
variableLayout->addWidget(checkbox);
}

mainLayout->addLayout(variableLayout);
mainLayout->addLayout(layoutOk);
setLayout(mainLayout);

connect(&buttonBox, &QDialogButtonBox::accepted, [=](){ this->done(true); });
connect(&buttonBox, &QDialogButtonBox::rejected, [=](){ this->done(false); });

show();
exec();

}

void DialogVariableToSum::done(bool res)
{
if (res)
{
foreach (QCheckBox *checkBox, checkList)
{
if (checkBox->isChecked())
{
selectedVariable.append(checkBox->text());
}
}
QDialog::done(QDialog::Accepted);
return;
}
else // cancel, close or exc was pressed
{
QDialog::done(QDialog::Rejected);
return;
}
}

QList<QString> DialogVariableToSum::getSelectedVariable()
{
return selectedVariable;
}


21 changes: 21 additions & 0 deletions agrolib/meteoWidget/dialogVariableToSum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef DIALOGVARIABLETOSUM_H
#define DIALOGVARIABLETOSUM_H

#include <QtWidgets>

class DialogVariableToSum : public QDialog
{
Q_OBJECT

private:
QList<QString> variableList;
QList<QString> selectedVariable;
QList<QCheckBox*> checkList;

public:
DialogVariableToSum(QList<QString> variableList);
QList<QString> getSelectedVariable();
void done(bool res);
};

#endif // DIALOGVARIABLETOSUM_H
35 changes: 30 additions & 5 deletions agrolib/meteoWidget/meteoWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "dialogRemoveStation.h"
#include "dialogMeteoTable.h"
#include "dialogChangeAxis.h"
#include "dialogVariableToSum.h"
#include "utilities.h"
#include "commonConstants.h"
#include "formInfo.h"
Expand Down Expand Up @@ -777,7 +778,11 @@ void Crit3DMeteoWidget::drawEnsembleDailyVar()
{
sortedList.clear();
myDate = firstCrit3DDate.addDays(day);
meteoVariable meteoVar = MapDailyMeteoVar.at(nameLines[i].toStdString());
meteoVariable meteoVar = getMeteoVar(nameLines[i].toStdString());
if (meteoVar == noMeteoVar)
{
continue;
}

for (int mp=0; mp<nrMembers;mp++)
{
Expand Down Expand Up @@ -840,7 +845,11 @@ void Crit3DMeteoWidget::drawEnsembleDailyVar()
for (int day = 0; day < nDays; day++)
{
myDate = firstCrit3DDate.addDays(day);
meteoVariable meteoVar = MapDailyMeteoVar.at(nameBar[i].toStdString());
meteoVariable meteoVar = getMeteoVar(nameBar[i].toStdString());
if (meteoVar == noMeteoVar)
{
continue;
}
sortedList.clear();
for (int mp=0; mp<nrMembers;mp++)
{
Expand Down Expand Up @@ -1008,7 +1017,11 @@ void Crit3DMeteoWidget::drawDailyVar()
{
for (int i = 0; i < nameLines.size(); i++)
{
meteoVariable meteoVar = MapDailyMeteoVar.at(nameLines[i].toStdString());
meteoVariable meteoVar = getMeteoVar(nameLines[i].toStdString());
if (meteoVar == noMeteoVar)
{
continue;
}
double value = meteoPoints[mp].getMeteoPointValueD(myDate, meteoVar, meteoSettings);
if (value != NODATA)
{
Expand All @@ -1035,7 +1048,11 @@ void Crit3DMeteoWidget::drawDailyVar()
{
for (int j = 0; j < nameBar.size(); j++)
{
meteoVariable meteoVar = MapDailyMeteoVar.at(nameBar[j].toStdString());
meteoVariable meteoVar = getMeteoVar(nameBar[j].toStdString());
if (meteoVar == noMeteoVar)
{
continue;
}
double value = meteoPoints[mp].getMeteoPointValueD(myDate, meteoVar, meteoSettings);
if (value != NODATA)
{
Expand Down Expand Up @@ -1564,7 +1581,7 @@ void Crit3DMeteoWidget::showHourlyGraph()
auto searchDaily = MapDailyMeteoVar.find(name.toStdString());
if (searchDaily != MapDailyMeteoVar.end())
{
meteoVariable dailyVar = MapDailyMeteoVar.at(name.toStdString());
meteoVariable dailyVar = getMeteoVar(name.toStdString());
meteoVariable hourlyVar= updateMeteoVariable(dailyVar, hourly);
if (hourlyVar != noMeteoVar)
{
Expand Down Expand Up @@ -2297,6 +2314,14 @@ void Crit3DMeteoWidget::on_actionDataSum()
{
// TO DO;
// Apre una finestra con l'elenco delle variabili attualmente visualizzate in modo che siano selezionabili quali vogliamo switchare sulla comulata
DialogVariableToSum varToSum(currentVariables);
QList<QString> varToSumList;
if (varToSum.result() == QDialog::Accepted)
{
varToSumList = varToSum.getSelectedVariable();
}
qDebug() << "varToSumList " << varToSumList.join(",");

}


Expand Down
2 changes: 2 additions & 0 deletions agrolib/meteoWidget/meteoWidget.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SOURCES += \
dialogMeteoTable.cpp \
dialogRemoveStation.cpp \
dialogSelectVar.cpp \
dialogVariableToSum.cpp \
meteoTable.cpp \
meteoWidget.cpp

Expand All @@ -47,6 +48,7 @@ HEADERS += \
dialogMeteoTable.h \
dialogRemoveStation.h \
dialogSelectVar.h \
dialogVariableToSum.h \
meteoTable.h \
meteoWidget.h

Expand Down

0 comments on commit d9c84b1

Please sign in to comment.