Salome HOME
refs #568: use ordered list view with selection synchronized with object browser...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataBrowser.cxx
index 4a553e045db07a6f924de937252923a98a19c5b9..57d868a19f18ad277be9623711f6067442c50fef 100644 (file)
@@ -322,5 +322,33 @@ void HYDROGUI_DataBrowser::setReadOnly( const bool theIsReadOnly )
 void HYDROGUI_DataBrowser::createPopupMenu( QMenu* theMenu )
 {
   theMenu->clear();
-  theMenu->addAction( tr( "ZONE_TO_NEW_REGION" ), this, SIGNAL( newRegion() ) );
+  DataObjectList aSelection = getSelected();
+  bool isOnlyZones = aSelection.size() > 0;
+  foreach( SUIT_DataObject* anObj, aSelection )
+  {
+    HYDROGUI_DataObject* aHydroObj = dynamic_cast<HYDROGUI_DataObject*>( anObj );
+    if( aHydroObj )
+    {
+      Handle(HYDROData_Entity) aModelObj = aHydroObj->modelObject();
+      if( !aModelObj.IsNull() )
+      {
+        isOnlyZones = aModelObj->GetKind()==KIND_ZONE;
+        if( !isOnlyZones )
+          break;
+      }
+      else
+      {
+        isOnlyZones = false;
+        break;
+      }
+    }
+    else
+    {
+      isOnlyZones = false;
+      break;
+    }
+  }
+
+  if( isOnlyZones )
+    theMenu->addAction( tr( "ZONE_TO_NEW_REGION" ), this, SIGNAL( newRegion() ) );
 }