Salome HOME
Issue #3231: Provide presentation for offset operation
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Offset.h
index 19fff782accf8e77085ebf99c8f5c377595b38a2..7ed4e379494fdbe3a0bb66c793f0a7da8d45c202 100644 (file)
 #include <SketchPlugin.h>
 #include <SketchPlugin_SketchEntity.h>
 
+#include <GeomDataAPI_Point2D.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_IPresentable.h>
+
 /**\class SketchPlugin_Offset
  * \ingroup Plugins
  * \brief Builds offset curves in the sketch.
  */
-class SketchPlugin_Offset : public SketchPlugin_SketchEntity
+class SketchPlugin_Offset : public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
 {
 public:
   /// Offset macro feature kind
@@ -80,9 +85,10 @@ public:
 
   /// Reimplemented from ModelAPI_Feature::isMacro().
   /// \returns true
-  SKETCHPLUGIN_EXPORT virtual bool isMacro() const { return true; }
+  //SKETCHPLUGIN_EXPORT virtual bool isMacro() const { return false; }
 
-  SKETCHPLUGIN_EXPORT virtual bool isPreviesNeeded() const { return false; }
+  //SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
+  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return true; }
 
   /// Find edges connected by coincident boundary constraint and composing a wire with
   /// the already selected segments. It means that not more than 2 edges can be connected
@@ -91,7 +97,10 @@ public:
   /// \return \c false in case the action not performed.
   SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
 
-  /// Use plugin manager for features creatio
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+
+  /// Use plugin manager for features creation.
   SketchPlugin_Offset();
 
 protected:
@@ -101,6 +110,30 @@ protected:
 private:
   /// Find all wires connected with the selected edges
   bool findWires();
+
+  // Create sketch feature for each edge of theOffsetResult,
+  // and store it in myCreatedFeatures to remove on next execute()
+  void addToSketch (const std::shared_ptr<GeomAPI_Shape>& theOffsetResult);
+
+  // Create BSpline or BSplinePeriodic sketch feature from theEdge
+  void mkBSpline (FeaturePtr& theResult, const GeomEdgePtr& theEdge);
+
+  // Find edges that prolongate theEdgeFeature (in a chain) at theEndPoint
+  // Recursive method.
+  // \param[in] theFirstEdge Start edge of wire searching
+  // \param[in] theEdge Current edge
+  // \param[in] theEndPoint Point of the Current edge, not belonging to a previous edge
+  // \param[in/out] theEdgesSet All edges to find among. If empty, all sketch edges assumed.
+  // \param[in/out] theChain Resulting edges
+  /// \return \c true if the chain is closed
+  bool findWireOneWay (const FeaturePtr& theFirstEdge,
+                       const FeaturePtr& theEdge,
+                       const std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint,
+                       std::set<FeaturePtr>& theEdgesSet,
+                       std::list<FeaturePtr>& theChain);
+
+  // tmp
+  std::set<FeaturePtr> myCreatedFeatures;
 };
 
 #endif