Salome HOME
refs #585: polylines operations (split/merge)
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 9127cb74a747cd7926b26e0583279c62fbf4f614..77aecedec32b355f6ba39745ce9d1507bdb22943 100644 (file)
@@ -46,6 +46,7 @@
 #include <HYDROData_Profile.h>
 #include <HYDROData_Lambert93.h>
 #include <HYDROData_Polyline3D.h>
+#include <HYDROData_StricklerTable.h>
 
 #include <HYDROData_OperationsFactory.h>
 
@@ -479,7 +480,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     }
 
     if ( !anIsObjectCanBeColored )
-      anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
+      anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
   }
 
   // Check if all selected objects are profiles
@@ -653,6 +654,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( ExportStricklerTableFromFileId ) );
         theMenu->addAction( action( DuplicateStricklerTableId ) );
         theMenu->addSeparator();
+
+        if ( !isLandCoversScalarMapModeOn( anActiveViewId ) && 
+             !getObjectShapes( anActiveViewId, KIND_LAND_COVER ).isEmpty() ) {
+          theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
+          theMenu->addSeparator();
+        }
       }
       else if( anIsLandCover )
       {
@@ -718,6 +725,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addSeparator();
     theMenu->addAction( action( SetZLevelId ) );
     theMenu->addSeparator();
+
+    if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
+      theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
+      theMenu->addSeparator();
+    }
   }
 
   if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
@@ -781,7 +793,7 @@ void HYDROGUI_Module::createPreferences()
 
   int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
   int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
-                                            LightApp_Preferences::DblSpin, "HYDRO", "default_strickler_coefficient" );
+                                            LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
   setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
   setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
   setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
@@ -1036,6 +1048,12 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
         if ( visState != Qtx::UnpresentableState )
             treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
     }
+
+    if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
+      setLandCoversScalarMapModeOff( theViewId );
+    } else if ( theObject->GetKind() == KIND_LAND_COVER && theState ) {
+      getOCCDisplayer()->SetToUpdateColorScale();
+    }
   }
 }
 
@@ -1439,8 +1457,11 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
     if ( anOCCViewManager )
     {
       OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
-      if ( anOCCViewer )
-        removeViewShapes( (size_t)anOCCViewer );
+      if ( anOCCViewer ) {
+        int aViewerId = (size_t)anOCCViewer;
+        removeViewShapes( aViewerId );
+        setLandCoversScalarMapModeOff( aViewerId );
+      }
     }
 
     if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
@@ -1748,3 +1769,32 @@ void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn
 
   update( UF_OCCViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
 }
+
+Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
+{
+  Handle(HYDROData_StricklerTable) aTable;
+
+  if ( myLandCoverColoringMap.contains( theViewId ) ) {
+    aTable = myLandCoverColoringMap.value( theViewId );
+  }
+
+  return aTable;
+}
+
+void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
+                                                 const Handle(HYDROData_StricklerTable)& theTable )
+{
+  if ( !theTable.IsNull() ) {
+    myLandCoverColoringMap.insert( theViewId, theTable );
+  }
+}
+
+void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
+{
+  myLandCoverColoringMap.remove( theViewId );
+}
+
+bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
+{
+  return myLandCoverColoringMap.contains( theViewId );
+}