Salome HOME
fa8a571585f04aa8cfc2e9592c68ad31081f60c8
[modules/shaper.git] / src / GeomDataAPI / GeomDataAPI_Point2D.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomDataAPI_Point2D.h
4 // Created:     24 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef GeomDataAPI_Point2D_H_
8 #define GeomDataAPI_Point2D_H_
9
10 #include <GeomDataAPI.h>
11 #include <ModelAPI_Attribute.h>
12 #include <ModelAPI_Data.h>
13
14 #include <set>
15
16 class GeomAPI_Pnt2d;
17
18 /**\class GeomDataAPI_Point2D
19  * \ingroup DataModel
20  * \brief Attribute that contains 2D point coordinates.
21  */
22
23 class GeomDataAPI_Point2D : public ModelAPI_Attribute
24 {
25  public:
26   /// Defines the double value
27   GEOMDATAAPI_EXPORT virtual void setValue(const double theX, const double theY) = 0;
28   /// Defines the point
29   GEOMDATAAPI_EXPORT virtual void setValue(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
30
31   /// Returns the X double value
32   GEOMDATAAPI_EXPORT virtual double x() const = 0;
33   /// Returns the Y double value
34   GEOMDATAAPI_EXPORT virtual double y() const = 0;
35   /// Returns the 2D point
36   GEOMDATAAPI_EXPORT virtual std::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
37
38   /// Defines the calculated double value
39   GEOMDATAAPI_EXPORT virtual void setCalculatedValue(const double theX, const double theY) = 0;
40
41   /// Defines the text values
42   GEOMDATAAPI_EXPORT virtual void setText(const std::string& theX,
43                                           const std::string& theY) = 0;
44
45   /// Returns the text value for X
46   GEOMDATAAPI_EXPORT virtual std::string textX() = 0;
47   /// Returns the text value for Y
48   GEOMDATAAPI_EXPORT virtual std::string textY() = 0;
49
50   /// Point component (x,y)
51   enum PointComponent { C_X = 0,
52                         C_Y = 1,
53   };
54
55   /// Allows to set expression (text) as invalid (by the parameters listener)
56   GEOMDATAAPI_EXPORT virtual void setExpressionInvalid(int theComponent, const bool theFlag) = 0;
57
58   /// Returns true if text is invalid
59   GEOMDATAAPI_EXPORT virtual bool expressionInvalid(int theComponent) = 0;
60
61   /// Allows to set expression (text) error (by the parameters listener)
62   GEOMDATAAPI_EXPORT virtual 
63     void setExpressionError(int theComponent, const std::string& theError) = 0;
64
65   /// Returns an expression error
66   GEOMDATAAPI_EXPORT virtual std::string expressionError(int theComponent) = 0;
67
68   /// Defines the used parameters
69   GEOMDATAAPI_EXPORT virtual void setUsedParameters(int theComponent, 
70     const std::set<std::string>& theUsedParameters) = 0;
71
72   /// Returns the used parameters
73   GEOMDATAAPI_EXPORT virtual std::set<std::string> usedParameters(int theComponent) const = 0;
74
75   /// Appends the delta values to point
76   GEOMDATAAPI_EXPORT void move(const double theDeltaX, const double theDeltaY);
77
78   /// Returns the type of this class of attributes
79   static std::string typeId()
80   {
81     return std::string("Point2D");
82   }
83
84   /// Returns the type of this class of attributes, not static method
85   GEOMDATAAPI_EXPORT virtual std::string attributeType();
86
87   /// Returns this attribute from the data if it is possible
88   /// \param theData a model data
89   /// \param theAttribute an attribute index
90   static GEOMDATAAPI_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getPoint2D(const DataPtr& theData,
91                                                                   const std::string& theAttribute);
92
93  protected:
94   /// Objects are created for features automatically
95   GEOMDATAAPI_EXPORT GeomDataAPI_Point2D();
96   GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Point2D();
97 };
98
99 //! Pointer on attribute object
100 typedef std::shared_ptr<GeomDataAPI_Point2D> AttributePoint2DPtr;
101
102 #endif