X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetSketchLabel.cpp;h=c2ca8a4d2d863cefb118caf7f7dd05e92a5cb639;hb=4b1f76b455140cae5d18319b62627af3ba28f226;hp=2bf6d00aa5f2b1619e77eecd195f91b418ebe643;hpb=3b83d3f11641c0a2001c1ad73d68d920f3b4530c;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 2bf6d00aa..c2ca8a4d2 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -85,6 +85,17 @@ PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel() erasePreviewPlanes(); } +bool PartSet_WidgetSketchLabel::setSelection(const QList& theValues, int& thePosition) +{ + // do not use the given selection if the plane of the sketch has been already set. + // If this check is absent, a selected plane in the viewer can be set in the sketch + // even if the sketch is built on another plane. + if (plane().get()) + return true; + + return ModuleBase_WidgetValidated::setSelection(theValues, thePosition); +} + QList PartSet_WidgetSketchLabel::getControls() const { QList aResult; @@ -94,26 +105,12 @@ QList PartSet_WidgetSketchLabel::getControls() const void PartSet_WidgetSketchLabel::onSelectionChanged() { - ModuleBase_ViewerPrs aPrs; - // 1. find selected presentation either in the viewer or in OB - XGUI_Selection* aSelection = myWorkshop->selector()->selection(); - QList aSelected = aSelection->getSelected(); - // the selection in OCC viewer - the selection of a face in the viewer - // it can be th main plane's face of a face on a visualized body - if (!aSelected.empty()) { - aPrs = aSelected.first(); - } - else { - // the selection in Object Browser: the plane object can be used as sketch plane - QObjectPtrList anObjects = aSelection->selectedObjects(); - if (!anObjects.empty()) { - aPrs.setObject(anObjects.first()); - } - } - if (aPrs.isEmpty()) + QList aSelectedPrs = getSelectedEntitiesOrObjects( + myWorkshop->selector()->selection()); + if (aSelectedPrs.empty()) return; - - if (!isValidSelection(aPrs)) + ModuleBase_ViewerPrs aPrs = aSelectedPrs.first(); + if (aPrs.isEmpty() || !isValidSelection(aPrs)) return; // 2. set the selection to sketch