From: nds Date: Thu, 14 Jan 2016 13:40:48 +0000 (+0300) Subject: BUG: Sketch plane is initialized by click in empty place X-Git-Tag: V_2.2.0~213 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cc44f965f1cf88739b70bf73f33e877e72e11628;p=modules%2Fshaper.git BUG: Sketch plane is initialized by click in empty place Scenario: Start sketch Move mouse over planes(one of them is highlighted) Click in empty place Result: sketch nested actions are enabled, sketch planes stayed in the viewer. --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 6fa8eae78..090715361 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -359,7 +359,7 @@ bool ModuleBase_WidgetMultiSelector::processDelete() myWorkshop->setSelected(getAttributeSelection()); myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeAllObjects, true); } - return true; // if the delete should be processed outsize, the method should return isDone + return aDone; } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 55abdb503..0dab2cee1 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -136,17 +136,10 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th return aValid; } - DataPtr aData = myFeature->data(); - AttributePtr anAttribute = myFeature->attribute(attributeID()); - // stores the current values of the widget attribute - Events_Loop* aLoop = Events_Loop::loop(); - // blocks the flush signals to avoid the temporary objects visualization in the viewer - // they should not be shown in order to do not lose highlight by erasing them - bool isActive = aLoop->activateFlushes(false); + bool isFlushesActived, isAttributeSetInitializedBlocked; + blockAttribute(true, isFlushesActived, isAttributeSetInitializedBlocked); - aData->blockSendAttributeUpdated(true); - bool isAttributeBlocked = anAttribute->blockSetInitialized(true); storeAttributeValue(); // saves the owner value to the widget attribute @@ -157,10 +150,8 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th // restores the current values of the widget attribute restoreAttributeValue(aValid); - aData->blockSendAttributeUpdated(false); - anAttribute->blockSetInitialized(isAttributeBlocked); - aLoop->activateFlushes(isActive); + blockAttribute(false, isFlushesActived, isAttributeSetInitializedBlocked); // In particular case the results are deleted and called as redisplayed inside of this // highlight-selection, to they must be flushed as soon as possible. // Example: selection of group-vertices subshapes with shift pressend on body. Without @@ -168,8 +159,8 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th // removed results still in the viewer. static Events_ID aDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED); static Events_ID aRedispEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); - aLoop->flush(aDeletedEvent); - aLoop->flush(aRedispEvent); + Events_Loop::loop()->flush(aDeletedEvent); + Events_Loop::loop()->flush(aRedispEvent); storeValidState(theValue, aValid); return aValid; @@ -214,6 +205,28 @@ void ModuleBase_WidgetValidated::activateFilters(const bool toActivate) } } +//******************************************************************** +void ModuleBase_WidgetValidated::blockAttribute(const bool& theToBlock, bool& isFlushesActived, + bool& isAttributeSetInitializedBlocked) +{ + Events_Loop* aLoop = Events_Loop::loop(); + DataPtr aData = myFeature->data(); + AttributePtr anAttribute = myFeature->attribute(attributeID()); + if (theToBlock) { + // blocks the flush signals to avoid the temporary objects visualization in the viewer + // they should not be shown in order to do not lose highlight by erasing them + isFlushesActived = aLoop->activateFlushes(false); + + aData->blockSendAttributeUpdated(true); + isAttributeSetInitializedBlocked = anAttribute->blockSetInitialized(true); + } + else { + aData->blockSendAttributeUpdated(false); + anAttribute->blockSetInitialized(isAttributeSetInitializedBlocked); + aLoop->activateFlushes(isFlushesActived); + } +} + //******************************************************************** void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid) { diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 385f11a00..60ed4edc9 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -123,6 +123,15 @@ protected: /// \param toActivate a flag about activation or deactivation the filters void activateFilters(const bool toActivate); + /// Block the model flush of update and intialization of attribute + /// \param theToBlock flag whether the model is blocked or unblocked + /// \param isActive out value if model is blocked, in value if model is unblocked + /// to be used to restore flush state when unblocked + /// \param isAttributeSetInitializedBlocked out value if model is blocked + /// in value if model is unblocked to be used to restore previous state when unblocked + virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived, + bool& isAttributeSetInitializedBlocked); + protected: /// Reference to workshop ModuleBase_IWorkshop* myWorkshop; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index d64f10952..b8c78602c 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -185,6 +185,27 @@ void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn) emit showConstraintToggled(theOn, aState); } +void PartSet_WidgetSketchLabel::blockAttribute(const bool& theToBlock, bool& isFlushesActived, + bool& isAttributeSetInitializedBlocked) +{ + ModuleBase_WidgetValidated::blockAttribute(theToBlock, isFlushesActived, + isAttributeSetInitializedBlocked); + // We do not restore the previous state of isAttributeSetInitializedBlocked for each of + // attributes. It it is necessary, these states should be append to the method attributes + // or stored in the widget + + std::list anAttributes = myFeature->data()->attributes(""); + std::list::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end(); + QStringList aValues; + for(; anIt != aLast; anIt++) { + AttributePtr anAttribute = *anIt; + if (theToBlock) + anAttribute->blockSetInitialized(true); + else + anAttribute->blockSetInitialized(isAttributeSetInitializedBlocked); + } +} + void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs) { // 1. hide main planes if they have been displayed diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 9d9092253..600147ed4 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -121,6 +121,17 @@ protected: /// The methiod called when widget is activated virtual void activateCustom(); + /// Block the model flush of update and intialization of attribute + /// In additional to curstom realization it blocks initialization for all feature attributes + /// as the current attribute is selection but its modification leads to other attributes change + /// \param theToBlock flag whether the model is blocked or unblocked + /// \param isActive out value if model is blocked, in value if model is unblocked + /// to be used to restore flush state when unblocked + /// \param isAttributeSetInitializedBlocked out value if model is blocked + /// in value if model is unblocked to be used to restore previous state when unblocked + virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived, + bool& isAttributeSetInitializedBlocked); + /// Erase preview planes, disconnect widget, change the view projection /// \param thePrs a selected presentation void updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs); diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index a40e77722..06a3d5702 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -174,7 +174,10 @@ std::shared_ptr SketchPlugin_Plugin if (aData) { std::shared_ptr aNormal = std::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); - aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); + // it is important to check whether the normal attribute is initialized + // because it is possible that normal values are filled when the plane is checked on validity + aHasSketchPlane = aNormal && aNormal->isInitialized() && + !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane); aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);