From 60a73811930634f2c4ead912a865c7d24211f728 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 30 Apr 2015 23:01:47 +0300 Subject: [PATCH] Restore selection in the viewer by multi selector widget activation. --- .../ModuleBase_WidgetMultiSelector.cpp | 18 ++++++++++++++++++ src/PartSet/PartSet_WidgetMultiSelector.h | 3 +++ src/XGUI/XGUI_Displayer.cpp | 9 +++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index c2e3138a5..225521501 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -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(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); } //******************************************************************** diff --git a/src/PartSet/PartSet_WidgetMultiSelector.h b/src/PartSet/PartSet_WidgetMultiSelector.h index ba7ffea54..8b71001e8 100644 --- a/src/PartSet/PartSet_WidgetMultiSelector.h +++ b/src/PartSet/PartSet_WidgetMultiSelector.h @@ -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; } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 486f23a50..430556d29 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -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(); - 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 { -- 2.39.2