Salome HOME
Create goups for stream.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 1ffbf5aa90a15565a86bfafa57b422299bbe7711..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