1 #include "XGUI_SelectionMgr.h"
3 #include "XGUI_Workshop.h"
4 #include "XGUI_ObjectsBrowser.h"
5 #include "XGUI_SalomeConnector.h"
6 #include "XGUI_ViewerProxy.h"
7 #include "XGUI_Displayer.h"
8 #include "XGUI_Selection.h"
10 #include <AppElements_MainWindow.h>
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Session.h>
14 #include <ModelAPI_AttributeDocRef.h>
15 #include <ModelAPI_Data.h>
16 #include <ModelAPI_Result.h>
17 #include <ModelAPI_Object.h>
19 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent)
23 mySelection = new XGUI_Selection(myWorkshop);
26 XGUI_SelectionMgr::~XGUI_SelectionMgr()
31 //**************************************************************
32 void XGUI_SelectionMgr::connectViewers()
34 connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()), this,
35 SLOT(onObjectBrowserSelection()));
37 //Connect to other viewers
38 connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), this, SLOT(onViewerSelection()));
41 //**************************************************************
42 void XGUI_SelectionMgr::onObjectBrowserSelection()
44 QObjectPtrList aObjects = myWorkshop->objectBrowser()->selectedObjects();
45 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
46 aDisplayer->setSelected(aObjects);
47 emit selectionChanged();
50 //**************************************************************
51 void XGUI_SelectionMgr::onViewerSelection()
53 QObjectPtrList aFeatures;
54 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
55 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
56 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
57 ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
59 aFeatures.append(aResult);
61 bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true);
62 myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
63 myWorkshop->objectBrowser()->blockSignals(aBlocked);
65 emit selectionChanged();
68 //**************************************************************
69 /*QFeatureList XGUI_SelectionMgr::selectedFeatures() const
71 return myWorkshop->objectBrowser()->selectedFeatures();
74 //**************************************************************
75 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
77 return myWorkshop->objectBrowser()->selectedIndexes();
80 //**************************************************************
81 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
83 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
85 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
86 theList.Append(aContext->SelectedInteractive());
89 //**************************************************************
90 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
93 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
94 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
95 TopoDS_Shape aShape = aContext->SelectedShape();
97 theList.Append(aShape);