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"
8 #include <ModelAPI_Feature.h>
9 #include <ModelAPI_PluginManager.h>
10 #include <ModelAPI_AttributeDocRef.h>
11 #include <ModelAPI_Data.h>
15 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
16 QObject(theParent), myWorkshop(theParent)
20 XGUI_SelectionMgr::~XGUI_SelectionMgr()
24 //**************************************************************
25 void XGUI_SelectionMgr::connectViewers()
27 connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()),
28 this, SLOT(onObjectBrowserSelection()));
30 //Connect to other viewers
31 if (myWorkshop->isSalomeMode()) {
32 connect(myWorkshop, SIGNAL(salomeViewerSelection()),
33 this, SLOT(onViewerSelection()));
35 connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
36 this, SLOT(onViewerSelection()));
40 //**************************************************************
41 void XGUI_SelectionMgr::onObjectBrowserSelection()
44 // TODO: Highliht selected objects in Viewer 3d
46 emit selectionChanged();
49 //**************************************************************
50 void XGUI_SelectionMgr::onViewerSelection()
52 emit selectionChanged();
55 //**************************************************************
56 QFeatureList XGUI_SelectionMgr::selectedFeatures() const
58 return myWorkshop->objectBrowser()->selectedFeatures();
61 //**************************************************************
62 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
64 return myWorkshop->objectBrowser()->selectionModel()->selectedIndexes();
67 //**************************************************************
68 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
70 if (myWorkshop->isSalomeMode()) {
71 Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
73 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
74 theList.Append(aContext->SelectedInteractive());
76 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
77 aViewer->getSelectedObjects(theList);
81 //**************************************************************
82 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
84 if (myWorkshop->isSalomeMode()) {
86 Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
87 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
88 TopoDS_Shape aShape = aContext->SelectedShape();
90 theList.Append(aShape);
93 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
94 aViewer->getSelectedShapes(theList);