/
PropertyLinks.h
288 lines (221 loc) · 8.24 KB
/
PropertyLinks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef APP_PROPERTYLINKS_H
#define APP_PROPERTYLINKS_H
// Std. configurations
#include <vector>
#include <string>
#include "Property.h"
namespace Base {
class Writer;
}
namespace App
{
class DocumentObject;
/** the general Link Poperty
* Main Purpose of this property is to Link Objects and Feautures in a document.
*/
class AppExport PropertyLink : public Property
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyLink();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyLink();
/** Sets the property
*/
void setValue(App::DocumentObject *);
/** This method returns the linked DocumentObject
*/
App::DocumentObject * getValue(void) const;
/** Returns the link type checked
*/
App::DocumentObject * getValue(Base::Type t) const;
/** Returns the link type checked
*/
template <typename _type>
inline _type getValue(void) const {
return _pcLink ? dynamic_cast<_type>(_pcLink) : 0;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save (Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual Property *Copy(void) const;
virtual void Paste(const Property &from);
virtual unsigned int getMemSize (void) const{
return sizeof(App::DocumentObject *);
}
virtual const char* getEditorName(void) const
{ return "Gui::PropertyEditor::PropertyLinkItem"; }
protected:
App::DocumentObject *_pcLink;
};
/** the Link Poperty with sub elements
* This property links a object and a defined sequence of
* sub elements. This subelemts (like Edges of a Shape)
* are stored as names, which can be resolved by the
* ComplexGeoDataType interface to concrete sub objects.
*/
class AppExport PropertyLinkSub: public Property
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyLinkSub();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyLinkSub();
/** Sets the property
*/
void setValue(App::DocumentObject *,const std::vector<std::string> &SubList=std::vector<std::string>());
/** This method returns the linked DocumentObject
*/
App::DocumentObject * getValue(void) const;
/// return the list of sub elements
const std::vector<std::string>& getSubValues(void) const;
/// return the list of sub elements starts with a special string
std::vector<std::string> getSubValuesStartsWith(const char*) const;
/** Returns the link type checked
*/
App::DocumentObject * getValue(Base::Type t) const;
/** Returns the link type checked
*/
template <typename _type>
inline _type getValue(void) const {
return _pcLinkSub ? dynamic_cast<_type>(_pcLinkSub) : 0;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save (Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual Property *Copy(void) const;
virtual void Paste(const Property &from);
virtual unsigned int getMemSize (void) const{
return sizeof(App::DocumentObject *);
}
protected:
App::DocumentObject *_pcLinkSub;
std::vector<std::string> _cSubList;
};
class AppExport PropertyLinkList: public PropertyLists
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyLinkList();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyLinkList();
virtual void setSize(int newSize);
virtual int getSize(void) const;
/** Sets the property
*/
void setValue(DocumentObject*);
void setValues(const std::vector<DocumentObject*>&);
/// index operator
DocumentObject* operator[] (const int idx) const {
return _lValueList.operator[] (idx);
}
void set1Value (const int idx, DocumentObject* value) {
_lValueList.operator[] (idx) = value;
}
const std::vector<DocumentObject*> &getValues(void) const {
return _lValueList;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save (Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual Property *Copy(void) const;
virtual void Paste(const Property &from);
virtual unsigned int getMemSize (void) const;
private:
std::vector<DocumentObject*> _lValueList;
};
class AppExport PropertyLinkSubList: public PropertyLists
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyLinkSubList();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyLinkSubList();
struct SubSet {
SubSet(DocumentObject*o,const char*s):obj(o),sub(s){}
SubSet(DocumentObject*o,const std::string &s):obj(o),sub(s.c_str()){}
DocumentObject* obj;
const char* sub;
};
virtual void setSize(int newSize);
virtual int getSize(void) const;
/** Sets the property
*/
void setValue(DocumentObject*,const char*);
void setValues(const std::vector<DocumentObject*>&,const std::vector<const char*>&);
void setValues(const std::vector<DocumentObject*>&,const std::vector<std::string>&);
// index operator
SubSet operator[] (const int idx) const {
return SubSet(_lValueList.operator[] (idx),_lSubList.operator [](idx));
}
const std::vector<DocumentObject*> &getValues(void) const {
return _lValueList;
}
const std::vector<std::string> &getSubValues(void) const {
return _lSubList;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save (Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual Property *Copy(void) const;
virtual void Paste(const Property &from);
virtual unsigned int getMemSize (void) const;
private:
std::vector<DocumentObject*> _lValueList;
std::vector<std::string> _lSubList;
};
} // namespace App
#endif // APP_PROPERTYLINKS_H