Salome HOME
Porting to SALOME_8.2.0
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Feature.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Feature.h
4 // Created:     27 Mar 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef SketchPlugin_Feature_H_
8 #define SketchPlugin_Feature_H_
9
10 #include "SketchPlugin.h"
11 #include <ModelAPI_CompositeFeature.h>
12 #include <GeomAPI_Shape.h>
13 #include <ModelAPI_Document.h>
14 #include <ModelAPI_AttributeSelection.h>
15 #include <ModelAPI_AttributeBoolean.h>
16
17 #include <Config_PropManager.h>
18
19 class SketchPlugin_Sketch;
20
21 /**\class SketchPlugin_Feature
22  * \ingroup Plugins
23  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
24  * an interface to create the sketch feature preview.
25  */
26 class SketchPlugin_Feature : public ModelAPI_Feature
27 {
28  public:
29   /// Returns true if this feature must be displayed in the history (top level of Part tree)
30   SKETCHPLUGIN_EXPORT virtual bool isInHistory()
31   {
32     return false;
33   }
34
35   /// Returns true of the feature is created basing on the external shape of not-this-sketch object
36   SKETCHPLUGIN_EXPORT virtual bool isExternal() const
37   {
38     return false;
39   }
40
41   /// Returns true if the feature is a copy of other feature
42   SKETCHPLUGIN_EXPORT virtual bool isCopy() const
43   {
44     return false;
45   }
46
47   /// Returns true if the feature and the feature results can be displayed
48   /// \return true
49   SKETCHPLUGIN_EXPORT virtual bool canBeDisplayed() const
50   {
51     return true;
52   }
53
54   /// Moves the feature
55   /// \param theDeltaX the delta for X coordinate is moved
56   /// \param theDeltaY the delta for Y coordinate is moved
57   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
58
59   /// Construction result is allways recomuted on the fly
60   SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
61
62   /// Returns true is sketch element is under the rigid constraint
63   SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
64
65   /// Returns the sketch of this feature
66   SketchPlugin_Sketch* sketch();
67 protected:
68   /// Sets the higher-level feature for the sub-feature (sketch for line)
69   void setSketch(SketchPlugin_Sketch* theSketch)
70   {
71     mySketch = theSketch;
72   }
73   /// initializes mySketch
74   SketchPlugin_Feature();
75
76   friend class SketchPlugin_Sketch;
77
78  private:
79   std::shared_ptr<GeomAPI_Shape> myPreview;  ///< the preview shape
80   SketchPlugin_Sketch* mySketch;  /// sketch that contains this feature
81 };
82
83 #endif