1 #include "XGUI_SelectionMgr.h"
3 #include "XGUI_Workshop.h"
4 #include "XGUI_MainWindow.h"
5 #include "XGUI_ObjectsBrowser.h"
6 #include "XGUI_SalomeConnector.h"
7 #include "XGUI_ViewerProxy.h"
8 #include "XGUI_Displayer.h"
9 #include "XGUI_Selection.h"
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_PluginManager.h>
13 #include <ModelAPI_AttributeDocRef.h>
14 #include <ModelAPI_Data.h>
15 #include <ModelAPI_Result.h>
16 #include <ModelAPI_Object.h>
20 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
21 QObject(theParent), myWorkshop(theParent)
23 mySelection = new XGUI_Selection(myWorkshop);
26 XGUI_SelectionMgr::~XGUI_SelectionMgr()
31 //**************************************************************
32 void XGUI_SelectionMgr::connectViewers()
34 connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()),
35 this, SLOT(onObjectBrowserSelection()));
37 //Connect to other viewers
38 connect(myWorkshop->viewer(), SIGNAL(selectionChanged()),
39 this, SLOT(onViewerSelection()));
42 //**************************************************************
43 void XGUI_SelectionMgr::onObjectBrowserSelection()
45 QList<ObjectPtr> aObjects = myWorkshop->objectBrowser()->selectedObjects();
46 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
47 aDisplayer->setSelected(aObjects);
48 emit selectionChanged();
51 //**************************************************************
52 void XGUI_SelectionMgr::onViewerSelection()
54 QList<ObjectPtr> aFeatures;
55 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
56 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
57 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
58 ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
60 aFeatures.append(aResult);
62 bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true);
63 myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
64 myWorkshop->objectBrowser()->blockSignals(aBlocked);
66 emit selectionChanged();
69 //**************************************************************
70 /*QFeatureList XGUI_SelectionMgr::selectedFeatures() const
72 return myWorkshop->objectBrowser()->selectedFeatures();
75 //**************************************************************
76 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
78 return myWorkshop->objectBrowser()->selectedIndexes();
81 //**************************************************************
82 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
84 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
86 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
87 theList.Append(aContext->SelectedInteractive());
90 //**************************************************************
91 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
94 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
95 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
96 TopoDS_Shape aShape = aContext->SelectedShape();
98 theList.Append(aShape);