From 116bb60ea40c12d8691207fae79b05892df6f674 Mon Sep 17 00:00:00 2001 From: ftomei Date: Sun, 7 Jul 2024 16:47:11 +0200 Subject: [PATCH] update meteoWidget --- gis/gisIO.cpp | 2 +- graphics/stationMarker.cpp | 209 ++++++++++++++----------------- graphics/stationMarker.h | 46 +++++-- meteoWidget/dialogMeteoTable.cpp | 1 - meteoWidget/meteoWidget.cpp | 54 ++++++-- meteoWidget/meteoWidget.h | 2 + project/project.cpp | 8 +- soil/soil.cpp | 2 +- soilWidget/soilWidget.cpp | 2 +- soilWidget/soilWidget.pro | 1 - 10 files changed, 184 insertions(+), 143 deletions(-) diff --git a/gis/gisIO.cpp b/gis/gisIO.cpp index d09fda699..c4e829841 100644 --- a/gis/gisIO.cpp +++ b/gis/gisIO.cpp @@ -571,7 +571,7 @@ namespace gis } myFile << "ENVI\n"; - myFile << "description = {CRITERIA3D raster grid}\n"; + myFile << "description = {raster grid}\n"; myFile << "samples = " << rasterGrid->header->nrCols << "\n"; myFile << "lines = " << rasterGrid->header->nrRows << "\n"; myFile << "bands = 1\n"; diff --git a/graphics/stationMarker.cpp b/graphics/stationMarker.cpp index 233edb7dc..7faae0389 100644 --- a/graphics/stationMarker.cpp +++ b/graphics/stationMarker.cpp @@ -12,64 +12,18 @@ StationMarker::StationMarker(qreal radius,bool sizeIsZoomInvariant, QColor fillC this->setFlag(MapGraphicsObject::ObjectIsSelectable, false); this->setFlag(MapGraphicsObject::ObjectIsMovable, false); this->setFlag(MapGraphicsObject::ObjectIsFocusable, false); + _id = ""; _name = ""; _dataset = ""; + _municipality = ""; _altitude = NODATA; _lapseRateCode = primary; - _municipality = ""; - _active = true; -} - -void StationMarker::setId(std::string id) -{ - _id = id; -} - -std::string StationMarker::id() const -{ - return _id; -} - -void StationMarker::setName(const std::string &name) -{ - _name = name; -} - -void StationMarker::setDataset(const std::string &dataset) -{ - _dataset = dataset; -} - -void StationMarker::setAltitude(double altitude) -{ - _altitude = altitude; -} - -void StationMarker::setLapseRateCode(lapseRateCodeType code) -{ - _lapseRateCode = code; -} - -void StationMarker::setMunicipality(const std::string &municipality) -{ - _municipality = municipality; -} - -void StationMarker::setQuality(const quality::qualityType &quality) -{ - _quality = quality; -} -bool StationMarker::active() const -{ - return _active; + _caller = PRAGA_caller; + _active = true; } -void StationMarker::setActive(bool active) -{ - _active = active; -} void StationMarker::setToolTip() { @@ -109,74 +63,101 @@ void StationMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::RightButton) { - bool isGrid = false; - QMenu menu; - QAction *openMeteoWidget = menu.addAction("Open new meteo widget"); - QAction *appendMeteoWidget = menu.addAction("Append to last meteo widget"); - menu.addSeparator(); - QAction *openPointStatisticsWidget = menu.addAction("Open point statistics widget"); - QAction *openHomogeneityWidget = menu.addAction("Open homogeneity test widget"); - menu.addSeparator(); - QAction *openSynchronicityWidget = menu.addAction("Open synchronicity test widget"); - QAction *setSynchronicityReferencePoint = menu.addAction("Set as synchronicity reference point"); - menu.addSeparator(); - QMenu *orogCodeSubMenu; - orogCodeSubMenu = menu.addMenu("Orog code"); - QAction *actionOrogCode_primary = orogCodeSubMenu->addAction( "Set as primary station" ); - QAction *actionOrogCode_secondary = orogCodeSubMenu->addAction( "Set as secondary station" ); - QAction *actionOrogCode_supplemental = orogCodeSubMenu->addAction( "Set as supplemental station" ); - menu.addSeparator(); - QAction *actionMarkPoint = menu.addAction( "Mark point" ); - QAction *actionUnmarkPoint = menu.addAction( "Unmark point" ); - - QAction *selection = menu.exec(QCursor::pos()); - - if (selection != nullptr) + if (_caller == PRAGA_caller) { - std::string lapseRateCode = getLapseRateCodeName(_lapseRateCode); - if (selection == openMeteoWidget) - { - emit newStationClicked(_id, _name, _dataset, _altitude, lapseRateCode, isGrid); - } - else if (selection == appendMeteoWidget) - { - emit appendStationClicked(_id, _name, _dataset, _altitude, lapseRateCode, isGrid); - } - else if (selection == openPointStatisticsWidget) - { - emit newPointStatisticsClicked(_id, isGrid); - } - else if (selection == openHomogeneityWidget) - { - emit newHomogeneityTestClicked(_id); - } - else if (selection == openSynchronicityWidget) - { - emit newSynchronicityTestClicked(_id); - } - else if (selection == setSynchronicityReferencePoint) - { - emit setSynchronicityReferenceClicked(_id); - } - else if (selection == actionOrogCode_primary) - { - emit changeOrogCodeClicked(_id, 0); - } - else if (selection == actionOrogCode_secondary) - { - emit changeOrogCodeClicked(_id, 1); - } - else if (selection == actionOrogCode_supplemental) + QMenu menu; + QAction *openMeteoWidget = menu.addAction("Open a new meteo widget"); + QAction *appendMeteoWidget = menu.addAction("Append to the lastest meteo widget"); + menu.addSeparator(); + QAction *openPointStatisticsWidget = menu.addAction("Open point statistics widget"); + QAction *openHomogeneityWidget = menu.addAction("Open homogeneity test widget"); + menu.addSeparator(); + QAction *openSynchronicityWidget = menu.addAction("Open synchronicity test widget"); + QAction *setSynchronicityReferencePoint = menu.addAction("Set as synchronicity reference point"); + menu.addSeparator(); + QAction *actionMarkPoint = menu.addAction( "Mark point" ); + QAction *actionUnmarkPoint = menu.addAction( "Unmark point" ); + menu.addSeparator(); + QMenu *orogCodeSubMenu; + orogCodeSubMenu = menu.addMenu("Orog code"); + QAction *actionOrogCode_primary = orogCodeSubMenu->addAction( "Set as primary station" ); + QAction *actionOrogCode_secondary = orogCodeSubMenu->addAction( "Set as secondary station" ); + QAction *actionOrogCode_supplemental = orogCodeSubMenu->addAction( "Set as supplemental station" ); + + QAction *selection = menu.exec(QCursor::pos()); + + if (selection != nullptr) { - emit changeOrogCodeClicked(_id, 2); + bool isGrid = false; + std::string lapseRateCode = getLapseRateCodeName(_lapseRateCode); + if (selection == openMeteoWidget) + { + emit newStationClicked(_id, _name, _dataset, _altitude, lapseRateCode, isGrid); + } + else if (selection == appendMeteoWidget) + { + emit appendStationClicked(_id, _name, _dataset, _altitude, lapseRateCode, isGrid); + } + else if (selection == openPointStatisticsWidget) + { + emit newPointStatisticsClicked(_id, isGrid); + } + else if (selection == openHomogeneityWidget) + { + emit newHomogeneityTestClicked(_id); + } + else if (selection == openSynchronicityWidget) + { + emit newSynchronicityTestClicked(_id); + } + else if (selection == setSynchronicityReferencePoint) + { + emit setSynchronicityReferenceClicked(_id); + } + else if (selection == actionOrogCode_primary) + { + emit changeOrogCodeClicked(_id, 0); + } + else if (selection == actionOrogCode_secondary) + { + emit changeOrogCodeClicked(_id, 1); + } + else if (selection == actionOrogCode_supplemental) + { + emit changeOrogCodeClicked(_id, 2); + } + else if (selection == actionMarkPoint) + { + emit markPoint(_id); + } + else if (selection == actionUnmarkPoint) + { + emit unmarkPoint(_id); + } } - else if (selection == actionMarkPoint) - { - emit markPoint(_id); - } - else if (selection == actionUnmarkPoint) + } + else + { + // Other Software + QMenu menu; + QAction *openMeteoWidget = menu.addAction("Open a new meteo widget"); + QAction *appendMeteoWidget = menu.addAction("Append to the lastest meteo widget"); + menu.addSeparator(); + + QAction *selection = menu.exec(QCursor::pos()); + + if (selection != nullptr) { - emit unmarkPoint(_id); + bool isGrid = false; + std::string lapseRateCode = getLapseRateCodeName(_lapseRateCode); + if (selection == openMeteoWidget) + { + emit newStationClicked(_id, _name, _dataset, _altitude, lapseRateCode, isGrid); + } + else if (selection == appendMeteoWidget) + { + emit appendStationClicked(_id, _name, _dataset, _altitude, lapseRateCode, isGrid); + } } } } diff --git a/graphics/stationMarker.h b/graphics/stationMarker.h index 84171b4fa..c98841de0 100644 --- a/graphics/stationMarker.h +++ b/graphics/stationMarker.h @@ -5,36 +5,58 @@ #include "CircleObject.h" #include "MapGraphicsView.h" #include "quality.h" + #include "meteo.h" class Crit3DMeteoPoint; + enum callerSoftware{PRAGA_caller, CRITERIA3D_caller, other_caller}; + class StationMarker : public CircleObject { Q_OBJECT public: explicit StationMarker(qreal radius, bool sizeIsZoomInvariant, QColor fillColor, MapGraphicsObject *parent = nullptr); - void setId(std::string id); + void setToolTip(); - std::string id() const; - void setName(const std::string &name); - void setDataset(const std::string &dataset); - void setAltitude(double altitude); - void setLapseRateCode(lapseRateCodeType code); - void setMunicipality(const std::string &municipality); - void setQuality(const quality::qualityType &quality); - bool active() const; - void setActive(bool active); + + void setId(std::string id) { _id = id; } + std::string id() const { return _id; } + + bool active() const { return _active; } + void setActive(bool active) { _active = active; } + + void setName(const std::string &name) { _name = name; } + + void setDataset(const std::string &dataset) { _dataset = dataset; } + + void setAltitude(double altitude) { _altitude = altitude; } + + void setCallerSoftware(callerSoftware caller) + { _caller = caller;} + + void setLapseRateCode(lapseRateCodeType code) + { _lapseRateCode = code; } + + void setMunicipality(const std::string &municipality) + { _municipality = municipality; } + + void setQuality(const quality::qualityType &quality) + { _quality = quality; } private: std::string _id; std::string _name; std::string _dataset; - double _altitude; - lapseRateCodeType _lapseRateCode; std::string _municipality; + + double _altitude; float _currentValue; + + lapseRateCodeType _lapseRateCode; quality::qualityType _quality; + callerSoftware _caller; + bool _active; protected: diff --git a/meteoWidget/dialogMeteoTable.cpp b/meteoWidget/dialogMeteoTable.cpp index cfc30f94b..7bafccb0f 100644 --- a/meteoWidget/dialogMeteoTable.cpp +++ b/meteoWidget/dialogMeteoTable.cpp @@ -31,7 +31,6 @@ DialogMeteoTable::DialogMeteoTable(Crit3DMeteoSettings *meteoSettings_, QVector< QVBoxLayout* mainLayout = new QVBoxLayout; this->resize(800, 600); - meteoTable = new MeteoTable(); mainLayout->addWidget(meteoTable); diff --git a/meteoWidget/meteoWidget.cpp b/meteoWidget/meteoWidget.cpp index 079031f49..20e0e43a3 100644 --- a/meteoWidget/meteoWidget.cpp +++ b/meteoWidget/meteoWidget.cpp @@ -1,24 +1,29 @@ /*! - CRITERIA3D - \copyright 2016 Fausto Tomei, Gabriele Antolini, Laura Costantini - Alberto Pistocchi, Marco Bittelli, Antonio Volta - You should have received a copy of the GNU General Public License - along with Nome-Programma. If not, see . + \file meteoWidget.cpp + + \abstract this widget displays hourly or daily weather data sets + + \copyright This file is part of CRITERIA3D. - CRITERIA3D has been developed under contract issued by A.R.P.A. Emilia-Romagna + CRITERIA3D has been developed by ARPAE Emilia-Romagna. + CRITERIA3D is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + CRITERIA3D is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the /NU Lesser General Public License + + You should have received a copy of the GNU Lesser General Public License along with CRITERIA3D. If not, see . - contacts: - fausto.tomei@gmail.com - ftomei@arpae.it + + \authors + Laura Costantini + Fausto Tomei ftomei@arpae.it + Gabriele Antolini gantolini@arpae.it */ @@ -117,7 +122,7 @@ Crit3DMeteoWidget::Crit3DMeteoWidget(bool isGrid_, QString projectPath, Crit3DMe currentVariables.clear(); QTextStream in(&fileDefaultGraph); in.readLine(); //skip first line - while (!in.atEnd()) + while (! in.atEnd()) { QString line = in.readLine(); QList items = line.split(","); @@ -198,6 +203,7 @@ Crit3DMeteoWidget::Crit3DMeteoWidget(bool isGrid_, QString projectPath, Crit3DMe hourlyVar = hourlyVar+1; } } + if (currentVariables.isEmpty() || (dailyVar != 0 && hourlyVar != 0)) { QMessageBox::information(nullptr, "Warning", "Wrong variables in Crit3DPlotDefault.csv"); @@ -415,6 +421,32 @@ Crit3DMeteoWidget::~Crit3DMeteoWidget() } +void Crit3DMeteoWidget::setCurrentFrequency(frequencyType frequency) +{ + currentFreq = frequency; + + // update gui + if (currentFreq == daily || currentFreq == noFrequency) + { + dailyButton->setEnabled(false); + hourlyButton->setEnabled(true); + monthlyButton->setEnabled(true); + } + else if (currentFreq == hourly) + { + hourlyButton->setEnabled(false); + dailyButton->setEnabled(true); + monthlyButton->setEnabled(true); + } + else if (currentFreq == monthly) + { + monthlyButton->setEnabled(false); + dailyButton->setEnabled(true); + hourlyButton->setEnabled(true); + } +} + + void Crit3DMeteoWidget::setDailyRange(QDate firstDate, QDate lastDate) { firstDailyDate = firstDate; diff --git a/meteoWidget/meteoWidget.h b/meteoWidget/meteoWidget.h index 447bc5c86..2186dfeae 100644 --- a/meteoWidget/meteoWidget.h +++ b/meteoWidget/meteoWidget.h @@ -24,6 +24,8 @@ bool getIsEnsemble() { return isEnsemble; } void setNrMembers(int value) { nrMembers = value; } + void setCurrentFrequency(frequencyType frequency); + void setDailyRange(QDate firstDate, QDate lastDate); void setHourlyRange(QDate firstDate, QDate lastDate); void setMonthlyRange(QDate firstDate, QDate lastDate); diff --git a/project/project.cpp b/project/project.cpp index d21de05dc..695b3e12d 100644 --- a/project/project.cpp +++ b/project/project.cpp @@ -3388,7 +3388,7 @@ void Project::showMeteoWidgetPoint(std::string idMeteoPoint, std::string namePoi { bool isGrid = false; Crit3DMeteoWidget* meteoWidgetPoint = new Crit3DMeteoWidget(isGrid, projectPath, meteoSettings); - if (!meteoWidgetPointList.isEmpty()) + if (! meteoWidgetPointList.isEmpty()) { meteoWidgetId = meteoWidgetPointList[meteoWidgetPointList.size()-1]->getMeteoWidgetID()+1; } @@ -3396,6 +3396,7 @@ void Project::showMeteoWidgetPoint(std::string idMeteoPoint, std::string namePoi { meteoWidgetId = 0; } + meteoWidgetPoint->setMeteoWidgetID(meteoWidgetId); meteoWidgetPointList.append(meteoWidgetPoint); QObject::connect(meteoWidgetPoint, SIGNAL(closeWidgetPoint(int)), this, SLOT(deleteMeteoWidgetPoint(int))); @@ -3405,10 +3406,15 @@ void Project::showMeteoWidgetPoint(std::string idMeteoPoint, std::string namePoi if (hasDailyData) { meteoWidgetPoint->setDailyRange(firstDaily, lastDaily); + meteoWidgetPoint->setCurrentFrequency(daily); } if (hasHourlyData) { meteoWidgetPoint->setHourlyRange(firstHourly.date(), lastHourly.date()); + if (! hasDailyData) + { + meteoWidgetPoint->setCurrentFrequency(hourly); + } } meteoWidgetPoint->setCurrentDate(this->currentDate); diff --git a/soil/soil.cpp b/soil/soil.cpp index 712798936..05ef72892 100644 --- a/soil/soil.cpp +++ b/soil/soil.cpp @@ -1,5 +1,5 @@ /*! - CRITERIA3D + soil.cpp \copyright 2016 Fausto Tomei, Gabriele Antolini, Alberto Pistocchi, Marco Bittelli, Antonio Volta, Laura Costantini diff --git a/soilWidget/soilWidget.cpp b/soilWidget/soilWidget.cpp index 379c62782..be2d07359 100644 --- a/soilWidget/soilWidget.cpp +++ b/soilWidget/soilWidget.cpp @@ -1,5 +1,5 @@ /*! - CRITERIA3D + soilWidget.cpp \copyright 2016 Fausto Tomei, Gabriele Antolini, Laura Costantini Alberto Pistocchi, Marco Bittelli, Antonio Volta diff --git a/soilWidget/soilWidget.pro b/soilWidget/soilWidget.pro index 6b695bf1f..497dd6004 100644 --- a/soilWidget/soilWidget.pro +++ b/soilWidget/soilWidget.pro @@ -3,7 +3,6 @@ # Soil Widget library # This project is part of CRITERIA-3D distribution # -# #---------------------------------------------------- QT += widgets sql charts