Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / src / GeomDataAPI / GeomDataAPI_Point2D.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef GeomDataAPI_Point2D_H_
22 #define GeomDataAPI_Point2D_H_
23
24 #include <GeomDataAPI.h>
25 #include <ModelAPI_Attribute.h>
26 #include <ModelAPI_Data.h>
27
28 #include <set>
29
30 class GeomAPI_Pnt2d;
31
32 /**\class GeomDataAPI_Point2D
33  * \ingroup DataModel
34  * \brief Attribute that contains 2D point coordinates.
35  */
36
37 class GeomDataAPI_Point2D : public ModelAPI_Attribute
38 {
39  public:
40   /// Defines the double value
41   GEOMDATAAPI_EXPORT virtual void setValue(const double theX, const double theY) = 0;
42   /// Defines the point
43   GEOMDATAAPI_EXPORT virtual void setValue(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
44
45   /// Returns the X double value
46   GEOMDATAAPI_EXPORT virtual double x() const = 0;
47   /// Returns the Y double value
48   GEOMDATAAPI_EXPORT virtual double y() const = 0;
49   /// Returns the 2D point
50   GEOMDATAAPI_EXPORT virtual std::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
51
52   /// Defines the calculated double value
53   GEOMDATAAPI_EXPORT virtual void setCalculatedValue(const double theX, const double theY) = 0;
54
55   /// Defines the text values
56   GEOMDATAAPI_EXPORT virtual void setText(const std::string& theX,
57                                           const std::string& theY) = 0;
58
59   /// Returns the text value for X
60   GEOMDATAAPI_EXPORT virtual std::string textX() = 0;
61   /// Returns the text value for Y
62   GEOMDATAAPI_EXPORT virtual std::string textY() = 0;
63
64   /// Point component (x,y)
65   enum PointComponent { C_X = 0,
66                         C_Y = 1,
67   };
68
69   /// Allows to set expression (text) as invalid (by the parameters listener)
70   GEOMDATAAPI_EXPORT virtual void setExpressionInvalid(int theComponent, const bool theFlag) = 0;
71
72   /// Returns true if text is invalid
73   GEOMDATAAPI_EXPORT virtual bool expressionInvalid(int theComponent) = 0;
74
75   /// Allows to set expression (text) error (by the parameters listener)
76   GEOMDATAAPI_EXPORT virtual
77     void setExpressionError(int theComponent, const std::string& theError) = 0;
78
79   /// Returns an expression error
80   GEOMDATAAPI_EXPORT virtual std::string expressionError(int theComponent) = 0;
81
82   /// Defines the used parameters
83   GEOMDATAAPI_EXPORT virtual void setUsedParameters(int theComponent,
84     const std::set<std::string>& theUsedParameters) = 0;
85
86   /// Returns the used parameters
87   GEOMDATAAPI_EXPORT virtual std::set<std::string> usedParameters(int theComponent) const = 0;
88
89   /// Appends the delta values to point
90   GEOMDATAAPI_EXPORT void move(const double theDeltaX, const double theDeltaY);
91
92   /// Returns the type of this class of attributes
93   static std::string typeId()
94   {
95     return std::string("Point2D");
96   }
97
98   /// Returns the type of this class of attributes, not static method
99   GEOMDATAAPI_EXPORT virtual std::string attributeType();
100
101   /// Returns this attribute from the data if it is possible
102   /// \param theData a model data
103   /// \param theAttribute an attribute index
104   static GEOMDATAAPI_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getPoint2D(const DataPtr& theData,
105                                                                   const std::string& theAttribute);
106
107  protected:
108   /// Objects are created for features automatically
109   GEOMDATAAPI_EXPORT GeomDataAPI_Point2D();
110   GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Point2D();
111 };
112
113 //! Pointer on attribute object
114 typedef std::shared_ptr<GeomDataAPI_Point2D> AttributePoint2DPtr;
115
116 #endif