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