A fix for restore selection after manipulation close/open local context on display.
#include <XGUI_Displayer.h>
#include <XGUI_Workshop.h>
#include <XGUI_Selection.h>
+#include <XGUI_SelectionMgr.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
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() )
#include "XGUI_Displayer.h"
#include "XGUI_Workshop.h"
#include "XGUI_ViewerProxy.h"
+#include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
#include <AppElements_Viewer.h>
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());
if (aCanBeShaded) {
openLocalContext();
activateObjects(myActiveSelectionModes);
+ myWorkshop->selector()->setSelectedOwners(aSelectedOwners);
}
}
if (isUpdateViewer)
}
}
+//**************************************************************
+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()) {
virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theShapes,
std::list<ObjectPtr>& 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;
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()
{
#include <AIS_ListOfInteractive.hxx>
#include <NCollection_List.hxx>
#include <TopoDS_Shape.hxx>
+#include <SelectMgr_IndexedMapOfOwner.hxx>
class XGUI_Workshop;
class XGUI_ObjectsBrowser;
//! 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();