Salome HOME
Avoid redisplay of sketcher while it is not finished
[modules/shaper.git] / src / XGUI / XGUI_SelectionMgr.cpp
index f949c782a5a4b4a7ca17f5440ef2a7513a1cc441..caf78cededfa473823d177c7ad21591edcd6f852 100644 (file)
@@ -1,25 +1,31 @@
 #include "XGUI_SelectionMgr.h"
+
 #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 "XGUI_Displayer.h"
+#include "XGUI_Selection.h"
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Object.h>
 
 
 
 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
   QObject(theParent), myWorkshop(theParent)
 {
+  mySelection = new XGUI_Selection(myWorkshop);
 }
 
 XGUI_SelectionMgr::~XGUI_SelectionMgr()
 {
+  delete mySelection;
 }
 
 //**************************************************************
@@ -29,33 +35,39 @@ void XGUI_SelectionMgr::connectViewers()
     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()));
-  }
+  connect(myWorkshop->viewer(), SIGNAL(selectionChanged()),
+    this, SLOT(onViewerSelection()));
 }
 
 //**************************************************************
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
-
-  // TODO: Highliht selected objects in Viewer 3d
-
+  QList<ObjectPtr> aObjects = myWorkshop->objectBrowser()->selectedObjects();
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  aDisplayer->setSelected(aObjects);
   emit selectionChanged();
 }
 
 //**************************************************************
 void XGUI_SelectionMgr::onViewerSelection()
 {
-  // TODO: Highliht selected objects in Object Browser
+  QList<ObjectPtr> aFeatures;
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+    ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
+    if (aResult)
+      aFeatures.append(aResult);
+  }
+  bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true);
+  myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
+  myWorkshop->objectBrowser()->blockSignals(aBlocked);
+
   emit selectionChanged();
 }
 
 //**************************************************************
-QFeatureList XGUI_SelectionMgr::selectedFeatures() const 
+/*QFeatureList XGUI_SelectionMgr::selectedFeatures() const 
 { 
   return myWorkshop->objectBrowser()->selectedFeatures(); 
 }
@@ -85,4 +97,4 @@ void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList)
     if (!aShape.IsNull())
       theList.Append(aShape);
   }
-}
+}*/