Salome HOME
Default planes and origin initialization
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Plane.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ConstructionPlugin_Plane.h
4 // Created:     12 Dec 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef ConstructionPlugin_Plane_H
8 #define ConstructionPlugin_Plane_H
9
10 #include "ConstructionPlugin.h"
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Result.h>
13 #include <GeomAPI_ICustomPrs.h>
14
15
16
17 /**\class ConstructionPlugin_Plane
18  * \ingroup Plugins
19  * \brief Feature for creation of the new planar surface in PartSet.
20  */
21 class ConstructionPlugin_Plane : public ModelAPI_Feature, public GeomAPI_ICustomPrs
22 {
23  public:
24   /// Returns the kind of a feature
25   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
26   {
27     static std::string MY_KIND = ConstructionPlugin_Plane::ID();
28     return MY_KIND;
29   }
30
31   /// default color for a plane
32   inline static const std::string& DEFAULT_COLOR()
33   {
34     static const std::string CONSTRUCTION_PLANE_COLOR("#32FF32");
35     return CONSTRUCTION_PLANE_COLOR;
36   }
37
38   /// Plane kind
39   inline static const std::string& ID()
40   {
41     static const std::string CONSTRUCTION_PLANE_KIND("Plane");
42     return CONSTRUCTION_PLANE_KIND;
43   }
44
45   /// attribute name for first point
46   inline static const std::string& METHOD()
47   {
48     static const std::string METHOD_ATTR("CreationMethod");
49     return METHOD_ATTR;
50   }
51
52   /// attribute name for base face
53   inline static const std::string& FACE()
54   {
55     static const std::string FACE_ATTR("planeFace");
56     return FACE_ATTR;
57   }
58   /// attribute name for distance
59   inline static const std::string& DISTANCE()
60   {
61     static const std::string DISTANCE_ATTR("distance");
62     return DISTANCE_ATTR;
63   }
64
65   /// the a parameter for the general equation of a plane (ax+by+cz+d=0)
66   inline static const std::string& A()
67   {
68     static const std::string PARAM_A_ATTR("A");
69     return PARAM_A_ATTR;
70   }
71   /// the b parameter for the general equation of a plane (ax+by+cz+d=0)
72   inline static const std::string& B()
73   {
74     static const std::string PARAM_B_ATTR("B");
75     return PARAM_B_ATTR;
76   }
77   /// the c parameter for the general equation of a plane (ax+by+cz+d=0)
78   inline static const std::string& C()
79   {
80     static const std::string PARAM_C_ATTR("C");
81     return PARAM_C_ATTR;
82   }
83   /// the d parameter for the general equation of a plane (ax+by+cz+d=0)
84   inline static const std::string& D()
85   {
86     static const std::string PARAM_D_ATTR("D");
87     return PARAM_D_ATTR;
88   }
89
90   /// Creates a new part document if needed
91   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
92
93   /// Request for initialization of data model of the feature: adding all attributes
94   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
95
96   /// Construction result is always recomputed on the fly
97   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
98
99   /// Use plugin manager for features creation
100   ConstructionPlugin_Plane();
101
102   /// Customize presentation of the feature
103   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
104                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
105
106  protected:
107   std::shared_ptr<GeomAPI_Shape> createPlaneByFaceAndDistance();
108   std::shared_ptr<GeomAPI_Shape> createPlaneByGeneralEquation();
109 };
110
111 #endif