Salome HOME
Merge branch 'master' of salome:modules/shaper
[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 class Handle_AIS_InteractiveObject;
21
22 /**\class SketchPlugin_Feature
23  * \ingroup Plugins
24  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
25  * an interface to create the sketch feature preview.
26  */
27 class SketchPlugin_Feature : public ModelAPI_Feature
28 {
29  public:
30   /// Returns true if this feature must be displayed in the history (top level of Part tree)
31   SKETCHPLUGIN_EXPORT virtual bool isInHistory()
32   {
33     return false;
34   }
35
36   /// Returns true of the feature is created basing on the external shape of not-this-sketch object
37   SKETCHPLUGIN_EXPORT virtual bool isExternal() const
38   {
39     return false;
40   }
41
42   /// Returns true if the feature is a copy of other feature
43   SKETCHPLUGIN_EXPORT virtual bool isCopy() const
44   {
45     return false;
46   }
47
48   /// Returns true if the feature and the feature results can be displayed
49   /// \return true
50   SKETCHPLUGIN_EXPORT virtual bool canBeDisplayed() const
51   {
52     return true;
53   }
54
55   /// Moves the feature
56   /// \param theDeltaX the delta for X coordinate is moved
57   /// \param theDeltaY the delta for Y coordinate is moved
58   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
59
60   /// Construction result is allways recomuted on the fly
61   SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
62
63   /// Returns true is sketch element is under the rigid constraint
64   SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
65
66   /// Returns the sketch of this feature
67   SketchPlugin_Sketch* sketch();
68 protected:
69   /// Sets the higher-level feature for the sub-feature (sketch for line)
70   void setSketch(SketchPlugin_Sketch* theSketch)
71   {
72     mySketch = theSketch;
73   }
74   /// initializes mySketch
75   SketchPlugin_Feature();
76
77   friend class SketchPlugin_Sketch;
78
79  private:
80   std::shared_ptr<GeomAPI_Shape> myPreview;  ///< the preview shape
81   SketchPlugin_Sketch* mySketch;  /// sketch that contains this feature
82 };
83
84 #endif