Salome HOME
Meet the coding style (line length <= 100)
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroCircle.h
index 4ea0ecc50262dc3b15accd2d5e8083a2be4567f7..4e1bfeb22e049df6f5d63c5efa375095abccd5ab 100644 (file)
@@ -7,20 +7,24 @@
 #ifndef SketchPlugin_MacroCircle_H_
 #define SketchPlugin_MacroCircle_H_
 
+#include <ModelAPI_IReentrant.h>
+
 #include "SketchPlugin.h"
 
-#include "SketchPlugin_Sketch.h"
 #include "SketchPlugin_SketchEntity.h"
 
 #include <GeomAPI_IPresentable.h>
-#include <GeomAPI_Pnt2d.h>
+
+class GeomAPI_Circ2d;
+class GeomAPI_Pnt2d;
 
 /**\class SketchPlugin_MacroCircle
  * \ingroup Plugins
  * \brief Feature for creation of the new circle in Sketch.
  */
 class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
-                                public GeomAPI_IPresentable
+                                public GeomAPI_IPresentable,
+                                public ModelAPI_IReentrant
 {
  public:
   /// Circle feature kind
@@ -36,6 +40,12 @@ class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
     return ID;
   }
 
+  inline static const std::string& EDIT_CIRCLE_TYPE()
+  {
+    static const std::string ID("edit_circle_type");
+    return ID;
+  }
+
   /// Creation method by center and passed point.
   inline static const std::string& CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()
   {
@@ -85,6 +95,13 @@ class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
     return ID;
   }
 
+  /// Reference for first point selection.
+  inline static const std::string& FIRST_POINT_REF_ID()
+  {
+    static const std::string ID("first_point_ref");
+    return ID;
+  }
+
   /// Second point id.
   inline static const std::string& SECOND_POINT_ID()
   {
@@ -92,6 +109,13 @@ class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
     return ID;
   }
 
+  /// Reference for second point selection.
+  inline static const std::string& SECOND_POINT_REF_ID()
+  {
+    static const std::string ID("second_point_ref");
+    return ID;
+  }
+
   /// Third point id.
   inline static const std::string& THIRD_POINT_ID()
   {
@@ -99,6 +123,13 @@ class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
     return ID;
   }
 
+  /// Reference for third point selection.
+  inline static const std::string& THIRD_POINT_REF_ID()
+  {
+    static const std::string ID("third_point_ref");
+    return ID;
+  }
+
   /// Radius of the circle
   inline static const std::string& CIRCLE_RADIUS_ID()
   {
@@ -137,15 +168,27 @@ class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
 
   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
 
+  /// Apply information of the message to current object. It fills reference object,
+  /// tangent type and tangent point refence in case of tangent arc
+  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
   /// Use plugin manager for features creation
   SketchPlugin_MacroCircle();
 
 private:
-  void resetAttribute(const std::string& theId);
+  void fillByCenterAndPassed();
+  void fillByThreePoints();
+  /// set fields if only two of three points is initialized
+  void fillByTwoPassedPoints();
+
+  void constraintsForCircleByCenterAndPassed(FeaturePtr theCircleFeature);
+  void constraintsForCircleByThreePoints(FeaturePtr theCircleFeature);
+
+  FeaturePtr createCircleFeature();
 
 private:
   std::shared_ptr<GeomAPI_Pnt2d> myCenter;
-  double myRadius;
+  double                         myRadius;
 };
 
 #endif