]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_SelectionMgr.cpp
Salome HOME
0bba0d847e44253acc5379e70d42b3c64deef85b
[modules/shaper.git] / src / XGUI / XGUI_SelectionMgr.cpp
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
8 #include <ModelAPI_Feature.h>
9 #include <ModelAPI_PluginManager.h>
10 #include <ModelAPI_AttributeDocRef.h>
11 #include <ModelAPI_Data.h>
12
13
14
15 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
16   QObject(theParent), myWorkshop(theParent)
17 {
18 }
19
20 XGUI_SelectionMgr::~XGUI_SelectionMgr()
21 {
22 }
23
24 //**************************************************************
25 void XGUI_SelectionMgr::connectViewers()
26 {
27   connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()), 
28     this, SLOT(onObjectBrowserSelection()));
29
30   //Connect to other viewers
31   if (myWorkshop->isSalomeMode()) {
32     connect(myWorkshop, SIGNAL(salomeViewerSelection()),
33       this, SLOT(onViewerSelection()));
34   } else {
35     connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
36       this, SLOT(onViewerSelection()));
37   }
38 }
39
40 //**************************************************************
41 void XGUI_SelectionMgr::onObjectBrowserSelection()
42 {
43
44   // TODO: Highliht selected objects in Viewer 3d
45
46   emit selectionChanged();
47 }
48
49 //**************************************************************
50 void XGUI_SelectionMgr::onViewerSelection()
51 {
52   // TODO: Highliht selected objects in Object Browser
53   emit selectionChanged();
54 }
55
56 //**************************************************************
57 QFeatureList XGUI_SelectionMgr::selectedFeatures() const 
58
59   return myWorkshop->objectBrowser()->selectedFeatures(); 
60 }
61
62 //**************************************************************
63 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const 
64
65   return myWorkshop->objectBrowser()->selectionModel()->selectedIndexes();
66 }
67
68 //**************************************************************
69 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
70 {
71   if (myWorkshop->isSalomeMode()) {
72     Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
73     theList.Clear();
74     for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
75       theList.Append(aContext->SelectedInteractive());
76   } else {
77     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
78     aViewer->getSelectedObjects(theList);
79   }
80 }
81
82 //**************************************************************
83 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
84 {
85   if (myWorkshop->isSalomeMode()) {
86     theList.Clear();
87     Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
88     for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
89       TopoDS_Shape aShape = aContext->SelectedShape();
90       if (!aShape.IsNull())
91         theList.Append(aShape);
92     }
93   } else {
94     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
95     aViewer->getSelectedShapes(theList);
96   }
97 }