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
6 #include <ModelAPI_Feature.h>
7 #include <ModelAPI_PluginManager.h>
8 #include <ModelAPI_AttributeDocRef.h>
9 #include <ModelAPI_Data.h>
10
11
12
13 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
14   QObject(theParent), myWorkshop(theParent)
15 {
16 }
17
18 void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB)
19 {
20   myObjectBrowser = theOB;
21   connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
22 }
23
24 XGUI_SelectionMgr::~XGUI_SelectionMgr()
25 {
26 }
27
28 void XGUI_SelectionMgr::onSelectionChanged()
29 {
30   XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->objectBrowser();
31   mySelectedData = aObjBrowser->selectedData();
32   
33   // Set current document
34   if (mySelectedData.size() > 0) {
35     FeaturePtr aFeature = mySelectedData.first();
36
37     boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
38     boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
39     if (aDocRef)
40       aMgr->setCurrentDocument(aDocRef->value());
41   }
42
43   emit selectionChanged();
44 }