From 949d5fc0e4778d1f0c7faf77cf8efadc1b19fff6 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 2 Jun 2015 17:42:29 +0300 Subject: [PATCH] Show/Hide for Part result --- src/ModuleBase/ModuleBase_ParamSpinBox.cpp | 3 +- src/XGUI/XGUI_ContextMenuMgr.cpp | 6 ++++ src/XGUI/XGUI_Workshop.cpp | 33 ++++++++++++++++------ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index bcd0d28e1..dd3eebd30 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -164,7 +164,8 @@ bool ModuleBase_ParamSpinBox::hasVariable() const bool ModuleBase_ParamSpinBox::hasVariable(const QString& theText) const { - QRegExp varNameMask("[-+]?[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?"); + //QRegExp varNameMask("[-+]?[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?"); //This row causes problem with input in sketcher (circle) + QRegExp varNameMask("[-+]?[0-9]*.?[0-9]+([eE][-+]?[0-9]+)?"); return !varNameMask.exactMatch(theText); } diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 88f167b96..c9a9689f4 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -164,6 +164,12 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const } else if (hasResult && (!hasParameter)) { aMenu->addAction(action("SHOW_CMD")); } + + ResultPartPtr aPartRes = std::dynamic_pointer_cast(aObject); + if (aPartRes) { + aMenu->addAction(action("SHOW_CMD")); + } + if (!(hasParameter || hasFeature)) aMenu->addAction(action("SHOW_ONLY_CMD")); } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index e56e696f5..bfdc7f104 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1587,29 +1587,46 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) } //************************************************************** +#define SET_DISPLAY_GROUP(aGroupName, aDisplay) \ +for (int i = 0; i < aDoc->size(aGroupName); i++) { \ + aDoc->object(aGroupName, i)->setDisplayed(aDisplay); \ +} void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible) { foreach (ObjectPtr aObj, theList) { - if (isVisible) { - aObj->setDisplayed(true); - //displayObject(aObj); + ResultPartPtr aPartRes = std::dynamic_pointer_cast(aObj); + if (aPartRes) { + DocumentPtr aDoc = aPartRes->partDoc(); + SET_DISPLAY_GROUP(ModelAPI_ResultBody::group(), isVisible) + SET_DISPLAY_GROUP(ModelAPI_ResultConstruction::group(), isVisible) + SET_DISPLAY_GROUP(ModelAPI_ResultGroup::group(), isVisible) } else { - aObj->setDisplayed(false); - //myDisplayer->erase(aObj, false); + aObj->setDisplayed(isVisible); } } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - //myDisplayer->updateViewer(); } //************************************************************** void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList) { + // Hide all displayed objects QObjectPtrList aList = myDisplayer->displayedObjects(); foreach (ObjectPtr aObj, aList) aObj->setDisplayed(false); - foreach (ObjectPtr aObj, theList) - aObj->setDisplayed(true); + + // Show only objects from the list + foreach (ObjectPtr aObj, theList) { + ResultPartPtr aPartRes = std::dynamic_pointer_cast(aObj); + if (aPartRes) { + DocumentPtr aDoc = aPartRes->partDoc(); + SET_DISPLAY_GROUP(ModelAPI_ResultBody::group(), true) + SET_DISPLAY_GROUP(ModelAPI_ResultConstruction::group(), true) + SET_DISPLAY_GROUP(ModelAPI_ResultGroup::group(), true) + } else { + aObj->setDisplayed(true); + } + } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } -- 2.39.2