wxArt2D
recur.h
Go to the documentation of this file.
1 /*! \file wx/canvas/recur.h
2  \brief special a2dCanvasObject which are used to create hierarchy different from
3  the standard a2dCanvasObject child list.
4 
5  Hierarchy is normally created by adding child a2dCanvasObject's to the root object of the document,
6  and next to those a2dCanvasObject's again add child objects.
7  But the object here create different types of hierarchy.
8 
9  a2dCanvasObjectReference refrences another a2dCanvasObject which might be stored as a child of
10  another one already. This way you can display the same object at several places.
11 
12  a2dCanvasObjectArrayReference is simular, but here the referenced object is displayed in
13  a grid of n by M objects.
14 
15  \author Klaas Holwerda
16 
17  Copyright: 2000-2004 (c) Klaas Holwerda
18 
19  Licence: wxWidgets Licence
20 
21  RCS-ID: $Id: recur.h,v 1.17 2009/09/26 20:40:32 titato Exp $
22 */
23 
24 #ifndef __WXRECUR_H__
25 #define __WXRECUR_H__
26 
27 #ifndef WX_PRECOMP
28 #include "wx/wx.h"
29 #endif
30 
31 #include "wx/canvas/canprim.h"
32 #include "wx/canvas/canimage.h"
33 #include "wx/canvas/cantext.h"
34 
35 #define __USE_EVENTS 1
36 
37 #define newline wxString("\n")
38 
39 //!a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
40 /*!
41 It does not Clone the referenced object.
42 It has a matrix to reposition/rotate/scale the object it references.
43 The position/matrix of the referenced Object is accumulated with the one here.
44 
45 An object Referenced will be rendered if it has the right layer and the reference
46 itself is visible. The Object its own visible flag is ignored.
47 
48 The selected flag of the Object referenced is overruled by the Reference.
49 
50  \ingroup canvasobject
51 
52 */
53 class A2DCANVASDLLEXP a2dCanvasObjectReference: public a2dCanvasObject
54 {
55 public:
56 
58 
59  a2dCanvasObjectReference( double x, double y, a2dCanvasObject* obj );
60 
62 
64 
65  //!\return the object that is referenced
66  a2dCanvasObject* GetCanvasObject();
67 
68  //! set the object that is referenced
69  void SetCanvasObject( a2dCanvasObject* object );
70 
71  virtual void DoWalker( wxObject* parent, a2dWalkerIOHandler& handler );
72 
73  //! when resolving this refrence via a a2dIOHandler, this is used.
74  virtual bool LinkReference( a2dObject* other );
75 
76  void MakeReferencesUnique();
77 
78  DECLARE_DYNAMIC_CLASS( a2dCanvasObjectReference )
79 
80  bool IsRecursive() { return true; }
81 
82  void RemoveHierarchy();
83 
84  virtual a2dCanvasObject* PushInto( a2dCanvasObject* parent );
85 
86 protected:
87 
88  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
89 
90  virtual void DoAddPending( a2dIterC& ic );
91 
92 #if wxART2D_USE_CVGIO
93  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
94 
95  void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
96 #endif //wxART2D_USE_CVGIO
97 
98  void DoRender( a2dIterC& ic, OVERLAP clipparent );
99 
100  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
101 
102  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
103 
104  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
105 
106  a2dCanvasObjectPtr m_object;
107 
108  static const a2dPropertyIdCanvasObject PROPID_refobject;
109 
110 private:
111 
112  virtual void DoWalkerWithContext( a2dIterC& ic, wxObject* parent, a2dWalkerIOHandlerWithContext& handler );
113 
114  //!this is a not implemented copy constructor that avoids automatic creation of one
116 
117 };
118 
119 //!a2dCanvasObjectArrayReference is an array of a reference to any a2dCanvasObject derived class.
120 /*!
121  Places the refernced a2dCanvasObject in an array of x elemnts wide and y elements heigh.
122 
123  It does not Clone the referenced object.
124 
125  The a2dCanvasObject::m_lworld can be used to reposition/rotate/scale the array.
126 
127  The position/matrix of the referenced Object is accumulated with the poistion in the array.
128 
129  \ingroup canvasobject
130 */
132 {
133 public:
134 
136 
137  a2dCanvasObjectArrayReference( double x, double y, int rows, int columns, double horzSpace, double vertSpace, a2dCanvasObject* obj );
138 
140 
142 
143  void SetHorzSpace( double horzSpace ) { m_horzSpace = horzSpace; SetPending( true ); }
144 
145  double GetHorzSpace() { return m_horzSpace; }
146 
147  void SetVertSpace( double vertSpace ) { m_vertSpace = vertSpace; SetPending( true ); }
148 
149  double GetVertSpace() { return m_vertSpace; }
150 
151  int GetRows() { return m_rows; }
152 
153  void SetRows( int rows ) { m_rows = rows; SetPending( true ); }
154 
155  int GetColumns() { return m_columns; }
156 
157  void SetColumns( int columns ) { m_columns = columns; SetPending( true ); }
158 
159  //!return total width of array
160  double GetWidth() { return m_columns * m_horzSpace; }
161 
162  //!return total height of array
163  double GetHeight() { return m_rows * m_vertSpace; }
164 
165  void RemoveHierarchy();
166 
167 protected:
168 
169  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
170 
171 #if wxART2D_USE_CVGIO
172  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
173 
174  void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
175 #endif //wxART2D_USE_CVGIO
176 
177  void DoRender( a2dIterC& ic, OVERLAP clipparent );
178 
179  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
180 
181  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
182 
183  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
184 
185 private:
186 
187  //! number of columns
188  int m_columns;
189 
190  //! number of rows
191  int m_rows;
192 
193  //! space between columns
194  double m_horzSpace;
195 
196  //! space between rows
197  double m_vertSpace;
198 
199  DECLARE_DYNAMIC_CLASS( a2dCanvasObjectArrayReference )
200 
201 private:
202  //!this is a not implemented copy constructor that avoids automatic creation of one
204 };
205 
206 //!a2dLibraryReference is a symbol object, it holds a reference
207 /*!
208 to a a2dCanvasObject. But renders itself as a symbolic image, which is either a small presentation
209 of its children or an independent a2dCanvasObject
210 This object can be used to implement libraries overviews.
211 
212  \ingroup canvasobject
213 
214 */
215 class A2DCANVASDLLEXP a2dLibraryReference: public a2dImage
216 {
217 public:
219 
220  a2dLibraryReference( double x, double y, a2dCanvasObject* obj, const wxString& name, double totalheight = 100,
221  a2dCanvasObject* symbol = 0,
222  const a2dFont& font = *a2dDEFAULT_CANVASFONT,
223  int imagew = 100, int imageh = 100 );
224 
226 
227  a2dLibraryReference( const a2dLibraryReference& other, CloneOptions options, a2dRefMap* refs );
228 
229  //!\return the object that is referenced
231 
232  //! set the object that is referenced
233  void SetCanvasObject( a2dCanvasObject* object );
234 
235  //!\return the object that is used as icon
236  a2dCanvasObject* GetSymbol();
237 
238  //! set the object that is used as icon
239  void SetSymbol( a2dCanvasObject* symbol );
240 
241  DECLARE_DYNAMIC_CLASS( a2dLibraryReference )
242 
243 protected:
244 
245  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
246 
247  void DoWalker( wxObject* parent, a2dWalkerIOHandler& handler );
248 
249  void DoRender( a2dIterC& ic, OVERLAP clipparent );
250  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
251  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
252  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
253 
254 #if wxART2D_USE_CVGIO
255  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
256 
257  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
258 #endif //wxART2D_USE_CVGIO
259 
260  a2dCanvasObjectPtr m_symbol;
261 
262  wxString m_description;
263 
264  a2dSmrtPtr<a2dText> m_text;
265 
266  //! object to which a reference is hold.
268 
269  double m_height;
270  double m_width;
271 
272 private:
273  //!this is a not implemented copy constructor that avoids automatic creation of one
275 };
276 
277 
278 //!a2dExternalReference is a text like object, but next to that it holds a reference
279 /*!
280 to a a2dCanvasObject. The referenced object is not a child, and is not part the boundingbox.
281 This object can be used to implement libraries and overviews.
282 
283  \ingroup canvasobject
284 
285 */
286 class A2DCANVASDLLEXP a2dExternalReference: public a2dText
287 {
288 public:
290 
291  a2dExternalReference( double x, double y, a2dCanvasObject* obj = 0, const wxString& text = wxT( "" ),
292  double angle = 0, const a2dFont& font = *a2dDEFAULT_CANVASFONT );
293 
295 
296  a2dExternalReference( const a2dExternalReference& other, CloneOptions options, a2dRefMap* refs );
297 
298  //!\return the object that is referenced
299  a2dCanvasObject* GetCanvasObject();
300 
301  //! set the object that is referenced
302  void SetCanvasObject( a2dCanvasObject* object );
303 
304  DECLARE_DYNAMIC_CLASS( a2dExternalReference )
305 
306 protected:
307 
308  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
309  void DoWalker( wxObject* parent, a2dWalkerIOHandler& handler );
310 
311  //! object to which a reference is held.
313 
314 private:
315  //!this is a not implemented copy constructor that avoids automatic creation of one
317 };
318 
319 //!a2dNameReference is a text like object, but next to that it holds a reference
320 /*!
321 to an a2dCanvasObject.
322 This object can be used to implement libraries and overviews.
323 
324  \ingroup canvasobject
325 
326 */
327 class A2DCANVASDLLEXP a2dNameReference: public a2dText
328 {
329 public:
331 
332  a2dNameReference( double x, double y, a2dCanvasObject* obj = 0, const wxString& text = wxT( "" ),
333  double angle = 0, const a2dFont& font = *a2dDEFAULT_CANVASFONT );
334 
335  ~a2dNameReference();
336 
337  a2dNameReference( const a2dNameReference& other, CloneOptions options, a2dRefMap* refs );
338 
339  //!\return the object that is referenced
340  a2dCanvasObject* GetCanvasObject();
341 
342  //! set the object that is referenced
343  void SetCanvasObject( a2dCanvasObject* object );
344 
345  virtual a2dCanvasObject* PushInto( a2dCanvasObject* parent );
346 
347  DECLARE_DYNAMIC_CLASS( a2dNameReference )
348 
349  virtual void DoWalker( wxObject* parent, a2dWalkerIOHandler& handler );
350 
351  //! when resolving this refrence via a a2dIOHandler, this is used.
352  virtual bool LinkReference( a2dObject* other );
353 
354 protected:
355 
356  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
357  virtual void DoAddPending( a2dIterC& ic );
358 
359  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
360 
361 #if wxART2D_USE_CVGIO
362  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
363 
364  void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
365 #endif //wxART2D_USE_CVGIO
366 
367  //! object to which a reference is held.
369 
370 private:
371  //!this is a not implemented copy constructor that avoids automatic creation of one
372  a2dNameReference( const a2dNameReference& other );
373 };
374 
375 
376 //! a2dSymbolicReference does not render referenced object.
377 /*!
378  Internal it has a reference to a second a2dCanvasObject.
379 
380  \ingroup canvasobject
381 
382 */
383 class A2DCANVASDLLEXP a2dSymbolicReference: public a2dCanvasObject
384 {
385 public:
387 
388  a2dSymbolicReference( double x, double y, a2dCanvasObject* obj );
389 
391 
392  a2dSymbolicReference( const a2dSymbolicReference& other, CloneOptions options, a2dRefMap* refs );
393 
394  //!\return the object that is referenced
395  a2dCanvasObject* GetCanvasObject();
396 
397  //! set the object that is referenced
398  void SetCanvasObject( a2dCanvasObject* object );
399 
400  DECLARE_DYNAMIC_CLASS( a2dSymbolicReference )
401 
402 protected:
403 
404  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
405  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
406 
407 #if wxART2D_USE_CVGIO
408  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
409 
410  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
411 #endif //wxART2D_USE_CVGIO
412 
413  a2dCanvasObjectPtr m_object;
414 
415 private:
416  //!this is a not implemented copy constructor that avoids automatic creation of one
418 };
419 
420 #endif
421 
a2dCanvasObject * GetCanvasObject()
Definition: recur.cpp:104
virtual void MakeReferencesUnique()
All direct a2dCanvasObject which are part of this one are made unique.
Definition: canobj.cpp:5440
a2dText derived from a2dCanvasObject, holds multiline text
all basic primitives derived from a2dCanvasObject
virtual bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: canobj.cpp:3713
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
Definition: recur.h:53
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: canobj.cpp:1426
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
a2dNameReference is a text like object, but next to that it holds a reference
Definition: recur.h:327
a2dSymbolicReference does not render referenced object.
Definition: recur.h:383
Ref Counted base object.
Definition: gen.h:1045
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: recur.cpp:230
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
virtual void RemoveHierarchy()
move childs of childs and members which have hierarchy one level up to this object its child list...
Definition: canobj.cpp:6160
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
void RemoveHierarchy()
move childs of childs and members which have hierarchy one level up to this object its child list...
Definition: recur.cpp:263
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
double GetWidth()
return total width of array
Definition: recur.h:160
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: recur.cpp:207
a2dCanvasObjectArrayReference is an array of a reference to any a2dCanvasObject derived class...
Definition: recur.h:131
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: recur.cpp:256
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: canobj.cpp:4695
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: recur.cpp:65
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: recur.cpp:138
a2dCanvasObjectPtr m_object
object to which a reference is held.
Definition: recur.h:312
a2dText is an abstract base class.
Definition: cantext.h:93
void SetCanvasObject(a2dCanvasObject *object)
set the object that is referenced
Definition: recur.cpp:109
a2dImage (will scale/rotate image when needed)
Definition: canimage.h:33
a2dExternalReference is a text like object, but next to that it holds a reference ...
Definition: recur.h:286
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
a2dCanvasObjectPtr m_object
object to which a reference is hold.
Definition: recur.h:267
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
a2dCanvasObjectPtr m_objectRef
object to which a reference is held.
Definition: recur.h:368
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: recur.cpp:130
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: recur.cpp:165
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: recur.cpp:148
virtual bool LinkReference(a2dObject *other)
link a reference in the object to the given value
Definition: gen.cpp:1460
virtual void DoAddPending(a2dIterC &ic)
called by addPending
Definition: canobj.cpp:4601
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
virtual a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: canobj.cpp:5031
virtual a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
Definition: canobj.cpp:2577
a2dLibraryReference is a symbol object, it holds a reference
Definition: recur.h:215
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: canobj.cpp:5098
This template class is for property ids with a known data type.
Definition: id.h:477
Walker taking iterative context into account.
Definition: algos.h:1208
list of a2dObject&#39;s
Definition: gen.h:3157
CloneOptions
options for cloning
Definition: gen.h:1200
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: canobj.cpp:5504
double GetHeight()
return total height of array
Definition: recur.h:163
recur.h Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation