]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
for squash
authorasozinov <alexey.sozinov@opencascade.com>
Fri, 3 Nov 2023 14:54:10 +0000 (14:54 +0000)
committerasozinov <alexey.sozinov@opencascade.com>
Fri, 3 Nov 2023 14:54:10 +0000 (14:54 +0000)
src/SketchAPI/SketchAPI_MacroCircle.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_MacroCircle.cpp
src/SketchPlugin/SketchPlugin_MacroCircle.h
src/SketchPlugin/plugin-Sketch.xml

index 64089321421253a697f567044c716a66cd0c904c..05477033bd1ea5c1535441fa5a089a17e3e8a411 100644 (file)
@@ -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_ptr<GeomAPI_Pnt2d
   fillAttribute(thePoint1, myfirstPoint);
   fillAttribute(thePoint2, mysecondPoint);
   fillAttribute(thePoint3, mythirdPoint);
-
-  bool isNeedPoint =
-    feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
-
-  if (isNeedPoint)
-    fillAttribute(theAngle, angle());
+  fillAttribute(theAngle, angle());
 
   execute();
 }
index ad29a71fb3eaf93e6388ffbca80112035d37f6e5..ca1059f554e91cc9cb133ea230fd16cc5c6e93b1 100644 (file)
@@ -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<GeomDataAPI_Point2D>(
+    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<GeomDataAPI_Point2D> aCenterAttr =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CENTER_ID()));
+    std::dynamic_pointer_cast<GeomDataAPI_Point2D>(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<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
   std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+    aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
   std::shared_ptr<GeomAPI_Dir> 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<GeomDataAPI_Point2D>(data()->attribute(ROTATE_ID()))->pnt());
+    SketchPlugin_Tools::createConstraintAttrAttr(sketch(), SketchPlugin_ConstraintCoincidenceInternal::ID(),
+      attribute(SketchPlugin_Circle::ROTATE_ID()), std::dynamic_pointer_cast<GeomDataAPI_Point2D>(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() {
index 97afaa9c0511958d47d8f9d03f5eb3d9f7807630..3cc52b32cd0d5cd9ec52b274cc83620955181ca0 100644 (file)
@@ -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<ModelAPI_AttributeInteger>(
-    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<GeomAPI_Pnt2d> 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<GeomDataAPI_Point2D>(attribute(ROTATE_POINT_ID()));
     aPointAttr->setValue(myRotPoint);
   }
+  else if (aCircle)
+  {
+    computeNewAngle(aCircle);
+  }
 
   if (anAngleAttr->isInitialized())
     anAngleAttr->setValue(myAngle);
index d5b45c59f738152d187c5f5234b76360f65c010d..afadafcb51b916ece8a42f15f995c9b409c81fc9 100644 (file)
@@ -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()
   {
index ab5488d0a4b0dabfe2a6023674fb4b915453da26..bdd6262c2c625003ad76eba6e5495d9aa1510771 100644 (file)
                                  tooltip="Center coordinates"
                                  accept_expressions="0"
                                  enable_value="enable_by_preferences"/>
-        <sketch-2dpoint_selector id="circle_rotate"
-                                 title="Rotate"
-                                 tooltip="Rotate coordinates"
-                                 accept_expressions="0"
-                                 enable_value="enable_by_preferences"/>
         <labelvalue id="circle_radius"
                     icon="icons/Sketch/radius.png"
                     label="Radius"
                                      enable_value="enable_by_preferences">
               <validator id="SketchPlugin_CirclePassedPointValidator"/>
             </sketch-2dpoint_selector>
-            <sketch-2dpoint_selector id="rotate_point"
-                                      reference_attribute="rotate_point_ref"
-                                      title="Rotate point"
-                                      tooltip="Rotate point coordinates"
-                                      accept_expressions="0"
-                                      enable_value="enable_by_preferences"/>
             <validator id="GeomValidators_Different" parameters="center_point_ref,passed_point_ref"/>
-            <validator id="GeomValidators_Different" parameters="center_point_ref,rotate_point_ref"/>
           </box>
           <box id="circle_type_by_three_points"
                icon="icons/Sketch/circle_3pt_32x32.png"
               <validator id="SketchPlugin_DifferentReference" parameters="first_point_ref,second_point_ref,third_point_ref"/>
               <validator id="SketchPlugin_ThirdPointValidator" parameters="third_point_ref"/>
             </sketch-2dpoint_selector>
-            <sketch-2dpoint_selector id="rotate_point"
-                                      reference_attribute="rotate_point_ref"
-                                      title="Rotate point"
-                                      tooltip="Rotate point coordinates"
-                                      accept_expressions="0"
-                                      enable_value="enable_by_preferences"/>
-            <validator id="GeomValidators_Different" parameters="first_point_ref,second_point_ref,third_point_ref"/>
           </box>
         </toolbox>
         <labelvalue id="circle_radius"