Salome HOME
refs #568: Land Cover: a draft of data model and implementation of dialog box and...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 1ed020f82b10f099d5e7a64f5dd4d48ca568bdd7..3d5dc177b24e0ea104e9ad3e3db34593e223479e 100644 (file)
@@ -336,6 +336,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsRegion = false;
   bool anIsZone = false;
   bool anIsObstacle = false;
+  bool anIsStricklerTable = false;
+  bool anIsLandCover = false;
   bool anIsStream = false;
   bool anIsChannel = false;
   bool anIsDigue = false;
@@ -454,6 +456,10 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsBathymetry = true;
       else if( anObjectKind == KIND_OBSTACLE )
         anIsObstacle = true;
+      else if( anObjectKind == KIND_STRICKLER_TABLE )
+        anIsStricklerTable = true;
+      else if( anObjectKind == KIND_LAND_COVER )
+        anIsLandCover = true;
       else if( anObjectKind == KIND_STREAM )
       {
         anIsStream = true;
@@ -507,6 +513,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
           theMenu->addAction( action( CreateBoxId ) );
           theMenu->addAction( action( CreateCylinderId ) );
           break;
+        case KIND_STRICKLER_TABLE:
+          theMenu->addAction( action( ImportStricklerTableFromFileId ) );          
+          break;
+        case KIND_LAND_COVER:
+          theMenu->addAction( action( CreateLandCoverId ) );          
+          break;
         case KIND_CALCULATION:
           theMenu->addAction( action( CreateCalculationId ) );
           break;
@@ -633,6 +645,18 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( TranslateObstacleId ) );
         theMenu->addSeparator();
       }
+      else if( anIsStricklerTable )
+      {
+        theMenu->addAction( action( EditStricklerTableId ) );
+        theMenu->addAction( action( ExportStricklerTableFromFileId ) );
+        theMenu->addAction( action( DuplicateStricklerTableId ) );
+        theMenu->addSeparator();
+      }
+      else if( anIsLandCover )
+      {
+        theMenu->addAction( action( EditLandCoverId ) );
+        theMenu->addSeparator();
+      }      
       else if( anIsVisualState && anIsObjectBrowser )
       {
         theMenu->addAction( action( SaveVisualStateId ) );
@@ -709,13 +733,16 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
 
   if( anIsObjectBrowser && anOwners.size()==1 )
   {
-    Handle( HYDROData_Object ) anObject = Handle( HYDROData_Object )::DownCast( aSeq.First() );
-    if( !anObject.IsNull() )
+    if( aSeq.Size() > 0 )
     {
-      theMenu->addSeparator();
-      theMenu->addAction( action( SubmersibleId ) );
-      action( SubmersibleId )->setCheckable( true );
-      action( SubmersibleId )->setChecked( anObject->IsSubmersible() );
+      Handle( HYDROData_Object ) anObject = Handle( HYDROData_Object )::DownCast( aSeq.First() );
+      if( !anObject.IsNull() )
+      {
+        theMenu->addSeparator();
+        theMenu->addAction( action( SubmersibleId ) );
+        action( SubmersibleId )->setCheckable( true );
+        action( SubmersibleId )->setChecked( anObject->IsSubmersible() );
+      }
     }
   }
 }
@@ -746,6 +773,14 @@ void HYDROGUI_Module::createPreferences()
   int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
   addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
                  LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
+
+  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" );
+  setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
+  setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
+  setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
+  setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
 }
 
 QCursor HYDROGUI_Module::getPrefEditCursor() const
@@ -948,6 +983,17 @@ bool HYDROGUI_Module::isObjectVisible( const int theViewId,
   if( theObject.IsNull() )
     return false;
 
+  if( theViewId < 0 )
+  {
+    //search in all
+    foreach( int aViewId, myObjectStateMap.keys() )
+    {
+      if( isObjectVisible( aViewId, theObject ) )
+        return true;
+    }
+    return false;
+  }
+
   ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
   if( anIter1 != myObjectStateMap.end() )
   {