Salome HOME
Issue #2024: Redesign of circle and arc of circle
[modules/shaper.git] / src / GeomData / GeomData_Point2D.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomData_Point2D.h
4 // Created:     24 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef GeomData_Point2D_H_
8 #define GeomData_Point2D_H_
9
10 #include "GeomData.h"
11 #include "GeomDataAPI_Point2D.h"
12
13 #include <TDF_Label.hxx>
14
15 class ModelAPI_ExpressionDouble;
16
17 /**\class GeomData_Point2D
18  * \ingroup DataModel
19  * \brief Attribute that contains 2D point.
20  */
21
22 class GeomData_Point2D : public GeomDataAPI_Point2D
23 {
24   enum { NUM_COMPONENTS = 2 };
25   std::shared_ptr<ModelAPI_ExpressionDouble> myExpression[NUM_COMPONENTS]; ///< Expressions for X, Y
26  public:
27   /// Defines the double value
28   GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY);
29   /// Defines the point
30   GEOMDATA_EXPORT virtual void setValue(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
31
32   /// Returns the X double value
33   GEOMDATA_EXPORT virtual double x() const;
34   /// Returns the Y double value
35   GEOMDATA_EXPORT virtual double y() const;
36   /// Returns the 2D point
37   GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Pnt2d> pnt();
38
39   /// Defines the calculated double value
40   GEOMDATA_EXPORT virtual void setCalculatedValue(const double theX, const double theY);
41
42   /// Defines the text values
43   GEOMDATA_EXPORT virtual void setText(const std::string& theX,
44                                        const std::string& theY);
45
46   /// Returns the text values
47   GEOMDATA_EXPORT virtual std::string textX();
48   GEOMDATA_EXPORT virtual std::string textY();
49
50   /// Allows to set expression (text) as invalid (by the parameters listener)
51   GEOMDATA_EXPORT virtual void setExpressionInvalid(int, const bool theFlag);
52
53   /// Returns true if text is invalid
54   GEOMDATA_EXPORT virtual bool expressionInvalid(int);
55
56   /// Allows to set expression (text) error (by the parameters listener)
57   GEOMDATA_EXPORT virtual void setExpressionError(int theComponent, const std::string& theError);
58
59   /// Returns an expression error
60   GEOMDATA_EXPORT virtual std::string expressionError(int theComponent);
61
62   /// Defines the used parameters
63   GEOMDATA_EXPORT virtual void setUsedParameters(int theComponent,
64     const std::set<std::string>& theUsedParameters);
65
66   /// Returns the used parameters
67   GEOMDATA_EXPORT virtual std::set<std::string> usedParameters(int theComponent) const;
68
69  protected:
70   /// Initializes attributes
71   GEOMDATA_EXPORT GeomData_Point2D();
72   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
73   virtual void reinit();
74
75   /// Resets attribute to deafult state.
76   virtual void reset();
77
78   friend class Model_Data;
79 };
80
81 #endif