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"
10 #include <ModelAPI_Feature.h>
11 #include <ModelAPI_PluginManager.h>
12 #include <ModelAPI_AttributeDocRef.h>
13 #include <ModelAPI_Data.h>
17 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
18 QObject(theParent), myWorkshop(theParent)
22 XGUI_SelectionMgr::~XGUI_SelectionMgr()
26 //**************************************************************
27 void XGUI_SelectionMgr::connectViewers()
29 connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()),
30 this, SLOT(onObjectBrowserSelection()));
32 //Connect to other viewers
33 connect(myWorkshop->viewer(), SIGNAL(selectionChanged()),
34 this, SLOT(onViewerSelection()));
37 //**************************************************************
38 void XGUI_SelectionMgr::onObjectBrowserSelection()
40 QFeatureList aFeatures = selectedFeatures();
41 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
42 aDisplayer->setSelected(aFeatures);
44 emit selectionChanged();
47 //**************************************************************
48 void XGUI_SelectionMgr::onViewerSelection()
50 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
51 QFeatureList aFeatures = aDisplayer->selectedFeatures();
52 myWorkshop->objectBrowser()->setFeaturesSelected(aFeatures);
53 emit selectionChanged();
56 //**************************************************************
57 QFeatureList XGUI_SelectionMgr::selectedFeatures() const
59 return myWorkshop->objectBrowser()->selectedFeatures();
62 //**************************************************************
63 QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
65 return myWorkshop->objectBrowser()->selectedIndexes();
68 //**************************************************************
69 void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
71 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
73 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
74 theList.Append(aContext->SelectedInteractive());
77 //**************************************************************
78 void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
81 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
82 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
83 TopoDS_Shape aShape = aContext->SelectedShape();
85 theList.Append(aShape);