From: mkr Date: Fri, 19 Jun 2015 17:58:06 +0000 (+0300) Subject: refs #575, #580: zones preview and combo-box to choose the land cover and, therefore... X-Git-Tag: v1.4.2~53^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4b33750b322ac240114ede7702cbf844672469a9;p=modules%2Fhydro.git refs #575, #580: zones preview and combo-box to choose the land cover and, therefore, the Strickler type defined for it. --- diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 2a124fb5..72db9915 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -60,6 +60,7 @@ #endif #define CALCULATION_REGIONS_PREF GetName() + "_Reg" #define CALCULATION_ZONES_PREF GetName() + "_Zone" +#define CALCULATION_LANDCOVER_ZONES_PREF GetName() + "_LandCoverZone" #define CALCULATION_GROUPS_PREF GetName() + "_" //#define DEB_CLASS2D 1 #ifdef DEB_CLASS2D @@ -324,7 +325,7 @@ void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Documen { // Create result regions for case, by default one zone for one region QString aRegsPref = CALCULATION_REGIONS_PREF; - QString aZonesPref = CALCULATION_ZONES_PREF; + QString aZonesPref = theLandCover ? CALCULATION_LANDCOVER_ZONES_PREF : CALCULATION_ZONES_PREF; HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones ); while( anIter.hasNext() ) @@ -344,7 +345,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume { QMap aRegionsMap; //object name to region QMap aRegionNameToObjNameMap; - QString aZonesPref = CALCULATION_ZONES_PREF; + QString aZonesPref = theLandCover ? CALCULATION_LANDCOVER_ZONES_PREF : CALCULATION_ZONES_PREF; HYDROData_PriorityQueue aPr( this, theLandCover ? DataTag_CustomLandCoverRules : DataTag_CustomRules ); // 1. First we create a default region for each object included into the calculation case diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 5d3481e6..7e153019 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -490,7 +490,7 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoverZonesPage() { QGridLayout* aLayout = new QGridLayout( aPage ); - myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage ); + myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage, true ); myLandCoverBrowser->setAutoOpenLevel( 3 ); aLayout->setMargin( 5 ); aLayout->setSpacing( 5 ); @@ -503,8 +503,8 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoverZonesPage() { myStricklerTypeLabel->setVisible( false ); myStricklerTypeChoice->setVisible( false ); - aLayout->addWidget( myBathymetryLabel, 1, 0 ); - aLayout->addWidget( myBathymetryChoice, 1, 1 ); + aLayout->addWidget( myStricklerTypeLabel, 1, 0 ); + aLayout->addWidget( myStricklerTypeChoice, 1, 1 ); aPage->setLayout( aLayout ); @@ -672,7 +672,7 @@ void HYDROGUI_CalculationDlg::onLandCoverZoneSelected( SUIT_DataObject* theObjec myCurrentZone = aZone; myStricklerTypeChoice->clear(); myStricklerTypeChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN ); - /*QStringList aList = aZone->getStricklerTypes(); + QStringList aList = aZone->getObjects(); for ( int i = 0; i < aList.length(); i++ ) { myStricklerTypeChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object ); @@ -687,13 +687,13 @@ void HYDROGUI_CalculationDlg::onLandCoverZoneSelected( SUIT_DataObject* theObjec default: aCurIndex = 0; // Select unknown by default } - myStricklerTypeChoice->setCurrentIndex( aCurIndex );*/ + myStricklerTypeChoice->setCurrentIndex( aCurIndex ); myStricklerTypeChoice->blockSignals( prevBlock ); } myStricklerTypeChoice->setVisible( doShow ); myStricklerTypeChoice->setEnabled( getLandCoverMode() == HYDROData_CalculationCase::MANUAL ); - myStricklerTypeChoice->setVisible( doShow ); + myStricklerTypeLabel->setVisible( doShow ); } void HYDROGUI_CalculationDlg::onMergeStricklerTypeSelected( int theIndex ) @@ -706,7 +706,35 @@ void HYDROGUI_CalculationDlg::onMergeStricklerTypeSelected( int theIndex ) void HYDROGUI_CalculationDlg::onLandCoverZonesDropped( const QList& theList, SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction ) { - // TODO: implement this function + 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 ) diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index e00d3a44..82a21857 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -942,6 +942,9 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)aPanel->getLandCoverMode() ); } } + + closePreview( false ); + createPreview( true ); } else if( theIndex==3 ) { @@ -1005,7 +1008,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) //aPanel->setEditedObject( myEditedObject ); aPanel->refreshZonesBrowser(); - closePreview(); + closePreview( false ); createPreview( false ); anIsToUpdateOb = true; @@ -1066,7 +1069,8 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) aPanel->setEditLandCoverZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL ); bool anIsToUpdateOb = false; - if ( myEditedObject->IsMustBeUpdated() ) + bool anIsToUpdate = myEditedObject->IsMustBeUpdated(); + if ( anIsToUpdate ) { myShowZones = true; myEditedObject->Update(); @@ -1074,15 +1078,14 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) AssignDefaultZonesColors( true ); aPanel->refreshLandCoverZonesBrowser(); - - closePreview(); - createPreview( true ); anIsToUpdateOb = true; - - myEditedObject->SetToUpdate( true ); } - else + + closePreview( false ); + createPreview( true ); + + if ( !anIsToUpdate ) { // Hide zones setZonesVisible( false, false ); @@ -1103,15 +1106,32 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) void HYDROGUI_CalculationOp::onHideZones( const int theIndex ) { - if( theIndex==3 ) + if( theIndex==1 ) + { + closePreview( false ); + createPreview( false ); + } + if( theIndex==2 ) { + closePreview( false ); + createPreview( true ); + // Hide zones setZonesVisible( false, false ); + // Hide land covers + setZonesVisible( false, true ); } - else if( theIndex==4 ) + else if( theIndex==3 ) { + AssignDefaultZonesColors( false ); + + closePreview( false ); + createPreview( false ); + // Hide land cover zones setZonesVisible( false, true ); + // Show zones + setZonesVisible( true, false ); } } @@ -1378,7 +1398,7 @@ void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager closePreview(); } -void HYDROGUI_CalculationOp::closePreview() +void HYDROGUI_CalculationOp::closePreview( bool theRemoveViewManager ) { SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser(); QList aShortcuts = aOb->findChildren(); @@ -1409,14 +1429,17 @@ void HYDROGUI_CalculationOp::closePreview() } } - disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), - this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); + if ( theRemoveViewManager ) + { + disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); - module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here - myPreviewViewManager = NULL; + module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here + myPreviewViewManager = NULL; + } } - if( myActiveViewManager ) + if( myActiveViewManager && theRemoveViewManager ) { HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager ); myActiveViewManager = NULL; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 263efd4f..17134b7e 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -152,7 +152,7 @@ protected slots: private: void createPreview( const bool theLandCover); - void closePreview(); + void closePreview( bool theRemoveViewManager = true ); void setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible ); void setZonesVisible( bool theIsVisible, const bool theLandCover ); void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx index 57d868a1..3d8b1875 100644 --- a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx @@ -188,7 +188,10 @@ void HYDROGUI_OBSelector::fillEntries( QMap& entr } -HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject* theRoot, QWidget* theParent ) +HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, + SUIT_DataObject* theRoot, + QWidget* theParent, + bool theLandCover/* = false*/) : SUIT_DataBrowser( theRoot, theParent ), myModule( theModule ) { SUIT_ResourceMgr* resMgr = theModule->getApp()->resourceMgr(); @@ -211,7 +214,11 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat QString EntryCol = QObject::tr( "ENTRY_COLUMN" ); QString RefObjCol = tr( "REF_OBJECT_COLUMN" ); - QString AltitudeCol = tr( "ALTITUDE_COLUMN" ); + QString AltitudeCol; + if ( theLandCover ) + AltitudeCol = tr( "STRICKLER_TABLE_COLUMN" ); + else + AltitudeCol = tr( "ALTITUDE_COLUMN" ); SUIT_AbstractModel* treeModel = dynamic_cast( model() ); //RKV: treeModel->setSearcher( theModule->getApp() ); diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.h b/src/HYDROGUI/HYDROGUI_DataBrowser.h index decdcbed..9a6c9cd3 100644 --- a/src/HYDROGUI/HYDROGUI_DataBrowser.h +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.h @@ -33,7 +33,8 @@ class HYDROGUI_DataBrowser : public SUIT_DataBrowser, public SUIT_DataSearcher Q_OBJECT public: - HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject*, QWidget* = 0 ); + HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject*, + QWidget* = 0, bool theLandCover = false ); ~HYDROGUI_DataBrowser(); HYDROGUI_Module* module() const; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 0f4218b5..cd000f86 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -361,6 +361,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) INCLUDED_LAND_COVERS Included land covers + + STRICKLER_TYPE + Strickler type from land cover + @@ -425,6 +429,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) ALTITUDE_COLUMN Altitude.Object + + STRICKLER_TABLE_COLUMN + Strickler table + ZONE_TO_NEW_REGION Create a new region