Salome HOME
Create goups for stream.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 7c9c45f802674298fb55eec1446390a60efbdceb..81eabc1f0c87b4c71c0fdc1c53acac2711aa8099 100644 (file)
@@ -40,6 +40,7 @@
 #include "HYDROGUI_AbstractDisplayer.h"
 #include "HYDROGUI_PolylineOp.h"
 #include "HYDROGUI_SetColorOp.h"
+#include "HYDROGUI_ImportGeomObjectOp.h"
 
 #include <HYDROData_Image.h>
 #include <HYDROData_Profile.h>
@@ -309,10 +310,30 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsDummyObject3D = false;
   bool anIsObjectCanBeColored = false;
 
-  // check the selected GEOM objects
-  if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
-    theMenu->addAction( action( ImportGeomObjectId ) );
-    theMenu->addSeparator();
+  // Check the selected GEOM objects (take into account the Object Browser only)
+  if ( anIsObjectBrowser ) {
+    QList<GEOM::shape_type> anObstacleTypes = 
+      HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
+    QList<GEOM::shape_type> aPolylineTypes = 
+      HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
+
+    bool isCanBeImportedAsObstacle = 
+      !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
+    bool isCanBeImportedAsPolyline = 
+      !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
+
+    // Add import as obstacle action
+    if ( isCanBeImportedAsObstacle ) {
+      theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
+    }
+    // Add import as polyline action
+    if ( isCanBeImportedAsPolyline ) {
+      theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
+    }
+    // Add separator
+    if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
+      theMenu->addSeparator();
+    }
   }
 
   // check the selected data model objects
@@ -901,25 +922,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 );
@@ -978,7 +1002,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 );
       }
@@ -1102,7 +1126,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 );
       }
     }