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_Object.h>
13 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
14 QObject(theParent), myWorkshop(theParent)
16 XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
18 connect(aObjBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
22 XGUI_SelectionMgr::~XGUI_SelectionMgr()
26 void XGUI_SelectionMgr::onSelectionChanged()
28 XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
29 mySelectedData = aObjBrowser->selectedData();
31 // Set current document
32 if (mySelectedData.size() > 0) {
33 FeaturePtr aFeature = mySelectedData.first();
35 std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
36 std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
38 aMgr->setCurrentDocument(aDocRef->value());
41 emit selectionChanged();