1 // File: SketchPlugin_Feature.h
2 // Created: 27 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef SketchPlugin_Feature_HeaderFile
6 #define SketchPlugin_Feature_HeaderFile
8 #include "SketchPlugin.h"
9 #include <ModelAPI_Feature.h>
10 #include <GeomAPI_Shape.h>
12 class SketchPlugin_Sketch;
15 /**\class SketchPlugin_Feature
17 * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
18 * an interface to create the sketch feature preview.
20 class SketchPlugin_Feature: public ModelAPI_Feature
23 /// Returns the sketch preview
24 /// \param theSketch the owner of this feature
25 /// \return the built preview
26 SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
28 /// Adds sub-feature of the higher level feature (sub-element of the sketch)
29 /// \param theFeature sub-feature
30 SKETCHPLUGIN_EXPORT virtual const void addSub(
31 const FeaturePtr& theFeature) = 0;
33 /// Returns true if this feature must be displayed in the history (top level of Part tree)
34 SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;}
37 /// \param theDeltaX the delta for X coordinate is moved
38 /// \param theDeltaY the delta for Y coordinate is moved
39 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
41 /// Return the distance between the feature and the point
42 /// \param thePoint the point
43 virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
46 /// Set the shape to the internal preview field
47 /// \param theShape a preview shape
48 void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
49 /// Return the shape from the internal preview field
50 /// \return theShape a preview shape
51 const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
52 /// Sets the higher-level feature for the sub-feature (sketch for line)
53 void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;}
54 /// Returns the sketch of this feature
55 SketchPlugin_Sketch* sketch();
56 /// initializes mySketch
57 SketchPlugin_Feature();
59 friend class SketchPlugin_Sketch;
62 boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
63 SketchPlugin_Sketch* mySketch; /// sketch that contains this feature