Salome HOME
9d1d1e72490207b1b9a426b368d3ce2dc5532704
[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_Object.h>
10
11
12
13 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
14   QObject(theParent), myWorkshop(theParent)
15 {
16   XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
17
18   connect(aObjBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
19 }
20
21
22 XGUI_SelectionMgr::~XGUI_SelectionMgr()
23 {
24 }
25
26 void XGUI_SelectionMgr::onSelectionChanged()
27 {
28   XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
29   mySelectedData = aObjBrowser->selectedData();
30   
31   // Set current document
32   if (mySelectedData.size() > 0) {
33     FeaturePtr aFeature = mySelectedData.first();
34
35     std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
36     aMgr->setCurrentDocument(aFeature->data()->docRef("PartDocument")->value());
37   }
38
39   emit selectionChanged();
40 }