]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_SelectionMgr.cpp
Salome HOME
Merge branch 'master' of newgeom:newgeom
[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_ViewerProxy.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()->selectedIndexes();
67 }
68
69 //**************************************************************
70 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
71 {
72   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
73   theList.Clear();
74   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
75     theList.Append(aContext->SelectedInteractive());
76 }
77
78 //**************************************************************
79 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
80 {
81   theList.Clear();
82   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
83   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
84     TopoDS_Shape aShape = aContext->SelectedShape();
85     if (!aShape.IsNull())
86       theList.Append(aShape);
87   }
88 }