From d75b1b5c09b57fd8326d846118fa3246a9857492 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 6 Apr 2017 10:00:15 +0300 Subject: [PATCH] Issue #2079 : Select parent feature for default Constructions. Disable popup menu "Select parent feature" if feature of selected result in not history. --- src/ModuleBase/ModuleBase_Tools.cpp | 9 ++++++++- src/ModuleBase/ModuleBase_Tools.h | 4 +++- src/PartSet/PartSet_Module.cpp | 3 ++- src/XGUI/XGUI_ContextMenuMgr.cpp | 5 +++-- src/XGUI/XGUI_Workshop.cpp | 4 +++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index dc3187868..cca2ba2c5 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -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(aObj); ResultPtr aResult = std::dynamic_pointer_cast(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; } diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 1d9d2118c..5b9e658d0 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -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 diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e1bac3b35..e13d7cb1f 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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) { diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index a1fa3c468..c76241a29 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -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 diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 499c14b48..01336c642 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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; -- 2.39.2