From: mkr Date: Tue, 9 Jun 2015 16:29:17 +0000 (+0300) Subject: refs #573, #574: fill in ordered list widget on Land Cover panel with land covers... X-Git-Tag: v1.4.1~6^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1687cb2e2e3e31ae16197ba2b0939cacc31f9807;p=modules%2Fhydro.git refs #573, #574: fill in ordered list widget on Land Cover panel with land covers data model objects, include/exclude land covers and change its order. --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index c50679f8..889e8114 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -84,9 +84,11 @@ 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 ); @@ -324,7 +326,7 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { connect( myStricklerTableName, SIGNAL( activated( const QString & ) ), SIGNAL( StricklerTableSelected( const QString & ) ) ); - // mode selector (auto/manual) + // Mode selector (auto/manual) QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) ); QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() ); @@ -341,22 +343,22 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { aModeSelectorLayout->addWidget( aManualRB ); aModeGroup->setLayout( aModeSelectorLayout ); - // land covers + // Available land covers QLabel* aLandCoversLabel = new QLabel( tr( "CALCULATION_REFERENCE_LAND_COVERS" ) ); - myLandCovers = new HYDROGUI_OrderedListWidget( aPage, 16 ); - myLandCovers->setHiddenObjectsShown(true); - myLandCovers->setVisibilityIconShown(false); - myLandCovers->setContentsMargins(QMargins()); - - // included land covers - QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_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()); - // buttons + // Include/Exclude buttons QFrame* aBtnsFrame = new QFrame; QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame ); aBtnsLayout->setMargin( 5 ); @@ -365,14 +367,12 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame ); QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame ); - // fill the butons frame with two buttons + // Fill the butons frame with two buttons aBtnsLayout->addWidget( anAddBtn ); aBtnsLayout->addWidget( aRemoveBtn ); aBtnsLayout->addStretch( 1 ); - // top of the page layout - - // land covers frame + // Land covers frame QFrame* aLandCoversFrame = new QFrame( aPage ); aLandCoversFrame->setFrameStyle( QFrame::Panel | QFrame::Raised ); QGridLayout* aLandCoversLayout = new QGridLayout( aLandCoversFrame ); @@ -380,14 +380,14 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { aLandCoversLayout->setSpacing( 5 ); aLandCoversFrame->setLayout( aLandCoversLayout ); - // fill the land covers frame with two lists, two labels and with buttons frame + // 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 of the page + // Fill the top layout of the page QGridLayout* aTopLayout = new QGridLayout; aTopLayout->setMargin( 5 ); aTopLayout->setSpacing( 5 ); @@ -399,7 +399,7 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { aTopContainer->setLayout( aTopLayout ); - // add the top of the page to the splitter + // Add the top of the page to the splitter myLandCoverSplitter->insertWidget(0, aTopContainer); myLandCoverSplitter->setStretchFactor(0, 2); @@ -413,7 +413,7 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() { aPriorityLayout->addWidget( myLandCoverPriorityWidget ); aPriorityGroup->setLayout( aPriorityLayout ); - // add the bottom of the page to the splitter + // Add the bottom of the page to the splitter myLandCoverSplitter->insertWidget(1, aPriorityGroup); myLandCoverSplitter->setStretchFactor(1, 1); @@ -739,6 +739,20 @@ 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; @@ -755,16 +769,31 @@ 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; @@ -982,6 +1011,45 @@ void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTabl myStricklerTableName->blockSignals( isBlocked ); } +void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCovers ) +{ + HYDROGUI_ListModel::Object2VisibleList anObjectsToInclude; + 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 ) ); + } + + // TODO: adapt HYDROGUI_PriorityWidget to process land covers + //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 ); + } + + // TODO: adapt HYDROGUI_PriorityWidget to process land covers + //myLandCoverPriorityWidget->setObjects( getLandCovers() ); +} + /** Slot called when land covers order is changed. */ @@ -989,9 +1057,9 @@ void HYDROGUI_CalculationDlg::onOrderLandCoverChanged() { bool isConfirmed = true; emit orderLandCoverChanged( isConfirmed ); + // TODO: adapt HYDROGUI_PriorityWidget to process land covers /*if( isConfirmed ) myLandCoverPriorityWidget->setObjects( getLandCovers() ); - else - myLandCovers->undoLastMove(); - */ + else*/ + myLandCovers->undoLastMove(); } diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 566ea281..9bcdfd8a 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -63,10 +63,14 @@ 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 ); 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; @@ -94,6 +98,8 @@ public slots: void setLandCoverMode( int theMode ); void setStricklerTable( const QString& theStricklerTableName ); + void includeLandCovers( const QStringList& theLandCovers ); + void excludeLandCovers( const QStringList& theLandCovers ); void onOrderLandCoverChanged(); /** @@ -132,6 +138,7 @@ signals: void addLandCovers(); void removeLandCovers(); + void landCoversSelected(); void orderLandCoverChanged( bool& isConfirmed ); void StricklerTableSelected( const QString & theObjName ); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index d0fc53d5..8ace99e3 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -224,14 +224,19 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() ); // Connect signals and slots - connect( aPanel, SIGNAL( changeMode( int ) ), SLOT( onChangeMode( int ) ) ); - connect( aPanel, SIGNAL( changeLandCoverMode( int ) ), SLOT( onChangeLandCoverMode( int ) ) ); + connect( aPanel, SIGNAL( changeMode( int ) ), SLOT( onChangeMode( int ) ) ); connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) ); connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) ); 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( Next( const int ) ), SLOT( onNext( const int ) ) ); connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) ); //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) ); @@ -244,6 +249,8 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) ); connect( aPanel, SIGNAL( objectsSelected() ), SLOT( onObjectsSelected() ) ); + connect( aPanel, SIGNAL( landCoversSelected() ), + SLOT( onLandCoversSelected() ) ); connect( aPanel, SIGNAL( boundarySelected( const QString & ) ), SLOT( onBoundarySelected( const QString & ) ) ); connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ), @@ -395,6 +402,47 @@ void HYDROGUI_CalculationOp::onObjectsSelected() aLastShape->update( true, false ); } +void HYDROGUI_CalculationOp::onLandCoversSelected() +{ + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + + QStringList aSelectedObjs = aPanel->getSelectedLandCovers(); + QMap aSelectedObjsMap; + foreach( QString aName, aSelectedObjs ) + aSelectedObjsMap[aName] = true; + + + // Select the appropriate land cover shape in the viewer + selectionMgr()->clearSelected(); + + // Unhighlight all land covers except selected + HYDROGUI_Shape* aShape = 0, *aLastShape = 0; + Handle(HYDROData_Entity) anEntity; + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers(); + HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); + bool isSelected; + QString aName; + for ( ; anIter.More(); anIter.Next() ) + { + anEntity = anIter.Value(); + if ( !anEntity.IsNull() ) + { + aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity ); + if ( aShape ) + { + aName = anEntity->GetName(); + isSelected = aSelectedObjsMap.contains( aName ); + aShape->highlight( isSelected, false ); + aShape->update( false, false ); + aLastShape = aShape; + } + } + } + if( aLastShape ) + aLastShape->update( true, false ); +} + void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem ) { HYDROGUI_Region* aRegionItem = dynamic_cast(theItem); @@ -692,6 +740,32 @@ bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const return isConfirmed; } +bool HYDROGUI_CalculationOp::confirmLandCoverOrderChange() const +{ + // Check if the case is already modified or not + bool isConfirmed = myEditedObject->IsMustBeUpdated(); + if ( !isConfirmed ) + { + // If not modified check if the case has already defined regions with zones + // TODO: adapt HYDROData_CalculationCase class to process regions constructed for land covers + /*HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCoverRegions(); + if ( aSeq.Length() > 0 ) + {*/ + // If there are already defined zones then ask a user to confirm 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 zones - nothing to recalculate + }*/ + } + return isConfirmed; +} + bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) @@ -818,10 +892,11 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } aPanel->setStricklerTableNames( aList, anEntryList ); - //HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetGeometryObjects( module() ); - //getNamesAndEntries( aSeq, aList, anEntryList ); - //aPanel->setAllGeomObjects( aList, anEntryList ); - + // Fill in list widget with all available land covers + HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetLandCovers( module() ); + getNamesAndEntries( aSeq, aList, anEntryList ); + aPanel->setAllLandCovers( aList, anEntryList ); + if ( !myEditedObject.IsNull() ) { if ( myIsEdit ) @@ -950,7 +1025,24 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) // Set objects in the specified order if( myEditedObject->IsMustBeUpdated() ) { - //... + 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->ClearLandCoverRules( true ); + // TODO: Set priority rules + //foreach ( const HYDROData_CustomRule& aRule, aPanel->getLandCoverRules() ) { + // myEditedObject->AddLandCoverRule( aRule.Object1, aRule.Priority, + // aRule.Object2, aRule.MergeType ); } } aPanel->setEditLandCoversEnabled( aMode == HYDROData_CalculationCase::MANUAL ); @@ -1303,36 +1395,95 @@ void HYDROGUI_CalculationOp::onRemoveGroups() aPanel->excludeGroups( aSelectedList ); } -void HYDROGUI_CalculationOp::onChangeMode( int theMode ) +void HYDROGUI_CalculationOp::onChangeLandCoverMode( int theMode ) { HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return; - if ( !confirmModeChange() ) { - aPanel->setMode( myEditedObject->GetAssignmentMode() ); + if ( !confirmLandCoverModeChange() ) { + aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() ); return; } - myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)theMode ); - aPanel->setMode( theMode ); + myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)theMode ); + aPanel->setLandCoverMode( theMode ); } -void HYDROGUI_CalculationOp::onChangeLandCoverMode( int theMode ) +void HYDROGUI_CalculationOp::onAddLandCovers() { HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return; - if ( !confirmLandCoverModeChange() ) { - aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() ); + // Add land covers selected in the module browser to the calculation case + QStringList aSelectedList = aPanel->getSelectedAvailableLandCovers(); + if ( aSelectedList.isEmpty() || !confirmRegionsChange() ) 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() ); } - myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)theMode ); - aPanel->setLandCoverMode( theMode ); + if ( !anAddedList.isEmpty() ) + { + aPanel->includeLandCovers( anAddedList ); + // TODO: create preview of included land covers + //createPreview(); + } +} + +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() || !confirmRegionsChange() ) + 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 = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + if ( !confirmModeChange() ) { + aPanel->setMode( myEditedObject->GetAssignmentMode() ); + return; + } + + myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)theMode ); + aPanel->setMode( theMode ); } void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed ) @@ -1349,12 +1500,12 @@ void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed ) void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed ) { - /*HYDROGUI_CalculationDlg* aPanel = + HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return; - isConfirmed = confirmOrderChange(); + isConfirmed = confirmLandCoverOrderChange(); if( isConfirmed ) - myEditedObject->SetToUpdate( true );*/ + myEditedObject->SetToUpdate( true ); } diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 467d1a39..cf6a52a0 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -62,12 +62,6 @@ protected slots: */ void onChangeMode( int theMode ); - /** - * Change the creation mode related to land covers. - * @param theMode the mode to set - */ - void onChangeLandCoverMode( int theMode ); - /** * Add geometry objects selected in the module browser to the calculation case. */ @@ -86,6 +80,21 @@ 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 merge type to the current zone. */ @@ -116,6 +125,10 @@ protected slots: * Geometry object is selected in the list on the first wizard page */ void onObjectsSelected(); + /** + * Land cover is selected in the list on the third wizard page + */ + void onLandCoversSelected(); /** * Boundary polyline is selected in the list on the first wizard page */ @@ -162,6 +175,7 @@ private: bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const; bool confirmLandCoverModeChange() const; + bool confirmLandCoverOrderChange() const; private: bool myIsEdit; diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 568ffb1c..83cdad60 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -362,6 +363,23 @@ HYDROData_SequenceOfObjects HYDROGUI_Tool::GetGeometryObjects( return aResSeq; } +HYDROData_SequenceOfObjects HYDROGUI_Tool::GetLandCovers( HYDROGUI_Module* theModule ) +{ + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() ); + + HYDROData_SequenceOfObjects aResSeq; + + HYDROData_Iterator anIter( aDocument ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) anObj = anIter.Current(); + if ( !anObj.IsNull() && anObj->IsKind( STANDARD_TYPE(HYDROData_LandCover) )) + aResSeq.Append( anObj ); + } + + return aResSeq; +} + ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule ) { HYDROGUI_DataModel* aModel = theModule->getDataModel(); diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index 60600a54..fada415c 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -166,6 +166,13 @@ public: */ static HYDROData_SequenceOfObjects GetGeometryObjects( HYDROGUI_Module* theModule ); + /** + * \brief Get the land covers from document. + * \param theModule module + * \return sequence of land covers + */ + static HYDROData_SequenceOfObjects GetLandCovers( HYDROGUI_Module* theModule ); + /** * \brief Get kind of objects the selected partition contains. * \param theModule module diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index a511731b..0b6e4a6c 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -401,6 +401,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION Region(s): %1 do not contain any objects. Do you want to continue? + + CONFIRM_LAND_COVER_PARTITION_RECALCULATION_REGIONS + Case land covers partition already exists and will be recalculated after regions list modification. Do you confirm the recalculation? + CONFIRM_LAND_COVER_PARTITION_RECALCULATION_MODE Case land covers partition already exists and will be recalculated after mode change. Do you confirm the recalculation?