From: nds Date: Thu, 26 Jan 2017 09:01:06 +0000 (+0300) Subject: Issue #1941 Split auxiliary line. X-Git-Tag: V_2.7.0~307 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6962b55abf9d2cd5c5a5853ef98b72b86bb262e2;p=modules%2Fshaper.git Issue #1941 Split auxiliary line. Case: create circle in sketch, set auxiliary state, create lines contour: 1st, 3rd and 5th points are coincident to the circle. Make split of a circle segment. Call arc edit, set not auxiliary. Result it is visualized still as auxiliary. --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 750b9103b..a2e4a208c 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -298,8 +298,9 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) } } -void Model_Data::blockSendAttributeUpdated(const bool theBlock, const bool theSendMessage) +bool Model_Data::blockSendAttributeUpdated(const bool theBlock, const bool theSendMessage) { + bool aWasBlocked = mySendAttributeUpdated; if (mySendAttributeUpdated == theBlock) { mySendAttributeUpdated = !theBlock; if (mySendAttributeUpdated && !myWasChangedButBlocked.empty()) { @@ -320,6 +321,7 @@ void Model_Data::blockSendAttributeUpdated(const bool theBlock, const bool theSe } } } + return aWasBlocked; } void Model_Data::erase() diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 30b7b3486..f34306dcb 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -171,7 +171,8 @@ class Model_Data : public ModelAPI_Data /// \param theSendMessage if false, it does not send the update message /// even if something is changed /// (normally is it used in attributeChanged because this message will be sent anyway) - MODEL_EXPORT virtual void blockSendAttributeUpdated( + /// \returns the previous state of block + MODEL_EXPORT virtual bool blockSendAttributeUpdated( const bool theBlock, const bool theSendMessage = true); /// Puts feature to the document data sub-structure diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index da5161421..a8d196093 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -129,8 +129,8 @@ class MODELAPI_EXPORT ModelAPI_Data /// Blocks sending "attribute updated" if theBlock is true /// \param theID identifier of the attribute that can be referenced by this ID later /// \param theAttrType type of the created attribute (received from the type method) - /// \returns the just created attribute - virtual void blockSendAttributeUpdated( + /// \returns the previous state of block + virtual bool blockSendAttributeUpdated( const bool theBlock, const bool theSendMessage = true) = 0; /// Erases all the data from the data model diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index b0d69053e..b6ce46421 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -150,9 +150,10 @@ bool ModuleBase_WidgetValidated::isValidSelectionForAttribute( bool aValid = false; // stores the current values of the widget attribute - bool isFlushesActived, isAttributeSetInitializedBlocked; + bool isFlushesActived, isAttributeSetInitializedBlocked, isAttributeSendUpdatedBlocked; - blockAttribute(theAttribute, true, isFlushesActived, isAttributeSetInitializedBlocked); + blockAttribute(theAttribute, true, isFlushesActived, isAttributeSetInitializedBlocked, + isAttributeSendUpdatedBlocked); storeAttributeValue(theAttribute); @@ -165,7 +166,8 @@ bool ModuleBase_WidgetValidated::isValidSelectionForAttribute( // restores the current values of the widget attribute restoreAttributeValue(theAttribute, aValid); - blockAttribute(theAttribute, false, isFlushesActived, isAttributeSetInitializedBlocked); + blockAttribute(theAttribute, false, isFlushesActived, isAttributeSetInitializedBlocked, + isAttributeSendUpdatedBlocked); /// NDS: The following rows are commented for issue #1452 (to be removed after debug) /// This is not correct to perform it here because it might cause update selection and /// the selection mechanizm will be circled: use the scenario of the bug with preselected point. @@ -229,7 +231,8 @@ bool ModuleBase_WidgetValidated::activateFilters(const bool toActivate) void ModuleBase_WidgetValidated::blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock, bool& isFlushesActived, - bool& isAttributeSetInitializedBlocked) + bool& isAttributeSetInitializedBlocked, + bool& isAttributeSendUpdatedBlocked) { Events_Loop* aLoop = Events_Loop::loop(); DataPtr aData = myFeature->data(); @@ -238,11 +241,11 @@ void ModuleBase_WidgetValidated::blockAttribute(const AttributePtr& theAttribute // they should not be shown in order to do not lose highlight by erasing them isFlushesActived = aLoop->activateFlushes(false); - aData->blockSendAttributeUpdated(true); + isAttributeSendUpdatedBlocked = aData->blockSendAttributeUpdated(true); isAttributeSetInitializedBlocked = theAttribute->blockSetInitialized(true); } else { - aData->blockSendAttributeUpdated(false, false); + aData->blockSendAttributeUpdated(isAttributeSendUpdatedBlocked, false); theAttribute->blockSetInitialized(isAttributeSetInitializedBlocked); aLoop->activateFlushes(isFlushesActived); } diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 71f9c8a2e..ac8eb89eb 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -126,8 +126,10 @@ protected: /// 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 + /// \param isAttributeSendUpdatedBlocked out value if model signal is blocked virtual void blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock, - bool& isFlushesActived, bool& isAttributeSetInitializedBlocked); + bool& isFlushesActived, bool& isAttributeSetInitializedBlocked, + bool& isAttributeSendUpdatedBlocked); private: /// Checks the current attibute in all attribute validators diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index 428f43f8b..ef8fa81fb 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -140,9 +140,9 @@ void ParametersPlugin_EvalListener::renameInParameter( theNewName); // Issue #588. No need for reevaluating expression. // Moreover, current history may not contain necessary parameters. - anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(true); + bool aWasBlocked = anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(true); anExpressionAttribute->setValue(anExpressionString); - anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(false); + anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(aWasBlocked); } void ParametersPlugin_EvalListener::renameInAttribute( @@ -229,18 +229,18 @@ bool isValidAttribute(const AttributePtr& theAttribute) void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName) { - theResultParameter->data()->blockSendAttributeUpdated(true); + bool aWasBlocked = theResultParameter->data()->blockSendAttributeUpdated(true); theResultParameter->data()->setName(theName); - theResultParameter->data()->blockSendAttributeUpdated(false, false); + theResultParameter->data()->blockSendAttributeUpdated(aWasBlocked, false); std::shared_ptr aParameter = std::dynamic_pointer_cast( ModelAPI_Feature::feature(theResultParameter)); - aParameter->data()->blockSendAttributeUpdated(true); + aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true); aParameter->data()->setName(theName); aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName); - aParameter->data()->blockSendAttributeUpdated(false); + aParameter->data()->blockSendAttributeUpdated(aWasBlocked); } void ParametersPlugin_EvalListener::processObjectRenamedEvent( diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index a45de9121..1daff12ae 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -211,10 +211,12 @@ void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn) void PartSet_WidgetSketchLabel::blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock, bool& isFlushesActived, - bool& isAttributeSetInitializedBlocked) + bool& isAttributeSetInitializedBlocked, + bool& isAttributeSendUpdatedBlocked) { ModuleBase_WidgetValidated::blockAttribute(theAttribute, theToBlock, isFlushesActived, - isAttributeSetInitializedBlocked); + isAttributeSetInitializedBlocked, + isAttributeSendUpdatedBlocked); // 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 diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index a89a6167d..7e0a1c73e 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -130,9 +130,11 @@ protected: /// 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 + /// \param isAttributeSendUpdatedBlocked out value if model signal is blocked virtual void blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock, bool& isFlushesActived, - bool& isAttributeSetInitializedBlocked); + bool& isAttributeSetInitializedBlocked, + bool& isAttributeSendUpdatedBlocked); /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index be7ad7dc7..3b7e41349 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -268,7 +268,7 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - aData->blockSendAttributeUpdated(true); + bool aWasBlocked = aData->blockSendAttributeUpdated(true); myStartUpdate = true; myEndUpdate = true; @@ -293,7 +293,7 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY) std::dynamic_pointer_cast(aData->attribute(PASSED_POINT_ID())); if (aPassedPoint->isInitialized()) aPassedPoint->move(theDeltaX, theDeltaY); - aData->blockSendAttributeUpdated(false); + aData->blockSendAttributeUpdated(aWasBlocked); } bool SketchPlugin_Arc::isFixed() { @@ -418,10 +418,10 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) std::shared_ptr aMiddleLine(new GeomAPI_Lin2d(aMidPnt, aMidDir)); std::shared_ptr aCenter = anOrthoLine->intersect(aMiddleLine); if (aCenter) { - data()->blockSendAttributeUpdated(true); + bool aWasBlocked = data()->blockSendAttributeUpdated(true); aCenterAttr->setValue(aCenter); aStartAttr->setValue(aTangPnt2d); - data()->blockSendAttributeUpdated(false); + data()->blockSendAttributeUpdated(aWasBlocked); } tangencyArcConstraints(); @@ -441,7 +441,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) return; std::shared_ptr aCircleForArc(new GeomAPI_Circ2d(aCenter, aStart)); - data()->blockSendAttributeUpdated(true); + bool aWasBlocked = data()->blockSendAttributeUpdated(true); // The Arc end point is projected // on the circle formed by center and start points std::shared_ptr aProjection = aCircleForArc->project(anEnd); @@ -526,12 +526,12 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) // do not need to inform that other parameters were changed in this basis mode: these arguments // change is enough - data()->blockSendAttributeUpdated(false, false); + data()->blockSendAttributeUpdated(aWasBlocked, false); return; } if (theID == PASSED_POINT_ID()) { - data()->blockSendAttributeUpdated(true); + bool aWasBlocked = data()->blockSendAttributeUpdated(true); std::shared_ptr aPoints[3]; int aNbInitialized = 0; @@ -551,7 +551,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) aCenterAttr->setValue(aCenter); } } - data()->blockSendAttributeUpdated(false); + data()->blockSendAttributeUpdated(aWasBlocked); return; } @@ -569,7 +569,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) data()->attribute(RADIUS_ID())); double aRadius = aRadiusAttr->value(); - data()->blockSendAttributeUpdated(true); + bool aWasBlocked = data()->blockSendAttributeUpdated(true); std::shared_ptr aStartDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy()))); std::shared_ptr @@ -580,7 +580,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) std::shared_ptr aNewEnd = anEndDir->xy()->multiplied(aRadius)->added(aCenter->xy()); anEndAttr->setValue(aNewEnd->x(), aNewEnd->y()); - data()->blockSendAttributeUpdated(false); + data()->blockSendAttributeUpdated(aWasBlocked); return; } if (theID == ANGLE_ID()) { @@ -588,7 +588,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) return; AttributeDoublePtr anAngleAttr = std::dynamic_pointer_cast( data()->attribute(ANGLE_ID())); - data()->blockSendAttributeUpdated(true); + bool aWasBlocked = data()->blockSendAttributeUpdated(true); // move end point and passed point std::shared_ptr aCenter = aCenterAttr->pnt()->xy(); double anAngle = anAngleAttr->value() * PI / 180.0; @@ -599,7 +599,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) aStartDir->x() * cosA - aStartDir->y() * sinA, aStartDir->x() * sinA + aStartDir->y() * cosA)); anEndAttr->setValue(aCenter->x() + aDir->x(), aCenter->y() + aDir->y()); - data()->blockSendAttributeUpdated(false); + data()->blockSendAttributeUpdated(aWasBlocked); return; } } diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index d8b4c8441..435a071cb 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -221,7 +221,7 @@ void SketchPlugin_Circle::attributeChanged(const std::string& theID) { data()->attribute(CIRCLE_TYPE()))->value(); if (aType == CIRCLE_TYPE_CENTER_AND_RADIUS()) return; - data()->blockSendAttributeUpdated(true); // to modify two attributes at once + bool aWasBlocked = data()->blockSendAttributeUpdated(true); // to modify two attributes at once std::shared_ptr aPoints[3]; int aNbInitialized = 0; for (int i = 1; i <= 3; ++i) { @@ -255,7 +255,7 @@ void SketchPlugin_Circle::attributeChanged(const std::string& theID) { aRadiusAttr->setValue(aRadius); } } - data()->blockSendAttributeUpdated(false, false); + data()->blockSendAttributeUpdated(aWasBlocked, false); } else if (theID == CIRCLE_TYPE()) { // if switched to 3 points mode, adjust the needed attributes std::string aType = std::dynamic_pointer_cast( @@ -277,7 +277,7 @@ void SketchPlugin_Circle::adjustThreePoints() if (!aRadiusAttr->isInitialized()) return; - data()->blockSendAttributeUpdated(true); + bool aWasBlocked = data()->blockSendAttributeUpdated(true); std::shared_ptr aFirstPnt = std::dynamic_pointer_cast(attribute(FIRST_POINT_ID())); std::shared_ptr aSecondPnt = @@ -297,5 +297,5 @@ void SketchPlugin_Circle::adjustThreePoints() aSecondPnt->setValue(aCenterAttr->x(), aCenterAttr->y() + aRadius); aThirdPnt->setValue(aCenterAttr->x() - aRadius, aCenterAttr->y()); } - data()->blockSendAttributeUpdated(false, false); + data()->blockSendAttributeUpdated(aWasBlocked, false); } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index 4015ca52a..83fde70e8 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -290,7 +290,7 @@ void SketchPlugin_ConstraintFillet::execute() // update fillet arc: make the arc correct for sure, so, it is not needed to // process the "attribute updated" // by arc; moreover, it may cause cyclicity in hte mechanism of updater - aResultArc->data()->blockSendAttributeUpdated(true); + bool aWasBlocked = aResultArc->data()->blockSendAttributeUpdated(true); std::dynamic_pointer_cast( aResultArc->attribute(SketchPlugin_Arc::CENTER_ID()))->setValue(aCenter->x(), aCenter->y()); if(isReversed) { @@ -310,7 +310,7 @@ void SketchPlugin_ConstraintFillet::execute() } aStartPoint->setValue(aTangentPntA->x(), aTangentPntA->y()); aEndPoint->setValue(aTangentPntB->x(), aTangentPntB->y()); - aResultArc->data()->blockSendAttributeUpdated(false); + aResultArc->data()->blockSendAttributeUpdated(aWasBlocked); aResultArc->execute(); if(anIsNeedNewObjects) { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index 32199abce..b8a7102d9 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -1228,7 +1228,7 @@ FeaturePtr SketchPlugin_ConstraintSplit::createArcFeature(const FeaturePtr& theB // update fillet arc: make the arc correct for sure, so, it is not needed to process // the "attribute updated" // by arc; moreover, it may cause cyclicity in hte mechanism of updater - aFeature->data()->blockSendAttributeUpdated(true); + bool aWasBlocked = aFeature->data()->blockSendAttributeUpdated(true); aFeature->string(SketchPlugin_Arc::ARC_TYPE())->setValue( SketchPlugin_Arc::ARC_TYPE_CENTER_START_END()); @@ -1246,7 +1246,7 @@ FeaturePtr SketchPlugin_ConstraintSplit::createArcFeature(const FeaturePtr& theB bool aReversed = theBaseFeature->boolean(SketchPlugin_Arc::INVERSED_ID())->value(); aFeature->boolean(SketchPlugin_Arc::INVERSED_ID())->setValue(aReversed); } - aFeature->data()->blockSendAttributeUpdated(false); + aFeature->data()->blockSendAttributeUpdated(aWasBlocked); aFeature->execute(); // to obtain result return aFeature; diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp index c708e7028..743d843e4 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp @@ -390,7 +390,7 @@ std::list PlaneGCSSolver_Builder::createMirror( // Do not allow mirrored arc recalculate its position until // coordinated of all points recalculated FeaturePtr aMirrArc = theEntity2->baseFeature(); - aMirrArc->data()->blockSendAttributeUpdated(true); + bool aWasBlocked = aMirrArc->data()->blockSendAttributeUpdated(true); // Make mirror for center and start point of original arc std::list aMrrList; @@ -450,7 +450,7 @@ std::list PlaneGCSSolver_Builder::createMirror( aResult.push_back(aSubResult); // Restore event sending - aMirrArc->data()->blockSendAttributeUpdated(false); + aMirrArc->data()->blockSendAttributeUpdated(aWasBlocked); } return aResult; } diff --git a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp index dbc5b6c89..a86ab8b5f 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp @@ -161,8 +161,9 @@ void SketchSolver_ConstraintMulti::adjustConstraint() continue; anEntity = myStorage->entity(aFeature); + bool aWasBlocked = false; if (!anEntity || !myStorage->isEventsBlocked()) - aFeature->data()->blockSendAttributeUpdated(true); + aWasBlocked = aFeature->data()->blockSendAttributeUpdated(true); std::list aPoints; if (aFeature->getKind() == SketchPlugin_Arc::ID()) { @@ -203,7 +204,7 @@ void SketchSolver_ConstraintMulti::adjustConstraint() } if (!anEntity || !myStorage->isEventsBlocked()) - aFeature->data()->blockSendAttributeUpdated(false); + aFeature->data()->blockSendAttributeUpdated(aWasBlocked); } } diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp index 814987bcc..babba23da 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp @@ -260,7 +260,7 @@ std::list SolveSpaceSolver_Builder::createMirror( // Do not allow mirrored arc recalculate its position until // coordinated of all points recalculated FeaturePtr aMirrArc = theEntity2->baseFeature(); - aMirrArc->data()->blockSendAttributeUpdated(true); + bool aWasBlocked = aMirrArc->data()->blockSendAttributeUpdated(true); std::list aMrrList; std::list::const_iterator anIt1 = theEntity1->subEntities().begin(); @@ -283,7 +283,7 @@ std::list SolveSpaceSolver_Builder::createMirror( aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end()); } // Restore event sending - aMirrArc->data()->blockSendAttributeUpdated(false); + aMirrArc->data()->blockSendAttributeUpdated(aWasBlocked); } return aResult; }