]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2079 : Select parent feature for default Constructions. Disable popup menu...
authornds <nds@opencascade.com>
Thu, 6 Apr 2017 07:00:15 +0000 (10:00 +0300)
committernds <nds@opencascade.com>
Thu, 6 Apr 2017 07:00:15 +0000 (10:00 +0300)
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index dc3187868b5b3c4cefe1219b152dca959f6531ea..cca2ba2c5eea6c1a9271abef9e5cb99404fe454a 100755 (executable)
@@ -345,12 +345,13 @@ int shapeType(const QString& theType)
 }
 
 void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
-                  bool& hasParameter, bool& hasCompositeOwner)
+                  bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory)
 {
   hasResult = false;
   hasFeature = false;
   hasParameter = false;
   hasCompositeOwner = false;
+  hasResultInHistory = false;
   foreach(ObjectPtr aObj, theObjects) {
     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
@@ -361,6 +362,12 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe
     hasParameter |= (aConstruction.get() != NULL);
     if (hasFeature)
       hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
+
+    if (!hasResultInHistory && aResult.get()) {
+      FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
+      hasResultInHistory = aFeature.get() && aFeature->isInHistory();
+    }
+
     if (hasFeature && hasResult  && hasParameter && hasCompositeOwner)
       break;
   }
index 1d9d2118c685af95368d01c80bf3d3a67b3bc420..5b9e658d0a8e9fbc63f4985378e543641aa6c302 100755 (executable)
@@ -156,8 +156,10 @@ MODULEBASE_EXPORT bool isSubResult(ObjectPtr theObject);
 /// \param hasFeature will be set to true if list contains Feature objects
 /// \param hasParameter will be set to true if list contains Parameter objects
 /// \param hasCompositeOwner will be set to true if list contains Sub-Feature objects
+/// \param hasResultInHistory will be set to true if one of result is in history
 MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult,
-                           bool& hasFeature, bool& hasParameter, bool& hasCompositeOwner);
+                           bool& hasFeature, bool& hasParameter, bool& hasCompositeOwner,
+                           bool& hasResultInHistory);
 
 /// Sets the default coeffient into the driver calculated accordingly the shape type.
 /// It provides 1.e-4 for results of construction type
index e1bac3b35ead0d0ad08436dfc1cfc9ed6ec74aa5..e13d7cb1f4f3c78f61bd3704d41b4c4af104254c 100755 (executable)
@@ -1150,8 +1150,9 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
   bool hasFeature = false;
   bool hasParameter = false;
   bool hasCompositeOwner = false;
+  bool hasResultInHistory = false;
   ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
-                                  hasCompositeOwner);
+                                  hasCompositeOwner, hasResultInHistory);
 
   ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation();
   if (aSelected == 1) {
index a1fa3c468ae1314710e5d9d38b179e95976dd683..c76241a294eca31d2c6d64a82f9f9d9ac9e757ff 100644 (file)
@@ -238,8 +238,9 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
     bool hasFeature = false;
     bool hasParameter = false;
     bool hasCompositeOwner = false;
+    bool hasResultInHistory = false;
     ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
-                                   hasCompositeOwner);
+                                   hasCompositeOwner, hasResultInHistory);
     //Process Feature
     if (aSelected == 1) {
       ObjectPtr aObject = aObjects.first();
@@ -306,7 +307,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
       action("CLEAN_HISTORY_CMD")->setEnabled(true);
 
     action("SHOW_RESULTS_CMD")->setEnabled(hasFeature);
-    action("SHOW_FEATURE_CMD")->setEnabled(hasResult);
+    action("SHOW_FEATURE_CMD")->setEnabled(hasResult && hasResultInHistory);
   }
 
   // Show/Hide command has to be disabled for objects from non active document
index 499c14b48dd9e3f16f0ec1c0fe8a44cdb952f0cd..01336c642e827b77cfa3162bdff9e9d453b9a886 100755 (executable)
@@ -1460,7 +1460,9 @@ void XGUI_Workshop::deleteObjects()
   bool hasFeature = false;
   bool hasParameter = false;
   bool hasCompositeOwner = false;
-  ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner);
+  bool hasResultInHistory = false;
+  ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner,
+                                 hasResultInHistory);
   if (!(hasFeature || hasParameter))
     return;