wxArt2D
candoc.h
1 /*! \file wx/canvas/candoc.h
2  \brief Contains a2dCanvasDocument Class to hold a drawing.
3 
4  a2dCanvasDocument is the class where a hierarchy of a2dCanvasObject's is stored.
5  Updating pending/changed objects and drawing a document is all from this class.
6 
7  \author Klaas Holwerda
8 
9  Copyright: 2000-2004 (c) Klaas Holwerda
10 
11  Licence: wxWidgets Licence
12 
13  RCS-ID: $Id: candoc.h,v 1.31 2009/07/10 19:23:13 titato Exp $
14 */
15 
16 #ifndef __WXCANDOC_H__
17 #define __WXCANDOC_H__
18 
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22 
23 #include "wx/image.h"
24 #include "a2dprivate.h"
25 
26 #include "wx/docview/docviewref.h"
27 
28 #include "wx/canvas/canobj.h"
29 #include "wx/canvas/vpath.h"
30 #include "wx/canvas/canprim.h"
31 #include "wx/canvas/polygon.h"
32 #include "wx/canvas/objlist.h"
33 #include "wx/canvas/recur.h"
34 #include "wx/canvas/canvas.h"
35 #include "wx/canvas/drawing.h"
36 
37 #include "wx/canvas/canprop.h"
38 
39 #if wxART2D_USE_SVGIO
40 #include "wx/svgio/parssvg.h"
41 #endif //wxART2D_USE_SVGIO
42 
43 #if wxART2D_USE_GDSIO
44 #include "wx/gdsio/gdsio.h"
45 #include "wx/gdsio/gdserr.h"
46 #endif //wxART2D_USE_GDSIO
47 
49 class a2dIOHandlerCVGIn;
50 class a2dIOHandlerCVGOut;
51 class a2dCameleon;
52 
53 //----------------------------------------------------------------------------
54 // decls
55 //----------------------------------------------------------------------------
56 
57 class A2DEDITORDLLEXP a2dViewPrintout;
58 class A2DEDITORDLLEXP a2dCanvasView;
59 
60 #if wxUSE_PRINTING_ARCHITECTURE
61 //! to print what is displayed on a a2dCanvasView or the whole document as seen from the showobject of the drawer.
62 /*!
63  Internal a second wxDarwer class is initiated with a mapping that nicely fits that mapping of the input
64  a2dCanvasView to a piece of paper. This mapping depends on the type of print. If only what is on the view needs
65  to be printed, the mapping of the input drawer is used, but if the whole document is wanted as seen
66  from the ShowObject() of the input drawer, the boundingbox of the showobject will be used for the mapping.
67 
68 
69  \ingroup docview
70 */
71 class A2DEDITORDLLEXP a2dViewPrintout: public a2dDocumentPrintout
72 {
73 public:
74 
75  //!initialize mapping based on an existing canvas
76  /*!
77  \param drawer the a2dCanvasView from which the print is wanted.
78 
79  \param title title at top of the print
80 
81  \param filename the name of the file to be printed (may be empty )
82 
83  \param typeOfPrint When called from a2dDocumentCommandProcessor, the a2dCommand* which lead to this call.
84 
85  Depending on the command one can organize printing features.
86  Like in the default implementation:
87  \code
88  a2dPrintWhat
89  {
90  Print,
91  Preview,
92  PrintView,
93  PreviewView,
94  PrintDocument,
95  PreviewDocument,
96  PrintSetup
97  };
98  \endcode
99 
100  Here View is to only print what is the visible view.
101  Document print the document as seen from the
102  a2dView::ShowObject(), it fits this to the paper.
103 
104  \param drawframe print a frame rectangle in bounding box of drawing/view
105  \param scalelimit limits the scaling (world/pixel) to the given value, so that small graphics are not zoomed to full page
106  \param fitToPage scale to fit the page
107  */
108  a2dViewPrintout( const wxPageSetupDialogData& pageSetupData, a2dCanvasView* drawer, const wxString& title, const wxString& filename, a2dPrintWhat typeOfPrint, bool drawframe, double scalelimit, bool fitToPage );
109 
110  //!destructor
111  ~a2dViewPrintout( void );
112 
113  //! if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
114  static void SetPrintAsBitmap( bool printAsBitmap ) { m_printAsBitmap = printAsBitmap; }
115 
116  //! if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
117  static bool GetPrintAsBitmap() { return m_printAsBitmap; }
118 
119  //! called for every page to print, for a2dCanvasDocument in general just one.
120  /*!
121  It redraws/rerenders without double buffering the view or document on the pinter its wxDC.
122  Internal a a2dDcDrawer is used to redraw the a2dCanvasDocument on the device.
123  */
124  bool OnPrintPage( int );
125 
126 protected:
127 
128  const wxPageSetupDialogData& m_pageSetupData;
129 
130  //! type of print requested
132 
133  //! maping defined by this canvas
135 
136  //!title put above printout
137  wxString m_title;
138 
139  //!filename put below printout
140  wxString m_filename;
141 
142  //! limit scaling to this value (world/pixel)
143  double m_scalelimit;
144 
145  //! draw a frame around the page
147 
148  //! draw a view without real scale, the scaling in X and Y may differ.
149  //! The drawing is adjusted in X and Y seperately to draw until the sides/border of the printer area
151 
152  //! if set print a bitmap that was drawn into
153  static bool m_printAsBitmap;
154 };
155 #endif
156 
157 //! view to display the size of a2dCanvasView compared to the whole of the a2dCanvasDocument that is viewed.
158 /*!
159  \ingroup docview
160 */
161 class A2DEDITORDLLEXP a2dZoomedView: public wxWindow
162 {
163  DECLARE_EVENT_TABLE()
164 
165 public:
166 
167  //! constructor
168  a2dZoomedView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, a2dCanvasView* canvasview );
169 
170  //!destructor
171  virtual ~a2dZoomedView();
172 
173 protected:
174 
175  //! called for a2dComEvent events.
176  void OnComEvent( a2dComEvent& event );
177 
178  //! \cond
179 
180  void OnUpdate( a2dDocumentEvent& event );
181 
182  //! repaint damaged araes.
183  void OnPaint( wxPaintEvent& event );
184 
185  void OnRemoveView( a2dDocumentEvent& event );
186 
187  //! resize
188  void OnSize( wxSizeEvent& event );
189 
190  //! \endcond
191 
192  //! the view to view zoomed
194 
195  DECLARE_CLASS( a2dZoomedView )
196 
197 private:
198 
199 
200 };
201 
202 
203 
204 //! View on a a2dCanvasDocument
205 /*!
206  a2dCanvasView is a specialized view as connecting class to a2dCanvas via a2dViewCanvas.
207  a2DrawingPart eventually display a part of a2dDrawing in a2dCanvas. This a2dDrawing is part of a a2dCanvasDocument.
208  a2dCanvasDocument can contain a hierarchy of drawings.
209  It depends on the a2dCanvas created by this view or via a derived a2dViewConnector class, what part of a drawing
210  and which drawing is displayed.
211 */
212 class A2DEDITORDLLEXP a2dCanvasView: public a2dView
213 {
214 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
215  a2dInitCurrentSmartPointerOwner m_initCurrentSmartPointerOwner;
216 #endif
217  DECLARE_EVENT_TABLE()
218 
219 public:
220 
221 
222  //!constructor
223  /*!
224  \remark
225  Do not forget to call SetDocument() if used standalone
226  (in a a2dDocumentCommandProcessor setting this is taken care of).
227  */
228  a2dCanvasView( int width = 1000, int height = 1000 );
229 
230 
231  //!constructor
232  /*!
233  \remark
234  Do not forget to call SetDocument() if used standalone
235  (in a a2dDocumentCommandProcessor setting this is taken care of)
236  */
237  a2dCanvasView( const wxSize& size );
238 
239  //!copy constructor
240  a2dCanvasView( const a2dCanvasView& other );
241 
242  //! Get the Display window of the a2dView. But casted to a a2dCanvas
243  /*! when a a2dCanvas is used in this a2dCanvasView return it else 0.
244  a2dCanvasView needs to know the window (a2dCanvas) to display somethinf of the a2dCanvasDocument.
245 
246  \sa a2dView::SetDisplayWindow()
247  */
248  a2dCanvas* GetCanvas() const;
249 
250  a2dCanvasDocument* GetCanvasDocument() const;
251 
252  //!destructor
253  virtual ~a2dCanvasView();
254 
255  a2dDrawingPart* GetDrawingPart() const;
256 
257  //! Special event handling for a2dCanvasView class
258  /*!
259  Redirects events to the a2dViewCanvas.
260  */
261  virtual bool ProcessEvent( wxEvent& event );
262 
263  void OnCreateView( a2dViewEvent& event );
264 
265 #if wxUSE_PRINTING_ARCHITECTURE
266  //! to create a a2dViewPrintout, used to print a view or its document
267  /*!
268  The a2dViewPrintout created will take as much possible from the this view.
269  a2dViewPrintout will create itself a view which fits the size of the paper, but important setting are taken from this view.
270  */
271  virtual wxPrintout* OnCreatePrintout( a2dPrintWhat typeOfPrint, const wxPageSetupDialogData& pageSetupData );
272 #endif
273 
274 
275  //! Not implemented, use a2dViewPrintout to print
276  /*!
277  OnDraw is called when printing a view via wxView::OnPrint with wxDocPrintout::OnPrintPage.
278  But for a2dCanvasView, i implemented it in a2dViewPrintout::OnPrintPage.
279 
280  This funcion is and should NOT be used to Redraw the a2dCanvasView views, this is taken care of automatically,
281  and if needed can be forced with OnUpdate or Update.
282  Paint events are intercepted to blit damaged parts caused by overlaping windows,
283  and in Idle time changes or updated in a2dCanvasView.
284  */
285  virtual void OnDraw( wxDC* );
286 
287  //! If true render the printout with a title string, otherwise not
288  void SetPrintTitle( bool val ) { m_printtitle = val; }
289 
290  //! If true render the printout with a filename string, otherwise not
291  void SetPrintFilename( bool val ) { m_printfilename = val; }
292 
293  //! Set the scaling limit for printing, so that small stuff is not zoomed to full page
294  void SetPrintScaleLimit( double val ) { m_printscalelimit = val; }
295 
296  //! If true, draw a frame around printouts
297  void SetPrintFrame( bool val ) { m_printframe = val; }
298 
299  //! If true, draw a view on all page without real scale
300  void SetPrintFitToPage( bool val ) { m_printfittopage = val; }
301 
302 protected:
303 
304  //! if true, a printout is done with title (document name (description?)), otherwise not
306 
307  //! if true, a printout is done with filename (document file path), otherwise not
309 
310  //! Set the scaling limit for printing, so that small stuff is not zoomed to full page
312 
313  //! If true, draw a frame around printouts
315 
316  //! If true, draw a view on all page without real scale
318 
319 public:
320 
321  DECLARE_DYNAMIC_CLASS( a2dCanvasView )
322 
323 private:
324 
325  //initialize a drawer
326  void Init();
327 
328 private:
329  virtual a2dObject* DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const { return NULL; }
330 };
331 
332 typedef wxUint16 a2dDrawingId;
333 
334 //!Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data.
335 /*!
336  Several a2dCanvasView objects can share the same a2dCanvasDocument.
337  The a2dCanvasDocument has one top a2dCanvasObject, called m_drawing.
338  All other a2dCanvasObject's are added as children to this root object.
339  The docuemnt also contains the layer settings for the canvas objects to be rendered.
340  The a2dCanvasDocument is derived from a2dDocument, and it is used to store a hierarchy of a2dCanvasObject's.
341  The updating of modified a2dCanvasObject's is also organized as part of this class. One can load a canvas document from
342  a file, and save it to a file, in the CVG format. But other formats are possible, via the document its a2dDocumentTemplate and
343  associated a2dIOHandlers.
344 
345  Rendering a a2dCanvasDocument is started at a given a2dCanvasObject,
346  which needs to be part of the data structure below the a2dCanvasDocument.
347  Since a2dCanvasDocument owns a a2dCanvasObject as root, rendering the complete document will start at the m_drawing.
348  But any nested child a2dCanvasObject can be used to start rendering, and only that object and it children will be displayed
349  on the a2dCanvasView ( and a2dCanvas which is the display window ).
350  The a2dCanvasObject to be displayed on a certain a2dCanvasView is maintained in the
351  a2dCanvasView object. It can be different for all a2dCanvasView objects sharing the same a2dCanvasDocument.
352 
353  a2dCanvasDocument senets update events when a2dCanvasObject have changed internal. The a2dView's using the document
354  are intercepting the update events, and react by updating the data that they display. For a a2dCanvasView this means
355  redrawing those parts that have changed.
356 
357  Any nested child from a a2dCanvasDocument Object can be displayed on several a2dCanvasView Objects at the same time.
358  The child displayed does not have to be the same on each a2dCanvasView.
359  The active a2dCanvasView is used to render and convert coordinates from world to device.
360  So it is important to set the active a2dCanvasView based on the a2dCanvasView that has the focus
361  or is scrolled etc. This is normally done within a2dCanvasView when appropriate.
362 
363 
364  \remark Use a2dDocumentTemplate's to get the type of the file, where this data was read from.
365  based on this the document can be saved in the same type as read from.
366 
367 \sa a2dCanvasView
368 \sa a2dCanvas
369 \sa wxWorldCanvas
370 \sa a2dCanvasObject
371 
372  \ingroup docview canvasobject
373 */
374 class A2DEDITORDLLEXP a2dCanvasDocument : public a2dDocument
375 {
376 public:
377 
378  //!Construct a a2dCanvasDocument to store a complete drawing in
379  /*!
380  This class contains nested a2dCanvasObject's and other drawing object derived from a2dCanvasObject's.
381  The class itself is derived from a2dDocument.
382  All objects are stored are as childs of the m_drawing.
383  A complete drawing is stored here, and displaying the drawing, is done by setting a pointer to this a2dCanvasDocument
384  for a a2dCanvasView derived class.
385  Every change inside the wxCavasObject's stored inside this class, will report themselfs as pending to an instance
386  of this class.
387  The a2dCanvasView classes, having this instance of a2dCanvasDocument set, will be updated from the document via update events.
388  a2dCanvasObject that are changed or set pending. Those pending objects are reported to the document also. In Idle time the pending
389  objects are redrawn on the a2dCanvasView's that display the document.
390  The same a2dCanvasDocument can be displayed on reveral a2dCanvasView's at the same time.
391  And therefore a pending a2dCanvasObject maybe be (re)displayed on several a2dCanvasView's also.
392  The a2dCanvasObjects stored in a a2dCanvasDocument, will have their m_root member set in order to get to the a2dCanvasDocument
393  in which they are stored. Through the a2dCanvasDocument they will be able to reach the a2dCanvasView class that is currently active.
394  The a2dCanvasView class is set to the document when needed on a higher level. e.g. when rendering a a2dCanvasDocument.
395  This way each a2dCanvasObject stored inside the a2dCanvasDocument, can draw itself on the active a2dCanvasView.
396  The a2dCanvasView in this case can be seen as a sort of drawing context.
397  Indirectly a a2dCanvasView can use a2dCanvas as the window/device to draw up on.
398  Another type of a2dCanvasView can draw to a bitmap, image or printer device.
399 
400  \remark The initially layer setup is defined my a2dCanvasGlobal::GetLayerSetup
401 
402  \see SetLayerSetup for an example for introduce your own layers
403  */
405 
406  //! destructor
408 
409  //! like it to be protected, but this does not work with wxList macros
410  //void operator delete(void* recordptr);
411 
412  //! constructor with other document
413  a2dCanvasDocument( const a2dCanvasDocument& other );
414 
415  void CreateCommandProcessor();
416 
417  //! get the root object, which holds the objects in the document.
418  inline a2dDrawing* GetDrawing() const { return m_drawing; }
419 
420  //! set new root object ( may not ne NULL )
421  void SetDrawing( a2dDrawing* newRoot );
422 
423  //! Sets a description of the document
424  /*!
425  A description may describe the content of this document or contain keywords etc.
426  The default value is "a2dCanvasDocument generated by wxArt2D".
427 
428  \param desc description of the document
429  */
430  void SetDescription( const wxString& desc ) { m_description = desc; }
431 
432  //! Returns the description of the document
433  /*!
434  \see SetDescription
435 
436  \return the description
437  */
438  wxString& GetDescription() { return m_description; }
439 
440  //! to name the document as a library (independent of a path and filename )
441  void SetLibraryName( const wxString& libraryname ) { m_libraryname = libraryname; }
442 
443  //! Get name the document as a library (independent of a path and filename )
444  wxString& GetLibraryName() { return m_libraryname; }
445 
446  //! set version of library or document
447  void SetVersion( wxString version ) { m_version = version; }
448 
449  //! get version of library or document
450  wxString GetVersion() { return m_version; }
451 
452  //! delete all object in this document (also nested groups etc.)
453  virtual void DeleteContents();
454 
455  //!write as SVG to a file starting at given object
456  /*!
457  \param drawer drawing view context
458  \param filename filename of stream to write the SVG content to.
459  \param top start writting at this object.
460  \param Width width in unit will be the physical width of the drawing.
461  \param Height height in unit will be the physical height of the drawing.
462  \param unit Unit of width and height e.g. "cm" "um".
463  */
464  bool WriteSVG( a2dCanvasView* drawer, const wxString& filename, a2dCanvasObject* top, double Width, double Height, wxString unit );
465 
466  //!load form a file containing the a2dCanvas specific XML called CVG format
467  virtual a2dDocumentInputStream& LoadObject( a2dDocumentInputStream& stream, a2dIOHandlerStrIn* handler );
468 
469 #if wxART2D_USE_CVGIO
470  //! used by CVG parser
471  /*!
472  \remark do not use directly
473  */
474  void Load( wxObject* parent, a2dIOHandlerXmlSerIn& parser );
475 #endif //wxART2D_USE_CVGIO
476 
477  //! load document from a file with the given filename and given parser type
478  bool Load( const wxString& filename, a2dIOHandlerStrIn* handler );
479 
480  //! save layer settings to CVG file
481  bool SaveLayers( const wxString& filename );
482 
483  //! load layers from another file
484  /*!
485  Only the layer settings are read from the file and put in place of the
486  current layers settings in the document.
487  */
488  bool LoadLayers( const wxString& filename );
489 
490  //! Update a loaded layer setup
491  /*! This is called after loading a layer setup. The base class function does
492  nothing. It is usefull to override this to update a loaded layer setup to
493  e.g. a new software version */
494  virtual void UpdateLoadedLayerSetup();
495 
496  //!save as the a2dCanvas specific XML called CVG format
497  a2dDocumentOutputStream& SaveObject( a2dDocumentOutputStream& stream, a2dIOHandlerStrOut* handler );
498 
499 #if wxART2D_USE_CVGIO
500  void Save( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dObjectList* towrite );
501 
502  //! called from a2dIOHandlerCVGOut after a SaveObject.
503  /*!
504  \param out CVG io handler
505  \param start start wrting from this object
506  */
507  void Save( a2dIOHandlerCVGOut& out, a2dCanvasObject* start = 0 );
508 #endif //wxART2D_USE_CVGIO
509 
510  //! save document to a file with the given name and given output writer type
511  bool Save( const wxString& filename, a2dIOHandlerStrOut* handler ) const;
512 
513  //! update all pending objects in the document
514  /*
515  At the minumum all boudingboxes are brought up to date, and if a layersetup is set,
516  in the end all layers used in the document are known.
517 
518  This function is part of the update cycle e.g. in AddPendingUpdatesOldNew()
519  */
520  void Update( a2dCanvasObject::UpdateMode mode );
521 
522  //!set the layersettings for the canvas.
523  /*!
524  A default Layer Setting is created in the constructor a2dCanvasDocument::a2dCanvasDocument
525 
526  An example how to set another layer setup
527  \code
528  // Clone the current layer setup
529  a2dLayers* docLayers = doc->GetLayerSetup()->Clone( bool deep = true );
530 
531  // Create a new layer with an index above the predefined layers
532  a2dLayerInfo* lr = new a2dLayerInfo(wxLAYER_USER_FIRST, "MyLayer");
533 
534  // Set layer available
535  lr->Set_Available(true);
536 
537  // Add layer to to the a2dLayers
538  docLayers->Append(lr);
539 
540  doc->SetLayerSetup(docLayers);
541  \endcode
542 
543  \remark
544  You don't have to call Set_UpdateAvailableLayers it will be done automatically
545 
546  \param layersetup the new layersetup
547  */
548  void SetLayerSetup( a2dLayers* layersetup );
549 
550  //!Get the layersettings for the canvas.
551  /*!
552  A default Layer Setting is taken from a2dCanvasGlobal.
553  \sa a2dCanvasGlobal for central layers settings, used for initializing a a2dCanvasDocument
554  */
555  a2dLayers* GetLayerSetup() { return m_layersetup; }
556 
557  //!Set true if the document read from a file did not have on erootobject but several
558  /*!
559  Some formats as GDS-II and KEY, can contain many structure, which are not placed in
560  a single parent object. Still in a a2dCanvasDocument they will be placed in the m_drawing.
561  This flag can be used when writing the data back in the same way, skipping the rootobject if possible.
562  */
563  void SetMultiRoot( bool multiRoot = true ) { m_multiRoot = multiRoot; }
564 
565  //! \see SetMultiRoot()
566  bool GetMultiRoot() { return m_multiRoot; }
567 
568  //! what is the top a2dcameleon in the drawing to display after opening a document, when m_show is not set.
569  a2dCameleon* GetTopCameleon() { return m_main; }
570  //! what is the top a2dcameleon in the drawing to display after opening a document, when m_show is not set.
571  void SetTopCameleon( a2dCameleon* root ) { m_main = root; }
572 
573  //! what to display when document is openened
574  a2dCanvasObject* GetShowObject() { return m_show; }
575  //! what to display when document is openened
576  void SetShowObject( a2dCanvasObject* show ) { m_show = show; }
577 
578  //!this is the number that defines the number of decimal places in the fraction
579  /*!when writing numbers to a file.
580  When reading a file, this number is set to the accuracy information available in the file.
581  1/GetUnitsAccuracy() == 100 means 2 decimal places will be written, or the data just
582  read is accurate to this number of decimal places.
583 
584  \remark GetUnitsAccuracy() can also be > 1
585  */
586  double GetUnitsAccuracy() { return m_units_accuracy; }
587 
588  //!this is the number that defines the number of decimal places in the fraction
589  /*!when writing numbers to a file.
590  When reading a file, this number is set to the accuracy information available in the file.
591  1/GetAccuracyUserUnits() == 100 means 2 decimal places will be written, or the data just
592  read is accurate to this number of decimal places.
593  \remark SetUnitsAccuracy() can also be > 1
594  */
595  void SetUnitsAccuracy( double accuracy ) { m_units_accuracy = accuracy; }
596 
597  //!this is the number that defines the physical dimension in meters / inch/ etc.
598  /*! numbers used for storing length or position or always stored as doubles.
599  The real dimension is: (anynumber) * GetUnitsScale() * GetUnits()
600  */
601  double GetUnitsScale() { return m_units_scale; }
602 
603 
604  //!this is the number that defines the physical dimension in meters / inch/ etc.
605  /*! numbers used for storing length or position or always stored as doubles.
606  The real dimension is: (anynumber) * GetUnitsScale() * GetUnits()
607  */
608  void SetUnitsScale( double scale ) { m_units_scale = scale; }
609 
610  //! Normalize objects ( defined in coordinates -1 to 1 ranges ) will be multiplied by this factor.
611  /*!
612  Libraries containing object which are defined in normalized coordinates,
613  need to be multiplied by a certain factor before they can be added to a document.
614  This factor defines by how much that should be done.
615  As an example a libary containing arrow objects for placing at the end of a2dEndsLine
616  objects, will use this factor.
617  */
618  double GetNormalizeScale() { return m_normalize_scale; }
619 
620  //! see GetNormalizeScale()
621  void SetNormalizeScale( double scale ) { m_normalize_scale = scale; }
622 
623  //!this string defines the unit e.g. meters / inch/ etc.
624  /*! numbers used for storing length or position or always stored as doubles.
625  The real dimension is: (anynumber) * GetUnitsScale() * GetUnits()
626 
627  \remark the value may also be "trees" "pixels" or "people" etc.
628 
629  \remark conversion to other units is not just simply changing this string.
630  You must Change the SetUnitsScale(double) or really scale the data itself.
631  */
632  wxString GetUnits() { return m_units; }
633 
634  //!this string defines the unit e.g. meters / inch/ etc.
635  /*! numbers used for storing length or position or always stored as doubles.
636  The real dimension is: (anynumber) * GetUnitsScale() * GetUnits()
637 
638  \remark the value may also be "trees" "pixels" or "people" etc.
639 
640  \remark conversion to other units is not just simply changing this string.
641  You must Change the SetUnitsScale(double) or really scale the data itself.
642  */
643  void SetUnits( const wxString& unitString ) { m_units = unitString; }
644 
645  //! Sets the time of last access to this doc.
646  /*!
647  \param datatime new last access time
648  */
649  void SetAccessTime( const wxDateTime& datatime ) { m_accesstime = datatime; }
650 
651  //! Returns the time of last access.
652  wxDateTime& GetAccessTime() { return m_accesstime; }
653 
654  //! gives time when a change was made to the document which may effect rendering
655  /*!
656  Comparing this time in a dialogs its own update time, one can easily keep them up to date.
657 
658  e.g. set in SetUpdatesPending()
659  */
660  wxDateTime& GetInternalChangedTime() { return m_changedInternalAccesstime; }
661 
662 
663  DECLARE_DYNAMIC_CLASS( a2dCanvasDocument );
664 
665 protected:
666 
667  //! Called by ProcessEvent(wxEvent& event) of document
668  /*!
669  Event processing is called by wxView and therefore a2dCanvasView.
670  In a a2dDocumentCommandProcessor controller application wxDocChildFrame and wxDocParentFrame
671  redirect events to wxView and a2dDocumentCommandProcessor.
672  In a non a2dDocumentCommandProcessor the a2dCanvas is calling ProcessEvent(wxEvent& event) of document.
673  Onidle updates all drawers if pending updates are available
674  */
675  void OnIdle( wxIdleEvent& event );
676 
677  //! uses wxBufferedInputStream instead of a2dDocumentInputStream
678  void OnOpenDocument( a2dDocumentEvent& event );
679 
680  //! track modification of document
681  void OnDoEvent( a2dCommandProcessorEvent& event );
682 
683  //! track modification of document
684  void OnRedoEvent( a2dCommandProcessorEvent& event );
685 
686  //! track modification of document
687  void OnUndoEvent( a2dCommandProcessorEvent& event );
688 
689  //! called when a drawing in a document did change.
690  void OnChangeDrawings( a2dDrawingEvent& event );
691 
692  a2dObject* DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const;
693 
694 protected:
695 
696 #if wxART2D_USE_CVGIO
697  //! do not use directly, part of CVG format writing
698  void DoSave( a2dIOHandlerCVGOut& out, a2dCanvasObjectList* towrite );
699 #endif //wxART2D_USE_CVGIO
700 
701  //! start a2dCanvasObject containing all primitives
703 
704  //! what is the root a2dcameleon in the drawing to display after opening a document, when m_show is not set.
706 
707  //! what to display when document is openened
709 
710  //!setup for layers in this document
711  /*!
712  \remark will contain if a layer is available/visible for rendering
713  \remark object without style will take the layer style to draw itself.
714  */
716 
717  //! multi root document
719 
720  //! how many decimal places in fraction are valid
722 
723  //! scaling factor (how many "m_units_measure" is one unit)
725 
726  //! normalization factor to scale normalized objects.
728 
729  //! unit (e.g. Meters Inch Microns etc.)
730  wxString m_units;
731 
732  //! measuring unit (e.g. Meters Inch Microns etc.)
733  wxString m_units_measure;
734 
735  //! when was the document last accessed.
736  wxDateTime m_accesstime;
737 
738  //! gives time when a change was made to the document which may effect rendering
739  /*!
740  e.g. set in SetUpdatesPending()
741  */
743 
744 
745 public:
746 
747  //! name of library or document
748  wxString m_libraryname;
749 
750  //! description for document
751  wxString m_description;
752 
753  //! version of library or document
754  wxString m_version;
755 
756  //! layer info changed id sent around when m_layersetup is changed.
757  static const a2dSignal sig_layersetupChanged;
758 
759  //! when an object is removed from a layer,
760  static const a2dSignal sig_changedLayer;
761 
762  DECLARE_EVENT_TABLE()
763 
764 };
765 
766 #if defined(WXART2D_USINGDLL)
767 template class A2DEDITORDLLEXP a2dSmrtPtr<a2dCanvasDocument>;
768 #endif
769 
770 //! a2dCanvas and a2dCanvasView meet eachother here.
771 /*!
772  a2dCanvasView will use this canvas to display part of a document.
773 */
774 class a2dViewCanvas : public a2dCanvas
775 {
776  DECLARE_EVENT_TABLE()
777 
778 public:
779 
780  a2dViewCanvas( a2dCanvasView* view, wxWindow* parent, wxWindowID id = -1,
781  const wxPoint& pos = wxDefaultPosition,
782  const wxSize& size = wxDefaultSize,
783  long style = wxScrolledWindowStyle, a2dDrawer2D* drawer2D = 0 );
784 
785  a2dViewCanvas( a2dCanvasView* view, a2dDrawingPart* drawingpart, wxWindow* parent, wxWindowID id = -1,
786  const wxPoint& pos = wxDefaultPosition,
787  const wxSize& size = wxDefaultSize,
788  long style = wxScrolledWindowStyle );
789 
790  a2dCanvasView* GetView() { return m_view; }
791 
792  void SetView( a2dCanvasView* view );
793 
794 protected:
795 
796  //! called when document of the a2dView has changed.
797  /*!
798  Sets the a2dCanvasDocument where the objects for this canvas are stored
799  It will trigger boundingbox calculation and other administrative tasks
800  to properly render the document onto this view
801  */
802  void OnSetDocument( a2dViewEvent& event );
803 
804  void OnActivate( a2dViewEvent& viewevent );
805 
806  void OnCloseView( a2dCloseViewEvent& event );
807 
808  //! calls a2dDrawingpart::Update()
809  void OnUpdate( a2dDocumentEvent& event );
810 
811  a2dCanvasView* m_view;
812 
813 };
814 
815 #endif /* __WXCANDOC_H__ */
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
all basic primitives derived from a2dCanvasObject
SVG loader and saver of a wxCanvasDocument.
wxString m_units_measure
measuring unit (e.g. Meters Inch Microns etc.)
Definition: candoc.h:733
double m_printscalelimit
Set the scaling limit for printing, so that small stuff is not zoomed to full page.
Definition: candoc.h:311
void SetVersion(wxString version)
set version of library or document
Definition: candoc.h:447
bool GetMultiRoot()
Definition: candoc.h:566
see a2dDrawingEvent
Definition: drawing.h:933
wxString m_description
description for document
Definition: candoc.h:751
wxString m_units
unit (e.g. Meters Inch Microns etc.)
Definition: candoc.h:730
double m_units_scale
scaling factor (how many &quot;m_units_measure&quot; is one unit)
Definition: candoc.h:724
void SetUnitsScale(double scale)
this is the number that defines the physical dimension in meters / inch/ etc.
Definition: candoc.h:608
void OnCloseView(a2dCloseViewEvent &event)
Intercept to do cleanup/veto closing of a view.
Definition: docviewref.cpp:413
void SetDescription(const wxString &desc)
Sets a description of the document.
Definition: candoc.h:430
bool m_multiRoot
multi root document
Definition: candoc.h:718
void SetMultiRoot(bool multiRoot=true)
Set true if the document read from a file did not have on erootobject but several.
Definition: candoc.h:563
bool m_printtitle
if true, a printout is done with title (document name (description?)), otherwise not ...
Definition: candoc.h:305
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
View on a a2dCanvasDocument.
Definition: candoc.h:212
void SetPrintFrame(bool val)
If true, draw a frame around printouts.
Definition: candoc.h:297
static bool GetPrintAsBitmap()
if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
Definition: candoc.h:117
a2dSmrtPtr< a2dCameleon > m_main
what is the root a2dcameleon in the drawing to display after opening a document, when m_show is not s...
Definition: candoc.h:705
a2dCanvasObjectPtr m_show
what to display when document is openened
Definition: candoc.h:708
Ref Counted base object.
Definition: gen.h:1045
wxString m_version
version of library or document
Definition: candoc.h:754
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
Definition: gen.h:3458
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
Definition: candoc.h:601
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
a command processor specially designed to work with a a2dCanvasDocument
Definition: drawing.h:1046
a2dDrawing * GetDrawing() const
get the root object, which holds the objects in the document.
Definition: candoc.h:418
double m_normalize_scale
normalization factor to scale normalized objects.
Definition: candoc.h:727
The base class for all drawable objects in a a2dCanvasDocument.
using a file stream for input, stream the file into a a2dDocument or other object ...
Definition: gen.h:3632
static const a2dSignal sig_changedLayer
when an object is removed from a layer,
Definition: candoc.h:760
void SetLibraryName(const wxString &libraryname)
to name the document as a library (independent of a path and filename )
Definition: candoc.h:441
void SetAccessTime(const wxDateTime &datatime)
Sets the time of last access to this doc.
Definition: candoc.h:649
a2dView event, to report events in the a2dView class
Definition: docviewref.h:424
object to show several appearance views on what it contains
Definition: cameleon.h:630
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dPrintWhat m_typeOfPrint
type of print requested
Definition: candoc.h:131
Holds an error message.
void SetPrintFilename(bool val)
If true render the printout with a filename string, otherwise not.
Definition: candoc.h:291
output handler for the CVG format.
Definition: xmlpars.h:103
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
Definition: candoc.h:555
a2dCanvas uses a2dCanvasView for displaying a view on a a2dCanvasDocument.
special a2dCanvasObject which are used to create hierarchy different from the standard a2dCanvasObjec...
a2dCameleon * GetTopCameleon()
what is the top a2dcameleon in the drawing to display after opening a document, when m_show is not se...
Definition: candoc.h:569
void SetPrintFitToPage(bool val)
If true, draw a view on all page without real scale.
Definition: candoc.h:300
void SetUnitsAccuracy(double accuracy)
this is the number that defines the number of decimal places in the fraction
Definition: candoc.h:595
vector path a2dVectorPath derived from a2dCanvasObject
Holds a view on a a2dDocument.
Definition: docviewref.h:1804
double m_scalelimit
limit scaling to this value (world/pixel)
Definition: candoc.h:143
bool m_drawframe
draw a frame around the page
Definition: candoc.h:146
static const a2dSignal sig_layersetupChanged
layer info changed id sent around when m_layersetup is changed.
Definition: candoc.h:757
The document class can be used to model an application&#39;s file-based data.
Definition: docviewref.h:1066
wxDateTime m_accesstime
when was the document last accessed.
Definition: candoc.h:736
wxString GetVersion()
get version of library or document
Definition: candoc.h:450
wxUint16 a2dPrintWhat
defines what to print
Definition: gen.h:4052
Docview classes for document view, window and frame.
wxString GetUnits()
this string defines the unit e.g. meters / inch/ etc.
Definition: candoc.h:632
void SetPrintScaleLimit(double val)
Set the scaling limit for printing, so that small stuff is not zoomed to full page.
Definition: candoc.h:294
a2dCanvasObject * GetShowObject()
what to display when document is openened
Definition: candoc.h:574
Drawing context abstraction.
Definition: drawer2d.h:177
a2dCanvas and a2dCanvasView meet eachother here.
Definition: candoc.h:774
to print what is displayed on a a2dCanvasView or the whole document as seen from the showobject of th...
Definition: candoc.h:71
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
void SetPrintTitle(bool val)
If true render the printout with a title string, otherwise not.
Definition: candoc.h:288
view to display the size of a2dCanvasView compared to the whole of the a2dCanvasDocument that is view...
Definition: candoc.h:161
void SetNormalizeScale(double scale)
see GetNormalizeScale()
Definition: candoc.h:621
Contains a2dDrawing Class to hold a drawing.
bool m_fitToPage
Definition: candoc.h:150
properties specific for a2dCanvasOject
using a file stream for output, stream a a2dDocument or other wxObject into a stream.
Definition: gen.h:3751
wxString m_title
title put above printout
Definition: candoc.h:137
a2dCanvas is used to display one of the a2dCanvasObjects which are part of a a2dCanvasDocument object...
Definition: canvas.h:68
a2dSmrtPtr< a2dLayers > m_layersetup
setup for layers in this document
Definition: candoc.h:715
double m_units_accuracy
how many decimal places in fraction are valid
Definition: candoc.h:721
wxInputStream a2dDocumentInputStream
input stream based wxStreams
Definition: gen.h:3456
wxString m_libraryname
name of library or document
Definition: candoc.h:748
wxDateTime & GetInternalChangedTime()
gives time when a change was made to the document which may effect rendering
Definition: candoc.h:660
wxString & GetDescription()
Returns the description of the document.
Definition: candoc.h:438
wxDateTime m_changedInternalAccesstime
gives time when a change was made to the document which may effect rendering
Definition: candoc.h:742
static bool m_printAsBitmap
if set print a bitmap that was drawn into
Definition: candoc.h:153
double GetNormalizeScale()
Normalize objects ( defined in coordinates -1 to 1 ranges ) will be multiplied by this factor...
Definition: candoc.h:618
a2dCanvasView * m_canvasDocview
the view to view zoomed
Definition: candoc.h:193
double GetUnitsAccuracy()
this is the number that defines the number of decimal places in the fraction
Definition: candoc.h:586
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
Definition: candoc.h:374
bool m_printfilename
if true, a printout is done with filename (document file path), otherwise not
Definition: candoc.h:308
a2dCanvasView * m_drawingView
maping defined by this canvas
Definition: candoc.h:134
list for a2dCanvasObject
print a document
Definition: docviewref.h:3311
void SetUnits(const wxString &unitString)
this string defines the unit e.g. meters / inch/ etc.
Definition: candoc.h:643
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
see a2dComEvent
Definition: gen.h:371
see a2dDocumentEvent
Definition: docviewref.h:356
bool m_printfittopage
If true, draw a view on all page without real scale.
Definition: candoc.h:317
used to report a2dDocument events
Definition: docviewref.h:591
static void SetPrintAsBitmap(bool printAsBitmap)
if set, printing is done via a bitmap which is drawn into, and next bitmap is printed.
Definition: candoc.h:114
all polygon and polyline a2dCanvasObject are here.
Input handler for the CVG format.
Definition: xmlpars.h:59
wxDateTime & GetAccessTime()
Returns the time of last access.
Definition: candoc.h:652
GdsII format input and output.
void SetShowObject(a2dCanvasObject *show)
what to display when document is openened
Definition: candoc.h:576
list of a2dObject&#39;s
Definition: gen.h:3157
void SetTopCameleon(a2dCameleon *root)
what is the top a2dcameleon in the drawing to display after opening a document, when m_show is not se...
Definition: candoc.h:571
wxString m_filename
filename put below printout
Definition: candoc.h:140
CloneOptions
options for cloning
Definition: gen.h:1200
a2dDrawingPtr m_drawing
start a2dCanvasObject containing all primitives
Definition: candoc.h:702
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
wxString & GetLibraryName()
Get name the document as a library (independent of a path and filename )
Definition: candoc.h:444
bool m_printframe
If true, draw a frame around printouts.
Definition: candoc.h:314
candoc.h Source File -- Sun Oct 12 2014 17:04:13 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation