]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #664: redesign of calculation case dialog and operation.
authormkr <mkr@opencascade.com>
Thu, 12 Nov 2015 17:10:47 +0000 (20:10 +0300)
committermkr <mkr@opencascade.com>
Thu, 12 Nov 2015 17:10:47 +0000 (20:10 +0300)
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index a2d3c7dce3107ac9596f114f6775fd666a8f1022..c17352746b40293b725b4f4464f057b460d1b539 100644 (file)
@@ -85,6 +85,7 @@ void HYDROGUI_CalculationDlg::reset()
   HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
   myGeomObjects->setObjects(anObject2VisibleList);
   myPolylineName->clear();
+  myLandCoverMapName->clear();
   myStricklerTableName->clear();
   myAvailableGeomObjects->clear();
 
@@ -315,7 +316,12 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoverMapPage() {
   // Top of the page
   QWidget* aTopContainer = new QWidget;
 
-  // TODO: add combo-box to choose land cover map object
+  // Combo-box to choose land cover map object
+  QLabel* aLandCoverMapLabel = new QLabel( tr( "LAND_COVER_MAP" ), aPage );
+  myLandCoverMapName = new QComboBox( aPage );
+  myLandCoverMapName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myLandCoverMapName, SIGNAL( activated( const QString & ) ), 
+                               SIGNAL( landCoverMapSelected( const QString & ) ) );
   // Combo-box to choose Strickler table name
   QLabel* aStricklerTableLabel = new QLabel( tr( "STRICKLER_TABLE" ), aPage );
   myStricklerTableName = new QComboBox( aPage );
@@ -324,25 +330,24 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoverMapPage() {
                                  SIGNAL( StricklerTableSelected( const QString & ) ) );
 
   // Fill the top layout of the page
-  QGridLayout* aTopLayout = new QGridLayout;
+  QGridLayout* aGridLayout = new QGridLayout;
+  aGridLayout->setMargin( 5 );
+  aGridLayout->setSpacing( 5 );
+  aGridLayout->setVerticalSpacing( 10 );
+  aGridLayout->addWidget( aLandCoverMapLabel,   0, 0 );
+  aGridLayout->addWidget( myLandCoverMapName,   0, 1 );
+  aGridLayout->addWidget( aStricklerTableLabel, 1, 0 );
+  aGridLayout->addWidget( myStricklerTableName, 1, 1 );
+
+  QVBoxLayout* aTopLayout = new QVBoxLayout;
   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->addLayout( aGridLayout );
+  aTopLayout->addStretch( 1 );
   
   aTopContainer->setLayout( aTopLayout );
 
-  // Page layout
-  QVBoxLayout* aPageLayout = new QVBoxLayout;
-  aPageLayout->setMargin( 5 );
-  aPageLayout->setSpacing( 5 );
-  
-  aPage->setLayout( aPageLayout );
-
-  // Connections
-  // TODO
+  aPage->setLayout( aTopLayout );
 
   return aPage;
 }
@@ -603,6 +608,16 @@ void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, c
   }
 }
 
+void HYDROGUI_CalculationDlg::setLandCoverMapsNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
+{
+  myLandCoverMapName->clear();
+
+  for ( int i = 0, n = theObjects.length(); i < n; ++i )
+  {
+    myLandCoverMapName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
+  }
+}
+
 void HYDROGUI_CalculationDlg::setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
 {
   myStricklerTableName->clear();
@@ -666,17 +681,6 @@ void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculatio
   myBrowser->adjustColumnsWidth();
   myBrowser->setAutoUpdate( true );
   myBrowser->setUpdateModified( true );
-
-  /*TODO
-  // Build the calculation case subtree for Land Cover regions
-  module()->getDataModel()->buildCaseTree( myLandCoverBrowser->root(), myEditedObject, true );
-
-  myLandCoverBrowser->updateTree();
-  myLandCoverBrowser->openLevels();
-  myLandCoverBrowser->adjustColumnsWidth();
-  myLandCoverBrowser->setAutoUpdate( true );
-  myLandCoverBrowser->setUpdateModified( true );
-  */
 }
 
 HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
@@ -785,31 +789,6 @@ QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getGeometryObjects()
   return anObjects;
 }
 
-/**
-  Get chosen land cover map.
-  @return the land cover map object
- */
-Handle(HYDROData_LandCoverMap) HYDROGUI_CalculationDlg::getLandCoverMap()
-{
-  /* TODO
-  QList<Handle(HYDROData_Entity)> anEntities = myLandCovers->getObjects();
-  QList<Handle(HYDROData_Entity)> aLandCovers;
-
-  foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
-    Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
-    if ( aLandCover.IsNull() ) {
-      continue;
-    }
-
-    aLandCovers << aLandCover;
-  }
-
-  return aLandCovers;
-  */
-  Handle(HYDROData_LandCoverMap) aLandCoverMap = NULL;
-  return aLandCoverMap;
-}
-
 /**
   Get rules.
   @return the list of rules
@@ -852,7 +831,6 @@ void HYDROGUI_CalculationDlg::onRuleChanged()
     myPriorityWidget->undoLastChange();
 }
 
-// TODO: setLandCoverMap(...)
 void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals )
 {
   bool isBlocked;
@@ -866,3 +844,17 @@ void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTabl
   else
     emit StricklerTableSelected( theStricklerTableName );
 }
+
+void HYDROGUI_CalculationDlg::setLandCoverMap( const QString& theLandCoverMapName, bool theBlockSignals )
+{
+  bool isBlocked;
+  if ( theBlockSignals )
+    isBlocked = myLandCoverMapName->blockSignals( true );
+  
+  myLandCoverMapName->setCurrentIndex( myLandCoverMapName->findText( theLandCoverMapName ) );
+
+  if ( theBlockSignals )
+    myLandCoverMapName->blockSignals( isBlocked );
+  else
+    emit landCoverMapSelected( theLandCoverMapName );
+}
index 1c6acb8c6e34bd7905e88648464bc777e08ff67b..6b5a44639c9d80a33394c26cffd47b04bcdfca63 100644 (file)
@@ -63,7 +63,7 @@ public:
   void                       setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries );
   QStringList                getAllGeomObjects() const;
   void                       setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
-  // TODO: setLandCoverMapsNames(...)
+  void                       setLandCoverMapsNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
   void                       setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
   QStringList                getSelectedGeomObjects() const;
   QStringList                getSelectedAvailableGeomObjects() const;
@@ -93,6 +93,7 @@ public slots:
   void                       onRuleChanged();
 
   void                       setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals = true );
+  void                       setLandCoverMap( const QString& theLandCoverMapName, bool theBlockSignals = true );
   
   /**
    * Process items selection: hide/show bathymetry merge type selector.
@@ -127,7 +128,7 @@ signals:
   void                       moveZones( SUIT_DataObject* theRegion, const QList<SUIT_DataObject*>& theZonesList );
   void                       clickedInZonesBrowser( SUIT_DataObject* );
 
-  void                       landCoverMapSelected();
+  void                       landCoverMapSelected( const QString & theObjName );
 
   void                       StricklerTableSelected( const QString & theObjName );
 
@@ -143,8 +144,6 @@ protected slots:
 private:
   QList<Handle(HYDROData_Entity)> getGeometryObjects();
   
-  Handle(HYDROData_LandCoverMap) getLandCoverMap();
-  
   QWizardPage*               createObjectsPage();
   QWizardPage*               createGroupsPage();
   QWizardPage*               createLandCoverMapPage();
@@ -157,7 +156,7 @@ private:
   HYDROGUI_NameValidator*    myValidator;
 
   QComboBox*                 myPolylineName;
-  // TODO: myLandCoverMapName
+  QComboBox*                 myLandCoverMapName;
   QComboBox*                 myStricklerTableName;
 
   QButtonGroup*              myModeButtons;
index 1987887cfab9eb3b9a9a85fc21a90914ef18260a..01b65432010e76d407feca5feb2b3cacfef804a4 100644 (file)
@@ -231,10 +231,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( createLandCoverRegion( const QList<SUIT_DataObject*>& ) ),
-    SLOT( onCreateLandCoverRegion( const QList<SUIT_DataObject*>& ) ) );
+  connect( aPanel, SIGNAL( landCoverMapSelected( const QString & ) ), 
+           SLOT( onLandCoverMapSelected( const QString & ) ) );
   connect( aPanel, SIGNAL( boundarySelected( const QString & ) ), 
     SLOT( onBoundarySelected( const QString & ) ) );
   connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ), 
@@ -289,26 +287,12 @@ 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;
-  HYDROData_SequenceOfObjects aLandCovers;
-  HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers();
-  HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
-  for ( ; anIter.More(); anIter.Next() )
+  // Remove old presentation of land cover map from the operation viewer  
+  Handle(HYDROData_LandCoverMap) aLandCoverMap = myEditedObject->GetLandCoverMap();
+  if ( !aLandCoverMap.IsNull() )
   {
-    anEntity = anIter.Value();
-    if ( !anEntity.IsNull() )
-    {
-      aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
-      if ( !aLandCover.IsNull() )
-      {
-        aLandCovers.Append( aLandCover );
-        setObjectVisibility( aLandCover, false );
-        anIsToUpdateViewer = true;
-      }
-    }
+    setObjectVisibility( aLandCoverMap, false );
+    anIsToUpdateViewer = true;
   }
 
   // Set the selected Strickler table to the calculation case
@@ -326,19 +310,10 @@ void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjNa
         Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
         if ( !aCtx.IsNull() )
         {
-          HYDROData_SequenceOfObjects::Iterator anIter( aLandCovers );
-          for ( ; anIter.More(); anIter.Next() )
+          if ( !aLandCoverMap.IsNull() )
           {
-            anEntity = anIter.Value();
-            if ( !anEntity.IsNull() )
-            {
-              aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
-              if ( !aLandCover.IsNull() )
-              {
-                setObjectVisibility( aLandCover, true );
-                anIsToUpdateViewer = true;
-              }
-            }
+            setObjectVisibility( aLandCoverMap, true );
+            anIsToUpdateViewer = true;
           }          
         }
       }
@@ -347,7 +322,6 @@ void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjNa
         module()->update( UF_OCCViewer );
     }
   }
-  */
 }
 
 void HYDROGUI_CalculationOp::onObjectsSelected()
@@ -391,53 +365,27 @@ void HYDROGUI_CalculationOp::onObjectsSelected()
     aLastShape->update( true, false );
 }
 
-void HYDROGUI_CalculationOp::onLandCoverMapSelected()
+void HYDROGUI_CalculationOp::onLandCoverMapSelected( const QString & theObjName )
 {
-  HYDROGUI_CalculationDlg* aPanel = 
-    ::qobject_cast<HYDROGUI_CalculationDlg*>( 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<QString, bool> 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;
-  /* 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;
-  QString aName;
-  for ( ; anIter.More(); anIter.Next() )
+  bool anIsToUpdateViewer = false;
+  
+  // Remove old presentation of land cover map from the operation viewer  
+  Handle(HYDROData_LandCoverMap) aPrevLandCoverMap = myEditedObject->GetLandCoverMap();
+  if ( !aPrevLandCoverMap.IsNull() )
   {
-    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;
-      }
-    }
+    setObjectVisibility( aPrevLandCoverMap, false );
+    anIsToUpdateViewer = true;
   }
-  */
 
-  // TODO
-  //createPreview( true );
+  // Select the appropriate land cover map shape in the viewer
+  selectionMgr()->clearSelected();
 
-  if( aLastShape )
-    aLastShape->update( true, false );
+  // Set the selected land cover map to the calculation case
+  Handle(HYDROData_LandCoverMap) aNewLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast(
+    HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_LAND_COVER_MAP ) );
+  myEditedObject->SetLandCoverMap( aNewLandCoverMap );
+
+  createPreview( true );
 }
 
 void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
@@ -825,16 +773,47 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
 
     QStringList aList;
     QStringList anEntryList;
-    HYDROData_SequenceOfObjects aSeq;
 
-    /* TODO: get all land cover map objects to fill in combo-box
+    // Get all land cover map objects to fill in combo-box
+    Handle(HYDROData_LandCoverMap) aLandCoverMapObj;
+    QString aLandCoverMapName;
+
+    aList.clear();
+    anEntryList.clear();
+    HYDROData_Iterator anIter( doc(), KIND_LAND_COVER_MAP );
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      aLandCoverMapObj = Handle(HYDROData_LandCoverMap)::DownCast( anIter.Current() );
+
+      if ( !aLandCoverMapObj.IsNull() )
+      { 
+        aLandCoverMapName = aLandCoverMapObj->GetName();
+        if ( !aLandCoverMapName.isEmpty() )
+        {
+          aList.append( aLandCoverMapName );
+          anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aLandCoverMapObj ) );
+        }
+      }
+    }
+    aPanel->setLandCoverMapsNames( aList, anEntryList );
+    aLandCoverMapObj = myEditedObject->GetLandCoverMap();
+    if ( !aList.isEmpty() )
+    {
+      if ( aLandCoverMapObj.IsNull() )
+        aPanel->setLandCoverMap( aList.at( 0 ), false );
+      else if ( myIsEdit )
+        aPanel->setLandCoverMap( aList.at( 0 ), true );
+      else
+        aPanel->setLandCoverMap( aList.at( aList.indexOf( aLandCoverMapObj->GetName() ) ), true );
+    }
+
+    // Get all Strickler table objects to fill in combo-box
     Handle(HYDROData_StricklerTable) aStricklerTableObj;
     QString aStricklerTableName;
 
-    // Get all Strickler table objects to fill in combo-box
     aList.clear();
     anEntryList.clear();
-    HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE );      
+    anIter = HYDROData_Iterator( doc(), KIND_STRICKLER_TABLE );
     for ( ; anIter.More(); anIter.Next() )
     {
       aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() );
@@ -870,9 +849,19 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
           aStricklerTableName = aStricklerTableObj->GetName();
           aPanel->setStricklerTable( aStricklerTableName );
         }
+
+        // Select the certain land cover map object in combo-box
+        if ( aLandCoverMapObj.IsNull() )
+        {
+          aPanel->setLandCoverMap( QString() );
+        }
+        else
+        {
+          aLandCoverMapName = aLandCoverMapObj->GetName();
+          aPanel->setLandCoverMap( aLandCoverMapName );
+        }
       }
     }
-    */
 
     closePreview( false );
     createPreview( true );
index b6791f0d4106ffc6c2ced16dd5071e585b55d72e..a74d7b0648400955661c3ab34b5efec43c96a06a 100644 (file)
@@ -113,7 +113,7 @@ protected slots:
   /** 
    * Land cover map is selected in the list on the third wizard page
    */
-  void                            onLandCoverMapSelected();
+  void                            onLandCoverMapSelected( const QString & theObjName );
   /** 
    * Boundary polyline is selected in the list on the first wizard page
    */
index 23d8dc989bd03acc10bea47d8638a5ce7ebf8850..123f975887faf7d6346af272a6f1f0be2975a784 100644 (file)
@@ -989,6 +989,14 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
           createObject( aCaseNOSect, aNObject, aGuiObj->entry(), false );
       }
     }
+
+    LightApp_DataObject* aLandCoverMapSect = 
+      createObject( aGuiObj, tr( "CASE_LAND_COVER_MAP" ), aGuiObj->entry() );
+
+    Handle(HYDROData_LandCoverMap) aLandCoverMap = aCaseObj->GetLandCoverMap();
+    if ( !aLandCoverMap.IsNull() && !aLandCoverMap->IsRemoved() )
+      createObject( aLandCoverMapSect, aLandCoverMap, aGuiObj->entry(), false );
+
     LightApp_DataObject* aCaseRegionsSect = 
       createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
 
index 1c10d4f41c615f2ce19844b0134d730dcefc471d..4d904c4950c0db0943d3527625bb1033d17d6841 100644 (file)
       <translation>REGIONS</translation>
     </message>
     <message>
-      <source>CASE_LAND_COVER_REGIONS</source>
-      <translation>LAND COVER REGIONS</translation>
+      <source>CASE_LAND_COVER_MAP</source>
+      <translation>LAND COVER MAP</translation>
     </message>
     <message>
       <source>CASE_SPLITTED_GROUPS</source>
@@ -358,12 +358,8 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <translation>Strickler table</translation>
     </message>
     <message>
-      <source>CALCULATION_REFERENCE_LAND_COVERS</source>
-      <translation>Land covers</translation>
-    </message>
-    <message>
-      <source>INCLUDED_LAND_COVERS</source>
-      <translation>Included land covers</translation>
+      <source>LAND_COVER_MAP</source>
+      <translation>Land cover map</translation>
     </message>
     <message>
       <source>STRICKLER_TYPE</source>