#include "XGUI_Workshop.h"
#include "XGUI_MainWindow.h"
#include "XGUI_ObjectsBrowser.h"
+#include "XGUI_Viewer.h"
+#include "XGUI_SalomeConnector.h"
+#include "XGUI_ViewerProxy.h"
#include <ModelAPI_Feature.h>
#include <ModelAPI_PluginManager.h>
{
}
-void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB)
+XGUI_SelectionMgr::~XGUI_SelectionMgr()
{
- myObjectBrowser = theOB;
- connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
}
-XGUI_SelectionMgr::~XGUI_SelectionMgr()
+//**************************************************************
+void XGUI_SelectionMgr::connectViewers()
{
+ connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()),
+ this, SLOT(onObjectBrowserSelection()));
+
+ //Connect to other viewers
+ if (myWorkshop->isSalomeMode()) {
+ connect(myWorkshop, SIGNAL(salomeViewerSelection()),
+ this, SLOT(onViewerSelection()));
+ } else {
+ connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
+ this, SLOT(onViewerSelection()));
+ }
}
-void XGUI_SelectionMgr::onSelectionChanged()
+//**************************************************************
+void XGUI_SelectionMgr::onObjectBrowserSelection()
{
- XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
- mySelectedData = aObjBrowser->selectedData();
-
- // Set current document
- if (mySelectedData.size() > 0) {
- FeaturePtr aFeature = mySelectedData.first();
-
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
- if (aDocRef)
- aMgr->setCurrentDocument(aDocRef->value());
- }
+
+ // TODO: Highliht selected objects in Viewer 3d
emit selectionChanged();
-}
\ No newline at end of file
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::onViewerSelection()
+{
+ // TODO: Highliht selected objects in Object Browser
+ emit selectionChanged();
+}
+
+//**************************************************************
+QFeatureList XGUI_SelectionMgr::selectedFeatures() const
+{
+ return myWorkshop->objectBrowser()->selectedFeatures();
+}
+
+//**************************************************************
+QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
+{
+ return myWorkshop->objectBrowser()->selectedIndexes();
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
+{
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ theList.Clear();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ theList.Append(aContext->SelectedInteractive());
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
+{
+ theList.Clear();
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ TopoDS_Shape aShape = aContext->SelectedShape();
+ if (!aShape.IsNull())
+ theList.Append(aShape);
+ }
+}