]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3049: Create arc Perpendicular to a straight edge mode - impossible to create...
authorazv <azv@opencascade.com>
Wed, 16 Oct 2019 11:13:50 +0000 (14:13 +0300)
committerazv <azv@opencascade.com>
Wed, 16 Oct 2019 11:28:56 +0000 (14:28 +0300)
src/SketchAPI/SketchAPI_Arc.cpp
src/SketchAPI/SketchAPI_MacroArc.cpp
src/SketchAPI/SketchAPI_MacroArc.h
src/SketchPlugin/SketchPlugin_MacroArc.cpp
src/SketchPlugin/SketchPlugin_MacroArc.h
src/SketchPlugin/plugin-Sketch.xml

index 4f973996c92b0e6732f0275a046e42f8abc84323..d71722b83dd253dafe2ac724d0b97122bec72875 100644 (file)
@@ -29,9 +29,6 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintTangent.h>
 
-/// Obtain constraints prepared by tangent arc
-static std::list<FeaturePtr> tangentArcConstraints(const FeaturePtr& theArc);
-
 //================================================================================================
 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
 : SketchAPI_SketchEntity(theFeature)
index 67dc5f0c768bcb6063d9cb07566d4cfa7aa4542e..ebacfb9d1496ca7f8698302c806205b59e8bc7f2 100644 (file)
@@ -29,9 +29,6 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintTangent.h>
 
-/// Obtain constraints prepared by tangent arc
-static std::list<FeaturePtr> tangentArcConstraints(const FeaturePtr& theArc);
-
 //================================================================================================
 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
 : SketchAPI_SketchEntity(theFeature)
