X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetSketchLabel.cpp;h=2ce6f152e509dc63d733a5228c3e3a327f96f137;hb=1834431e0e067cbb4616f42679562d56af528f5e;hp=6760949400bf9c47906b827752426f307d9bd62b;hpb=a11ca8e50848c291ed13f920168622937ae3b8dc;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 676094940..2ce6f152e 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 @@ -229,7 +226,7 @@ bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& t } else if (!aShape.IsNull()) { aDir = setSketchPlane(aShape); - isOwnerSet = aDir; + isOwnerSet = aDir.get(); } return isOwnerSet; } @@ -237,6 +234,9 @@ bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& t void PartSet_WidgetSketchLabel::activateCustom() { std::shared_ptr aPlane = plane(); + if (aPlane.get()) + return; + bool aBodyIsVisualized = false; XGUI_Displayer* aDisp = myWorkshop->displayer(); QObjectPtrList aDisplayed = aDisp->displayedObjects(); @@ -249,14 +249,7 @@ void PartSet_WidgetSketchLabel::activateCustom() } } - if (aPlane || aBodyIsVisualized) { - //setSketchingMode(); - // In order to avoid Opening/Closing of context too often - // it can be useful for a delay on the property panel filling - // it is possible that it is not necessary anymore, but it requires a check - //mySelectionTimer->start(20); - //setSketchingMode(); - } else { + if (!aBodyIsVisualized) { // We have to select a plane before any operation showPreviewPlanes(); }