wxArt2D
canobj.h
Go to the documentation of this file.
1 /*! \file wx/canvas/canobj.h
2  \brief The base class for all drawable objects in a a2dCanvasDocument.
3 
4  Next to a2dCanvasObject, there are classes for filtering object ( a2dCanvasObjectFilter )
5  when iterating recursively through a document hierarchy.
6  The class a2dIterC is used for holding the iteration context,
7  which on its turn holds the drawing context when needed.
8 
9  \author Klaas Holwerda & Robert Roebling
10 
11  Copyright: 2000-2004 (c) Robert Roebling
12 
13  Licence: wxWidgets Licence
14 
15  RCS-ID: $Id: canobj.h,v 1.85 2009/07/10 19:23:13 titato Exp $
16 */
17 
18 #ifndef __WXCANOBJ_H__
19 #define __WXCANOBJ_H__
20 
21 #ifndef WX_PRECOMP
22 #include "wx/wx.h"
23 #endif
24 
25 #include "wx/image.h"
26 
27 #include "wx/general/genmod.h"
28 
29 #include "wx/geometry.h"
30 #include "wx/artbase/afmatrix.h"
31 #include "wx/artbase/bbox.h"
32 #include "wx/canvas/candefs.h"
33 
35 
36 #include "wx/canvas/styleprop.h"
37 #include "wx/canvas/xmlpars.h"
38 #include "wx/canvas/restrict.h"
39 #include "wx/canvas/hittest.h"
40 #include "wx/canvas/connectgen.h"
41 
42 #include "wx/canvas/route.h"
43 
44 #include <bitset>
45 using namespace std;
46 
48 
49 //----------------------------------------------------------------------------
50 // decls
51 //----------------------------------------------------------------------------
52 
53 #if defined(WXART2D_USINGDLL)
54 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dCanvasObject>;
55 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dDrawingPart>;
56 #endif
57 #if defined(WXART2D_USINGDLL)
59 template class A2DCANVASDLLEXP a2dPropertyIdProp<a2dStyleProperty>;
60 template class A2DCANVASDLLEXP a2dPropertyIdProp<a2dShadowStyleProperty>;
62 #endif
67 typedef wxUint8 a2dTag;
68 typedef vector<a2dTag> a2dTagVec;
70 
71 class A2DCANVASDLLEXP a2dPinClass;
72 class A2DCANVASDLLEXP a2dHandle;
73 
74 //! Enum for hit test options
75 
77 {
78  //! no special options
80 
81  //! if set, respect layer order, hit testing is done per layer from the top.
83  //! if set, don't hit test the root object or object for which IsHitWorld is called
84  /*!
85  This option hit tests the child objects as seen from the parent object.
86  */
88 
89  //! object hit should not have select flag set
91 
92  //! if set, don't stop at the first hit, but test child/sibling objects anyway
93  /*!
94  For accurate hitting of close parallel lines. If object earlier on layer, is within tolerance, it would be hit,
95  even if other lines are more close to the cursor, or cursor is on top of a later.
96  */
98 };
99 
100 //! OR-ing a2dHitOption is allowed
101 
103 {
104  return ( a2dHitOption ) ( ( int ) a | ( int ) b );
105 }
106 
107 
108 
110 {
111  //! no special flags set
113 
114  //! edit a copy of the original object
115  /*! There are two reasons, why you might want to edit a copy:
116 
117  - In layered drawings, one might want to see the effect of the layering
118  during editing (e.g. that the edited object ist partially obscured),
119  while at the same time the outline of the object and the editing handles
120  should be rendered on top. This behaviour is best implemented by having
121  two objects, an editing object with handles on top and the usual object.
122 
123  - in wxEDIT_COPY mode the editing information is transfered from the editing
124  object to the original object using the command processor. This way the command
125  processor is not only used for undo and redo but for all editing. This results
126  in a more robust architecture (especially concerning undo/redo).
127 
128  If this style is not set, the original object is edited directly. Commands
129  are still generated for undo/redo but the original object is not changed
130  by these commands, so undo/redo is less robust.
131  */
133 
134  //! editing is completely controlled by tools. No handles are added
135  /*! If a master tool is used, handle editing is not realy appropriate, because
136  the editing tool is not active and handles are not visible before the user
137  clicks somewhere. Also master tools need fine control over editing and use
138  tools that perform a very specific task. This can be done without handles.
139  */
141 };
142 
144 {
145  return ( wxEditStyle ) ( ( int ) a | ( int ) b );
146 }
147 
148 //----------------------------------------------------------------------------
149 // a2dCanvasObject
150 //----------------------------------------------------------------------------
151 
152 //! event mask flags for a2dCanvasObject hit
153 /*! a2dCanvasObjectHitFlags used in a mask for defining how an object should be hit
154 
155  \ingroup canvasobject
156 
157 */
159 {
160  a2dCANOBJ_EVENT_NON = 0x0001, //!< no hit will be reported
161  a2dCANOBJ_EVENT_FILL = 0x0002, //!< hit if filled
162  a2dCANOBJ_EVENT_STROKE = 0x0004, //!< hit if stroked
163  a2dCANOBJ_EVENT_FILL_NON_TRANSPARENT = 0x0008, //!< hit if filling is not transparent
164  a2dCANOBJ_EVENT_STROKE_NON_TRANSPARENT = 0x0010, //!< hit if stroke is not transparent
165  a2dCANOBJ_EVENT_VISIBLE = 0x0020, //!< hit if visible
166  a2dCANOBJ_EVENT_ALL = 0x0040 //!< always hit
167 };
168 
169 //! a2dCanvasObject hit flags as a structure \ingroup canvasobject
170 /*! a2dCanvasOHitFlags is used as mask for defining how an object should be hit
171 */
173 {
174  //!no events
175  bool m_non: 1;
176  //! only when over filled area of object
177  bool m_fill: 1;
178  //! only when over stroked area of object
179  bool m_stroke: 1;
180  //! only when non transparent fill
181  bool m_fill_non_transparent: 1;
182  //! only when non transparent stroke
183  bool m_stroke_non_transparent: 1;
184  //! only when visible
185  bool m_visible: 1;
186  //!all events
187  bool m_all: 1;
188 
189 };
190 
191 //! This is one hit result from a2dExtendedResult
192 class A2DCANVASDLLEXP a2dExtendedResultItem
193 {
194 public:
195  //! Default Constructor
197  //! Standard Constructor
198  a2dExtendedResultItem( a2dCanvasObject* object, a2dCanvasObject* parent, a2dHit type, int level, int typeex )
199  {
200  m_object = object;
201  m_parent = parent;
202  m_type = type;
203  m_level = level;
204  m_typeex = typeex;
205  }
206  //! the hit object
207  class a2dCanvasObject* GetObject() const { return m_object; };
208  //! the parent object of the hit object
209  class a2dCanvasObject* GetParent() const { return m_parent; };
210  //! type of the hit
211  const a2dHit& GetHitType() const { return m_type; }
212  //! level of the hit object below the start (root) object
213  int GetLevel() const { return m_level; }
214 
215 protected:
216  friend class a2dExtendedResult;
217  //! the hit object
219  //! the parent object of the hit object
221  //! type of the hit
223  //! level of the hit object below the start (root) object
224  /*! note: the extended result can contain multiple hits on the same level */
225  int m_level;
226  //! Extended hit type
227  /*! This is generally class specific.
228  Derived classes must include the IDs for the base class.
229  a2dCanvasObject does not define extended hit IDs.
230  */
231  int m_typeex;
232 };
233 
234 //! An object of this class represents the context of a query like a hit test
235 /*! This is similar to a2dIterC, but it is not used for iteration, but for
236  return values.
237 */
238 class A2DCANVASDLLEXP a2dExtendedResult: public std::vector<a2dExtendedResultItem>
239 {
240 public:
241  //! Default constructor
243  //! Destructor
245 };
246 
247 //! structure to give as parameter to member functions of a2dCanvasObject
248 /*!
249  During event processing and hittesting in a a2dDrawingPart and a2dDrawing, this
250  structure is used to give and assemble information while traversing the document.
251 */
253 {
254 
255 public:
256 
257  a2dHitEvent( double absx = 0, double absy = 0, bool continues = true,
258  a2dHitOption option = a2dCANOBJHITOPTION_NONE, bool wantExtended = false )
259  {
260  m_option = option;
261  m_maxlevel = INT_MAX;
262  m_relx = 0;
263  m_rely = 0;
264  m_x = absx;
265  m_y = absy;
266  m_processed = false;
267  m_continue = continues;
268  m_isHit = false;
269  m_how = a2dHit::stock_nohit;
270  m_id = 0;
271  m_extendedWanted = wantExtended;
272  m_xyRelToChildren = false;
273  m_event = NULL;
274  }
275 
276  void SetProcessed( bool val )
277  {
278 #ifdef _DEBUG
279  if ( val )
280  m_processed = true;
281  else
282  m_processed = false;
283 #else
284  m_processed = val;
285 #endif
286  }
287 
288  //! (world coordinates) hit point x relative to the canvas object its parent object(s)
289  double m_relx;
290  //! (world coordinates) hit point y relative to the canvas object its parent object(s)
291  double m_rely;
292  //! (world coordinates) hit point x as in a2dDrawingPart or any other top level
293  double m_x;
294  //! (world coordinates) hit point y as in a2dDrawingPart or any other top level
295  double m_y;
296  //! is set, m_x and m_y are supplied relative to the child objects ( object matrix m_world already applied )
298  //! the way to hit/traverse the document.
299  wxUint32 m_option;
300  //! return in which way the object was hit (stroke, fill, ...)
302  //! extended result information with e.g path to lead to the nested object hit
304  //! fill m_extended or not
306  //! maximum level of hit object below this (this = level 0)
308  //! event to process in case of event processing call
309  wxEvent* m_event;
310  //! set if event was processed sofar
312  //! set if the event processing or hittest needs to continue after first hit
314  //! in the end if there was a hit (even if not processed event)
315  bool m_isHit;
316  //! application specific use
317  int m_id;
318 };
319 
320 //! if pointToSnap is closer to pointToSnapTo than bestPointSofar, make bestPointSofar that point.
321 //! But only if it is within thresHoldWorld distance.
322 extern bool SetPointIfCloser( const a2dPoint2D& pointToSnapTo, const a2dPoint2D& pointToSnap, a2dPoint2D& bestPointSofar, double thresHoldWorld );
323 
324 //!a2dCanvasObject is the base class for Canvas Objects.
325 /*!
326  All objects for drawing on the a2dCanvas are derived from this class.
327  A a2dCanvasDocument is filled with instances of this object.
328  a2dCanvasObject can have children, which are also a2dCanvasObjects.
329  A a2dCanvasObject itself can be a child of more than one parent a2dCanvasObject.
330  The reference counter takes care of deleting the object when all references are released.
331 
332  Child objects are stored in a2dCanvasObjectList m_childobjects, which is only created
333  when the first child is added to the a2dCanvasObject. Else it points to wxNullCanvasObjectList.
334 
335  Each a2dCanvasObject can also have a list of a2dObject objects.
336  They are stored in the a2dObjectList m_properties.
337 
338  Asking for the GetCount() of the above two lists, is save, since wxNullCanvasObjectList
339  will return 0.
340 
341  Traversing a a2dCanvasDocument is mainly by traversing of the child list of each a2dCanvasObject in the
342  document in a recursive manner.
343  Many functions in a2dCanvasObject need to traverse the document, therefore there is often a DoSomething
344  function called from the base a2dCanvasObject, in order to do the object specific job while
345  traversing the document.
346 
347  Rendering of a2dCanvasObject's is via the base Render function, which takes care
348  of rendering child objects. It also does the clipping of objects to the area to be drawn.
349  First it searches for style properties in the property list, if found they will be used
350  to set the drawing style of the active a2dDrawingPart which is used to draw on a device.
351  If no style properties are available, the layer settings are used to set the style of the a2dDrawingPart.
352  Next to style properties, there can be other properties which influence the rendering of the object
353  in general; e.g. the a2dClipPathProperty, is pushed into the a2dDrawingPart to clip the child objects.
354  After setting the style the rendering can start. First the children which have the flag
355  m_prerenderaschild set are rendered. Next the a2dCanvasObject derived object itself is rendered
356  via the virtual DoRender() method. After that the rest of the child objects are rendered.
357  In the end visible properties are rendered, via their a2dCanvasObject, which they may use for displaying
358  themselfs.
359 
360  It is possible to intercept mouse event on a a2dCanvasObject.
361  a2dCanvasObject's receive there events after a hit of the mouse pointer was detected
362  from within a a2dDrawingPart or a2dCanvas object.
363  The lowest object seen from the a2dDrawingPart::ShowObject() receives the events first, and if skipped there
364  and no othere child proesses the event, its parent will get the event etc.
365 
366  \remark When a style (fill or stroke) is set it will be used instead of the layer fill and stroke
367  \remark fill style is inherited by children
368 
369  \ingroup canvasobject
370 */
371 class A2DCANVASDLLEXP a2dCanvasObject: public a2dObject
372 {
373 
374 public:
375 
376  friend class a2dCanvasObjectFilter;
377  friend class a2dCanvasObjectFilterLayerMask;
379 
380  //! used to tell which child object to render and to detect the need for it.
381  struct RenderChild
382  {
383  bool m_prerender: 1; /*!< object marked for pre rendering ( before the parent ) */
384  bool m_postrender: 1; /*!< object marked for post rendering ( after the parent ) */
385  bool m_property: 1; /*!< object marked for property rendering */
386  };
387 
388 
389  DECLARE_EVENT_TABLE()
390 
391  //****************** CONSTRUCTION AND REF COUNTING ******************/
392  /*! \name Construction and reference counting
393  */
394  //\{
395 
396  DECLARE_DYNAMIC_CLASS( a2dCanvasObject )
397 
398  //!constructor called by derived objects
399  a2dCanvasObject( double x = 0 , double y = 0 );
400 
401  //!constructor using reference to existing canvas object
402  a2dCanvasObject( const a2dCanvasObject& other, CloneOptions options, a2dRefMap* refs );
403 
404  inline a2dCanvasObject* TClone( CloneOptions options, a2dRefMap* refs = NULL ) { return ( a2dCanvasObject* ) Clone( options, refs ); }
405 
406  //!destructor called by derived objects
407  virtual ~a2dCanvasObject();
408 
409  a2dHabitat* GetHabitat() const;
410 
411 protected:
412 
413  //!Clone this object and return a pointer to the new object
414  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
415 
416 public:
417 
418  //! After constructing a derived instance from a string, using CreateObject(), the object may need to be filled
419  //! with child objects. This is often by reading more from a file, or by calling this.
420  virtual void Initialize() {}
421 
422  //! returns if this object does have nested objects
423  /*!
424  If the object has children it is nested, but if not it can still have nested objects. This is when
425  a derived a2dCanvasObject does have a2dCanvasObject's members itself.
426  This function should return true if an object does have nested children or members.
427  */
428  virtual bool IsRecursive();
429 
430  //! All direct a2dCanvasObject which are part of this one are made unique
431  /*!
432  The base implementation check all child objects in m_childobjects for being more then single referenced.
433  If not a clone is created in put in place of the one there, leving the origenal to the other objects
434  which owned that child too.
435  Derived a2dCanvasObject must implement this, if it has members which can be multiple referenced.
436  */
437  virtual void MakeReferencesUnique();
438 
439 
440  //\}
441  //**************** END CONSTRUCTION AND REF COUNTING ****************/
442 
443  //****************** AFFINE TRANSFORMATION ******************/
444  /*! \name Affine Transformation
445  Each a2dCanvasObject has an affine Transformation to translate, rotate, scale,
446  and skew it. The Transformations are mutiplied with the transformations of
447  all parent objects up the show object of teh current view.
448  */
449  //\{
450 public:
451 
452  //!Rotates this object clockwise
453  /*!
454  Rotates this object clockwise: If you call <code>Rotate(20); Rotate(10);</code> the
455  absolute rotation will be 30 degrees (if initially rotation was 0 degrees)
456  \see a2dAffineMatrix::Rotate
457  \see SetRotation
458 
459  \param rotation rotate by this angle in degrees
460  */
461  void Rotate( double rotation );
462 
463  //!Sets a rotation of this object
464  /*!
465  Sets in opposite to Rotate the absolute rotation of this object.
466  \see a2dAffineMatrix::SetRotation
467  \see Rotate
468 
469  \param rotation set rotation angle in degrees
470  */
471  void SetRotation( double rotation );
472 
473  //! Scale in x and y ( > zero)
474  /*!
475  \param scalex scalling in X
476  \param scaley scalling in Y
477  */
478  void Scale( double scalex, double scaley );
479 
480  //!Mirrors this object in x or y orientation
481  /*!
482  \param x mirror at X-axis (horizontally orientation)
483  \param y mirror at Y-axis (vertically orientation)
484  */
485  void Mirror( bool x = true, bool y = false );
486 
487  //! Skew in X
488  /*!
489  \param angle angle to skew in X
490  */
491  void SkewX( double angle );
492 
493  //! Skew in Y
494  /*!
495  \param angle angle to skew in Y
496  */
497  void SkewY( double angle );
498 
499  //!get the matrix used to position the object
500  const a2dAffineMatrix& GetTransformMatrix() const { return m_lworld; }
501 
502  a2dAffineMatrix GetTransform() const { return m_lworld; }
503  void SetTransform( a2dAffineMatrix mat = a2dIDENTITY_MATRIX ) { m_lworld = mat; SetPending( true ); }
504 
505  //! Returns the matrix used to position the object
506  /*!
507  \param mat matrix set for transforming the object
508  */
509  void SetTransformMatrix( const a2dAffineMatrix& mat = a2dIDENTITY_MATRIX ) { m_lworld = mat; SetPending( true ); }
510 
511  //!Sets the matrix used to position the object
512  /*!
513  A new matrix will be constructed for transforming this object.
514 
515  \see SetTransformMatrix
516  \see a2dAffineMatrix::a2dAffineMatrix
517 
518  \param xt x translation
519  \param yt y translation
520  \param scalex x scale factor
521  \param scaley y scale factor
522  \param degrees rotation in degrees
523  */
524  void SetTransformMatrix( double xt, double yt, double scalex = 1, double scaley = 1, double degrees = 0 );
525 
526  //!get x position from affine matrix
527  double GetPosX() const { return m_lworld.GetValue( 2, 0 ); }
528 
529  //!get y position from affine matrix
530  double GetPosY() const { return m_lworld.GetValue( 2, 1 ); }
531 
532  //!get position of object
533  a2dPoint2D GetPosXY() const { return a2dPoint2D( m_lworld.GetValue( 2, 0 ), m_lworld.GetValue( 2, 1 ) ); }
534 
535  //!set position to x,y
536  /*! translation is set to x,y, rest of the affine matrix is preserved.
537  \param x x position
538  \param y y position
539  \param restrict use a2dCanvasGlobals->GetRestrictionEngine() to snap position
540  */
541  void SetPosXY( double x, double y, bool restrict = false );
542 
543  //!set position to x,y
544  /*! translation is set to x,y, rest of the affine matrix is preserved.
545  \param pos position
546  */
547  void SetPosXyPoint( const a2dPoint2D& pos )
548  {
549  SetPosXY( pos.m_x, pos.m_y, false );
550  }
551 
552  //!set position to x,y but restricted, returns new values
553  /*! translation is set to x,y, rest of the affine matrix is preserved.
554 
555  Same as SetPoXY(), but returneing restricted values
556 
557  \param x x position
558  \param y y position
559  \return true of point was restricted/changed
560  */
561  bool SetPosXYRestrict( double& x, double& y );
562 
563  //!relative translate the object to position x,y in world coordinates
564  /*! this function may be defined for each derived object, to move other object with this object.
565  it is used internally for dragging and moving objects.
566  \param x delta x for translation
567  \param y delta y for translation
568  */
569  void Translate( double x, double y ) { m_lworld.Translate( x, y ); SetPending( true ); }
570 
571  //!transform the object using the given matrix
572  /*!If the object can not rotate or scale those will be ignored
573  and only translation will take place.
574  If totally transformed it will return true else false.
575  \param tworld matrix for transform
576  */
577  void Transform( const a2dAffineMatrix& tworld ) { m_lworld = tworld * m_lworld; SetPending( true ); }
578 
579  //! reduce matrix to identity
580  /*! Override if possible to eliminate matrix of the object
581  For a non Derived a2dCanvasObject this function multiplies its children
582  with this object matrix, and reduces its own matrix to identity.
583  */
584  virtual bool EliminateMatrix();
585 
586  //\}
587  //****************** END AFFINE TRANSFORMATION ******************/
588 
589 
590  //****************** SNAP AND ALIGMENT ******************/
591  /*! \name Snap and Alignment
592  - Functions to deal with snapping the objects to the grid or other objects.
593  - Alignment of objects using a calculated boundingbox.
594  */
595  //\{
596 
597  //! called from an a2dRestrictionEngine, to restrict vertexes, lines, object to this object.
598  /*!
599  When other object, vertexes or lines are moved (e.g. by a tool), the restriction engine can be set to snap/restrict
600  to neighbouring objects. Here you can define to which parts of those neighbour objects something can be snapped to.
601  For a simple polygon this will be its vertexes, for an ellipse its extremes. For complex objects, it can be anything.
602  For objects with pins, it will be the pins if that is asked for.
603  For the various types of snap, you only implement what is useful for the object.
604 
605  The result of a possible snap point, is stored in a2dRestrictionEngine.
606 
607  The default can snap to:
608  - pins snapToWhat == snapToWhat & a2dRestrictionEngine::snapToPins or a2dRestrictionEngine::snapToPinsUnconnected
609  - the object its position snapToWhat == a2dRestrictionEngine::snapToObjectPos
610  - the vector path conversion with GetAsCanvasVpaths() snapToWhat == a2dRestrictionEngine::snapToObjectVertexes
611  */
612  virtual bool RestrictToObject( a2dIterC& ic, const a2dPoint2D& pointToSnapTo, a2dPoint2D& bestPointSofar, a2dSnapToWhatMask snapToWhat, double thresHoldWorld );
613 
614  //! return a vectorpath indicating on which point/segments the object likes to be snapped.
615  /*!
616  If a drag of this object is on going, one may want to snap itself to other objects, while dragging.
617  This member functions will tell the a2dRestrictionEngine on which points this object likes to snap to others.
618 
619  The default implementation for a2dRestrictionEngine::snapToObjectVertexes tries to convert to a Vpath,
620  and if so, uses that as return, if not, it takes the boundingbox its points.
621  For a2dRestrictionEngine::snapToObjectPos its is the position of the object that is added.
622  For a2dRestrictionEngine::snapToBoundingBox its is the BoundingBox points of the object that are added.
623  */
624  virtual a2dCanvasObjectList* GetSnapVpath( a2dSnapToWhatMask snapToWhat );
625 
626  //! Return a list of points to align object with others.
627  /*!
628  First 4 point are the boundingbox (without pins like objects).
629  Next are the middle points along the boundingbox ( can be made object specific if wanted).
630  Next the baseline for e.g. text.
631  Application specific poinst after that.
632 
633  \remark return value must be deleted.
634  */
635  virtual a2dVertexArray* GetAlignmentPoints();
636 
637  //! calls GetAlignmentPoints()
638  a2dBoundingBox GetAlignmentBbox();
639 
640  //\}
641  //****************** SNAP AND ALIGMENT ******************/
642 
643 
644  //****************** BOUNDING BOX ******************/
645  /*! \name Bounding box
646  Each a2dCanvasObject has a Bounding box for efficient drawing and hit testing.
647  The bounding box is always the bounding box of the vertices. It is extended
648  in pixels or would units to cope for stroke width and decorations like handles.
649  */
650  //\{
651 public:
652 
653  //! flags for calculating boundingbox of derived object
654  /*!
655  Those flags are used in a a2dBboxFlags to indicate different ways of bounding boxes to be calculated.
656 
657  \sa DoGetUnTransformedBbox()
658  \sa GetUnTransformedBbox()
659 
660  \ingroup canvasobject
661 
662  */
664  {
665  a2dCANOBJ_BBOX_NON = 0x0000, //!< return full boundingbox of derived object
666  a2dCANOBJ_BBOX_EDIT = 0x0001, //!< return to contain edit bbox, suitable for editing matrix of object
667  a2dCANOBJ_BBOX_CHILDREN = 0x0002 //!< return to contain children bbox
668  };
669 
670  typedef unsigned int a2dBboxFlags;
671 
672  //!get minimum X of the boundingbox in world coordinates relative to its parents
673  /*!
674  \remark stroke width is not included.
675  */
676  double GetBboxMinX() { return GetBbox().GetMinX(); }
677 
678  //!get minimum Y of the boundingbox in world coordinates relative to its parents
679  /*!
680  \remark stroke width is not included.
681  */
682  double GetBboxMinY() { return GetBbox().GetMinY(); }
683 
684  //!get maximum X of the boundingbox in world coordinates relative to its parents
685  /*!
686  \remark stroke width is not included.
687  */
688  double GetBboxMaxX() { return GetBbox().GetMaxX(); }
689 
690  //!get maximum Y of the boundingbox in world coordinates relative to its parents
691  /*!
692  \remark stroke width is not included.
693  */
694  double GetBboxMaxY() { return GetBbox().GetMaxY(); }
695 
696  //!get width of the boundingbox in world coordinates relative to its parents
697  /*!
698  \remark stroke width is not included.
699  */
700  double GetBboxWidth() { return GetBbox().GetWidth(); }
701 
702  //!get height of the boundingbox in world coordinates relative to its parents
703  /*!
704  \remark stroke width is not included.
705  */
706  double GetBboxHeight() { return GetBbox().GetHeight(); }
707 
708  //!get boundingbox in world coordinates exclusive stroke width relative to its parent
709  /*!
710  \remark stroke width is not included.
711 
712  \remark if the boundingbox is not valid, it will be calculated right now,
713  and to make sure parent object will have the right boundingbox, the object is
714  set pending. That will in the update of a2dCanvasDocument, lead to redrawing and
715  recalculation of this object and parent boundingbox will be recalculated.
716  */
717  a2dBoundingBox& GetBbox();
718 
719  //!Get boundingbox without the affine matrix transform included.
720  /*!
721  Extends as a result of stroke etc. is not included.
722 
723  \param flags default a2dCANOBJ_BBOX_CHILDREN to include child objects in the boundingbox
724  */
725  virtual a2dBoundingBox GetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_CHILDREN ) const;
726 
727  //!Like GetBbox, but it always calculcates the bounding box from scratch
728  /*!
729  This is usefull, when you need the bounding box, but the stored bounding box
730  is not up to date. The rendering system relies on doing this update on its own,
731  because it needs the old bounding box for update area calculation.
732 
733  \param nChildLevels number of child levels to include (0=no childs, 1=direct childs, ...)
734  */
735  a2dBoundingBox GetCalculatedBoundingBox( int nChildLevels );
736 
737  //!first translate boundingbox with cworld and recalculate at new position
738  /*!
739  \remark a2dDrawingPart for the a2dCanvasDocument must be set.
740  \param ic iterative context contains matrix which is applied first to get to absolute position
741  \param withExtend if true boundingbox includes extend in world and pixels ( a2dDrawingPart must be set for m_root )
742  */
743  a2dBoundingBox GetMappedBbox( a2dIterC& ic, bool withExtend = true );
744 
745  //!first translate boundingbox with cworld and recalculate at new position
746  /*!
747  \param cworld matrix applied first to get to absolute position
748  */
749  a2dBoundingBox GetMappedBbox( const a2dAffineMatrix& cworld );
750 
751 
752  //!Get absolute occupied area in the device coordinates.
753  /*!
754  The object its boundingbox in world coordinates is first translated using the matrix cworld.
755  Cworld will normally contain the accumulated matrix to the object with in the
756  object Tree structure.
757 
758  \remark pixel and world extend are included.
759 
760  \param ic iterative context to get matrix which is applied first to get to absolute position
761  \param inflate extra pxiels added on each size, to get rid of double to int rounding problems.
762  */
763  wxRect GetAbsoluteArea( a2dIterC& ic, int inflate = 2 );
764 
765  //!get world extend
766  /*!
767  world extend is the amount that the boundingbox is enlarged because
768  of the stroke its size in case of a stroke with width defined in world coordinates.
769  Other things may be included to get the total extend to the boundingbox of the object.
770 
771  The complete area occupied by a a2dCanvasObject in general is the boundingbox enlarged with
772  the worldExtend + the pixelExtend ( expressed in worldcoordinates ).
773  But if needed one can add to the both extends whatever is needed.
774 
775  \remark worldExtend is calculated while Updating document/object
776  */
777  float GetWorldExtend() const { return m_worldExtend; }
778 
779  //!get pixel extend
780  /*!
781  pixel extend is the amount that the boundingbox is enlarged because
782  of the stroke its size in case of a storke with width defined in pixel coordinates.
783  Other things may be included to get the total extend to the boundingbox of the object.
784 
785  The complete area occupied by a a2dCanvasObject in general is the boundingbox enlarged with
786  the worldExtend + the pixelExtend ( expressed in worldcoordinates ).
787  But if needed one can add to the both extends whatever is needed.
788 
789  \remark pixelExtend is calculated while Updating document/object
790 
791  \remark a trick to be able to use objects complete in pixel coordinates,
792  the boundingbox can be made zero while the pixel extend account for the rest.
793  a2dHandle uses this approach. It will result in a total area that is square.
794  */
795  int GetPixelExtend() const { return m_pixelExtend; }
796 
797  //! used for deciding if the object needs to be rendered against the current clipping area of the active drawer.
798  /*!
799  \param ic iterative context contains matrix which is applied first to get to absolute position
800  \param clipparent clipping status of parent object ( to optimize )
801  */
802  OVERLAP GetClipStatus( a2dIterC& ic, OVERLAP clipparent );
803 
804  //! returns boundingbox clipping object if clipping property is set
805  /*! \sa a2dClipPathProperty
806  \param ic iterative context contains matrix which is applied first to get to absolute position
807  */
808  a2dBoundingBox GetClipBox( a2dIterC& ic );
809 
810  //\}
811  //****************** END BOUNDING BOX ******************/
812 
813  //****************** EVENT PROCESSING AND HIT TESTING ******************/
814  /*! \name Event processing
815  Windows events are routed to the canvas objects under the mouse
816  */
817  //\{
818 public:
819 
820  //! Do hittest on children
821  /*!
822  Ignores this object its m_layer and drawing for the object and properties.
823  Only does a hit test on the children.
824  When hitEvent.m_option & a2dCANOBJHITOPTION_LAYERS is true, iteration on layers is performed,
825  by setting ic.SetPerLayerMode( true ).
826  When hitEvent.m_xyRelToChildren is true, hit test is done relative to child objects, realized by
827  adding inverse matrix of object to the a2dIterC first.
828  The a2dIterC can contain a a2dIterC::SetObjectFilter() but this is only used when not iterating layers.
829  When iterating layers, first normal objects are tested for a hit in reverse order of drawing the layers.
830  So last drawn layer displayed on top, is tested first. At last the edit and tool object are tested.
831 
832  \param ic iterative context, relative to this testing is performed.
833  \param hitEvent contains x,y to test, and other hit info is assembled here
834  \param filterSelectableLayers if true layers should not only be visible but also selectable
835  */
836  a2dCanvasObject* ChildIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent, bool filterSelectableLayers = false );
837 
838  //!If the position (x,y) is within the object return this
839  /*!
840  First a simple bounding box test is done, if that hit is positive, a recursive call on child objects
841  and properties which are normarmally rendered id done.
842  The hit test is in reverse order of the rendering order of the object and its nested child
843  objects.
844 
845  For an accurate hittest one needs to implement DoIsHitWorld() for the derived a2dCanvasObject,
846  in that function one should test the object accurate, and also additional object which are
847  not in the childslist but real members of the derived object.
848  DoIsHitWorld() should return the way the object is hit by filling a2dHitEvent::m_how with the correct info.
849 
850  \param ic contains iteration context
851  \param hitEvent stores hit information
852 
853  \return this pointer if there is a hit on this object or its children or its properties.
854  */
855  a2dCanvasObject* IsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
856 
857  //!set hit flags
858  /*!
859  Based on these flags the object will generate a hit true.
860  \param mask set hit flags in object according to given mask.
861  */
862  void SetHitFlags( a2dCanvasObjectHitFlags mask );
863 
864  //! return hitflags as mask
865  a2dCanvasObjectFlagsMask GetHitFlags() const;
866 
867  //! Hit objects will receive the event
868  /*!
869  The event is first sent to the child objects, and if not processes there,
870  testing for a hit on the object itself is done, and if true a2dEvtHandler::ProcessEvent is called.
871  The function goes through the whole hierarchy, even if event is already processed.
872  It maybe be that other events are generated while iterating over the document.
873 
874  \param ic iteration context
875  \param hitEvent stores hit information
876 
877  \return true if Object (or a child ) did process the event and did not call event.Skip()
878  */
879  virtual bool ProcessCanvasObjectEvent( a2dIterC& ic, a2dHitEvent& hitEvent );
880 
881  //! default handler for mouse events, sent to the object from the a2dDrawingPart.
882  /*!
883  Mouse events are sent to the object when the mouse pointer is hiting the object.
884  The default is used when the object is in edit mode. Else it will detect
885  if the special object tip property named __OBJECTTIP__ is available, and switch
886  it on or off when the mouse eneter or leaves the object.
887  */
888  void OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event );
889 
890  //! default handler for character events
891  void OnChar( wxKeyEvent& event );
892 
893  //! called on Right Down by default.
894  void OnPopUpEvent( a2dCanvasObjectMouseEvent& event );
895 
896  //! called when the mouse enters the object
897  void OnEnterObject( a2dCanvasObjectMouseEvent& event );
898 
899  //! called when the mouse leaves the object
900  void OnLeaveObject( a2dCanvasObjectMouseEvent& event );
901 
902  //! object with mouse in flag set, will sent a leave event, and set flag off.
903  //! recursive for children.
904  void LeaveInObjects( a2dIterC& ic, a2dHitEvent& hitEvent );
905 
906  //! called if a mouse event occured on a child object, that is a handle
907  void OnHandleEvent( a2dHandleMouseEvent& event );
908 
909 protected:
910 
911  // hit on derived object
912  bool LocalHit( a2dIterC& ic, a2dHitEvent& hitEvent );
913 
914  //!This is an internal function used by IsHitWorld(). Don't use it directly.
915  a2dCanvasObject* IsHitWorldChildObjects( a2dIterC& ic, RenderChild& whichchilds, a2dHitEvent& hitEvent );
916 
917  //!Does hit test on the object (exclusif child objects)
918  /*!
919  DoIsHitWorld() should return the way the object is hit by filling a2dHitEvent::m_how with the correct info.
920 
921  \param ic iterative context ( e.g. current transform WITH the local transform applied )
922  \param hitEvent stores hit information
923  \return true if hit
924  */
925  virtual bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
926 
927  //!This is an internal function used by IsHitWorldChildObjects(). Don't use it directly.
928  a2dCanvasObject* HitChildObjectsOneLayer( a2dIterC& ic, RenderChild& whichchilds, a2dHitEvent& hitEvent );
929 
930  //\}
931  //****************** END EVENT PROECSSING AND HIT TESTING ******************/
932 
933  //****************** CHILD TREE AND DOCUMENT STRUCTURE ******************/
934  /*! \name Child tree and document structure
935  Every a2dCanvasObject has a list of child objects. One a2dCanvasObject can
936  be element of multiple child lists and can thus have multiple parents.
937  Reference counting is used to control the life time of a a2dCanvasObject.
938  Because a a2dCanvasObject can have multiple parents, it has no parent pointer.
939  A a2dCanvasObject has a pointer to the a2dCanvasDocument it belongs to.
940  */
941  //\{
942 public:
943 
944  //!get a2dCanvasDocument of the object.
945  /*!
946  Root (a2dCanvasDocument) needs to be known to each object for the following reasons:
947  - It is used to inform the document that there are pending objects in the document.
948  - To reach the layer setup of the document.
949  - To reach the command processor of the document, which is used to submit commands to,
950  that can be undone if needed.
951  */
952  inline a2dDrawing* GetRoot() const { return m_root; }
953 
954  //! Sets this object to a a2dCanvasDocument.
955  /*!
956  \param root set the a2dCanvasDocument for this object to this (if appropriate recursive)
957  \param recurse default true, which uses a2dWalker_SetCanvasDocument for doing the
958  same recursive for nested object and nested object in derived classes.
959  */
960  void SetRoot( a2dDrawing* root, bool recurse = true );
961 
962  //!prepend a a2dCanvasObject to the childobjects
963  void Prepend( a2dCanvasObject* obj );
964 
965  //!append a a2dCanvasObject to the childobjects
966  void Append( a2dCanvasObject* obj );
967 
968  //!insert a a2dCanvasObject to the childobjects
969  void Insert( size_t before, a2dCanvasObject* obj, bool ignoreReleased = true );
970 
971  //!get the list where the child objects are stored in.
972  /*!
973  \return A pointer to the childlist. If there is no child list yet, it returns wxNullCanvasObjectList.
974 
975  \remark wxNullCanvasObjectList has no children and therefore one can use
976  GetChildObjectList()->GetCount() to test for children.
977  */
978  a2dCanvasObjectList* GetChildObjectList();
979  const a2dCanvasObjectList* GetChildObjectList() const;
980 
981  //!create and get the list where the child objects are stored in.
982  /*!
983  If there is no childlist yet (wxNullCanvasObjectList), a new childlist will be created.
984  Else the existing one will be returned.
985 
986  \return A pointer to the childlist.
987  */
988  a2dCanvasObjectList* CreateChildObjectList();
989 
990  //! get number of child objects
991  /*!
992  \return number of child objects
993  */
994  unsigned int GetChildObjectsCount() const;
995 
996  //!object with the same given mask are made into a group.
997  /*!
998  \param mask: mask for objects to assemble for creating a group of child objects
999  \param createref: next to a new a2dCanvasObject, create a reference to the new object.
1000  \return return newly created object only if objects where found else NULL
1001  */
1002  a2dCanvasObject* CreateHierarchy( a2dCanvasObjectFlagsMask mask, bool createref = true );
1003 
1004  //! move childs of childs and members which have hierarchy one level up to this object its child list.
1005  /*!
1006  The base implementation takes child object in m_childobjects to the parent object.
1007  The child object are transformed by the parent its transform.
1008  */
1009  virtual void RemoveHierarchy();
1010 
1011  //!remove the given object from the childobjects
1012  /*! The object will be Realeased.
1013  if its refcount is 0 it will be deleted else its refcount decremented.
1014 
1015  \param obj object to release
1016  \param backwards start at the end
1017  \param all if true remove all references to object
1018  \param now if true remove all references to object now!, else only delete flag is set,
1019  and Update() takes care of it.
1020  \param undoCommands when object is connected to othere, use commands do be able to undo.
1021 
1022  \return number of released objects
1023  */
1024  int ReleaseChild( a2dCanvasObject* obj, bool backwards = false, bool all = false, bool now = false, bool undoCommands = false );
1025 
1026 
1027  //!removes and release only from the childobjects the objects with the given mask
1028  /*!
1029  \return true if some object were released
1030  */
1031  bool ReleaseChildObjects( a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::ALL );
1032 
1033  //!returns index of the given a2dCanvasObject in this childobjects
1034  int IndexOf( a2dCanvasObject* obj ) const;
1035 
1036  //!return the object which fits the filter.
1037  /*!
1038  \param objectname object with this name to search for
1039  \param classname If classname is empty it collects all objects else only object with this class name.
1040  \param mask object must have this mask.
1041  \param propid if a property id is given, the object must have a property with this id
1042  \param valueAsString StringValueRepresentation of the property that is required (if not empty).
1043  \param id GetUniqueSerializationId() should be this unless 0
1044  */
1045  a2dCanvasObject* Find( const wxString& objectname, const wxString& classname = wxT( "" ),
1046  a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::ALL , const a2dPropertyId* propid = NULL, const wxString& valueAsString = wxT( "" ),
1047  wxUint32 id = 0 ) const;
1048 
1049  //!return the child object if it is part of this object
1050  /*!
1051  \param obj object to search for
1052  */
1053  a2dCanvasObject* Find( a2dCanvasObject* obj ) const;
1054 
1055  //! the object with the given name is released and switched in place to newobject
1056  /*!
1057  \return true if object was found else false
1058  */
1059  bool SwitchChildNamed( const wxString& objectname, a2dCanvasObject* newobject );
1060 
1061  //!Copy objects with the right conditions to the total list.
1062  /*!
1063  \param total list of object found (may already contain elements found in earlier call)
1064  \param classname If classname is empty it collects all objects else only object with this class name.
1065  \param mask object must have this mask.
1066  \param id If property id is set the object needs to have this property.
1067  \param bbox only find objects within this box.
1068 
1069  \remark only searches this object and its children, not deeper.
1070 
1071  \return number of objects found
1072  */
1073  int CollectObjects( a2dCanvasObjectList* total,
1074  const wxString& classname = wxT( "" ),
1076  const a2dPropertyId* id = 0,
1077  const a2dBoundingBox& bbox = wxNonValidBbox
1078  ) const;
1079 
1080  //\}
1081  //****************** END CHILD TREE AND DOCUMENT STRUCTURE ******************/
1082 
1083  //****************** UPDATE AND PENDING ******************/
1084  /*! \name Update and Pending
1085  */
1086  //\{
1087 public:
1088  //! Various mode flags for Update
1089  /*! It doesn't make sense to bit-or these, but these are bitflags anyway
1090  for quick multi-testing (e.g. ( mode & (mode1|mode2|mode3) ) */
1092  {
1093  /*! saves old valid boundingbox as boundingbox property */
1094  update_save = 0x0001,
1095 
1096  /*! includes boundingbox properties in object its boundingbox */
1097  update_includebboxprop = 0x0002,
1098 
1099  updatemask_countObjects = 0x0004,
1100 
1101  /*! update_save and update_includebboxprop combined */
1102  updatemask_save_includebboxprop =
1103  update_includebboxprop |
1104  update_save,
1105 
1106  //! All updates of these modes force an update (e.g. update non-pending valid bounding boxes)
1107  updatemask_force =
1108  update_includebboxprop |
1109  update_save,
1110 
1111  //! object with invalid boundingbox or pending objects their boundingbix is recalculated.
1112  //! When boundingbox properties are found, theye will be include in the box.
1113  updatemask_normal =
1114  update_includebboxprop,
1115 
1116  updatemask_force_and_count =
1117  update_includebboxprop |
1118  updatemask_countObjects |
1119  update_save,
1120 
1121  };
1122 
1123  //! child objects which have relesed flag set, are removed as child, called recursive on rleased child objects.
1124  bool RemoveReleased();
1125 
1126  //! Update the state of the object according to its current position etc.
1127  /*!
1128  This usually does the following:
1129  - calculates the new bounding box in world coordinates relative to parents.
1130  - Release childs that have m_release set
1131 
1132  This function is usually called in a2dCanvasDocument::AddPendingUpdatesOldNew between adding
1133  the old and the new bounding box to the pending area.
1134  You should NOT do any change here that issues commands to the command processor,
1135  because such commands wouldn't have a proper context. Such things should be
1136  done in UpdateImmediate.
1137  Other things like updating the cache data need to be done here.
1138 
1139  Takes into account associated child, properties and derived objects.
1140  If a2dCanvasObject::UpdateMode = updatemask_force all boundingboxes are invalidated and recalculated,
1141  else it only recalculates if invalid or one of the children is invalid.
1142 
1143  This function calls DoUpdate(), when needed. The idea is to minimize the number of recalculated boudingboxes.
1144  So if an object is setpending or a child became pending, the boudingbox needs to be recalculated,
1145  but since this is a combination of property, child and derived object boundingboxes, this is optimized.
1146 
1147  \return true if the bounding box did change and the parent has to recalculate
1148 
1149 
1150  \remark The object its layers is set in the layersetup as being available in the document.
1151  \remark if overridden in derived class, also call baseclass Update
1152  \remark in derived classes DoUpdate() should be implemented to at least calculate the boundingbox of the object
1153  without children in m_childobjects, but including any referenced objects in the derived objects. Like arrow point
1154  objects on a line or polyline.
1155  */
1156  virtual bool Update( UpdateMode mode );
1157 
1158  //!is this object pending for update?
1159  /*!(overruled by parent object in some cases during rendering)
1160  \remark set the object its pending flag and inform root about this
1161  */
1162  bool GetPending() const { return m_flags.m_pending; }
1163 
1164  //!set this object pending for update
1165  /*!
1166  This flag is set when an object has changed, which means that it needs to be redrawn.
1167  Since an object can be Referenced also, it can be drawn at several positions.
1168  Therefore the redrawing needs to be done indirectly from the top, and for each a2dDrawingPart
1169  displaying the object. In general old and new boundingbox areas are updated on the display.
1170  \li Step 1 add pending objects occupied areas to drawer.
1171  \li Step 2 The new boundingbox is calculated.
1172  \li Step 3 add pending objects occupied areas to draweronce more.
1173  \li Step 4 reset all pending flags for objects.
1174 
1175  \remark Does also inform the a2dCanvasDocument that there are pending objects.
1176  \remark If because of this object becoming pending other objects should become pending also,
1177  one should override this function to set those other objects pending.
1178  \remark If redefined in derived object always call base also.
1179 
1180  \sa DependencyPending()
1181 
1182  \param pending if true set object pending
1183 
1184  */
1185  virtual void SetPending( bool pending );
1186 
1187  //!search objects ( if nested recursive ) that have the pending flag Set
1188  /*!
1189  And add the current absolute boudingbox of the object to the pendingareas in the active
1190  a2dDrawingPart for update/redrawing that area later. After a this normally the boundingbox of
1191  this object will be recalculated in a2dCanvasObject::Update(), followed by one more call to this function
1192  here, in order to also redraw the new boundingbox its area.
1193  When all pending areas are combined to a minimum in a2dDrawingPart, the areas will be redrawn.
1194 
1195  The area currently occupied by the object in the active a2dDrawingPart is added for update in case
1196  the object was pending. Next to that the a2dDrawingPart is informed that the object its layer
1197  is available in the document and should be rendered.
1198  In case the object will be released ( m_Release is set ), the a2dDrawingPart::SetLayerCheck( objectlayer )
1199  is called, in order to recheck if there or still object on that layer as seen from that view.
1200 
1201  \remark this method is fast if many objects need an update.
1202  \remark You are responsible for setting and resetting the pending flag.
1203  \remark Not valid boundingbox in the object, means the object and its children will be ignored.
1204 
1205  \param ic iterative context, contains cumulative matrix for transforming object to absolute position
1206  */
1207  void AddPending( a2dIterC& ic );
1208 
1209 
1210  //!called by to check if this object becomes pending as a result of other objects
1211  /*!
1212  You can Override DependencyPending() to set your object pending, when another object was
1213  set pending.
1214  */
1215  virtual void DependencyPending( a2dWalkerIOHandler* WXUNUSED( handler ) );
1216 
1217  //! call this when a a2dCommands should result in extra commands, to become part of a parent a2dCommandGroup.
1218  /*!
1219  In some cases a command (e.g. delete an object), needs to be followed by extra commands. For example to disconnect other objects.
1220 
1221  \param parent the parent of this object instance.
1222  \param command the command for which the dependcies need to be found.
1223  */
1224  virtual void DependentCommands( a2dCanvasObject* parent, a2dCommand* command );
1225 
1226  //****************** END UPDATE AND PENDING ******************/
1227 
1228  //****************** RENDERING AND STYLE ******************/
1229  /*! \name Rendering and style
1230  */
1231  //\{
1232 public:
1233 
1234  //!Render this object to the active a2dDrawingPart
1235  /*!
1236 
1237  This function is called via the a2dCanvasDocument class or its nested children.
1238  The active a2dDrawingPart which is set for the document is used to draw
1239  to (either on its buffer or directly on the device)
1240  All rendering goes through this function to be able to render specific things
1241  in the base class first (like a2dCanvasObject its properties.)
1242  Somewhere internal DoRender will be called to really render the derived object itself.
1243  Next to that nested a2dCanvasObject's will be rendered too.
1244 
1245  If wanted only the canvas objects with a certain mask set, will be rendered.
1246  Mask example: Checking visible and selected
1247 
1248  use: mask=(a2dCANOBJ_VISIBLE | a2dCANOBJ_SELECTED)
1249 
1250  \remark
1251  Do not use directly from outside the containing document of this object.
1252  Normally only used directly in derived classes \sa a2dCanvasDocument
1253 
1254  \remark The active clipping rectangle is set within the active drawer.
1255  It can be used to decide which parts of the object need to be re-drawn or not.
1256  This may speed up drawing in sepcial cases, but in general the active a2dDrawingPart, simply
1257  clips all that is drawn on it to active clipping rectangle.
1258  The fact that the object is called to redrawn itself, is not decided here, instead it is part
1259  of the pending object mechanism. Which uses the object its boundingbox to request redrawing.
1260 
1261  \remark Normally an object will be rendered if the given layer is equal to the object its layer.
1262 
1263  \remark wxLAYER_ALL has a special meaning.
1264  If the given input layer is wxLAYER_ALL, then the m_layer of objects is not tested.
1265  So the child objects their own layer settings are ignored/not checked in that case.
1266  All child objects are drawn at once, still the style of the layers settings is used when needed.
1267 
1268  If the flag "m_flags.m_childrenOnSameLayer" is set, a new iteration over layers will take place.
1269  The effect is that all children will be drawn at once ( not only objects on the given layer ),
1270  but the order of the layers will be taken into account to draw the children.
1271  If the flag "m_flags.m_childrenOnSameLayer" is NOT set, a new iteration on layers is NOT done,
1272  and only the objects on the given layer will be drawn.
1273 
1274  \remark ic.GetPerLayerMode() is true, then only ic.GetLayer() is rendered, which can not be wxLAYER_ALL.
1275 
1276  \param ic iteration context (has a2dDrawingPart accumulative matrix to calculate absolute position of the object)
1277  \param clipparent this must be the clip status of parent object, it is used to optimize drawing speed.
1278  e.g If parent is completely within the current clipping rectangle of the a2dDrawingPart,
1279  there is no need to check child objects.
1280  */
1281  virtual void Render( a2dIterC& ic, OVERLAP clipparent );
1282 
1283  //! update the transform matrix for objects with property 'PROPID_viewDependent'
1284  /*!
1285  will recursive call the UpdateViewDependentObjects routines of all the child objects (TODO for optimize: with flag 'm_childpixelsize=true').
1286  \param ic iteration context (has a2dDrawingPart accumulative matrix to calculate absolute position of the object)
1287 
1288  \remark Check all child objects with (TODO for optimize: flag 'm_childpixelsize=true').
1289  */
1290  void UpdateViewDependentObjects( a2dIterC& ic );
1291 
1292  //! called by Render() if m_flags.m_HighLight is set
1293  /*!
1294  \param ic iteration context (has a2dDrawingPart accumulative matrix to calculate absolute position of the object)
1295  */
1296  virtual void DrawHighLighted( a2dIterC& ic );
1297 
1298  //!set if this object will visible (be rendered or not)
1299  /*!(overruled by parent object in some cases during rendering)
1300  \remark set the object its pending flag and inform root about this
1301  \param visible if true set object visible
1302  */
1303  void SetVisible( bool visible )
1304  {
1305  if( m_flags.m_visible != visible ) { m_flags.m_visible = visible; SetPending( true ); }
1306  }
1307 
1308  //!get visibility (rendering depends on layer settings also)
1309  bool GetVisible() const { return m_flags.m_visible; }
1310 
1311  //!get visibility (rendering depends on layer settings also)
1312  /*!
1313  Alias for GetVisible
1314  \see GetVisible
1315  */
1316  inline bool IsVisible() const { return GetVisible(); }
1317 
1318  //!Set a fill for the object which will be used instead of the layer fill
1319  /*!
1320  The fill is for filling the object.
1321  Use a2dCanvasNullFill or 0 to remove the fill from a object.
1322  Use a2dTRANSPARENT_FILL to not fill the object.
1323  \remark m_flags.m_filled flag overrules the fill to fill TRANSPARENT
1324  \remark inheritance to children of object
1325  \remark object is free to use style or not
1326  \remark a style resulting in wxLAYER_FILL means property will be removed
1327  \sa a2dStyleProperty
1328  */
1329  void SetFill( const a2dFill& fill );
1330 
1331  a2dFill GetFill() const;
1332 
1333  //!Set a fill color for the object which will be used instead of the layer fill
1334  /*!
1335  \param fillcolor color to fill object with
1336  \param style style for one colour fill
1337  \remark creates a a2dOneColourFill internal
1338  \remark inheritance to children of object
1339  \remark object is free to use style or not
1340  \sa a2dStyleProperty
1341  \sa a2dOneColourFill
1342  */
1343  void SetFill( const wxColour& fillcolor, a2dFillStyle style = a2dFILL_SOLID );
1344 
1345  //!Set a fill color for the object which will be used instead of the layer fill
1346  /*!
1347  \param fillcolor color to fill object with
1348  \param fillcolor2 color to fill object with
1349  \param style style for one colour fill
1350  \remark inheritance to children of object
1351  \remark object is free to use style or not
1352  \sa a2dStyleProperty
1353  \sa a2dTwoColourFill
1354  */
1355  void SetFill( const wxColour& fillcolor, const wxColour& fillcolor2, a2dFillStyle style = a2dFILL_SOLID );
1356 
1357  //! set first colour of fill
1358  void SetFillColour( const wxColour& colour );
1359 
1360  //! get first colour of fill
1361  wxColour GetFillColour() const;
1362 
1363  //!Set a stroke for the object which will be used instead of the layer stroke
1364  /*!
1365  \param strokecolor color to stroke object with
1366  \param width width of stroke in world coordinates
1367  \param style style for one colour stroke
1368  \remark a style resulting in wxLAYER_STROKE means property will be removed
1369  \remark inheritance to children of object
1370  \remark object is free to use style or not
1371  \sa a2dStyleProperty
1372  */
1373  void SetStroke( const wxColour& strokecolor, double width = 0, a2dStrokeStyle style = a2dSTROKE_SOLID );
1374 
1375  //!Set a stroke for the object which will be used instead of the layer stroke
1376  /*!
1377  \param strokecolor color to stroke object with
1378  \param width width of stroke in device coordinates
1379  \param style style for one colour stroke
1380  \remark creates a a2dOneColourStroke property internal
1381  \remark inheritance to children of object
1382  \remark object is free to use style or not
1383  \sa a2dStyleProperty
1384  */
1385  void SetStroke( const wxColour& strokecolor, int width , a2dStrokeStyle style = a2dSTROKE_SOLID );
1386 
1387  //! Set stroke using pointer to a stroke
1388  /*!
1389  The stroke is for drawing outlines of the object.
1390  Use a2dNullStroke to remove the stroke from a object.
1391  Use a2dTRANSPARENT_STROKE to not fill the object.
1392  \remark a style resulting in wxLAYER_STROKE means property will be removed
1393  */
1394  void SetStroke( const a2dStroke& stroke );
1395 
1396  a2dStroke GetStroke() const;
1397 
1398  //! set first colour of stroke
1399  void SetStrokeColour( const wxColour& colour );
1400 
1401  //! get first colour of stroke
1402  wxColour GetStrokeColour() const;
1403 
1404  //!set the Contour width of the shape
1405  /*!
1406  Next to the stroke width one can sometimes set a contour width e.g. a circular donut.
1407  */
1408  virtual void SetContourWidth( double WXUNUSED( width ) ) {}
1409 
1410  //!get the Contour width of the shape
1411  virtual double GetContourWidth() const { return 0; }
1412 
1413  //!sets fill and stroke of object to a2dDrawingPart
1414  /*!
1415  sets local fill and pen into a2dDrawingPart if available, else
1416  they will be set on basis of the layer index.
1417  \sa a2dDrawingPart
1418  */
1419  void SetDrawerStyle( a2dIterC& ic, a2dStyleProperty* style );
1420 
1421  //!if set children are rendered on the same layer as this object.
1422  /*!
1423  Children will be rendered at the same moment as the object itself, the effect
1424  is that they appear at the same layer.
1425  The rendering style of the children will be based on their own layer id's or style properties.
1426 
1427  \param samelayer if true render children on same layer
1428  */
1429  inline void SetChildrenOnSameLayer( bool samelayer ) { SetPending( true ); m_flags.m_childrenOnSameLayer = samelayer; }
1430 
1431  //!are children rendered on the same layer as this object?
1432  inline bool GetChildrenOnSameLayer() const { return m_flags.m_childrenOnSameLayer; }
1433 
1434  //!set the object view dependent and maybe process all children to set these flags
1435  /*!
1436  \param aView view for adding next properties on this object and maybe its children.
1437  \param viewdependent if true, then add property 'PROPID_viewDependent' to objects
1438  that are depending on 'aView' view when it comes to size.
1439  Else to remove this property.
1440  \param viewspecific if true then add property 'PROPID_viewSpecific' to objects
1441  that are only visible on 'aView' view.
1442  Else to remove this property to make visible on all views.
1443  \param onlyinternalarea removing scale for children
1444  \param deep if true then set flags for all nested children objects
1445  */
1446  void SetViewDependent(a2dDrawingPart* aView, bool viewdependent, bool viewspecific = false, bool onlyinternalarea = false, bool deep = false );
1447 
1448  //! How a child is placed towards its parent object.
1449  /*!
1450  If set true this object as a child object is placed only relative to the position of the
1451  parent object. Rotation and scaling of parent object are ignored.
1452  */
1453  inline void SetChildOnlyTranslate( bool onlytranslate ) { SetPending( true ); m_flags.m_ChildOnlyTranslate = onlytranslate; }
1454 
1455  //!are children rendered using just the translation of the parent or also rotation and scale.
1456  inline bool GetChildOnlyTranslate() const { return m_flags.m_ChildOnlyTranslate; }
1457 
1458  //! If set, this object has a higher priority in rendering than other children objects.
1459  /*!
1460  This method sets a priority in rendering: All children which have set
1461  the property m_prerenderaschild will be rendered before other children objects.
1462 
1463  As default the a2dCanvasObject has no priority in rendering, you have to
1464  set this property to true, if you want prerendering.
1465 
1466  \param prerender <code>true</code> to prerender this object, else <code>false</code>
1467 
1468  */
1469  inline void SetPreRenderAsChild( bool prerender ) { SetPending( true ); m_flags.m_prerenderaschild = prerender; }
1470 
1471  //! Returns if this object should be rendered before other children objects.
1472  inline bool GetPreRenderAsChild() const { return m_flags.m_prerenderaschild; }
1473 
1474  //!is the object filled flag set
1475  //!Rendering is only outline when set.
1476  bool GetFilled() const { return m_flags.m_filled; }
1477 
1478  //!set the filled flag to render only outlines
1479  /*!Rendering is only outline when set.
1480  \remark set the object its pending flag and inform root about this
1481  \param filled if true set object filled
1482  */
1483  void SetFilled( bool filled ) { if ( m_flags.m_filled != filled ) SetPending( true ); m_flags.m_filled = filled; }
1484 
1485  //! If True shadow object is visible (if property is there)
1486  bool GetShowShadow() const { return m_flags.m_showshadow; }
1487 
1488  //! If True shadow object is visible (if property is there)
1489  void SetShowShadow( bool showshadow ) { m_flags.m_showshadow = showshadow; }
1490 
1491  //! see SetResizeOnChildBox()
1492  bool GetResizeOnChildBox() const { return m_flags.m_resizeToChilds; }
1493 
1494  //! If True resize to child boundingbox
1495  /*!
1496  In a2dCanvasObject::Update() a wxEVT_CANVASOBJECT_RESIZE_EVENT will be sent to this object.
1497  Default there is no handler for the event.
1498  */
1499  void SetResizeOnChildBox( bool resizeToChilds ) { m_flags.m_resizeToChilds = resizeToChilds; }
1500 
1501  //!quick way to get the style property containing Shadow property
1502  /*! style is maintained within an object as a a2dStyleProperty called __SHADOW__
1503  \remark object is free to use style or not
1504  \sa a2dShadowStyleProperty
1505  */
1506  const a2dShadowStyleProperty* GetShadowStyle() const ;
1507 
1508  void CallDoRender( a2dIterC& ic, OVERLAP clipparent )
1509  {
1510  DoRender( ic, clipparent );
1511  }
1512 
1513  //!when wanting to traverse hierarchy what level is down here.
1514  virtual a2dCanvasObject* PushInto( a2dCanvasObject* parent );
1515 
1516  virtual a2dCanvasObject* GetCommandProcessor() { return NULL; }
1517  virtual a2dLayers* GetLayerSetup() { return NULL; }
1518 
1519 protected:
1520 
1521  const a2dFill& MX_GetFill() const;
1522  void MX_SetFill( const a2dFill& value );
1523  const a2dStroke& MX_GetStroke() const;
1524  void MX_SetStroke( const a2dStroke& value );
1525 
1526 
1527  //!render derived object
1528  /*!if the object has sub objects (apart from the childobject which are handled here),
1529  those subobject most rendered by iterating on layer when needed/wanted, simular to child objects.
1530  We do not iterate here, since that is only needed if indeed there or subobjects.
1531  This will be know in a "wxDerivedCanvasObject DoRender".
1532 
1533  SO parent objects that call this function, must:
1534 
1535  \li 1- clip object against area to redraw.
1536  \li 2- iterate on layers when needed.
1537 
1538  A a2dCanvasObject is rendered as a + (plus sign) when there or no children.
1539 
1540  */
1541  virtual void DoRender( a2dIterC& WXUNUSED( ic ), OVERLAP WXUNUSED( clipparent ) );
1542 
1543  //! update transform matrix klion: I'm not sure that this function necessary as virtual
1544  virtual void DoUpdateViewDependentTransform( a2dIterC& ic );
1545 
1546  //! update derived objects
1547  virtual void DoUpdateViewDependentObjects( a2dIterC& WXUNUSED( ic ) );
1548 
1549  //! render only the child objects
1550  /*!
1551  \param ic iteration context (has a2dDrawingPart accumulative matrix to calculate absolute position of the object)
1552  \param whichchilds defined which childs will be rendered now, and detects while rendering other types.
1553  \param clipparent this must be the clip status of parent object.
1554  */
1555  virtual void RenderChildObjects( a2dIterC& ic, RenderChild& whichchilds, OVERLAP clipparent );
1556 
1557  //!to render the child objects
1558  /*!
1559  \param ic iteration context (hasa2dDrawingPart accumulative matrix to calculate absolute position of the object)
1560  \param whichchilds defined which childs will be rendered now, and detects while rendering other types.
1561  \param clipparent this must be the clip status of parent object.
1562  */
1563  virtual void RenderChildObjectsOneLayer( a2dIterC& ic, RenderChild& whichchilds, OVERLAP clipparent );
1564 
1565  //\}
1566  //****************** END RENDERING AND STYLE ******************/
1567 
1568  //****************** EDITING AND HIGHLIGHTING ******************/
1569  /*! \name Editing and Highlighting
1570  */
1571  //\{
1572 public:
1573 
1574  //!Sets if this object may be edited
1575  /*!
1576  If editable is set to <code>true</code> the object may be edited by an user.
1577  The default behaviour of this object is to allow modifications (editable).
1578 
1579  \param editable <code>true</code> to allow modifications, else <code>false</code>
1580  */
1581  inline void SetEditable( bool editable ) { m_flags.m_editable = editable; }
1582 
1583  //!get if the object may be edited
1584  inline bool GetEditable() const { return m_flags.m_editable; }
1585 
1586  //! Set object to fixed style ot not.
1587  inline void SetFixedStyle( bool fixedStyle ) { m_flags.m_fixedStyle = fixedStyle; }
1588 
1589  //! Get object fixed style setting
1590  inline bool GetFixedStyle() const { return m_flags.m_fixedStyle; }
1591 
1592  //!get if the object may be edited
1593  /*!
1594  Alias for GetEditable
1595  \see GetEditable
1596  */
1597  inline bool IsEditable() const { return GetEditable(); }
1598 
1599  //!is the object selected flag set
1600  /*!
1601  Rendering is different when set, it will use a special layer in this case.
1602  */
1603  bool GetSelected() const { return m_flags.m_selected;}
1604 
1605  //!Is the object selected flag set
1606  /*!
1607  Alias for GetSelected
1608  \see GetSelected
1609  */
1610  bool IsSelected() const { return GetSelected(); }
1611 
1612  //!Set the object selected flag if allowed
1613  /*!
1614  When set the second rendering cycle from the document a2dCanvasDocument::Render() etc.
1615  will draw this object selected.
1616 
1617  \remark sets the object its pending flag and inform root about this
1618  \param selected if true set object selected
1619  */
1620  void SetSelected( bool selected )
1621  {
1622  if ( m_flags.m_selectable ) { if( m_flags.m_selected != selected ) SetPending( true ); m_flags.m_selected = selected;}
1623  }
1624 
1625  //!is the object selected2 flag set
1626  /*!
1627  Rendering is different when set, it will use a special layer in this case.
1628  */
1629  bool GetSelected2() const { return m_flags.m_selected2; }
1630 
1631  //!Set the object selected2 flag if allowed
1632  /*!
1633  When set the second rendering cycle from the document a2dCanvasDocument::Render() etc.
1634  will draw this object selected with select2 color.
1635 
1636  \remark sets the object its pending flag and inform root about this
1637  \param selected if true set object selected
1638  */
1639  void SetSelected2( bool selected )
1640  {
1641  if ( m_flags.m_selectable ) { if( m_flags.m_selected2 != selected ) SetPending( true ); m_flags.m_selected2 = selected;}
1642  }
1643 
1644  //!is the object selectable flag set
1645  /*!
1646  \return <code>true</code> if object is selectable, else <code>false</code>
1647  */
1648  bool GetSelectable() const { return m_flags.m_selectable; }
1649 
1650  //! Is the object selectable flag set
1651  /*!
1652  Alias for GetSelectable
1653  \see GetSelectable
1654  */
1655  bool IsSelectable() const { return GetSelectable(); }
1656 
1657  //!Allows to select this object.
1658  /*!
1659  If selectable is set to <code>true</code> the object may be selected by an user.
1660  The default behaviour of this object is to allow selection.
1661 
1662  \param selectable <code>true</code> to allow selection, else <code>false</code>
1663  */
1664  void SetSelectable( bool selectable ) { m_flags.m_selectable = selectable; }
1665 
1666  //!Sets if this object may be dragged
1667  /*!
1668  If draggable is set to <code>true</code> the object may be dragged by an user.
1669  The default behaviour of this object is to allow dragg-operations.
1670 
1671  \param draggable <code>true</code> to allow selection, else <code>false</code>
1672  */
1673  inline void SetDraggable( bool draggable ) { m_flags.m_draggable = draggable; }
1674 
1675  //!get if the object can be dragged
1676  inline bool GetDraggable() const { return m_flags.m_draggable; }
1677 
1678  //!get if the object can be dragged
1679  /*!
1680  Alias for GetDraggable
1681  \see GetDraggable
1682  */
1683  inline bool IsDraggable() const { return GetDraggable(); }
1684 
1685  //!is snap flag set?
1686  bool GetSnap() const { return m_flags.m_snap; }
1687 
1688  //!Sets snap flag
1689  /*!
1690  If snap is set to <code>true</code> this object is snapped by
1691  the restriction engine of a2dCanvasGlobal, when it is edited/moved etc.
1692 
1693  \see Restrict
1694  */
1695  void SetSnap( bool snap ) { m_flags.m_snap = snap; }
1696 
1697  //!Sets snap_to flag
1698  /*!
1699  If snap is set to <code>true</code> others objects may snap to this object by
1700  the restriction engine of a2dCanvasGlobal.
1701 
1702  \see Restrict
1703  */
1704  void SetSnapTo( bool snap ) { m_flags.m_snap_to = snap; }
1705 
1706  //!is snap_to flag set?
1707  bool GetSnapTo() const { return m_flags.m_snap_to; }
1708 
1709  //! you may use it to modify rendering of the object depending on setting
1710  /*!
1711  Override this function to define a way to modify rendering for a derived object.
1712 
1713  e.g. When hiting an object you could modify the rendering to notify it to the user.
1714  */
1715  virtual void SetMode( int WXUNUSED( mode ) ) {}
1716 
1717  //! get the rendering mode of the object.
1718  virtual int GetMode() const { return 0; }
1719 
1720  //! create an editcopy and initialize editing of the editcopy
1721  /*! This is called for an original object and creates an editcopy object.
1722 
1723  Calls DoStartEdit() in the end
1724 
1725  \param tool tool from which this function is called. Currently this is the a2dObjectEditTool
1726  \param editmode tobe used in derived object to switch between different way of editing
1727  ( 0 means matrix mode of a2dCanvasObject )
1728  \param editstyle style of editing e.g. filled and stroked or with a wire frame.
1729  */
1730  virtual a2dCanvasObject* StartEdit( a2dBaseTool* tool, wxUint16 editmode, wxEditStyle editstyle = wxEDITSTYLE_COPY, a2dRefMap* refs = NULL );
1731 
1732  //! cleanup an editcopy object
1733  /*!
1734  This will Remove the editcopy from its parent.
1735  If editstyle is not wxEDITSTYLE_COPY, EditEnd is called for an original
1736  object, which is deprecated. The only tool using non wxEDITSTYLE_COPY is
1737  the wxMultEditTool, which will be changed.
1738  Calls DoEndEdit() first
1739  */
1740  virtual void EndEdit();
1741 
1742  //! to restart editing in a different mode
1743  void ReStartEdit( wxUint16 editmode );
1744 
1745  //! if this is an editcopy, return the orginal else NULL
1746  a2dCanvasObject* GetOriginal();
1747 
1748  //! set a2dHandle position with the given name
1749  a2dHandle* SetHandlePos( wxString name, double x, double y );
1750 
1751  //!redirect all mouse events for the canvas to this object
1752  void CaptureMouse( a2dIterC& ic );
1753 
1754  //!release the mouse capture for this object
1755  void ReleaseMouse( a2dIterC& ic );
1756 
1757  //!is the mouse captured for this object
1758  bool IsCapturedMouse( a2dIterC& ic ) const ;
1759 
1760  //! selected object itself or one of its recursive children
1761  bool GetHasSelectedObjectsBelow() const { return m_flags.m_HasSelectedObjectsBelow; }
1762 
1763  //! selected object itself or one of its recursive children
1764  void SetHasSelectedObjectsBelow( bool value ) { m_flags.m_HasSelectedObjectsBelow = value; }
1765 
1766  //! tool object itself or one of its recursive children
1767  bool GetHasToolObjectsBelow() const { return m_flags.m_HasToolObjectsBelow; }
1768 
1769  //! selected object itself or one of its recursive children
1770  void SetHasToolObjectsBelow( bool value ) { m_flags.m_HasToolObjectsBelow = value; }
1771 
1772  //\}
1773  //****************** END EDITING AND HIGHLIGHTING ******************/
1774 
1775  //****************** SERIALIZATION, IDs AND REFERENCES *****************/
1776  /*! \name Serialization, IDs and references
1777  In the CVG format one can store multiple references to one and the same object.
1778  The object that is referenced is only written once, for the rest only
1779  the reference id is written to the CVG file.
1780  When loading a file in CVG, such references are resolved inside the document.
1781  So in the end the old reference is restored via by searching the object having that id.
1782  As such the refid attribute is just a place holder for a reference to the actual referenced object.
1783  The reason behind all this, is that the actual object might to be read yet, when a reference
1784  is encountered in the CVG file, and therefore the link can not be directly created.
1785  In other formats references are used in a simular manner, and to resolve them the same mechanism
1786  is used.
1787  */
1788  //\{
1789 public:
1790 
1791  //!Check if this is a temporary object, which should not be saved
1792  virtual bool IsTemporary_DontSave() const;
1793 
1794 #if wxART2D_USE_CVGIO
1795 
1796  //!write object specific CVGL data
1797  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
1798 
1799  //!load object specific CVG data
1800  virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
1801 
1802 #endif //wxART2D_USE_CVGIO
1803 
1804 
1805  //\}
1806  //**************** END SERIALIZATION, IDs AND REFERENCES ***************/
1807 
1808  //********************** CONNECTION PINS AND WIRES *********************/
1809  /*! \name Connection via Pins and Wires
1810 
1811  - a a2dCanvasObject can have a2dPin objects as childs.
1812  These objects can connect to other a2dPin's and thus to other objects.
1813 
1814  - a2dPin objects know their parent, so that a communication path
1815  a2dCanvasObject (has child) a2dPin (is connected to) a2dPin (has parent) a2dCanvasObject
1816  exists.
1817 
1818  - There are wire objects, that connect pins in objects and modify themselfes if the
1819  objects they connect move. A wire object overloads "IsConnect" to return true.
1820 
1821  - Note: There are two quite different wire classes: a2dWires and a2dWirePolylineL.
1822  a2dWires is more like a least-distance "airline" network used e.g. in routing applications to
1823  show unconnected nets.
1824  a2dWirePolylineL is a usual polyline with wire functioanlity.
1825  Some of the functions apply to one type, one to the other type.
1826  */
1827  //\{
1828 public:
1829 
1830  //! return true, if this object is used to connect other object's using rubberband like structures.
1831  virtual bool IsConnect() const { return false; }
1832 
1833  //! object is a virtual connection (connects invisible with other objects without using wires )
1834  virtual bool IsVirtConnect() const { return false; }
1835 
1836  //!used in case of flexible canvas objects (wires).
1837  /*!
1838  If another object connected to this object changes, and that has an effect on this
1839  object, return true;
1840  */
1841  virtual bool NeedsUpdateWhenConnected() const { return false; }
1842 
1843  //! if return true, connection with other object on this object its pins is allowed.
1844  /*! This is usually used for temporarily disabling connectivity */
1845  bool DoConnect() { return m_flags.m_doConnect; }
1846 
1847  //! If set to true this object may be connected to other object on its pins.
1848  /*! This is usually used for temporarily disabling connectivity */
1849  void DoConnect( bool doconnect ) { m_flags.m_doConnect = doconnect; }
1850 
1851  //! check connect to other object
1852  /*! After the call Pin objects which can connect, have their bin flag set.
1853  */
1854  bool CanConnectWith( a2dIterC& ic, a2dCanvasObject* toConnect, bool autocreate );
1855 
1856  //! is the given pin close enough to another a2dPin to allow connection?
1857  /*!
1858  The default searches for a2dPin children in this object, and a pointer to the one which
1859  can connect with the given pin is returned. If non, returns NULL.
1860 
1861  Before trying to connect to the object DoCanConnectWith() is called, here the object can be prepared
1862  to be able to connect to the given pin here. The default implementation asks the object to GeneratePins()
1863  if autoccreate is set true.
1864 
1865  \param ic iteration context
1866  \param pin pin to check for connection to this object
1867  \param margin pin as to be this close.
1868  \param autocreate when true, pins maybe be created at the position in a derived object.
1869 
1870  */
1871  a2dPin* CanConnectWith( a2dIterC& ic, a2dPin* pin, double margin, bool autocreate );
1872 
1873  //! Is the object connected ( Optinal to specific object ) ?
1874  /*!
1875  \param needsupdate if true, only return true when connected Object(s) need an update.
1876  \param toConnect when not ( NULL ), the object needs to be connected with toConnect.
1877  */
1878  bool IsConnected( bool needsupdate, a2dCanvasObject* toConnect = 0 );
1879 
1880  //! Find pins in other object which are connected to this object.
1881  /*!
1882  If this object is connected on pins to other objects, those pins in the other objects
1883  will be put into the result list.
1884  The search uses the bin flag on pins to detect if this pin was already checked.
1885  Therefore you should clear that flag on pins of all object at the same level as this.
1886  Meaning the parent object of this object here. For the root object of a document, that can be done like:
1887  <code>
1888  a2dCanvasObject* root = doc->GetRootObject();
1889  a2dWalker_SetSpecificFlagsCanvasObjects setflags( a2dCanvasOFlags::BIN );
1890  setflags.Start( root, false );
1891 
1892  a2dCanvasObject* checkthis = root->GetChildObjectList()->Find( wxT("MyNameObject") );
1893  a2dCanvasObjectList result;
1894  wxString names;
1895  if ( checkthis )
1896  checkthis->FindConnectedPins( result, NULL, true, NULL );
1897  </code>
1898 
1899  If you want to skip certain Pins you can set the bin flag in advance.
1900  Pins on objects which are of connect type, like wires, will be skipped if walkWires is true.
1901  In that case the reported pins will be pins on normal objects connected to this, also via wires.
1902 
1903  \param result all pins found
1904  \param pin If not NULL find only connections on this pin
1905  \param walkWires If true, all wires like object are recursively iterated for pins to other non wire objects.
1906  The wire pins are skipped from the result.
1907  \param searchPinClass if set search pin with this pinclass
1908  \param isConnectedTo if not NULL, only pins connected to this object will be searched.
1909  */
1910  virtual bool FindConnectedPins( a2dCanvasObjectList& result, a2dPin* pin = NULL, bool walkWires = true, a2dPinClass* searchPinClass = NULL, a2dCanvasObject* isConnectedTo = NULL );
1911 
1912  //! find wires on pins of this objects.
1913  /*!
1914  A depth first serarch for correct branches. Wire passed and fitting condition, are stored to result.
1915 
1916  \param result all wires found
1917  \param pin If not NULL find only wires on this pin
1918  \param walkWires If true, all wires like object are recursively iterated for pins to other wire objects.
1919  \param selectedEnds if true, end of wire to a non wire object must have selected flag set.
1920  \param addToResult if true, this object is added to result. (default false, but recursive call set true).
1921  */
1922  bool FindConnectedWires( a2dCanvasObjectList& result, a2dPin* pin, bool walkWires = true, bool selectedEnds = false, bool stopAtSelectedWire = false, bool addToResult = false );
1923 
1924  //! get connected objects that are connected to this object via its pins.
1925  /*!
1926  \param connected list to which connected objects will be added.
1927  \param needsupdate if true only connected objects which need updating will be added.
1928  */
1929  bool GetConnected( a2dCanvasObjectList* connected, bool needsupdate );
1930 
1931  //!Do connect with another a2dCanvasObject by pinname
1932  /*!
1933  If pinname is an empty string the pins that lie on top of each-other will be connected.
1934  Zero Length wires or objects (having pins on top of eachother) are not connected if already a connection exists.
1935  If needed (eg pin was already connected to another object) extra wires will be added to keep connection intact.
1936  */
1937  virtual bool ConnectWith( a2dCanvasObject* parent, a2dCanvasObject* toconnect, const wxString& pinname = wxT( "" ), double margin = 1, bool undo = false );
1938 
1939  //!Do connect with another a2dCanvasObject by pin pointer
1940  /*!
1941  Searches this object for a pin, which is at the same position as the one given.
1942  If that pin allows connection, those pins will be connected.
1943  */
1944  virtual bool ConnectWith( a2dCanvasObject* parent, a2dPin* pin, double margin = 1, bool undo = false );
1945 
1946  //! connect two pins
1947  /*! by creating a a2dWires object in between, unless already connected and
1948  they are exactly at the same position.
1949  They idea is to connect pins without changing there position, and keep already connected
1950  objects at the given pins connected also (to the wire object that is created ).
1951  */
1952  virtual void ConnectPinsCreateConnect( a2dCanvasObject* parent, a2dPin* pinc, a2dPin* pinother, bool undo = false );
1953 
1954  //! pins one wires to the same kind of wire are removed.
1955  bool CleanWires( a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::ALL );
1956 
1957  //! connect two pins which must be unconnected and at the same position
1958  /*!
1959  This is a simple straight forward connection of the two pins.
1960  When Undo is true proper commands are issued to connect the pins.
1961  If the pins are already connected with something, they will be first disconnected.
1962  */
1963  void ConnectPins( a2dCanvasObject* parent, a2dPin* pinc, a2dPin* pinother, bool undo = false );
1964 
1965  //!Do Disconnect from another a2dCanvasObject by pin name
1966  /*!
1967  \param toDisConnect object to disconnect, if NULL all objects will be disconnected.
1968  \param pinname If pinname is an empty string the pins connected to toConnect will be dis-connected,
1969  else only the ones with the pinname will be disconnected.
1970  \param undo if true commands will be used to disconnect pins.
1971  */
1972  virtual bool DisConnectWith( a2dCanvasObject* toDisConnect = NULL, const wxString& pinname = wxT( "" ), bool undo = false );
1973 
1974  //!Do Disconnect from another a2dCanvasObject by pin pointer
1975  /*!
1976  Disconnect at pin (of this object ).
1977  */
1978  virtual bool DisConnectAt( a2dPin* pin, bool undo = false );
1979 
1980  //! rewire the object to keep connection or to make connection with other objects
1981  /*!
1982  \param parent parent object to get and release to connected objects.
1983  \param undo if true commands will be used to disconnect pins.
1984  */
1985  void ReWireConnected( a2dCanvasObject* parent, bool undo = false );
1986 
1987  //! create wires on pins which do not have wires, but directly are connected to other objects.
1988  /*!
1989  This prepares the object for dragging/moving, while preserving the connection, since then wires will
1990  be rerouted when dragging.
1991  */
1992  bool CreateWiresOnPins( a2dCanvasObject* parent, bool undo, bool onlyNonSelected = false );
1993 
1994  //! set connected pending or not pending
1995  /*!
1996  \param onoff set connected object pending or not pending
1997  \param needsupdateonly if true only connected object which need updating will treated.
1998  */
1999  bool SetConnectedPending( bool onoff, bool needsupdateonly );
2000 
2001  //!are there a2dPin derived children
2002  /*!
2003  \param realcheck if true checks all children else the flag m_flags.m_hasPins is returned
2004  \remark if realcheck is true also the m_flags.m_hasPins will be updated.
2005  */
2006  bool HasPins( bool realcheck = false );
2007 
2008  //!are there a2dPin derived children which matches the given pin name?
2009  /*!
2010  \param pinName the name of the pin to search for ( uses wxString::Matches() ).
2011  \param NotConnected if true the pin must be unconnected too.
2012 
2013  \return the a2dPin object found or NULL
2014 
2015  \remark the m_flags.m_hasPins is ignored here for the moment
2016  */
2017  a2dPin* HasPinNamed( const wxString pinName, bool NotConnected = false );
2018 
2019  //!How many a2dPin derived children are there.
2020  int GetPinCount();
2021 
2022  //! generates pins on all possible locations where the object can be connected.
2023  /*!
2024  Default calls pinClass->GetConnectionGenerator()->GeneratePossibleConnections()
2025  And that leads to calling a2dCanvasObject::GeneratePins()
2026  This way a a2dConnectionGenerator can limit the pins which are generated.
2027 
2028  \param pinClass if not NULL, only generate temporary pins that may connect to this pinClass.
2029  \param task what/how to connect
2030  \param x can be used to create pins depending on the poition of the mouse inside the object.
2031  \param y can be used to create pins depending on the poition of the mouse inside the object.
2032  \param margin if not 0 the genarted pins must be this close to x and y.
2033  */
2034  virtual bool GeneratePinsPossibleConnections( a2dPinClass* pinClass, a2dConnectTask task, double x, double y, double margin = 0 );
2035 
2036  //! create pins in derived objects.
2037  /*!
2038  When wanting to connect to shapes which at construction has no pins, but still make sence
2039  to connect too, this function generates pins for the object, when connection is asked for by a tool.
2040 
2041  The idea is to generate temporary pins in objects, as feedback for the tools.
2042  This way the user sees where connections are possible.
2043 
2044  You need to implement this function per object. The default is not doing anything.
2045 
2046  \sa GeneratePinsPossibleConnections()
2047 
2048  \param toConnectTo the pinClass to which the generated pin must be able to connect.
2049  \param task what/how to connect
2050  \param x x position of mouse or pin which wants/needs connection
2051  \param y y position of mouse or pin which wants/needs connection
2052  \param margin if not 0 the genarted pins must be this close to x and y.
2053  */
2054  virtual bool GeneratePins( a2dPinClass* WXUNUSED( toConnectTo ), a2dConnectTask WXUNUSED( task ), double WXUNUSED( x ), double WXUNUSED( y ), double WXUNUSED(margin) = 0 )
2055  { return false; }
2056 
2057  //! Allow change in pin location when wiring things up.
2058  virtual bool AdjustPinLocation() { return false; }
2059 
2060  //! based on the a2dPinClass's of eventually a2dPin's wanted in both objects, a
2061  /*! connection object will be delivered as a template to be cloned by the caller.
2062  In principle calling this->GetConnectTemplate() and other->GetConnectTemplate()
2063  should result in the same.
2064  The default implementation uses a2dCanvasGlobals->GetPinClassMaps() which is a simple system
2065  to supply a template object based ob the two entry maps.
2066  You can override this function to define your own way of connections.
2067  */
2068  virtual a2dCanvasObject* GetConnectTemplate( a2dPinClass* mapThis, a2dCanvasObject* other, a2dPinClass* mapOther ) const;
2069 
2070  //! generates a connection object with pins and all.
2071  /*!
2072  Default calls pinThis->GetConnectionGenerator()->CreateConnectObject()
2073  This way a a2dConnectionGenerator can decide on the type of object to generate
2074  as a plugin.
2075  */
2076  virtual a2dCanvasObject* CreateConnectObject( a2dCanvasObject* parent, a2dPin* pinThis, a2dPin* pinOther, bool undo = false ) const;
2077 
2078  //! add a a2dPin as child
2079  /*!
2080  \param name name which the pin will get
2081  \param x x-position of pin
2082  \param y y-position of pin
2083  \param a2dpinFlags
2084  - a2dPin::dynamic if true pin will be dynamic
2085  - a2dPin::temporary if true pin will be temporary
2086  - a2dPin::objectPin if true pin is seen as part of an object and not a wire/connect
2087  \param pinClass pinClass of the pin, created pin cloned from a2dPinClass->GetPin()
2088  \param undo if set undo-able commands will be used
2089 
2090  \return the pin that was created and added to the object.
2091  */
2092  a2dPin* AddPin( const wxString name, double x, double y, wxUint32 a2dpinFlags, a2dPinClass* pinClass, bool undo = false );
2093 
2094  //! Remove all a2dPin children
2095  /*!
2096  \param NotConnected when true only pins which are not connected tp another pin will be deleted
2097  \param onlyTemporary when true only pins with the temporary flag set
2098  using a2dPin::SetTemporaryPin() will be deleted.
2099  These type of pins are used in automatic connection situations, and often
2100  after an editing attempt of other objects need to be deleted in the end.
2101  \param now if true remove pin object now!, else only delete flag is set,
2102  and it will be deleted in idle time.
2103  */
2104  void RemovePins( bool NotConnected = false, bool onlyTemporary = false, bool now = false );
2105 
2106  //! Set a2dPin children visible or not
2107  void ShowPins( bool onoff );
2108 
2109  //! Calls a2dPin::SetRenderConnected() for all pins
2110  /*! By default connected pins are not rendered, you can set it true for all pins here.
2111  But you can also set each pin individual.
2112  */
2113  void SetRenderConnectedPins( bool onoff );
2114 
2115  //! Remove all pin connections by issuing a2dCommand_DisConnectPins commands
2116  /*! This should be done before a a2dCommand_ReleaseObject is issued, else the pins will be disconnected to late.
2117  \param withundo if true use a2dCommand_DisConnectPins commands.
2118  */
2119  virtual void ClearAllPinConnections( bool withundo = true );
2120 
2121  //! set parent object of the pin or some other objects that needs a parent
2122  virtual void SetParent( a2dCanvasObject* WXUNUSED( parent ) ) {};
2123 
2124  //! return NULL, because a a2dCanvasObject normally does not have only one parent.
2125  //! In a derived class, it can be a defined.
2126  virtual a2dCanvasObject* GetParent() const { return NULL; };
2127 
2128 protected:
2129 
2130  //! prepare an object for being connected to a given pin
2131  /*!
2132  Before trying to connect in CanConnectWith() to the object DoCanConnectWith() is called,
2133  here the object can be prepared to be able to connect to the given pin here.
2134  The default implementation asks the object to GeneratePins() if autoccreate is set true.
2135 
2136  In a derived class one can do more complicated things to decide if a pin needs to be created or not.
2137  */
2138  virtual bool DoCanConnectWith( a2dIterC& ic, a2dPin* pin, double margin, bool autocreate );
2139 
2140  //\}
2141  //******************** END CONNECTION PINS AND WIRES********************/
2142 
2143  //********************** PROPERTIES *********************/
2144  /*! \name Properties
2145  a a2dCanvasObject has a list of general named properties
2146  */
2147  //\{
2148 public:
2149 
2150  //! a2dCanvasObject set as property will be rendered after all other child objects
2151  //! when it is rendreed from a parent a2dCanvasObject
2152  inline void SetIsProperty( bool IsProperty ) { SetPending( true ); m_flags.m_IsProperty = IsProperty; }
2153 
2154  //! a2dCanvasObject set as property will be rendered after all other child objects
2155  //! when it is rendreed from a parent a2dCanvasObject
2156  inline bool GetIsProperty() const { return m_flags.m_IsProperty; }
2157 
2158  //! quickly set a property name __OBJECTTIP__
2159  /*!
2160  This function stores an OBJECTTIP property which will be shown when mouse is within an object.
2161 
2162  \param tip the tip which should be shown
2163  \param x x-pos of the tip
2164  \param y y-pos of the tip
2165  \param size font-size in world coordinates (font size of the font-param will be ignored, see a2dText documentation)
2166  \param angle rotation in degrees
2167  \param font the font to use
2168 
2169  \return a pointer to the a2dText object used to show the tip.
2170  */
2171  a2dText* SetObjectTip( const wxString& tip, double x, double y, double size = 30, double angle = 0,
2172  const a2dFont& font = *a2dDEFAULT_CANVASFONT );
2173 
2174  //! quickly set a property a2dTipWindowProperty
2175  /*!
2176  This function stores a a2dTipWindowProperty property which will be shown when mouse is within an object.
2177  The function a2dCanvasObject::OnEnterObject() will show it.
2178 
2179  \param tip the tip which should be shown
2180  */
2181  void SetTipWindow( const wxString& tip );
2182 
2183  //! quickly get first property with name __OBJECTTIP__
2184  a2dObject* GetObjectTip();
2185 
2186  //! edit properties of the object
2187  /*!
2188  This default implementation sents the a2dPropertyEditEvent with
2189  id wxEVT_PROPOBJECT_EDITPROPERTIES_EVENT.
2190 
2191  This can be intercepted by any registrated class in order to edit the properties.
2192  When after return, the event its GetEdited() returns true, this indicates that the
2193  properties where indeed edited.
2194 
2195  \param id If property id is set only matching properties are selected
2196  \param withUndo If true, the changes can be undone later.
2197  */
2198  virtual bool EditProperties( const a2dPropertyId* id, bool withUndo );
2199 
2200 protected:
2201 
2202  //! This function is called after a property obn this object did change
2203  //! This is overloaded to set e.g. a pending flag
2204  void OnPropertyChanged( a2dComEvent& event );
2205 
2206 public:
2207 
2208  //\}
2209  //**************** END PROPERTIES ***************/
2210 
2211  //********************** FLAGS *********************/
2212  /*! \name Flags
2213  a a2dCanvasObject has some falgs for general and algorithmic use.
2214  Other flags have special meaning or are used internally. The flags with special
2215  meaning (e.g. m_visible) are detailed in the proper sections.
2216  */
2217  //\{
2218 public:
2219 
2220  //!set all bit flags in object that or true in mask to true or false
2221  /*!
2222  set specific flags to true or false
2223 
2224  \remark the object is not setpending when something changed ( actually the pending flag can be set here also )
2225 
2226  \param setOrClear if true sets the flag to true else to false
2227  \param which set only those flags in object to true or false
2228  */
2229  void SetSpecificFlags( bool setOrClear, a2dCanvasObjectFlagsMask which );
2230 
2231  //!Compares all flags in object to the given mask and return true is the same.
2232  bool CheckMask( a2dCanvasObjectFlagsMask mask ) const;
2233 
2234  //!set bit flags of object (true or false) to given newmask values
2235  /*!
2236  \remark does not recurse into children
2237 
2238  \param newmask mask to set flags to in object (either true or false)
2239  */
2240  void SetFlags( a2dCanvasObjectFlagsMask newmask );
2241 
2242  //!get specific bitflag value
2243  bool GetFlag( const a2dCanvasObjectFlagsMask which ) const;
2244 
2245  //!get bitflags as an integer
2246  a2dCanvasObjectFlagsMask GetFlags() const;
2247 
2248  //!general flag use at will.
2249  /*!
2250  \remark
2251  This flag should only be used for temporarly purposes.
2252  This object uses this flag too and you might run into problems if you use this flag.
2253  It's a good practice to set this flag if you need it and reset this flag to <code>false</code>
2254  if you don't need it anymore. Another possibility might be to add a new property to this object
2255  if you want to be on the secure side.
2256 
2257  \param bin temporarely status information
2258  */
2259  inline void SetBin( bool bin ) { m_flags.m_bin = bin; }
2260 
2261  //!general flag use at will.
2262  inline bool GetBin() const {return m_flags.m_bin;}
2263 
2264  //!get the groupA flag
2265  /*! used to define operands in operation on two groups of objects
2266  */
2267  bool GetGroupA() const { return m_flags.m_a; }
2268 
2269  //!set the groupA flag
2270  /*! used to define operands in operation on two groups of objects
2271  \param value true to set group flag A
2272  */
2273  void SetGroupA( bool value ) { SetPending( true ); m_flags.m_a = value; }
2274 
2275  //!get the groupA flag
2276  /*! used to define operands in operation on two groups of objects
2277  */
2278  bool GetGroupB() const { return m_flags.m_b; }
2279 
2280  //!set the groupA flag
2281  /*! used to define operands in operation on two groups of objects
2282  \param value true to set group flag B
2283  */
2284  void SetGroupB( bool value ) { SetPending( true ); m_flags.m_b = value; }
2285 
2286  //!get the GeneratePins flag
2287  /*! used to define operands in operation on two groups of objects
2288  */
2289  bool GetGeneratePins() const { return m_flags.m_generatePins; }
2290 
2291  //!set the GeneratePins flag
2292  /*! used to define operands in operation on two groups of objects
2293  \param value true to set group flag C
2294  */
2295  void SetGeneratePins( bool value ) { SetPending( true ); m_flags.m_generatePins = value; }
2296 
2297  //!set IgnoreSetpending flag
2298  /*!If this flag is set, the object will be not be set pending in SetPending()*/
2299  void SetIgnoreSetpending( bool value = true ) { m_flags.m_ignoreSetpending = value; }
2300 
2301  //!get IgnoreSetpending flag
2302  /*!If this flag is set, the object will be not be set pending in SetPending()*/
2303  bool GetIgnoreSetpending( ) const { return m_flags.m_ignoreSetpending; }
2304 
2305  //!set static IgnoreAllSetpending flag
2306  /*!If this flag is set, all a2dCanvasObject will be not be set pending in SetPending()*/
2307  static void SetIgnoreAllSetpending( bool value = true ) { m_ignoreAllSetpending = value; }
2308 
2309  //!get static IgnoreSetpending flag
2310  /*!If this flag is set, all a2dCanvasObject will be not be set pending in SetPending()*/
2311  static bool GetIgnoreAllSetpending( ) { return m_ignoreAllSetpending; }
2312 
2313  void SetIgnoreLayer( bool value = true ) { m_flags.m_ignoreLayer = value; }
2314 
2315  bool GetIgnoreLayer( ) const { return m_flags.m_ignoreLayer; }
2316 
2317  void SetSubEdit( bool value ) { m_flags.m_subEdit = value; }
2318  bool GetSubEdit( ) const { return m_flags.m_subEdit; }
2319  void SetSubEditAsChild( bool value ) { m_flags.m_subEditAsChild = value; }
2320  bool GetSubEditAsChild( ) const { return m_flags.m_subEditAsChild; }
2321  void SetShowshadow( bool value ) { m_flags.m_showshadow = value; }
2322  bool GetShowshadow( ) const { return m_flags.m_showshadow; }
2323  void SetPushin( bool value ) { m_flags.m_pushin = value; }
2324  bool GetPushin( ) const { return m_flags.m_pushin; }
2325  void SetBin2( bool value ) { m_flags.m_bin2 = value; }
2326  bool GetBin2( ) const { return m_flags.m_bin2; }
2327  void SetPrerenderaschild( bool value ) { m_flags.m_prerenderaschild = value; }
2328  bool GetPrerenderaschild( ) const { return m_flags.m_prerenderaschild; }
2329  void SetVisiblechilds( bool value ) { m_flags.m_visiblechilds = value; }
2330  bool GetVisiblechilds( ) const { return m_flags.m_visiblechilds; }
2331  void SetEditing( bool value ) { m_flags.m_editing = value; }
2332  bool GetEditing( ) const { return m_flags.m_editing; }
2333  void SetEditingRender( bool value ) { m_flags.m_editingCopy = value; }
2334  bool GetEditingRender( ) const { return m_flags.m_editingCopy; }
2335  void SetDoConnect( bool value ) { m_flags.m_doConnect = value; }
2336  bool GetDoConnect( ) const { return m_flags.m_doConnect; }
2337  void SetIsOnCorridorPath( bool value ) { m_flags.m_isOnCorridorPath = value; }
2338  bool GetIsOnCorridorPath( ) const { return m_flags.m_isOnCorridorPath; }
2339  void SetHasPins( bool value ) { m_flags.m_hasPins = value; }
2340  bool GetHasPins( ) const { return m_flags.m_hasPins; }
2341  void SetMouseInObject( bool value ) { m_flags.m_MouseInObject = value; }
2342  bool GetMouseInObject( ) const { return m_flags.m_MouseInObject; }
2343  void SetHighLight( bool value ) { m_flags.m_HighLight = value; }
2344  bool GetHighLight( ) const { return m_flags.m_HighLight; }
2345  void SetAlgoSkip( bool value ) { m_flags.m_AlgoSkip = value; }
2346  bool GetAlgoSkip( ) const { return m_flags.m_AlgoSkip; }
2347 
2348 protected:
2349 
2350  //\}
2351  //**************** END FLAGS ***************/
2352 
2353  //********************** LAYERS *********************/
2354  /*! \name Layers
2355  a a2dCanvasDocument is rendered in layers. Every canvas object belongs to excatly
2356  one layer.
2357  */
2358  //\{
2359 public:
2360 
2361  //! Returns the layer index where this object is drawn upon.
2362  /*!
2363  The order of the a2dLayers in the root object decides if and when it will be drawn.
2364 
2365  \see a2dCanvasDocument::SetLayerSetup
2366  \see a2dLayers
2367  */
2368  inline wxUint16 GetLayer() const { return m_layer; }
2369 
2370  //!set layer index where this object is drawn upon.
2371  /*!
2372  Default is layer wxLAYER_DEFAULT (colours etc taken from layer list)
2373  Some layers are predefined and used for special purposes (i.e. for selection of
2374  an object etc.). Please refer to wxLayerNames.
2375 
2376  \see wxLayerNames
2377  \see a2dLayerInfo
2378  \see a2dLayers
2379 
2380  \param layer the index of the layer
2381  */
2382  virtual void SetLayer( wxUint16 layer );
2383 
2384  //\}
2385  //**************** END LAYERS ***************/
2386 
2387  //********************** APPLICATION SPECIFIC EXTENSIONS *********************/
2388  /*! \name Application specific extensions.
2389  The functions in this section can be used to extend the functionality of
2390  a2dCanvasObject without adding new virtual member functions to the base class.
2391  */
2392  //\{
2393 public:
2394 
2395  //!call fp for each object
2396  void foreach_f( void ( *fp ) ( a2dCanvasObject* item ) );
2397 
2398  //!call fp for each object
2399  void foreach_mf( void ( a2dCanvasObject::*mfp ) () );
2400 
2401  //!can be used by the user to implement a function that affects all a2dCanvas derived objects
2402  virtual bool UserBaseFunction() { return true;}
2403 
2404  //!can be used by the user to implement a function that affects all a2dCanvas derived objects
2405  /*!
2406  a2dIOHandler can be used to transfer data to the function, for example a a2dWalkerIOHandler handler
2407  can be used to iterate the document, and calll this function on every object wanted.
2408 
2409  \param function function id, to be able to use this function for more tasks.
2410  \param handler a2dIOHandler which was use to iterate the document
2411  */
2412  virtual bool UserBaseFunctionEx( int WXUNUSED( function ), a2dIOHandler* WXUNUSED( handler ) = NULL ) { return true; }
2413 
2414  //!can be used by the user to implement a function using a variable argument list that affects all a2dCanvas derived objects
2415  virtual bool UserBaseFunctionVar( ... ) { return true;}
2416 
2417  //!can be used by the user to implement a function using a variable argument list and format string that affects all a2dCanvas derived objects
2418  virtual bool UserBaseFunctionFormat( wxString format, ... ) { return true;}
2419 
2420  //! This is used to recursively walk through an object tree
2421  void WalkerWithContext( a2dIterC& ic, wxObject* parent, a2dWalkerIOHandlerWithContext& handler );
2422 
2423 protected:
2424 
2425  //! iterate over this object and its children
2426  /*!
2427  This function allows you to extend the functionality of all a2dCanvasObject classes
2428  in a a2dCanvasDocument, without adding extra members to these objects.
2429 
2430  Default functions are called on the a2dWalkerIOHandler, which redirect the
2431  calls to other functions based on this object its classname.
2432  On can register classes to a2dWalkerIOHandler or derived classes.
2433  This way for each unique object in the document there can be a function
2434  in a2dWalkerIOHandler.
2435 
2436  \return false if some object did not have a function attached via a2dWalkerIOHandler.
2437 
2438  See a2dWalkerIOHandler for more.
2439  */
2440  virtual void DoWalker( wxObject* parent, a2dWalkerIOHandler& handler );
2441 
2442  // used if context is needed.
2443  virtual void DoWalkerWithContext( a2dIterC& ic, wxObject* parent, a2dWalkerIOHandlerWithContext& handler );
2444 
2445  //\}
2446  //********************** END APPLICATION SEPCIFIC EXTENSIONS *********************/
2447 
2448  //********************** DEBUGGING *********************/
2449  /*! \name Debugging functions
2450  These functions are only enabled in Debug mode
2451  */
2452  //\{
2453 public:
2454 #ifdef _DEBUG
2455 
2456  //! Dump an Object with its childs and properties
2457  /*! Note: this function is not virtual, because virtual functions cannot
2458  be called from the debugger
2459  */
2460  void Dump( int indent = 0 );
2461  //! Called by Dump to Dump class specific stuff
2462  /*! Add class specific info to line or output line and create a new line */
2463  virtual void DoDump( int indent, wxString* line );
2464 
2465 #endif
2466  //\}
2467 
2468  //! when implemented the object without its children, is converted to
2469  /*!
2470  to a list of a2dVectorPath's.
2471  Else wxNullCanvasObjectList is returned.
2472  */
2473  virtual a2dCanvasObjectList* GetAsCanvasVpaths( bool transform = true ) const;
2474 
2475  //! convert to a list of polygons.
2476  /*!
2477  Return non wxNullCanvasObjectList if possible and implemented.
2478  */
2479  virtual a2dCanvasObjectList* GetAsPolygons( bool transform = true ) const;
2480 
2481  //! convert to a list of polylines.
2482  /*!
2483  Return non wxNullCanvasObjectList if possible and implemented.
2484  */
2485  virtual a2dCanvasObjectList* GetAsPolylines( bool transform = true ) const;
2486 
2487  //! convert to a polygon.
2488  /*!
2489  Return non NULL if possible and implemented.
2490  */
2491  virtual a2dVertexList* GetAsVertexList( bool& returnIsPolygon ) const { return NULL; }
2492 
2493  void SetTemplate( bool b = true );
2494  void SetExternal( bool b = true );
2495  void SetUsed( bool b = true );
2496 
2497  bool GetTemplate() const ;
2498  bool GetExternal() const ;
2499  bool GetUsed() const ;
2500 
2501 protected:
2502 
2503  bool ProcessCanvasEventChild( a2dIterC& ic, RenderChild& whichchilds, a2dHitEvent& hitEvent );
2504 
2505  bool ProcessCanvasEventChildOneLayer( a2dIterC& ic, RenderChild& whichchilds, a2dHitEvent& hitEvent );
2506 
2507 public:
2508 
2509  //!only used for editable objects and under control of a editing tool.
2510  /*!
2511  If object is editable this function is used to initialize the object for editing.
2512  In general this means adding editing handles to the child list.
2513  In the event handling of the object those handles are hit and moved, the object itself
2514  is changed accordingly.
2515 
2516  \return true is this object can be edited and is initialized for that.
2517  */
2518  virtual bool DoStartEdit( wxUint16 editmode, wxEditStyle editstyle );
2519 
2520 protected:
2521 
2522  virtual bool DoIgnoreIfNotMember( const a2dPropertyId& id );
2523 
2524  //!root group for rendering and accessing the canvas's also contains layer settings
2526 
2527  //!holds flags for objects
2529 
2530  //bitset<64> m_bflags;
2531 
2532  //!holds value for flags to initialize m_flags
2534 
2535  //!allow hits on basis of those flags
2537 
2538  //!boundingbox in world coordinates
2540 
2541  //! world extend in world coordinates.
2542  /*!
2543  Normally contains at least the stroke width when this is in world coordinates.
2544  */
2546 
2547  //! Pixel extend
2548  /*!
2549  In case of pixel object or partial pixel object or pixel strokes,
2550  this will contain the needed oversize on top of the boundingbox.
2551  It is to be set in Update() or OnUpdate()
2552  */
2553  wxUint16 m_pixelExtend;
2554 
2555  //!layer of object, default wxLAYER_DEFAULT
2556  wxUint16 m_layer;
2557 
2558  //!used for positioning the object (x,y,ang,scale etc.)
2560 
2561  //!holds child objects
2563 
2564  //! parse Cvg transform of object
2565  bool ParseCvgTransForm( a2dAffineMatrix& result, a2dIOHandlerXmlSerIn& parser );
2566 
2567  //!called by addPending
2568  virtual void DoAddPending( a2dIterC& ic );
2569 
2570  //! In derived object this should be overriden to calculate the boundingbox of the object without its children.
2571  /*!
2572  The default return a non Valid boundingbox.
2573 
2574  The real boundingbox of the object is often less desirable for editing. e.g. a rectangle with a contour,
2575  one does not want editing handles on the contour, instead they should still be on the basic rectangle.
2576  */
2577  virtual a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
2578 
2579  //!Update derived Object specific things ( mainly boundingbox)
2580  /*!
2581  Calculates the boundingbox of the object (exclusif base class child objects but with other nested objects).
2582 
2583  \param mode way to update the objects
2584  \param childbox size of children boundingbox
2585  \param clipbox clip to this
2586  \param propbox size of properties boundingbox
2587 
2588  \remark in a derived class this function can also be used to update object specific cache data.
2589 
2590  \remark force may or may not have direct influence on the object itself, if this function is called directly
2591  for some reason (e.g from derived objects), you must invalidate the boudingbox yourself.
2592  GetDrawerBox()->SetValid( false );
2593  */
2594  virtual bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
2595 
2596  //!only used for editable objects and under control of a editing tool.
2597  /*!
2598  Do a clean up at the end of an editing sesion of the object.
2599  In general this means, remove editing handles from child list.
2600  */
2601  virtual void DoEndEdit() {};
2602 
2603 public:
2604 
2605  //! when set all SetPending() calss are supressed.
2606  static bool m_ignoreAllSetpending;
2607 
2608  // member ids
2609  static a2dPropertyIdMatrix* PROPID_TransformMatrix;
2610  static a2dPropertyIdPoint2D* PROPID_Position;
2611  static a2dPropertyIdUint16* PROPID_Layer;
2612  static a2dPropertyIdBool* PROPID_Selected;
2613  static a2dPropertyIdBool* PROPID_Selectable;
2614  static a2dPropertyIdBool* PROPID_SubEdit;
2615  static a2dPropertyIdBool* PROPID_SubEditAsChild;
2616  static a2dPropertyIdBool* PROPID_Visible;
2617  static a2dPropertyIdBool* PROPID_Draggable;
2618  static a2dPropertyIdBool* PROPID_Showshadow;
2619  static a2dPropertyIdBool* PROPID_Filled;
2620  static a2dPropertyIdBool* PROPID_GroupA;
2621  static a2dPropertyIdBool* PROPID_GroupB;
2622  static a2dPropertyIdBool* PROPID_GeneratePins;
2623  static a2dPropertyIdBool* PROPID_Bin;
2624  static a2dPropertyIdBool* PROPID_Bin2;
2625  static a2dPropertyIdBool* PROPID_Pending;
2626  static a2dPropertyIdBool* PROPID_Snap;
2627  static a2dPropertyIdBool* PROPID_SnapTo;
2628  static a2dPropertyIdBool* PROPID_Pushin;
2629  static a2dPropertyIdBool* PROPID_Prerenderaschild;
2630  static a2dPropertyIdBool* PROPID_Visiblechilds;
2631  static a2dPropertyIdBool* PROPID_Editable;
2632  static a2dPropertyIdBool* PROPID_Editing;
2633  static a2dPropertyIdBool* PROPID_EditingRender;
2634  static a2dPropertyIdBool* PROPID_ChildrenOnSameLayer;
2635  static a2dPropertyIdBool* PROPID_DoConnect;
2636  static a2dPropertyIdBool* PROPID_IsOnCorridorPath;
2637  static a2dPropertyIdBool* PROPID_HasPins;
2638  static a2dPropertyIdBool* PROPID_IsProperty;
2639  static a2dPropertyIdBool* PROPID_MouseInObject;
2640  static a2dPropertyIdBool* PROPID_HighLight;
2641  static a2dPropertyIdBool* PROPID_Template;
2642  static a2dPropertyIdBool* PROPID_External;
2643  static a2dPropertyIdBool* PROPID_Used;
2644  static a2dPropertyIdBool* PROPID_Release;
2645 
2646  // commonly used member ids in derived classes
2647  static a2dPropertyIdCanvasObject* PROPID_Begin;
2648  static a2dPropertyIdCanvasObject* PROPID_End;
2649  static a2dPropertyIdDouble* PROPID_EndScaleX;
2650  static a2dPropertyIdDouble* PROPID_EndScaleY;
2651  static a2dPropertyIdBool* PROPID_Spline;
2652  static a2dPropertyIdDouble* PROPID_ContourWidth;
2653 
2654  // property ids
2655  static a2dPropertyIdBool* PROPID_DisableFeedback;
2656  static a2dPropertyIdBool* PROPID_Allowrotation;
2657  static a2dPropertyIdBool* PROPID_Allowsizing;
2658  static a2dPropertyIdBool* PROPID_Allowskew;
2659  static a2dPropertyIdBool* PROPID_IncludeChildren;
2660  static a2dPropertyIdRefObjectAutoZero* PROPID_Controller;
2661  static a2dPropertyIdCanvasObject* PROPID_Original;
2662  static a2dPropertyIdCanvasObject* PROPID_Editcopy;
2663  static a2dPropertyIdCanvasObject* PROPID_Parent;
2664  static a2dPropertyIdCanvasObject* PROPID_Objecttip;
2665  static a2dPropertyIdUint16* PROPID_Editmode;
2666  static a2dPropertyIdUint16* PROPID_Editstyle;
2667  static a2dPropertyIdUint16* PROPID_Index;
2668  static a2dPropertyIdCanvasShadowStyle* PROPID_Shadowstyle;
2669  static a2dPropertyIdFill* PROPID_Fill;
2670  static a2dPropertyIdStroke* PROPID_Stroke;
2671  static a2dPropertyIdUint32* PROPID_RefDesCount;
2672  static a2dPropertyIdUint32* PROPID_RefDesNr;
2673 
2674  //! set for objects that act as tool decorations, when a tool is in action.
2676 
2677  //! set for objects that act as tool object, when a tool is in action.
2679 
2680  //! set for objects that do not have to be saved
2682 
2683  //! used to store state ( redraw area) of the object as it was before a change
2685 
2686  static a2dPropertyIdColour* PROPID_StrokeColour;
2687  static a2dPropertyIdColour* PROPID_FillColour;
2688 
2689  //! when an object should only be rendered in the view pointed to by this property.
2690  //! This is tipically used when using tool object.
2692 
2693  //! set in Startedit(), to be used to detect first (mouse)event sent to object.
2695 
2696  //! used in GDSII and KEY format to specify the DATATYPE of elements
2697  /*! GDSII compatible to sub identify this object.
2698  you can use it as a special tagged object
2699  */
2701 
2702  //! used for objects that depend on 'aView' view when it comes to size.
2704  //! used for objects with* PROPID_viewDependent but only for internal area
2706 
2707  //! some time property which a user wants to store
2709 
2710  static a2dPropertyIdDateTime* PROPID_ModificationDateTime;
2711 
2712  static a2dPropertyIdDateTime* PROPID_AccessDateTime;
2713 
2714  //! when set used for popup menu by default in OnPopUpEvent()
2716 
2717  //! when set used for tip window by default in OnCanvasMouseEvent()
2719 
2720  //! used in tool when grouping using tags
2722 
2724 
2725 private:
2726  //!this is a not implemented copy constructor that avoids automatic creation of one
2727  a2dCanvasObject( const a2dCanvasObject& other );
2728 };
2729 
2730 #include "wx/canvas/canpin.h"
2731 
2732 bool operator < ( const a2dCanvasObjectPtr& a, const a2dCanvasObjectPtr& b );
2733 
2734 typedef bool ( *a2dCanvasObjectSorter ) ( const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y );
2735 A2DCANVASDLLEXP extern a2dCanvasObjectSorter s_a2dCanvasObjectSorter;
2736 
2737 #ifdef _DEBUG
2738 // Here are two globals that can be used as registers in the debugger
2739 extern a2dCanvasObject* _dbco1;
2740 extern a2dCanvasObject* _dbco2;
2741 #endif
2742 
2743 
2744 
2745 //! class use by a2dIterC to filter objects for rendering.
2746 /*!
2747  From a2dCanvasDocument render cycles for the document are initiated.
2748  An iteration context is set up, and this context can have an object filter set,
2749  only a2dCanvasObject objects that return true, will be rendered.
2750 
2751  The idea is to derived from this class, and defined your own Filter()
2752 
2753  This object can contain dynamic properties which can be used for filtering.
2754  It is also refcounted for use with smart pointers.
2755 */
2756 class A2DCANVASDLLEXP a2dCanvasObjectFilter : public a2dObject
2757 {
2758 public:
2759 
2760  //!
2761  /*!
2762  */
2763  a2dCanvasObjectFilter() {};
2764 
2765  ~a2dCanvasObjectFilter() {};
2766 
2767  //! called from a2dCanvasObject to filter objects for rendering
2768  virtual bool Filter( a2dIterC& WXUNUSED( ic ), a2dCanvasObject* WXUNUSED( canvasObject ) ) { return true; }
2769 
2770  //! called from a2dCanvasObject to reset filtering feature when filtered object goes out of context.
2771  virtual void EndFilter( a2dIterC& WXUNUSED( ic ), a2dCanvasObject* WXUNUSED( canvasObject ) ) {}
2772 };
2773 
2774 #if defined(WXART2D_USINGDLL)
2775 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dCanvasObjectFilter>;
2776 
2777 #endif
2778 
2779 //! filter on this layer and mask.
2781 {
2782 public:
2783 
2784  //!
2785  /*!
2786  */
2788  {
2789  m_layer = layer;
2790  m_mask = mask;
2791  m_antimask = antimask;
2792  }
2793 
2795 
2796  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2797 
2798 protected:
2799 
2800  wxUint16 m_layer;
2801  a2dCanvasObjectFlagsMask m_mask;
2802  a2dCanvasObjectFlagsMask m_antimask;
2803 
2804 private:
2805  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; };
2806 };
2807 
2808 //! objects with m_editingcopy or m_toolobject are skipped.
2810 {
2811 public:
2812 
2813  //!
2814  /*!
2815  */
2817  : a2dCanvasObjectFilterLayerMask( layer, mask, antimask )
2818  {
2819  }
2820 
2821  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2822 
2823  virtual void EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2824 
2825 private:
2826  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
2827 };
2828 
2829 //! object not fitting the mask are drawn blind.
2831 {
2832 public:
2833 
2834  //!
2835  /*!
2836  */
2839  {
2840  m_mask = mask;
2841  m_maskedCanvasObject = 0;
2842  }
2843 
2844  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2845 
2846  virtual void EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2847 
2848 protected:
2849 
2850  a2dCanvasObjectFlagsMask m_mask;
2851  a2dCanvasObjectPtr m_maskedCanvasObject;
2852 
2853 private:
2854  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
2855 };
2856 
2857 //! objects not fitting the property are not drawn, inclusif its children.
2858 /*!
2859  Mask is still checked for objects with that property and its children
2860  The drawing is only enabled by the filter, the top in a2dCanvasDocument sets it off at start.
2861 */
2863 {
2864 public:
2865 
2866  //!
2867  /*!
2868  */
2871  {
2872  m_id = id;
2873  }
2874 
2875  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2876 
2877  virtual void EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2878 
2879 protected:
2880 
2881  const a2dPropertyId* m_id;
2882 
2883 private:
2884  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
2885 };
2886 
2887 //! filter for selected a2dCanvasObject's
2888 /*!
2889 
2890 */
2892 {
2893 public:
2894 
2895  //!
2896  /*!
2897  */
2900  {
2901  }
2902 
2903  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2904 
2905  virtual void EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2906 
2907 protected:
2908 
2909 private:
2910  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
2911 };
2912 
2913 //! filter for selected a2dCanvasObject's
2914 /*!
2915 
2916 */
2918 {
2919 public:
2920 
2921  //!
2922  /*!
2923  */
2926  {
2927  }
2928 
2929  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2930 
2931  virtual void EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2932 
2933 protected:
2934 
2935 private:
2936  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
2937 };
2938 
2939 //! filter for selected a2dCanvasObject's
2940 /*!
2941 
2942 */
2944 {
2945 public:
2946 
2947  //!
2948  /*!
2949  */
2952  {
2953  }
2954 
2955  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2956 
2957  virtual void EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2958 
2959 protected:
2960 
2961 private:
2962  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; };
2963 };
2964 
2965 //! filter for tool related a2dCanvasObject's
2966 /*!
2967 
2968 */
2970 {
2971 public:
2972 
2973  //!constructor
2974  /*!
2975  */
2978  {
2979  m_id = id;
2980  }
2981 
2982  virtual bool Filter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2983 
2984  virtual void EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject );
2985 
2986 protected:
2987 
2988  const a2dPropertyId* m_id;
2989 
2990 private:
2991  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; };
2992 };
2993 
2994 
2995 class A2DCANVASDLLEXP a2dIterPP
2996 {
2997  friend class a2dIterC;
2998 public:
2999  //! Update iteration context
3000  /*! Create an object of this type locally in a a2dCanvasObject child tree
3001  iteration function at each recusion level. This will update the iteration
3002  context and restore it later
3003  */
3004  a2dIterPP( a2dIterC& ic, a2dCanvasObject* object, OVERLAP clip = _IN, a2dHit type = a2dHit() );
3005 
3006  //! construction of intitial
3007  a2dIterPP( a2dIterC& ic, const a2dAffineMatrix& matrix = a2dIDENTITY_MATRIX, OVERLAP clip = _IN );
3008 
3009  //! copy constructor
3010  a2dIterPP( const a2dIterPP& cu );
3011 
3012  //! Restore the iteration context
3013  ~a2dIterPP();
3014 
3015  //! Get the current object
3016  a2dCanvasObject* GetObject() { return m_object; }
3017 
3018  //! Get the accumulated transforms up to and including m_object->m_lworld
3019  const a2dAffineMatrix& GetTransform() { return m_relativetransform; }
3020 
3021  //! Get the accumulated transforms up to and including m_object->m_lworld
3022  const a2dAffineMatrix& GetInverseTransform() { return m_inverseRelativetransform; }
3023 
3024  const a2dAffineMatrix& GetLocalTransform() { return m_localtransform; }
3025 
3026  //! type of the hit
3027  const a2dHit& GetHitType() const { return m_type; }
3028 
3029  //! the canvas object at the current level of iteration
3031 
3032  a2dAffineMatrix m_localtransform;
3033 
3034  //! the accumulated transforms up to and including m_object->m_lworld
3036 
3037  //! inverse of m_relativetransform
3039 
3040  //! indicates type of constructor used.
3042 
3043  //! how far this object in the view being rendered
3045 
3046  //! type of the hit
3048 
3049 private:
3050  //!how many references to this object do exist
3051  int m_refcount;
3052 
3053  //! Call to have a new owner for this object
3054  /*! This function should only be called by a2dSmrtPtr
3055 
3056  \remark owning mean that the object calling this member needs to call Release at some time,
3057  in order to actually release/delete the object.
3058 
3059  \return The return value is the object itself, which is now owned on time extra.
3060 
3061  increment refcount by 1 ( use when adding a reference to this object)
3062  */
3063  a2dIterPP* SmrtPtrOwn() { m_refcount++; return this; }
3064 
3065  //!To release the object, it is not longer owned by the calling object.
3066  /*! This function should only be called by a2dSmrtPtr
3067  */
3068  bool SmrtPtrRelease()
3069  {
3070  m_refcount--;
3071  wxASSERT_MSG( m_refcount >= 0, wxT( "a2dIterCU Own/Release not matched (extra Release calls)" ) );
3072  if ( m_refcount <= 0 )
3073  {
3074  delete this;
3075  return true;
3076  }
3077  return false;
3078  }
3079 
3080 private:
3081  friend class a2dSmrtPtrBase;
3082 
3083 };
3084 
3085 //! An object of this class will update a a2dIterC with the required information
3086 /*! As iteration goes down the child hierarchy, a a2dIterCU is created to
3087  update a a2dIterC. It will update the parent list as well as the matrix
3088 
3089 Assume the following object tree
3090 
3091 \verbatim
3092  A
3093  / \
3094  B C
3095  / \ / \
3096 D E F G
3097 \endverbatim
3098 
3099  The constructors / destructors are called in the following order, and the values
3100 of GetParent and GetPreviousSibling, GetPreviousOrParent and GetPreviousDeep are shown
3101 (time is going from left to right):
3102 
3103 \verbatim
3104 Const: A B D E C F G
3105 Destr: D E B F G C A
3106 
3107 Parent: X 0 A B A B A 0 A C A C A 0 X
3108 
3109 PrevSi: X 0 0 0 0 D 0 0 B 0 B F B 0 X
3110 
3111 PrevOP: X 0 A B A D A 0 B C B F B 0 X
3112 
3113 PrevD: X 0 0 0 D D E B B B F F G C A
3114 
3115 Stack: - A A A A A A A A A A A A A -
3116  - - B B B B B - C C C C C - -
3117  - - - D - E - - - F - G - - -
3118 
3119 \endverbatim
3120 
3121 \see a2dIterC
3122 */
3123 class A2DCANVASDLLEXP a2dIterCU
3124 {
3125  friend class a2dIterC;
3126 public:
3127  //! Update iteration context
3128  /*! Create an object of this type locally in a a2dCanvasObject child tree
3129  iteration function at each recusion level. This will update the iteration
3130  context and restore it later
3131  */
3132  a2dIterCU( a2dIterC& ic, a2dCanvasObject* object, OVERLAP clip = _IN );
3133 
3134  //! construction of intitial
3135  a2dIterCU( a2dIterC& ic, const a2dAffineMatrix& matrix = a2dIDENTITY_MATRIX, OVERLAP clip = _IN );
3136 
3137  //! copy constructor
3138  a2dIterCU( const a2dIterCU& cu );
3139 
3140  //! Restore the iteration context
3141  ~a2dIterCU();
3142 
3143  //! Get the current object
3144  a2dCanvasObject* GetObject() { return m_pp->m_object; }
3145 
3146  //! Get the accumulated transforms up to and including m_object->m_lworld
3147  const a2dAffineMatrix& GetTransform() { return m_pp->m_relativetransform; }
3148 
3149  //! Get the accumulated transforms up to and including m_object->m_lworld
3150  const a2dAffineMatrix& GetInverseTransform() { return m_pp->m_inverseRelativetransform; }
3151 
3152 private:
3153 
3154  a2dIterPP* m_pp;
3155 
3156  a2dIterC* m_iterC;
3157 
3158 };
3159 
3160 
3161 //! mask flags for a2dDrawingPart::OnUpdate
3162 /*! a2dCanViewUpdateFlags
3163 \sa a2dDrawingPart
3164 
3165  \ingroup docview
3166 */
3168 {
3169  a2dCANVIEW_UPDATE_NON = 0x0000, /*!< nothing hinted */
3170 
3171  a2dCANVIEW_UPDATE_OLDNEW = 0x0001, /*!< only add pending object areas from document to arealist of all drawer views,
3172  does reset pending objects */
3173  a2dCANVIEW_UPDATE_PENDING = 0x0002, /*!< only add pending object areas from document to arealist of this drawer view,
3174  do NOT reset pending objects */
3175  a2dCANVIEW_UPDATE_ALL = 0x0004, /*!< total area displayed by drawer is added as pending to arealist
3176  (removes all other pending areas) */
3177  a2dCANVIEW_UPDATE_AREAS = 0x0008, /*!< redraw arealist into buffer or directly to device when not double buffered */
3178 
3179  a2dCANVIEW_UPDATE_AREAS_NOBLIT = 0x0010, /*!< redraw arealist into buffer but do not blit them by directly deleting the redrawn area */
3180 
3181  a2dCANVIEW_UPDATE_BLIT = 0x0020, /*!< blit updated areas to device window*/
3182 
3183  a2dCANVIEW_UPDATE_VIEWDEPENDENT = 0x0040, /*!< update objects which are view dependent */
3184 
3185  a2dCANVIEW_UPDATE_VIEWDEPENDENT_RIGHTNOW = 0x0080, /*!< update objects which are view dependent right now*/
3186 
3187  a2dCANVIEW_UPDATE_PENDING_PREUPDATE = 0x0100, /*!< only add pending object areas from document to arealist of this drawer view,
3188  do NOT reset pending objects */
3189 
3190  a2dCANVIEW_UPDATE_PENDING_POSTUPDATE = 0x0200, /*!< only add pending object areas from document to arealist of this drawer view,
3191  do NOT reset pending objects */
3192 
3193  a2dCANVIEW_UPDATE_PENDING_PREVIEWUPDATE = 0x0800, /*!< same as a2dCANVIEW_UPDATE_PENDING_PREUPDATE but event called before that*/
3194 
3195  a2dCANVIEW_UPDATE_SYNC_DRAWERS = a2dCANVIEW_UPDATE_OLDNEW | a2dCANVIEW_UPDATE_AREAS | a2dCANVIEW_UPDATE_BLIT
3196 
3197 };
3198 
3199 typedef unsigned int a2dCanViewUpdateFlagsMask;
3200 
3201 //! while iterating a a2dCanvasDocument, this holds the context.
3202 /*!
3203  The context is a collection of information, which might be needed when
3204  traversing the document.
3205  e.g. Transforms for drawing and conversion to absolute coordinates are stored here.
3206 
3207  Specific information in the context can be valid or not.
3208  If the information is set and is valid, a flag is set too.
3209  This flag is checked when information is asked for. Asking for non valid information
3210  will result in an assert.
3211 */
3212 class A2DCANVASDLLEXP a2dIterC
3213 {
3214  friend class a2dIterPP;
3215  friend class a2dIterCU;
3216  friend class a2dCorridor;
3217 
3218 public:
3219 
3220  //! constructor used when drawer is not known
3221  a2dIterC();
3222 
3223  //! constructor used when drawer is known ( usually the case )
3224  /*!
3225  \param drawer the drawer that is currently in use.
3226  \param level how deep is the starting object to render from the ShowObject of the a2dDrawingPart.
3227  */
3228  a2dIterC( a2dDrawingPart* drawer, int level = 0 );
3229 
3230  //! destructor
3231  ~a2dIterC();
3232 
3233  //! when true, disable inversion of matrixes
3234  /*!
3235  e.g. when rendering a document the inverted matrix is not needed, so we disable the calculation to gain speed.
3236  */
3237  void SetDisableInvert( bool disableInvert ) { m_disableInvert = disableInvert; }
3238 
3239  //! see SetDisableInvert()
3240  inline bool GetDisableInvert() { return m_disableInvert; }
3241 
3242  //! Reset this object for beeing reused. It will keep the drawer but NULL object infos
3243  void Reset();
3244 
3245  a2dIterPP* Push( const a2dAffineMatrix& matrix, OVERLAP clip );
3246 
3247  a2dIterPP* Push( a2dCanvasObject* object, OVERLAP clip );
3248 
3249  void Pop();
3250 
3251  a2dIterPP* Last() { return m_contextList.back(); }
3252 
3253  //! used to extend a hittest with the number of pixels.
3254  /*! to be able to hit a line of width zero, a margin is needed to hit it,
3255  which is set here.
3256  In fact this value is directly converted to a value in world coordinates,
3257  using the current GetDrawer2D(). GetHitMarginWorld() returns this value.
3258 
3259  \remark default value is taken from a2dDrawingPart or a2dCanvasGlobal
3260  */
3261  void SetHitMarginDevice( int pixels );
3262 
3263  //! used to extend a hittest with the given margin in world coordinates.
3264  /*! to be able to hit a line of width zero, a margin is needed to hit it,
3265  which is set here.
3266 
3267  \remark default value is taken from a2dCanvasGlobal::GetHitMarginWorld
3268  */
3269  void SetHitMarginWorld( double world );
3270 
3271  //! Get HitMargin in World units.
3272  double GetHitMarginWorld();
3273 
3274  //! Transform a pixel extend from device to world units
3275  /*! If no drawer is there (e.g. command procesing) the return value will be zero */
3276  double ExtendDeviceToWorld( int extend );
3277 
3278  //! transformed to object its coordinate system
3279  double GetTransformedHitMargin();
3280 
3281  //! get the layer that is to be rendered
3282  inline wxUint16 GetLayer() { return m_layer; }
3283 
3284  //! set the layer that is to be rendered
3285  /*!
3286  wxLAYER_ALL has the special meaning that it renderers all layers at once.
3287  */
3288  void SetLayer( wxUint16 layer ) { m_layer = layer; }
3289 
3290  //! get setting for command generation or not.
3291  inline bool GetGenerateCommands() { return m_generateCommands; }
3292 
3293  //! set to generate command or not in certain situations.
3294  /*!
3295  */
3296  void SetGenerateCommands( bool generateCommands ) { m_generateCommands = generateCommands; }
3297 
3298  //!get the mapping matrix
3299  const a2dAffineMatrix& GetMappingTransform() const;
3300 
3301  //! get matrix which transforms directly from relative world coordinates to device
3302  const a2dAffineMatrix& GetUserToDeviceTransform() const;
3303 
3304  //! get current a2dDrawingPart
3305  a2dDrawingPart* GetDrawingPart() const;
3306 
3307  //! get current a2dDrawer2D
3308  a2dDrawer2D* GetDrawer2D() const;
3309 
3310  //!set drawstyle used for rendering the document
3311  /*!
3312  The drawstyle is set in a2dCanvasDocument when rendering parts of the document.
3313 
3314  \param drawstyle one of the draw styles
3315  */
3316  void SetDrawStyle( a2dDocumentRenderStyle drawstyle ) { m_drawstyle = drawstyle; }
3317 
3318  //!get drawstyles used for drawing the document
3319  a2dDocumentRenderStyle GetDrawStyle() { return m_drawstyle; }
3320 
3321  //! when traversing tree this the object one level higher.
3322  /*!
3323  Used internal during rendering etc.
3324  During recursive traversing a a2dCanvasDocument from top group that is displayed
3325  this holds the a2dCanvasObject that is one level higher in the branch that is traversed
3326  used during rendering etc., to know what is the parent object in a branch that is being rendered
3327  */
3328  a2dCanvasObject* GetParent() const;
3329 
3330  //! the object where the iterative context is currently
3331  a2dCanvasObject* GetObject() const;
3332 
3333  //! Get the accumulated transform up to and including m_lworld of the current object
3334  /*! This converts from relative local coordinates of the current object to world coordinates.
3335  This matrix transforms all drawing primitives used to draw a a2dCanvasObject from relative
3336  world coordinates to absolute world coordinates.
3337  */
3338  const a2dAffineMatrix& GetTransform() const;
3339 
3340  //! Inverse of GetTransform()
3341  const a2dAffineMatrix& GetInverseTransform() const;
3342 
3343  //! Get the accumulated transform up to but NOT including m_lworld of the current obejct
3344  /*! This converts from local coordinates of the curent object to world coordinates
3345  !!!! I am not sure if it should contains the view transform (world->device) as well !!!!
3346  */
3347  const a2dAffineMatrix& GetParentTransform() const;
3348 
3349  //! inverse of GetParentTransform()
3350  const a2dAffineMatrix& GetInverseParentTransform() const;
3351 
3352  //! number of levels deep we are inside a document as seen from the m_top
3353  int GetLevel() const { return m_levels; }
3354 
3355  //! to set corridor path ( also to captured object), its a2dCanvasOFlags::IsOnCorridorPath flag is set on or off.
3356  /*!
3357  The iteration context knows its parent object via its m_bottom and m_parent a2dIterCU.
3358  Each a2dIterCU added when going deeper into the drawing hierarchy, knows from which object it came.
3359  This way, it is possible to iterate back to the top/show object in a a2dDrawingPart.
3360  All canvasobjects passed that way is called the event path.
3361  Of course when going up in hierarchy, the event path is becoming smaller again. And when arriving at the top
3362  it will be zero.
3363  To preserve the event path to a specific canvas object, a flag can be set along the canvas objects in
3364  the current event path. Those flags will be kept intact inside the canvasobjects, even if the event path
3365  is changing after setting the flags.
3366  The a2dCanvasOFlags::IsOnCorridorPath set this way, is/can be used to find and redirect events to the
3367  objects along or at the end of this path. The path created like this is called the Corridor path.
3368 
3369  When capturing an object, the corridor is used to redirect events to that object, even
3370  if the object is a deeper nested child. A non captured corridor also redirects
3371  events to the last object in the corridor, but still does normal event processing
3372  from that point on. So only a positive hittest will really make the event go to the object.
3373  When also capturing the object at the end of a corridor, the mouse event is always going to that object,
3374  even if it does not hit it.
3375 
3376  \param OnOff to set the corridor path on or off.
3377  \param captureObject to set this as a captured object at the end of the corridor, if NULL non is captured.
3378  */
3379  void SetCorridorPath( bool OnOff, a2dCanvasObject* captureObject = NULL );
3380 
3381  /* set corridor path to parent of current iteration context */
3382  void SetCorridorPathToParent();
3383 
3384  //! leaves corridorpath as is, but resets the capture object at the end of the corridor to
3385  //! the given object. If NULL, the corridor is set to non captured.
3386  void SetCorridorPathCaptureObject( a2dCanvasObject* captureObject );
3387 
3388  //! when there is a corridor path set, this return if end has bin found while iterating.
3389  bool GetFoundCorridorEnd() { return m_foundCorridorEnd; }
3390 
3391  //! when there is a corridorPath set, this is used internal to set this flag to indicate that the end of it was found.
3392  void SetFoundCorridorEnd( bool foundCorridorEnd ) { m_foundCorridorEnd = foundCorridorEnd; }
3393 
3394  //! Set strokeworld extend of last added object, used in a2dCanvasObject::DoIsHitWorld()
3395  /*!
3396  Holds the size/width of the Stroke in world coordinates, else 0.
3397  This can be used in derived a2dCanvasObject to do a proper hittest.
3398  If the stroke is of type pixel, that value will be converted into world coordinates.
3399  */
3400  void SetStrokeWorldExtend( double worldStrokeExtend ) { m_worldStrokeExtend = worldStrokeExtend; }
3401 
3402  //! \see SetWorldStrokeExtend()
3403  double GetWorldStrokeExtend() { return m_worldStrokeExtend; }
3404 
3405  //! what is the clipping withing the current view for the last added object in context
3406  OVERLAP GetClipStatus() const;
3407 
3408  //! what is the clipping withing the current view for the second last added object in context
3409  OVERLAP GetParentClipStatus() const;
3410 
3411  //! set the clipping withing the current view for the last added object in context
3412  void SetClipStatus( OVERLAP status );
3413 
3414  //! get the filter set for the iteration context.
3415  a2dCanvasObjectFilter* GetObjectFilter() { return m_objectFilter; }
3416 
3417  //! set object filter class.
3418  void SetObjectFilter( a2dCanvasObjectFilter* filter ) { m_objectFilter = filter; }
3419 
3420  //! apply object filter
3421  bool FilterObject( a2dCanvasObject* canvasObject );
3422 
3423  //! called when filter ends
3424  void EndFilterObject( a2dCanvasObject* canvasObject );
3425 
3426  //! if set the rendering is done layers by layer from the top
3427  void SetPerLayerMode( bool value ) { m_perLayerMode = value; }
3428 
3429  //! if set the rendering is done layers by layer from the top
3430  bool GetPerLayerMode() { return m_perLayerMode; }
3431 
3432  //! when set child object in derived a2dCanvasObject are rendered, else only the object itself.
3433  void SetRenderChildDerived( bool value ) { m_renderChildDerived = value; }
3434 
3435  //! when set child object in derived a2dCanvasObject are rendered, else only the object itself.
3436  bool GetRenderChildDerived() { return m_renderChildDerived; }
3437 
3438  //! set during event processing down the hierarchy, to the deepest object that was hit
3439  void SetDeepestHit( a2dCanvasObject* canvasObject ) { m_deepestHit = canvasObject; }
3440 
3441  //! get deepest object that was hit during event processing down the hierarchy.
3442  a2dCanvasObject* GetDeepestHit() const { return m_deepestHit; }
3443 
3444  void SetUpdateHint( a2dCanViewUpdateFlagsMask updateHint ) { m_updateHint = updateHint; }
3445 
3446  a2dCanViewUpdateFlagsMask GetUpdateHint() { return m_updateHint; }
3447 
3448  a2dSmrtPtrList< a2dIterPP > m_contextList;
3449  a2dSmrtPtrList< a2dIterPP > m_contextListDeep;
3450 
3451 private:
3452 
3453  //! if true no inversion on matrixes is done.
3454  bool m_disableInvert;
3455 
3456  //!world to device coordinate mapping
3457  a2dAffineMatrix m_mapping;
3458 
3459  //!relative world to device transform matrix ( so includes mapping matrix )
3460  a2dAffineMatrix m_usertodevice;
3461 
3462  //! during event processing down the hierarchy, this is set to deepest object hit.
3463  a2dSmrtPtr<a2dCanvasObject> m_deepestHit;
3464 
3465  //! from which a2dDrawingPart the iteration started.
3466  a2dSmrtPtr<a2dDrawingPart> m_drawingPart;
3467 
3468  //! how close in pixles does a hit need to be to the object you are trying to hit.
3469  /*! this is in world units */
3470  double m_hitmargin_world;
3471 
3472  //! How much child levels deep are we, seen from the ShowObject of the a2dDrawingPart.
3473  int m_levels;
3474 
3475  //! when there is a corridorPath set, this is set when end is found.
3476  bool m_foundCorridorEnd;
3477 
3478  //! \see SetWorldExtend()
3479  double m_worldStrokeExtend;
3480 
3481  //! drawstyles used to render document
3482  a2dDocumentRenderStyle m_drawstyle;
3483 
3484  //! for filtering objects when e.g. rendering
3485  a2dSmrtPtr<a2dCanvasObjectFilter> m_objectFilter;
3486 
3487  //! the layer that is currently rendered.
3488  wxUint16 m_layer;
3489 
3490  //! see SetGenerateCommands()
3491  bool m_generateCommands;
3492 
3493  bool m_ownDrawer;
3494 
3495  //! if set the rendering is done layers by layer from the top
3496  bool m_perLayerMode;
3497 
3498  //! when set child object in derived a2dCanvasObject are rendered, else only the object itself.
3499  bool m_renderChildDerived;
3500 
3501  a2dCanViewUpdateFlagsMask m_updateHint;
3502 
3503 };
3504 
3505 #endif // WXCANOBJ
3506 
3507 
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
Definition: canobj.h:301
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
bool m_processed
set if event was processed sofar
Definition: canobj.h:311
virtual bool GeneratePins(a2dPinClass *toConnectTo, a2dConnectTask task, double x, double y, double margin=0)
create pins in derived objects.
Definition: canobj.h:2054
virtual void EndFilter(a2dIterC &ic, a2dCanvasObject *canvasObject)
called from a2dCanvasObject to reset filtering feature when filtered object goes out of context...
Definition: canobj.h:2771
void SetFixedStyle(bool fixedStyle)
Set object to fixed style ot not.
Definition: canobj.h:1587
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
bool GetFilled() const
Definition: canobj.h:1476
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
Definition: canobj.h:289
bool GetSnap() const
is snap flag set?
Definition: canobj.h:1686
bool GetDisableInvert()
see SetDisableInvert()
Definition: canobj.h:3240
bool m_objectLevel
indicates type of constructor used.
Definition: canobj.h:3041
objects with m_editingcopy or m_toolobject are skipped.
Definition: canobj.h:2809
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
hit if visible
Definition: canobj.h:165
bool GetGeneratePins() const
get the GeneratePins flag
Definition: canobj.h:2289
a2dCanViewUpdateFlags
mask flags for a2dDrawingPart::OnUpdate
Definition: canobj.h:3167
bool GetGenerateCommands()
get setting for command generation or not.
Definition: canobj.h:3291
void SetGeneratePins(bool value)
set the GeneratePins flag
Definition: canobj.h:2295
bool m_continue
set if the event processing or hittest needs to continue after first hit
Definition: canobj.h:313
virtual bool IsVirtConnect() const
object is a virtual connection (connects invisible with other objects without using wires ) ...
Definition: canobj.h:1834
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin or some other objects that needs a parent
Definition: canobj.h:2122
a2dHandle is used inside editing versions of a certain objects.
Definition: canpin.h:30
bool GetEditable() const
get if the object may be edited
Definition: canobj.h:1584
The a2dBaseTool is used to derive tools from that are controlled by.
Definition: tools.h:379
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
Definition: connectgen.h:40
float GetWorldExtend() const
get world extend
Definition: canobj.h:777
no special options
Definition: canobj.h:79
a2dAffineMatrix m_relativetransform
the accumulated transforms up to and including m_object-&gt;m_lworld
Definition: canobj.h:3035
filter for tool related a2dCanvasObject&#39;s
Definition: canobj.h:2969
void SetFoundCorridorEnd(bool foundCorridorEnd)
when there is a corridorPath set, this is used internal to set this flag to indicate that the end of ...
Definition: canobj.h:3392
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
Definition: canobj.h:500
virtual bool IsTemporary_DontSave() const
Check if this is a temporary object, which should not be saved.
Definition: gen.h:1258
a2dCanvasObjectHitFlags
event mask flags for a2dCanvasObject hit
Definition: canobj.h:158
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
Creates a shadow behind a a2dCanvasObject when added as property.
Definition: canprop.h:157
a2dDrawing * m_root
root group for rendering and accessing the canvas&#39;s also contains layer settings
Definition: canobj.h:2525
a2dDocumentRenderStyle operator|(a2dDocumentRenderStyle a, a2dDocumentRenderStyle b)
OR-ing a2dDocumentRenderStyle is allowed.
Definition: canglob.h:50
filter for selected a2dCanvasObject&#39;s
Definition: canobj.h:2917
a2dCanvasObject * GetDeepestHit() const
get deepest object that was hit during event processing down the hierarchy.
Definition: canobj.h:3442
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
virtual bool AdjustPinLocation()
Allow change in pin location when wiring things up.
Definition: canobj.h:2058
int m_level
level of the hit object below the start (root) object
Definition: canobj.h:225
void SetSelected2(bool selected)
Set the object selected2 flag if allowed.
Definition: canobj.h:1639
a2dPin is used in a2dCanvasObject to add pins to it.
Definition: canpin.h:233
This is a class/type description for a2dPin&#39;s.
Definition: canpin.h:628
static a2dCanvasOFlags m_flagsInit
holds value for flags to initialize m_flags
Definition: canobj.h:2533
static a2dPropertyIdVoidPtr * PROPID_ToolObject
set for objects that act as tool object, when a tool is in action.
Definition: canobj.h:2678
static a2dHit stock_nohit
Stock object for no hit.
Definition: polyver.h:135
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: gen.cpp:1488
Ref Counted base object.
Definition: gen.h:1045
bool GetPending() const
is this object pending for update?
Definition: canobj.h:1162
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object.
Definition: canobj.h:509
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
Definition: canobj.h:952
a2dIOHandlerCVGIn and a2dIOHandlerCVGOut - XML I/O classes for the CVG format.
virtual void SetContourWidth(double width)
set the Contour width of the shape
Definition: canobj.h:1408
a2dIOHandler takes care of loading and/or saving data.
Definition: gen.h:3592
double GetBboxMinY()
get minimum Y of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:682
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
Definition: gen.cpp:1199
wxUint16 GetLayer()
get the layer that is to be rendered
Definition: canobj.h:3282
a2dCanvasOHitFlags m_hitflags
allow hits on basis of those flags
Definition: canobj.h:2536
This template class is for property ids meant for properties that do not encapsulate another type...
Definition: id.h:397
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
virtual int GetMode() const
get the rendering mode of the object.
Definition: canobj.h:1718
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
void SetStrokeWorldExtend(double worldStrokeExtend)
Set strokeworld extend of last added object, used in a2dCanvasObject::DoIsHitWorld() ...
Definition: canobj.h:3400
void SetSelectable(bool selectable)
Allows to select this object.
Definition: canobj.h:1664
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
bool ParseCvgTransForm(a2dAffineMatrix &matrix, const wxString &str, wxString &error)
function to parse a string in SVG/CVG format and return the resulting matrix
Definition: afmatrix.cpp:890
a2dCanvasObjectPtr m_object
the canvas object at the current level of iteration
Definition: canobj.h:3030
a2dCanvasObjectFilter * GetObjectFilter()
get the filter set for the iteration context.
Definition: canobj.h:3415
object hit should not have select flag set
Definition: canobj.h:90
A trivial base class for a2dSmrtPtr. Non-template class, so that it can.
Definition: smrtptr.h:55
void SetShowShadow(bool showshadow)
If True shadow object is visible (if property is there)
Definition: canobj.h:1489
snapping engine, for snapping while editing a drawing
This is one hit result from a2dExtendedResult.
Definition: canobj.h:192
#define DECLARE_PROPERTIES()
check if class has the given id as a valid id for this object
Definition: gen.h:835
virtual bool UserBaseFunction()
can be used by the user to implement a function that affects all a2dCanvas derived objects ...
Definition: canobj.h:2402
double GetBboxMinX()
get minimum X of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:676
wxUint16 m_layer
layer of object, default wxLAYER_DEFAULT
Definition: canobj.h:2556
int GetLevel() const
level of the hit object below the start (root) object
Definition: canobj.h:213
vertex array of line and arc segments.
Definition: polyver.h:494
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
Definition: afmatrix.cpp:51
a2dHit m_type
type of the hit
Definition: canobj.h:3047
routing of wires.
a2dBoundingBox wxNonValidBbox
global non valid boundingbox to use as default argument etc.
Definition: bbox.cpp:23
double GetBboxMaxY()
get maximum Y of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:694
a2dCanvasObjectFilterToolObjects(const a2dPropertyId *id, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor
Definition: canobj.h:2976
bool SetPointIfCloser(const a2dPoint2D &pointToSnapTo, const a2dPoint2D &pointToSnap, a2dPoint2D &bestPointSofar, double thresHoldWorld)
Definition: canobj.cpp:4189
a2dCanvasObject * GetObject()
Get the current object.
Definition: canobj.h:3016
void SetEditable(bool editable)
Sets if this object may be edited.
Definition: canobj.h:1581
vertex list of line and arc segments.
Definition: polyver.h:600
void SetObjectFilter(a2dCanvasObjectFilter *filter)
set object filter class.
Definition: canobj.h:3418
defenitions an no more
OVERLAP m_clip
how far this object in the view being rendered
Definition: canobj.h:3044
bool GetSelected() const
is the object selected flag set
Definition: canobj.h:1603
void SetSelected(bool selected)
Set the object selected flag if allowed.
Definition: canobj.h:1620
a2dAffineMatrix m_inverseRelativetransform
inverse of m_relativetransform
Definition: canobj.h:3038
filter for selected a2dCanvasObject&#39;s
Definition: canobj.h:2891
virtual a2dCanvasObject * GetParent() const
Definition: canobj.h:2126
double GetBboxWidth()
get width of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:700
void SetBin(bool bin)
general flag use at will.
Definition: canobj.h:2259
bool IsVisible() const
get visibility (rendering depends on layer settings also)
Definition: canobj.h:1316
double GetBboxMaxX()
get maximum X of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:688
static a2dPropertyIdBool * PROPID_FirstEventInObject
set in Startedit(), to be used to detect first (mouse)event sent to object.
Definition: canobj.h:2694
float m_worldExtend
world extend in world coordinates.
Definition: canobj.h:2545
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
Definition: canobj.h:2559
static a2dPropertyIdRefObject * PROPID_ViewSpecific
Definition: canobj.h:2691
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
Definition: candefs.h:152
virtual void OnPropertyChanged(const a2dPropertyId *id)
This function is called after a property changed.
Definition: gen.cpp:1635
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
bool GetGroupA() const
get the groupA flag
Definition: canobj.h:2267
a2dFillStyle
Filling styles for a2dFill.
Definition: stylebase.h:91
void SetGroupA(bool value)
set the groupA flag
Definition: canobj.h:2273
class a2dCanvasObject * GetObject() const
the hit object
Definition: canobj.h:207
a2dCanvasObject * m_parent
the parent object of the hit object
Definition: canobj.h:220
bool m_xyRelToChildren
is set, m_x and m_y are supplied relative to the child objects ( object matrix m_world already applie...
Definition: canobj.h:297
wxUint32 m_option
the way to hit/traverse the document.
Definition: canobj.h:299
void SetIgnoreSetpending(bool value=true)
set IgnoreSetpending flag
Definition: canobj.h:2299
bool GetPreRenderAsChild() const
Returns if this object should be rendered before other children objects.
Definition: canobj.h:1472
void SetHasToolObjectsBelow(bool value)
selected object itself or one of its recursive children
Definition: canobj.h:1770
a2dText is an abstract base class.
Definition: cantext.h:93
virtual bool UserBaseFunctionVar(...)
can be used by the user to implement a function using a variable argument list that affects all a2dCa...
Definition: canobj.h:2415
virtual bool EditProperties(const a2dPropertyId *id, bool withUndo=true)
edit properties of the object
Definition: gen.cpp:1499
a2dCanvasObjectList * m_childobjects
holds child objects
Definition: canobj.h:2562
void SetDrawStyle(a2dDocumentRenderStyle drawstyle)
set drawstyle used for rendering the document
Definition: canobj.h:3316
void Transform(const a2dAffineMatrix &tworld)
transform the object using the given matrix
Definition: canobj.h:577
a2dExtendedResult m_extended
extended result information with e.g path to lead to the nested object hit
Definition: canobj.h:303
no special flags set
Definition: canobj.h:112
bool GetIgnoreSetpending() const
get IgnoreSetpending flag
Definition: canobj.h:2303
a2dHitOption
Enum for hit test options.
Definition: canobj.h:76
bool GetSnapTo() const
is snap_to flag set?
Definition: canobj.h:1707
double GetPosX() const
get x position from affine matrix
Definition: canobj.h:527
Definition: bbox.h:26
bounding class for optimizing drawing speed.
hit if filled
Definition: canobj.h:161
Drawing context abstraction.
Definition: drawer2d.h:177
static a2dPropertyIdBool * PROPID_TemporaryObject
set for objects that do not have to be saved
Definition: canobj.h:2681
void SetDisableInvert(bool disableInvert)
when true, disable inversion of matrixes
Definition: canobj.h:3237
const a2dAffineMatrix & GetTransform()
Get the accumulated transforms up to and including m_object-&gt;m_lworld.
Definition: canobj.h:3019
class a2dCanvasObject * GetParent() const
the parent object of the hit object
Definition: canobj.h:209
bool GetShowShadow() const
If True shadow object is visible (if property is there)
Definition: canobj.h:1486
const a2dAffineMatrix & GetInverseTransform()
Get the accumulated transforms up to and including m_object-&gt;m_lworld.
Definition: canobj.h:3150
void SetPerLayerMode(bool value)
if set the rendering is done layers by layer from the top
Definition: canobj.h:3427
virtual bool UserBaseFunctionEx(int function, a2dIOHandler *handler=NULL)
can be used by the user to implement a function that affects all a2dCanvas derived objects ...
Definition: canobj.h:2412
void SetResizeOnChildBox(bool resizeToChilds)
If True resize to child boundingbox.
Definition: canobj.h:1499
void SetDeepestHit(a2dCanvasObject *canvasObject)
set during event processing down the hierarchy, to the deepest object that was hit ...
Definition: canobj.h:3439
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
Definition: canobj.h:569
a2dCanvasObject hit flags as a structure
Definition: canobj.h:172
general event sent from a2dHandle to its parent a2dCanvasObject
Definition: canglob.h:273
virtual void Initialize()
Definition: canobj.h:420
bool m_extendedWanted
fill m_extended or not
Definition: canobj.h:305
bool m_isHit
in the end if there was a hit (even if not processed event)
Definition: canobj.h:315
wxUint16 GetLayer() const
Returns the layer index where this object is drawn upon.
Definition: canobj.h:2368
general hittest functions
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
if set, respect layer order, hit testing is done per layer from the top.
Definition: canobj.h:82
bool GetResizeOnChildBox() const
see SetResizeOnChildBox()
Definition: canobj.h:1492
bool IsSelected() const
Is the object selected flag set.
Definition: canobj.h:1610
bool GetBin() const
general flag use at will.
Definition: canobj.h:2262
Invisible Style property that can be added to Canvas Objects.
Definition: canprop.h:55
bool GetChildOnlyTranslate() const
are children rendered using just the translation of the parent or also rotation and scale...
Definition: canobj.h:1456
a2dCanvasObject * GetObject()
Get the current object.
Definition: canobj.h:3144
void SetFilled(bool filled)
set the filled flag to render only outlines
Definition: canobj.h:1483
a2dCanvasObject flags as a structure
Definition: candefs.h:164
a2dCanvasObject * m_object
the hit object
Definition: canobj.h:218
int GetLevel() const
number of levels deep we are inside a document as seen from the m_top
Definition: canobj.h:3353
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
Definition: restrict.h:26
a2dBboxFlag
flags for calculating boundingbox of derived object
Definition: canobj.h:663
no hit will be reported
Definition: canobj.h:160
editing is completely controlled by tools. No handles are added
Definition: canobj.h:140
int m_refcount
how many references to this object do exist
Definition: gen.h:1564
corridor as a direct event path to a a2dCanvasObject
Definition: objlist.h:313
defines common settinsg for a habitat for a set of a2dCameleons.
Definition: canglob.h:439
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
Definition: canobj.h:1303
void SetSnapTo(bool snap)
Sets snap_to flag.
Definition: canobj.h:1704
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
static a2dPropertyIdMatrix * PROPID_IntViewDependTransform
used for objects with* PROPID_viewDependent but only for internal area
Definition: canobj.h:2705
a2dPoint2D GetPosXY() const
get position of object
Definition: canobj.h:533
static a2dPropertyIdWindow * PROPID_TipWindow
when set used for tip window by default in OnCanvasMouseEvent()
Definition: canobj.h:2718
wxUint16 m_pixelExtend
Pixel extend.
Definition: canobj.h:2553
if set, don&#39;t hit test the root object or object for which IsHitWorld is called
Definition: canobj.h:87
bool DoConnect()
if return true, connection with other object on this object its pins is allowed.
Definition: canobj.h:1845
a2dExtendedResultItem(a2dCanvasObject *object, a2dCanvasObject *parent, a2dHit type, int level, int typeex)
Standard Constructor.
Definition: canobj.h:198
bool GetFixedStyle() const
Get object fixed style setting.
Definition: canobj.h:1590
double GetPosY() const
get y position from affine matrix
Definition: canobj.h:530
double GetWorldStrokeExtend()
Definition: canobj.h:3403
virtual double GetContourWidth() const
get the Contour width of the shape
Definition: canobj.h:1411
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
void SetChildOnlyTranslate(bool onlytranslate)
How a child is placed towards its parent object.
Definition: canobj.h:1453
struct for how a single object on one layer was hit
Definition: polyver.h:38
double m_x
(world coordinates) hit point x as in a2dDrawingPart or any other top level
Definition: canobj.h:293
bool GetPerLayerMode()
if set the rendering is done layers by layer from the top
Definition: canobj.h:3430
static const a2dCanvasObjectFlagsMask NON
Flags for a2dCanvasObject.
Definition: candefs.h:179
void SetHasSelectedObjectsBelow(bool value)
selected object itself or one of its recursive children
Definition: canobj.h:1764
void SetSnap(bool snap)
Sets snap flag.
Definition: canobj.h:1695
static a2dPropertyIdMenu * PROPID_PopupMenu
when set used for popup menu by default in OnPopUpEvent()
Definition: canobj.h:2715
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
general modules header files all together.
virtual a2dVertexList * GetAsVertexList(bool &returnIsPolygon) const
convert to a polygon.
Definition: canobj.h:2491
a2dHit m_type
type of the hit
Definition: canobj.h:222
void SetChildrenOnSameLayer(bool samelayer)
if set children are rendered on the same layer as this object.
Definition: canobj.h:1429
int m_id
application specific use
Definition: canobj.h:317
void SetGenerateCommands(bool generateCommands)
set to generate command or not in certain situations.
Definition: canobj.h:3296
const a2dAffineMatrix & GetInverseTransform()
Get the accumulated transforms up to and including m_object-&gt;m_lworld.
Definition: canobj.h:3022
const a2dAffineMatrix & GetTransform()
Get the accumulated transforms up to and including m_object-&gt;m_lworld.
Definition: canobj.h:3147
bool GetFoundCorridorEnd()
when there is a corridor path set, this return if end has bin found while iterating.
Definition: canobj.h:3389
bool GetGroupB() const
get the groupA flag
Definition: canobj.h:2278
const a2dHit & GetHitType() const
type of the hit
Definition: canobj.h:211
wxObject * GetParent()
Definition: gen.h:3972
void SetGroupB(bool value)
set the groupA flag
Definition: canobj.h:2284
bool GetRenderChildDerived()
when set child object in derived a2dCanvasObject are rendered, else only the object itself...
Definition: canobj.h:3436
bool IsEditable() const
get if the object may be edited
Definition: canobj.h:1597
a2dExtendedResultItem()
Default Constructor.
Definition: canobj.h:196
virtual bool DoIgnoreIfNotMember(const a2dPropertyId *id) const
used to decide if a property shall be ignored, if it is not a member
Definition: gen.h:1393
void DoConnect(bool doconnect)
If set to true this object may be connected to other object on its pins.
Definition: canobj.h:1849
virtual bool Filter(a2dIterC &ic, a2dCanvasObject *canvasObject)
called from a2dCanvasObject to filter objects for rendering
Definition: canobj.h:2768
bool IsDraggable() const
get if the object can be dragged
Definition: canobj.h:1683
filter for selected a2dCanvasObject&#39;s
Definition: canobj.h:2943
This is the base class for all kinds of property id&#39;s for a2dObject.
Definition: id.h:154
bool IsSelectable() const
Is the object selectable flag set.
Definition: canobj.h:1655
An object of this class will update a a2dIterC with the required information.
Definition: canobj.h:3123
hit if stroked
Definition: canobj.h:162
style properties that are specific to the canvas modules.
void SetIsProperty(bool IsProperty)
Definition: canobj.h:2152
if set, don&#39;t stop at the first hit, but test child/sibling objects anyway
Definition: canobj.h:97
int m_maxlevel
maximum level of hit object below this (this = level 0)
Definition: canobj.h:307
void SetLayer(wxUint16 layer)
set the layer that is to be rendered
Definition: canobj.h:3288
void SetDraggable(bool draggable)
Sets if this object may be dragged.
Definition: canobj.h:1673
bool GetHasSelectedObjectsBelow() const
selected object itself or one of its recursive children
Definition: canobj.h:1761
objects not fitting the property are not drawn, inclusif its children.
Definition: canobj.h:2862
double GetBboxHeight()
get height of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:706
hit if stroke is not transparent
Definition: canobj.h:164
always hit
Definition: canobj.h:166
see a2dComEvent
Definition: gen.h:371
bool GetVisible() const
get visibility (rendering depends on layer settings also)
Definition: canobj.h:1309
int m_typeex
Extended hit type.
Definition: canobj.h:231
bool GetSelectable() const
is the object selectable flag set
Definition: canobj.h:1648
used to tell which child object to render and to detect the need for it.
Definition: canobj.h:381
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
bool GetChildrenOnSameLayer() const
are children rendered on the same layer as this object?
Definition: canobj.h:1432
virtual void SetMode(int mode)
you may use it to modify rendering of the object depending on setting
Definition: canobj.h:1715
static a2dPropertyIdDateTime * PROPID_DateTime
some time property which a user wants to store
Definition: canobj.h:2708
bool GetHasToolObjectsBelow() const
tool object itself or one of its recursive children
Definition: canobj.h:1767
affine matrix class
int GetPixelExtend() const
get pixel extend
Definition: canobj.h:795
static a2dPropertyIdBoundingBox * PROPID_BoundingBox
used to store state ( redraw area) of the object as it was before a change
Definition: canobj.h:2684
Classes for generating connection between pins in canvas objects.
An object of this class represents the context of a query like a hit test.
Definition: canobj.h:238
object not fitting the mask are drawn blind.
Definition: canobj.h:2830
void SetPosXyPoint(const a2dPoint2D &pos)
set position to x,y
Definition: canobj.h:547
bool GetSelected2() const
is the object selected2 flag set
Definition: canobj.h:1629
virtual bool NeedsUpdateWhenConnected() const
used in case of flexible canvas objects (wires).
Definition: canobj.h:1841
static a2dPropertyIdBool * PROPID_ToolDecoration
set for objects that act as tool decorations, when a tool is in action.
Definition: canobj.h:2675
filter on this layer and mask.
Definition: canobj.h:2780
This template class is for property ids with a known data type.
Definition: id.h:477
a2dBoundingBox m_bbox
boundingbox in world coordinates
Definition: canobj.h:2539
Walker taking iterative context into account.
Definition: algos.h:1208
static bool GetIgnoreAllSetpending()
get static IgnoreSetpending flag
Definition: canobj.h:2311
static a2dPropertyIdTagVec * PROPID_Tags
used in tool when grouping using tags
Definition: canobj.h:2721
hit if filling is not transparent
Definition: canobj.h:163
static const a2dCanvasObjectFlagsMask ALL
Definition: candefs.h:220
class use by a2dIterC to filter objects for rendering.
Definition: canobj.h:2756
bool GetIsProperty() const
Definition: canobj.h:2156
a2dStrokeStyle
stroke styles for a2dStroke
Definition: stylebase.h:298
a2dDocumentRenderStyle
Define the manner in which a2dCanvasView draws the document to the device.
Definition: candefs.h:84
static a2dPropertyIdUint16 * PROPID_Datatype
used in GDSII and KEY format to specify the DATATYPE of elements
Definition: canobj.h:2700
virtual bool IsConnect() const
return true, if this object is used to connect other object&#39;s using rubberband like structures...
Definition: canobj.h:1831
wxEvent * m_event
event to process in case of event processing call
Definition: canobj.h:309
void SetRenderChildDerived(bool value)
when set child object in derived a2dCanvasObject are rendered, else only the object itself...
Definition: canobj.h:3433
list of a2dObject&#39;s
Definition: gen.h:3157
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
Definition: canobj.h:291
a2dDocumentRenderStyle GetDrawStyle()
get drawstyles used for drawing the document
Definition: canobj.h:3319
double m_y
(world coordinates) hit point y as in a2dDrawingPart or any other top level
Definition: canobj.h:295
edit a copy of the original object
Definition: canobj.h:132
CloneOptions
options for cloning
Definition: gen.h:1200
bool GetDraggable() const
get if the object can be dragged
Definition: canobj.h:1676
static a2dPropertyIdRefObject * PROPID_ViewDependent
used for objects that depend on &#39;aView&#39; view when it comes to size.
Definition: canobj.h:2703
void SetPreRenderAsChild(bool prerender)
If set, this object has a higher priority in rendering than other children objects.
Definition: canobj.h:1469
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
const a2dHit & GetHitType() const
type of the hit
Definition: canobj.h:3027
static void SetIgnoreAllSetpending(bool value=true)
set static IgnoreAllSetpending flag
Definition: canobj.h:2307
wxEditStyle
Definition: canobj.h:109
virtual bool UserBaseFunctionFormat(wxString format,...)
can be used by the user to implement a function using a variable argument list and format string that...
Definition: canobj.h:2418
a base command for the a2dCommandProcessor
Definition: comevt.h:140
canobj.h Source File -- Sun Oct 12 2014 17:04:14 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation