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.
}
}
-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()) {
}
}
}
+ return aWasBlocked;
}
void Model_Data::erase()
/// \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
/// 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
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);
// 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.
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();
// 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);
}
/// 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
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(
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<ParametersPlugin_Parameter> aParameter =
std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
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(
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
/// 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
if (!aData->isValid())
return;
- aData->blockSendAttributeUpdated(true);
+ bool aWasBlocked = aData->blockSendAttributeUpdated(true);
myStartUpdate = true;
myEndUpdate = true;
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(PASSED_POINT_ID()));
if (aPassedPoint->isInitialized())
aPassedPoint->move(theDeltaX, theDeltaY);
- aData->blockSendAttributeUpdated(false);
+ aData->blockSendAttributeUpdated(aWasBlocked);
}
bool SketchPlugin_Arc::isFixed() {
std::shared_ptr<GeomAPI_Lin2d> aMiddleLine(new GeomAPI_Lin2d(aMidPnt, aMidDir));
std::shared_ptr<GeomAPI_Pnt2d> 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();
return;
std::shared_ptr<GeomAPI_Circ2d> 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<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEnd);
// 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<GeomAPI_Pnt2d> aPoints[3];
int aNbInitialized = 0;
aCenterAttr->setValue(aCenter);
}
}
- data()->blockSendAttributeUpdated(false);
+ data()->blockSendAttributeUpdated(aWasBlocked);
return;
}
data()->attribute(RADIUS_ID()));
double aRadius = aRadiusAttr->value();
- data()->blockSendAttributeUpdated(true);
+ bool aWasBlocked = data()->blockSendAttributeUpdated(true);
std::shared_ptr<GeomAPI_Dir2d>
aStartDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy())));
std::shared_ptr<GeomAPI_XY>
std::shared_ptr<GeomAPI_XY>
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()) {
return;
AttributeDoublePtr anAngleAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
data()->attribute(ANGLE_ID()));
- data()->blockSendAttributeUpdated(true);
+ bool aWasBlocked = data()->blockSendAttributeUpdated(true);
// move end point and passed point
std::shared_ptr<GeomAPI_XY> aCenter = aCenterAttr->pnt()->xy();
double anAngle = anAngleAttr->value() * PI / 180.0;
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;
}
}
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<GeomAPI_Pnt2d> aPoints[3];
int aNbInitialized = 0;
for (int i = 1; i <= 3; ++i) {
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<ModelAPI_AttributeString>(
if (!aRadiusAttr->isInitialized())
return;
- data()->blockSendAttributeUpdated(true);
+ bool aWasBlocked = data()->blockSendAttributeUpdated(true);
std::shared_ptr<GeomDataAPI_Point2D> aFirstPnt =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(FIRST_POINT_ID()));
std::shared_ptr<GeomDataAPI_Point2D> aSecondPnt =
aSecondPnt->setValue(aCenterAttr->x(), aCenterAttr->y() + aRadius);
aThirdPnt->setValue(aCenterAttr->x() - aRadius, aCenterAttr->y());
}
- data()->blockSendAttributeUpdated(false, false);
+ data()->blockSendAttributeUpdated(aWasBlocked, false);
}
// 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<GeomDataAPI_Point2D>(
aResultArc->attribute(SketchPlugin_Arc::CENTER_ID()))->setValue(aCenter->x(), aCenter->y());
if(isReversed) {
}
aStartPoint->setValue(aTangentPntA->x(), aTangentPntA->y());
aEndPoint->setValue(aTangentPntB->x(), aTangentPntB->y());
- aResultArc->data()->blockSendAttributeUpdated(false);
+ aResultArc->data()->blockSendAttributeUpdated(aWasBlocked);
aResultArc->execute();
if(anIsNeedNewObjects) {
// 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());
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;
// 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<ConstraintWrapperPtr> aMrrList;
aResult.push_back(aSubResult);
// Restore event sending
- aMirrArc->data()->blockSendAttributeUpdated(false);
+ aMirrArc->data()->blockSendAttributeUpdated(aWasBlocked);
}
return aResult;
}
continue;
anEntity = myStorage->entity(aFeature);
+ bool aWasBlocked = false;
if (!anEntity || !myStorage->isEventsBlocked())
- aFeature->data()->blockSendAttributeUpdated(true);
+ aWasBlocked = aFeature->data()->blockSendAttributeUpdated(true);
std::list<AttributePtr> aPoints;
if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
}
if (!anEntity || !myStorage->isEventsBlocked())
- aFeature->data()->blockSendAttributeUpdated(false);
+ aFeature->data()->blockSendAttributeUpdated(aWasBlocked);
}
}
// 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<ConstraintWrapperPtr> aMrrList;
std::list<EntityWrapperPtr>::const_iterator anIt1 = theEntity1->subEntities().begin();
aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end());
}
// Restore event sending
- aMirrArc->data()->blockSendAttributeUpdated(false);
+ aMirrArc->data()->blockSendAttributeUpdated(aWasBlocked);
}
return aResult;
}