From f169205c4f5f2d077a35ba9e1db8f143fbba70c3 Mon Sep 17 00:00:00 2001 From: mkr Date: Wed, 21 Oct 2015 10:56:03 +0300 Subject: [PATCH] Remove references to land cover object from data model and GUI in order to have a compilable application. Add indexes for new operations. --- src/HYDROData/HYDROData_CalculationCase.cxx | 8 + src/HYDROData/HYDROData_CalculationCase.h | 7 + src/HYDROGUI/CMakeLists.txt | 10 - src/HYDROGUI/HYDROGUI_CalculationDlg.cxx | 437 +----------------- src/HYDROGUI/HYDROGUI_CalculationDlg.h | 74 +-- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 447 +++---------------- src/HYDROGUI/HYDROGUI_CalculationOp.h | 51 +-- src/HYDROGUI/HYDROGUI_ExportFileOp.cxx | 13 +- src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx | 178 -------- src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h | 74 --- src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx | 376 ---------------- src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h | 61 --- src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx | 155 ------- src/HYDROGUI/HYDROGUI_LandCoverDlg.h | 59 --- src/HYDROGUI/HYDROGUI_LandCoverOp.cxx | 395 ---------------- src/HYDROGUI/HYDROGUI_LandCoverOp.h | 64 --- src/HYDROGUI/HYDROGUI_Module.cxx | 28 +- src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx | 18 +- src/HYDROGUI/HYDROGUI_Operations.cxx | 47 +- src/HYDROGUI/HYDROGUI_Operations.h | 10 +- src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx | 3 +- src/HYDROGUI/HYDROGUI_SetColorOp.cxx | 28 +- src/HYDROGUI/HYDROGUI_Shape.cxx | 1 - src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx | 94 ---- src/HYDROGUI/HYDROGUI_ShapeLandCover.h | 59 --- src/HYDROGUI/HYDROGUI_Zone.cxx | 19 - src/HYDROGUI/resources/HYDROGUI_images.ts | 18 +- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 72 ++- 28 files changed, 268 insertions(+), 2538 deletions(-) delete mode 100644 src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx delete mode 100644 src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h delete mode 100644 src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx delete mode 100644 src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h delete mode 100644 src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx delete mode 100644 src/HYDROGUI/HYDROGUI_LandCoverDlg.h delete mode 100644 src/HYDROGUI/HYDROGUI_LandCoverOp.cxx delete mode 100644 src/HYDROGUI/HYDROGUI_LandCoverOp.h delete mode 100644 src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx delete mode 100644 src/HYDROGUI/HYDROGUI_ShapeLandCover.h diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 46cf97ba..3d3d918b 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -25,6 +25,7 @@ #include "HYDROData_NaturalObject.h" #include "HYDROData_PolylineXY.h" #include "HYDROData_StricklerTable.h" +#include "HYDROData_LandCoverMap.h" #include "HYDROData_SplittedShapesGroup.h" #include "HYDROData_Region.h" #include "HYDROData_Tool.h" @@ -575,6 +576,13 @@ void HYDROData_CalculationCase::RemoveStricklerTable() Changed( Geom_No ); } +Handle(HYDROData_LandCoverMap) HYDROData_CalculationCase::GetLandCoverMap() const +{ + // TODO + Handle(HYDROData_LandCoverMap) aLandCoverMap = NULL; + return aLandCoverMap; +} + Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone ) { Changed( Geom_No ); diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 405896fc..1a4eb311 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -53,6 +53,7 @@ class Handle(HYDROData_ShapesGroup); class Handle(HYDROData_SplittedShapesGroup); class Handle(HYDROData_Document); class Handle(HYDROData_StricklerTable); +class Handle(HYDROData_LandCoverMap); DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) @@ -214,6 +215,12 @@ public: */ HYDRODATA_EXPORT virtual void RemoveStricklerTable(); + /** + * Returns reference Land Cover Map of calculation case. + * \return the referenced Land Cover Map + */ + HYDRODATA_EXPORT virtual Handle(HYDROData_LandCoverMap) GetLandCoverMap() const; + /** * Add new one child region for calculation case. * The new region is added into the list of reference regions. diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index ae5ef832..6ebcafeb 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -37,8 +37,6 @@ set(PROJECT_HEADERS HYDROGUI_ImportImageDlg.h HYDROGUI_ImportImageOp.h HYDROGUI_ImportPolylineOp.h - HYDROGUI_ImportLandCoverOp.h - HYDROGUI_ImportLandCoverDlg.h HYDROGUI_ImportSinusXOp.h HYDROGUI_ExportSinusXOp.h HYDROGUI_ExportSinusXDlg.h @@ -86,8 +84,6 @@ set(PROJECT_HEADERS HYDROGUI_LineEditDoubleValidator.h HYDROGUI_StricklerTableDlg.h HYDROGUI_StricklerTableOp.h - HYDROGUI_LandCoverDlg.h - HYDROGUI_LandCoverOp.h HYDROGUI_SubmersibleOp.h HYDROGUI_Tool.h HYDROGUI_TwoImagesDlg.h @@ -134,7 +130,6 @@ set(PROJECT_HEADERS HYDROGUI_RecognizeContoursDlg.h HYDROGUI_RecognizeContoursOp.h HYDROGUI_LandCoverColoringOp.h - HYDROGUI_ShapeLandCover.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -175,8 +170,6 @@ set(PROJECT_SOURCES HYDROGUI_ImportImageOp.cxx HYDROGUI_ImportPolylineOp.cxx HYDROGUI_ImportSinusXOp.cxx - HYDROGUI_ImportLandCoverOp.cxx - HYDROGUI_ImportLandCoverDlg.cxx HYDROGUI_ExportSinusXOp.cxx HYDROGUI_ExportSinusXDlg.cxx HYDROGUI_InputPanel.cxx @@ -221,8 +214,6 @@ set(PROJECT_SOURCES HYDROGUI_LineEditDoubleValidator.cxx HYDROGUI_StricklerTableDlg.cxx HYDROGUI_StricklerTableOp.cxx - HYDROGUI_LandCoverDlg.cxx - HYDROGUI_LandCoverOp.cxx HYDROGUI_SplitPolylinesDlg.cxx HYDROGUI_SplitPolylinesOp.cxx HYDROGUI_SubmersibleOp.cxx @@ -272,7 +263,6 @@ set(PROJECT_SOURCES HYDROGUI_RecognizeContoursDlg.cxx HYDROGUI_RecognizeContoursOp.cxx HYDROGUI_LandCoverColoringOp.cxx - HYDROGUI_ShapeLandCover.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 6a6e60f0..a2d3c7dc 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -71,9 +71,8 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co { addPage( createObjectsPage() ); addPage( createGroupsPage() ); - addPage( createLandCoversPage() ); + addPage( createLandCoverMapPage() ); addPage( createZonesPage() ); - addPage( createLandCoverZonesPage() ); } HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg() @@ -85,20 +84,16 @@ void HYDROGUI_CalculationDlg::reset() myObjectName->clear(); HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList; myGeomObjects->setObjects(anObject2VisibleList); - myLandCovers->setObjects(anObject2VisibleList); myPolylineName->clear(); myStricklerTableName->clear(); myAvailableGeomObjects->clear(); - myAvailableLandCovers->clear(); // Activate the automatic mode setMode( HYDROData_CalculationCase::AUTOMATIC ); - setLandCoverMode( HYDROData_CalculationCase::AUTOMATIC ); // Reset the priority widget state QList anObjects; myPriorityWidget->setObjects( anObjects ); - myLandCoverPriorityWidget->setObjects( anObjects ); } QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() { @@ -313,16 +308,14 @@ QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() { return aPage; } -QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { +QWizardPage* HYDROGUI_CalculationDlg::createLandCoverMapPage() { QWizardPage* aPage = new QWizardPage( mainFrame() ); QFrame* aFrame = new QFrame( aPage ); - // Splitter - myLandCoverSplitter = new QSplitter(Qt::Vertical); - // Top of the page QWidget* aTopContainer = new QWidget; - + + // TODO: add combo-box to choose land cover map object // Combo-box to choose Strickler table name QLabel* aStricklerTableLabel = new QLabel( tr( "STRICKLER_TABLE" ), aPage ); myStricklerTableName = new QComboBox( aPage ); @@ -330,124 +323,26 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { connect( myStricklerTableName, SIGNAL( activated( const QString & ) ), SIGNAL( StricklerTableSelected( const QString & ) ) ); - // Mode selector (auto/manual) - QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) ); - - QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() ); - QRadioButton* anAutoRB = new QRadioButton( tr( "AUTO" ), mainFrame() ); - - myLandCoverModeButtons = new QButtonGroup( mainFrame() ); - myLandCoverModeButtons->addButton( anAutoRB, HYDROData_CalculationCase::AUTOMATIC ); - myLandCoverModeButtons->addButton( aManualRB, HYDROData_CalculationCase::MANUAL ); - - QBoxLayout* aModeSelectorLayout = new QHBoxLayout; - aModeSelectorLayout->setMargin( 5 ); - aModeSelectorLayout->setSpacing( 5 ); - aModeSelectorLayout->addWidget( anAutoRB ); - aModeSelectorLayout->addWidget( aManualRB ); - aModeGroup->setLayout( aModeSelectorLayout ); - - // Available land covers - QLabel* aLandCoversLabel = new QLabel( tr( "CALCULATION_REFERENCE_LAND_COVERS" ) ); - myAvailableLandCovers = new QListWidget( aPage ); - myAvailableLandCovers->setSelectionMode( QListWidget::ExtendedSelection ); - myAvailableLandCovers->setEditTriggers( QListWidget::NoEditTriggers ); - myAvailableLandCovers->setViewMode( QListWidget::ListMode ); - myAvailableLandCovers->setSortingEnabled( true ); - - // Included land covers - QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_LAND_COVERS" ) ); - myLandCovers = new HYDROGUI_OrderedListWidget( aPage, 16 ); - myLandCovers->setHiddenObjectsShown(true); - myLandCovers->setVisibilityIconShown(false); - myLandCovers->setContentsMargins(QMargins()); - - // Include/Exclude buttons - QFrame* aBtnsFrame = new QFrame; - QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame ); - aBtnsLayout->setMargin( 5 ); - aBtnsLayout->setSpacing( 5 ); - aBtnsFrame->setLayout( aBtnsLayout ); - QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame ); - QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame ); - - // Fill the butons frame with two buttons - aBtnsLayout->addWidget( anAddBtn ); - aBtnsLayout->addWidget( aRemoveBtn ); - aBtnsLayout->addStretch( 1 ); - - // Land covers frame - QFrame* aLandCoversFrame = new QFrame( aPage ); - aLandCoversFrame->setFrameStyle( QFrame::Panel | QFrame::Raised ); - QGridLayout* aLandCoversLayout = new QGridLayout( aLandCoversFrame ); - aLandCoversLayout->setMargin( 5 ); - aLandCoversLayout->setSpacing( 5 ); - aLandCoversFrame->setLayout( aLandCoversLayout ); - - // Fill the land covers frame with two lists, two labels and with buttons frame - aLandCoversLayout->addWidget( aLandCoversLabel, 0, 0, Qt::AlignHCenter ); - aLandCoversLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter ); - aLandCoversLayout->addWidget( myAvailableLandCovers, 1, 0 ); - aLandCoversLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter ); - aLandCoversLayout->addWidget( myLandCovers, 1, 2 ); - // Fill the top layout of the page QGridLayout* aTopLayout = new QGridLayout; aTopLayout->setMargin( 5 ); aTopLayout->setSpacing( 5 ); aTopLayout->setVerticalSpacing( 10 ); + // TODO: add land cover map combo-box to the layout aTopLayout->addWidget( aStricklerTableLabel, 0, 0, Qt::AlignHCenter ); aTopLayout->addWidget( myStricklerTableName, 0, 1 ); - aTopLayout->addWidget( aModeGroup, 1, 0, 1, 2 ); - aTopLayout->addWidget( aLandCoversFrame, 2, 0, 1, 2 ); - + aTopContainer->setLayout( aTopLayout ); - // Add the top of the page to the splitter - myLandCoverSplitter->insertWidget(0, aTopContainer); - myLandCoverSplitter->setStretchFactor(0, 2); - - // Bottom of the page - myLandCoverPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() ); - HYDROGUI_PriorityTableModel* aModel = - dynamic_cast( myLandCoverPriorityWidget->getTable()->model() ); - if ( aModel ) - aModel->setColumnCount( 3 ); - - QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) ); - QBoxLayout* aPriorityLayout = new QHBoxLayout; - aPriorityLayout->setMargin( 5 ); - aPriorityLayout->setSpacing( 5 ); - aPriorityLayout->addWidget( myLandCoverPriorityWidget ); - aPriorityGroup->setLayout( aPriorityLayout ); - - // Add the bottom of the page to the splitter - myLandCoverSplitter->insertWidget(1, aPriorityGroup); - myLandCoverSplitter->setStretchFactor(1, 1); - // Page layout QVBoxLayout* aPageLayout = new QVBoxLayout; aPageLayout->setMargin( 5 ); aPageLayout->setSpacing( 5 ); - aPageLayout->addWidget( myLandCoverSplitter ); - + aPage->setLayout( aPageLayout ); - // Create selector - if ( module() ) { - HYDROGUI_ListSelector* aListSelector = - new HYDROGUI_ListSelector( myLandCovers, module()->getApp()->selectionMgr() ); - aListSelector->setAutoBlock( true ); - } - // Connections - connect( myLandCoverModeButtons, SIGNAL( buttonClicked( int ) ), SIGNAL( changeLandCoverMode( int ) ) ); - connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addLandCovers() ) ); - connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeLandCovers() ) ); - - connect( myLandCovers, SIGNAL( orderChanged() ), SLOT( onOrderLandCoverChanged() ) ); - - connect( myLandCoverPriorityWidget, SIGNAL( ruleChanged() ), SLOT( onLandCoverRuleChanged() ) ); + // TODO return aPage; } @@ -494,47 +389,6 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() { return aPage; } -QWizardPage* HYDROGUI_CalculationDlg::createLandCoverZonesPage() { - QWizardPage* aPage = new QWizardPage( mainFrame() ); - QFrame* aFrame = new QFrame( aPage ); - - QGridLayout* aLayout = new QGridLayout( aPage ); - - QLabel* aResultsOnLandCoversLabel = new QLabel( tr( "RESULTS_ON_LAND_COVERS" ), aFrame ); - - myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage, true ); - myLandCoverBrowser->setAutoOpenLevel( 3 ); - aLayout->setMargin( 5 ); - aLayout->setSpacing( 5 ); - - aLayout->addWidget( aResultsOnLandCoversLabel, 0, 0 ); - aLayout->addWidget( myLandCoverBrowser, 1, 0, 1, 2 ); - - myStricklerTypeLabel = new QLabel( tr( "STRICKLER_TYPE" ), aFrame ); - myStricklerTypeChoice = new QComboBox( aFrame ); - - myStricklerTypeLabel->setVisible( false ); - myStricklerTypeChoice->setVisible( false ); - - aLayout->addWidget( myStricklerTypeLabel, 2, 0 ); - aLayout->addWidget( myStricklerTypeChoice, 2, 1 ); - - aPage->setLayout( aLayout ); - - // Connections - connect( myLandCoverBrowser, SIGNAL( dataChanged() ), SLOT( onDataLandCoverChanged() ) ); - connect( myLandCoverBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) ); - connect( myLandCoverBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onLandCoverZoneSelected( SUIT_DataObject* ) ) ); - connect( myStricklerTypeChoice, SIGNAL( activated( int ) ), SLOT( onMergeStricklerTypeSelected( int ) ) ); - connect( myLandCoverBrowser, - SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), - SLOT( onLandCoverZonesDropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); - connect( myLandCoverBrowser, SIGNAL( newRegion() ), this, SLOT( OnNewLandCoverRegion() ) ); - - return aPage; -} - - bool HYDROGUI_CalculationDlg::acceptCurrent() const { QString anErrorMsg; @@ -598,7 +452,7 @@ void HYDROGUI_CalculationDlg::onZonesDropped( const QList& the HYDROGUI_Region* aRegion = dynamic_cast(theTargetParent); if ( aRegion ) { - emit moveZones( theTargetParent, aZonesList, false ); + emit moveZones( theTargetParent, aZonesList ); } } } @@ -609,11 +463,6 @@ void HYDROGUI_CalculationDlg::OnNewRegion() emit createRegion( myBrowser->getSelected() ); } -void HYDROGUI_CalculationDlg::OnNewLandCoverRegion() -{ - emit createLandCoverRegion( myLandCoverBrowser->getSelected() ); -} - void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex ) { int aType = myBathymetryChoice->itemData( theIndex ).toInt(); @@ -669,87 +518,6 @@ void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject ) myBathymetryLabel->setVisible( doShow ); } -void HYDROGUI_CalculationDlg::onLandCoverZoneSelected( SUIT_DataObject* theObject ) -{ - bool doShow = false; - HYDROGUI_Zone* aZone = dynamic_cast( theObject ); - if ( aZone ) - { - doShow = aZone->isMergingNeed(); - } - - if ( doShow ) - { - // Fill the merge type combo box - bool prevBlock = myStricklerTypeChoice->blockSignals( true ); - myCurrentZone = aZone; - myStricklerTypeChoice->clear(); - myStricklerTypeChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN ); - QStringList aList = aZone->getObjects(); - for ( int i = 0; i < aList.length(); i++ ) - { - myStricklerTypeChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object ); - } - // Select the current choice if any - int aCurIndex = 0; - switch ( aZone->getMergeType() ) - { - case HYDROData_Zone::Merge_Object: - aCurIndex = 1 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) ); - break; - default: - aCurIndex = 0; // Select unknown by default - } - myStricklerTypeChoice->setCurrentIndex( aCurIndex ); - myStricklerTypeChoice->blockSignals( prevBlock ); - } - - myStricklerTypeChoice->setVisible( doShow ); - myStricklerTypeChoice->setEnabled( getLandCoverMode() == HYDROData_CalculationCase::MANUAL ); - myStricklerTypeLabel->setVisible( doShow ); -} - -void HYDROGUI_CalculationDlg::onMergeStricklerTypeSelected( int theIndex ) -{ - int aType = myStricklerTypeChoice->itemData( theIndex ).toInt(); - QString aText = myStricklerTypeChoice->itemText( theIndex ); - emit setMergeStricklerType( aType, aText ); -} - -void HYDROGUI_CalculationDlg::onLandCoverZonesDropped( const QList& theList, - SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction ) -{ - QList aZonesList; - HYDROGUI_Zone* aZone; - // Get a list of dropped land cover zones - for ( int i = 0; i < theList.length(); i++ ) - { - aZone = dynamic_cast( theList.at( i ) ); - if ( aZone ) - { - aZonesList.append( aZone ); - } - } - if ( aZonesList.length() > 0 ) - { - // Get the target region - HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast(theTargetParent); - if ( aRegionsRoot ) - { - // Create a new region - emit createLandCoverRegion( aZonesList ); - } - else - { - HYDROGUI_Region* aRegion = dynamic_cast(theTargetParent); - if ( aRegion ) - { - emit moveZones( theTargetParent, aZonesList, true ); - } - } - } -} - void HYDROGUI_CalculationDlg::setObjectName( const QString& theName ) { myObjectName->setText( theName ); @@ -859,20 +627,6 @@ void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, } } -void HYDROGUI_CalculationDlg::setAllLandCovers( const QStringList& theObjects, const QStringList& theObjectsEntries ) -{ - myAvailableLandCovers->clear(); - - for ( int i = 0, n = theObjects.length(); i < n; ++i ) - { - QString anObjName = theObjects.at( i ); - - QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myAvailableLandCovers ); - aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - aListItem->setData( Qt::UserRole, theObjectsEntries.at( i ) ); - } -} - QStringList getSelected( QListWidget* theWidget ) { QStringList aResList; @@ -889,38 +643,23 @@ QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const return myGeomObjects->getSelectedNames(); } -QStringList HYDROGUI_CalculationDlg::getSelectedLandCovers() const -{ - return myLandCovers->getSelectedNames(); -} - QStringList HYDROGUI_CalculationDlg::getAllGeomObjects() const { return myGeomObjects->getAllNames(); } -QStringList HYDROGUI_CalculationDlg::getAllLandCovers() const -{ - return myLandCovers->getAllNames(); -} - QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGeomObjects() const { return getSelected( myAvailableGeomObjects ); } -QStringList HYDROGUI_CalculationDlg::getSelectedAvailableLandCovers() const -{ - return getSelected( myAvailableLandCovers ); -} - void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase ) { myEditedObject = theCase; myValidator->setEditedObject( theCase ); // Build the calculation case subtree - module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject, false ); + module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject); myBrowser->updateTree(); myBrowser->openLevels(); @@ -928,6 +667,7 @@ void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculatio myBrowser->setAutoUpdate( true ); myBrowser->setUpdateModified( true ); + /*TODO // Build the calculation case subtree for Land Cover regions module()->getDataModel()->buildCaseTree( myLandCoverBrowser->root(), myEditedObject, true ); @@ -936,6 +676,7 @@ void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculatio myLandCoverBrowser->adjustColumnsWidth(); myLandCoverBrowser->setAutoUpdate( true ); myLandCoverBrowser->setUpdateModified( true ); + */ } HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const @@ -947,14 +688,14 @@ void HYDROGUI_CalculationDlg::refreshZonesBrowser() { SUIT_DataObject* aRoot = myBrowser->root(); module()->getDataModel()->updateObjectTree( myEditedObject ); - module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, false ); + module()->getDataModel()->buildCaseTree( aRoot, myEditedObject ); myBrowser->updateTree( aRoot ); } void HYDROGUI_CalculationDlg::onDataChanged() { SUIT_DataObject* aRoot = myBrowser->root(); - module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, false ); + module()->getDataModel()->buildCaseTree( aRoot, myEditedObject ); myBrowser->updateTree( aRoot ); } @@ -1014,34 +755,6 @@ void HYDROGUI_CalculationDlg::setMode( int theMode ) } } -/** - Get creation mode for land covers panel. - @param theMode the mode -*/ -int HYDROGUI_CalculationDlg::getLandCoverMode() const -{ - return myLandCoverModeButtons->checkedId(); -} - -/** - Set creation mode for land cover panel. - @param theMode the mode -*/ -void HYDROGUI_CalculationDlg::setLandCoverMode( int theMode ) -{ - bool isBlocked = myLandCoverModeButtons->blockSignals( true ); - myLandCoverModeButtons->button( theMode )->setChecked( true ); - myLandCoverModeButtons->blockSignals( isBlocked ); - - bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC ); - - myLandCovers->setOrderingEnabled( isAuto ); - QWidget* aWidget = myLandCoverSplitter->widget( 1 ); - if ( aWidget ) { - aWidget->setVisible( isAuto ); - } -} - /** Enable/disable zones drag'n'drop and renaming. @param theIsEnabled if true - zones drag'n'drop and renaming will be enabled @@ -1051,15 +764,6 @@ void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled ) myBrowser->setReadOnly( !theIsEnabled ); } -/** - Enable/disable land covers drag'n'drop and renaming. - @param theIsEnabled if true - land covers drag'n'drop and renaming will be enabled -*/ -void HYDROGUI_CalculationDlg::setEditLandCoverZonesEnabled( const bool theIsEnabled ) -{ - myLandCoverBrowser->setReadOnly( !theIsEnabled ); -} - /** Get included geometry objects. @return the list of geometry objects @@ -1082,11 +786,12 @@ QList HYDROGUI_CalculationDlg::getGeometryObjects() } /** - Get included land covers. - @return the list of land covers + Get chosen land cover map. + @return the land cover map object */ -QList HYDROGUI_CalculationDlg::getLandCovers() +Handle(HYDROData_LandCoverMap) HYDROGUI_CalculationDlg::getLandCoverMap() { + /* TODO QList anEntities = myLandCovers->getObjects(); QList aLandCovers; @@ -1100,6 +805,9 @@ QList HYDROGUI_CalculationDlg::getLandCovers() } return aLandCovers; + */ + Handle(HYDROData_LandCoverMap) aLandCoverMap = NULL; + return aLandCoverMap; } /** @@ -1120,24 +828,6 @@ void HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules ) myPriorityWidget->setRules( theRules ); } -/** - Get rules defined for land covers. - @return the list of rules - */ -HYDROData_ListOfRules HYDROGUI_CalculationDlg::getLandCoverRules() const -{ - return myLandCoverPriorityWidget->getRules(); -} - -/** - Set rules for land covers. - @param theRules the list of rules - */ -void HYDROGUI_CalculationDlg::setLandCoverRules( const HYDROData_ListOfRules& theRules ) const -{ - myLandCoverPriorityWidget->setRules( theRules ); -} - /** Slot called when objects order is changed. */ @@ -1162,6 +852,7 @@ void HYDROGUI_CalculationDlg::onRuleChanged() myPriorityWidget->undoLastChange(); } +// TODO: setLandCoverMap(...) void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals ) { bool isBlocked; @@ -1175,87 +866,3 @@ void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTabl else emit StricklerTableSelected( theStricklerTableName ); } - -void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCovers, bool theReset ) -{ - if ( theReset ) - { - HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList; - myLandCovers->setObjects(anObject2VisibleList); - } - - QList aFoundItems; - foreach ( const QString& anObjName, theLandCovers ) { - // Hide the land cover in the available land covers list - aFoundItems = myAvailableLandCovers->findItems( anObjName, Qt::MatchExactly ); - foreach ( QListWidgetItem* anItem, aFoundItems ) { - anItem->setHidden( true ); - } - - // Add the land cover to the list of included objects - Handle(HYDROData_Entity) anObject = - HYDROGUI_Tool::FindObjectByName( module(), anObjName ); - myLandCovers->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) ); - } - - myLandCoverPriorityWidget->setObjects( getLandCovers() ); -} - -void HYDROGUI_CalculationDlg::excludeLandCovers( const QStringList& theLandCovers ) -{ - QList aFoundItems; - foreach ( const QString& anObjName, theLandCovers ) { - // Set visible the land cover in the available objects list - aFoundItems = myAvailableLandCovers->findItems( anObjName, Qt::MatchExactly ); - foreach ( QListWidgetItem* anItem, aFoundItems ) { - anItem->setHidden( false ); - } - - // Remove the land cover from the list of included objects - myLandCovers->removeObjectByName( anObjName ); - } - - myLandCoverPriorityWidget->setObjects( getLandCovers() ); -} - -void HYDROGUI_CalculationDlg::refreshLandCoverZonesBrowser() -{ - SUIT_DataObject* aRoot = myLandCoverBrowser->root(); - module()->getDataModel()->updateObjectTree( myEditedObject ); - module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, true ); - myLandCoverBrowser->updateTree( aRoot ); -} - -/** - Slot called when zones created on land covers are changed. - */ -void HYDROGUI_CalculationDlg::onDataLandCoverChanged() -{ - SUIT_DataObject* aRoot = myLandCoverBrowser->root(); - module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, true ); - myLandCoverBrowser->updateTree( aRoot ); -} - -/** - Slot called when land covers order is changed. - */ -void HYDROGUI_CalculationDlg::onOrderLandCoverChanged() -{ - bool isConfirmed = true; - emit orderLandCoverChanged( isConfirmed ); - if( isConfirmed ) - myLandCoverPriorityWidget->setObjects( getLandCovers() ); - else - myLandCovers->undoLastMove(); -} - -/** - Slot called when priority rule for land covers is changed. - */ -void HYDROGUI_CalculationDlg::onLandCoverRuleChanged() -{ - bool isConfirmed = true; - emit ruleLandCoverChanged( isConfirmed ); - if( !isConfirmed ) - myLandCoverPriorityWidget->undoLastChange(); -} diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 41f010ba..1c6acb8c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -22,7 +22,7 @@ #include "HYDROGUI_Wizard.h" #include -#include +#include class HYDROGUI_ObjSelector; class HYDROGUI_DataBrowser; @@ -54,8 +54,7 @@ public: void reset(); int getMode() const; - int getLandCoverMode() const; - + void setObjectName( const QString& theName ); QString getObjectName() const; @@ -63,14 +62,11 @@ public: void setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries ); QStringList getAllGeomObjects() const; - void setAllLandCovers( const QStringList& theObjects, const QStringList& theObjectsEntries ); - QStringList getAllLandCovers() const; void setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries ); + // TODO: setLandCoverMapsNames(...) void setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries ); QStringList getSelectedGeomObjects() const; - QStringList getSelectedLandCovers() const; QStringList getSelectedAvailableGeomObjects() const; - QStringList getSelectedAvailableLandCovers() const; QStringList getSelectedGroups() const; QStringList getSelectedAvailableGroups() const; HYDROGUI_Zone* getCurrentZone() const; @@ -78,14 +74,10 @@ public: void setAvailableGroups( const QStringList& ); void setEditZonesEnabled( const bool theIsEnabled ); - void setEditLandCoverZonesEnabled( const bool theIsEnabled ); HYDROData_ListOfRules getRules() const; void setRules( const HYDROData_ListOfRules& theRules ) const; - HYDROData_ListOfRules getLandCoverRules() const; - void setLandCoverRules( const HYDROData_ListOfRules& theRules ) const; - public slots: void setMode( int theMode ); void setBoundary( const QString& theObjName ); @@ -100,15 +92,8 @@ public slots: void onOrderChanged(); void onRuleChanged(); - void setLandCoverMode( int theMode ); void setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals = true ); - void includeLandCovers( const QStringList& theLandCovers, bool theReset ); - void excludeLandCovers( const QStringList& theLandCovers ); - void refreshLandCoverZonesBrowser(); - void onDataLandCoverChanged(); - void onOrderLandCoverChanged(); - void onLandCoverRuleChanged(); - + /** * Process items selection: hide/show bathymetry merge type selector. */ @@ -123,20 +108,6 @@ public slots: void onZonesDropped( const QList& theList, SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction ); - /** - * Process items selection: hide/show Strickler type merge type selector. - */ - void onLandCoverZoneSelected( SUIT_DataObject* theObject ); - /** - * Process merge type selection: set the selected Strickler type merge type for the currently selected zone. - */ - void onMergeStricklerTypeSelected( int theIndex ); - /** - * Process land cover zones moving. Create a new region with dropped zones or add to existing one. - */ - void onLandCoverZonesDropped( const QList& theList, - SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction ); - signals: void changeMode( int theMode ); @@ -153,21 +124,12 @@ signals: void boundarySelected( const QString & theObjName ); void setMergeType( int theMergeType, QString& theBathymetryName ); void createRegion( const QList& theZonesList ); - void moveZones( SUIT_DataObject* theRegion, const QList& theZonesList, bool theLandCover ); + void moveZones( SUIT_DataObject* theRegion, const QList& theZonesList ); void clickedInZonesBrowser( SUIT_DataObject* ); - void changeLandCoverMode( int theMode ); - - void addLandCovers(); - void removeLandCovers(); - void landCoversSelected(); - void orderLandCoverChanged( bool& isConfirmed ); - void ruleLandCoverChanged( bool& isConfirmed ); + void landCoverMapSelected(); - void createLandCoverRegion( const QList& theLandCoverZonesList ); - void StricklerTableSelected( const QString & theObjName ); - void setMergeStricklerType( int theMergeType, QString& theStricklerTypeName ); void regenerateColors(); @@ -177,52 +139,42 @@ protected: protected slots: void OnNewRegion(); - void OnNewLandCoverRegion(); private: QList getGeometryObjects(); - QList getLandCovers(); - + + Handle(HYDROData_LandCoverMap) getLandCoverMap(); + QWizardPage* createObjectsPage(); QWizardPage* createGroupsPage(); - QWizardPage* createLandCoversPage(); + QWizardPage* createLandCoverMapPage(); QWizardPage* createZonesPage(); - QWizardPage* createLandCoverZonesPage(); - + QSplitter* mySplitter; - QSplitter* myLandCoverSplitter; - + QGroupBox* myObjectNameGroup; QLineEdit* myObjectName; HYDROGUI_NameValidator* myValidator; QComboBox* myPolylineName; + // TODO: myLandCoverMapName QComboBox* myStricklerTableName; QButtonGroup* myModeButtons; - QButtonGroup* myLandCoverModeButtons; QListWidget* myAvailableGeomObjects; HYDROGUI_OrderedListWidget* myGeomObjects; HYDROGUI_PriorityWidget* myPriorityWidget; - HYDROGUI_PriorityWidget* myLandCoverPriorityWidget; QListWidget* myAvailableGroups; QListWidget* myGroups; - QListWidget* myAvailableLandCovers; - HYDROGUI_OrderedListWidget* myLandCovers; - HYDROGUI_DataBrowser* myBrowser; Handle(HYDROData_CalculationCase) myEditedObject; QComboBox* myBathymetryChoice; QLabel* myBathymetryLabel; HYDROGUI_Zone* myCurrentZone; - - HYDROGUI_DataBrowser* myLandCoverBrowser; - QComboBox* myStricklerTypeChoice; - QLabel* myStricklerTypeLabel; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 97c826ad..1987887c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -57,9 +57,8 @@ HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool myActiveViewManager( NULL ), myPreviewViewManager( NULL ), myShowGeomObjects( true ), - myShowLandCovers( false ), - myShowZones( false ), - myUpdateLandCoverZonesPrs( false ) + myShowLandCoverMap( false ), + myShowZones( false ) { setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) ); } @@ -216,21 +215,14 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) ); connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) ); - connect( aPanel, SIGNAL( changeLandCoverMode( int ) ), SLOT( onChangeLandCoverMode( int ) ) ); - connect( aPanel, SIGNAL( addLandCovers() ), SLOT( onAddLandCovers() ) ); - connect( aPanel, SIGNAL( removeLandCovers() ), SLOT( onRemoveLandCovers() ) ); - connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) ); - connect( aPanel, SIGNAL( orderLandCoverChanged( bool& ) ), SLOT( onOrderLandCoverChanged( bool& ) ) ); connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) ); - connect( aPanel, SIGNAL( ruleLandCoverChanged( bool& ) ), SLOT( onRuleLandCoverChanged( bool& ) ) ); connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) ); connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones( const int ) ) ); //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) ); connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) ); - connect( aPanel, SIGNAL( setMergeStricklerType( int, QString& ) ), SLOT( onSetMergeStricklerType( int, QString& ) ) ); connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList&, bool ) ), SLOT( onMoveZones( SUIT_DataObject*, const QList&, bool ) ) ); connect( aPanel, SIGNAL( createRegion( const QList& ) ), @@ -297,6 +289,7 @@ void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjNa { bool anIsToUpdateViewer = false; + /* TODO // Remove old presentations of land covers from the operation viewer Handle(HYDROData_Entity) anEntity; Handle(HYDROData_LandCover) aLandCover; @@ -354,6 +347,7 @@ void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjNa module()->update( UF_OCCViewer ); } } + */ } void HYDROGUI_CalculationOp::onObjectsSelected() @@ -397,15 +391,17 @@ void HYDROGUI_CalculationOp::onObjectsSelected() aLastShape->update( true, false ); } -void HYDROGUI_CalculationOp::onLandCoversSelected() +void HYDROGUI_CalculationOp::onLandCoverMapSelected() { HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); + /* TODO: highlight the selected land cover map in the 3d viewer (synchronize slection in the dialog with a preview in the viewer) QStringList aSelectedObjs = aPanel->getSelectedLandCovers(); QMap aSelectedObjsMap; foreach( QString aName, aSelectedObjs ) aSelectedObjsMap[aName] = true; + */ // Select the appropriate land cover shape in the viewer @@ -414,6 +410,7 @@ void HYDROGUI_CalculationOp::onLandCoversSelected() // Unhighlight all land covers except selected HYDROGUI_Shape* aShape = 0, *aLastShape = 0; Handle(HYDROData_Entity) anEntity; + /* TODO: highlight the selected land cover map in the 3d viewer (synchronize slection in the dialog with a preview in the viewer) HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers(); HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); bool isSelected; @@ -434,6 +431,11 @@ void HYDROGUI_CalculationOp::onLandCoversSelected() } } } + */ + + // TODO + //createPreview( true ); + if( aLastShape ) aLastShape->update( true, false ); } @@ -472,8 +474,7 @@ void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem ) } void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, - const QList& theZonesList, - bool theLandCover ) + const QList& theZonesList ) { HYDROGUI_Region* aRegion = dynamic_cast(theRegionItem); if ( aRegion ) @@ -495,17 +496,15 @@ void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); if ( aPanel ) - { - theLandCover ? aPanel->refreshLandCoverZonesBrowser(): aPanel->refreshZonesBrowser(); - } - createPreview( theLandCover ); + aPanel->refreshZonesBrowser(); + createPreview( false ); } } } void HYDROGUI_CalculationOp::onCreateRegion( const QList& theZonesList ) { - if ( createRegion( theZonesList, false ) ) + if ( createRegion( theZonesList ) ) { HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -517,20 +516,6 @@ void HYDROGUI_CalculationOp::onCreateRegion( const QList& theZ } } -void HYDROGUI_CalculationOp::onCreateLandCoverRegion( const QList& theZonesList ) -{ - if ( createRegion( theZonesList, true ) ) - { - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( aPanel ) - { - aPanel->refreshLandCoverZonesBrowser(); - } - createPreview( true ); - } -} - void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theMergeObjectName ) { HYDROGUI_CalculationDlg* aPanel = @@ -551,26 +536,6 @@ void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theMerge } } -void HYDROGUI_CalculationOp::onSetMergeStricklerType( int theMergeType, QString& theStricklerTypeName ) -{ - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( aPanel ) - { - HYDROGUI_Zone* aZone = aPanel->getCurrentZone(); - if ( aZone ) - { - aZone->setMergeType( theMergeType, theStricklerTypeName ); - HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() ); - if ( aShape ) - { - aShape->update( true, false ); - } - } - aPanel->refreshLandCoverZonesBrowser(); - } -} - void HYDROGUI_CalculationOp::onAddObjects() { HYDROGUI_CalculationDlg* aPanel = @@ -636,7 +601,7 @@ bool HYDROGUI_CalculationOp::confirmRegionsChange() const if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false ); + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions(); if ( aSeq.Length() > 0 ) { // If there are already defined zones then ask a user to confirm zones recalculation @@ -661,7 +626,7 @@ bool HYDROGUI_CalculationOp::confirmOrderChange() const if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false ); + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions(); if ( aSeq.Length() > 0 ) { // If there are already defined zones then ask a user to confirm zones recalculation @@ -686,7 +651,7 @@ bool HYDROGUI_CalculationOp::confirmRuleChange() const if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false ); + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions(); if ( aSeq.Length() > 0 ) { // If there are already defined zones then ask a user to confirm zones recalculation @@ -711,7 +676,7 @@ bool HYDROGUI_CalculationOp::confirmModeChange() const if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false ); + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions(); if ( aSeq.Length() > 0 ) { // If there are already defined zones then ask a user to confirm zones recalculation @@ -758,106 +723,6 @@ bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning return ( anAnswer == QMessageBox::Yes ); } -bool HYDROGUI_CalculationOp::confirmLandCoverRegionsChange() const -{ - // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); - if ( !isConfirmed ) - { - // If not modified check if the case has already defined regions with land cover zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true ); - if ( aSeq.Length() > 0 ) - { - // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation - isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(), - tr( "REGIONS_CHANGED" ), - tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_REGIONS" ), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No ) == QMessageBox::Yes ); - } - else - { - isConfirmed = true; // No regions - no land cover zones - nothing to recalculate - } - } - return isConfirmed; -} - -bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const -{ - // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); - if ( !isConfirmed ) - { - // If not modified check if the case has already defined regions with land cover zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true ); - if ( aSeq.Length() > 0 ) - { - // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation - isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(), - tr( "MODE_CHANGED" ), - tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_MODE" ), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No ) == QMessageBox::Yes ); - } - else - { - isConfirmed = true; // No regions - no land cover zones - nothing to recalculate - } - } - return isConfirmed; -} - -bool HYDROGUI_CalculationOp::confirmLandCoverOrderChange() const -{ - // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); - if ( !isConfirmed ) - { - // If not modified check if the case has already defined regions with land cover zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true ); - if ( aSeq.Length() > 0 ) - { - // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation - isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(), - tr( "ORDER_CHANGED" ), - tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_REGIONS" ), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No ) == QMessageBox::Yes ); - } - else - { - isConfirmed = true; // No regions - no land cover zones - nothing to recalculate - } - } - return isConfirmed; -} - -bool HYDROGUI_CalculationOp::confirmLandCoverRuleChange() const -{ - // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); - if ( !isConfirmed ) - { - // If not modified check if the case has already defined regions with land cover zones - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true ); - if ( aSeq.Length() > 0 ) - { - // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation - isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(), - tr( "RULE_CHANGED" ), - tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_REGIONS" ), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No ) == QMessageBox::Yes ); - } - else - { - isConfirmed = true; // No regions - no land cover zones - nothing to recalculate - } - } - return isConfirmed; -} - bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) @@ -877,9 +742,6 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) { myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, false ); } - if ( aPanel->getLandCoverMode() == HYDROData_CalculationCase::MANUAL ) { - myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules, false ); - } theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init; @@ -953,18 +815,19 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } else if( theIndex==2 ) { - // Land covers panel + // Land cover map panel HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return; - setLandCoversVisible( true ); + setLandCoverMapVisible( true ); QStringList aList; QStringList anEntryList; HYDROData_SequenceOfObjects aSeq; + /* TODO: get all land cover map objects to fill in combo-box Handle(HYDROData_StricklerTable) aStricklerTableObj; QString aStricklerTableName; @@ -992,16 +855,6 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) aPanel->setStricklerTable( aList.at( 0 ), false ); //@ASL: myEditedObject->SetToUpdate( anUpdateState ); - // Fill in list widget with all available land covers - aSeq = HYDROGUI_Tool::GetLandCovers( module() ); - getNamesAndEntries( aSeq, aList, anEntryList ); - aPanel->setAllLandCovers( aList, anEntryList ); - - // Set list of included land covers - aSeq = myEditedObject->GetLandCovers(); - getNamesAndEntries( aSeq, aList, anEntryList ); - aPanel->includeLandCovers( aList, true ); - if ( !myEditedObject.IsNull() ) { if ( myIsEdit ) @@ -1017,18 +870,9 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) aStricklerTableName = aStricklerTableObj->GetName(); aPanel->setStricklerTable( aStricklerTableName ); } - - // Set mode (Auto or Manual) to defined priority of land covers - aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() ); - - // Set rules defined on land covers - setRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules ); - } - else - { - myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)aPanel->getLandCoverMode() ); } } + */ closePreview( false ); createPreview( true ); @@ -1043,7 +887,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) QApplication::setOverrideCursor( Qt::WaitCursor ); setGeomObjectsVisible( false ); - setLandCoversVisible( false ); + setLandCoverMapVisible( false ); QString aNewCaseName = aPanel->getObjectName(); QString anOldCaseName = myEditedObject->GetName(); @@ -1088,43 +932,12 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } aPanel->setEditZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL ); - // Land cover zones: set parameters for automatic mode - aMode = aPanel->getLandCoverMode(); - if ( aMode == HYDROData_CalculationCase::AUTOMATIC ) - { - // Set objects in the specified order - if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) - { - myEditedObject->RemoveLandCovers(); - foreach ( const QString& aName, aPanel->getAllLandCovers() ) - { - Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aName ) ); - if ( aLandCover.IsNull() ) - { - continue; - } - myEditedObject->AddLandCover( aLandCover ); - } - - // Clear priority rules - myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules, true ); - // Set priority rules - foreach ( const HYDROData_CustomRule& aRule, aPanel->getLandCoverRules() ) { - myEditedObject->AddRule( aRule.Object1, aRule.Priority, - aRule.Object2, HYDROData_Zone::Merge_Object, - HYDROData_CalculationCase::DataTag_CustomLandCoverRules ); - } - } - } - aPanel->setEditLandCoverZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL ); - if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ) { myShowZones = true; myEditedObject->Update(); - AssignDefaultZonesColors( false ); + AssignDefaultZonesColors(); //aPanel->setEditedObject( myEditedObject ); aPanel->refreshZonesBrowser(); @@ -1133,13 +946,11 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) createPreview( false ); anIsToUpdateOb = true; - - myUpdateLandCoverZonesPrs = true; } else { // Show zones - setZonesVisible( true, false ); + setZonesVisible( true ); if ( isNameChanged ) { module()->getDataModel()->updateObjectTree( myEditedObject ); @@ -1147,51 +958,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } QApplication::restoreOverrideCursor(); - } - else if( theIndex==4 ) - { - // Partition of Land covers panel - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - QApplication::setOverrideCursor( Qt::WaitCursor ); - - bool anIsToUpdateOb = false; - if ( myUpdateLandCoverZonesPrs ) - { - myShowZones = true; - - AssignDefaultZonesColors( true ); - - aPanel->refreshLandCoverZonesBrowser(); - - anIsToUpdateOb = true; - } - - closePreview( false ); - createPreview( true ); - - if ( myUpdateLandCoverZonesPrs ) - myUpdateLandCoverZonesPrs = false; - else - { - // Hide zones - setZonesVisible( false, false ); - // Show land cover zones - setZonesVisible( true, true ); - } - - if ( anIsToUpdateOb ) { - SUIT_DataBrowser* anObjBrowser = ((LightApp_Application*)module()->application())->objectBrowser(); - if ( anObjBrowser ) { - anObjBrowser->updateTree( module()->getDataModel()->getDataObject( myEditedObject ), false ); - } - } - - QApplication::restoreOverrideCursor(); - } + } } void HYDROGUI_CalculationOp::onHideZones( const int theIndex ) @@ -1205,34 +972,30 @@ void HYDROGUI_CalculationOp::onHideZones( const int theIndex ) } if( theIndex==2 ) { - setLandCoversVisible( true ); + setLandCoverMapVisible( true ); closePreview( false ); createPreview( true ); // Hide zones - setZonesVisible( false, false ); - // Hide land covers - setZonesVisible( false, true ); + setZonesVisible( false ); } else if( theIndex==3 ) { - AssignDefaultZonesColors( false ); + AssignDefaultZonesColors(); closePreview( false ); createPreview( false ); - // Hide land cover zones - setZonesVisible( false, true ); // Show zones - setZonesVisible( true, false ); + setZonesVisible( true ); } } -void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible, const bool theLandCover ) +void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible ) { myShowZones = theIsVisible; - HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions( theLandCover ); + HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions(); HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions ); HYDROData_SequenceOfObjects aZones; Handle(HYDROData_Region) aRegion; @@ -1275,21 +1038,15 @@ void HYDROGUI_CalculationOp::setGeomObjectsVisible( bool theIsVisible ) } } -void HYDROGUI_CalculationOp::setLandCoversVisible( bool theIsVisible ) +void HYDROGUI_CalculationOp::setLandCoverMapVisible( bool theIsVisible ) { - myShowLandCovers = theIsVisible; - - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers(); - - HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); - for ( ; anIter.More(); anIter.Next() ) { - setObjectVisibility( anIter.Value(), theIsVisible ); - } + myShowLandCoverMap = theIsVisible; + setObjectVisibility( myEditedObject->GetLandCoverMap(), theIsVisible ); } -void HYDROGUI_CalculationOp::AssignDefaultZonesColors( const bool theLandCover ) +void HYDROGUI_CalculationOp::AssignDefaultZonesColors() { - HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions( theLandCover ); + HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions(); HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions ); HYDROData_SequenceOfObjects aZones; Handle(HYDROData_Region) aRegion; @@ -1370,13 +1127,10 @@ void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDat } if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomRules ) - aPanel->setRules( aRules ); - else if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomLandCoverRules ) - aPanel->setLandCoverRules( aRules ); + aPanel->setRules( aRules ); } -bool HYDROGUI_CalculationOp::createRegion( const QList& theZonesList, - const bool theLandCover ) +bool HYDROGUI_CalculationOp::createRegion( const QList& theZonesList ) { bool aRetValue = false; @@ -1393,23 +1147,22 @@ bool HYDROGUI_CalculationOp::createRegion( const QList& theZon } if ( aZonesList.length() > 0 ) { - module()->getDataModel()->createNewRegion( myEditedObject, aZonesList, theLandCover ); + module()->getDataModel()->createNewRegion( myEditedObject, aZonesList ); aRetValue = true; } return aRetValue; } -void HYDROGUI_CalculationOp::createPreview( const bool theLandCover ) +void HYDROGUI_CalculationOp::createPreview( const bool theLandCoverMap ) { LightApp_Application* anApp = module()->getApp(); HYDROData_SequenceOfObjects aSeq; - if ( theLandCover && myShowLandCovers ) + if ( theLandCoverMap && myShowLandCoverMap ) { - HYDROData_SequenceOfObjects aSeqLC = myEditedObject->GetLandCovers(); - aSeq.Append( aSeqLC ); + aSeq.Append( myEditedObject->GetLandCoverMap() ); } - else if ( !theLandCover && myShowGeomObjects ) + else if ( !theLandCoverMap && myShowGeomObjects ) { HYDROData_SequenceOfObjects aSeqGO = myEditedObject->GetGeometryObjects(); aSeq.Append( aSeqGO ); @@ -1420,7 +1173,7 @@ void HYDROGUI_CalculationOp::createPreview( const bool theLandCover ) if ( myShowZones ) { // Gather zones for displaying - HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions( theLandCover ); + HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions(); HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions ); HYDROData_SequenceOfObjects aZones; Handle(HYDROData_Region) aRegion; @@ -1648,80 +1401,6 @@ void HYDROGUI_CalculationOp::onRemoveGroups() aPanel->excludeGroups( aSelectedList ); } -void HYDROGUI_CalculationOp::onChangeLandCoverMode( int theMode ) -{ - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - if ( !confirmLandCoverModeChange() ) { - aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() ); - return; - } - - myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)theMode ); - aPanel->setLandCoverMode( theMode ); -} - -void HYDROGUI_CalculationOp::onAddLandCovers() -{ - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - // Add land covers selected in the module browser to the calculation case - QStringList aSelectedList = aPanel->getSelectedAvailableLandCovers(); - if ( aSelectedList.isEmpty() || !confirmLandCoverRegionsChange() ) - return; - - QStringList anAddedList; - for (int i = 0; i < aSelectedList.length(); i++) - { - Handle(HYDROData_LandCover) anObject = Handle(HYDROData_LandCover)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) ); - if ( anObject.IsNull() ) - continue; - - if ( myEditedObject->AddLandCover( anObject ) ) - anAddedList.append( anObject->GetName() ); - } - - if ( !anAddedList.isEmpty() ) - { - aPanel->includeLandCovers( anAddedList, false ); - createPreview( true ); - } -} - -void HYDROGUI_CalculationOp::onRemoveLandCovers() -{ - // Remove selected objects from the calculation case - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - QStringList aSelectedList = aPanel->getSelectedLandCovers(); - if ( aSelectedList.isEmpty() || !confirmLandCoverRegionsChange() ) - return; - - for (int i = 0; i < aSelectedList.length(); i++) - { - Handle(HYDROData_LandCover) anObject = Handle(HYDROData_LandCover)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) ); - if ( anObject.IsNull() ) - continue; - - setObjectVisibility( anObject, false ); - myEditedObject->RemoveLandCover( anObject ); - } - - module()->update( UF_OCCViewer ); - aPanel->excludeLandCovers( aSelectedList ); -} - void HYDROGUI_CalculationOp::onChangeMode( int theMode ) { HYDROGUI_CalculationDlg* aPanel = @@ -1750,18 +1429,6 @@ void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed ) myEditedObject->Changed( HYDROData_Entity::Geom_2d ); } -void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed ) -{ - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - isConfirmed = confirmLandCoverOrderChange(); - if( isConfirmed ) - myEditedObject->Changed( HYDROData_Entity::Geom_No ); -} - void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed ) { HYDROGUI_CalculationDlg* aPanel = @@ -1774,22 +1441,10 @@ void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed ) myEditedObject->Changed( HYDROData_Entity::Geom_2d ); } -void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed ) -{ - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - isConfirmed = confirmLandCoverRuleChange(); - if( isConfirmed ) - myEditedObject->Changed( HYDROData_Entity::Geom_No ); -} - void HYDROGUI_CalculationOp::onRegenerateColors() { // For geometry zones - AssignDefaultZonesColors( false ); - setZonesVisible( false, false ); - setZonesVisible( true, false ); + AssignDefaultZonesColors(); + setZonesVisible( false ); + setZonesVisible( true ); } diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 1a5998ad..b6791f0d 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -80,43 +80,19 @@ protected slots: */ void onRemoveGroups(); - /** - * Change the creation mode related to land covers. - * @param theMode the mode to set - */ - void onChangeLandCoverMode( int theMode ); - - /** - * Add land covers selected in the module browser to the calculation case. - */ - void onAddLandCovers(); - /** - * Remove selected land covers from the calculation case. - */ - void onRemoveLandCovers(); - /** * Set the given bathymetry/type merge type to the current zone. */ void onSetMergeType( int theMergeType, QString& theMergeObjectName ); - /** - * Set the given Strickler merge type to the current zone. - */ - void onSetMergeStricklerType( int theMergeType, QString& theStricklerTypeName ); /** * Selected zones are moved to the existing region. */ void onMoveZones( SUIT_DataObject* theRegionItem, - const QList& theZonesList, - bool theLandCover ); + const QList& theZonesList); /** * Selected zones are moved to the new region to be created. */ void onCreateRegion( const QList& theZonesList ); - /** - * Selected land cover zones are moved to the new region to be created. - */ - void onCreateLandCoverRegion( const QList& theZonesList ); /** * Case objects must be splitted to zones if the case has been modified or new. */ @@ -135,9 +111,9 @@ protected slots: */ void onObjectsSelected(); /** - * Land cover is selected in the list on the third wizard page + * Land cover map is selected in the list on the third wizard page */ - void onLandCoversSelected(); + void onLandCoverMapSelected(); /** * Boundary polyline is selected in the list on the first wizard page */ @@ -148,27 +124,25 @@ protected slots: void onStricklerTableSelected( const QString & theObjName ); void onOrderChanged( bool& isConfirmed ); - void onOrderLandCoverChanged( bool& isConfirmed ); void onRuleChanged( bool& isConfirmed ); - void onRuleLandCoverChanged( bool& isConfirmed ); void onRegenerateColors(); private: - void createPreview( const bool theLandCover); + void createPreview( const bool theLandCoverMap); void closePreview( bool theRemoveViewManager = true ); void setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible ); - void setZonesVisible( bool theIsVisible, const bool theLandCover ); + void setZonesVisible( bool theIsVisible ); void setGeomObjectsVisible( bool theIsVisible ); - void setLandCoversVisible( bool theIsVisible ); + void setLandCoverMapVisible( bool theIsVisible ); void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, QStringList& theNames, QStringList& theEntries ) const; /** * Internal method that used to assign unique default colors for zones */ - void AssignDefaultZonesColors( const bool theLandCover ); + void AssignDefaultZonesColors(); /** * Internal method that used to generate default color for zone * @param theIndex the index of color to be generated @@ -187,8 +161,7 @@ private: void setRules( HYDROData_CalculationCase::DataTag theDataTag ); - bool createRegion( const QList& theZonesList, - const bool theLandCover ); + bool createRegion( const QList& theZonesList ); bool confirmRegionsChange() const; bool confirmModeChange() const; @@ -196,17 +169,11 @@ private: bool confirmRuleChange() const; bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const; - bool confirmLandCoverRegionsChange() const; - bool confirmLandCoverModeChange() const; - bool confirmLandCoverOrderChange() const; - bool confirmLandCoverRuleChange() const; - private: bool myIsEdit; bool myShowZones; bool myShowGeomObjects; - bool myShowLandCovers; - bool myUpdateLandCoverZonesPrs; + bool myShowLandCoverMap; Handle(HYDROData_CalculationCase) myEditedObject; SUIT_ViewManager* myActiveViewManager; diff --git a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx index e2998187..2cfb54ab 100644 --- a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include @@ -73,10 +73,10 @@ void HYDROGUI_ExportFileOp::startOperation() Handle(HYDROData_PolylineXY) aPolyXY; Handle(HYDROData_Polyline3D) aPoly3D; - Handle(HYDROData_LandCover) aLC; NCollection_Sequence aPolyXYSeq; NCollection_Sequence aPoly3DSeq; - NCollection_Sequence aLCSeq; + // TODO + Handle_HYDROData_LandCoverMap aLCSeq; HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) @@ -88,10 +88,6 @@ void HYDROGUI_ExportFileOp::startOperation() aPoly3D = Handle(HYDROData_Polyline3D)::DownCast( aSeq.Value( anIndex )); if (!aPoly3D.IsNull()) aPoly3DSeq.Append(aPoly3D); - - aLC = Handle(HYDROData_LandCover)::DownCast( aSeq.Value( anIndex )); - if (!aLC.IsNull()) - aLCSeq.Append(aLC); } if (!aPolyXYSeq.IsEmpty() && !aPoly3DSeq.IsEmpty()) @@ -103,13 +99,12 @@ void HYDROGUI_ExportFileOp::startOperation() aName = aPolyXYSeq(1)->GetName(); if (aPoly3DSeq.Size() == 1 && aPolyXYSeq.IsEmpty()) aName = aPoly3DSeq(1)->GetName(); - if (aLCSeq.Size() == 1 && aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty()) - aName = aLCSeq(1)->GetName(); QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), aName, aFilter, tr( "EXPORT_TO_SHAPE_FILE" ), false ); if (!aFileName.isEmpty()) { QStringList aNonExpList; HYDROData_ShapeFile anExporter; + // TODO anExporter.Export(aFileName, aPolyXYSeq, aPoly3DSeq, aLCSeq, aNonExpList); if (!aNonExpList.empty()) { diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx deleted file mode 100644 index 40a4b721..00000000 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "HYDROGUI_ImportLandCoverDlg.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -HYDROGUI_ImportLandCoverDlg::HYDROGUI_ImportLandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_InputPanel( theModule, theTitle ) -{ - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - - myFileNameGroup = new QGroupBox( tr( "IMPORT_LANDCOVER_FROM_FILE" ) ); - - QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup ); - - myFileName = new QLineEdit( myFileNameGroup ); - myFileName->setReadOnly( true ); - - QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup ); - aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); - - QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup ); - aFileNameLayout->setMargin( 5 ); - aFileNameLayout->setSpacing( 5 ); - aFileNameLayout->addWidget( aFileNameLabel ); - aFileNameLayout->addWidget( myFileName ); - aFileNameLayout->addWidget( aBrowseBtn ); - - myObjectNameGroup = new QGroupBox( tr( "LANDCOVER_NAME" ) ); - - QLabel* aLandcoverNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup ); - myObjectName = new QLineEdit( myObjectNameGroup ); - - QBoxLayout* aLandcoverNameLayout = new QHBoxLayout( myObjectNameGroup ); - aLandcoverNameLayout->setMargin( 5 ); - aLandcoverNameLayout->setSpacing( 5 ); - aLandcoverNameLayout->addWidget( aLandcoverNameLabel ); - aLandcoverNameLayout->addWidget( myObjectName ); - - QGroupBox* aPolygonsGroup = new QGroupBox( tr( "FOUNDED_POLYGONS" ), mainFrame() ); - myPolygons = new QListWidget( aPolygonsGroup ); - myPolygons->setSelectionMode( QListWidget::ExtendedSelection ); - myPolygons->setEditTriggers( QListWidget::NoEditTriggers ); - myPolygons->setViewMode( QListWidget::ListMode ); - myPolygons->setSortingEnabled( false ); - - QBoxLayout* aPolygonsLayout = new QVBoxLayout; - aPolygonsLayout->addWidget( myPolygons ); - aPolygonsGroup->setLayout( aPolygonsLayout ); - - // Layout - addWidget( myFileNameGroup ); - addWidget( myObjectNameGroup ); - addWidget( aPolygonsGroup ); - - // Conections - connect( myPolygons, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) ); - connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); -} - -HYDROGUI_ImportLandCoverDlg::~HYDROGUI_ImportLandCoverDlg() -{ -} - -void HYDROGUI_ImportLandCoverDlg::reset() -{ - myPolygons->clear(); -} - -void HYDROGUI_ImportLandCoverDlg::setPolygonNames( const QStringList& theNames ) -{ - myPolygons->clear(); - myPolygons->addItems( theNames ); -} - -void HYDROGUI_ImportLandCoverDlg::removePolygonNames( const QStringList& theNames ) -{ - QList aFoundItems; - - foreach ( const QString& aName, theNames ) { - aFoundItems = myPolygons->findItems( aName, Qt::MatchExactly ); - foreach ( QListWidgetItem* anItem, aFoundItems ) { - anItem = myPolygons->takeItem( myPolygons->row( anItem ) ); - delete anItem; - } - } -} - -void HYDROGUI_ImportLandCoverDlg::setSelectedPolygonNames( const QStringList& theNames ) -{ - myPolygons->clearSelection(); - - foreach( const QString aName, theNames ) { - QList anItems = myPolygons->findItems( aName, Qt::MatchExactly ); - if ( anItems.count() == 1 ) { - anItems.first()->setSelected( true ); - } - } -} - -void HYDROGUI_ImportLandCoverDlg::onItemSelectionChanged() -{ - emit selectionChanged( getSelectedPolygonNames() ); -} - -QStringList HYDROGUI_ImportLandCoverDlg::getSelectedPolygonNames() const -{ - QStringList aSelectedNames; - - QList aSelectedItems = myPolygons->selectedItems(); - foreach( const QListWidgetItem* anItem, aSelectedItems ) { - aSelectedNames << anItem->text(); - } - - return aSelectedNames; -} - - -void HYDROGUI_ImportLandCoverDlg::onBrowse() -{ - QString aFilter( tr( "LANDCOVER_FILTER" ) ); - QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_LANDCOVER_FROM_FILE" ), true ); - - if( !aFileName.isEmpty() ) - { - setFileName( aFileName ); - emit FileSelected( aFileName ); - } -} - -void HYDROGUI_ImportLandCoverDlg::setObjectName( const QString& theName ) -{ - myObjectName->setText( theName ); - myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() ); -} - -QString HYDROGUI_ImportLandCoverDlg::getObjectName() const -{ - return myObjectName->text(); -} - -void HYDROGUI_ImportLandCoverDlg::setFileName( const QString& theFileName ) -{ - myFileName->setText( theFileName ); - - if ( !myObjectNameGroup->isEnabled() ) - myObjectNameGroup->setEnabled( !theFileName.isEmpty() ); -} - -QString HYDROGUI_ImportLandCoverDlg::getFileName() const -{ - return myFileName->text(); -} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h deleted file mode 100644 index 67482a90..00000000 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - - -#ifndef HYDROGUI_ImportLandCoverDlg_H -#define HYDROGUI_ImportLandCoverDlg_H - -#include "HYDROGUI_InputPanel.h" - -class QListWidget; -class QLineEdit; -class QGroupBox; - -class HYDROGUI_ImportLandCoverDlg : public HYDROGUI_InputPanel -{ - Q_OBJECT - -public: - HYDROGUI_ImportLandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ); - virtual ~HYDROGUI_ImportLandCoverDlg(); - - void reset(); - - void setPolygonNames( const QStringList& theNames ); - void removePolygonNames( const QStringList& theNames ); - - void setSelectedPolygonNames( const QStringList& theNames ); - - QStringList getSelectedPolygonNames() const; - - void setObjectName( const QString& theName ); - QString getObjectName() const; - - void setFileName( const QString& theFileName ); - QString getFileName() const; - -signals: - void FileSelected( const QString& theFileName ); - -protected slots: - void onBrowse(); - -signals: - void selectionChanged( const QStringList& ); - -public slots: - void onItemSelectionChanged(); - -private: - QLineEdit* myFileName; - QGroupBox* myFileNameGroup; - QListWidget* myPolygons; - - QGroupBox* myObjectNameGroup; - QLineEdit* myObjectName; - -}; - -#endif diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx deleted file mode 100644 index d7ff0024..00000000 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "HYDROGUI_ImportLandCoverOp.h" - -#include "HYDROGUI_DataModel.h" -#include "HYDROGUI_Module.h" -#include "HYDROGUI_UpdateFlags.h" -#include "HYDROGUI_Tool.h" -#include "HYDROGUI_ImportLandCoverDlg.h" -#include "HYDROGUI_Shape.h" -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - - - -HYDROGUI_ImportLandCoverOp::HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule ) -: HYDROGUI_Operation( theModule ) -{ - setName( tr( "IMPORT_LANDCOVER" ) ); -} - -HYDROGUI_ImportLandCoverOp::~HYDROGUI_ImportLandCoverOp() -{ - erasePreview(); -} - -void HYDROGUI_ImportLandCoverOp::startOperation() -{ - HYDROGUI_Operation::startOperation(); - - if ( !getPreviewManager() ) { - setPreviewManager( ::qobject_cast( - module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); - } - - if ( !isApplyAndClose() ) { - return; - } - - HYDROGUI_ImportLandCoverDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) { - return; - } - - aPanel->reset(); -} - - -HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverOp::createInputPanel() const -{ - HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportLandCoverDlg( module(), getName() ); - - connect( aPanel, SIGNAL( FileSelected( const QString& ) ), SLOT( onFileSelected() ) ); - - connect( aPanel, SIGNAL( selectionChanged( const QStringList& ) ), this, SLOT( onSelectionChanged( const QStringList& ) ) ); - - return aPanel; -} - -bool HYDROGUI_ImportLandCoverOp::processApply( int& theUpdateFlags, - QString& theErrorMsg, - QStringList& theBrowseObjectsEntries ) -{ - - HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) { - return false; - } - - QStringList aSelectedtPolygons = aPanel->getSelectedPolygonNames(); - aPanel->removePolygonNames( aSelectedtPolygons ); - - if (!aSelectedtPolygons.empty()) - { - Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) ); - TopoDS_Shape aResShape; - if (aSelectedtPolygons.size() > 1) - { - TopoDS_Compound cmp; - BRep_Builder BB; - BB.MakeCompound(cmp); - - foreach ( QString aName, aSelectedtPolygons ) { - TopoDS_Shape aShape = myPolygonName2PrsShape.value( aName )->getTopoShape(); - if ( aShape.IsNull() ) - continue; - BB.Add(cmp, aShape); - HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aName ); - delete aShapeToDelete; - } - aResShape = cmp; - } - else - { - TopoDS_Shape aShape = myPolygonName2PrsShape.value( aSelectedtPolygons.first() )->getTopoShape(); - if ( !aShape.IsNull() ) - { - HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aSelectedtPolygons.first() ); - delete aShapeToDelete; - aResShape = aShape; - } - } - if( !aLC.IsNull() ) - { - QString aLCName = aPanel->getObjectName() + "_polygon"; - int i = 0; - for( ;HYDROGUI_Tool::FindObjectByName(module(), aLCName); i++) - aLCName = aPanel->getObjectName() + "_polygon_" + QString::number(i); - aLC->SetName( aLCName ); - aLC->SetFillingColor( aLC->DefaultFillingColor() ); - aLC->SetBorderColor( aLC->DefaultBorderColor() ); - - aLC->SetShape(aResShape); - aLC->Show(); - - //erasePreview(); - - module()->setIsToUpdate( aLC ); - - } - } - - module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init ); - - if ( isApplyAndClose() ) - erasePreview(); - - return true; -} - - -void HYDROGUI_ImportLandCoverOp::onFileSelected() -{ - HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - QString anObjectName = aPanel->getObjectName().simplified(); - anObjectName = aPanel->getFileName(); - if ( !anObjectName.isEmpty() ) - anObjectName = QFileInfo( anObjectName ).baseName(); - - if ( anObjectName.isEmpty() ) - anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LANDCOVER_NAME" ) ); - aPanel->setObjectName( anObjectName ); - - QString aFileName = aPanel->getFileName(); - if ( aFileName.isEmpty() ) - { - abort(); - return; - } - - QString anExt = aFileName.split('.', QString::SkipEmptyParts).back(); - - if (anExt == "shp") - { - startDocOperation(); - QApplication::setOverrideCursor(Qt::WaitCursor); - - QStringList aPolygonsList; - TopTools_SequenceOfShape aFaces; - HYDROData_ShapeFile anImporter; - - SalomeApp_Study* aStudy = dynamic_cast( module()->getApp()->activeStudy() ); - if ( !aStudy ) - return; - - erasePreview(); - - Handle(AIS_InteractiveContext) aCtx = NULL; - int aShapeTypeOfFile = -1; - int aStat = anImporter.ImportLandCovers(aFileName, aPolygonsList, aFaces, aShapeTypeOfFile); - if (aStat == 1) - { - aPanel->setPolygonNames(aPolygonsList); - - LightApp_Application* anApp = module()->getApp(); - if ( !getPreviewManager() ) - setPreviewManager( ::qobject_cast( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); - OCCViewer_ViewManager* aViewManager = getPreviewManager(); - - if ( aViewManager ) - { - if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) - { - aCtx = aViewer->getAISContext(); - connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) ); - } - } - - Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) ); - for ( int i = 1; i <= aFaces.Length(); i++ ) - { - TopoDS_Face aFace = TopoDS::Face(aFaces.Value( i )); - - aLC->SetShape( aFace ); - - if ( aViewManager && !aCtx.IsNull() ) - { - HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); - - aShape->setFillingColor( aLC->DefaultFillingColor(), false, false ); - aShape->setBorderColor( aLC->DefaultBorderColor(), false, false ); - if( !aFace.IsNull() ) - aShape->setShape( aLC->GetShape() ); - myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape); - } - } - aLC->Remove(); - - if ( !aCtx.IsNull() ) - { - UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD ); - aCtx->UpdateCurrentViewer(); - } - - QApplication::restoreOverrideCursor(); - commitDocOperation(); - } - else - { - erasePreview(); - aPanel->setPolygonNames(QStringList()); - aPanel->setObjectName(""); - QApplication::restoreOverrideCursor(); - QString aMess = "Cannot import land cover;\n"; - if (aStat == -1) - aMess += "Cannot open SHP file"; - else if (aStat == -2) - aMess += "Cannot open SHX file"; - else - aMess += "The shape type of file is " + anImporter.GetShapeTypeName(aShapeTypeOfFile); - SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER" ), aMess); - commitDocOperation(); - //abort(); - } - anImporter.Free(); - - } - -} - -void HYDROGUI_ImportLandCoverOp::onSelectionChanged( const QStringList& theSelectedNames ) -{ - Handle(AIS_InteractiveContext) aCtx = NULL; - - OCCViewer_ViewManager* aViewManager = getPreviewManager(); - if ( aViewManager ) { - if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) { - aCtx = aViewer->getAISContext(); - } - } - - if ( !aCtx.IsNull() ) { - foreach ( QString aName, myPolygonName2PrsShape.keys() ) { - Handle(AIS_InteractiveObject) anObject = - myPolygonName2PrsShape.value(aName)->getAISObject(); - - bool isSelected = theSelectedNames.contains( aName ); - if ( ( isSelected && !aCtx->IsSelected( anObject) ) || - ( !isSelected && aCtx->IsSelected( anObject) ) ) { - aCtx->AddOrRemoveSelected( anObject, Standard_False ); - } - } - aCtx->UpdateCurrentViewer(); - } -} - - -void HYDROGUI_ImportLandCoverOp::onViewerSelectionChanged() -{ - // Get panel - HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) { - return; - } - - OCCViewer_ViewManager* aViewManager = getPreviewManager(); - Handle(AIS_InteractiveContext) aCtx = NULL; - if ( aViewManager ) { - if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) { - aCtx = aViewer->getAISContext(); - } - } - - if ( !aCtx.IsNull() ) - { - QStringList aSelectedNames; - foreach ( QString aName, myPolygonName2PrsShape.keys() ) { - bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() ); - if ( isSelected ) { - aSelectedNames << aName; - } - } - aPanel->setSelectedPolygonNames( aSelectedNames ); - } -} - - -void HYDROGUI_ImportLandCoverOp::erasePreview() -{ - foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape ) { - delete aShape; - } - - myPolygonName2PrsShape.clear(); -} - - -void HYDROGUI_ImportLandCoverOp::abortOperation() -{ - LightApp_Application* anApp = module()->getApp(); - if ( anApp ) { - anApp->disconnect( this ); - } - - erasePreview(); - - HYDROGUI_Operation::abortOperation(); -} - - diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h deleted file mode 100644 index 6b48f0ef..00000000 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef HYDROGUI_IMPORTLANDCOVER_H -#define HYDROGUI_IMPORTLANDCOVER_H - -#include "HYDROGUI_Operation.h" -#include -#include - -class SUIT_FileDlg; -class HYDROGUI_Shape; -class TopoDS_Face; - - -class HYDROGUI_ImportLandCoverOp : public HYDROGUI_Operation -{ - Q_OBJECT - -public: - HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule ); - virtual ~HYDROGUI_ImportLandCoverOp(); - -protected: - virtual void startOperation(); - virtual void abortOperation(); - - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ); - HYDROGUI_InputPanel* createInputPanel() const; - - void erasePreview(); - -protected slots: - void onFileSelected(); - void onSelectionChanged( const QStringList& theSelectedNames ); - void onViewerSelectionChanged (); - -private: - QMap myPolygonName2PrsShape; -}; - -#endif diff --git a/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx b/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx deleted file mode 100644 index a0c027be..00000000 --- a/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "HYDROGUI_LandCoverDlg.h" - -#include "HYDROGUI_Module.h" -#include "HYDROGUI_OrderedListWidget.h" -#include "HYDROGUI_ListSelector.h" - -#include -#include - -#include -#include -#include -#include -#include - -HYDROGUI_LandCoverDlg::HYDROGUI_LandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_BasicZoneDlg( theModule, theTitle, - tr( "LAND_COVER_NAME" ), tr( "NAME" ), - tr( "LAND_COVER_PARAMETERS" ), tr( "LAND_COVER_STRICKLER_TYPE" ) ) -{ - myPolylines = new HYDROGUI_OrderedListWidget( myPolylineFrame, 16 ); - myPolylines->setHiddenObjectsShown(true); - myPolylines->setVisibilityIconShown(false); - myPolylines->setContentsMargins(QMargins()); - myPolylines->setOrderingEnabled( true ); - - // Include/Exclude buttons - QFrame* aBtnsFrame = new QFrame( myPolylineFrame ); - QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame ); - aBtnsLayout->setMargin( 0 ); - aBtnsLayout->setSpacing( 5 ); - aBtnsFrame->setLayout( aBtnsLayout ); - QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame ); - QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame ); - - // Fill the butons frame with two buttons - aBtnsLayout->addWidget( anAddBtn ); - aBtnsLayout->addWidget( aRemoveBtn ); - aBtnsLayout->addStretch( 1 ); - - QGridLayout* aPolyLayout = new QGridLayout( myPolylineFrame ); - aPolyLayout->setMargin( 0 ); - aPolyLayout->setSpacing( 10 ); - aPolyLayout->addWidget( new QLabel( tr( "LAND_COVER_POLYLINES" ), myPolylineFrame ), 0, 0, 1, 2 ); - aPolyLayout->addWidget( aBtnsFrame, 1, 0, 1, 1 ); - aPolyLayout->addWidget( myPolylines, 1, 1, 1, 1 ); - - QBoxLayout* aParamLayout = new QVBoxLayout( myParamGroup ); - aParamLayout->setMargin( 5 ); - aParamLayout->setSpacing( 5 ); - aParamLayout->addWidget( myPolylineFrame ); - - // Create selector - if ( module() ) { - HYDROGUI_ListSelector* aListSelector = - new HYDROGUI_ListSelector( myPolylines, module()->getApp()->selectionMgr() ); - aListSelector->setAutoBlock( true ); - } - - // Connect signals and slots - connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) ); - connect( myPolylines, SIGNAL( orderPolylinesChanged() ), SLOT( onOrderPolylinesChanged() ) ); - connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addPolylines() ) ); - connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removePolylines() ) ); -} - -HYDROGUI_LandCoverDlg::~HYDROGUI_LandCoverDlg() -{ -} - -void HYDROGUI_LandCoverDlg::reset() -{ - bool isBlocked = blockSignals( true ); - - HYDROGUI_BasicZoneDlg::reset(); - - HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList; - myPolylines->setObjects(anObject2VisibleList); - myPolylines->setOrderingEnabled( false ); - - blockSignals( isBlocked ); - - onZoneDefChanged(); -} - -bool HYDROGUI_LandCoverDlg::includePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines ) -{ - QStringList anIncludedPolylinesNames = myPolylines->getAllNames(); - - bool aSetOfPolylinesChanged = false; - foreach ( const HYDROGUI_ListModel::Object2Visible& aSelectedPolyline, theSelectedPolylines ) - { - if ( !anIncludedPolylinesNames.contains( aSelectedPolyline.first->GetName() ) ) - { - myPolylines->addObject( aSelectedPolyline ); - aSetOfPolylinesChanged = true; - } - } - myPolylines->setOrderingEnabled( myPolylines->getObjects().count() > 1 ); - - return aSetOfPolylinesChanged; -} - -bool HYDROGUI_LandCoverDlg::excludePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines ) -{ - bool aSetOfPolylinesChanged = !theSelectedPolylines.isEmpty(); - - foreach ( const HYDROGUI_ListModel::Object2Visible& aSelectedPolyline, theSelectedPolylines ) - myPolylines->removeObjectByName( aSelectedPolyline.first->GetName() ); - myPolylines->setOrderingEnabled( myPolylines->getObjects().count() > 1 ); - - return aSetOfPolylinesChanged; -} - -QStringList HYDROGUI_LandCoverDlg::getPolylineNames() const -{ - return myPolylines->getAllNames(); -} - -QStringList HYDROGUI_LandCoverDlg::getSelectedPolylineNames() const -{ - return myPolylines->getSelectedNames(); -} - -void HYDROGUI_LandCoverDlg::onZoneDefChanged() -{ - if ( signalsBlocked() ) - return; - - QStringList aPolylineNames = getPolylineNames(); - emit CreatePreview( aPolylineNames ); -} - -void HYDROGUI_LandCoverDlg::onOrderPolylinesChanged() -{ - // TODO: implement this method -} diff --git a/src/HYDROGUI/HYDROGUI_LandCoverDlg.h b/src/HYDROGUI/HYDROGUI_LandCoverDlg.h deleted file mode 100644 index 26b97ba5..00000000 --- a/src/HYDROGUI/HYDROGUI_LandCoverDlg.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef HYDROGUI_LANDCOVERDLG_H -#define HYDROGUI_LANDCOVERDLG_H - -#include "HYDROGUI_BasicZoneDlg.h" - -#include "HYDROGUI_ListModel.h" - -class HYDROGUI_OrderedListWidget; - -class QListWidget; - -class HYDROGUI_LandCoverDlg : public HYDROGUI_BasicZoneDlg -{ - Q_OBJECT - -public: - HYDROGUI_LandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ); - virtual ~HYDROGUI_LandCoverDlg(); - - virtual void reset(); - - bool includePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines ); - bool excludePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines ); - QStringList getPolylineNames() const; - QStringList getSelectedPolylineNames() const; - -signals: - void CreatePreview( const QStringList& thePolylineNames ); - void orderPolylinesChanged(); - void addPolylines(); - void removePolylines(); - -private slots: - void onZoneDefChanged(); - void onOrderPolylinesChanged(); - -private: - HYDROGUI_OrderedListWidget* myPolylines; -}; - -#endif diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx deleted file mode 100644 index d81f0d07..00000000 --- a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "HYDROGUI_LandCoverOp.h" - -#include "HYDROGUI_LandCoverDlg.h" -#include "HYDROGUI_Module.h" -#include "HYDROGUI_OCCDisplayer.h" -#include "HYDROGUI_Shape.h" -#include "HYDROGUI_Tool.h" -#include "HYDROGUI_UpdateFlags.h" -#include "HYDROGUI_DataObject.h" - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include - -HYDROGUI_LandCoverOp::HYDROGUI_LandCoverOp( HYDROGUI_Module* theModule, - const bool theIsEdit ) -: HYDROGUI_Operation( theModule ), - myIsEdit( theIsEdit ), - myPreviewPrs( 0 ) -{ - setName( theIsEdit ? tr( "EDIT_LAND_COVER" ) : tr( "CREATE_LAND_COVER" ) ); -} - -HYDROGUI_LandCoverOp::~HYDROGUI_LandCoverOp() -{ - closePreview(); -} - -void HYDROGUI_LandCoverOp::startOperation() -{ - HYDROGUI_Operation::startOperation(); - - HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - aPanel->blockSignals( true ); - - aPanel->reset(); - - QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LAND_COVER_NAME" ) ); - - HYDROGUI_ListModel::Object2VisibleList aSelectedPolylines; - QString aSelectedStricklerType; - - if ( myIsEdit ) - { - if ( isApplyAndClose() ) - myEditedObject = Handle(HYDROData_LandCover)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); - if ( !myEditedObject.IsNull() ) - { - anObjectName = myEditedObject->GetName(); - - HYDROData_SequenceOfObjects aRefPolylines = myEditedObject->GetPolylines(); - for ( int i = aRefPolylines.Lower(); i <= aRefPolylines.Upper(); i++ ) { - Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aRefPolylines.Value( i ) ); - if ( !aPolyline.IsNull() ) { - aSelectedPolylines.append( HYDROGUI_ListModel::Object2Visible( aPolyline, true ) ); - } - } - } - - aSelectedStricklerType = myEditedObject->GetStricklerType(); - } - - aPanel->setObjectName( anObjectName ); - // Construct a list of unique names of all Strickler types defined within the data model - QStringList aStricklerTypes; - HYDROData_Iterator anIterator( doc(), KIND_STRICKLER_TABLE ); - for( ; anIterator.More(); anIterator.Next() ) - { - Handle(HYDROData_StricklerTable) aStricklerTableObj = - Handle(HYDROData_StricklerTable)::DownCast( anIterator.Current() ); - if ( !aStricklerTableObj.IsNull() ) - { - // Get Strickler table data from the data model - QStringList aTypes = aStricklerTableObj->GetTypes(); - for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it ) - { - QString aType = *it; - if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ) ) - aStricklerTypes.append( aType ); - } - } - } - - aStricklerTypes.sort(); - aPanel->setAdditionalParams( aStricklerTypes ); - - aPanel->blockSignals( false ); - - aPanel->includePolylines( aSelectedPolylines ); - aPanel->setSelectedAdditionalParamName( aSelectedStricklerType ); -} - -void HYDROGUI_LandCoverOp::abortOperation() -{ - closePreview(); - - HYDROGUI_Operation::abortOperation(); -} - -void HYDROGUI_LandCoverOp::commitOperation() -{ - closePreview(); - - HYDROGUI_Operation::commitOperation(); -} - -HYDROGUI_InputPanel* HYDROGUI_LandCoverOp::createInputPanel() const -{ - HYDROGUI_LandCoverDlg* aPanel = new HYDROGUI_LandCoverDlg( module(), getName() ); - connect( aPanel, SIGNAL( CreatePreview( const QStringList& ) ), - this, SLOT( onCreatePreview( const QStringList& ) ) ); - connect( aPanel, SIGNAL( addPolylines() ), SLOT( onAddPolylines() ) ); - connect( aPanel, SIGNAL( removePolylines() ), SLOT( onRemovePolylines() ) ); - return aPanel; -} - -bool HYDROGUI_LandCoverOp::processApply( int& theUpdateFlags, - QString& theErrorMsg, - QStringList& theBrowseObjectsEntries ) -{ - HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return false; - - QString anObjectName = aPanel->getObjectName().simplified(); - if ( anObjectName.isEmpty() ) - { - theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); - return false; - } - - if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) ) - { - // check that there are no other objects with the same name in the document - Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); - if( !anObject.IsNull() ) - { - theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); - return false; - } - } - - HYDROData_SequenceOfObjects aZonePolylines; - QString aStricklerType; - - QStringList aSelectedPolylineNames = aPanel->getPolylineNames(); - QStringList::const_iterator anIt = aSelectedPolylineNames.begin(), aLast = aSelectedPolylineNames.end(); - for( ; anIt!=aLast; anIt++ ) - { - QString aPolylineName = *anIt; - if ( !aPolylineName.isEmpty() ) - { - aZonePolylines.Append( Handle(HYDROData_PolylineXY)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ) ); - } - } - - if ( aZonePolylines.IsEmpty() ) - { - theErrorMsg = tr( "POLYLINES_NOT_DEFINED" ); - return false; - } - - QString aSelectedStricklerType = aPanel->getSelectedAdditionalParamName(); - - TCollection_AsciiString anError; - if ( HYDROData_LandCover::buildShape( aZonePolylines, anError ).IsNull() ) - { - if ( !anError.IsEmpty() ) { - theErrorMsg = HYDROGUI_Tool::ToQString( anError ); - } else { - theErrorMsg = tr( "LAND_COVER_OBJECT_CANNOT_BE_CREATED" ); - } - return false; - } - - Handle(HYDROData_LandCover) aZoneObj = myIsEdit ? myEditedObject : - Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) ); - - aZoneObj->SetName( anObjectName ); - - if ( !myIsEdit ) - { - aZoneObj->SetFillingColor( aZoneObj->DefaultFillingColor() ); - aZoneObj->SetBorderColor( aZoneObj->DefaultBorderColor() ); - } - - aZoneObj->SetPolylines( aZonePolylines ); - aZoneObj->SetStricklerType( aSelectedStricklerType ); - aZoneObj->Update(); - - closePreview(); - - if( !myIsEdit ) - { - module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true ); - QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aZoneObj ); - theBrowseObjectsEntries.append( anEntry ); - } - - module()->setIsToUpdate( aZoneObj ); - module()->getOCCDisplayer()->SetToUpdateColorScale(); - - theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; - - return true; -} - -void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames ) -{ - HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - QApplication::setOverrideCursor( Qt::WaitCursor ); - - HYDROData_SequenceOfObjects aZonePolylines; - QStringList::const_iterator anIt = thePolylineNames.begin(), aLast = thePolylineNames.end(); - for( ; anIt!=aLast; anIt++ ) - { - QString aPolylineName = *anIt; - Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ); - if ( !aPolyline.IsNull() ) - aZonePolylines.Append( aPolyline ); - } - - TCollection_AsciiString anError; - TopoDS_Shape aZoneShape = HYDROData_LandCover::buildShape( aZonePolylines, anError ); - - LightApp_Application* anApp = module()->getApp(); - if ( !getPreviewManager() ) - setPreviewManager( ::qobject_cast( - anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); - OCCViewer_ViewManager* aViewManager = getPreviewManager(); - if ( aViewManager && !myPreviewPrs ) - { - if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) - { - Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); - if ( !aCtx.IsNull() ) - myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); - } - } - - if ( aViewManager && myPreviewPrs ) - { - QColor aFillingColor = Qt::magenta; - QColor aBorderColor = Qt::transparent; - if ( !myEditedObject.IsNull() ) { - aFillingColor = myEditedObject->GetFillingColor(); - aBorderColor = myEditedObject->GetBorderColor(); - } - - myPreviewPrs->setFillingColor( aFillingColor, false, false ); - myPreviewPrs->setBorderColor( aBorderColor, false, false ); - - if( !aZoneShape.IsNull() ) - myPreviewPrs->setShape( aZoneShape ); - } - - QApplication::restoreOverrideCursor(); -} - -void HYDROGUI_LandCoverOp::onAddPolylines() -{ - HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - // Add polylines selected in the module browser - Handle(HYDROData_PolylineXY) aPolyXY; - HYDROGUI_ListModel::Object2VisibleList aSelectedPolylines; - HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); - - if ( aSeq.IsEmpty() || !confirmPolylinesChange() ) - return; - - for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) - { - aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( aSeq.Value( anIndex )); - if (!aPolyXY.IsNull()) - aSelectedPolylines.append( HYDROGUI_ListModel::Object2Visible( aPolyXY, true ) ); - } - - if ( aPanel->includePolylines( aSelectedPolylines ) ) - { - closePreview(); - onCreatePreview( aPanel->getPolylineNames() ); - } -} - -void HYDROGUI_LandCoverOp::onRemovePolylines() -{ - // Remove selected polylines from the calculation case - HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - QStringList aSelectedList = aPanel->getSelectedPolylineNames(); - if ( aSelectedList.isEmpty() || !confirmPolylinesChange() ) - return; - - HYDROGUI_ListModel::Object2VisibleList aSelectedPolylines; - for (int i = 0; i < aSelectedList.length(); i++) - { - Handle(HYDROData_PolylineXY) anObject = Handle(HYDROData_PolylineXY)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) ); - if ( anObject.IsNull() ) - continue; - - aSelectedPolylines.append( HYDROGUI_ListModel::Object2Visible( anObject, true ) ); - } - - module()->update( UF_OCCViewer ); - - if ( aPanel->excludePolylines( aSelectedPolylines ) ) - { - closePreview(); - onCreatePreview( aPanel->getPolylineNames() ); - } -} - -void HYDROGUI_LandCoverOp::closePreview() -{ - if( myPreviewPrs ) - { - delete myPreviewPrs; - myPreviewPrs = 0; - } -} - -bool HYDROGUI_LandCoverOp::confirmPolylinesChange() const -{ - if ( myEditedObject.IsNull() ) - return true; - - // Check if the land cover object is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ); - if ( !isConfirmed ) - { - // If not modified check if the land cover has already defined polylines - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetPolylines(); - if ( aSeq.Length() > 0 ) - { - // If there are already defined polylines then ask a user to confirm land cover recalculation - isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(), - tr( "POLYLINES_CHANGED" ), - tr( "CONFIRM_LAND_COVER_RECALCULATION" ), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No ) == QMessageBox::Yes ); - } - else - { - isConfirmed = true; // No polylines - nothing to recalculate - } - } - return isConfirmed; -} diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.h b/src/HYDROGUI/HYDROGUI_LandCoverOp.h deleted file mode 100644 index fb25f255..00000000 --- a/src/HYDROGUI/HYDROGUI_LandCoverOp.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef HYDROGUI_LANDCOVEROP_H -#define HYDROGUI_LANDCOVEROP_H - -#include "HYDROGUI_Operation.h" - -#include - -class HYDROGUI_Shape; - -class HYDROGUI_LandCoverOp : public HYDROGUI_Operation -{ - Q_OBJECT - -public: - HYDROGUI_LandCoverOp( HYDROGUI_Module* theModule, const bool theIsEdit ); - virtual ~HYDROGUI_LandCoverOp(); - -protected: - virtual void startOperation(); - virtual void abortOperation(); - virtual void commitOperation(); - - virtual HYDROGUI_InputPanel* createInputPanel() const; - - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, - QStringList& theBrowseObjectsEntries ); - - virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; }; - -protected slots: - void onCreatePreview( const QStringList& thePolylineNames ); - void onAddPolylines(); - void onRemovePolylines(); - -private: - void closePreview(); - bool confirmPolylinesChange() const; - -private: - bool myIsEdit; - Handle(HYDROData_LandCover) myEditedObject; - - HYDROGUI_Shape* myPreviewPrs; -}; - -#endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 81ad9fa0..168dc17f 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -338,7 +338,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsZone = false; bool anIsObstacle = false; bool anIsStricklerTable = false; - bool anIsLandCover = false; + bool anIsLandCoverMap = false; bool anIsStream = false; bool anIsChannel = false; bool anIsDigue = false; @@ -459,8 +459,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsObstacle = true; else if( anObjectKind == KIND_STRICKLER_TABLE ) anIsStricklerTable = true; - else if( anObjectKind == KIND_LAND_COVER ) - anIsLandCover = true; + else if( anObjectKind == KIND_LAND_COVER_MAP ) + anIsLandCoverMap = true; else if( anObjectKind == KIND_STREAM ) { anIsStream = true; @@ -517,9 +517,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, case KIND_STRICKLER_TABLE: theMenu->addAction( action( ImportStricklerTableFromFileId ) ); break; - case KIND_LAND_COVER: - theMenu->addAction( action( CreateLandCoverId ) ); - theMenu->addAction( action( ImportLandCoverId ) ); + case KIND_LAND_COVER_MAP: + theMenu->addAction( action( CreateLandCoverMapId ) ); + theMenu->addAction( action( ImportLandCoverMapId ) ); break; case KIND_CALCULATION: theMenu->addAction( action( CreateCalculationId ) ); @@ -666,14 +666,18 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) ); bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable ); - if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER ).isEmpty() ) { + if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) { theMenu->addAction( action( LandCoverScalarMapModeOnId ) ); theMenu->addSeparator(); } } - else if( anIsLandCover ) + else if( anIsLandCoverMap ) { - theMenu->addAction( action( EditLandCoverId ) ); + theMenu->addAction( action( AddLandCoverId ) ); + theMenu->addAction( action( RemoveLandCoverId ) ); + theMenu->addSeparator(); + theMenu->addAction( action( SplitLandCoverId ) ); + theMenu->addAction( action( MergeLandCoverId ) ); theMenu->addSeparator(); } else if( anIsVisualState && anIsObjectBrowser ) @@ -701,7 +705,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } bool anIsPoly = anIsPolyline || anIsPolyline3D; - if ((anIsPoly && !anIsLandCover) || (!anIsPoly && anIsLandCover)) + if ((anIsPoly && !anIsLandCoverMap) || (!anIsPoly && anIsLandCoverMap)) theMenu->addAction( action( ExportToShapeFileID ) ); // Add copy action @@ -721,7 +725,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsImmersibleZone || anIsZone || anIsRegion || anIsBathymetry || anIsObstacle || anIsStream || anIsChannel || anIsDigue || anIsDummyObject3D || - anIsValidProfile || anIsGroup || anIsLandCover ) + anIsValidProfile || anIsGroup || anIsLandCoverMap ) { if( anIsHiddenInSelection ) theMenu->addAction( action( ShowId ) ); @@ -1081,7 +1085,7 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId, if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) { setLandCoversScalarMapModeOff( theViewId ); - } else if ( theObject->GetKind() == KIND_LAND_COVER && theState ) { + } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) { getOCCDisplayer()->SetToUpdateColorScale(); } } diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index ccec796f..a8e73707 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -23,13 +23,14 @@ #include "HYDROGUI_Tool.h" #include #include -#include +// TODO +//#include #include "HYDROGUI_Operation.h" #include "HYDROGUI_DataObject.h" #include "HYDROGUI_ZLayers.h" #include -#include +#include #include #include @@ -165,9 +166,11 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int aResShape = new HYDROGUI_ShapeImage( theContext, Handle_HYDROData_Image::DownCast( theObject ) ); else if( theObject->IsKind( STANDARD_TYPE( HYDROData_Bathymetry ) ) ) aResShape = new HYDROGUI_ShapeBathymetry( this, theContext, Handle_HYDROData_Bathymetry::DownCast( theObject ) ); - else if( theObject->IsKind( STANDARD_TYPE( HYDROData_LandCover ) ) ) { + else if( theObject->IsKind( STANDARD_TYPE( HYDROData_LandCoverMap ) ) ) { bool isScalarMode = module()->isLandCoversScalarMapModeOn( theViewerId ); - aResShape = new HYDROGUI_ShapeLandCover( this, theContext, Handle_HYDROData_LandCover::DownCast( theObject ), -1, isScalarMode ); + /* TODO + aResShape = new HYDROGUI_ShapeLandCover( this, theContext, Handle_HYDROData_LandCoverMap::DownCast( theObject ), -1, isScalarMode ); + */ } else aResShape = new HYDROGUI_Shape( theContext, theObject ); @@ -419,7 +422,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer int aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct bool isLandCoverColoringOn = module()->isLandCoversScalarMapModeOn( aViewerId ); - QList aLandCoverShapes = module()->getObjectShapes( aViewerId, KIND_LAND_COVER ); + QList aLandCoverShapes = module()->getObjectShapes( aViewerId, KIND_LAND_COVER_MAP ); QList aBathShapes = module()->getObjectShapes( aViewerId, KIND_BATHYMETRY ); bool isDisplayColorScale = !aBathShapes.empty() || isLandCoverColoringOn; @@ -500,6 +503,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer aView->ColorScaleErase(); } + /* TODO foreach( HYDROGUI_Shape* aShape, aLandCoverShapes ) { HYDROGUI_ShapeLandCover* aLandCoverShape = dynamic_cast( aShape ); @@ -508,6 +512,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer continue; } + QColor aColor; Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( aLandCoverShape->getObject() ); @@ -531,12 +536,13 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer aShapeColor.Blue() * 255 ); } } - } + } aLandCoverShape->setFillingColor( aColor, true, true ); aLandCoverShape->setScalarMapModeEnabled( isLandCoverColoringOn ); theViewer->getAISContext()->Redisplay( aLandCoverShape->getAISObject() ); } + */ myToUpdateColorScale = false; } diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index ae08b720..5641a2c4 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -62,13 +62,15 @@ #include "HYDROGUI_SubmersibleOp.h" #include "HYDROGUI_StricklerTableOp.h" #include "HYDROGUI_DuplicateOp.h" -#include "HYDROGUI_LandCoverOp.h" +// TODO +//#include "HYDROGUI_LandCoverMapOp.h" #include "HYDROGUI_PolylineExtractionOp.h" #include "HYDROGUI_ExportSinusXOp.h" #include "HYDROGUI_MergePolylinesOp.h" #include "HYDROGUI_SplitPolylinesOp.h" #include "HYDROGUI_LandCoverColoringOp.h" -#include "HYDROGUI_ImportLandCoverOp.h" +// TODO +//#include "HYDROGUI_ImportLandCoverMapOp.h" #include #include @@ -133,7 +135,7 @@ void HYDROGUI_Module::createActions() createAction( ImportPolylineId, "IMPORT_POLYLINE", "IMPORT_POLYLINE_ICO" ); createAction( ImportSinusXId, "IMPORT_SINUSX", "IMPORT_SINUSX_ICO" ); createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" ); - createAction( ImportLandCoverId, "IMPORT_LANDCOVER", "IMPORT_LANDCOVER_ICO" ); + createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" ); createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" ); createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" ); @@ -168,8 +170,12 @@ void HYDROGUI_Module::createActions() createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" ); createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" ); - createAction( CreateLandCoverId, "CREATE_LAND_COVER", "CREATE_LAND_COVER_ICO" ); - createAction( EditLandCoverId, "EDIT_LAND_COVER", "EDIT_LAND_COVER_ICO" ); + createAction( CreateLandCoverMapId, "CREATE_LAND_COVER_MAP", "CREATE_LAND_COVER_MAP_ICO" ); + + createAction( AddLandCoverId, "ADD_LAND_COVER", "ADD_LAND_COVER_ICO" ); + createAction( RemoveLandCoverId, "REMOVE_LAND_COVER", "REMOVE_LAND_COVER_ICO" ); + createAction( SplitLandCoverId, "SPLIT_LAND_COVER", "SPLIT_LAND_COVER_ICO" ); + createAction( MergeLandCoverId, "MERGE_LAND_COVER", "MERGE_LAND_COVER_ICO" ); createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" ); createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" ); @@ -241,7 +247,7 @@ void HYDROGUI_Module::createMenus() int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu ); createMenu( ImportSinusXId, aHydroId, -1, -1 ); createMenu( ExportSinusXId, aHydroId, -1, -1 ); - createMenu( ImportLandCoverId, aHydroId, -1, -1 ); + createMenu( ImportLandCoverMapId, aHydroId, -1, -1 ); createMenu( ImportBathymetryId, aHydroId, -1, -1 ); createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 ); @@ -249,7 +255,7 @@ void HYDROGUI_Module::createMenus() createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 ); createMenu( CreateChannelId, aHydroId, -1, -1 ); createMenu( CreateDigueId, aHydroId, -1, -1 ); - createMenu( CreateLandCoverId, aHydroId, -1, -1 ); + createMenu( CreateLandCoverMapId, aHydroId, -1, -1 ); int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 ); createMenu( ImportImageId, aNewImageId, -1, -1 ); @@ -299,7 +305,7 @@ void HYDROGUI_Module::createToolbars() createTool( ImportPolylineId, aToolBar ); createTool( ImportSinusXId, aToolBar ); createTool( ExportSinusXId, aToolBar ); - createTool( ImportLandCoverId, aToolBar ); + createTool( ImportLandCoverMapId, aToolBar ); createTool( ImportBathymetryId, aToolBar ); createTool( CreatePolylineId, aToolBar ); @@ -327,7 +333,7 @@ void HYDROGUI_Module::createToolbars() createTool( ImportStricklerTableFromFileId, aToolBar ); createTool( separator(), aToolBar ); - createTool( CreateLandCoverId, aToolBar ); + createTool( CreateLandCoverMapId, aToolBar ); createTool( separator(), aToolBar ); createTool( CreateCalculationId, aToolBar ); @@ -481,8 +487,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case ExportToShapeFileID: anOp = new HYDROGUI_ExportFileOp( aModule ); break; - case ImportLandCoverId: - anOp = new HYDROGUI_ImportLandCoverOp( aModule ); + case ImportLandCoverMapId: + // TODO + //anOp = new HYDROGUI_ImportLandCoverMapOp( aModule ); break; case RemoveImageRefsId: anOp = new HYDROGUI_RemoveImageRefsOp( aModule ); @@ -539,9 +546,21 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditStricklerTableId: anOp = new HYDROGUI_StricklerTableOp( aModule, theId ); break; - case CreateLandCoverId: - case EditLandCoverId: - anOp = new HYDROGUI_LandCoverOp( aModule, theId == EditLandCoverId ); + case CreateLandCoverMapId: + // TODO + //anOp = new HYDROGUI_LandCoverMapOp( aModule, theId == EditLandCoverMapId ); + break; + case AddLandCoverId: + // TODO + break; + case RemoveLandCoverId: + // TODO + break; + case SplitLandCoverId: + // TODO + break; + case MergeLandCoverId: + // TODO break; case DuplicateStricklerTableId: anOp = new HYDROGUI_DuplicateOp( aModule ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 9264dfc3..1c845bd2 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -114,15 +114,19 @@ enum OperationId ExportSinusXId, ExportToShapeFileID, - ImportLandCoverId, + ImportLandCoverMapId, ImportStricklerTableFromFileId, ExportStricklerTableFromFileId, EditStricklerTableId, DuplicateStricklerTableId, - CreateLandCoverId, - EditLandCoverId, + CreateLandCoverMapId, + + AddLandCoverId, + RemoveLandCoverId, + SplitLandCoverId, + MergeLandCoverId, PolylineExtractionId, SplitPolylinesId, diff --git a/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx b/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx index 684d3a53..0d7061cb 100644 --- a/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx +++ b/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx @@ -18,7 +18,6 @@ #include "HYDROGUI_PriorityTableModel.h" -#include #include /** @@ -240,7 +239,7 @@ QVariant HYDROGUI_PriorityTableModel::headerData( int theSection, break; case 3: { - if ( getObjectsKind() != KIND_LAND_COVER ) + if ( getObjectsKind() != KIND_LAND_COVER_MAP ) aData = tr( "BATHYMETRY" ); } break; diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx index cca862a6..ca292846 100644 --- a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ bool HYDROGUI_SetColorOp::CanObjectBeColored( const Handle(HYDROData_Entity)& th return false; bool isCanBeColored = false; - if ( theObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) ) { + if ( theObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) ) { size_t anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( theModule ); isCanBeColored = !theModule->isLandCoversScalarMapModeOn( anActiveViewId ); } @@ -104,13 +104,15 @@ void HYDROGUI_SetColorOp::startOperation() anIsOneColor = true; } - else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) ) + else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) ) { - Handle(HYDROData_LandCover) aLandCover = - Handle(HYDROData_LandCover)::DownCast( myEditedObject ); + Handle(HYDROData_LandCoverMap) aLandCoverMap = + Handle(HYDROData_LandCoverMap)::DownCast( myEditedObject ); - aFirstColor = aLandCover->GetFillingColor(); - aSecondColor = aLandCover->GetBorderColor(); + /* TODO + aFirstColor = aLandCoverMap->GetFillingColor(); + aSecondColor = aLandCoverMap->GetBorderColor(); + */ } // Create color dialog @@ -163,13 +165,15 @@ bool HYDROGUI_SetColorOp::processApply( int& theUpdateFlags, aPolyObject->SetWireColor( aFirstColor ); } - else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) ) + else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) ) { - Handle(HYDROData_LandCover) aLandCover = - Handle(HYDROData_LandCover)::DownCast( myEditedObject ); + Handle(HYDROData_LandCoverMap) aLandCoverMap = + Handle(HYDROData_LandCoverMap)::DownCast( myEditedObject ); - aLandCover->SetFillingColor( aFirstColor ); - aLandCover->SetBorderColor( aSecondColor ); + /* TODO + aLandCoverMap->SetFillingColor( aFirstColor ); + aLandCoverMap->SetBorderColor( aSecondColor ); + */ } module()->setIsToUpdate( myEditedObject ); diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index d8f5ab5e..f7132b32 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx b/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx deleted file mode 100644 index 635470ae..00000000 --- a/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "HYDROGUI_ShapeLandCover.h" -#include "HYDROGUI_OCCDisplayer.h" - -#include - -#include - -HYDROGUI_ShapeLandCover::HYDROGUI_ShapeLandCover( HYDROGUI_OCCDisplayer* theDisplayer, - const Handle(AIS_InteractiveContext)& theContext, - const Handle_HYDROData_LandCover& theLandCover, - const int theZLayer, - const bool theIsScalarMode ) -: HYDROGUI_Shape( theContext, theLandCover, theZLayer ), - myDisplayer( theDisplayer ), - myIsScalarMapMode( theIsScalarMode ) -{ -} - -HYDROGUI_ShapeLandCover::~HYDROGUI_ShapeLandCover() -{ -} - -void HYDROGUI_ShapeLandCover::update( bool theIsUpdateViewer, bool isDeactivateSelection ) -{ - setIsToUpdate( false ); - - Handle(HYDROData_LandCover) aLandCoverObj = - Handle(HYDROData_LandCover)::DownCast( getObject() ); - - TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape(); - if ( !aLandCoverShape.IsNull() ) { - setShape( aLandCoverShape, false, false ); - } - - if ( !myIsScalarMapMode ) { - QColor aFillingColor = aLandCoverObj->GetFillingColor(); - QColor aBorderColor = aLandCoverObj->GetBorderColor(); - - setFillingColor( aFillingColor, false, false ); - setBorderColor( aBorderColor, false, false ); - } else { - updateShape( false, false ); - } - - HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection ); -} - -void HYDROGUI_ShapeLandCover::setScalarMapModeEnabled( const bool theIsToEnable ) -{ - myIsScalarMapMode = theIsToEnable; -} - -void HYDROGUI_ShapeLandCover::setVisible( const bool theState, - const bool theIsUpdateViewer ) -{ - HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer ); - myDisplayer->SetToUpdateColorScale(); -} - -void HYDROGUI_ShapeLandCover::displayShape( const bool theIsUpdateViewer ) -{ - HYDROGUI_Shape::displayShape( theIsUpdateViewer ); - myDisplayer->SetToUpdateColorScale(); -} - -void HYDROGUI_ShapeLandCover::display( const bool theIsUpdateViewer ) -{ - HYDROGUI_Shape::display( theIsUpdateViewer ); - myDisplayer->SetToUpdateColorScale(); -} - -void HYDROGUI_ShapeLandCover::erase( const bool theIsUpdateViewer ) -{ - HYDROGUI_Shape::erase( theIsUpdateViewer ); - myDisplayer->SetToUpdateColorScale(); -} diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCover.h b/src/HYDROGUI/HYDROGUI_ShapeLandCover.h deleted file mode 100644 index 60bee858..00000000 --- a/src/HYDROGUI/HYDROGUI_ShapeLandCover.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2014-2015 EDF-R&D -// This library 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 2.1 of the License, or (at your option) any later version. -// -// This library 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 GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef HYDROGUI_SHAPE_LANDCOVER_H -#define HYDROGUI_SHAPE_LANDCOVER_H - -#include - -class HYDROGUI_OCCDisplayer; - -class HYDROGUI_ShapeLandCover : public HYDROGUI_Shape -{ -public: - HYDROGUI_ShapeLandCover( HYDROGUI_OCCDisplayer* theDisplayer, - const Handle(AIS_InteractiveContext)& theContext, - const Handle_HYDROData_LandCover& theLandCover, - const int theZLayer = -1, - const bool theIsScalarMode = false ); - virtual ~HYDROGUI_ShapeLandCover(); - - virtual void update( bool isUpdateViewer, - bool isDeactivateSelection ); - - virtual void display( const bool theIsUpdateViewer = true ); - virtual void erase( const bool theIsUpdateViewer = true ); - - virtual void setVisible( const bool theState, - const bool theIsUpdateViewer = true ); - - /** - * Enable/disable scalar map coloring mode. - * @param theIsToEnable if true - scalar map coloring mode willbe enbaled, if false - disabled - */ - virtual void setScalarMapModeEnabled( const bool theIsToEnable ); - -protected: - virtual void displayShape( const bool theIsUpdateViewer ); - -private: - HYDROGUI_OCCDisplayer* myDisplayer; - bool myIsScalarMapMode; -}; - -#endif diff --git a/src/HYDROGUI/HYDROGUI_Zone.cxx b/src/HYDROGUI/HYDROGUI_Zone.cxx index c1139e1e..0d0ab6bc 100644 --- a/src/HYDROGUI/HYDROGUI_Zone.cxx +++ b/src/HYDROGUI/HYDROGUI_Zone.cxx @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -119,22 +118,6 @@ QString HYDROGUI_Zone::getObjectName() const } } } - else - { - Handle(HYDROData_LandCover) aRefLandCoverObj = - Handle(HYDROData_LandCover)::DownCast( anIter.Value() ); - if ( !aRefLandCoverObj.IsNull() ) - { - // Get name of land cover object - aName = aRefLandCoverObj->GetName(); - if ( !isMergingNeed ) - { - // Get the first land cover object's altitude name and go out - aRes = aName; - break; - } - } - } if ( !aName.isEmpty() && !aNamesSet.contains( aName ) ) { @@ -281,8 +264,6 @@ void HYDROGUI_Zone::setMergeType( int theMergeType, QString theMergeObjectName ) { // Get altitude object aMergeObject = aRefGeomObj->GetAltitudeObject(); - } else { - aMergeObject = Handle(HYDROData_LandCover)::DownCast( anIter.Value() ); } if ( !aMergeObject.IsNull() && theMergeObjectName == aMergeObject->GetName() ) diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index e6281451..cec1aa6e 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -379,13 +379,25 @@ - CREATE_LAND_COVER_ICO + CREATE_LAND_COVER_MAP_ICO icon_create_land_cover.png - EDIT_LAND_COVER_ICO + ADD_LAND_COVER_ICO icon_edit_land_cover.png + + REMOVE_LAND_COVER_ICO + icon_remove_land_cover.png + + + SPLIT_LAND_COVER_ICO + icon_split_land_cover.png + + + MERGE_LAND_COVER_ICO + icon_merge_land_cover.png + IMPORT_OBSTACLE_FROM_FILE_ICO @@ -428,7 +440,7 @@ - IMPORT_LANDCOVER_ICO + IMPORT_LANDCOVER_MAP_ICO icon_import_polygon.png diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index b9ef26ae..e9226632 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -857,12 +857,24 @@ Would you like to remove all references from the image? Duplicate Strickler table - DSK_CREATE_LAND_COVER - Create land cover + DSK_CREATE_LAND_COVER_MAP + Create land cover map - DSK_EDIT_LAND_COVER - Edit land cover + DSK_ADD_LAND_COVER + Add land cover + + + DSK_REMOVE_LAND_COVER + Remove land cover + + + DSK_SPLIT_LAND_COVER + Split land cover(s) + + + DSK_MERGE_LAND_COVER + Merge land covers DSK_COPY @@ -949,8 +961,8 @@ Would you like to remove all references from the image? Import polyline from file(s) - DSK_IMPORT_LANDCOVER - Import land cover from file(s) + DSK_IMPORT_LANDCOVER_MAP + Import land cover map from file(s) DSK_IMPORT_SINUSX @@ -1146,12 +1158,24 @@ Would you like to remove all references from the image? Duplicate Strickler table - MEN_CREATE_LAND_COVER - Create land cover + MEN_CREATE_LAND_COVER_MAP + Create land cover map - MEN_EDIT_LAND_COVER - Edit land cover + MEN_ADD_LAND_COVER + Add land cover + + + MEN_REMOVE_LAND_COVER + Remove land cover + + + MEN_SPLIT_LAND_COVER + Split land cover(s) + + + MEN_MERGE_LAND_COVER + Merge land covers MEN_CUT_IMAGES @@ -1270,8 +1294,8 @@ Would you like to remove all references from the image? Import polyline - MEN_IMPORT_LANDCOVER - Import land cover from file(s) + MEN_IMPORT_LANDCOVER_MAP + Import land cover map from file(s) MEN_IMPORT_SINUSX @@ -1467,12 +1491,24 @@ Would you like to remove all references from the image? Duplicate Strickler table - STB_CREATE_LAND_COVER - Create land cover + STB_CREATE_LAND_COVER_MAP + Create land cover map - STB_EDIT_LAND_COVER - Edit land cover + STB_ADD_LAND_COVER + Add land cover + + + STB_REMOVE_LAND_COVER + Remove land cover + + + STB_SPLIT_LAND_COVER + Split land cover(s) + + + STB_MERGE_LAND_COVER + Merge land covers STB_COPY @@ -1559,8 +1595,8 @@ Would you like to remove all references from the image? Import polyline - STB_IMPORT_LANDCOVER - Import land cover from file(s) + STB_IMPORT_LANDCOVER_MAP + Import land cover map from file(s) STB_IMPORT_SINUSX -- 2.39.2