OpenLexocad  27.1
PropertyPoint.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Geom/Pnt.h>
4 #include <Geom/Pnt2d.h>
5 
6 #include <vector>
7 
8 #include "Core/Property.h"
9 #include "Core/Variant.h"
10 
11 namespace Core
12 {
13 class LX_CORE_EXPORT PropertyPoint : public Core::Property
14 {
16 
17 public:
18  PropertyPoint(void);
19  virtual ~PropertyPoint(void);
20 
21  void setValue(const Geom::Pnt& p);
22  virtual bool setValueFromVariant(const Core::Variant& value);
24  virtual bool setKeyValue(const std::string& name, const Core::Variant& value);
25  virtual void copyValue(Core::Property* p);
26 
27  const Geom::Pnt& getValue() const;
28  virtual Core::Variant getVariant(void) const;
30  virtual std::map<std::string, Core::Variant> getKeyValueMap() const;
31 
32  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
33  inline virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
34  virtual bool isEqual(const Property*) const;
35  virtual Core::Property* copy(void) const override;
36  virtual void paste(const Core::Property& from) override;
37 
38 protected:
40 };
41 
42 class LX_CORE_EXPORT PropertyPointList : public Core::Property
43 {
45 
46 public:
49 
50  void setValue(const std::vector<Geom::Pnt>& list);
51  virtual bool setValueFromVariant(const Core::Variant& value);
52  virtual void copyValue(Core::Property* p);
53 
54  void addPoint(const Geom::Pnt& v);
55  void setEmpty();
56  bool isEmpty() const;
57 
58  const std::vector<Geom::Pnt>& getValue() const;
59  const size_t getSize() const;
60 
61  virtual Core::Variant getVariant(void) const { return Core::Variant(_pointList); }
62 
63  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
64  virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
65  virtual bool isEqual(const Property*) const;
66  virtual Core::Property* copy(void) const override;
67  virtual void paste(const Core::Property& from) override;
68 
69  static void save_static(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version, const std::vector<Geom::Pnt>& pointList);
70  static void restore_static(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version, std::vector<Geom::Pnt>& pointList);
71 
72 protected:
73  std::vector<Geom::Pnt> _pointList;
74 };
75 
76 class LX_CORE_EXPORT PropertyListPointList : public Core::Property
77 {
79 
80 public:
83 
84  void setValue(const std::list<std::list<Geom::Pnt> >& list);
85  void setValue(
86  int num_i,
87  int num_j,
88  const std::vector<Geom::Pnt>& vector); // This sets the _pointList given a vector and the number of lines/rows of the _pointList itself
89  virtual bool setValueFromVariant(const Core::Variant& value);
90  virtual void copyValue(Core::Property* p);
91 
92  void setEmpty();
93  bool isEmpty() const;
94 
95  const std::list<std::list<Geom::Pnt> >& getValue() const;
96  const std::vector<Geom::Pnt> getValue(int& num_i, int& num_j)
97  const; // This returns a copy of the _pointList encoded in a vector and the number of lines/rows of the multidimensional array
98 
99  virtual Core::Variant getVariant(void) const { return Core::Variant(_pointList); }
100 
101  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
102  virtual void save(std::ofstream& writer); // For test purposes
103  virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
104  virtual bool isEqual(const Property*) const;
105  virtual Core::Property* copy(void) const override;
106  virtual void paste(const Core::Property& from) override;
107 
108 protected:
110 };
111 
112 class LX_CORE_EXPORT PropertyPoint2d : public Core::Property
113 {
115 
116 public:
117  PropertyPoint2d(void);
118  virtual ~PropertyPoint2d(void);
119 
120  void setValue(const Geom::Pnt2d& p);
121  bool setValueFromVariant(const Core::Variant& value);
122  void copyValue(Core::Property* p);
123 
124  const Geom::Pnt2d& getValue() const;
125  Core::Variant getVariant(void) const;
126 
127  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
128  virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
129  virtual bool isEqual(const Property*) const;
130  virtual Core::Property* copy(void) const override;
131  virtual void paste(const Core::Property& from) override;
132 
133 protected:
135 };
136 
137 class LX_CORE_EXPORT PropertyPoint2dList : public Core::Property
138 {
140 
141 public:
144 
145  void setValue(const std::vector<Geom::Pnt2d>& list);
146  bool setValueFromVariant(const Core::Variant& value);
147  void copyValue(Core::Property* p);
148 
149  void addPoint(const Geom::Pnt2d& v);
150  void setEmpty();
151  bool isEmpty() const;
152 
153  const std::vector<Geom::Pnt2d>& getValue() const;
154 
155  Core::Variant getVariant(void) const { return Core::Variant(_pointList); }
156 
157  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
158  virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
159  virtual bool isEqual(const Property*) const;
160  virtual Core::Property* copy(void) const override;
161  virtual void paste(const Core::Property& from) override;
162 
163 protected:
164  std::vector<Geom::Pnt2d> _pointList;
165 };
166 
167 DECLARE_PROPERTY_FACTORY(PropertyPoint_Factory, Core::PropertyPoint);
168 DECLARE_PROPERTY_FACTORY(PropertyPointList_Factory, Core::PropertyPointList);
169 DECLARE_PROPERTY_FACTORY(PropertyListPointList_Factory, Core::PropertyListPointList);
170 DECLARE_PROPERTY_FACTORY(PropertyPoint2d_Factory, Core::PropertyPoint2d);
171 DECLARE_PROPERTY_FACTORY(PropertyPoint2dList_Factory, Core::PropertyPoint2dList);
172 
173 
174 } // namespace Core
Core::Variant getVariant(void) const
Definition: PropertyPoint.h:155
Definition: PropertyPoint.h:137
Geom::Pnt2d _pnt
Definition: PropertyPoint.h:134
Definition: PropertyPoint.h:76
Definition: Persistence.h:14
std::vector< Geom::Pnt2d > _pointList
Definition: PropertyPoint.h:164
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
std::list< std::list< Geom::Pnt > > _pointList
Definition: PropertyPoint.h:109
virtual Core::Variant getVariant(void) const
Definition: PropertyPoint.h:99
Core::PropertyText name
Definition: CoreDocument.h:167
Geom::Pnt _pnt
Definition: PropertyPoint.h:39
virtual Core::Variant getVariant(void) const
Definition: PropertyPoint.h:61
LX_CORE_EXPORT Version & version
Definition: Variant.h:87
Definition: AbstractXMLReader.h:7
Definition: PropertyPoint.h:112
Definition: Base.h:12
Definition: AbstractConstraint.h:6
std::vector< Geom::Pnt > _pointList
Definition: PropertyPoint.h:73
Definition: Writer.h:16
Definition: PropertyPoint.h:13
Definition: PropertyPoint.h:42
Definition: Property.h:77
Defines a non-persistent 2D cartesian point.
Definition: Pnt2d.h:33
TYPESYSTEM_HEADER()
DECLARE_PROPERTY_FACTORY(PropertyAxis1_Factory, Core::PropertyAxis1)