Salome HOME
77faff494295faad84adc6e4b156ebcb781a8682
[modules/shaper.git] / src / GeomData / GeomData_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 GeomData_Point2D_H_
21 #define GeomData_Point2D_H_
22
23 #include "GeomData.h"
24 #include "GeomDataAPI_Point2D.h"
25
26 #include <TDF_Label.hxx>
27
28 class ModelAPI_ExpressionDouble;
29
30 /**\class GeomData_Point2D
31  * \ingroup DataModel
32  * \brief Attribute that contains 2D point.
33  */
34
35 class GeomData_Point2D : public GeomDataAPI_Point2D
36 {
37   enum { NUM_COMPONENTS = 2 };
38   std::shared_ptr<ModelAPI_ExpressionDouble> myExpression[NUM_COMPONENTS]; ///< Expressions for X, Y
39  public:
40   /// Defines the double value
41   GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY);
42   /// Defines the point
43   GEOMDATA_EXPORT virtual void setValue(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
44
45   /// Returns the X double value
46   GEOMDATA_EXPORT virtual double x() const;
47   /// Returns the Y double value
48   GEOMDATA_EXPORT virtual double y() const;
49   /// Returns the 2D point
50   GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Pnt2d> pnt();
51
52   /// Defines the calculated double value
53   GEOMDATA_EXPORT virtual void setCalculatedValue(const double theX, const double theY);
54
55   /// Defines the text values
56   GEOMDATA_EXPORT virtual void setText(const std::wstring& theX,
57                                        const std::wstring& theY);
58
59   /// Returns the text values
60   GEOMDATA_EXPORT virtual std::wstring textX();
61   GEOMDATA_EXPORT virtual std::wstring textY();
62
63   /// Allows to set expression (text) as invalid (by the parameters listener)
64   GEOMDATA_EXPORT virtual void setExpressionInvalid(int, const bool theFlag);
65
66   /// Returns true if text is invalid
67   GEOMDATA_EXPORT virtual bool expressionInvalid(int);
68
69   /// Allows to set expression (text) error (by the parameters listener)
70   GEOMDATA_EXPORT virtual void setExpressionError(int theComponent, const std::string& theError);
71
72   /// Returns an expression error
73   GEOMDATA_EXPORT virtual std::string expressionError(int theComponent);
74
75   /// Defines the used parameters
76   GEOMDATA_EXPORT virtual void setUsedParameters(int theComponent,
77     const std::set<std::wstring>& theUsedParameters);
78
79   /// Returns the used parameters
80   GEOMDATA_EXPORT virtual std::set<std::wstring> usedParameters(int theComponent) const;
81
82  protected:
83   /// Initializes attributes
84   GEOMDATA_EXPORT GeomData_Point2D();
85   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
86   virtual void reinit();
87
88   /// Resets attribute to deafult state.
89   virtual void reset();
90
91   friend class Model_Data;
92 };
93
94 #endif