@@ -195,7 +192,7 @@ void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoin
                                  bool theInversed)
 {
   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
-  fillAttribute(theTangentPoint, mytangentPoint);
+  fillAttribute(theTangentPoint, mytransversalPoint);
   fillAttribute(theEnd, myendPoint3);
   fillAttribute(theInversed, myreversed);
 
@@ -208,8 +205,8 @@ void SketchAPI_MacroArc::setByTransversal(const ModelHighAPI_RefAttr& theTransve
                                           bool theInversed)
 {
   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TRANSVERSAL_LINE(), myarcType);
-  fillAttribute(theTransversalPoint, mytangentPoint);
-  fillAttribute(endPoint3(), theEndX, theEndY);
+  fillAttribute(theTransversalPoint, mytransversalPoint);
+  fillAttribute(endPoint4(), theEndX, theEndY);
   fillAttribute(theInversed, myreversed);
 
   execute();
@@ -221,8 +218,8 @@ void SketchAPI_MacroArc::setByTransversal(const ModelHighAPI_RefAttr& theTransve
                                           bool theInversed)
 {
   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TRANSVERSAL_LINE(), myarcType);
-  fillAttribute(theTransversalPoint, mytangentPoint);
-  fillAttribute(theEnd, myendPoint3);
+  fillAttribute(theTransversalPoint, mytransversalPoint);
+  fillAttribute(theEnd, myendPoint4);
   fillAttribute(theInversed, myreversed);
 
   execute();
index 3a6ae556604c73c01c28ae6110ae009519603f15..5ac234cc0ebbcce27225d0b803a503d4442f7214 100644 (file)
@@ -88,7 +88,7 @@ public:
   SKETCHAPI_EXPORT
   virtual ~SketchAPI_MacroArc();
 
-  INTERFACE_12(SketchPlugin_MacroArc::ID(),
+  INTERFACE_14(SketchPlugin_MacroArc::ID(),
                arcType, SketchPlugin_MacroArc::ARC_TYPE(),
                ModelAPI_AttributeString, /** Arc type */,
                center, SketchPlugin_MacroArc::CENTER_POINT_ID(),
@@ -107,6 +107,10 @@ public:
                ModelAPI_AttributeRefAttr, /** Tangent point */,
                endPoint3, SketchPlugin_MacroArc::END_POINT_3_ID(),
                GeomDataAPI_Point2D, /** End point */,
+               transversalPoint, SketchPlugin_MacroArc::TRANSVERSAL_POINT_ID(),
+               ModelAPI_AttributeRefAttr, /** Transversal point */,
+               endPoint4, SketchPlugin_MacroArc::END_POINT_4_ID(),
+               GeomDataAPI_Point2D, /** End point */,
                reversed, SketchPlugin_MacroArc::REVERSED_ID(),
                ModelAPI_AttributeBoolean, /** Reversed flag */,
                radius, SketchPlugin_MacroArc::RADIUS_ID(),
index f0379c4618eac92385f15b151b3f1eaedd048e20..ecd064a088075dc90bfae63f75d5d668602ce888 100644 (file)
@@ -154,6 +154,9 @@ void SketchPlugin_MacroArc::initAttributes()
   data()->addAttribute(TANGENT_POINT_ID(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(END_POINT_3_ID(), GeomDataAPI_Point2D::typeId());
 
+  data()->addAttribute(TRANSVERSAL_POINT_ID(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(END_POINT_4_ID(), GeomDataAPI_Point2D::typeId());
+
   data()->addAttribute(REVERSED_ID(), ModelAPI_AttributeBoolean::typeId());
 
   data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
@@ -196,6 +199,8 @@ void SketchPlugin_MacroArc::attributeChanged(const std::string& theID)
     SketchPlugin_Tools::resetAttribute(this, PASSED_POINT_REF_ID());
     SketchPlugin_Tools::resetAttribute(this, TANGENT_POINT_ID());
     SketchPlugin_Tools::resetAttribute(this, END_POINT_3_ID());
+    SketchPlugin_Tools::resetAttribute(this, TRANSVERSAL_POINT_ID());
+    SketchPlugin_Tools::resetAttribute(this, END_POINT_4_ID());
     SketchPlugin_Tools::resetAttribute(this, REVERSED_ID());
     SketchPlugin_Tools::resetAttribute(this, RADIUS_ID());
     SketchPlugin_Tools::resetAttribute(this, ANGLE_ID());
@@ -344,8 +349,10 @@ void SketchPlugin_MacroArc::execute()
                                          true);
   } else {
     // coincident with connection point
+    const std::string& aPointAttr = anArcType == ARC_TYPE_BY_TANGENT_EDGE() ?
+                                                 TANGENT_POINT_ID() : TRANSVERSAL_POINT_ID();
     SketchPlugin_Tools::createCoincidenceOrTangency(this,
-                                         TANGENT_POINT_ID(),
+                                         aPointAttr,
                                          anArcFeature->attribute(SketchPlugin_Arc::START_ID()),
                                          ObjectPtr(),
                                          false);
@@ -358,7 +365,7 @@ void SketchPlugin_MacroArc::execute()
     // setting attributes of the start point constraint
     AttributeRefAttrPtr aRefAttrA =
         aStartPointConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
-    AttributeRefAttrPtr aTgPntRefAttr = refattr(TANGENT_POINT_ID());
+    AttributeRefAttrPtr aTgPntRefAttr = refattr(aPointAttr);
     FeaturePtr aTgFeature = ModelAPI_Feature::feature(aTgPntRefAttr->attr()->owner());
     aRefAttrA->setObject(aTgFeature->lastResult());
     AttributeRefAttrPtr aRefAttrB =
@@ -398,11 +405,18 @@ std::string SketchPlugin_MacroArc::processEvent(const std::shared_ptr<Events_Mes
     aFilledAttributeName = ARC_TYPE();
     if(anArcType == ARC_TYPE_BY_TANGENT_EDGE()) {
       aFilledAttributeName = TANGENT_POINT_ID();
-      AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                                        attribute(aFilledAttributeName));
+      AttributeRefAttrPtr aRefAttr = refattr(aFilledAttributeName);
       FeaturePtr aCreatedFeature = aReentrantMessage->createdFeature();
       aRefAttr->setAttr(aCreatedFeature->attribute(SketchPlugin_Arc::END_ID()));
     }
+    else if (anArcType == ARC_TYPE_BY_TRANSVERSAL_LINE()) {
+      AttributeRefAttrPtr aRefAttr = refattr(TRANSVERSAL_POINT_ID());
+      AttributePtr anAttribute = aReentrantMessage->selectedAttribute();
+      if (anAttribute) {
+        aRefAttr->setAttr(anAttribute);
+        aFilledAttributeName = TRANSVERSAL_POINT_ID();
+      }
+    }
     else {
       ObjectPtr anObject = aReentrantMessage->selectedObject();
       AttributePtr anAttribute = aReentrantMessage->selectedAttribute();
@@ -609,7 +623,10 @@ void SketchPlugin_MacroArc::recalculateReversedFlagByPassed(
 
 void SketchPlugin_MacroArc::fillByEdge(bool theTransversal)
 {
-  AttributeRefAttrPtr aTangentAttr = refattr(TANGENT_POINT_ID());
+  const std::string& aStartPoint = theTransversal ? TRANSVERSAL_POINT_ID() : TANGENT_POINT_ID();
+  const std::string& aEndPoint = theTransversal ? END_POINT_4_ID() : END_POINT_3_ID();
+
+  AttributeRefAttrPtr aTangentAttr = refattr(aStartPoint);
   if (!aTangentAttr->isInitialized())
     return;
 
@@ -619,7 +636,7 @@ void SketchPlugin_MacroArc::fillByEdge(bool theTransversal)
     return;
 
   AttributePoint2DPtr anEndPointAttr =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(END_POINT_3_ID()));
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(aEndPoint));
   if (!anEndPointAttr->isInitialized())
     return;
 
index 886f6efdcb91b8de25eb0e88f30d254c6ddf47c5..305b89d8a19fcecf64abefceabbbfecb3c64e650 100644 (file)
@@ -132,6 +132,13 @@ class SketchPlugin_MacroArc: public SketchPlugin_SketchEntity,
     return ID;
   }
 
+  /// End 2D point of the arc
+  inline static const std::string& END_POINT_4_ID()
+  {
+    static const std::string ID = "end_point_4";
+    return ID;
+  }
+
   inline static const std::string& END_POINT_REF_ID()
   {
     static const std::string ID = "end_point_ref";
@@ -157,6 +164,12 @@ class SketchPlugin_MacroArc: public SketchPlugin_SketchEntity,
     return ID;
   }
 
+  static const std::string& TRANSVERSAL_POINT_ID()
+  {
+    static const std::string ID("transversal_point");
+    return ID;
+  }
+
   /// Reversed flag
   inline static const std::string& REVERSED_ID()
   {
index 1476a14926570dc655e341a8be0bb9b4a7d2b8ad..eef35764893f6b9a8407b37b0b0262a9f1d89fe4 100644 (file)
           <box id="by_transversal_line"
                icon="icons/Sketch/arc_perp_32x32.png"
                title="Perpendicular to line">
-            <sketch_shape_selector id="tangent_point"
+            <sketch_shape_selector id="transversal_point"
                                    label="Point on the perpendicular line"
                                    tooltip="Select point on line"
                                    shape_types="vertex">
               <validator id="SketchPlugin_ArcTransversalPoint"/>
             </sketch_shape_selector>
-            <sketch-2dpoint_selector id="end_point_3"
+            <sketch-2dpoint_selector id="end_point_4"
                                      reference_attribute="end_point_ref"
                                      title="End point"
                                      tooltip="End point"