1 #include "XGUI_SelectionMgr.h"
2 #include "XGUI_Workshop.h"
3 #include "XGUI_MainWindow.h"
4 #include "XGUI_ObjectsBrowser.h"
5 #include "XGUI_Viewer.h"
6 #include "XGUI_SalomeConnector.h"
7 #include "XGUI_ViewerProxy.h"
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_PluginManager.h>
11 #include <ModelAPI_AttributeDocRef.h>
12 #include <ModelAPI_Data.h>
16 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
17 QObject(theParent), myWorkshop(theParent)
21 XGUI_SelectionMgr::~XGUI_SelectionMgr()
25 //**************************************************************
26 void XGUI_SelectionMgr::connectViewers()
28 connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()),
29 this, SLOT(onObjectBrowserSelection()));
31 //Connect to other viewers
32 if (myWorkshop->isSalomeMode()) {
33 connect(myWorkshop, SIGNAL(salomeViewerSelection()),
34 this, SLOT(onViewerSelection()));
36 connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
37 this, SLOT(onViewerSelection()));
41 //**************************************************************
42 void XGUI_SelectionMgr::onObjectBrowserSelection()
45 // TODO: Highliht selected objects in Viewer 3d
47 emit selectionChanged();
50 //**************************************************************
51 void XGUI_SelectionMgr::onViewerSelection()
53 // TODO: Highliht selected objects in Object Browser
54 emit selectionChanged();
57 //**************************************************************
58 QFeatureList XGUI_SelectionMgr::selectedFeatures() const
60 return myWorkshop->objectBrowser()->selectedFeatures();
63 //**************************************************************
64 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
66 return myWorkshop->objectBrowser()->selectedIndexes();
69 //**************************************************************
70 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
72 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
74 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
75 theList.Append(aContext->SelectedInteractive());
78 //**************************************************************
79 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
82 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
83 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
84 TopoDS_Shape aShape = aContext->SelectedShape();
86 theList.Append(aShape);