Salome HOME
refs #534: not to show "New region" item on the empty or not-zone selection
authorasl <asl@opencascade.com>
Wed, 27 May 2015 13:39:17 +0000 (16:39 +0300)
committerasl <asl@opencascade.com>
Wed, 27 May 2015 13:39:17 +0000 (16:39 +0300)
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() ) );
 }