Salome HOME
17.12.2013. Added Partition algorithm (draft version).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 7244bab70c5448c06576aef30aa561bff201f1ef..1ffbf5aa90a15565a86bfafa57b422299bbe7711 100644 (file)
@@ -39,6 +39,7 @@
 #include "HYDROGUI_VTKPrsDisplayer.h"
 #include "HYDROGUI_AbstractDisplayer.h"
 #include "HYDROGUI_PolylineOp.h"
+#include "HYDROGUI_SetColorOp.h"
 
 #include <HYDROData_Image.h>
 #include <HYDROData_Profile.h>
@@ -305,7 +306,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsStream = false;
   bool anIsChannel = false;
   bool anIsDigue = false;
-  bool anIsGeomObject = false;
+  bool anIsDummyObject3D = false;
+  bool anIsObjectCanBeColored = false;
 
   // check the selected GEOM objects
   if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
@@ -391,9 +393,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsChannel = true;
       else if( anObjectKind == KIND_DIGUE )
         anIsDigue = true;
+      else if( anObjectKind == KIND_DUMMY_3D )
+        anIsDummyObject3D = true;
     }
 
-    anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
+    if ( !anIsObjectCanBeColored )
+      anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
   }
 
   // Check if all selected objects are profiles
@@ -543,7 +548,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       }
 
       // Add set color action for geometrical objects
-      if ( anIsGeomObject )
+      if ( anIsObjectCanBeColored )
       {
         theMenu->addAction( action( SetColorId ) );
         theMenu->addSeparator();
@@ -553,13 +558,15 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       theMenu->addSeparator();
     }
 
-    theMenu->addAction( action( DeleteId ) );
+    if( !anIsDummyObject3D )
+      theMenu->addAction( action( DeleteId ) );
     theMenu->addSeparator();
 
     if( anIsImage || anIsPolyline || anIsPolyline3D || 
         anIsImmersibleZone || anIsZone || anIsRegion ||
         anIsBathymetry || anIsObstacle || anIsStream ||
-        anIsChannel || anIsDigue || anIsValidProfile )
+        anIsChannel || anIsDigue || anIsDummyObject3D ||
+        anIsValidProfile )
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
@@ -894,25 +901,28 @@ void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId
   if( theObject.IsNull() )
     return;
 
-  // Compute the new global Z range from the added presentation and the old global Z range.
-  double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
-  double* aRange = theShape->getInternalZRange();
-  bool anIsUpdate = false;
-  if ( aRange[0] < aGlobalRange[0] )
-  {
-    aGlobalRange[0] = aRange[0];
-    anIsUpdate = true;
-  }
-  if ( aRange[1] > aGlobalRange[1] )
+  if( theShape && theShape->needScalarBar() )
   {
-    aGlobalRange[1] = aRange[1];
-    anIsUpdate = true;
-  }
+    // Compute the new global Z range from the added presentation and the old global Z range.
+    double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
+    double* aRange = theShape->getInternalZRange();
+    bool anIsUpdate = false;
+    if ( aRange[0] < aGlobalRange[0] )
+    {
+      aGlobalRange[0] = aRange[0];
+      anIsUpdate = true;
+    }
+    if ( aRange[1] > aGlobalRange[1] )
+    {
+      aGlobalRange[1] = aRange[1];
+      anIsUpdate = true;
+    }
 
-  //if ( anIsUpdate )
-  //{
-    updateVTKZRange( theViewId, aGlobalRange );
-  //}
+    //if ( anIsUpdate )
+    //{
+      updateVTKZRange( theViewId, aGlobalRange );
+    //}
+  }
 
   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
   aViewShapes.append( theShape );
@@ -971,7 +981,7 @@ void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
     for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
     {
       aShape = aViewShapes.at( i );
-      if ( aShape )
+      if ( aShape && aShape->needScalarBar() )
       {
         aShape->setZRange( theRange );
       }
@@ -1095,7 +1105,7 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
       SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
       if ( aVTKViewer )
       {
-        getVTKDisplayer()->DeleteScalarBar( anId );
+        getVTKDisplayer()->EraseScalarBar( anId, true );
         removeViewShapes( (size_t)aVTKViewer );
       }
     }