wxArt2D
drawer.h
Go to the documentation of this file.
1 /*! \file wx/canvas/drawer.h
2  \brief the a2dDrawingPart is a a2dView specially designed for displaying
3  parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document,
4  by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw
5  a certain rectangular area. At that last is what this class is for.
6  It optimizes the areas to be redrawn after object in the document were changed.
7  To do that it combines redraw areas to a minimal set of redrawing areas.
8  All the administration for this and the way things will be redrawn is from this view.
9 
10  \author Klaas Holwerda
11 
12  Copyright: 2000-2004 (c) Klaas Holwerda
13 
14  Licence: wxWidgets Licence
15 
16  RCS-ID: $Id: drawer.h,v 1.49 2008/10/21 21:48:30 titato Exp $
17 */
18 
19 #ifndef __WXDRAWER_H__
20 #define __WXDRAWER_H__
21 
22 #ifndef WX_PRECOMP
23 #include "wx/wx.h"
24 #endif
25 
26 #include "wx/dnd.h"
27 #include "wx/dataobj.h"
28 #include "wx/clipbrd.h"
29 #include "wx/metafile.h"
30 #include <wx/wfstream.h>
31 #include <wx/stdstream.h>
32 #include "wx/image.h"
33 #include "wx/geometry.h"
34 
35 #include "wx/artbase/drawer2d.h"
36 #include "wx/artbase/dcdrawer.h"
37 #include "wx/canvas/candefs.h"
38 #include "wx/canvas/tools.h"
39 #include "wx/canvas/edit.h"
40 #include "wx/canvas/drawing.h"
41 #include "wx/canvas/algos.h"
42 
43 #include <vector>
44 
45 class a2dCursorStack : public std::vector<wxCursor>
46 {
47 public:
48 
50 };
51 
52 class a2dPushInStack : public std::vector< a2dCanvasObjectPtr >
53 {
54 public:
55 
57 };
58 
59 
60 //! record in update list of a2dDrawingPart.
61 /*!
62  \ingroup drawer
63 */
64 class A2DCANVASDLLEXP a2dUpdateArea: public wxRect
65 {
66 #ifdef CLASS_MEM_MANAGEMENT
67  //! memory manager for speed up to replace system calls allocation and deallocation
68  static a2dMemManager sm_memManager;
69 public:
70  //! overloaded operator new for this class and it all derived classes
71  void* operator new( size_t bytes )
72  {
73  return sm_memManager.Allocate( bytes );
74  }
75 
76  //! overloaded operator delete for this class and it all derived classes
77  /*!
78  This function doesn't free to OS-system memory block by pointer 'space'.
79  It adds memory block by pointer 'space' to internal lists.
80  It is speed up.
81  */
82  void operator delete( void* space, size_t bytes )
83  {
84  sm_memManager.Deallocate( space, bytes );
85  }
86 #endif //CLASS_MEM_MANAGEMENT
87 
88 public:
89  a2dUpdateArea( int x, int y, int width, int height, wxUint8 id = 0 );
90  ~a2dUpdateArea();
91 
92 public:
93 
94  // update done blit awaiting
95  bool m_update_done;
96  bool m_update_direct;
97 
98  //! buffer id
99  wxUint8 m_id;
100 };
101 
102 #include <wx/listimpl.cpp>
103 
104 //! Holds all updateareas within a a2dDrawingPart
105 WX_DECLARE_LIST_WITH_DECL( a2dUpdateArea, a2dUpdateListBase, class A2DCANVASDLLEXP );
106 
107 //! maintains a list of areas on a view to be redrawn.
108 /*!
109  update areas reported directly to a view or extracted from tiles or stored here.
110 */
111 class A2DCANVASDLLEXP a2dUpdateList : public a2dUpdateListBase
112 {
113 
114 #ifdef CLASS_MEM_MANAGEMENT
115  //! memory manager for speed up to replace system calls allocation and deallocation
116  static a2dMemManager sm_memManager;
117 public:
118  //! overloaded operator new for this class and it all derived classes
119  void* operator new( size_t bytes )
120  {
121  return sm_memManager.Allocate( bytes );
122  }
123 
124  //! overloaded operator delete for this class and it all derived classes
125  /*!
126  This function doesn't free to OS-system memory block by pointer 'space'.
127  It adds memory block by pointer 'space' to internal lists.
128  It is speed up.
129  */
130  void operator delete( void* space, size_t bytes )
131  {
132  sm_memManager.Deallocate( space, bytes );
133  }
134 #endif //CLASS_MEM_MANAGEMENT
135 
136 public:
137  a2dUpdateList( void ) : a2dUpdateListBase()
138  {
139  }
140 
141 };
142 
143 #define a2d_TILESHIFT 8
144 #define a2d_TILESIZE 256 //(1 << a2d_TILESHIFT)
145 
146 //! a2dTileBox is a subarea of a tile.
147 /*!
148  The drawing area is divided into tiles, where each tile is 256 * 256 pixels.
149  The part of the tile which needs a redraw is stored in tile coordinates.
150 */
151 class A2DCANVASDLLEXP a2dTileBox
152 {
153 public:
154 
155  //! constructor
156  a2dTileBox( int x1 = 0, int y1 = 0, int x2 = 0, int y2 = 0 );
157 
158  //! destructor
159  ~a2dTileBox();
160 
161  //! Initialize a tile
162  void Init( int x1 = 0, int y1 = 0, int x2 = 0, int y2 = 0 );
163 
164  //! expand a tile with this box
165  void Expand( int x1, int y1, int x2, int y2 );
166 
167  //! get x1 in pixel coordinates
168  inline int x1p() { return m_x1 << a2d_TILESHIFT; }
169  //! get y1 in pixel coordinates
170  inline int y1p() { return m_y1 << a2d_TILESHIFT; }
171  //! get x2 in pixel coordinates
172  inline int x2p() { return m_x2 << a2d_TILESHIFT; }
173  //! get y2 in pixel coordinates
174  inline int y2p() { return m_y2 << a2d_TILESHIFT; }
175 
176  //! if set, true
177  bool m_valid;
178 
179  //! x1 in pixel coordinates
180  int m_x1;
181  //! y1 in pixel coordinates
182  int m_y1;
183  //! x2 in pixel coordinates
184  int m_x2;
185  //! y2 in pixel coordinates
186  int m_y2;
187 
188  //! prev row pointer to combine tiles into rectangles
190 
191 };
192 
193 #define a2d_INIT_TILES 100
194 
195 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
196 template class A2DCANVASDLLEXP a2dArrayGrow < a2dTileBox >;
197 #endif
198 
199 //! a storage for a a tiled area
200 /*!
201  An array of tiles width * height is maintained here.
202  The tiles can be filled using scaning functions which take basic primitives as input.
203  Later on the covered tiles can be extracted as a list of rectangles which
204  cover the same area but with less rectangles in general.
205 */
206 class A2DCANVASDLLEXP a2dTiles
207 {
208 public:
209 
210  //! constructor
211  /*!
212  \param width number of horizontal tiles
213  \param height number of vertical tiles
214  */
215  a2dTiles( int width, int height );
216 
217  //! destructor
218  ~a2dTiles();
219 
220  //! change tile area
221  void SetSize( int width, int height );
222 
223  //! All tiles become empty
224  void Clear();
225 
226  //! draw tiles to given view in device coordinates.
227  void DrawTiles( a2dDrawer2D* drawer );
228 
229  //! draw optimized rectangles to given view in device coordinates.
230  void DrawRects( a2dDrawer2D* drawer );
231 
232  //! convert internal tile to pixel coordinate tiles area
233  inline int toP( int tilexy ) { return tilexy << a2d_TILESHIFT; }
234 
235  //! convert pixel to internal tile coordinate tiles area
236  inline int toT( int xy ) { return xy >> a2d_TILESHIFT; }
237 
238  //! xy modules 256
239  inline int ModT( int xy ) { return xy & ( a2d_TILESIZE - 1 ); }
240 
241  //! fill tiles covering the rect given see FillTiles( int x, int y, int w, int h, bool expand )
242  void FillTiles( const wxRect& rect, bool expand = true );
243 
244  //! fill tiles covering the rect given
245  /*!
246  The rect formed by x,y,w,h, is divided over the tiles, filling the the part of the tiles that
247  are covered by the rectangle.
248 
249  \param x x of rectangle
250  \param y y of rectangle
251  \param w width of rectangle
252  \param h height of rectangle
253  \param expand if true keep existing filled tiles, else clear all.
254  */
255  void FillTiles( int x, int y, int w, int h, bool expand );
256 
257  //! are there filled tiles available?
258  bool HasFilledTiles();
259 
260  //! generate from files tiles a list of semi optimal covering rectangles
261  /*!
262  The tiles are iterated in horizontal rows, combining filed tiles found
263  in the rows when at same height and connecting with the previous tile.
264  The found rect is then combined a rectangle already found in a previous row.
265  */
266  a2dUpdateList* GenerateUpdateRectangles();
267 
268  //! see GenerateUpdateRectangles(), this one adds to the list given.
269  void GenerateUpdateRectangles( a2dUpdateList* rects, wxUint8 id );
270 
271  //! number of horizontal tiles
272  int m_width;
273  //! number of vertical tiles
274  int m_height;
275 
276  //! get tile at index i
277  inline a2dTileBox tile( int i )
278  {
279  assert( i < ( m_width * m_height - 1 ) );
280  return m_tiles[ i ];
281  }
282 
283  //! array of tiles ( normally m_width * m_height )
284  vector< a2dTileBox > m_tiles;
285 };
286 
287 class A2DCANVASDLLEXP a2dCanvas;
288 
289 
290 //! Used by a2dDrawingPart to decide what layers are to be rendered.
291 /*!
292  The a2dDrawing is checked via a2dCanvasObject::Addpending() etc. which
293  layers contain objects. The array containing this information is stored
294  seperate for each a2dDrawingPart. This is because each view can show different parts
295  of a document, and one part can contain more layers then the other.
296  This information is used to skip rendering layers which do not contain objects,
297  or which are set invisible.
298 
299  \ingroup canvasobject
300 
301  \ingroup docview
302 */
303 class A2DCANVASDLLEXP a2dLayerView
304 {
305 
306 public:
307 
308  //!constructor
310  {
311  m_layervisible = true;
312  m_layeravailable = false;
313  m_check = true;
314  m_canvasObjectCount = 0;
315  m_canvasPreviousObjectCount = 0;
316  }
317 
318  ~a2dLayerView() {};
319 
320  //!is the layer visible
321  bool GetVisible() { return m_layervisible; }
322 
323  //! set layer visible
324  void SetVisible( bool status ) { m_layervisible = status; }
325 
326  //!are the objects on this layer
327  bool GetAvailable() { return m_layeravailable; }
328 
329  //! set layer available (will be rendered)
330  void SetAvailable( bool status ) { m_layeravailable = status; }
331 
332  //! check this layer?
333  bool GetCheck() { return m_check; }
334 
335  //! set the layer to be checked in idle time.
336  void SetCheck( bool status ) { m_check = status; }
337 
338  //! should this layer be rendered
340  {
341  return ( m_layeravailable && m_layervisible ) || m_check;
342  }
343 
344  //! get currently counted number of objects on this layer inside a document.
345  wxUint32 GetObjectCount() { return m_canvasObjectCount; }
346 
347  //! set currently counted number of objects on this layer inside a document.
348  void SetObjectCount( wxUint32 numberOfObjects ) { m_canvasObjectCount = numberOfObjects; }
349 
350  //! get currently counted number of objects on this layer inside a document.
351  wxUint32 GetPreviousObjectCount() { return m_canvasPreviousObjectCount; }
352 
353  //! set currently counted number of objects on this layer inside a document.
354  void SetPreviousObjectCount( wxUint32 numberOfObjects ) { m_canvasPreviousObjectCount = numberOfObjects; }
355 
356  //! increment currently counted number of objects on this layer inside a document.
357  void IncrementObjectCount() { m_canvasObjectCount++; }
358 
359  //! decrement currently counted number of objects on this layer inside a document.
360  void DecrementObjectCount() { m_canvasObjectCount--; }
361 
362 protected:
363 
364  //! Gives the number of object on this layer in a document.
365  //! Only accurate after a SetAvailable
366  mutable wxUint32 m_canvasObjectCount;
367 
368  mutable wxUint32 m_canvasPreviousObjectCount;
369 
370  //!is the layer visible
372 
373  //!is the layer filled with primitives
375 
376  //!if true layer need to be check again document for availability.
377  bool m_check;
378 
379 private:
380  //!how many references to this object do exist
381  int m_refcount;
382 
383  //! Call to have a new owner for this object
384  /*! This function should only be called by a2dSmrtPtr
385 
386  \remark owning mean that the object calling this member needs to call Release at some time,
387  in order to actually release/delete the object.
388 
389  \return The return value is the object itself, which is now owned on time extra.
390 
391  increment refcount by 1 ( use when adding a reference to this object)
392  */
393  a2dLayerView* SmrtPtrOwn() { m_refcount++; return this; }
394 
395  //!To release the object, it is not longer owned by the calling object.
396  /*! This function should only be called by a2dSmrtPtr
397  */
398  bool SmrtPtrRelease()
399  {
400  m_refcount--;
401  wxASSERT_MSG( m_refcount >= 0, wxT( "a2dLayerView Own/Release not matched (extra Release calls)" ) );
402  if ( m_refcount <= 0 )
403  {
404  delete this;
405  return true;
406  }
407  return false;
408  }
409 
410 private:
411  friend class a2dSmrtPtrBase;
412 
413 };
414 
415 typedef std::vector<a2dLayerView> a2dLayerViewList;
416 
417 //! Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
418 /*!
419  a2dDrawingPart is a specialized view to display parts of a a2dDrawing.
420  Such a part always starts at one a2dCanvasObject which is inside of a a2dDrawing object.
421  The a2dCanvasObject itself contains as children a2dCanvasObject derived drawable objects. A hierarchy
422  of recursively nexted objects is what forms the actual drawing.
423  The parent object to start the drawing is called the ShowObject.
424  The member functions SetShowObject(...) are used to set the ShowObject to be displayed.
425  All objects are defined in relative world coordinates, which are relative to the parent object(s).
426 
427  a2dDrawing is given as a drawing and/or updating context an a2dDrawingPart. E.g. in
428  a2dDrawingPart::RenderTopObject() is used by the a2dCanvasObject render functions to get to
429  a2dDrawingPart::m_drawer2D, which is the Drawing Context used to do the actual drawing within
430  the a2dCanvasObjects. But a2dDrawingPart::RenderTopObject() defines what drawing style is used to draw.
431 
432  The real purpose of a2dDrawingPart, is to maintain a list of damaged/changed areas in the view/drawing, and
433  when time is ready, start redrawing those areas. When a a2dCanvasObject did change in position or size etc.,
434  the a2dDrawing reports this change as a rectangular redraw areas to the a2dDrawingPart's of that drawing.
435  The update areas are based on the boundingbox of the object in its old state and in its new state.
436  This reporting is done in idle time, and for all changed objects at once. When reporting of all changed areas is done,
437  each a2dDrawingPart knows what parts of its drawing need to be redrawn. It will then start redrawing those areas,
438  but only after optimizing to the minimum areas to redraw. So overlapping areas will only be redrawn once.
439  The mechanism for that is called tilling.
440 
441  The size of the drawing in world coordinates and the size of the view in pixels is all indirectly defined by
442  a2dDrawingPart::m_drawer2D and a2dView::m_display. The area of the drawing in world coordinates that is visible,
443  can be set via a2dDrawingPart::m_drawer2D. Also if World coordinates is with the Y axis going up are down.
444  a2dDrawer2D has methods to convert from world to device coordinates and visa versa.
445  a2dDrawingPart::m_drawer2D draws into a buffer. After rendering an update of all damaged parts into this buffer,
446  it will be blitted from the buffer to the a2dView::m_display of the a2dDrawingPart. This is done in Idle time,
447  but can also be forced. In the end a2dDrawingPart automatically always displays an up to date part of the drawing
448  which is stored inside the a2dDrawing. The user just changes a a2dCanvasObject inside the a2dDrawing,
449  and the redrawing on all the views will be done automatically.
450 
451  A a2dDrawingPart its a2dDrawingPart::m_drawer2D knows where to draw to, this can be a bitmap buffer or a window etc.
452  The job to update a window in case of drawing to a bitmap buffer, is not part of the a2dDrawer2D.
453  This is/needs to be done by the class using the drawer, like a2dDrawingPart and indirectly a2dCanvas here.
454  The a2dCanvas receives a paint event, e.g. when moving an overlapping window or dialog, and it then blits the right
455  parts from a2dDrawingPart::m_drawer2D its drawing buffer to the canvas window.
456  a2dDrawingPart also takes care of scrolling the view, it does this by re-using the contents of the a2dDrawer2D drawing
457  buffer when possible.
458  The drawing buffer can be bigger then the size of the canvas window. a2dDrawingPart always makes sure the whole buffer
459  contains an up to date contents, as being the drawing to display form its a2dDrawing. Therefore if the canvas windows
460  which uses the a2dDrawingPart for drawing, implements scrolling and resizing, the canvas window is responsible for
461  optimizing the scroll to take maximum advantage from the buffer of a2dDrawingPart. Like if the buffer is bigger in
462  size then the canvas windows size, a resize of the canvas window only needs to increase the buffer size of
463  a2dDrawingPart, when the size of the window exeeds the buffer size.
464  One can even decide to set the buffer to the size of the complete virtual area that can be scrolled.
465  This way one can make a trade of between buffer size and scrolling/resizing speed.
466  Knowing this, one needs to realize that mouse coordinates as received inside a canvas window, are different
467  if the origin in the drawing context is not at the orginin of the canvas window.
468  The a2dDrawingPart::m_drawer2D takes (0,0) of the buffer as the origin of device coodinates.
469 */
470 class A2DCANVASDLLEXP a2dDrawingPart: public a2dObject
471 {
472 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
473  a2dInitCurrentSmartPointerOwner m_initCurrentSmartPointerOwner;
474 #endif
475  DECLARE_EVENT_TABLE()
476 
477 public:
478 
479 #if defined(_DEBUG)
480  //! shows where updates did take place.
481  void SetUpdateVisible( bool updatesVisible ) { m_updatesVisible = updatesVisible; }
482 
483  bool m_updatesVisible;
484 #endif
485 
486  //!constructor
487  /*!
488  */
489  a2dDrawingPart( int width = 1000, int height = 1000 );
490 
491  //!constructor
492  /*!
493  Width and hight is given, mapping is as in drawer given.
494  */
495  a2dDrawingPart( int width, int height, a2dDrawer2D* drawer2D );
496 
497  //!constructor
498  /*!
499  Width and hight and mapping is as in drawer given.
500  */
501  a2dDrawingPart( a2dDrawer2D* drawer );
502 
503  //!constructor
504  /*!
505  */
506  a2dDrawingPart( const wxSize& size );
507 
508  //!copy constructor
509  a2dDrawingPart( const a2dDrawingPart& other );
510 
511  //! next to the base its m_display, this also sets m_drawer2d to this display
512  virtual void SetDisplayWindow( wxWindow* display );
513 
514  virtual wxWindow* GetDisplayWindow() { return m_drawingDisplay; }
515 
516  //! Get the Display window of the a2dView. But casted to a a2dCanvas
517  /*! when a a2dCanvas is used in this a2dDrawingPart return it else 0.
518  a2dDrawingPart needs to know the window (a2dCanvas) to display itself.
519  The a2dDrawingPart updates to this window in idel time.
520  Paint event to the a2dCanvas are using the a2dDrawingPart its buffer for
521  quick updating the a2dCanvas window.
522 
523  \sa a2dView::SetDisplayWindow()
524  */
525  a2dCanvas* GetCanvas() const { return ( a2dCanvas* ) m_drawingDisplay; }
526 
527 #if wxUSE_PRINTING_ARCHITECTURE
528  //! to create a a2dDrawingPrintOut, used to print a view or its document
529  /*!
530  The a2dDrawingPrintOut created will take as much possible from the this drawing part.
531  a2dDrawingPrintOut will create itself a view which fits the size of the paper, but important setting are taken from this view.
532  */
533  virtual wxPrintout* OnCreatePrintout( a2dPrintWhat typeOfPrint, const wxPageSetupDialogData& pageSetupData );
534 #endif
535 
536  //! zoomout leafs a border of this amount of pixels around the drawing
537  void SetZoomOutBorder( wxUint16 border ) { m_border = border; }
538 
539  //! \see SetZoomOutBorder()
540  wxUint16 GetZoomOutBorder() { return m_border; }
541 
542  //! sets buffersize ( if used ) for the a2dDrawer2D
543  virtual void SetBufferSize( int w, int h );
544 
545  virtual bool GetTrippleBuf() { return false; }
546 
547  virtual bool GetTrippleBufHasAlpha() { return false; }
548 
549  virtual bool HasAlhpa() { return m_drawer2D->HasAlpha(); }
550 
551  //!destructor
552  virtual ~a2dDrawingPart();
553 
554  //! if set true, drawing can contain objects that depend on this view (size etc).
555  /*! If set those objects will be automatically updated for this view.
556  Else the drawing is assumed to not contain viewdependent objects for this view, and that update cycle is skipped.
557  */
558  void SetViewDependentObjects( bool viewDependentObjects ) { m_viewDependentObjects = viewDependentObjects; }
559 
560  //! see SetViewDependentObjects()
561  bool GetViewDependentObjects() const { return m_viewDependentObjects; }
562 
563  //! get the layer render array
564  a2dLayerViewList& GetLayerRenderArray() { return m_layerRenderArray; }
565 
566  //!update layers available needed?
567  /*!
568  \sa Set_UpdateAvailableLayers
569  */
570  bool Get_UpdateAvailableLayers() const { return m_update_available_layers; }
571 
572  //! check which layers do contain objects as seen from the ShowObject()
573  void SetAvailable();
574 
575  //! signals the need to check the given layer for visibility/availibility as seen from this drawing part.
576  void SetLayerCheck( wxUint16 layer );
577 
578  //! Sets a flag for updating available layers checking, which makes sure layers will be checked first when needed.
579  /*!
580  Eventually results in updating the layers table settings on layers available in drawing
581  before rendering starts or simular functions.
582  */
583  void Set_UpdateAvailableLayers( bool value ) { m_update_available_layers = value; }
584 
585  //!Set to draw layers in reverse order
586  void SetReverseOrder( bool revorder );
587 
588  //!Get Setting for draw layers in reverse order
589  bool GetReverseOrder() const { return m_reverse_order; }
590 
591  //! used to extend a hittest with the number of pixels.
592  /*! to be able to hit a line of width zero, a margin is needed to hit it,
593  which is set here.
594 
595  \remark default value is 2 pixels
596  */
597  inline void SetHitMargin( wxUint16 pixels ) { m_hitmargin = pixels; }
598 
599  //! Get HitMargin used to extend a hittest with the number of pixels.
600  inline wxUint16 GetHitMarginDevice() const { return m_hitmargin; }
601 
602  //! Get HitMargin used to extend a hittest in world units.
603  double GetHitMarginWorld() const;
604 
605  //! Special event handling for a2dDrawingPart class
606  /*!
607  If eventprocessing is enabled and the view is enabled. OR in case this event ( wxEVT_ENABLE_VIEW | wxEVT_ENABLE_VIEWS )
608  is to enable this a2dView, the event is processed.
609 
610  wxEVT_IDLE is first processed by the view, and next by the m_toolcontroller is set.
611  wxEVT_PAINT is first processed by the m_display if set, next by the view, and next by the m_toolcontroller is set.
612  This garantees proper redrawing of tools on top of the window.
613 
614  Next to this check the command processor for its current parent object, and sent
615  a command to set it right if change is needed.
616  */
617  virtual bool ProcessEvent( wxEvent& event );
618 
619  //! If not set do not process mouse events.
620  /*!
621  Mouse events are handled by the canvas.
622  They are redirected to the a2dCanvasObject hit.
623  You can switch this off here, and skip the event from being processed.
624  This is often used in tools, to prevent a2dCanvasObjects from receiving events.
625 
626  \remark most events go to the m_toolcontroller first if set. \see ProcessEvent()
627  */
628  void SetMouseEvents( bool onoff );
629 
630  //! return true if this a2dDrawingPart allows mouse events to be processed.
631  bool GetMouseEvents() const { return m_mouseevents; }
632 
633  //! set the object that is captured for events in the a2dDrawing.
634  /*!
635  Used in combination with the a2dIterC class to set a corridor path for events.
636  Do not use this function directly from outside a2dCorridor or a2diterC
637  */
638  void SetCaptured( a2dCanvasObject* captured ) { m_capture = captured; }
639 
640  //!are events redirected to a captured corridor? if so return the captured object in it, else NULL
641  inline a2dCanvasObject* GetCaptured() const { return m_capture; }
642 
643  //! use in combination with the a2dIterC class to set a corridor path for events.
644  /*!
645  A corridor path leads event to a specific a2dCanvasObject in a a2dDrawing.
646  This feature is used to do editing of nested a2dCanvasObject 's, and to captures events
647  to such objects.
648  The a2dCanvasObject's on a corridor path get the m_flags.m_isOnCorridorPath set, which result
649  in redirecting events to the m_endCorridorObject.
650  */
651  void SetEndCorridorObject( a2dCanvasObject* endCorridorObject );
652 
653  //! return the corridor object if set else NULL \see SetEndCorridorObject()
654  a2dCanvasObject* GetEndCorridorObject() const { return m_endCorridorObject; }
655 
656  //!set object available in the a2dDrawing to be shown on the drawer
657  /*!
658  \param name name of top object
659  \return pointer to the object found else NULL
660  */
661  a2dCanvasObject* SetShowObject( const wxString& name );
662 
663  //!set top object available in the a2dDrawing to be shown on the drawer
664  /*!
665  \param obj: pointer to object to show
666  */
667  bool SetShowObject( a2dCanvasObject* obj );
668 
669  //! Used temporarely in rendering bitmas or in printing, to Set the show object and redraw the whole part.
670  /*!
671  Notification in the form of signals and/or events is not done.
672  Also connection to event in othere objects is not done.
673  */
674  void SetShowObjectAndRender( a2dCanvasObject* obj );
675 
676  //!return pointer of then currently shown object on the drawer.
677  /*!
678  \return: pointer to the current object that is shown.
679  */
681  {
682  return m_top;
683  }
684 
685  //! set given canvasobject as show object, and store the current on the stack
686  void PushIn( a2dCanvasObject* pushin );
687 
688  //! pop last pushed canvasobject from the stack, now last becomes show object.
689  a2dCanvasObject* PopOut();
690 
691  //! mak push in stack empty
692  void ClearPushInStack();
693 
694  //! is there structure to popout (see PushIn )
695  bool HasPopOut() const { return m_pushInStack.size() != 0; }
696 
697  //! get drawing via top object
698  a2dDrawing* GetDrawing() const;
699 
700  //!add pending update for the area that is the boundingbox of the given object
701  /*!
702  Updates the boundingbox area of the given object at idle time.
703  If obj is NULL nothing will be done
704  If refalso is true then all references to this object will be updated also.
705 
706  \param obj the object where to take the bounding box from
707  \param refsalso <code>true</code> to update all references, else <code>false</code>
708  */
709  void AddPendingUpdateArea( a2dCanvasObject* obj, wxUint8 id = 0, bool refsalso = true );
710 
711  //!recursive find pending objects and adds their areas to the updatelist
712  /*! it does first test if the a2dDrawing has the flag set to tell it has pending objects inside.
713  If that is the case, it traverses the a2dDrawing, and adds
714  the absolute boundingbox of the pending object to the a2dDrawingPart updatelist.
715  This is for all paths leading to the object from the current ShowObject, so also a2dCanvasObjectReference's.
716  \return true if did add pendingobject's else false
717  */
718  bool AddObjectPendingUpdates( a2dCanViewUpdateFlagsMask how = a2dCANVIEW_UPDATE_PENDING );
719 
720  //!add boundingbox to update list for updating in idle time
721  void AddPendingUpdateArea( const a2dBoundingBox& box, wxUint8 id = 0 );
722 
723  //!add rectangle to update list for updating in idle time
724  void AddPendingUpdateArea( const wxRect& recnew, wxUint8 id = 0 );
725 
726  //!add area to update list for updating in idle time
727  /*!
728  the given area will be added to the
729  list of rectangles to be blitted to the screen later in idle time,
730  at repaint or after an UpdateNow action.
731  The given area will be combined (merged/ignored) with the already available update areas.
732  This to prevent un necessary redraws.
733  */
734  void AddPendingUpdateArea( int x, int y, int w, int h, wxUint8 id = 0 );
735 
736  void AddOverlayAreas( bool update );
737 
738  //! add to list of overlay objects (must be children of m_top)
739  void AddOverlayObject( a2dCanvasObject* obj );
740 
741  //! remove from the list of overlay objects (must be children of m_top)
742  void RemoveOverlayObject( a2dCanvasObject* obj );
743 
744  //! depending on the hint value performs specific updating on the view.
745  /*!
746  Hint is unsigned int containing flags of type \sa a2dCanViewUpdateFlags which actions will be executed in the right order.
747  In principle the view its internal data ( this is mostly the buffer ) should be updated, and be made ready
748  for redisplay on the view its DisplayWindow().
749  A reason for updating a view, is a change in the a2dDrawing. The document is checked for changes in idle
750  time, and updates all views on the document at once when a change exists.
751  First all changed areas on the view because of changes to the document, are reported by the document to the a2dDrawingPart.
752  The a2dDrawingPart keeps an internal list of areas needing a redraw.
753  The areas reported are found on the basis of the old and new boundingboxes of the changed objects.
754  Next the areas in the updatelist are redrawn in the buffer of the a2dDrawingPart, and at last those areas will be blitted.
755 
756  The above is done automatic, but one is free for whatever reason to add pending areas directly to the
757  a2dDrawingPart its update arealist. Those will be updated also in idle time, along with all others areas as a result
758  of changing objects.
759 
760  \remark OnUpdate is the key routine to speedy redraws, proper use asures only redraw of changed or
761  damaged areas in idle time.
762 
763  \remark Called in a2dDrawing from UpdateAllViews() and AddPendingUpdatesOldNew() to update this view.
764 
765  \remark a2dCANVIEW_UPDATE_BLIT means, blit all updated areas for this a2dCanvas now to the screen,
766  else it will happen in idle time.
767  Use a2dCANVIEW_UPDATE_OLDNEW |a2dCANVIEW_UPDATE_BLIT | a2dCANVIEW_UPDATE_BLIT
768  to support dragging for instance, because in such cases idle time
769  will take to long. Other a2dCanvas using the same a2dDrawing will not be redrawn and blitted
770  when double buffered.
771  */
772  void OnUpdate( a2dDrawingEvent& event );
773 
774  //! see OnUpdate
775  /*!by default adds a full pending update for the drawer and all in it, and redraws this to the device.
776  Use how = a2dCANVIEW_UPDATE_ALL when the contents/data of the canvas has changed
777  without specific updates applied to areas. This will do the redraw in idle time.
778  For example: after adding many new objects to the root object
779  or other objects referenced or after changing the root object
780 
781  \remark the default value is brute force redraw all, but in general not wise to use since it means a total redraw.
782  instead most often a2dCANVIEW_UPDATE_OLDNEW is used, or if result needs to be displayed directly, use
783  ( a2dCANVIEW_UPDATE_OLDNEW |a2dCANVIEW_UPDATE_AREAS | a2dCANVIEW_UPDATE_BLIT )
784 
785  */
786  void Update( unsigned int how = ( a2dCANVIEW_UPDATE_ALL | a2dCANVIEW_UPDATE_BLIT )
787  , wxObject* hintObject = NULL );
788 
789  //!update/redraw part of the buffer, using the given a2dDrawing and ShowObject within that root.
790  /*!
791  This method also takes care of redrawing the background and the grid
792  */
793  virtual void UpdateArea( int x, int y, int width, int height, wxUint8 id = 0 );
794 
795  virtual void ClearArea( int x, int y, int width, int height );
796 
797  virtual void RenderChildObject( a2dCanvasObject* obj );
798 
799  //! blit part of the drawing buffer to the canvas
800  virtual void BlitBuffer( int x, int y, int width, int height, int xbuf, int ybuf );
801 
802  //!Function to draw the origin
803  /*!override this function in a derived class to redefine painting of the origin*/
804  virtual void DrawOrigin();
805 
806  //!Function to draw the grid
807  /*!override this function in a derived class to redefine painting of the grid*/
808  virtual void PaintGrid( int x, int y, int width, int height );
809 
810  //!(re)painting of background
811  /*!override this function in a derived class to redefine painting of the background*/
812  virtual void PaintBackground( int x, int y, int width, int height );
813 
814  //! set enable crosshair cursor
815  void SetCrossHair( bool onoff );
816 
817  //! get enable crosshair cursor
818  bool GetCrossHair() { return m_crosshair; }
819 
820  //! set crosshair cursor Length in X in pixels
821  void SetCrossHairLengthX( int LengthX ) { m_crosshairLengthX = LengthX; }
822 
823  //! set crosshair cursor Length in Y in pixels
824  void SetCrossHairLengthY( int LengthY ) { m_crosshairLengthY = LengthY; }
825 
826  //! get crosshair cursor Length in X in pixels
827  int GetCrossHairLengthX() { return m_crosshairLengthX; }
828 
829  //! get crosshair cursor Length in Y in pixels
830  int GetCrossHairLengthY() { return m_crosshairLengthY; }
831 
832  //!set stroke for crosshair
833  void SetCrossHairStroke( const a2dStroke& stroke );
834 
835  //!get stroke for crosshair
836  a2dStroke& GetCrossHairStroke() { return m_crosshairStroke; }
837 
838  //! blit old areas to remove last drawn crosshair and draw the cross hair at this new position.
839  virtual void UpdateCrossHair( int x, int y );
840 
841  //! set a2dFill to use when RenderFIX_STYLE is set.
842  void SetFixedStyleFill( const a2dFill& fixFill ) { m_fixFill = fixFill; }
843 
844  //! set a2dStroke to use when RenderFIX_STYLE is set.
845  void SetFixedStyleStroke( const a2dStroke& fixStroke ) { m_fixStroke = fixStroke; }
846 
847  //! set a2dFill to use when RenderWIREFRAME_SELECT or RenderWIREFRAME_SELECT_INVERT is set.
848  void SetSelectFill( const a2dFill& selectFill ) { m_selectFill = selectFill; }
849 
850  //! set a2dStroke to use when RenderWIREFRAME_SELECT or RenderWIREFRAME_SELECT_INVERT is set.
851  void SetSelectStroke( const a2dStroke& selectStroke ) { m_selectStroke = selectStroke; }
852 
853  //! set a2dFill to use when RenderWIREFRAME_SELECT2 or RenderWIREFRAME_SELECT2_INVERT is set.
854  void SetSelect2Fill( const a2dFill& select2Fill ) { m_select2Fill = select2Fill; }
855 
856  //! set a2dStroke to use when RenderWIREFRAME_SELECT2 or RenderWIREFRAME_SELECT2_INVERT is set.
857  void SetSelect2Stroke( const a2dStroke& select2Stroke ) { m_select2Stroke = select2Stroke; }
858 
859  //! set a2dFill to use when RenderWIREFRAME_HighLight.
860  void SetHighLight( const a2dFill& hightLightFill ) { m_highLightFill = hightLightFill; }
861 
862  //! set a2dStroke to use when RenderWIREFRAME_HighLight.
863  void SetHighLight( const a2dStroke& hightLightStroke ) { m_highLightStroke = hightLightStroke; }
864 
865  //! set a2dFill to use when RenderFIX_STYLE is set.
866  void SetOverlayFill( const a2dFill& overlayFill ) { m_overlayFill = overlayFill; }
867 
868  //! set a2dStroke to use when RenderFIX_STYLE is set.
869  void SetOverlayStroke( const a2dStroke& overlayStroke ) { m_overlayStroke = overlayStroke; }
870 
871  //!background fill for the canvas
872  void SetBackgroundFill( const a2dFill& backgroundfill );
873 
874  //!get current background fill for the canvas
875  a2dFill& GetBackgroundFill() { return m_backgroundfill; }
876 
877  //!Set grid setting for drawing grid in front or back
878  void SetGridAtFront( bool gridatfront ) { m_gridatfront = gridatfront; Update( a2dCANVIEW_UPDATE_ALL ); }
879 
880  //!Get grid setting for drawing grid in front or back
881  bool GetGridAtFront() { return m_gridatfront;}
882 
883  //!set stroke used for grid drawing
884  void SetGridStroke( const a2dStroke& gridstroke );
885 
886  //!set size of grid circle
887  void SetGridSize( wxUint16 gridsize ) { m_gridsize = gridsize; Update( a2dCANVIEW_UPDATE_ALL );}
888 
889  //!set fill used for grid drawing
890  void SetGridFill( const a2dFill& gridfill );
891 
892  //!Get grid distance in X
893  double GetGridX() {return m_gridx;}
894 
895  //!Set grid distance in X
896  void SetGridX( double gridx ) { m_gridx = gridx; Update( a2dCANVIEW_UPDATE_ALL );}
897 
898  //!Get grid distance in Y
899  double GetGridY() {return m_gridy;}
900 
901  //!Set grid distance in Y
902  void SetGridY( double gridy ) { m_gridy = gridy; Update( a2dCANVIEW_UPDATE_ALL );}
903 
904  //!Set grid on/off
905  void SetGrid( bool grid ) { m_grid = grid; Update( a2dCANVIEW_UPDATE_ALL ); }
906 
907  //!Get grid setting on/off
908  bool GetGrid() {return m_grid;}
909 
910  //!Get grid setting for line drawing
911  /*!Note: SetGridSize must be 0, if gridlines=false */
912  void SetGridLines( bool gridlines ) { m_gridlines = gridlines; Update( a2dCANVIEW_UPDATE_ALL ); }
913 
914  //!Get setting for grid to draw lines instead of points
915  bool GetGridLines() { return m_gridlines; }
916 
917  //!Set grid threshold, if grid distance is below this in pixels, it will be increased
918  //! by factors of 2 until it fits.
919  void SetGridThreshold( wxUint16 gridthres ) { m_gridthres = gridthres; Update( a2dCANVIEW_UPDATE_ALL ); }
920 
921  //!Get grid threshold.
922  wxUint16 GetGridThreshold() { return m_gridthres; }
923 
924  //!Set showorigin on/off
925  void SetShowOrigin( bool show ) { m_showorigin = show; Update( a2dCANVIEW_UPDATE_ALL ); }
926 
927  //!Returns if canvas is frozen.
928  bool IsFrozen() { return m_frozen; }
929 
930  //!prevent changing the a2dDrawingPart buffer and blitting it to the window
931  /*!
932  This makes sure the contents displayed into the a2dDrawingPart buffer does not change.
933  Pending objects inside a root will be added to the update list of the a2dDrawingPart,
934  but not redrawn into the buffer until Thaw.
935 
936  \see Thaw
937  */
938  void Freeze();
939 
940  //! to release Freeze()
941  /*!
942  The Frozen view ( Freeze() ), is released. Pending update araes in the update list
943  will be redrawn in OnIdle at the next idle event.
944 
945  \see Freeze
946 
947  \param update if true all shown on this view will be redrawn.
948  */
949  void Thaw( bool update );
950 
951  //! blit pending update areas, that are already updated to the buffer, now to the screen.
952  /*! does the second stage in the two stage process of updating
953  */
954  virtual bool BlitPendingUpdateAreas();
955 
956  //! set toolcontroller ( reset with NULL )
957  /*! Toolcontrollers are meant to implement tools that manipulate the objects
958  displayed on the a2dCanvas.
959  All events to the canvas window or first redirected to the controller.
960  When skipped in the controller the events will eventually reach the a2dCanvas itself.
961 
962  \return true is there was a controller set already.
963 
964  \remark The controller is owned by the canvas and will be deleted by the canvas on destruction or when changed.
965  */
966  bool SetCanvasToolContr( a2dToolContr* controller );
967 
968  a2dToolContr* GetCanvasToolContr() { return m_toolcontroller; }
969 
970  void SetCursor( const wxCursor& cursor );
971 
972  //! push a cursor on the cursor stack, and set display cursor to new back being cursor.
973  void PushCursor( const wxCursor& cursor );
974 
975  //! pop a cursor from the cursor stack, and set display cursor to back
976  void PopCursor();
977 
978  //! clear the stack of cursor, and set display cursor ARROW.
979  void ClearCursorStack();
980 
981  //!do a hittest on the view at coordinates x,y
982  /*!
983  \param x x of point to do hittest
984  \param y y of point to do hittest
985  \param layer test only if objects are on this layer or if set to wxLAYER_ALL test obejcts on all layers
986  \param option ways to hit
987  \param mask only object with this mask set will be hit
988 
989  \return the top object that was hit (e.g.in case of groups)
990 
991  \remark hit margin is defined in a2dDrawing containing the root group
992  */
993  a2dCanvasObject* IsHitWorld(
994  double x, double y,
995  int layer = wxLAYER_ALL,
997  bool filterSelectableLayers = false
998  );
999 
1000 
1001  //!do a hittest on the view at coordinates x,y
1002  /*!
1003  \param x x of point to do hittest
1004  \param y y of point to do hittest
1005  \param layer test only if objects are on this layer or if set to wxLAYER_ALL test obejcts on all layers
1006  \param option ways to hit
1007  \param mask only object with this mask set will be hit
1008 
1009  \return the top object that was hit (e.g.in case of groups)
1010 
1011  \remark hit margin is defined in a2dDrawing containing the root group
1012  */
1013  a2dCanvasObject* IsHitWorldPath(
1014  double x, double y,
1015  int layer = wxLAYER_ALL,
1017  bool filterSelectableLayers = false
1018  );
1019 
1020  //!do an advanged hittest on the view
1021  /*!
1022  \param hitEvent stores hit information
1023  \param layer test only if objects are on this layer or if set to wxLAYER_ALL test obejcts on all layers
1024 
1025  \return the top object that was hit (e.g.in case of groups)
1026 
1027  \remark hit margin is defined in a2dDrawing containing the root group
1028  */
1029  a2dCanvasObject* IsHitWorld(
1030  a2dHitEvent& hitEvent,
1031  int layer = wxLAYER_ALL
1032  );
1033 
1034  //! Corridor and captured object event processing.
1035  /*!
1036  Follow corridor set, and redirect the event to last object in the corridor.
1037  The event is first sent to the child objects, and if not processed there,
1038  testing for a hit on the object itself is done, and if true wxEvtHandler::ProcessEvent is called.
1039 
1040  \param event the event to process
1041  \param isHit return if there was a hit on an object
1042  \param x x of point to do hittest
1043  \param y y of point to do hittest
1044  \param margin margin that still gives a valid hittest.
1045  \param layer only if object is on this layer or if set to wxLAYER_ALL ignore layer id.
1046 
1047  \return true if Object (or a child ) did process the event and did not call event.Skip()
1048  */
1049  virtual bool ProcessCanvasObjectEvent( wxEvent& event, bool& isHit,
1050  double x, double y, int margin,
1051  int layer = wxLAYER_ALL );
1052 
1053  //! Corridor and captured object event processing.
1054  /*! This is the same as the function
1055  ProcessCanvasObjectEvent( wxEvent& event, bool& isHit, double x, double y, int margin, int layer = wxLAYER_ALL ),
1056  but it sets the iteration context pointer of the event.
1057  This is used when sending a2dCanvasObjectEvents from a simple (handle less) tool.
1058 
1059  \param event the event to process
1060  \param isHit return if there was a hit on an object
1061  \param x x of point to do hittest
1062  \param y y of point to do hittest
1063  \param margin margin that still gives a valid hittest.
1064  \param layer only if object is on this layer or if set to wxLAYER_ALL ignore layer id.
1065 
1066  \return true if Object (or a child ) did process the event and did not call event.Skip()
1067  */
1068  virtual bool ProcessCanvasObjectEvent( a2dCanvasObjectEvent& event, bool& isHit,
1069  double x, double y, int margin,
1070  int layer = wxLAYER_ALL );
1071 
1072  //! This function is called after a property changed
1073  /*! This is overloaded to update the view if needed.
1074  */
1075  void OnPropertyChanged( const a2dPropertyId* id );
1076 
1077  //! Find the show-object child object, set the path to the given child object and capture it
1078  /*! \see a2dIterC::SetCorridorPath
1079  This is used to redirect events to a specific child object, e.g. one found by
1080  extended hit testing.
1081 
1082  \param findObject (child) object to be searched for.
1083  \param capture if true the findObject is captured
1084  \return true if findObject was found
1085  */
1086  bool FindAndSetCorridorPath( a2dCanvasObject* findObject, bool capture );
1087 
1088  //! find object on the current corridor path.
1089  /*!
1090  The a2dCanvasObject in the document with the m_flags.m_isOnCorridorPath set, are
1091  pushed into a list, which is returned. If non found the return is false, else true and the list
1092  of objects leading to the end of the corridor.
1093  */
1094  // bool FindCorridorPath( a2dCorridor& result );
1095 
1096  //! set a corridor from a list of objects
1097  void SetCorridorPath( const a2dCorridor& corridor );
1098 
1099  //! Reset all corridor paths and uncapture object
1100  /*! \see a2dIterC::SetCorridorPath
1101  Reset a corridor path set with FindAndSetCorridorPath
1102 
1103  \param uncapture if true uncaptured the captured object
1104  */
1105  void ClearCorridorPath( bool uncapture );
1106 
1107 
1108  //! use the boundingbox of the ShowObject to set the mapping such that it will be displayed completely on the device.
1109  /*!
1110  \see SetMappingDeviceRect to map to a different device/buffer rectangle.
1111  */
1112  void SetMappingShowAll();
1113 
1114  //! set the internal m_drawer2D to be used for rendering the document
1115  /*! The drawing context is owned by a2dDrawingPart, it will delete it.
1116  Still you set it to NULL or othere context without deletion using the noDelete parameter.
1117 
1118  \param drawer2d the drawing context object to set
1119  \param noDelete default the old drawing context object is deleted, but not is this is set true.
1120  This can be used to simulate ownership of the drawing context by another class.
1121  */
1122  void SetDrawer2D( a2dDrawer2D* drawer2d, bool noDelete = false );
1123 
1124  //! get the internal m_drawer2D that is used for rendering the document
1125  a2dDrawer2D* GetDrawer2D() { return m_drawer2D; }
1126 
1127  //!set drawstyles to use for drawing the document
1128  /*!
1129  The internal m_drawer2D is set to this style before rendering of the document starts.
1130 
1131  \remark m_drawstyleRestore is set to the current drawstyle. So a temporary change can easily be restored.
1132 
1133  \param drawstyle one of the draw styles
1134  */
1135  void SetDocumentDrawStyle( wxUint32 drawstyle );
1136 
1137  //! restore drawstyle to the one before the last change
1138  void RestoreDrawStyle() { m_documentDrawStyle = m_documentDrawStyleRestore; }
1139 
1140  //!get drawstyles used for drawing the document
1141  wxUint32 GetDocumentDrawStyle() { return m_documentDrawStyle; }
1142 
1143  void SetOverlayDrawStyle( a2dDocumentRenderStyle drawstyle );
1144 
1145  //! scroll up down or left right
1146  /*! \param dxy scroll distance in X or Y
1147  \param yscroll if true scrolling is in Y else X
1148  \param total update whole device after scroll
1149  */
1150  virtual void Scroll( int dxy, bool yscroll, bool total );
1151 
1152  //! used to drop a drawing object on the drawing part during Drag and Drop.
1153  void OnDrop(wxCoord x, wxCoord y, a2dDrawing* drawing);
1154 
1155  //! does render the top object in the given style.
1156  /*!
1157  This function can be used from tools to render the tool its objects which do become
1158  part of the document in a certain style.
1159  */
1160  virtual void RenderTopObject( wxUint32 documentDrawStyle, wxUint8 id );
1161 
1162  //! single drawstyle render cycle called on document
1163  /*!
1164  Render the given topobject and all that is below it
1165  Will recursive call the render routines of all the objects seen from the topobject.
1166  This rendering iterates over layers.
1167  \param mask object must have this mask
1168  \param drawstyle which drawstyle should be used for this render action .
1169 
1170  \remark If a layer is Invisible it will not be rendered.
1171  */
1172  virtual void RenderTopObject( a2dCanvasObjectFlagsMask mask, a2dDocumentRenderStyle drawstyle );
1173 
1174  //! render of overlay objects stored in m_overlayObjects specific to the view
1175  virtual void RenderOverlay( a2dDocumentRenderStyle drawstyle );
1176 
1177  //! update the transform matrix for objects with property 'PROPID_viewDependent'
1178  /*!
1179  will recursive call the UpdateViewDependentObjects routines of all the objects seen from the topobject.
1180 
1181  \remark TODO: Check all child objects (TODO for optimize: with flag 'm_childpixelsize=true').
1182  */
1183  void UpdateViewDependentObjects();
1184 
1185  //! If true render the printout with a title string, otherwise not
1186  void SetPrintTitle( bool val ) { m_printtitle = val; }
1187 
1188  //! If true render the printout with a filename string, otherwise not
1189  void SetPrintFilename( bool val ) { m_printfilename = val; }
1190 
1191  //! Set the scaling limit for printing, so that small stuff is not zoomed to full page
1192  void SetPrintScaleLimit( double val ) { m_printscalelimit = val; }
1193 
1194  //! If true, draw a frame around printouts
1195  void SetPrintFrame( bool val ) { m_printframe = val; }
1196 
1197  //! If true, draw a view on all page without real scale
1198  void SetPrintFitToPage( bool val ) { m_printfittopage = val; }
1199 
1200  //! get mouse position X
1201  int GetMouseX() { return m_mouse_x; }
1202  //! get mouse position Y
1203  int GetMouseY() { return m_mouse_y; }
1204 
1205  //! get mouse position X in world coordinates
1206  int GetWorldMouseX() { return ( int )m_drawer2D->DeviceToWorldX( m_mouse_x ); }
1207  //! get mouse position Y in world coordinates
1208  int GetWorldMouseY() { return ( int )m_drawer2D->DeviceToWorldY( m_mouse_y ); }
1209 
1210  //! convert mouse position as seen from the display window, into world coordinates.
1211  //! If no display window is defined,
1212  void MouseToToolWorld( int x, int y, double& xWorldLocal, double& yWorldLocal );
1213 
1214  //! get mouse position as seen from the display window, in world coordinates.
1215  //! If no display window is defined,
1216  void ToolWorldToMouse( double xWorld, double yWorld, int& x, int& y );
1217 
1218  //! if tool want an event to be handled by the view, even if already processed.
1219  void SetToolWantsEventToContinue( bool continueEvent = true ) { m_toolWantsIt = continueEvent; }
1220 
1221 protected:
1222 
1223  //void OnActivate( a2dViewEvent& activateEvent );
1224  //void OnCloseView( a2dCloseViewEvent& event );
1225 
1226  void OnSetFocus( wxFocusEvent& focusevent );
1227 
1228  void OnKillFocus( wxFocusEvent& focusevent );
1229 
1230  void OnEnter( wxMouseEvent& WXUNUSED( event ) );
1231 
1232  //! redraw and/or blit pending areas to the device
1233  void OnIdle( wxIdleEvent& event );
1234 
1235  //! normally sent from wxWindow containing the view, via its ProcessEvent(wxEvent& event)
1236  void OnMouseEvent( wxMouseEvent& event );
1237 
1238  //! normally sent from wxWindow containing the view, via its ProcessEvent(wxEvent& event)
1239  /*!
1240 
1241  */
1242  void OnCharEvent( wxKeyEvent& event );
1243 
1244  //! called for a2dComEvent events.
1245  void OnComEvent( a2dComEvent& event );
1246 
1247 #ifdef _DEBUG
1248  //!
1249  void OnDoEvent( a2dCommandProcessorEvent& event );
1250 
1251  //!
1252  void OnRedoEvent( a2dCommandProcessorEvent& event );
1253 
1254  //!
1255  void OnUndoEvent( a2dCommandProcessorEvent& event );
1256 #endif //_DEBUG
1257 
1258  //! do this at command start
1259  void OnBusyBegin( a2dCommandProcessorEvent& WXUNUSED( event ) );
1260 
1261  //! do this at command end
1262  void OnBusyEnd( a2dCommandProcessorEvent& WXUNUSED( event ) );
1263 
1264  //!redraw the pending update areas to the buffer given in device coordinates.
1265  void RedrawPendingUpdateAreas( bool noblit = false );
1266 
1267  //!pending update areas in the update list are deleted.
1268  /*! use when ready with updates, or when they become useless because of scroll etc.
1269  */
1270  void DeleteAllPendingAreas();
1271 
1272  //! based on angle and radius and m_aberration calculate a proper delta phi and number of segments
1273  /*!
1274  The calculation is used for circular arc segments
1275  */
1276  void Aberration( double angle, double radius, double& dphi, unsigned int& segments );
1277 
1278  //!buffer updating activity possible or not
1279  bool m_frozen;
1280 
1281  //!object that is receiving events
1283 
1284  //! when a corridor is active, this is set.
1286 
1287  //!enable/ disable mouse events handling by canvas
1289 
1290  //!top object for drawer object, from here the rendering starts
1292 
1293  //!background fill of canvas and background color of background fill in case of mono colour fill
1295 
1296  //! border zoomout but leaf around a border of this amount of pixels.
1297  wxUint16 m_border;
1298 
1299  //!showorigin?
1301 
1302  //!grid drawn at front or back
1304 
1305  //! is croshair visible
1307 
1308  //!crosshair x
1310 
1311  //!crosshair y
1313 
1314  //! crosshair cursor Length in X in pixels
1316 
1317  //! crosshair cursor Length in Y in pixels
1319 
1320  //! stroke to use for crosshair
1322 
1323  //! last mouse position
1324  int m_mouse_x, m_mouse_y;
1325 
1326  //!grid stroke
1328 
1329  //!grid fill
1331 
1332  //!fixed style stroke
1334 
1335  //!fixed style fill
1337 
1338  //!overlay style stroke
1340 
1341  //!overlay style fill
1343 
1344  //!select style stroke
1346 
1347  //!select style fill
1349 
1350  //!select style stroke
1352 
1353  //!select style fill
1355 
1356  //!highLight style stroke
1358 
1359  //!highLight style fill
1361 
1362  //!grid distance in x
1363  double m_gridx;
1364 
1365  //!grid distance in y
1366  double m_gridy;
1367 
1368  //!grid point size
1369  wxUint16 m_gridsize;
1370 
1371  //!show grid as lines
1373 
1374  //! threshold for grid.
1375  wxUint16 m_gridthres;
1376 
1377  //!grid on/off
1378  bool m_grid;
1379 
1380  //!is the virtual area set already (used during startup)
1382 
1383  //!device size width
1384  int m_width;
1385 
1386  //!device size height
1388 
1389  //! accuracy of spline
1391 
1392  //! pushed clipping regions
1393  a2dClipRegionList m_clipregionlist;
1394 
1395  //!accuracy of arc segment calculation etc. in device coordinates
1397 
1398  //!list of rectangles that need to be blited to the screen.
1399  /*!
1400  This list holds several rectangles, which should be updated.
1401  The are blitted from the buffer, since they were damaged they first need to be updated.
1402  */
1404 
1405  //!to prevent recursive updates
1406  bool m_recur;
1407 
1408  //! toolscontroller plugged in as first event handler
1410 
1411  a2dDrawer2D* m_drawer2D;
1412 
1413  wxWindow* m_drawingDisplay;
1414 
1415  //! how close does a hit need to be to the object you are trying to hit.
1416  /*! This is given in device units (pixels) and tranformed to world units
1417  using the drawers transform
1418  */
1419  wxUint16 m_hitmargin;
1420 
1421  //! underneath the threshold draw rectangles.
1423 
1424  //! drawstyles to use when rendering document
1426 
1427  //! drawstyles to use when rendering overlay
1429 
1430  //! to restore style after a temporary change.
1432 
1433  //! if true, a printout is done with title (document name (description?)), otherwise not
1435 
1436  //! if true, a printout is done with filename (document file path), otherwise not
1438 
1439  //! Set the scaling limit for printing, so that small stuff is not zoomed to full page
1441 
1442  //! If true, draw a frame around printouts
1444 
1445  //! If true, draw a view on all page without real scale
1447 
1448  //! which layer should be rendered ( visible and/or available )
1449  a2dLayerViewList m_layerRenderArray;
1450 
1451  //!flag to updatelayers that are available.
1452  /*!
1453  It is set when m_layerRenderArray does not contain all layers used by a2dCanvasObject's
1454  */
1456 
1457  //! tiles on drawing surface, used to optimize update areas.
1459 
1460  a2dTiles m_tiles2;
1461 
1462  //!draw in reverse order if set
1464 
1465  bool m_viewDependentObjects;
1466 
1467  a2dCursorStack m_cursorStack;
1468 
1469  a2dPushInStack m_pushInStack;
1470 
1471  a2dCanvasObjectList m_overlayObjects;
1472 
1473  bool m_toolWantsIt;
1474 
1475  a2dSmrtPtrList< a2dIterPP > m_patToHitPrev;
1476  a2dSmrtPtrList< a2dIterPP > m_patToHitCur;
1477 
1478 public:
1479 
1480  bool m_skipBuffer;
1481 
1482  DECLARE_DYNAMIC_CLASS( a2dDrawingPart )
1483 
1484 private:
1485 
1486  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
1487 
1488  //initialize a drawer
1489  void Init();
1490 
1491 public:
1492 
1493  static a2dPropertyIdUint16* PROPID_drawstyle;
1494  static a2dPropertyIdBool* PROPID_gridlines;
1495  static a2dPropertyIdBool* PROPID_grid;
1496  static a2dPropertyIdBool* PROPID_showorigin;
1497  static a2dPropertyIdUint16* PROPID_hitmargin;
1498  static a2dPropertyIdBool* PROPID_gridatfront;
1499  static a2dPropertyIdUint16* PROPID_gridsize;
1500  static a2dPropertyIdUint16* PROPID_gridthres;
1501  static a2dPropertyIdDouble* PROPID_gridx;
1502  static a2dPropertyIdDouble* PROPID_gridy;
1503 
1504  //! when more layers changed ( rerendering view is needed).
1505  static const a2dSignal sig_changedLayers;
1506  //! when an object is added to a layer, and therefore makes this layer available.
1507  static const a2dSignal sig_changedLayerAvailable;
1508  //! when one layer is set visible in a2dDrawingPart
1509  static const a2dSignal sig_changedLayerVisibleInView;
1510 
1511  //! id for changed a2dObject
1512  //! a new show object was chosen in a2dDrawingPart
1513  static const a2dSignal sig_changedShowObject;
1514 
1516 
1517 };
1518 
1519 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
1520 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dDrawingPart>;
1521 #endif
1522 
1523 
1524 #if wxUSE_PRINTING_ARCHITECTURE
1525 #include "wx/prntbase.h"
1526 
1527 
1528 // Don't use the Windows printer if we're in wxUniv mode and using
1529 // the PostScript architecture
1530 #if wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXUNIVERSAL__) || !wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
1531 
1532 
1533 class a2dPrintFactory: public wxNativePrintFactory
1534 {
1535 public:
1536  virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
1537 
1538  virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
1539  wxPrintout *printout = NULL,
1540  wxPrintDialogData *data = NULL );
1541  virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
1542  wxPrintout *printout,
1543  wxPrintData *data );
1544 };
1545 
1546 // ---------------------------------------------------------------------------
1547 // ---------------------------------------------------------------------------
1548 
1549 #if defined(__WXMSW__)
1550 #include "wx/msw/printwin.h"
1551 
1552 class WXDLLIMPEXP_CORE a2dWindowsPrintPreview : public wxWindowsPrintPreview
1553 {
1554 public:
1555  a2dWindowsPrintPreview(wxPrintout *printout,
1556  wxPrintout *printoutForPrinting = NULL,
1557  wxPrintDialogData *data = NULL);
1558  a2dWindowsPrintPreview(wxPrintout *printout,
1559  wxPrintout *printoutForPrinting,
1560  wxPrintData *data);
1561  virtual ~a2dWindowsPrintPreview();
1562 
1563 
1564 protected:
1565  virtual bool RenderPageIntoBitmap(wxBitmap& bmp, int pageNum);
1566 
1567  DECLARE_DYNAMIC_CLASS_NO_COPY(a2dWindowsPrintPreview)
1568 };
1569 
1570 #endif
1571 
1572 #endif
1573 
1574 
1575 #endif // wxUSE_PRINTING_ARCHITECTURE
1576 
1577 
1578 
1579 
1580 #if wxUSE_DRAG_AND_DROP
1581 //! Copy paste data objects for a2dDrawing.
1582 /*!
1583  To copy paste data to and from a a2dDrawing and the a2dDrawingPart currently active.
1584 
1585  At least a bitmap and text and url can be pasted from another application.
1586  Within wxArt2d a2dCanvasObject's can be copied and pasted internally,
1587  and external this will result in a bitmap or metafile to pasted.
1588 */
1589 template < class parserTypeIn, class parserTypeOut >
1590 class a2dDnDCanvasObjectData : public wxDataObject
1591 {
1592 public:
1593 
1594  a2dDnDCanvasObjectData( a2dDrawingPart* drawingPart = NULL, wxDataObject::Direction dir = wxDataObject::Set );
1595 
1596  virtual ~a2dDnDCanvasObjectData();
1597 
1598  //! add a canvasopbject to the copy data
1599  void Append( a2dCanvasObject* canvasobject );
1600 
1601  //! objects appended as clone, will be reconnected if connected.
1602  void Reconnect();
1603 
1604  a2dDrawing* GetDrawing() const { return m_drawing; }
1605 
1606  a2dCanvasObjectList* GetObjects() const;
1607 
1608  //if URL available return it
1609  wxString GetURL () const;
1610 
1611  //if text available return it
1612  wxString GetText() const;
1613 
1614  //! if set non zero, the width or height of the imported a2dImage will be set to this.
1615  void SetImportWidthHeightImage( double importWidthHeightImage ) { m_importWidthHeightImage = importWidthHeightImage; }
1616 
1617  //! if non zero, the width or height of the imported a2dImage will be set to this.
1618  double GetImportWidthHeightImage() const { return m_importWidthHeightImage; }
1619 
1620  // if set non zero, the width or height of the exported a2dImage or metafile resolution will be set to this.
1621  void SetExportWidthHeightImage( double exportWidthHeightImage ) { m_exportWidthHeightImage = exportWidthHeightImage; }
1622 
1623  //! if non zero, the width or height of the imported a2dImage will be set to this.
1624  double GetExportWidthHeightImage() const { return m_exportWidthHeightImage; }
1625 
1626  // implement base class pure virtuals
1627  // ----------------------------------
1628 
1629  virtual wxDataFormat GetPreferredFormat(Direction dir = Get ) const;
1630 
1631  virtual size_t GetFormatCount(Direction dir = Get ) const;
1632 
1633  virtual void GetAllFormats(wxDataFormat *formats, Direction dir = Get ) const;
1634 
1635  virtual size_t GetDataSize(const wxDataFormat& format) const;
1636 
1637  virtual bool GetDataHere(const wxDataFormat& format, void *pBuf) const;
1638 
1639  virtual bool SetData(const wxDataFormat& format,
1640  size_t WXUNUSED(len), const void *buf);
1641 protected:
1642 
1643  wxBitmap RenderImage( a2dCanvasObject* canvasobject ) const;
1644  void RenderToDc( wxDC* dc, a2dCanvasObject* canvasobject ) const;
1645 
1646  // creates a bitmap and assigns it to m_dobjBitmap (also sets m_hasBitmap)
1647  void CreateBitmap() const;
1648 #if wxUSE_METAFILE
1649  void CreateMetaFile() const;
1650 #endif // wxUSE_METAFILE
1651 
1652  bool m_hasShapes;
1653  wxDataFormat m_formatShape; // our custom format
1654 
1655  mutable a2dDocumentStringOutputStream m_mem;
1656 
1657  wxTextDataObject m_dobjText;
1658  bool m_hasText;
1659 
1660  wxBitmapDataObject m_dobjBitmap; // it handles bitmaps
1661  bool m_hasBitmap; // true if m_dobjBitmap has valid bitmap
1662 
1663  wxURLDataObject m_dobjURL;
1664  bool m_hasURL;
1665 
1666 #if wxUSE_METAFILE
1667  wxMetaFileDataObject m_dobjMetaFile;// handles metafiles
1668  bool m_hasMetaFile; // true if we have valid metafile
1669 #endif // wxUSE_METAFILE
1670 
1671  a2dDrawingPtr m_drawing; // to hold objects.
1672 
1673  a2dRefMap m_refs;
1674 
1675  a2dSmrtPtr<a2dDrawingPart> m_drawingPart; // drawing part from which the copy was made.
1676 
1677  double m_dragStartX;
1678  double m_dragStartY;
1679 
1680  double m_importWidthHeightImage;
1681  double m_exportWidthHeightImage;
1682 };
1683 
1684 typedef a2dDnDCanvasObjectData< a2dIOHandlerCVGIn, a2dIOHandlerCVGOut > a2dDnDCanvasObjectDataCVG;
1685 
1686 extern const wxChar *a2dCanvasObjectFormatId;
1687 
1688 template < class parserTypeIn, class parserTypeOut >
1689 a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::a2dDnDCanvasObjectData( a2dDrawingPart* drawingPart, wxDataObject::Direction dir )
1690 {
1691  m_drawingPart = drawingPart;
1692  m_dragStartX = 0;
1693  m_dragStartY = 0;
1694 
1695  m_drawing = new a2dDrawing();
1696  m_drawing->SetCommandProcessor( NULL );
1697 
1698  // this string should uniquely identify our format, but is otherwise
1699  // arbitrary
1700  m_formatShape.SetId(a2dCanvasObjectFormatId);
1701 
1702  // we don't draw the shape to a bitmap until it's really needed (i.e.
1703  // we're asked to do so)
1704  m_hasShapes = false;
1705  m_hasText = false;
1706  m_hasURL = false;
1707  m_hasBitmap = false;
1708 #if wxUSE_METAFILE
1709  m_hasMetaFile = false;
1710 #endif // wxUSE_METAFILE
1711  m_importWidthHeightImage = 0;
1712  m_exportWidthHeightImage = 0;
1713 
1714  if ( dir == wxDataObject::Set )
1715  return;
1717 
1718  //search selected shapes, and copy them to the local drawing
1719  if ( m_drawingPart )
1720  {
1721  a2dCanvasObjectList* objects = m_drawingPart->GetShowObject()->GetChildObjectList();
1722  forEachIn( a2dCanvasObjectList, objects )
1723  {
1724  a2dCanvasObject* obj = *iter;
1725  if ( obj->GetRelease() || !obj->IsVisible() || !obj->GetSelected() )
1726  continue;
1727  Append( obj );
1728  m_hasShapes = true;
1729  }
1730  Reconnect();
1731  }
1733 
1734  // selected text in editing of text has priority above selected objects.
1735  if ( m_drawingPart && wxDynamicCast( m_drawingPart->GetCanvasToolContr(), a2dStToolContr ) )
1736  {
1737  a2dStToolContr* contr = wxDynamicCast( m_drawingPart->GetCanvasToolContr(), a2dStToolContr );
1738  if ( contr )
1739  {
1741  if ( edittool )
1742  {
1743  a2dText* text = wxDynamicCast( edittool->GetEditObjectCopy(), a2dText );
1744  if ( text )
1745  {
1746  if ( !text->GetSelectedText().IsEmpty() && !m_hasURL )
1747  {
1748  m_hasURL = true;
1749  m_dobjURL.SetURL( text->GetSelectedText() );
1750  }
1751  if ( !text->GetSelectedText().IsEmpty() && !m_hasText )
1752  {
1753  m_hasText = true;
1754  m_dobjText.SetText( text->GetSelectedText() );
1755  }
1756  }
1757  }
1758  }
1759  }
1760  // if no text or url was selected in editing text, see if there is a text object selected.
1761  if ( m_drawingPart && !m_hasURL && !m_hasText )
1762  {
1763  a2dCanvasObjectList* objects = m_drawingPart->GetShowObject()->GetChildObjectList();
1764  forEachIn( a2dCanvasObjectList, objects )
1765  {
1766  a2dCanvasObject* obj = *iter;
1767  a2dText* text = wxDynamicCast( obj, a2dText );
1768  if ( text && text->GetSelected() )
1769  {
1770  if ( !m_hasURL )
1771  {
1772  m_hasURL = true;
1773  m_dobjURL.SetURL( text->GetText() );
1774  }
1775  if ( !m_hasText )
1776  {
1777  m_hasText = true;
1778  m_dobjText.SetText( text->GetText() );
1779  }
1780  }
1781  }
1782  }
1783 }
1784 
1785 template < class parserTypeIn, class parserTypeOut >
1786 a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::~a2dDnDCanvasObjectData()
1787 {
1788  m_drawing = NULL;
1789 }
1790 
1791 template < class parserTypeIn, class parserTypeOut >
1792 void a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::Append( a2dCanvasObject* canvasobject )
1793 {
1794  if ( !m_drawing )
1795  {
1796  m_drawing = new a2dDrawing();
1797  m_drawing->SetCommandProcessor( NULL );
1798  }
1799 
1800  if ( canvasobject )
1801  {
1802  a2dCanvasObject* copy = canvasobject->TClone( a2dObject::clone_deep | a2dObject::clone_noCameleonRef | a2dObject::clone_noReference, &m_refs );
1803  m_drawing->Append( copy );
1804  }
1805 }
1806 
1807 template < class parserTypeIn, class parserTypeOut >
1808 void a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::Reconnect()
1809 {
1810  // if template is a bunch of connected objects, the clone needs to be reconnected.
1811  m_refs.LinkReferences( true );
1812  a2dCanvasObjectPtr shape = m_drawing->GetRootObject();
1813  shape->GetBbox().SetValid( false );
1815 }
1816 
1817 template < class parserTypeIn, class parserTypeOut >
1818 a2dCanvasObjectList* a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetObjects() const
1819 {
1820  return m_drawing->GetRootObject()->CreateChildObjectList();
1821 }
1822 
1823 template < class parserTypeIn, class parserTypeOut >
1824 wxString a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetURL () const
1825 {
1826  if ( m_hasURL )
1827  return m_dobjURL.GetURL();
1828  return wxEmptyString;
1829 }
1830 
1831 template < class parserTypeIn, class parserTypeOut >
1832 wxString a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetText() const
1833 {
1834  if ( m_hasText )
1835  return m_dobjText.GetText();
1836  return wxEmptyString;
1837 }
1838 
1839 template < class parserTypeIn, class parserTypeOut >
1840 wxDataFormat a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetPreferredFormat(Direction WXUNUSED(dir)) const
1841 {
1842  return m_formatShape;
1843 }
1844 
1845 template < class parserTypeIn, class parserTypeOut >
1846 size_t a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetFormatCount(Direction dir) const
1847 {
1848  // our custom formats are supported by both GetData() and SetData()
1849  size_t nFormats = 0;
1850  if ( dir == Get )
1851  {
1852  size_t index = 0;
1853  if ( m_hasShapes )
1854  {
1855  nFormats++;
1856  }
1857 
1858  if ( m_hasURL )
1859  nFormats += m_dobjURL.GetFormatCount(dir);
1860  if ( m_hasText )
1861  nFormats += m_dobjText.GetFormatCount(dir);
1862 
1863  //if ( m_hasBitmap )
1864  nFormats += m_dobjBitmap.GetFormatCount(dir);
1865 
1866 #if wxUSE_METAFILE
1867  //if ( m_hasMetaFile )
1868  nFormats += m_dobjMetaFile.GetFormatCount(dir);
1869 #endif // wxUS
1870  }
1871  else
1872  {
1873  size_t index = 0;
1874  nFormats++;
1875 
1876  nFormats += m_dobjURL.GetFormatCount(dir);
1877  nFormats += m_dobjText.GetFormatCount(dir);
1878  nFormats += m_dobjBitmap.GetFormatCount(dir);
1879  }
1880  return nFormats;
1881 }
1882 
1883 template < class parserTypeIn, class parserTypeOut >
1884 void a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetAllFormats(wxDataFormat *formats, Direction dir) const
1885 {
1886  if ( dir == Get )
1887  {
1888  size_t index = 0;
1889  if ( m_hasShapes )
1890  {
1891  formats[index++] = m_formatShape;
1892  }
1893 
1894  if ( m_hasURL )
1895  {
1896  m_dobjURL.GetAllFormats(&formats[index], dir);
1897  index += m_dobjURL.GetFormatCount(dir);
1898  }
1899  if ( m_hasText )
1900  {
1901  m_dobjText.GetAllFormats(&formats[index], dir);
1902  index += m_dobjText.GetFormatCount(dir);
1903  }
1904  // in Get direction we additionally support bitmaps and metafiles
1905  // under Windows
1906  //if ( m_hasBitmap )
1907  {
1908  m_dobjBitmap.GetAllFormats(&formats[index], dir);
1909  index += m_dobjBitmap.GetFormatCount(dir);
1910  }
1911 #if wxUSE_METAFILE
1912  // don't assume that m_dobjBitmap has only 1 format
1913  //if ( m_hasMetaFile )
1914  m_dobjMetaFile.GetAllFormats(&formats[index], dir);
1915 #endif // wxUSE_METAFILE
1916  }
1917  else
1918  {
1919  size_t index = 0;
1920  formats[index++] = m_formatShape;
1921 
1922  m_dobjURL.GetAllFormats(&formats[index], dir);
1923  index += m_dobjURL.GetFormatCount(dir);
1924  m_dobjText.GetAllFormats(&formats[index], dir);
1925  index += m_dobjText.GetFormatCount(dir);
1926 
1927  // in Get direction we additionally support bitmaps and metafiles
1928  // under Windows
1929  m_dobjBitmap.GetAllFormats(&formats[index], dir);
1930  index += m_dobjBitmap.GetFormatCount(dir);
1931  }
1932 }
1933 
1934 template < class parserTypeIn, class parserTypeOut >
1935 size_t a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetDataSize(const wxDataFormat& format) const
1936 {
1937  if ( format == m_formatShape )
1938  {
1939  if ( !m_hasShapes )
1940  return 0;
1941 
1942  // convert to a memory string by writing it to CVG.
1943 
1944  // Set the locale to english for this I/O operation
1945  // !!!! It would be better to set the locale of the stream itself,
1946  // but this does not work for two reasons:
1947  // 1. wxWindows streams don't support this
1948  // 2. CVG-IO uses e.g. wxString::ToDouble, which is independent of the stream
1949  wxString oldLocale = wxSetlocale( LC_NUMERIC, NULL );
1950  #ifdef __WXMSW__
1951  wxSetlocale( LC_NUMERIC, wxString( wxT( "English" ) ) );
1952  #else
1953  wxSetlocale( LC_NUMERIC, wxString( wxT( "en_US" ) ) );
1954  #endif
1955 
1956  m_mem.str("");
1957  if ( m_drawing->GetRootObject()->GetChildObjectsCount() )
1958  {
1959  parserTypeOut CVGwriter;
1960  CVGwriter.SaveStartAt( m_mem, m_drawing, m_drawing->GetRootObject() );
1961  //CVGwriter.SaveStartAt( m_mem, m_regler->GetDrawing(), m_regler->GetDrawing()->GetRootObject() );
1962 
1963  wxSetlocale( LC_NUMERIC, oldLocale );
1964  /* to debug contents
1965  wxFFileOutputStream file("c:/data/soft/out2.txt");
1966  wxStdOutputStream out(file);
1967 
1968  out << m_mem.str() << std::endl;
1969  */
1970  }
1971  m_mem.seekp(0);
1972 
1973  return m_mem.str().length() + 10;
1974  }
1975 #if wxUSE_METAFILE
1976  else if ( m_dobjMetaFile.IsSupported(format) )
1977  {
1978  if ( !m_hasMetaFile )
1979  CreateMetaFile();
1980 
1981  return m_dobjMetaFile.GetDataSize(format);
1982  }
1983 #endif // wxUSE_METAFILE
1984  else if ( m_dobjURL.IsSupported(format) )
1985  {
1986  return m_dobjURL.GetDataSize(format);
1987  }
1988  else if ( m_dobjText.IsSupported(format) )
1989  {
1990  return m_dobjText.GetDataSize();
1991  }
1992  else
1993  {
1994  wxASSERT_MSG( m_dobjBitmap.IsSupported(format),
1995  wxT("unexpected format") );
1996 
1997  if ( !m_hasBitmap )
1998  CreateBitmap();
1999 
2000  return m_dobjBitmap.GetDataSize();
2001  }
2002 }
2003 
2004 template < class parserTypeIn, class parserTypeOut >
2005 bool a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::GetDataHere(const wxDataFormat& format, void *pBuf) const
2006 {
2007  if ( format == m_formatShape )
2008  {
2009 
2010 #if wxUSE_STD_IOSTREAM
2011  wxString str = m_mem.str();
2012  wxStrcpy( (char*) pBuf, str );
2013 #else
2014  pBuf = m_mem.GetString();
2015 #endif
2016 
2017  if ( str.Len() <= 10 )
2018  return false;
2019  return true;
2020  }
2021 #if wxUSE_METAFILE
2022  else if ( m_dobjMetaFile.IsSupported(format) )
2023  {
2024  if ( !m_hasMetaFile )
2025  CreateMetaFile();
2026 
2027  return m_dobjMetaFile.GetDataHere(format, pBuf);
2028  }
2029 #endif // wxUSE_METAFILE
2030  else if ( m_dobjURL.IsSupported(format) )
2031  {
2032  return m_dobjURL.GetDataHere(format, pBuf);
2033  }
2034  else if ( m_dobjText.IsSupported(format) )
2035  {
2036  return m_dobjText.GetDataHere(format, pBuf);
2037  }
2038  else
2039  {
2040  wxASSERT_MSG( m_dobjBitmap.IsSupported(format),
2041  wxT("unexpected format") );
2042 
2043  if ( !m_hasBitmap )
2044  {
2045  CreateBitmap();
2046  }
2047  return m_dobjBitmap.GetDataHere(pBuf);
2048  }
2049 }
2050 
2051 template < class parserTypeIn, class parserTypeOut >
2052 bool a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::SetData(const wxDataFormat& format, size_t len, const void *buf )
2053 {
2054  if ( !m_drawing )
2055  {
2056  m_drawing = new a2dDrawing();
2057  m_drawing->SetCommandProcessor( NULL );
2058  }
2059 
2060  if ( format == m_formatShape )
2061  {
2062  wxCharBuffer cvgString = wxCharBuffer( (const char*) buf );
2063 
2064  // Set the locale to english for this I/O operation
2065  // !!!! It would be better to set the locale of the stream itself,
2066  // but this does not work for two reasons:
2067  // 1. wxWindows streams don't support this
2068  // 2. CVG-IO uses e.g. wxString::ToDouble, which is independent of the stream
2069  wxString oldLocale = wxSetlocale( LC_NUMERIC, NULL );
2070 #ifdef __WXMSW__
2071  wxSetlocale( LC_NUMERIC, wxString( wxT( "English" ) ) );
2072 #else
2073  wxSetlocale( LC_NUMERIC, wxString( wxT( "en_US" ) ) );
2074 #endif
2075 
2076  #if wxART2D_USE_CVGIO
2077  #if wxUSE_STD_IOSTREAM
2078  #if wxUSE_UNICODE
2079  a2dDocumentStringInputStream stream( cvgString.data(), wxSTD ios_base::in );
2080  #else
2081  a2dDocumentStringInputStream stream( cvgString, wxSTD ios_base::in );
2082  #endif // wxUSE_UNICODE
2083  #else
2084  a2dDocumentStringInputStream stream( cvgStringtoExecute );
2085  #endif
2086 
2087  parserTypeIn CvgString;
2088 
2089  //a2dCanvasObjectPtr root = m_drawing->GetRootObject();
2090  CvgString.Load( stream, m_drawing, m_drawing->GetRootObject() );
2091 
2093  a2dCanvasObjectList* objects = m_drawing->GetRootObject()->GetChildObjectList();
2094  forEachIn( a2dCanvasObjectList, objects )
2095  {
2096  a2dCanvasObject* obj = *iter;
2097  obj->Translate( -m_dragStartX, -m_dragStartY);
2098  }
2100 
2101  //we have shapes from the clipboard stored here
2102  m_hasShapes = true;
2103 
2104  m_hasURL = m_hasText = false;
2105 
2106  // if text object available in copied object, make text as paste available.
2107  forEachIn( a2dCanvasObjectList, objects )
2108  {
2109  a2dCanvasObject* obj = *iter;
2110  a2dText* text = wxDynamicCast( obj, a2dText );
2111  if ( text )
2112  {
2113  if ( !m_hasURL )
2114  {
2115  m_hasURL = true;
2116  m_dobjURL.SetURL( text->GetText() );
2117  }
2118  if ( !m_hasText )
2119  {
2120  m_hasText = true;
2121  m_dobjText.SetText( text->GetText() );
2122  }
2123  }
2124  }
2125 
2126  // the shape has changed
2127  m_hasBitmap = false;
2128  wxSetlocale( LC_NUMERIC, oldLocale );
2129 
2130  #if wxUSE_METAFILE
2131  m_hasMetaFile = false;
2132  #endif // wxUSE_METAFILE
2133  return true;
2134  #else
2135  return false;
2136  #endif //wxART2D_USE_CVGIO
2137 
2138  //m_canvasobject = new a2dRect( 0,0, 3000,4000);
2139  return true;
2140  }
2141  else if ( m_dobjURL.IsSupported(format) )
2142  {
2143  // we create a pure text objects, and an a2dText object, the aplication decides what it wants to have.
2144  m_dobjURL.SetData( format, len, buf);
2145  m_hasURL = true;
2146 
2147  a2dText* text = NULL;
2148  //m_regler->GetDrawing()->Append( new a2dText( m_dobjURL.GetURL(), 0, 0, a2dCanvasGlobals->GetTextTemplateObject()->GetFont(), 0, true ) );
2149  text = a2dCanvasGlobals->GetHabitat()->GetTextTemplateObject()->TClone( a2dObject::clone_deep );
2150  text->SetText( m_dobjURL.GetURL() );
2151  m_drawing->Append( text );
2152  //we have shapes created from data on the clipboard stored here
2153  m_hasShapes = true;
2154  return true;
2155  }
2156  else if ( m_dobjText.IsSupported(format) )
2157  {
2158  // we create a pure text objects, and an a2dText object, the aplication decides what it wants to have.
2159  m_dobjText.SetData(len, buf);
2160  m_hasText = true;
2161 
2162  a2dText* text = NULL;
2163  //m_regler->GetDrawing()->Append( new a2dText( m_dobjURL.GetURL(), 0, 0, a2dCanvasGlobals->GetTextTemplateObject()->GetFont(), 0, true ) );
2164  text = a2dCanvasGlobals->GetHabitat()->GetTextTemplateObject()->TClone( a2dObject::clone_deep );
2165  text->SetText( m_dobjText.GetText() );
2166  m_drawing->Append( text );
2167  //we have shapes created from data on the clipboard stored here
2168  m_hasShapes = true;
2169  return true;
2170  }
2171  else if ( m_dobjBitmap.IsSupported(format) )
2172  {
2173  m_dobjBitmap.SetData(len, buf);
2174  m_drawing = new a2dDrawing();
2175 
2176  double w = m_dobjBitmap.GetBitmap().GetWidth();
2177  double h = m_dobjBitmap.GetBitmap().GetHeight();
2178  if ( m_importWidthHeightImage )
2179  {
2180  if ( w > h )
2181  {
2182  h = m_importWidthHeightImage * h/w;
2183  w = m_importWidthHeightImage;
2184  }
2185  else
2186  {
2187  w = m_importWidthHeightImage * w/h;
2188  h = m_importWidthHeightImage;
2189  }
2190  a2dImage* im = new a2dImage( m_dobjBitmap.GetBitmap().ConvertToImage(), 0, 0, w, h );
2191  im->SetFilename( im->GetName() + ".jpg", wxBITMAP_TYPE_JPEG, false );
2192  im->SetFill( *a2dTRANSPARENT_FILL );
2193  m_drawing->Append( im );
2194  }
2195  else
2196  {
2197  a2dImage* im = new a2dImage( m_dobjBitmap.GetBitmap().ConvertToImage(), 0, 0, w, h );
2198  im->SetFilename( im->GetName() + ".jpg", wxBITMAP_TYPE_JPEG, false );
2199  im->SetFill( *a2dTRANSPARENT_FILL );
2200  m_drawing->Append( im );
2201  }
2202 
2203  //we have shapes created from data on the clipboard stored here
2204  m_hasShapes = true;
2205  m_hasBitmap = true;
2206  return true;
2207  }
2208  return false;
2209 }
2210 
2211 #if wxUSE_METAFILE
2212 
2213 template < class parserTypeIn, class parserTypeOut >
2214 void a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::CreateMetaFile() const
2215 {
2216  //wxPoint pos = m_canvasobject->GetPosXY();
2217 
2218  wxMetaFileDC dcMF;//(wxEmptyString, pos.x + size.x, pos.y + size.y);
2219 
2220  m_drawing->GetRootObject()->GetBbox().SetValid( false );
2221  m_drawing->GetRootObject()->Update( a2dCanvasObject::updatemask_force );
2222  RenderToDc( &dcMF, m_drawing->GetRootObject() );
2223 
2224  wxMetafile *mf = dcMF.Close();
2225 
2226  a2dDnDCanvasObjectData *self = (a2dDnDCanvasObjectData *)this; // const_cast
2227  self->m_dobjMetaFile.SetMetafile(*mf);
2228  self->m_hasMetaFile = true;
2229 
2230  delete mf;
2231 }
2232 
2233 #endif // wxUSE_METAFILE
2234 
2235 template < class parserTypeIn, class parserTypeOut >
2236 void a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::CreateBitmap() const
2237 {
2238  wxBitmap bitmap = RenderImage( m_drawing->GetRootObject() );
2239  a2dDnDCanvasObjectData *self = (a2dDnDCanvasObjectData *)this; // const_cast
2240  self->m_dobjBitmap.SetBitmap(bitmap);
2241  self->m_hasBitmap = true;
2242 }
2243 
2244 
2245 template < class parserTypeIn, class parserTypeOut >
2246 wxBitmap a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::RenderImage( a2dCanvasObject* canvasobject ) const
2247 {
2248  wxSize imageSize = wxSize( 1000, 1000 );
2249  if ( m_drawingPart )
2250  imageSize = wxSize( m_drawingPart->GetDrawer2D()->GetWidth(), m_drawingPart->GetDrawer2D()->GetHeight() );
2251 
2252  int maxWidthHeight = wxMax( imageSize.x, imageSize.y );
2253  if ( m_exportWidthHeightImage )
2254  maxWidthHeight = m_exportWidthHeightImage;
2255 
2256  a2dBoundingBox viewBox;
2257  if ( canvasobject->GetBbox().GetValid() )
2258  {
2259  // view will be based on showobject its boundingbox
2260  viewBox = canvasobject->GetBbox();
2261  a2dAffineMatrix cworld = canvasobject->GetTransformMatrix();
2262  cworld.Invert();
2263  viewBox.MapBbox( cworld );
2264  }
2265 
2266  double w = viewBox.GetWidth();
2267  double h = viewBox.GetHeight();
2268 
2269  if ( w == 0 )
2270  w = 1000;
2271  if ( h == 0 )
2272  h = 1000;
2273 
2274  //virtual coordinates box its miminum X ( calculated to
2275  double virt_minX;
2276  //virtual coordinates box its miminum Y
2277  double virt_minY;
2278  //user units per pixel in x
2279  double xpp;
2280  //user units per pixel in y
2281  double ypp;
2282 
2283  //first calculate an image size that fits the drawing part size.
2284  xpp = w / maxWidthHeight;
2285  ypp = h / maxWidthHeight;
2286  if ( xpp > ypp )
2287  imageSize = wxSize( maxWidthHeight, ( int ) ( h / xpp ) );
2288  else
2289  imageSize = wxSize( ( int ) ( w / ypp ), maxWidthHeight );
2290 
2291  // the rect to show in world coordinates is calculated,
2292  // such that it fits within the image.
2293  double uppx;
2294  double uppy;
2295  int clientw = imageSize.GetWidth();
2296  int clienth = imageSize.GetHeight();
2297 
2298  bool yaxis = true;
2299  int borderpercentual = 10;
2300  int border = ( int ) ( wxMin( clientw, clienth ) * borderpercentual / 100.0 ) ;
2301 
2302  if ( clientw - border > 0 )
2303  clientw = clientw - border;
2304 
2305  if ( clienth - border > 0 )
2306  clienth = clienth - border;
2307 
2308  uppx = w / clientw;
2309  uppy = h / clienth;
2310  if ( uppx < uppy )
2311  uppx = uppy;
2312 
2313  double middlexworld = viewBox.GetMinX() + w / 2.0;
2314  double middleyworld = viewBox.GetMinY() + h / 2.0;
2315  virt_minX = middlexworld - ( clientw + border ) / 2.0 * uppx;
2316  virt_minY = middleyworld - ( clienth + border ) / 2.0 * uppx;
2317  xpp = uppx;
2318  ypp = uppx;
2319 
2320  a2dMemDcDrawer dcdrawer( imageSize.GetWidth(), imageSize.GetHeight() );
2321  dcdrawer.SetMappingDeviceRect( 0, 0, imageSize.GetWidth(), imageSize.GetHeight() );
2322 
2323  a2dSmrtPtr<a2dDrawingPart> drawPart;
2324  if ( m_drawingPart )
2325  drawPart = new a2dDrawingPart( *m_drawingPart );
2326  else
2327  drawPart = new a2dDrawingPart( imageSize.GetWidth(), imageSize.GetHeight() );
2328 
2329  //drawView is a a2dView and therefore gets events, but this is not wanted here.
2330  drawPart->SetEvtHandlerEnabled( false );
2331  drawPart->SetDrawer2D( &dcdrawer );
2332  drawPart->SetShowOrigin( false );
2333  drawPart->SetGrid( false );
2334  drawPart->SetShowObject( canvasobject );
2335  dcdrawer.SetYaxis( false );
2336  if ( m_drawingPart )
2337  {
2338  drawPart->SetDocumentDrawStyle( m_drawingPart->GetDocumentDrawStyle() );
2339  dcdrawer.SetYaxis( m_drawingPart->GetDrawer2D()->GetYaxis() );
2340  }
2341  drawPart->SetAvailable();
2342 
2344  setflags2.SetSkipNotRenderedInDrawing( true );
2345  setflags2.Start( canvasobject, false );
2346 
2347  drawPart->SetBackgroundFill( *a2dWHITE_FILL );
2348  dcdrawer.BeginDraw();
2349  drawPart->GetDrawer2D()->SetMappingUpp( virt_minX , virt_minY, xpp, ypp );
2350  drawPart->UpdateArea( 0, 0, imageSize.GetWidth(), imageSize.GetHeight() );
2351 
2352  dcdrawer.EndDraw();
2353 
2354  wxBitmap bitmap = dcdrawer.GetBuffer();
2355 
2356  drawPart->SetDrawer2D( NULL, true );
2357 
2358  return bitmap;
2359 }
2360 
2361 template < class parserTypeIn, class parserTypeOut >
2362 void a2dDnDCanvasObjectData< parserTypeIn, parserTypeOut >::RenderToDc( wxDC* dc, a2dCanvasObject* canvasobject ) const
2363 {
2364  wxCoord dcw, dch;
2365  dc->GetSize( &dcw, &dch );
2366 
2367  wxSize imageSize = wxSize( 1000, 1000 );
2368  if ( m_drawingPart )
2369  imageSize = wxSize( m_drawingPart->GetDrawer2D()->GetWidth(), m_drawingPart->GetDrawer2D()->GetHeight() );
2370 
2371  int maxWidthHeight = wxMax( imageSize.x, imageSize.y );
2372  if ( m_exportWidthHeightImage )
2373  maxWidthHeight = m_exportWidthHeightImage;
2374 
2375  a2dBoundingBox viewBox;
2376  if ( canvasobject->GetBbox().GetValid() )
2377  {
2378  // view will be based on the boundingbox
2379  viewBox = canvasobject->GetBbox();
2380  a2dAffineMatrix cworld = canvasobject->GetTransformMatrix();
2381  cworld.Invert();
2382  viewBox.MapBbox( cworld );
2383  }
2384 
2385  double w = viewBox.GetWidth();
2386  double h = viewBox.GetHeight();
2387 
2388  if ( w == 0 )
2389  w = 1000;
2390  if ( h == 0 )
2391  h = 1000;
2392 
2393  //virtual coordinates box its miminum X ( calculated to
2394  double virt_minX;
2395  //virtual coordinates box its miminum Y
2396  double virt_minY;
2397  //user units per pixel in x
2398  double xpp;
2399  //user units per pixel in y
2400  double ypp;
2401 
2402  //first calculate an image size that fits the drawing part size.
2403  xpp = w / maxWidthHeight;
2404  ypp = h / maxWidthHeight;
2405  if ( xpp > ypp )
2406  imageSize = wxSize( maxWidthHeight, ( int ) ( h / xpp ) );
2407  else
2408  imageSize = wxSize( ( int ) ( w / ypp ), maxWidthHeight );
2409 
2410  // the rect to show in world coordinates is calculated,
2411  // such that it fits within the image.
2412  double uppx;
2413  double uppy;
2414  int clientw = imageSize.GetWidth();
2415  int clienth = imageSize.GetHeight();
2416 
2417  bool yaxis = true;
2418  int borderpercentual = 10;
2419  int border = ( int ) ( wxMin( clientw, clienth ) * borderpercentual / 100.0 ) ;
2420 
2421  if ( clientw - border > 0 )
2422  clientw = clientw - border;
2423 
2424  if ( clienth - border > 0 )
2425  clienth = clienth - border;
2426 
2427  uppx = w / clientw;
2428  uppy = h / clienth;
2429  if ( uppx < uppy )
2430  uppx = uppy;
2431 
2432  double middlexworld = viewBox.GetMinX() + w / 2.0;
2433  double middleyworld = viewBox.GetMinY() + h / 2.0;
2434  virt_minX = middlexworld - ( clientw + border ) / 2.0 * uppx;
2435  virt_minY = middleyworld - ( clienth + border ) / 2.0 * uppx;
2436  xpp = uppx;
2437  ypp = uppx;
2438 
2439  a2dDcDrawer dcdrawer( imageSize.GetWidth(), imageSize.GetHeight() );
2440  dcdrawer.SetMappingDeviceRect( 0, 0, imageSize.GetWidth(), imageSize.GetHeight() );
2441 
2442  a2dSmrtPtr<a2dDrawingPart> drawPart;
2443  if ( m_drawingPart )
2444  drawPart = new a2dDrawingPart( *m_drawingPart );
2445  else
2446  drawPart = new a2dDrawingPart( imageSize.GetWidth(), imageSize.GetHeight() );
2447 
2448  //drawView is a a2dView and therefore gets events, but this is not wanted here.
2449  drawPart->SetEvtHandlerEnabled( false );
2450  drawPart->SetDrawer2D( &dcdrawer );
2451  dcdrawer.SetRenderDC( dc ); //a trick to set the drawers internal dc.
2452  drawPart->SetShowOrigin( false );
2453  drawPart->SetGrid( false );
2454  drawPart->SetShowObject( canvasobject );
2455  dcdrawer.SetYaxis( false );
2456  if ( m_drawingPart )
2457  {
2458  drawPart->SetDocumentDrawStyle( m_drawingPart->GetDocumentDrawStyle() );
2459  dcdrawer.SetYaxis( m_drawingPart->GetDrawer2D()->GetYaxis() );
2460  }
2461  drawPart->SetAvailable();
2462 
2464  setflags2.SetSkipNotRenderedInDrawing( true );
2465  setflags2.Start( canvasobject, false );
2466 
2467  drawPart->SetBackgroundFill( *a2dWHITE_FILL );
2468  dcdrawer.BeginDraw();
2469  drawPart->GetDrawer2D()->SetMappingUpp( virt_minX , virt_minY, xpp, ypp );
2470  drawPart->UpdateArea( 0, 0, imageSize.GetWidth(), imageSize.GetHeight() );
2471 
2472  dcdrawer.EndDraw();
2473  dcdrawer.SetRenderDC( NULL );
2474  drawPart->SetDrawer2D( NULL, true );
2475 /*
2476  dc->SetBrush( *wxTRANSPARENT_BRUSH );
2477  dc->SetPen( *wxRED_PEN );
2478  dc->DrawRectangle( 0,0, 100, 20 );
2479  dc->DrawRectangle( 20,20, 50, 30 );
2480 */
2481  return;
2482 }
2483 
2484 class a2dDnDCameleonData : public a2dDnDCanvasObjectDataCVG
2485 {
2486 public:
2487 
2488  a2dDnDCameleonData( a2dCanvasObject* canvasobject = (a2dCanvasObject*) NULL, double dragStartX = 0, double dragStartY = 0, a2dDrawingPart* drawingPart = NULL );
2489 
2490  virtual ~a2dDnDCameleonData();
2491 
2492  // implement base class pure virtuals
2493  // ----------------------------------
2494 
2495  virtual size_t GetDataSize(const wxDataFormat& format) const;
2496 
2497  virtual bool SetData(const wxDataFormat& format,
2498  size_t WXUNUSED(len), const void *buf);
2499 private:
2500 
2501 };
2502 
2503 // ----------------------------------------------------------------------------
2504 // wxDropTarget derivation for DnDShapes
2505 // ----------------------------------------------------------------------------
2506 
2507 class a2dDnDCanvasObjectDropTarget : public wxDropTarget
2508 {
2509 public:
2510  a2dDnDCanvasObjectDropTarget( a2dDrawingPart* drawingPart )
2511  : wxDropTarget(new a2dDnDCanvasObjectDataCVG )
2512  {
2513  m_drawingPart = drawingPart;
2514  }
2515 
2516  // override base class (pure) virtuals
2517  virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
2518  {
2519 #if wxUSE_STATUSBAR
2520  //if ( m_drawingPart && m_drawingPart->GetDisplayWindow() )
2521  //m_drawingPart->GetDisplayWindow()->SetStatusText(wxT("Mouse entered the frame"));
2522 #endif // wxUSE_STATUSBAR
2523  return OnDragOver(x, y, def);
2524  }
2525  virtual void OnLeave()
2526  {
2527 #if wxUSE_STATUSBAR
2528  //if ( m_drawingPart && m_drawingPart->GetDisplayWindow() )
2529  //m_frame->SetStatusText(wxT("Mouse left the frame"));
2530 #endif // wxUSE_STATUSBAR
2531  }
2532  virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
2533  {
2534  if ( !GetData() )
2535  {
2536  wxLogError(wxT("Failed to get drag and drop data"));
2537 
2538  return wxDragNone;
2539  }
2540 
2541  if ( m_drawingPart && m_drawingPart->GetDisplayWindow() )
2542  {
2543  m_drawingPart->OnDrop(x, y,
2544  ((a2dDnDCanvasObjectDataCVG *)GetDataObject())->GetDrawing());
2545  }
2546  return def;
2547  }
2548 
2549 private:
2550  a2dDrawingPart *m_drawingPart;
2551 };
2552 
2553 #endif //wxUSE_DRAG_AND_DROP
2554 
2555 
2556 #if wxUSE_PRINTING_ARCHITECTURE
2557 //! to print what is displayed on a a2dDrawingPart or the whole document as seen from the showobject of the drawer.
2558 /*!
2559  Internal a second wxDarwer class is initiated with a mapping that nicely fits that mapping of the input
2560  a2dDrawingPart to a piece of paper. This mapping depends on the type of print. If only what is on the view needs
2561  to be printed, the mapping of the input drawer is used, but if the whole document is wanted as seen
2562  from the ShowObject() of the input drawer, the boundingbox of the showobject will be used for the mapping.
2563 
2564 
2565  \ingroup docview
2566 */
2567 class A2DCANVASDLLEXP a2dDrawingPrintOut: public wxPrintout
2568 {
2569 public:
2570 
2571  //!initialize mapping based on an existing canvas
2572  /*!
2573  \param drawer the a2dDrawingPart from which the print is wanted.
2574 
2575  \param title title at top of the print
2576 
2577  \param filename the name of the file to be printed (may be empty )
2578 
2579  \param typeOfPrint When called from a2dDocumentCommandProcessor, the a2dCommand* which lead to this call.
2580 
2581  Depending on the command one can organize printing features.
2582  Like in the default implementation:
2583  \code
2584  a2dPrintWhat
2585  {
2586  Print,
2587  Preview,
2588  PrintView,
2589  PreviewView,
2590  PrintDocument,
2591  PreviewDocument,
2592  PrintSetup
2593  };
2594  \endcode
2595 
2596  Here View is to only print what is the visible view.
2597  Document print the document as seen from the
2598  a2dView::ShowObject(), it fits this to the paper.
2599 
2600  \param drawframe print a frame rectangle in bounding box of drawing/view
2601  \param scalelimit limits the scaling (world/pixel) to the given value, so that small graphics are not zoomed to full page
2602  \param fitToPage scale to fit the page
2603  */
2604  a2dDrawingPrintOut( const wxPageSetupDialogData& pageSetupData, a2dDrawingPart* drawingPart, const wxString& title, const wxString& filename, a2dPrintWhat typeOfPrint, bool drawframe, double scalelimit, bool fitToPage );
2605 
2606  //!destructor
2607  ~a2dDrawingPrintOut( void );
2608 
2609  //! if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
2610  static void SetPrintAsBitmap( bool printAsBitmap ) { m_printAsBitmap = printAsBitmap; }
2611 
2612  //! if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
2613  static bool GetPrintAsBitmap() { return m_printAsBitmap; }
2614 
2615  //! called for every page to print, for a2dDrawing in general just one.
2616  /*!
2617  It redraws/rerenders without double buffering the view or document on the pinter its wxDC.
2618  Internal a a2dDcDrawer is used to redraw the a2dDrawing on the device.
2619  */
2620  bool OnPrintPage( int );
2621 
2622  bool HasPage( int pageNum );
2623 
2624  bool OnBeginDocument( int startPage, int endPage );
2625 
2626  void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
2627 
2628 protected:
2629 
2630  const wxPageSetupDialogData& m_pageSetupData;
2631 
2632  //! type of print requested
2634 
2635  //! maping defined by this canvas
2637 
2638  //!title put above printout
2639  wxString m_title;
2640 
2641  //!filename put below printout
2642  wxString m_filename;
2643 
2644  //! limit scaling to this value (world/pixel)
2646 
2647  //! draw a frame around the page
2649 
2650  //! draw a view without real scale, the scaling in X and Y may differ.
2651  //! The drawing is adjusted in X and Y seperately to draw until the sides/border of the printer area
2653 
2654  //! if set print a bitmap that was drawn into
2655  static bool m_printAsBitmap;
2656 };
2657 #endif
2658 
2659 #endif /* __WXDRAWER_H__ */
2660 
2661 
2662 
Prevent cloning a a2dCameleon reference at a deeper level.
Definition: gen.h:1219
static const a2dCanvasObjectFlagsMask SELECTED2
Definition: candefs.h:181
void SetMappingUpp(double vx1, double vy1, double xpp, double ypp)
Give the virtual size to be displayed, the mapping matrix will be calculated.
Definition: drawer2d.cpp:250
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
double GetHeight() const
returns height of the boundingbox
Definition: bbox.cpp:334
bool m_gridlines
show grid as lines
Definition: drawer.h:1372
a2dTileBox is a subarea of a tile.
Definition: drawer.h:151
wxUint32 GetPreviousObjectCount()
get currently counted number of objects on this layer inside a document.
Definition: drawer.h:351
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
Prevent cloning a reference at a deeper level.
Definition: gen.h:1217
bool m_frozen
buffer updating activity possible or not
Definition: drawer.h:1279
a2dTiles m_tiles
tiles on drawing surface, used to optimize update areas.
Definition: drawer.h:1458
int m_crosshairLengthX
crosshair cursor Length in X in pixels
Definition: drawer.h:1315
void SetOverlayStroke(const a2dStroke &overlayStroke)
set a2dStroke to use when RenderFIX_STYLE is set.
Definition: drawer.h:869
void SetSelectStroke(const a2dStroke &selectStroke)
set a2dStroke to use when RenderWIREFRAME_SELECT or RenderWIREFRAME_SELECT_INVERT is set...
Definition: drawer.h:851
see a2dDrawingEvent
Definition: drawing.h:933
a2dFill m_gridfill
grid fill
Definition: drawer.h:1330
void SetSelectFill(const a2dFill &selectFill)
set a2dFill to use when RenderWIREFRAME_SELECT or RenderWIREFRAME_SELECT_INVERT is set...
Definition: drawer.h:848
Simple Memory manager for some objects which often create and destroy to replace OS-system calls...
Definition: a2dmemmgr.h:20
int m_y1
y1 in pixel coordinates
Definition: drawer.h:182
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
Definition: gen.cpp:1310
no special options
Definition: canobj.h:79
bool m_asrectangle
underneath the threshold draw rectangles.
Definition: drawer.h:1422
bool GetGridLines()
Get setting for grid to draw lines instead of points.
Definition: drawer.h:915
bool m_check
if true layer need to be check again document for availability.
Definition: drawer.h:377
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
Definition: canobj.h:500
void SetHighLight(const a2dFill &hightLightFill)
set a2dFill to use when RenderWIREFRAME_HighLight.
Definition: drawer.h:860
bool IsFrozen()
Returns if canvas is frozen.
Definition: drawer.h:928
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
wxUint16 m_gridsize
grid point size
Definition: drawer.h:1369
int m_mouse_x
last mouse position
Definition: drawer.h:1324
void SetValid(bool)
Definition: bbox.cpp:364
int m_x1
x1 in pixel coordinates
Definition: drawer.h:180
wxUint16 GetZoomOutBorder()
Definition: drawer.h:540
bool m_layeravailable
is the layer filled with primitives
Definition: drawer.h:374
wxUint32 m_documentDrawStyleRestore
to restore style after a temporary change.
Definition: drawer.h:1431
Ref Counted base object.
Definition: gen.h:1045
int GetWorldMouseY()
get mouse position Y in world coordinates
Definition: drawer.h:1208
a2dLayerViewList & GetLayerRenderArray()
get the layer render array
Definition: drawer.h:564
a2dCanvasObject * GetCaptured() const
are events redirected to a captured corridor? if so return the captured object in it...
Definition: drawer.h:641
void SetMappingDeviceRect(int mapx, int mapy, int mapWidth, int mapHeight, bool remap=false)
to change the default mapping (to the complete buffer).
Definition: drawer2d.cpp:216
void SetObjectCount(wxUint32 numberOfObjects)
set currently counted number of objects on this layer inside a document.
Definition: drawer.h:348
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
int m_crosshairx
crosshair x
Definition: drawer.h:1309
void SetPrintFilename(bool val)
If true render the printout with a filename string, otherwise not.
Definition: drawer.h:1189
int m_height
device size height
Definition: drawer.h:1387
bool m_crosshair
is croshair visible
Definition: drawer.h:1306
a2dStroke m_gridstroke
grid stroke
Definition: drawer.h:1327
bool GetReverseOrder() const
Get Setting for draw layers in reverse order.
Definition: drawer.h:589
int toP(int tilexy)
convert internal tile to pixel coordinate tiles area
Definition: drawer.h:233
This class implements drawing functions for wxDC based drawing.
Definition: dcdrawer.h:43
double m_gridx
grid distance in x
Definition: drawer.h:1363
record in update list of a2dDrawingPart.
Definition: drawer.h:64
a2dFill m_backgroundfill
background fill of canvas and background color of background fill in case of mono colour fill ...
Definition: drawer.h:1294
const a2dFill * a2dWHITE_FILL
global a2dFill stock object for WHITE filling
void SetBackgroundFill(const a2dFill &backgroundfill)
background fill for the canvas
Definition: drawer.cpp:3131
This class implements drawing functions for wxDC based drawing.
Definition: dcdrawer.h:203
void SetGrid(bool grid)
Set grid on/off.
Definition: drawer.h:905
A trivial base class for a2dSmrtPtr. Non-template class, so that it can.
Definition: smrtptr.h:55
a2dFill m_select2Fill
select style fill
Definition: drawer.h:1354
void SetFilename(const wxString filename, wxBitmapType type, bool doread=true)
set filename and type of image for saving.
Definition: canimage.cpp:249
int toT(int xy)
convert pixel to internal tile coordinate tiles area
Definition: drawer.h:236
void SetDocumentDrawStyle(wxUint32 drawstyle)
set drawstyles to use for drawing the document
Definition: drawer.cpp:1016
int ModT(int xy)
xy modules 256
Definition: drawer.h:239
bool m_valid
if set, true
Definition: drawer.h:177
void SetAvailable(bool status)
set layer available (will be rendered)
Definition: drawer.h:330
#define DECLARE_PROPERTIES()
check if class has the given id as a valid id for this object
Definition: gen.h:835
wxUint16 GetHitMarginDevice() const
Get HitMargin used to extend a hittest with the number of pixels.
Definition: drawer.h:600
int x1p()
get x1 in pixel coordinates
Definition: drawer.h:168
virtual void UpdateArea(int x, int y, int width, int height, wxUint8 id=0)
update/redraw part of the buffer, using the given a2dDrawing and ShowObject within that root...
Definition: drawer.cpp:1999
int GetCrossHairLengthX()
get crosshair cursor Length in X in pixels
Definition: drawer.h:827
int GetMouseY()
get mouse position Y
Definition: drawer.h:1203
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
static const a2dSignal sig_changedLayerVisibleInView
when one layer is set visible in a2dDrawingPart
Definition: drawer.h:1509
wxStringOutputStream a2dDocumentStringOutputStream
string output stream based wxStreams
Definition: gen.h:3454
a2dStroke m_overlayStroke
overlay style stroke
Definition: drawer.h:1339
wxString m_title
title put above printout
Definition: drawer.h:2639
void SetFixedStyleStroke(const a2dStroke &fixStroke)
set a2dStroke to use when RenderFIX_STYLE is set.
Definition: drawer.h:845
static bool m_printAsBitmap
if set print a bitmap that was drawn into
Definition: drawer.h:2655
a2dCanvas * GetCanvas() const
Get the Display window of the a2dView. But casted to a a2dCanvas.
Definition: drawer.h:525
int m_crosshairy
crosshair y
Definition: drawer.h:1312
bool m_printfittopage
If true, draw a view on all page without real scale.
Definition: drawer.h:1446
bool GetMouseEvents() const
return true if this a2dDrawingPart allows mouse events to be processed.
Definition: drawer.h:631
a2dStroke m_selectStroke
select style stroke
Definition: drawer.h:1345
defenitions an no more
double GetGridX()
Get grid distance in X.
Definition: drawer.h:893
int m_x2
x2 in pixel coordinates
Definition: drawer.h:184
int m_height
number of vertical tiles
Definition: drawer.h:274
wxUint32 m_documentDrawStyle
drawstyles to use when rendering document
Definition: drawer.h:1425
a2dCanvasObjectPtr m_top
top object for drawer object, from here the rendering starts
Definition: drawer.h:1291
a2dUpdateArea * m_rectPrevRow
prev row pointer to combine tiles into rectangles
Definition: drawer.h:189
bool m_drawframe
draw a frame around the page
Definition: drawer.h:2648
bool GetSelected() const
is the object selected flag set
Definition: canobj.h:1603
a2dLayerViewList m_layerRenderArray
which layer should be rendered ( visible and/or available )
Definition: drawer.h:1449
a2dStroke m_crosshairStroke
stroke to use for crosshair
Definition: drawer.h:1321
void SetGridSize(wxUint16 gridsize)
set size of grid circle
Definition: drawer.h:887
void SetGridThreshold(wxUint16 gridthres)
Definition: drawer.h:919
a2dPrintWhat m_typeOfPrint
type of print requested
Definition: drawer.h:2633
bool IsVisible() const
get visibility (rendering depends on layer settings also)
Definition: canobj.h:1316
a2dCanvasObjectPtr m_endCorridorObject
when a corridor is active, this is set.
Definition: drawer.h:1285
void SetCrossHairLengthX(int LengthX)
set crosshair cursor Length in X in pixels
Definition: drawer.h:821
bool GetGridAtFront()
Get grid setting for drawing grid in front or back.
Definition: drawer.h:881
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
Definition: candefs.h:152
void IncrementObjectCount()
increment currently counted number of objects on this layer inside a document.
Definition: drawer.h:357
virtual void OnPropertyChanged(const a2dPropertyId *id)
This function is called after a property changed.
Definition: gen.cpp:1635
void SetGridX(double gridx)
Set grid distance in X.
Definition: drawer.h:896
static const a2dSignal sig_changedLayerAvailable
when an object is added to a layer, and therefore makes this layer available.
Definition: drawer.h:1507
wxUint8 m_id
buffer id
Definition: drawer.h:99
a2dText is an abstract base class.
Definition: cantext.h:93
void SetGridAtFront(bool gridatfront)
Set grid setting for drawing grid in front or back.
Definition: drawer.h:878
bool m_showorigin
showorigin?
Definition: drawer.h:1300
see a2dCanvasObjectMouseEvent
Definition: canglob.h:161
bool DoRenderLayer()
should this layer be rendered
Definition: drawer.h:339
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
Definition: bbox.cpp:299
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
a2dDrawingPart * m_drawingPart
maping defined by this canvas
Definition: drawer.h:2636
bool m_mouseevents
enable/ disable mouse events handling by canvas
Definition: drawer.h:1288
static const a2dSignal sig_changedShowObject
Definition: drawer.h:1513
double m_scalelimit
limit scaling to this value (world/pixel)
Definition: drawer.h:2645
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
double GetGridY()
Get grid distance in Y.
Definition: drawer.h:899
int m_y2
y2 in pixel coordinates
Definition: drawer.h:186
int m_width
device size width
Definition: drawer.h:1384
double m_printscalelimit
Set the scaling limit for printing, so that small stuff is not zoomed to full page.
Definition: drawer.h:1440
bool GetGrid()
Get grid setting on/off.
Definition: drawer.h:908
wxUint16 a2dPrintWhat
defines what to print
Definition: gen.h:4052
The a2dStToolContr is a Tool Controller specialized for working with a2dCanvasView.
Definition: sttool.h:485
a2dHitOption
Enum for hit test options.
Definition: canobj.h:76
int m_width
number of horizontal tiles
Definition: drawer.h:272
void SetFixedStyleFill(const a2dFill &fixFill)
set a2dFill to use when RenderFIX_STYLE is set.
Definition: drawer.h:842
void SetAvailable()
check which layers do contain objects as seen from the ShowObject()
Definition: drawer.cpp:1641
int GetCrossHairLengthY()
get crosshair cursor Length in Y in pixels
Definition: drawer.h:830
Drawing context abstraction.
Definition: drawer2d.h:177
void * Allocate(size_t bytes)
function for allocating memory block by size bytes
Definition: a2dmemmgr.cpp:47
maintains a list of areas on a view to be redrawn.
Definition: drawer.h:111
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Definition: drawer.h:680
bool m_grid
grid on/off
Definition: drawer.h:1378
a2dImage (will scale/rotate image when needed)
Definition: canimage.h:33
void SetPrintScaleLimit(double val)
Set the scaling limit for printing, so that small stuff is not zoomed to full page.
Definition: drawer.h:1192
int m_crosshairLengthY
crosshair cursor Length in Y in pixels
Definition: drawer.h:1318
int y2p()
get y2 in pixel coordinates
Definition: drawer.h:174
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
Definition: canobj.h:569
wxStringInputStream a2dDocumentStringInputStream
string input stream based wxStreams
Definition: gen.h:3452
static void SetPrintAsBitmap(bool printAsBitmap)
if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
Definition: drawer.h:2610
Contains graphical drawing context specific classes. a2dDcDrawer and derived classes are used for dra...
a2dUpdateList m_updateareas
list of rectangles that need to be blited to the screen.
Definition: drawer.h:1403
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
Definition: drawer.h:1125
static const a2dCanvasObjectFlagsMask SELECTED
Definition: candefs.h:180
void SetVisible(bool status)
set layer visible
Definition: drawer.h:324
wxUint16 m_gridthres
threshold for grid.
Definition: drawer.h:1375
a2dStroke m_fixStroke
fixed style stroke
Definition: drawer.h:1333
Contains a2dDrawing Class to hold a drawing.
a2dFill m_selectFill
select style fill
Definition: drawer.h:1348
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument
Definition: algos.h:486
This tool is for editing a single object.
Definition: edit.h:73
int GetWorldMouseX()
get mouse position X in world coordinates
Definition: drawer.h:1206
wxUint16 m_border
border zoomout but leaf around a border of this amount of pixels.
Definition: drawer.h:1297
corridor as a direct event path to a a2dCanvasObject
Definition: objlist.h:313
bool GetVisible()
is the layer visible
Definition: drawer.h:321
a2dCanvasObject * GetEndCorridorObject() const
return the corridor object if set else NULL
Definition: drawer.h:654
double m_gridy
grid distance in y
Definition: drawer.h:1366
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
bool GetCrossHair()
get enable crosshair cursor
Definition: drawer.h:818
static bool GetPrintAsBitmap()
if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
Definition: drawer.h:2613
a2dCanvas is used to display one of the a2dCanvasObjects which are part of a a2dCanvasDocument object...
Definition: canvas.h:68
void Set_UpdateAvailableLayers(bool value)
Sets a flag for updating available layers checking, which makes sure layers will be checked first whe...
Definition: drawer.h:583
bool HasPopOut() const
is there structure to popout (see PushIn )
Definition: drawer.h:695
a2dDocumentRenderStyle m_overlayDrawStyle
drawstyles to use when rendering overlay
Definition: drawer.h:1428
a storage for a a tiled area
Definition: drawer.h:206
bool m_reverse_order
draw in reverse order if set
Definition: drawer.h:1463
Contains graphical drawing context specific classes. a2dDrawer2D and derived classes are used for dra...
static const a2dSignal sig_changedLayers
when more layers changed ( rerendering view is needed).
Definition: drawer.h:1505
a2dStroke & GetCrossHairStroke()
get stroke for crosshair
Definition: drawer.h:836
vector< a2dTileBox > m_tiles
array of tiles ( normally m_width * m_height )
Definition: drawer.h:284
bool Get_UpdateAvailableLayers() const
update layers available needed?
Definition: drawer.h:570
a2dWalker based algorithms
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
void SetSelect2Stroke(const a2dStroke &select2Stroke)
set a2dStroke to use when RenderWIREFRAME_SELECT2 or RenderWIREFRAME_SELECT2_INVERT is set...
Definition: drawer.h:857
void MapBbox(const a2dAffineMatrix &matrix)
Definition: bbox.cpp:445
void Aberration(double aber, double angle, double radius, double &dphi, unsigned int &segments)
calculate number of segments in an arc such that a certain accuracy is maintained ...
Definition: artglob.cpp:67
void SetGridY(double gridy)
Set grid distance in Y.
Definition: drawer.h:902
bool GetViewDependentObjects() const
see SetViewDependentObjects()
Definition: drawer.h:561
void SetPreviousObjectCount(wxUint32 numberOfObjects)
set currently counted number of objects on this layer inside a document.
Definition: drawer.h:354
a2dSmrtPtr< a2dToolContr > m_toolcontroller
toolscontroller plugged in as first event handler
Definition: drawer.h:1409
bool GetCheck()
check this layer?
Definition: drawer.h:333
void SetViewDependentObjects(bool viewDependentObjects)
if set true, drawing can contain objects that depend on this view (size etc).
Definition: drawer.h:558
void SetText(const wxString &text)
set the text for the object &#39; &#39; in string means new line
Definition: cantext.h:165
double m_displayaberration
accuracy of arc segment calculation etc. in device coordinates
Definition: drawer.h:1396
bool GetRelease() const
get release flag
Definition: gen.h:1350
editing tool for a2dCanvasObject&#39;s
void RestoreDrawStyle()
restore drawstyle to the one before the last change
Definition: drawer.h:1138
int x2p()
get x2 in pixel coordinates
Definition: drawer.h:172
wxUint32 m_canvasObjectCount
Definition: drawer.h:366
This is the base class for all kinds of property id&#39;s for a2dObject.
Definition: id.h:154
double GetWidth() const
returns width of the boundingbox
Definition: bbox.cpp:328
a2dCanvasObject * SetShowObject(const wxString &name)
set object available in the a2dDrawing to be shown on the drawer
Definition: drawer.cpp:2947
a2dBaseTool * GetFirstTool() const
get currently used eventhandler (always the first in the list)
Definition: tools.cpp:91
wxUint16 m_hitmargin
how close does a hit need to be to the object you are trying to hit.
Definition: drawer.h:1419
void SetPrintFrame(bool val)
If true, draw a frame around printouts.
Definition: drawer.h:1195
void SetPrintFitToPage(bool val)
If true, draw a view on all page without real scale.
Definition: drawer.h:1198
bool m_printtitle
if true, a printout is done with title (document name (description?)), otherwise not ...
Definition: drawer.h:1434
bool GetAvailable()
are the objects on this layer
Definition: drawer.h:327
void SetSelect2Fill(const a2dFill &select2Fill)
set a2dFill to use when RenderWIREFRAME_SELECT2 or RenderWIREFRAME_SELECT2_INVERT is set...
Definition: drawer.h:854
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
Used by a2dDrawingPart to decide what layers are to be rendered.
Definition: drawer.h:303
void SetToolWantsEventToContinue(bool continueEvent=true)
if tool want an event to be handled by the view, even if already processed.
Definition: drawer.h:1219
bool m_gridatfront
grid drawn at front or back
Definition: drawer.h:1303
see a2dComEvent
Definition: gen.h:371
wxUint16 GetGridThreshold()
Get grid threshold.
Definition: drawer.h:922
wxString m_filename
filename put below printout
Definition: drawer.h:2642
bool m_printfilename
if true, a printout is done with filename (document file path), otherwise not
Definition: drawer.h:1437
base classes for tools and controller on top of the tools.
bool m_recur
to prevent recursive updates
Definition: drawer.h:1406
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
bool Invert(void)
Invert matrix.
Definition: afmatrix.cpp:197
void SetCheck(bool status)
set the layer to be checked in idle time.
Definition: drawer.h:336
a2dTileBox tile(int i)
get tile at index i
Definition: drawer.h:277
bool m_layervisible
is the layer visible
Definition: drawer.h:371
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
void SetZoomOutBorder(wxUint16 border)
zoomout leafs a border of this amount of pixels around the drawing
Definition: drawer.h:537
void DecrementObjectCount()
decrement currently counted number of objects on this layer inside a document.
Definition: drawer.h:360
void SetHighLight(const a2dStroke &hightLightStroke)
set a2dStroke to use when RenderWIREFRAME_HighLight.
Definition: drawer.h:863
a2dClipRegionList m_clipregionlist
pushed clipping regions
Definition: drawer.h:1393
a2dFill m_highLightFill
highLight style fill
Definition: drawer.h:1360
void SetCaptured(a2dCanvasObject *captured)
set the object that is captured for events in the a2dDrawing.
Definition: drawer.h:638
void SetHitMargin(wxUint16 pixels)
used to extend a hittest with the number of pixels.
Definition: drawer.h:597
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
a2dStroke m_select2Stroke
select style stroke
Definition: drawer.h:1351
The a2dToolContr is the base class for Tool controller classes.
Definition: tools.h:87
This template class is for property ids with a known data type.
Definition: id.h:477
wxUint32 GetDocumentDrawStyle()
get drawstyles used for drawing the document
Definition: drawer.h:1141
int GetMouseX()
get mouse position X
Definition: drawer.h:1201
void SetGridLines(bool gridlines)
Get grid setting for line drawing.
Definition: drawer.h:912
bool m_update_available_layers
flag to updatelayers that are available.
Definition: drawer.h:1455
void SetShowOrigin(bool show)
Set showorigin on/off.
Definition: drawer.h:925
void SetDrawer2D(a2dDrawer2D *drawer2d, bool noDelete=false)
set the internal m_drawer2D to be used for rendering the document
Definition: drawer.cpp:765
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
a2dStroke m_highLightStroke
highLight style stroke
Definition: drawer.h:1357
void SetCrossHairLengthY(int LengthY)
set crosshair cursor Length in Y in pixels
Definition: drawer.h:824
bool m_virtualarea_set
is the virtual area set already (used during startup)
Definition: drawer.h:1381
wxUint32 GetObjectCount()
get currently counted number of objects on this layer inside a document.
Definition: drawer.h:345
double m_splineaberration
accuracy of spline
Definition: drawer.h:1390
a2dDocumentRenderStyle
Define the manner in which a2dCanvasView draws the document to the device.
Definition: candefs.h:84
to print what is displayed on a a2dDrawingPart or the whole document as seen from the showobject of t...
Definition: drawer.h:2567
wxString GetText() const
get the text of the object &#39; &#39; in string means new line
Definition: cantext.h:168
a2dFill m_fixFill
fixed style fill
Definition: drawer.h:1336
bool m_printframe
If true, draw a frame around printouts.
Definition: drawer.h:1443
a2dCanvasObjectPtr m_capture
object that is receiving events
Definition: drawer.h:1282
a2dText * GetTextTemplateObject()
set template for line object
Definition: canglob.h:920
CloneOptions
options for cloning
Definition: gen.h:1200
int y1p()
get y1 in pixel coordinates
Definition: drawer.h:170
void SetOverlayFill(const a2dFill &overlayFill)
set a2dFill to use when RenderFIX_STYLE is set.
Definition: drawer.h:866
a2dFill & GetBackgroundFill()
get current background fill for the canvas
Definition: drawer.h:875
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Definition: canobj.cpp:3175
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
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
a2dFill m_overlayFill
overlay style fill
Definition: drawer.h:1342
a2dLayerView()
constructor
Definition: drawer.h:309
void SetPrintTitle(bool val)
If true render the printout with a title string, otherwise not.
Definition: drawer.h:1186
static void SetIgnoreAllSetpending(bool value=true)
set static IgnoreAllSetpending flag
Definition: canobj.h:2307
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
drawer.h Source File -- Sun Oct 12 2014 17:04:16 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation