From c1d68a49306543937c9c27de15b6e16de38e33d8 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 16 Oct 2014 19:19:53 +0400 Subject: [PATCH] Provide selection of external edges and vertexes --- src/PartSet/PartSet_Module.cpp | 9 ++++++--- src/XGUI/XGUI_Displayer.cpp | 9 ++++++++- src/XGUI/XGUI_Displayer.h | 8 +++++--- src/XGUI/XGUI_ModuleConnector.cpp | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e2de98ee0..84bf567a3 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -155,11 +155,10 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); if (aSketchOp) { if (aSketchOp->isEditOperation()) { - aDisplayer->openLocalContext(); - //setSketchingMode(); + setSketchingMode(); } else { aDisplayer->openLocalContext(); - aDisplayer->activateObjectsOutOfContext(); + aDisplayer->activateObjectsOutOfContext(QIntList()); myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane); aDisplayer->addSelectionFilter(myPlaneFilter); QIntList aModes = sketchSelectionModes(aPreviewOp->feature()); @@ -376,6 +375,10 @@ void PartSet_Module::setSketchingMode() //aModes << TopAbs_VERTEX << TopAbs_EDGE; //aModes << AIS_DSM_Text << AIS_DSM_Line; aDisplayer->setSelectionModes(aModes); + aDisplayer->openLocalContext(); + // Get default selection modes + aModes = sketchSelectionModes(ObjectPtr()); + aDisplayer->activateObjectsOutOfContext(aModes); } void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 35d688661..264699899 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -396,7 +396,7 @@ void XGUI_Displayer::erase(boost::shared_ptr theAIS, const bo } } -void XGUI_Displayer::activateObjectsOutOfContext() +void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes) { Handle(AIS_InteractiveContext) aContext = AISContext(); // Open local context if there is no one @@ -409,6 +409,13 @@ void XGUI_Displayer::activateObjectsOutOfContext() for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) { anAISIO = (*aIt).second->impl(); aContext->Load(anAISIO, -1, true); + if (theModes.size() == 0) + aContext->Activate(anAISIO); + else { + foreach(int aMode, theModes) { + aContext->Activate(anAISIO, aMode); + } + } } } diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 4902fbceb..e5a7405d0 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -92,6 +92,7 @@ class XGUI_EXPORT XGUI_Displayer /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void eraseDeletedResults(const bool isUpdateViewer = true); + /// Opens local context. Does nothing if it is already opened. void openLocalContext(); /// Deactivates selection of sub-shapes @@ -126,16 +127,17 @@ class XGUI_EXPORT XGUI_Displayer void deactivate(ObjectPtr theFeature); /// Activates the given object (it can be selected) + /// \param theModes - modes on which it has to be activated (can be empty) void activate(ObjectPtr theFeature, const QIntList& theModes); /// 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 - void activateObjectsOutOfContext(); + /// \param theModes - modes on which it has to be activated (can be empty) + void activateObjectsOutOfContext(const QIntList& theModes); + /// Activates in local context displayed outside of the context. void deactivateObjectsOutOfContext(); /// Sets display mode for the given object if this object is displayed diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index a63b56356..ce9ca3680 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -54,7 +54,8 @@ void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes) { XGUI_Displayer* aDisp = myWorkshop->displayer(); aDisp->openLocalContext(); - aDisp->activateObjectsOutOfContext(); + // Use empty list because we will use standard modes + aDisp->activateObjectsOutOfContext(QIntList()); aDisp->setSelectionModes(theTypes); } -- 2.39.2