From a3e94a57c0572d75add6f80d7fc31731bf80c774 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 16 Feb 2015 17:21:27 +0300 Subject: [PATCH] Issue #394 Undo-ing a Sketch element the flyout value should to be computed here, not in the getAISObject in order to change the model value inside the object transaction. This is important for creating a constraint by preselection. The display of the presentation in this case happens after the transaction commit --- src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp | 10 +++++++++- src/SketchPlugin/SketchPlugin_ConstraintLength.cpp | 11 +++++++++-- src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp | 10 +++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index b8ce8c182..db309bae3 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -45,6 +45,14 @@ void SketchPlugin_ConstraintDistance::execute() if(aDistance >= 0) { anAttrValue->setValue(aDistance); } + + // the value should to be computed here, not in the getAISObject in order to change the model value + // inside the object transaction. This is important for creating a constraint by preselection. + // The display of the presentation in this case happens after the transaction commit + std::shared_ptr aFlyOutAttr = std::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + if(!aFlyOutAttr->isInitialized()) + compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); } bool SketchPlugin_ConstraintDistance::compute(const std::string& theAttributeId) @@ -142,7 +150,7 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi std::shared_ptr aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y()); std::shared_ptr aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y()); if(!aFlyOutAttr->isInitialized()) - compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); + return AISObjectPtr(); std::shared_ptr aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()/*aFPnt->x(), aFPnt->y()*/); // value calculation diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index ea50c3850..f0ac2e41d 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -50,6 +50,14 @@ void SketchPlugin_ConstraintLength::execute() //if(!aValueAttr->isInitialized()) { // aValueAttr->setValue(aLenght); //} + + // the value should to be computed here, not in the getAISObject in order to change the model value + // inside the object transaction. This is important for creating a constraint by preselection. + // The display of the presentation in this case happens after the transaction commit + AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); + if (!aFlyOutAttribute->isInitialized()) { + compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); + } } } @@ -109,8 +117,7 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); if (!aFlyOutAttribute->isInitialized()) { - if (!compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())) - return thePrevious; // not possible to show length because points are not defined + return thePrevious; // not possible to show length because points are not defined } std::shared_ptr aFlyOutAttr = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(aFlyOutAttribute); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index 0a2115dbc..17e16655a 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -60,6 +60,14 @@ void SketchPlugin_ConstraintRadius::execute() //if(!aValueAttr->isInitialized()) { // aValueAttr->setValue(aRadius); //} + + // the value should to be computed here, not in the getAISObject in order to change the model value + // inside the object transaction. This is important for creating a constraint by preselection. + // The display of the presentation in this case happens after the transaction commit + std::shared_ptr aFlyoutAttr = std::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + if (!aFlyoutAttr->isInitialized()) + compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); } } @@ -135,7 +143,7 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou // Flyout point std::shared_ptr aFlyoutAttr = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); - if (!aFlyoutAttr->isInitialized() && !compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())) + if (!aFlyoutAttr->isInitialized()) return thePrevious; // can not create a good presentation std::shared_ptr aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y()); -- 2.39.2