From: vsv Date: Tue, 14 Oct 2014 07:47:19 +0000 (+0400) Subject: Redesign of Sketcher selection X-Git-Tag: V_0.5~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=22e6328e4977a1ec97e0b96778e53abba0244edc;p=modules%2Fshaper.git Redesign of Sketcher selection --- diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 1ce2ab944..de011a1b9 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -14,7 +14,6 @@ SET(PROJECT_HEADERS PartSet_OperationSketchBase.h PartSet_OperationSketch.h PartSet_OperationFeatureBase.h - PartSet_TestOCC.h PartSet_Tools.h PartSet_WidgetSketchLabel.h PartSet_Validators.h @@ -30,7 +29,6 @@ SET(PROJECT_SOURCES PartSet_OperationSketchBase.cpp PartSet_OperationSketch.cpp PartSet_OperationFeatureBase.cpp - PartSet_TestOCC.cpp PartSet_Tools.cpp PartSet_WidgetSketchLabel.cpp PartSet_Validators.cpp diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index 8dd90a845..989b66880 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -69,7 +69,7 @@ void PartSet_Listener::processEvent(const boost::shared_ptr& the // Very possible it is not displayed aDisplayer->display(aObj, false); std::list aModes = aSketchOp->getSelectionModes(aObj); - aDisplayer->activateInLocalContext(aObj, aModes, false); + myModule->activateInLocalContext(aObj, aModes, false); } } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 3ada0450b..fcfc9e903 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -356,7 +356,7 @@ void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode) std::list::iterator aIt; for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { if (isDisplay) - aDisplayer->activateInLocalContext((*aIt), aModes, false); + activateInLocalContext((*aIt), aModes, false); else aDisplayer->erase((*aIt), false); } @@ -453,7 +453,7 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi if (aPreviewOp) { XGUI_Displayer* aDisplayer = xWorkshop()->displayer(); std::list aModes = aPreviewOp->getSelectionModes(theFeature); - aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer); + activateInLocalContext(theFeature, aModes, isUpdateViewer); // If this is a Sketcher then activate objects (planar faces) outside of context PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); @@ -500,10 +500,10 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) std::list::const_iterator aRIt; for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) { aDisplayer->display((*aRIt), false); - aDisplayer->activateInLocalContext((*aRIt), aModes, false); + activateInLocalContext((*aRIt), aModes, false); } aDisplayer->display(aSPFeature, false); - aDisplayer->activateInLocalContext(aSPFeature, aModes, false); + activateInLocalContext(aSPFeature, aModes, false); } aDisplayer->updateViewer(); } @@ -564,4 +564,39 @@ XGUI_Workshop* PartSet_Module::xWorkshop() const return aConnector->workshop(); } return 0; -} \ No newline at end of file +} + + +void PartSet_Module::activateInLocalContext(ObjectPtr theResult, const std::list& theModes, + const bool isUpdateViewer) +{ + XGUI_Displayer* aDisplayer = xWorkshop()->displayer(); + Handle(AIS_InteractiveContext) aContext = xWorkshop()->viewer()->AISContext(); + if (aContext.IsNull()) + return; + // Open local context if there is no one + if (!aContext->HasOpenedContext()) { + aContext->ClearCurrents(false); + //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); + aContext->OpenLocalContext(); + aContext->NotUseDisplayedObjects(); + } + // display or redisplay presentation + boost::shared_ptr anAIS = aDisplayer->getAISObject(theResult); + // Activate selection of objects from prs + if (anAIS) { + Handle(AIS_InteractiveObject) aAISObj = anAIS->impl(); + aContext->ClearSelected(false); // ToCheck + //aContext->upClearSelected(false); // ToCheck + aContext->Load(aAISObj, -1, true/*allow decomposition*/); + aContext->Deactivate(aAISObj); + + std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); + for (; anIt != aLast; anIt++) { + aContext->Activate(aAISObj, (*anIt)); + } + } + + if (isUpdateViewer) + aDisplayer->updateViewer(); +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 0c39e68f8..44322b359 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -61,6 +61,14 @@ Q_OBJECT XGUI_Workshop* xWorkshop() const; + /// Display the shape and activate selection of sub-shapes + /// \param theFeature a feature instance + /// \param theShape a shape + /// \param theMode a list of local selection modes + /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly + void activateInLocalContext(ObjectPtr theFeature, const std::list& theModes, + const bool isUpdateViewer = true); + public slots: void onFeatureTriggered(); /// SLOT, that is called after the operation is started. Connect on the focus activated signal diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 6ac7aca9a..cf39a413f 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -140,44 +140,6 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) } } -void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list& theModes, - const bool isUpdateViewer) -{ - Handle(AIS_InteractiveContext) aContext = AISContext(); - if (aContext.IsNull()) - return; - // Open local context if there is no one - if (!aContext->HasOpenedContext()) { - aContext->ClearCurrents(false); - //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); - aContext->OpenLocalContext(); - aContext->NotUseDisplayedObjects(); - } - // display or redisplay presentation - Handle(AIS_InteractiveObject) anAIS; - if (isVisible(theResult)) { - boost::shared_ptr anObj = myResult2AISObjectMap[theResult]; - if (anObj) - anAIS = anObj->impl(); - } - - // Activate selection of objects from prs - if (!anAIS.IsNull()) { - aContext->ClearSelected(false); // ToCheck - //aContext->upClearSelected(false); // ToCheck - aContext->Load(anAIS, -1, true/*allow decomposition*/); - aContext->Deactivate(anAIS); - - std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); - for (; anIt != aLast; anIt++) { - aContext->Activate(anAIS, (*anIt)); - } - } - - if (isUpdateViewer) - updateViewer(); -} - void XGUI_Displayer::deactivate(ObjectPtr theObject) { if (isVisible(theObject)) { diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 25b1cdfa2..4562e6d08 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -58,19 +58,6 @@ class XGUI_EXPORT XGUI_Displayer /// Display the given AIS object. To hide this object use corresponde erase method void display(boost::shared_ptr theAIS, bool isUpdate = true); - /// Redisplay the shape and activate selection of sub-shapes - /// \param theFeature a feature instance - /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - //void redisplay(Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true); - - /// Display the shape and activate selection of sub-shapes - /// \param theFeature a feature instance - /// \param theShape a shape - /// \param theMode a list of local selection modes - /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void activateInLocalContext(ObjectPtr theFeature, const std::list& theModes, - const bool isUpdateViewer = true); - /// Stop the current selection and color the given features to the selection color /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped