From: nds Date: Fri, 26 Dec 2014 15:24:50 +0000 (+0300) Subject: The local selection restore for a feature vertex (it is checked on the line feature) X-Git-Tag: V_0.7.0_rc1~38^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1209fb70bd8f453208eee8bcc79fdb42a697a8a0;p=modules%2Fshaper.git The local selection restore for a feature vertex (it is checked on the line feature) A fix for restore selection after manipulation close/open local context on display. --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index edc27e0b7..a2303017c 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -530,7 +531,7 @@ void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject, SelectMgr_IndexedMapOfOwner aSelectedOwners; - XGUI_Selection::entityOwners(anAISIO, aContext, aSelectedOwners); + aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners); for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) { Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i)); if ( anOwner.IsNull() || !anOwner->HasShape() ) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index c06aae88a..bf5a05165 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -7,6 +7,8 @@ #include "XGUI_Displayer.h" #include "XGUI_Workshop.h" #include "XGUI_ViewerProxy.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_Selection.h" #include @@ -131,8 +133,11 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, myResult2AISObjectMap[theObject] = theAIS; bool aCanBeShaded = canBeShaded(anAISIO); // In order to avoid extra closing/opening context - if (aCanBeShaded) + SelectMgr_IndexedMapOfOwner aSelectedOwners; + if (aCanBeShaded) { + myWorkshop->selector()->selection()->selectedOwners(aSelectedOwners); closeLocalContexts(false); + } aContext->Display(anAISIO, false); qDebug("### Display %i", (long)anAISIO.Access()); @@ -147,6 +152,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, if (aCanBeShaded) { openLocalContext(); activateObjects(myActiveSelectionModes); + myWorkshop->selector()->setSelectedOwners(aSelectedOwners); } } if (isUpdateViewer) diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 7b4bb5ff1..23b11c9fb 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -157,16 +157,27 @@ void XGUI_Selection::selectedShapes(NCollection_List& theList, } } +//************************************************************** +void XGUI_Selection::selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const +{ + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { + theSelectedOwners.Add(aContext->SelectedOwner()); + } +} + //************************************************************** void XGUI_Selection::entityOwners(const Handle(AIS_InteractiveObject)& theObject, - const Handle(AIS_InteractiveContext)& theContext, - SelectMgr_IndexedMapOfOwner& theOwners) + SelectMgr_IndexedMapOfOwner& theOwners) const { - if (theObject.IsNull() || theContext.IsNull()) + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + + if (theObject.IsNull() || aContext.IsNull()) return; TColStd_ListOfInteger aModes; - theContext->ActivatedModes(theObject, aModes); + aContext->ActivatedModes(theObject, aModes); TColStd_ListIteratorOfListOfInteger anIt(aModes); for (; anIt.More(); anIt.Next()) { diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index c411d5ff0..5dcd44ee1 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -57,14 +57,16 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection virtual void selectedShapes(NCollection_List& theShapes, std::list& theOwners) const; + //! Returns list of currently selected owners + /// \return list of owners + void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const; + //! Returns a list of selection entity owners of the interactive object /// It depends on the modes, in which the object is activated in the context /// \param theObject an object - /// \param theContext a viewer interactive context /// \param theOwners a map of entity owners - static void entityOwners(const Handle_AIS_InteractiveObject& theObject, - const Handle_AIS_InteractiveContext& theContext, - SelectMgr_IndexedMapOfOwner& theOwners); + void entityOwners(const Handle_AIS_InteractiveObject& theObject, + SelectMgr_IndexedMapOfOwner& theOwners) const; private: XGUI_Workshop* myWorkshop; diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index bafdeda30..0cdaecf9b 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -40,6 +40,15 @@ void XGUI_SelectionMgr::connectViewers() connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), this, SLOT(onViewerSelection())); } +//************************************************************** +void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners) +{ + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + for (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++) { + aContext->AddOrRemoveSelected(theSelectedOwners(i), false); + } +} + //************************************************************** void XGUI_SelectionMgr::onObjectBrowserSelection() { diff --git a/src/XGUI/XGUI_SelectionMgr.h b/src/XGUI/XGUI_SelectionMgr.h index 6b45fff70..8d74e0990 100644 --- a/src/XGUI/XGUI_SelectionMgr.h +++ b/src/XGUI/XGUI_SelectionMgr.h @@ -11,6 +11,7 @@ #include #include #include +#include class XGUI_Workshop; class XGUI_ObjectsBrowser; @@ -36,6 +37,10 @@ Q_OBJECT //! Connects the manager to all viewers accessible by Workshop void connectViewers(); + //! Selects the owners in the context. + //! \param theSelectedOwners a container of owners + void setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners); + signals: //! Emited when selection in a one of viewers was changed void selectionChanged();