]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Restore selection in the viewer by multi selector widget activation.
authornds <natalia.donis@opencascade.com>
Thu, 30 Apr 2015 20:01:47 +0000 (23:01 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 30 Apr 2015 20:01:47 +0000 (23:01 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/PartSet/PartSet_WidgetMultiSelector.h
src/XGUI/XGUI_Displayer.cpp

index c2e3138a534a37470800e452fb16f8edb031bdec..2255215011c0e31383e9401a0071c37c674c13d7 100644 (file)
@@ -13,6 +13,7 @@
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_Definitions.h>
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
@@ -107,6 +108,23 @@ void ModuleBase_WidgetMultiSelector::activateCustom()
 
   myIsActive = true;
   activateShapeSelection();
+
+  QObjectPtrList anObjects;
+  // Restore selection in the viewer by the attribute selection list
+  if(myFeature) {
+    DataPtr aData = myFeature->data();
+    AttributeSelectionListPtr aListAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
+    if (aListAttr) {
+      for (int i = 0; i < aListAttr->size(); i++) {
+        AttributeSelectionPtr anAttr = aListAttr->value(i);
+        ResultPtr anObject = anAttr->context();
+        if (anObject.get())
+          anObjects.append(anObject);
+      }
+    }
+  }
+  myWorkshop->setSelected(anObjects);
 }
 
 //********************************************************************
index ba7ffea5497942228d1df1a2d90b3fffd4f4a5c0..8b71001e8c147cb98fe5213b77feb2834ade8bea 100644 (file)
@@ -36,6 +36,9 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetMultiSelector();
 
+  /// Defines if it is supposed that the widget should interact with the viewer.
+  virtual bool isViewerSelector() { return true; }
+
   /// Set sketcher
   /// \param theSketch a sketcher object
   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
index 486f23a50f038a6acf2e503d56758b2a212a0912..430556d295d9c5e2e8bc5d8e79750747343a9bde 100644 (file)
@@ -428,8 +428,13 @@ void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool is
       if (isVisible(aResult)) {
         AISObjectPtr anObj = myResult2AISObjectMap[aResult];
         Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-        if (!anAIS.IsNull())
-          aContext->SetSelected(anAIS, false);
+        if (!anAIS.IsNull()) {
+          // The methods are replaced in order to provide multi-selection, e.g. restore selection
+          // by activating multi selector widget. It also gives an advantage that the multi
+          // selection in OB gives multi-selection in the viewer
+          //aContext->SetSelected(anAIS, false);
+          aContext->AddOrRemoveSelected(anAIS, false);
+        }
       }
     }
   } else {