From 0384b535af5605c8add66b61726912287e28313f Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 26 Apr 2016 18:16:54 +0300 Subject: [PATCH] Issue #1448 problem with saved study and visualization of distance: activate of the part leads to circling: multi translation tries to move external copied line --- src/SketchPlugin/SketchPlugin_Arc.cpp | 9 +++++---- src/SketchPlugin/SketchPlugin_Line.cpp | 4 +++- src/SketchPlugin/SketchPlugin_Sketch.cpp | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index d8803e90a..18380c7ec 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -353,7 +353,7 @@ static inline void calculateArcAngleRadius( theRadiusAttr->setValue(theCircle->radius()); } -static inline void calculatePassedPoint( +static inline bool calculatePassedPoint( const std::shared_ptr& theCenter, const std::shared_ptr& theStartPoint, const std::shared_ptr& theEndPoint, @@ -362,7 +362,7 @@ static inline void calculatePassedPoint( { if (theCenter->distance(theStartPoint) < tolerance || theCenter->distance(theEndPoint) < tolerance) - return; + return false; std::shared_ptr aStartDir(new GeomAPI_Dir2d( theStartPoint->xy()->decreased(theCenter->xy()))); @@ -381,6 +381,7 @@ static inline void calculatePassedPoint( double aRadius = theCenter->distance(theStartPoint); std::shared_ptr aPassedPnt = theCenter->xy()->added( aMidDir->xy()->multiplied(aRadius) ); thePassedPoint->setValue(aPassedPnt->x(), aPassedPnt->y()); + return true; } void SketchPlugin_Arc::updateDependentAttributes() @@ -403,9 +404,9 @@ void SketchPlugin_Arc::updateDependentAttributes() data()->blockSendAttributeUpdated(true); - calculatePassedPoint(aCenterAttr->pnt(), aStartAttr->pnt(), anEndAttr->pnt(), + bool isOk = calculatePassedPoint(aCenterAttr->pnt(), aStartAttr->pnt(), anEndAttr->pnt(), isReversed(), aPassedPoint); - if (aRadiusAttr && anAngleAttr) { + if (isOk && aRadiusAttr && anAngleAttr) { std::shared_ptr aCircle( new GeomAPI_Circ2d(aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt())); if (aCircle->implPtr()) diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 33d087d2c..c69b6019b 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -110,7 +110,9 @@ bool SketchPlugin_Line::isFixed() { void SketchPlugin_Line::attributeChanged(const std::string& theID) { // the second condition for unability to move external segments anywhere - if (theID == EXTERNAL_ID() || isFixed()) { + // isCopy() is checked temporary for case when copied lines stored external id state + // to be removed after debug + if ((theID == EXTERNAL_ID() || isFixed()) && !isCopy()) { std::shared_ptr aSelection = data()->selection(EXTERNAL_ID())->value(); // update arguments due to the selection value if (aSelection && !aSelection->isNull() && aSelection->isEdge()) { diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 053957cc5..ac94b5dd1 100755 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -290,7 +290,9 @@ FeaturePtr SketchPlugin_Sketch::addUniqueNamedCopiedFeature(FeaturePtr theFeatur std::string aUniqueFeatureName = aNewFeature->data()->name(); // all attribute values are copied\pasted to the new feature, name is not an exception theFeature->data()->copyTo(aNewFeature->data()); - // as a name for the feature, the generated unique name is set + // external state should not be copied as a new object is an object of the current sketch + if (theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID()).get()) + theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->setValue(NULL, NULL); aNewFeature->data()->setName(aUniqueFeatureName); // text expressions could block setValue of some attributes SketchPlugin_Tools::clearExpressions(aNewFeature); -- 2.39.2