1 #include "XGUI_SelectionMgr.h"
2 #include "XGUI_Workshop.h"
3 #include "XGUI_MainWindow.h"
4 #include "XGUI_ObjectsBrowser.h"
6 #include <ModelAPI_Feature.h>
7 #include <ModelAPI_PluginManager.h>
8 #include <ModelAPI_AttributeDocRef.h>
9 #include <ModelAPI_Data.h>
13 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
14 QObject(theParent), myWorkshop(theParent)
18 void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB)
20 myObjectBrowser = theOB;
21 connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
24 XGUI_SelectionMgr::~XGUI_SelectionMgr()
28 void XGUI_SelectionMgr::onSelectionChanged()
30 XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
31 mySelectedData = aObjBrowser->selectedData();
33 // Set current document
34 if (mySelectedData.size() > 0) {
35 FeaturePtr aFeature = mySelectedData.first();
37 std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
38 std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
40 aMgr->setCurrentDocument(aDocRef->value());
43 emit selectionChanged();