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_Session.h>
13 #include <ModelAPI_AttributeDocRef.h>
14 #include <ModelAPI_Data.h>
15 #include <ModelAPI_Result.h>
16 #include <ModelAPI_Object.h>
18 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent)
22 mySelection = new XGUI_Selection(myWorkshop);
25 XGUI_SelectionMgr::~XGUI_SelectionMgr()
30 //**************************************************************
31 void XGUI_SelectionMgr::connectViewers()
33 connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()), this,
34 SLOT(onObjectBrowserSelection()));
36 //Connect to other viewers
37 connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), this, SLOT(onViewerSelection()));
40 //**************************************************************
41 void XGUI_SelectionMgr::onObjectBrowserSelection()
43 QList<ObjectPtr> aObjects = myWorkshop->objectBrowser()->selectedObjects();
44 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
45 aDisplayer->setSelected(aObjects);
46 emit selectionChanged();
49 //**************************************************************
50 void XGUI_SelectionMgr::onViewerSelection()
52 QList<ObjectPtr> aFeatures;
53 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
54 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
55 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
56 ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
58 aFeatures.append(aResult);
60 bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true);
61 myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
62 myWorkshop->objectBrowser()->blockSignals(aBlocked);
64 emit selectionChanged();
67 //**************************************************************
68 /*QFeatureList XGUI_SelectionMgr::selectedFeatures() const
70 return myWorkshop->objectBrowser()->selectedFeatures();
73 //**************************************************************
74 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
76 return myWorkshop->objectBrowser()->selectedIndexes();
79 //**************************************************************
80 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
82 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
84 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
85 theList.Append(aContext->SelectedInteractive());
88 //**************************************************************
89 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
92 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
93 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
94 TopoDS_Shape aShape = aContext->SelectedShape();
96 theList.Append(aShape);