diff --git a/agrolib/criteriaOutput/criteriaOutput.pro b/agrolib/criteriaOutput/criteriaOutput.pro index 8583c884..55d48f93 100644 --- a/agrolib/criteriaOutput/criteriaOutput.pro +++ b/agrolib/criteriaOutput/criteriaOutput.pro @@ -40,23 +40,24 @@ DEFINES += QT_DEPRECATED_WARNINGS DEFINES += _CRT_SECURE_NO_WARNINGS +INCLUDEPATH += ../crit3dDate ../mathFunctions ../gis ../utilities \ + ../shapeHandler ../netcdfHandler ../shapeUtilities + SOURCES += \ - ../../agrolib/crop/cropDbQuery.cpp \ + ../crop/cropDbQuery.cpp \ criteriaAggregationVariable.cpp \ criteriaOutputElaboration.cpp \ criteriaOutputProject.cpp \ criteriaOutputVariable.cpp HEADERS += \ + ../crop/cropDbQuery.h \ criteriaAggregationVariable.h \ criteriaOutputElaboration.h \ criteriaOutputProject.h \ criteriaOutputVariable.h -INCLUDEPATH += ../crit3dDate ../mathFunctions ../crop ../gis \ - ../utilities ../shapeHandler ../netcdfHandler ../shapeUtilities - # comment to compile without GDAL library CONFIG += GDAL diff --git a/agrolib/criteriaOutput/criteriaOutputElaboration.cpp b/agrolib/criteriaOutput/criteriaOutputElaboration.cpp index 5d948518..4ca7d67b 100644 --- a/agrolib/criteriaOutput/criteriaOutputElaboration.cpp +++ b/agrolib/criteriaOutput/criteriaOutputElaboration.cpp @@ -3,7 +3,7 @@ #include "commonConstants.h" #include "basicMath.h" #include "utilities.h" -#include "cropDbQuery.h" +#include "../crop/cropDbQuery.h" #include #include diff --git a/agrolib/shapeUtilities/unitCropMap.cpp b/agrolib/shapeUtilities/unitCropMap.cpp index 5afe7c00..ee830198 100644 --- a/agrolib/shapeUtilities/unitCropMap.cpp +++ b/agrolib/shapeUtilities/unitCropMap.cpp @@ -9,16 +9,16 @@ #include -bool computeUcmPrevailing(Crit3DShapeHandler &ucm, Crit3DShapeHandler &crop, Crit3DShapeHandler &soil, Crit3DShapeHandler &meteo, +bool computeUcmPrevailing(Crit3DShapeHandler &shapeUCM, Crit3DShapeHandler &shapeCrop, Crit3DShapeHandler &shapeSoil, Crit3DShapeHandler &shapeMeteo, std::string idCrop, std::string idSoil, std::string idMeteo, double cellSize, double threshold, QString ucmFileName, std::string &error, bool showInfo) { // make a copy of crop shapefile (reference) and return cloned shapefile complete path - QString refFileName = QString::fromStdString(crop.getFilepath()); + QString refFileName = QString::fromStdString(shapeCrop.getFilepath()); QString ucmShapeFileName = cloneShapeFile(refFileName, ucmFileName); - if (!ucm.open(ucmShapeFileName.toStdString())) + if (!shapeUCM.open(ucmShapeFileName.toStdString())) { error = "Load shapefile failed: " + ucmShapeFileName.toStdString(); return false; @@ -27,37 +27,37 @@ bool computeUcmPrevailing(Crit3DShapeHandler &ucm, Crit3DShapeHandler &crop, Cri // create reference and value raster gis::Crit3DRasterGrid rasterRef; gis::Crit3DRasterGrid rasterVal; - initializeRasterFromShape(ucm, rasterRef, cellSize); - initializeRasterFromShape(ucm, rasterVal, cellSize); + initializeRasterFromShape(shapeUCM, rasterRef, cellSize); + initializeRasterFromShape(shapeUCM, rasterVal, cellSize); FormInfo formInfo; // CROP (reference shape) if (showInfo) formInfo.start("[1/8] Rasterize crop (reference)...", 0); - fillRasterWithShapeNumber(rasterRef, ucm); + fillRasterWithShapeNumber(rasterRef, shapeUCM); // meteo grid if (showInfo) formInfo.setText("[2/8] Rasterize meteo grid..."); - fillRasterWithShapeNumber(rasterVal, meteo); + fillRasterWithShapeNumber(rasterVal, shapeMeteo); if (showInfo) formInfo.setText("[3/8] Compute matrix crop/meteo..."); std::vector vectorNull; - std::vector > matrix = computeMatrixAnalysis(ucm, meteo, rasterRef, rasterVal, vectorNull); + std::vector > matrix = computeMatrixAnalysis(shapeUCM, shapeMeteo, rasterRef, rasterVal, vectorNull); if (showInfo) formInfo.setText("[4/8] Zonal statistic crop/meteo..."); - bool isOk = zonalStatisticsShapeMajority(ucm, meteo, matrix, vectorNull, idMeteo, "ID_METEO", threshold, error); + bool isOk = zonalStatisticsShapeMajority(shapeUCM, shapeMeteo, matrix, vectorNull, idMeteo, "ID_METEO", threshold, error); // zonal statistic on soil map if (isOk) { if (showInfo) formInfo.setText("[5/8] Rasterize soil..."); - fillRasterWithShapeNumber(rasterVal, soil); + fillRasterWithShapeNumber(rasterVal, shapeSoil); if (showInfo) formInfo.setText("[6/8] Compute matrix crop/soil..."); - matrix = computeMatrixAnalysis(ucm, soil, rasterRef, rasterVal, vectorNull); + matrix = computeMatrixAnalysis(shapeUCM, shapeSoil, rasterRef, rasterVal, vectorNull); if (showInfo) formInfo.setText("[7/8] Zonal statistic crop/soil..."); - isOk = zonalStatisticsShapeMajority(ucm, soil, matrix, vectorNull, idSoil, "ID_SOIL", threshold, error); + isOk = zonalStatisticsShapeMajority(shapeUCM, shapeSoil, matrix, vectorNull, idSoil, "ID_SOIL", threshold, error); } if (! isOk) @@ -79,29 +79,29 @@ bool computeUcmPrevailing(Crit3DShapeHandler &ucm, Crit3DShapeHandler &crop, Cri if (showInfo) formInfo.setText("[8/8] Write UCM..."); // add ID CASE - ucm.addField("ID_CASE", FTString, 20, 0); - int idCaseIndex = ucm.getFieldPos("ID_CASE"); + shapeUCM.addField("ID_CASE", FTString, 20, 0); + int idCaseIndex = shapeUCM.getFieldPos("ID_CASE"); // add ID CROP - bool existIdCrop = ucm.existField("ID_CROP"); - if (! existIdCrop) ucm.addField("ID_CROP", FTString, 5, 0); - int idCropIndex = ucm.getFieldPos("ID_CROP"); + bool existIdCrop = shapeUCM.existField("ID_CROP"); + if (! existIdCrop) shapeUCM.addField("ID_CROP", FTString, 5, 0); + int idCropIndex = shapeUCM.getFieldPos("ID_CROP"); // read indexes - int nShape = ucm.getShapeCount(); - int cropIndex = ucm.getFieldPos(idCrop); + int nShape = shapeUCM.getShapeCount(); + int cropIndex = shapeUCM.getFieldPos(idCrop); if(cropIndex == -1) { error = "Missing idCrop: " + idCrop; return false; } - int soilIndex = ucm.getFieldPos("ID_SOIL"); + int soilIndex = shapeUCM.getFieldPos("ID_SOIL"); if(soilIndex == -1) { error = "Missing idSoil: " + idSoil; return false; } - int meteoIndex = ucm.getFieldPos("ID_METEO"); + int meteoIndex = shapeUCM.getFieldPos("ID_METEO"); if(meteoIndex == -1) { error = "Missing idMeteo: " + idMeteo; @@ -111,28 +111,28 @@ bool computeUcmPrevailing(Crit3DShapeHandler &ucm, Crit3DShapeHandler &crop, Cri // FILL ID_CROP and ID_CASE for (int shapeIndex = 0; shapeIndex < nShape; shapeIndex++) { - std::string cropStr = ucm.readStringAttribute(shapeIndex, cropIndex); + std::string cropStr = shapeUCM.readStringAttribute(shapeIndex, cropIndex); if (cropStr == "-9999") cropStr = ""; - std::string soilStr = ucm.readStringAttribute(shapeIndex, soilIndex); + std::string soilStr = shapeUCM.readStringAttribute(shapeIndex, soilIndex); if (soilStr == "-9999") soilStr = ""; - std::string meteoStr = ucm.readStringAttribute(shapeIndex, meteoIndex); + std::string meteoStr = shapeUCM.readStringAttribute(shapeIndex, meteoIndex); if (meteoStr == "-9999") meteoStr = ""; std::string caseStr = ""; if (meteoStr != "" && soilStr != "" && cropStr != "") caseStr = "M" + meteoStr + "S" + soilStr + "C" + cropStr; - if (! existIdCrop) ucm.writeStringAttribute(shapeIndex, idCropIndex, cropStr.c_str()); - ucm.writeStringAttribute(shapeIndex, idCaseIndex, caseStr.c_str()); + if (! existIdCrop) shapeUCM.writeStringAttribute(shapeIndex, idCropIndex, cropStr.c_str()); + shapeUCM.writeStringAttribute(shapeIndex, idCaseIndex, caseStr.c_str()); if (caseStr == "") - ucm.deleteRecord(shapeIndex); + shapeUCM.deleteRecord(shapeIndex); } if (showInfo) formInfo.close(); - cleanShapeFile(ucm); + cleanShapeFile(shapeUCM); return isOk; } diff --git a/agrolib/shapeUtilities/unitCropMap.h b/agrolib/shapeUtilities/unitCropMap.h index c6e92712..f50425d7 100644 --- a/agrolib/shapeUtilities/unitCropMap.h +++ b/agrolib/shapeUtilities/unitCropMap.h @@ -6,7 +6,8 @@ #endif #include - bool computeUcmPrevailing(Crit3DShapeHandler &ucm, Crit3DShapeHandler &crop, Crit3DShapeHandler &soil, Crit3DShapeHandler &meteo, + bool computeUcmPrevailing(Crit3DShapeHandler &shapeUCM, Crit3DShapeHandler &shapeCrop, + Crit3DShapeHandler &shapeSoil, Crit3DShapeHandler &shapeMeteo, std::string idCrop, std::string idSoil, std::string idMeteo, double cellSize, double threshold, QString ucmFileName, std::string &error, bool showInfo); diff --git a/agrolib/utilities/computationUnitsDb.h b/agrolib/utilities/computationUnitsDb.h index 16542290..dbeefa7c 100644 --- a/agrolib/utilities/computationUnitsDb.h +++ b/agrolib/utilities/computationUnitsDb.h @@ -1,6 +1,6 @@ /*! -* \brief computation unit for CRITERIA-1D -* \note Unit = distinct combination of crop, soil and meteo +* \brief computational unit for CRITERIA-1D +* \note computational unit = distinct combination of crop, soil and meteo */ #ifndef COMPUTATIONUNITSDB_H diff --git a/bin/CRITERIAGEO/CRITERIAGEO.pro b/bin/CRITERIAGEO/CRITERIAGEO.pro index fe9bb190..635380e3 100644 --- a/bin/CRITERIAGEO/CRITERIAGEO.pro +++ b/bin/CRITERIAGEO/CRITERIAGEO.pro @@ -36,7 +36,7 @@ win32:{ } INCLUDEPATH += ../../mapGraphics \ - ../../agrolib/crit3dDate ../../agrolib/mathFunctions ../../agrolib/gis ../../agrolib/crop \ + ../../agrolib/crit3dDate ../../agrolib/mathFunctions ../../agrolib/gis ../../agrolib/meteo \ ../../agrolib/utilities ../../agrolib/shapeUtilities \ ../../agrolib/shapeHandler ../../agrolib/shapeHandler/shapelib ../../agrolib/netcdfHandler \ ../../agrolib/criteriaOutput ../../agrolib/graphics ../../agrolib/commonDialogs @@ -62,6 +62,7 @@ CONFIG(debug, debug|release) { LIBS += -L../../mapGraphics/debug -lMapGraphics LIBS += -L../../agrolib/commonDialogs/debug -lcommonDialogs + LIBS += -L../../agrolib/graphics/debug -lgraphics LIBS += -L../../agrolib/criteriaOutput/debug -lcriteriaOutput LIBS += -L../../agrolib/netcdfHandler/debug -lnetcdfHandler win32:{ @@ -76,6 +77,7 @@ CONFIG(debug, debug|release) { LIBS += -L../../agrolib/shapeUtilities/debug -lshapeUtilities LIBS += -L../../agrolib/shapeHandler/debug -lshapeHandler LIBS += -L../../agrolib/utilities/debug -lutilities + LIBS += -L../../agrolib/meteo/debug -lmeteo LIBS += -L../../agrolib/gis/debug -lgis LIBS += -L../../agrolib/crit3dDate/debug -lcrit3dDate LIBS += -L../../agrolib/mathFunctions/debug -lmathFunctions @@ -84,6 +86,7 @@ CONFIG(debug, debug|release) { LIBS += -L../../mapGraphics/release -lMapGraphics LIBS += -L../../agrolib/commonDialogs/release -lcommonDialogs + LIBS += -L../../agrolib/graphics/release -lgraphics LIBS += -L../../agrolib/criteriaOutput/release -lcriteriaOutput LIBS += -L../../agrolib/netcdfHandler/release -lnetcdfHandler win32:{ @@ -98,15 +101,13 @@ CONFIG(debug, debug|release) { LIBS += -L../../agrolib/shapeUtilities/release -lshapeUtilities LIBS += -L../../agrolib/shapeHandler/release -lshapeHandler LIBS += -L../../agrolib/utilities/release -lutilities + LIBS += -L../../agrolib/meteo/release -lmeteo LIBS += -L../../agrolib/gis/release -lgis LIBS += -L../../agrolib/crit3dDate/release -lcrit3dDate LIBS += -L../../agrolib/mathFunctions/release -lmathFunctions } HEADERS += \ - ../../agrolib/graphics/mapGraphicsRasterObject.h \ - ../../agrolib/graphics/mapGraphicsShapeObject.h \ - ../../agrolib/graphics/colorLegend.h \ criteriaGeoProject.h \ dialogDbfNewCol.h \ dialogDbfTable.h \ @@ -122,9 +123,6 @@ HEADERS += \ tableDbf.h SOURCES += \ - ../../agrolib/graphics/mapGraphicsRasterObject.cpp \ - ../../agrolib/graphics/mapGraphicsShapeObject.cpp \ - ../../agrolib/graphics/colorLegend.cpp \ criteriaGeoProject.cpp \ dialogDbfNewCol.cpp \ dialogDbfTable.cpp \ diff --git a/bin/CRITERIAGEO/criteriaGeoProject.cpp b/bin/CRITERIAGEO/criteriaGeoProject.cpp index 27987456..c3499348 100644 --- a/bin/CRITERIAGEO/criteriaGeoProject.cpp +++ b/bin/CRITERIAGEO/criteriaGeoProject.cpp @@ -160,21 +160,21 @@ void CriteriaGeoProject::getRasterFromShape(Crit3DShapeHandler &shape, QString f } -bool CriteriaGeoProject::addUnitCropMap(Crit3DShapeHandler *crop, Crit3DShapeHandler *soil, Crit3DShapeHandler *meteo, +bool CriteriaGeoProject::addUnitCropMap(Crit3DShapeHandler *shapeCrop, Crit3DShapeHandler *shapeSoil, Crit3DShapeHandler *shapeMeteo, std::string idCrop, std::string idSoil, std::string idMeteo, double cellSize, double threshold, QString ucmFileName, bool isPrevailing, bool showInfo) { std::string errorStr; - Crit3DShapeHandler *ucm = new(Crit3DShapeHandler); + Crit3DShapeHandler *shapeUCM = new(Crit3DShapeHandler); if (isPrevailing) { - if (computeUcmPrevailing(*ucm, *crop, *soil, *meteo, idCrop, idSoil, idMeteo, + if (computeUcmPrevailing(*shapeUCM, *shapeCrop, *shapeSoil, *shapeMeteo, idCrop, idSoil, idMeteo, cellSize, threshold, ucmFileName, errorStr, showInfo)) { - addShapeFile(ucm, QString::fromStdString(ucm->getFilepath()), "", ucm->getUtmZone()); + addShapeFile(ucm, QString::fromStdString(shapeUCM->getFilepath()), "", shapeUCM->getUtmZone()); return true; } else @@ -187,9 +187,9 @@ bool CriteriaGeoProject::addUnitCropMap(Crit3DShapeHandler *crop, Crit3DShapeHan { #ifdef GDAL /* - if (computeUcmIntersection(ucm, crop, soil, meteo, idCrop, idSoil, idMeteo, ucmFileName, &errorStr)) + if (computeUcmIntersection(shapeUCM, shapeCrop, shapeSoil, shapeMeteo, idCrop, idSoil, idMeteo, ucmFileName, &errorStr)) { - addShapeFile(ucm, QString::fromStdString(ucm->getFilepath()), "", ucm->getUtmZone()); + addShapeFile(shapeUCM, QString::fromStdString(shapeUCM->getFilepath()), "", shapeUCM->getUtmZone()); return true; } else diff --git a/bin/CRITERIAGEO/criteriaGeoProject.h b/bin/CRITERIAGEO/criteriaGeoProject.h index 81f046ee..9cb3fd28 100644 --- a/bin/CRITERIAGEO/criteriaGeoProject.h +++ b/bin/CRITERIAGEO/criteriaGeoProject.h @@ -42,7 +42,7 @@ bool extractUcmListToDb(Crit3DShapeHandler* shapeHandler, bool showInfo); - bool addUnitCropMap(Crit3DShapeHandler *crop, Crit3DShapeHandler *soil, Crit3DShapeHandler *meteo, + bool addUnitCropMap(Crit3DShapeHandler *shapeCrop, Crit3DShapeHandler *shapeSoil, Crit3DShapeHandler *shapeMeteo, std::string idCrop, std::string idSoil, std::string idMeteo, double cellSize, double threshold, QString ucmFileName, bool isPrevailing, bool showInfo); diff --git a/bin/CRITERIAGEO/dialogUcmIntersection.cpp b/bin/CRITERIAGEO/dialogUcmIntersection.cpp index dc3bb584..a7015c13 100644 --- a/bin/CRITERIAGEO/dialogUcmIntersection.cpp +++ b/bin/CRITERIAGEO/dialogUcmIntersection.cpp @@ -142,12 +142,12 @@ void DialogUcmIntersection::shapeCropClicked(QListWidgetItem* item) idCrop.clear(); showChildren(cropFieldLayout, true); unsigned int pos = cropShape->row(item); - crop = shapeObjList.at(pos); + shapeCrop = shapeObjList.at(pos); QList fieldLabel; - for (int i = 0; i < crop->getFieldNumbers(); i++) + for (int i = 0; i < shapeCrop->getFieldNumbers(); i++) { - std::string nameField = crop->getFieldName(i); + std::string nameField = shapeCrop->getFieldName(i); fieldLabel << QString::fromStdString(nameField); } cropField->addItems(fieldLabel); @@ -160,12 +160,12 @@ void DialogUcmIntersection::shapeSoilClicked(QListWidgetItem* item) idSoil.clear(); showChildren(soilFieldLayout, true); unsigned int pos = soilShape->row(item); - soil = shapeObjList.at(pos); + shapeSoil = shapeObjList.at(pos); QList fieldLabel; - for (int i = 0; i < soil->getFieldNumbers(); i++) + for (int i = 0; i < shapeSoil->getFieldNumbers(); i++) { - std::string nameField = soil->getFieldName(i); + std::string nameField = shapeSoil->getFieldName(i); fieldLabel << QString::fromStdString(nameField); } soilField->addItems(fieldLabel); @@ -178,12 +178,12 @@ void DialogUcmIntersection::shapeMeteoClicked(QListWidgetItem* item) idMeteo.clear(); showChildren(meteoFieldLayout, true); unsigned int pos = meteoShape->row(item); - meteo = shapeObjList.at(pos); + shapeMeteo = shapeObjList.at(pos); QList fieldLabel; - for (int i = 0; i < meteo->getFieldNumbers(); i++) + for (int i = 0; i < shapeMeteo->getFieldNumbers(); i++) { - std::string nameField = meteo->getFieldName(i); + std::string nameField = shapeMeteo->getFieldName(i); fieldLabel << QString::fromStdString(nameField); } meteoField->addItems(fieldLabel); @@ -259,11 +259,11 @@ void DialogUcmIntersection::ucm() if (itemSelected != nullptr) { pos = cropShape->row(itemSelected); - crop = shapeObjList.at(pos); + shapeCrop = shapeObjList.at(pos); } else { - crop = nullptr; + shapeCrop = nullptr; } itemSelected = soilShape->currentItem(); @@ -275,11 +275,11 @@ void DialogUcmIntersection::ucm() if (itemSelected != nullptr) { pos = soilShape->row(itemSelected); - soil = shapeObjList.at(pos); + shapeSoil = shapeObjList.at(pos); } else { - soil = nullptr; + shapeSoil = nullptr; } itemSelected = meteoShape->currentItem(); @@ -291,11 +291,11 @@ void DialogUcmIntersection::ucm() if (itemSelected != nullptr) { pos = meteoShape->row(itemSelected); - meteo = shapeObjList.at(pos); + shapeMeteo = shapeObjList.at(pos); } else { - meteo = nullptr; + shapeMeteo = nullptr; } unsigned int nShapeSelected = 0; @@ -379,16 +379,16 @@ QString DialogUcmIntersection::getIdMeteo() const Crit3DShapeHandler *DialogUcmIntersection::getCrop() const { - return crop; + return shapeCrop; } Crit3DShapeHandler *DialogUcmIntersection::getSoil() const { - return soil; + return shapeSoil; } Crit3DShapeHandler *DialogUcmIntersection::getMeteo() const { - return meteo; + return shapeMeteo; } diff --git a/bin/CRITERIAGEO/dialogUcmIntersection.h b/bin/CRITERIAGEO/dialogUcmIntersection.h index 76f01d75..abbb46e5 100644 --- a/bin/CRITERIAGEO/dialogUcmIntersection.h +++ b/bin/CRITERIAGEO/dialogUcmIntersection.h @@ -22,9 +22,9 @@ QLineEdit* idCropEdit; QLineEdit* idSoilEdit; QLineEdit* idMeteoEdit; - Crit3DShapeHandler *crop; - Crit3DShapeHandler *soil; - Crit3DShapeHandler *meteo; + Crit3DShapeHandler *shapeCrop; + Crit3DShapeHandler *shapeSoil; + Crit3DShapeHandler *shapeMeteo; QString idCrop; QString idSoil; QString idMeteo; diff --git a/bin/CRITERIAGEO/dialogUcmPrevailing.cpp b/bin/CRITERIAGEO/dialogUcmPrevailing.cpp index 6229b309..29365405 100644 --- a/bin/CRITERIAGEO/dialogUcmPrevailing.cpp +++ b/bin/CRITERIAGEO/dialogUcmPrevailing.cpp @@ -17,17 +17,17 @@ QString DialogUcmPrevailing::getIdMeteo() const Crit3DShapeHandler *DialogUcmPrevailing::getCrop() const { - return crop; + return shapeCrop; } Crit3DShapeHandler *DialogUcmPrevailing::getSoil() const { - return soil; + return shapeSoil; } Crit3DShapeHandler *DialogUcmPrevailing::getMeteo() const { - return meteo; + return shapeMeteo; } @@ -128,12 +128,12 @@ void DialogUcmPrevailing::shapeCropClicked(QListWidgetItem* item) { cropField->clear(); unsigned int pos = cropShape->row(item); - crop = shapeObjList.at(pos); + shapeCrop = shapeObjList.at(pos); QList fieldLabel; - for (int i = 0; i < crop->getFieldNumbers(); i++) + for (int i = 0; i < shapeCrop->getFieldNumbers(); i++) { - std::string nameField = crop->getFieldName(i); + std::string nameField = shapeCrop->getFieldName(i); fieldLabel << QString::fromStdString(nameField); } cropField->addItems(fieldLabel); @@ -143,12 +143,12 @@ void DialogUcmPrevailing::shapeSoilClicked(QListWidgetItem* item) { soilField->clear(); unsigned int pos = soilShape->row(item); - soil = shapeObjList.at(pos); + shapeSoil = shapeObjList.at(pos); QList fieldLabel; - for (int i = 0; i < soil->getFieldNumbers(); i++) + for (int i = 0; i < shapeSoil->getFieldNumbers(); i++) { - std::string nameField = soil->getFieldName(i); + std::string nameField = shapeSoil->getFieldName(i); fieldLabel << QString::fromStdString(nameField); } soilField->addItems(fieldLabel); @@ -158,12 +158,12 @@ void DialogUcmPrevailing::shapeMeteoClicked(QListWidgetItem* item) { meteoField->clear(); unsigned int pos = meteoShape->row(item); - meteo = shapeObjList.at(pos); + shapeMeteo = shapeObjList.at(pos); QList fieldLabel; - for (int i = 0; i < meteo->getFieldNumbers(); i++) + for (int i = 0; i < shapeMeteo->getFieldNumbers(); i++) { - std::string nameField = meteo->getFieldName(i); + std::string nameField = shapeMeteo->getFieldName(i); fieldLabel << QString::fromStdString(nameField); } meteoField->addItems(fieldLabel); @@ -182,7 +182,7 @@ void DialogUcmPrevailing::ucm() return; } unsigned int pos = cropShape->row(itemSelected); - crop = shapeObjList.at(pos); + shapeCrop = shapeObjList.at(pos); itemSelected = soilShape->currentItem(); if (itemSelected == nullptr) @@ -191,7 +191,7 @@ void DialogUcmPrevailing::ucm() return; } pos = soilShape->row(itemSelected); - soil = shapeObjList.at(pos); + shapeSoil = shapeObjList.at(pos); itemSelected = meteoShape->currentItem(); if (itemSelected == nullptr) @@ -200,7 +200,7 @@ void DialogUcmPrevailing::ucm() return; } pos = meteoShape->row(itemSelected); - meteo = shapeObjList.at(pos); + shapeMeteo = shapeObjList.at(pos); // check field selection diff --git a/bin/CRITERIAGEO/dialogUcmPrevailing.h b/bin/CRITERIAGEO/dialogUcmPrevailing.h index af84bd2b..a1f91e60 100644 --- a/bin/CRITERIAGEO/dialogUcmPrevailing.h +++ b/bin/CRITERIAGEO/dialogUcmPrevailing.h @@ -19,9 +19,9 @@ QListWidget* soilField; QListWidget* meteoField; QLineEdit* cellSize; - Crit3DShapeHandler *crop; - Crit3DShapeHandler *soil; - Crit3DShapeHandler *meteo; + Crit3DShapeHandler *shapeCrop; + Crit3DShapeHandler *shapeSoil; + Crit3DShapeHandler *shapeMeteo; QString idCrop; QString idSoil; QString idMeteo; diff --git a/bin/CRITERIAGEO/mainWindow.cpp b/bin/CRITERIAGEO/mainWindow.cpp index f5f17a9a..18ef6719 100644 --- a/bin/CRITERIAGEO/mainWindow.cpp +++ b/bin/CRITERIAGEO/mainWindow.cpp @@ -151,8 +151,6 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event) } } this->isDoubleClick = false; - - this->updateMaps(); } @@ -349,7 +347,7 @@ bool MainWindow::addShapeObject(GisObject* myObject) { // check zoneNumber int zoneNumber = myObject->getShapeHandler()->getUtmZone(); - if (zoneNumber < 1 || zoneNumber > 60) + if ((zoneNumber < 1) || (zoneNumber > 60)) { QMessageBox::critical(nullptr, "ERROR!", "Wrong UTM zone."); return false; @@ -701,33 +699,38 @@ void MainWindow::itemMenuRequested(const QPoint point) GisObject* myObject = myProject.objectList.at(unsigned(pos)); QMenu submenu; - RasterObject* myRasterObject = nullptr; + RasterObject* myRasterObject = getRasterObject(myObject); + MapGraphicsShapeObject* myShapeObject = getShapeObject(myObject); if (myObject->type == gisObjectShape) { - if (myObject->projectName.isEmpty()) + if (myShapeObject != nullptr) { - submenu.addAction("Remove"); - submenu.addSeparator(); - submenu.addAction("Save as"); + if (! myObject->projectName.isEmpty()) + { + submenu.addAction("Close Project"); + submenu.addSeparator(); + } + else + { + submenu.addAction("Remove"); + submenu.addSeparator(); + submenu.addAction("Save as"); + submenu.addSeparator(); + } + + submenu.addAction("Show data"); + submenu.addAction("Attribute table"); submenu.addSeparator(); - } - else - { - submenu.addAction("Close Project"); + submenu.addAction("Set style"); + submenu.addAction("Invert color scale"); submenu.addSeparator(); + submenu.addAction("Export to raster"); + submenu.addAction("Export to NetCDF"); } - submenu.addAction("Show data"); - submenu.addAction("Attribute table"); - submenu.addSeparator(); - submenu.addAction("Set style"); - submenu.addSeparator(); - submenu.addAction("Export to raster"); - submenu.addAction("Export to NetCDF"); } if (myObject->type == gisObjectRaster) { - myRasterObject = getRasterObject(myObject); if (myRasterObject != nullptr) { submenu.addAction("Remove"); @@ -736,7 +739,9 @@ void MainWindow::itemMenuRequested(const QPoint point) submenu.addSeparator(); submenu.addAction("Set grayscale"); submenu.addAction("Set default scale"); + submenu.addAction("Invert color scale"); submenu.addSeparator(); + if (myRasterObject->opacity() < 1) submenu.addAction("Set opaque"); else @@ -815,7 +820,7 @@ void MainWindow::itemMenuRequested(const QPoint point) if (myObject->type == gisObjectRaster) { setGrayScale(myObject->getRaster()->colorScale); - myRasterObject->redrawRequested(); + emit myRasterObject->redrawRequested(); } } else if (rightClickItem->text().contains("Set default scale")) @@ -823,7 +828,20 @@ void MainWindow::itemMenuRequested(const QPoint point) if (myObject->type == gisObjectRaster) { setDefaultDEMScale(myObject->getRaster()->colorScale); - myRasterObject->redrawRequested(); + emit myRasterObject->redrawRequested(); + } + } + else if (rightClickItem->text().contains("Invert color scale")) + { + if (myObject->type == gisObjectRaster) + { + reverseColorScale(myObject->getRaster()->colorScale); + emit myRasterObject->redrawRequested(); + } + else if (myObject->type == gisObjectShape) + { + reverseColorScale(myShapeObject->colorScale); + emit myShapeObject->redrawRequested(); } } else if (rightClickItem->text().contains("Set opaque")) @@ -831,15 +849,16 @@ void MainWindow::itemMenuRequested(const QPoint point) if (myObject->type == gisObjectRaster) { myRasterObject->setOpacity(1.0); - update(); + emit myRasterObject->redrawRequested(); } } else if (rightClickItem->text().contains("Set transparent")) { if (myObject->type == gisObjectRaster) { + // TODO choose value myRasterObject->setOpacity(0.66); - update(); + emit myRasterObject->redrawRequested(); } } } @@ -852,18 +871,21 @@ void MainWindow::selectShape(QPoint position) if (itemSelected == nullptr) return; + // check selected object (is shape) int row = ui->checkList->row(itemSelected); GisObject* myObject = myProject.objectList.at(unsigned(row)); if (myObject->type != gisObjectShape) return; + // check position QPoint mapPos = getMapPos(position); if (! isInsideMap(mapPos)) return; Position latLon = mapView->mapToScene(mapPos); - //Crit3DShapeHandler* shapeHandler = myObject->getShapeHandler(); - this->ui->statusBar->showMessage(QString::number(latLon.latitude()) + " " + QString::number(latLon.longitude())); + Crit3DShapeHandler* shapeHandler = myObject->getShapeHandler(); + + //this->ui->statusBar->showMessage(QString::number(latLon.latitude()) + " " + QString::number(latLon.longitude())); } diff --git a/bin/Makeall_CRITERIAGEO/Makeall_CRITERIAGEO.pro b/bin/Makeall_CRITERIAGEO/Makeall_CRITERIAGEO.pro index 54ed14b0..822e0ebb 100644 --- a/bin/Makeall_CRITERIAGEO/Makeall_CRITERIAGEO.pro +++ b/bin/Makeall_CRITERIAGEO/Makeall_CRITERIAGEO.pro @@ -5,16 +5,18 @@ TEMPLATE = subdirs CONFIG += GDAL GDAL { - SUBDIRS = ../../agrolib/crit3dDate ../../agrolib/mathFunctions ../../agrolib/gis \ + SUBDIRS = ../../agrolib/crit3dDate ../../agrolib/mathFunctions ../../agrolib/gis ../../agrolib/meteo \ ../../agrolib/utilities ../../agrolib/shapeHandler \ ../../agrolib/shapeUtilities ../../agrolib/gdalHandler ../../agrolib/netcdfHandler \ - ../../agrolib/criteriaOutput ../../agrolib/commonDialogs ../CRITERIAGEO + ../../agrolib/criteriaOutput ../../agrolib/commonDialogs ../../agrolib/graphics \ + ../CRITERIAGEO } else { - SUBDIRS = ../../agrolib/crit3dDate ../../agrolib/mathFunctions ../../agrolib/gis \ + SUBDIRS = ../../agrolib/crit3dDate ../../agrolib/mathFunctions ../../agrolib/gis ../../agrolib/meteo \ ../../agrolib/utilities ../../agrolib/shapeHandler \ ../../agrolib/shapeUtilities ../../agrolib/netcdfHandler \ - ../../agrolib/criteriaOutput ../../agrolib/commonDialogs ../CRITERIAGEO + ../../agrolib/criteriaOutput ../../agrolib/commonDialogs ../../agrolib/graphics \ + ../CRITERIAGEO } CONFIG += ordered