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