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 // TODO: Highliht selected objects in Object Browser
53 emit selectionChanged();
56 //**************************************************************
57 QFeatureList XGUI_SelectionMgr::selectedFeatures() const
59 return myWorkshop->objectBrowser()->selectedFeatures();
62 //**************************************************************
63 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
65 return myWorkshop->objectBrowser()->selectionModel()->selectedIndexes();
68 //**************************************************************
69 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
71 if (myWorkshop->isSalomeMode()) {
72 Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
74 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
75 theList.Append(aContext->SelectedInteractive());
77 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
78 aViewer->getSelectedObjects(theList);
82 //**************************************************************
83 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
85 if (myWorkshop->isSalomeMode()) {
87 Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
88 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
89 TopoDS_Shape aShape = aContext->SelectedShape();
91 theList.Append(aShape);
94 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
95 aViewer->getSelectedShapes(theList);