Salome HOME
Merge commit 'f709219506b7cd587e94abc5ebed18d629df92d8'
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Projection.h
index b928dfabdd5c577428685e3805da92641c5e0b56..21d8e0d47b110d198a3f2e7af4a038bb7f7886ce 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,8 @@
 
 #include "SketchPlugin_SketchEntity.h"
 
+class GeomAPI_Curve;
+
 /** \class SketchPlugin_Projection
  *  \ingroup Plugins
  *  \brief Feature for creation of external feature as a projection onto the sketch plane.
@@ -60,6 +62,24 @@ public:
     return MY_INCLUDE;
   }
 
+  static const std::string& KEEP_REFERENCE_ID()
+  {
+    static std::string ID("keep_reference");
+    return ID;
+  }
+
+  static const std::string& MAKE_FIXED()
+  {
+    static std::string ID("make_fixed");
+    return ID;
+  }
+
+  static const std::string& FIXED_CONSTRAINT_ID()
+  {
+    static std::string ID("fixed_constraint");
+    return ID;
+  }
+
   /// Returns true because projected feature is always external
   virtual bool isFixed()
   { return true; }
@@ -77,6 +97,11 @@ public:
   /// Called on change of any argument-attribute of this object: for external point
   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
+  /// Returns true if this feature is used as macro: creates other features and then removed.
+  /// This feature may change its macro-state according to selected item.
+  /// \returns false by default
+  SKETCHPLUGIN_EXPORT virtual bool isMacro() const;
+
   /// Use plugin manager for features creation
   SketchPlugin_Projection();
 
@@ -84,10 +109,53 @@ protected:
   /// \brief Initializes attributes of derived class.
   virtual void initDerivedClassAttributes();
 
+  /// \brief Initializes attributes of keeping the reference to the original shape.
+  virtual void initDerivedClassAttributes2();
+
 private:
   /// \brief Find projection of a feature onto sketch plane
   void computeProjection(const std::string& theID);
 
+  /// \brief Project point to the sketch plane
+  bool projectPoint(FeaturePtr& theProjection, const std::shared_ptr<GeomAPI_Pnt>& thePoint);
+  /// \brief Project segment to the sketch plane
+  bool projectSegment(FeaturePtr& theProjection, const std::shared_ptr<GeomAPI_Edge>& theEdge);
+  /// \brief Project any edge to sketch plane
+  bool projectEdge(FeaturePtr& theProjection, const std::shared_ptr<GeomAPI_Edge>& theEdge);
+
+  /// \brief Fill attributes of the Arc feature
+  bool fillArc(FeaturePtr& theProjection,
+               const std::shared_ptr<GeomAPI_Curve>& theArc,
+               const std::shared_ptr<GeomAPI_Pln>& thePlane,
+               const std::shared_ptr<GeomAPI_Edge>& theOriginalEdge);
+  /// \brief Fill attributes of the Circle feature
+  bool fillCircle(FeaturePtr& theProjection,
+                  const std::shared_ptr<GeomAPI_Curve>& theCircle,
+                  const std::shared_ptr<GeomAPI_Pln>& thePlane);
+  /// \brief Fill attributes of the Ellipse feature
+  bool fillEllipse(FeaturePtr& theProjection,
+                   const std::shared_ptr<GeomAPI_Curve>& theEllipse,
+                   const std::shared_ptr<GeomAPI_Pln>& thePlane);
+  /// \brief Fill attributes of the EllipticArc feature
+  bool fillEllipticArc(FeaturePtr& theProjection,
+                       const std::shared_ptr<GeomAPI_Curve>& theEllipticArc,
+                       const std::shared_ptr<GeomAPI_Pln>& thePlane,
+                       const std::shared_ptr<GeomAPI_Edge>& theOriginalEdge);
+  /// \brief Fill attributes of the B-spline feature
+  bool fillBSpline(FeaturePtr& theProjection,
+                   const std::shared_ptr<GeomAPI_Curve>& theCurve,
+                   const std::shared_ptr<GeomAPI_Pln>& thePlane);
+
+  /// \brief Delete already calculated projected feature
+  ///        if the selection of the projection is changed
+  /// \param[in/out] theProjection   projected feature
+  /// \param[in] theSupportedTypes   types supported relatively to the base selection
+  /// \param[in] theRequestedFeature type of the new feature to be created
+  ///                                (remove only if empty string).
+  bool rebuildProjectedFeature(FeaturePtr& theProjection,
+                               const std::set<std::string>& theSupportedTypes,
+                               const std::string& theRequestedFeature = std::string());
+
   bool myIsComputing;
 };