From 3dacebca7fed9d35733e7f7128548cf7e4530ae0 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 29 Sep 2014 17:55:10 +0400 Subject: [PATCH] Issue #171: Deactivate selection of object of current operation --- src/XGUI/XGUI_Displayer.cpp | 16 ++++++++++++++++ src/XGUI/XGUI_Displayer.h | 5 +++++ src/XGUI/XGUI_Workshop.cpp | 16 +++++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 68e8b68bd..6ac7aca9a 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -204,6 +204,22 @@ void XGUI_Displayer::activate(ObjectPtr theObject) } } +bool XGUI_Displayer::isActive(ObjectPtr theObject) const +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (aContext.IsNull()) + return false; + if (!isVisible(theObject)) + return false; + + boost::shared_ptr anObj = myResult2AISObjectMap.at(theObject); + Handle(AIS_InteractiveObject) anAIS = anObj->impl(); + + TColStd_ListOfInteger aModes; + aContext->ActivatedModes(anAIS, aModes); + return aModes.Extent() > 0; +} + void XGUI_Displayer::stopSelection(const QList& theResults, const bool isStop, const bool isUpdateViewer) { diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 6337a4096..9552fd6d3 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -124,10 +124,15 @@ class XGUI_EXPORT XGUI_Displayer /// \return feature the feature or NULL if it not visualized ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const; + /// Deactivates the given object (not allow selection) void deactivate(ObjectPtr theFeature); + /// Activates the given object (it can be selected) void activate(ObjectPtr theFeature); + /// Returns true if the given object can be selected + bool isActive(ObjectPtr theObject) const; + /// Activates in local context displayed outside of the context. /// \param theModes - selection modes to activate /// \param theFilter - filter for selection diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index def3e45ac..d36f3f6de 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -414,14 +414,24 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptrdata() || !aObj->data()->isValid() || aObj->document()->isConcealed(aObj)) myDisplayer->erase(aObj, false); else { - if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing + if (myDisplayer->isVisible(aObj)) { myDisplayer->display(aObj, false); // In order to update presentation - else { + if (myOperationMgr->hasOperation()) { + ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); + if (!aOperation->hasObject(aObj)) + if (!myDisplayer->isActive(aObj)) + myDisplayer->activate(aObj); + } + } else { if (myOperationMgr->hasOperation()) { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); // Display only current operation results if operation has preview - if (aOperation->hasObject(aObj) && aOperation->hasPreview()) + if (aOperation->hasObject(aObj) && aOperation->hasPreview()) { myDisplayer->display(aObj, false); + // Deactivate object of current operation from selection + if (myDisplayer->isActive(aObj)) + myDisplayer->deactivate(aObj); + } } } } -- 2.39.2