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