From fd4b86bffa594a53b7722eda8fdcd96d4f7ddf57 Mon Sep 17 00:00:00 2001 From: asozinov Date: Fri, 3 Nov 2023 14:54:10 +0000 Subject: [PATCH] for squash --- src/SketchAPI/SketchAPI_MacroCircle.cpp | 28 +++------------ src/SketchPlugin/SketchPlugin_Circle.cpp | 36 ++++++++++++++++--- src/SketchPlugin/SketchPlugin_MacroCircle.cpp | 17 ++++----- src/SketchPlugin/SketchPlugin_MacroCircle.h | 8 ----- src/SketchPlugin/plugin-Sketch.xml | 19 ---------- 5 files changed, 42 insertions(+), 66 deletions(-) diff --git a/src/SketchAPI/SketchAPI_MacroCircle.cpp b/src/SketchAPI/SketchAPI_MacroCircle.cpp index 640893214..05477033b 100644 --- a/src/SketchAPI/SketchAPI_MacroCircle.cpp +++ b/src/SketchAPI/SketchAPI_MacroCircle.cpp @@ -103,12 +103,7 @@ void SketchAPI_MacroCircle::setByCenterAndPassedPoints(double theCenterX, fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType); fillAttribute(centerPoint(), theCenterX, theCenterY); fillAttribute(passedPoint(), thePassedX, thePassedY); - - bool isNeedPoint = - feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0; - - if (isNeedPoint) - fillAttribute(theAngle, angle()); + fillAttribute(theAngle, angle()); execute(); } @@ -122,12 +117,7 @@ void SketchAPI_MacroCircle::setByCenterAndPassedPoints( fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType); fillAttribute(theCenterPoint, mycenterPoint); fillAttribute(thePassedPoint, mypassedPoint); - - bool isNeedPoint = - feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0; - - if (isNeedPoint) - fillAttribute(theAngle, angle()); + fillAttribute(theAngle, angle()); execute(); } @@ -142,12 +132,7 @@ void SketchAPI_MacroCircle::setByThreePoints(double theX1, double theY1, fillAttribute(firstPoint(), theX1, theY1); fillAttribute(secondPoint(), theX2, theY2); fillAttribute(thirdPoint(), theX3, theY3); - - bool isNeedPoint = - feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0; - - if (isNeedPoint) - fillAttribute(theAngle, angle()); + fillAttribute(theAngle, angle()); execute(); } @@ -162,12 +147,7 @@ void SketchAPI_MacroCircle::setByThreePoints(const std::shared_ptrinteger(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0; - - if (isNeedPoint) - fillAttribute(theAngle, angle()); + fillAttribute(theAngle, angle()); execute(); } diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index ad29a71fb..ca1059f55 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -70,24 +70,38 @@ void SketchPlugin_Circle::initDerivedClassAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ANGLE_ID()); } +/*static FeaturePtr CreatePoint(FeaturePtr theCircleFeature, SketchPlugin_Sketch* theSketch, + GeomPnt2dPtr thePoint) +{ + // create point at sewing point of circle + FeaturePtr aPointFeature = theSketch->addFeature(SketchPlugin_Point::ID()); + aPointFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theCircleFeature); + + AttributePoint2DPtr aCoord = std::dynamic_pointer_cast( + aPointFeature->attribute(SketchPlugin_Point::COORD_ID())); + aCoord->setValue(thePoint); + aPointFeature->execute(); + return aPointFeature; +}*/ + void SketchPlugin_Circle::execute() { SketchPlugin_Sketch* aSketch = sketch(); - if(!aSketch) { + if (!aSketch) { return; } // Compute a circle in 3D view. std::shared_ptr aCenterAttr = - std::dynamic_pointer_cast(data()->attribute(CENTER_ID())); + std::dynamic_pointer_cast(data()->attribute(CENTER_ID())); AttributeDoublePtr aRadiusAttr = real(RADIUS_ID()); AttributeDoublePtr anAngleAttr = real(ANGLE_ID()); - if(!aCenterAttr->isInitialized() || !aRadiusAttr->isInitialized()) { + if (!aCenterAttr->isInitialized() || !aRadiusAttr->isInitialized()) { return; } double aRadius = aRadiusAttr->value(); - if(aRadius < tolerance) { + if (aRadius < tolerance) { return; } @@ -100,7 +114,7 @@ void SketchPlugin_Circle::execute() // Make a visible circle. std::shared_ptr aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y())); std::shared_ptr aNDir = std::dynamic_pointer_cast( - aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); std::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); double aValAn = anAngleAttr->value(); @@ -117,6 +131,18 @@ void SketchPlugin_Circle::execute() aResult->setShape(aCircleShape); aResult->setIsInHistory(false); setResult(aResult, 1); + + /*if (!reference(ROTATE_REF_ID())->value()) + { + aWasBlocked = data()->blockSendAttributeUpdated(true); + auto aCurCircle = this->document()->currentFeature(true); + auto aCrPoint = CreatePoint(aCurCircle, sketch(), std::dynamic_pointer_cast(data()->attribute(ROTATE_ID()))->pnt()); + SketchPlugin_Tools::createConstraintAttrAttr(sketch(), SketchPlugin_ConstraintCoincidenceInternal::ID(), + attribute(SketchPlugin_Circle::ROTATE_ID()), std::dynamic_pointer_cast(aCrPoint->attribute(SketchPlugin_Point::COORD_ID()))); + aCrPoint->boolean(AUXILIARY_ID())->setValue(boolean(AUXILIARY_ID())->value()); + reference(SketchPlugin_Circle::ROTATE_REF_ID())->setValue(aCrPoint); + data()->blockSendAttributeUpdated(aWasBlocked, false); + }*/ } bool SketchPlugin_Circle::isFixed() { diff --git a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp index 97afaa9c0..3cc52b32c 100644 --- a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp @@ -112,12 +112,6 @@ void SketchPlugin_MacroCircle::initAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), THIRD_POINT_REF_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EDIT_CIRCLE_TYPE()); - // While exist addCircle without creating point. - AttributeIntegerPtr aVerAttr = std::dynamic_pointer_cast( - data()->addAttribute(VERSION_ID(), ModelAPI_AttributeInteger::typeId())); - aVerAttr->setIsArgument(false); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID()); - string(EDIT_CIRCLE_TYPE())->setValue(""); } @@ -530,13 +524,12 @@ void SketchPlugin_MacroCircle::attributeChanged(const std::string& theID) { SketchPlugin_Tools::resetAttribute(this, THIRD_POINT_ID()); SketchPlugin_Tools::resetAttribute(this, THIRD_POINT_REF_ID()); } else if(theID == CENTER_POINT_ID() || theID == PASSED_POINT_ID() || - theID == CENTER_POINT_REF_ID() || theID == PASSED_POINT_REF_ID() || - isRotPoint(theID, string(CIRCLE_TYPE())->value(), CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS())) + theID == CENTER_POINT_REF_ID() || theID == PASSED_POINT_REF_ID()) fillByCenterAndPassed(); else if(theID == FIRST_POINT_ID() || theID == FIRST_POINT_REF_ID() || theID == SECOND_POINT_ID() || theID == SECOND_POINT_REF_ID() || - theID == THIRD_POINT_ID() || theID == THIRD_POINT_REF_ID() || - isRotPoint(theID, string(CIRCLE_TYPE())->value(), CIRCLE_TYPE_BY_THREE_POINTS())) { + theID == THIRD_POINT_ID() || theID == THIRD_POINT_REF_ID()) + { std::shared_ptr aPoints[3]; int aNbInitialized = 0; for(int i = 1; i <= 3; ++i) { @@ -569,6 +562,10 @@ void SketchPlugin_MacroCircle::attributeChanged(const std::string& theID) { AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast(attribute(ROTATE_POINT_ID())); aPointAttr->setValue(myRotPoint); } + else if (aCircle) + { + computeNewAngle(aCircle); + } if (anAngleAttr->isInitialized()) anAngleAttr->setValue(myAngle); diff --git a/src/SketchPlugin/SketchPlugin_MacroCircle.h b/src/SketchPlugin/SketchPlugin_MacroCircle.h index d5b45c59f..afadafcb5 100644 --- a/src/SketchPlugin/SketchPlugin_MacroCircle.h +++ b/src/SketchPlugin/SketchPlugin_MacroCircle.h @@ -170,14 +170,6 @@ class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity, return ID; } - /// Attribute name of the version of Circle feature - /// Need for compability with old way of creating circle - inline static const std::string& VERSION_ID() - { - static const std::string MY_VERSION_ID("version"); - return MY_VERSION_ID; - } - /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() { diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index ab5488d0a..bdd6262c2 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -65,11 +65,6 @@ tooltip="Center coordinates" accept_expressions="0" enable_value="enable_by_preferences"/> - - - - -