From: nds Date: Wed, 17 Jun 2015 12:40:03 +0000 (+0300) Subject: Preselection using in operations: setSelection using in onSelectionChanged method. X-Git-Tag: V_1.3.0~228 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ddf41594c01d07eba840547e58c7fa35e8ce567e;p=modules%2Fshaper.git Preselection using in operations: setSelection using in onSelectionChanged method. --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 2720e55cf..b01892e6a 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -300,19 +300,21 @@ bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_Vie return true; #endif GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs); - // if there is no selected shape, the method returns true - bool aValid; - if (!aShape.get()) - aValid = true; - else { - // Check that the selection corresponds to selection type - TopoDS_Shape aTopoShape = aShape->impl(); - aValid = acceptSubShape(aTopoShape); + // if there is no result(the feature is presentable only), result is false + ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); + bool aValid = aResult.get() != NULL; + if (aValid) { + // if there is no selected shape, the method returns true + if (!aShape.get()) + aValid = true; + else { + // Check that the selection corresponds to selection type + TopoDS_Shape aTopoShape = aShape->impl(); + aValid = acceptSubShape(aTopoShape); + } } if (aValid) { - ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); - if (myFeature) { // We can not select a result of our feature const std::list& aResList = myFeature->results(); @@ -327,7 +329,6 @@ bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_Vie if(isSkipSelf) aValid = false; } - } return aValid; @@ -412,15 +413,10 @@ void ModuleBase_WidgetMultiSelector::onSelectionChanged() DataPtr aData = myFeature->data(); AttributeSelectionListPtr aSelectionListAttr = std::dynamic_pointer_cast(aData->attribute(attributeID())); - aSelectionListAttr->clear(); - if (aSelected.size() > 0) { - foreach (ModuleBase_ViewerPrs aPrs, aSelected) { - if (isValidSelection(aPrs)) { - setSelectionCustom(aPrs); - } - } - } + + setSelection(aSelected); + emit valuesChanged(); // the updateObject method should be called to flush the updated sigal. The workshop listens it, // calls validators for the feature and, as a result, updates the Apply button state. diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 457a9f6ff..03aaf1fcb 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -214,15 +214,9 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() // In order to make reselection possible, set empty object and shape should be done setObject(ObjectPtr(), std::shared_ptr(new GeomAPI_Shape())); - bool aHasObject = false; - QList aSelectedPrs = myWorkshop->selection()->getSelected(ModuleBase_ISelection::AllControls); - if (!aSelectedPrs.empty()) { - ModuleBase_ViewerPrs aPrs = aSelectedPrs.first(); - if (!aPrs.isEmpty() && isValidSelection(aPrs)) { - setSelectionCustom(aPrs); - aHasObject = true; - } - } + QList aSelected = myWorkshop->selection()->getSelected(ModuleBase_ISelection::AllControls); + bool aHasObject = setSelection(aSelected); + // the updateObject method should be called to flush the updated sigal. The workshop listens it, // calls validators for the feature and, as a result, updates the Apply button state. updateObject(myFeature); diff --git a/src/PartSet/PartSet_WidgetMultiSelector.cpp b/src/PartSet/PartSet_WidgetMultiSelector.cpp index 355758282..139be4ee3 100644 --- a/src/PartSet/PartSet_WidgetMultiSelector.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelector.cpp @@ -81,21 +81,12 @@ void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid) //******************************************************************** bool PartSet_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) { - TopoDS_Shape aShape = thePrs.shape(); - if (!acceptSubShape(aShape)) - return false; - - ResultPtr aResult; - if (!thePrs.owner().IsNull()) { - ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner()); - aResult = std::dynamic_pointer_cast(anObject); - } - else { - aResult = std::dynamic_pointer_cast(thePrs.object()); - } - + //TopoDS_Shape aShape = thePrs.shape(); + //if (!acceptSubShape(aShape)) + // return false; - if (myFeature) { + ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); + /*if (myFeature) { // We can not select a result of our feature const std::list& aResList = myFeature->results(); std::list::const_iterator aIt; @@ -108,9 +99,9 @@ bool PartSet_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& } if(isSkipSelf) return false; - } + }*/ - GeomShapePtr aGShape = GeomShapePtr(); + /*GeomShapePtr aGShape = GeomShapePtr(); const TopoDS_Shape& aTDSShape = thePrs.shape(); // if only result is selected, an empty shape is set to the model if (aTDSShape.IsNull()) { @@ -128,8 +119,9 @@ bool PartSet_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& else { //aSelectionListAttr->append(aResult, aShape); } - } + }*/ + GeomShapePtr aGShape = myWorkshop->selection()->getShape(thePrs); setObject(aResult, aGShape); return true; } diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 9e659086c..e2d551bd2 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -101,16 +101,16 @@ QList PartSet_WidgetSketchLabel::getControls() const void PartSet_WidgetSketchLabel::onSelectionChanged() { - QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected( + QList aSelected = myWorkshop->selector()->selection()->getSelected( ModuleBase_ISelection::AllControls); - if (aSelectedPrs.empty()) + if (aSelected.empty()) return; - ModuleBase_ViewerPrs aPrs = aSelectedPrs.first(); - if (aPrs.isEmpty() || !isValidSelection(aPrs)) + ModuleBase_ViewerPrs aPrs = aSelected.first(); + + bool isDone = ModuleBase_WidgetValidated::setSelection(aSelected); + if (!isDone) return; - // 2. set the selection to sketch - setSelectionCustom(aPrs); // 3. hide main planes if they have been displayed erasePreviewPlanes(); // 4. if the planes were displayed, change the view projection