]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #575, #580: zones preview and combo-box to choose the land cover and, therefore...
authormkr <mkr@opencascade.com>
Fri, 19 Jun 2015 17:58:06 +0000 (20:58 +0300)
committermkr <mkr@opencascade.com>
Fri, 19 Jun 2015 17:58:06 +0000 (20:58 +0300)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_DataBrowser.cxx
src/HYDROGUI/HYDROGUI_DataBrowser.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 2a124fb5d7fa0b79f988354b9e03d2d544b01280..72db9915e3f64ed73f3daf582a71ee1252c0d45d 100644 (file)
@@ -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<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
   QMap<QString, QString> 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
index 5d3481e66fc7516c20420124c3a6f82ea106f456..7e1530197d4783f896faab2911b5cb548298be71 100644 (file)
@@ -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<SUIT_DataObject*>& theList, 
     SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
 {
-  // TODO: implement this function
+  QList<SUIT_DataObject*> aZonesList;
+  HYDROGUI_Zone* aZone;
+  // Get a list of dropped land cover zones
+  for ( int i = 0; i < theList.length(); i++ )
+  {
+    aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
+    if ( aZone )
+    {
+      aZonesList.append( aZone );
+    }
+  }
+  if ( aZonesList.length() > 0 )
+  {
+    // Get the target region
+    HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
+    if ( aRegionsRoot )
+    {
+      // Create a new region
+      emit createLandCoverRegion( aZonesList );
+    }
+    else
+    {
+      HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
+      if ( aRegion )
+      {
+        emit moveZones( theTargetParent, aZonesList, true );
+      }
+    }
+  }
 }
 
 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
index e00d3a44acbb29fafcf7050786eb0a17c078ecf7..82a21857c12505f3c47ecfe19f151277d1d9f98c 100644 (file)
@@ -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<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
@@ -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;
index 263efd4fce4dfa7a1bb613965356b69f37990b68..17134b7eb2513200510bfd4332ab1ce6917bec2d 100644 (file)
@@ -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, 
index 57d868a19f18ad277be9623711f6067442c50fef..3d8b1875a0b301c930ce55b919ed424059d0e5f2 100644 (file)
@@ -188,7 +188,10 @@ void HYDROGUI_OBSelector::fillEntries( QMap<QString, LightApp_DataObject*>& 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<SUIT_AbstractModel*>( model() );
   //RKV: treeModel->setSearcher( theModule->getApp() );
index decdcbed02195f146a31d583760474326dc157fa..9a6c9cd313b0f10a07f430a46fcd54c1b92abfb0 100644 (file)
@@ -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;
index 0f4218b5e0f4d1e0441db34c0f780296105a8840..cd000f86aa7706eb24c603910449c4a0d6b148e3 100644 (file)
@@ -361,6 +361,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>INCLUDED_LAND_COVERS</source>
       <translation>Included land covers</translation>
     </message>
+    <message>
+      <source>STRICKLER_TYPE</source>
+      <translation>Strickler type from land cover</translation>
+    </message>
   </context>
 
   <context>
@@ -425,6 +429,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>ALTITUDE_COLUMN</source>
       <translation>Altitude.Object</translation>
     </message>
+    <message>
+      <source>STRICKLER_TABLE_COLUMN</source>
+      <translation>Strickler table</translation>
+    </message>
     <message>
       <source>ZONE_TO_NEW_REGION</source>
       <translation>Create a new region</translation>