00001 /*! \file wx/canvas/candoc.h 00002 \brief Contains a2dCanvasDocument Class to hold a drawing. 00003 00004 a2dCanvasDocument is the class where a hierarchy of a2dCanvasObject's is stored. 00005 Updating pending/changed objects and drawing a document is all from this class. 00006 00007 \author Klaas Holwerda 00008 00009 Copyright: 2000-2004 (c) Klaas Holwerda 00010 00011 Licence: wxWidgets Licence 00012 00013 RCS-ID: $Id: candoc.h,v 1.31 2009/07/10 19:23:13 titato Exp $ 00014 */ 00015 00016 #ifndef __WXCANDOC_H__ 00017 #define __WXCANDOC_H__ 00018 00019 #ifndef WX_PRECOMP 00020 #include "wx/wx.h" 00021 #endif 00022 00023 #include "wx/image.h" 00024 #include "wx/txtstrm.h" 00025 00026 #include "a2dprivate.h" 00027 00028 #include "wx/canvas/canobj.h" 00029 #include "wx/canvas/vpath.h" 00030 #include "wx/canvas/canprim.h" 00031 #include "wx/canvas/polygon.h" 00032 #include "wx/canvas/objlist.h" 00033 #include "wx/canvas/recur.h" 00034 00035 #include "wx/canvas/canprop.h" 00036 00037 #if wxART2D_USE_SVGIO 00038 #include "wx/svgio/parssvg.h" 00039 #endif //wxART2D_USE_SVGIO 00040 00041 #if wxART2D_USE_GDSIO 00042 #include "wx/gdsio/gdsio.h" 00043 #include "wx/gdsio/gdserr.h" 00044 #endif //wxART2D_USE_GDSIO 00045 00046 #include "wx/docview/docviewref.h" 00047 00048 class a2dCanvasCommandProcessor; 00049 class a2dIOHandlerCVGIn; 00050 class a2dIOHandlerCVGOut; 00051 00052 #include "wx/canvas/drawer.h" 00053 00054 //---------------------------------------------------------------------------- 00055 // decls 00056 //---------------------------------------------------------------------------- 00057 00058 //!Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. 00059 /*! 00060 Several a2dCanvasView objects can share the same a2dCanvasDocument. 00061 The a2dCanvasDocument has one top a2dCanvasObject, called m_rootobject. 00062 All other a2dCanvasObject's are added as children to this root object. 00063 The docuemnt also contains the layer settings for the canvas objects to be rendered. 00064 The a2dCanvasDocument is derived from a2dDocument, and it is used to store a hierarchy of a2dCanvasObject's. 00065 The updating of modified a2dCanvasObject's is also organized as part of this class. One can load a canvas document from 00066 a file, and save it to a file, in the CVG format. But other formats are possible, via the document its a2dDocumentTemplate and 00067 associated a2dIOHandlers. 00068 00069 Rendering a a2dCanvasDocument is started at a given a2dCanvasObject, 00070 which needs to be part of the data structure below the a2dCanvasDocument. 00071 Since a2dCanvasDocument owns a a2dCanvasObject as root, rendering the complete document will start at the m_rootobject. 00072 But any nested child a2dCanvasObject can be used to start rendering, and only that object and it children will be displayed 00073 on the a2dCanvasView ( and a2dCanvas which is the display window ). 00074 The a2dCanvasObject to be displayed on a certain a2dCanvasView is maintained in the 00075 a2dCanvasView object. It can be different for all a2dCanvasView objects sharing the same a2dCanvasDocument. 00076 00077 a2dCanvasDocument senets update events when a2dCanvasObject have changed internal. The a2dView's using the document 00078 are intercepting the update events, and react by updating the data that they display. For a a2dCanvasView this means 00079 redrawing those parts that have changed. 00080 00081 Any nested child from a a2dCanvasDocument Object can be displayed on several a2dCanvasView Objects at the same time. 00082 The child displayed does not have to be the same on each a2dCanvasView. 00083 The active a2dCanvasView is used to render and convert coordinates from world to device. 00084 So it is important to set the active a2dCanvasView based on the a2dCanvasView that has the focus 00085 or is scrolled etc. This is normally done within a2dCanvasView when appropriate. 00086 00087 00088 \remark Use a2dDocumentTemplate's to get the type of the file, where this data was read from. 00089 based on this the document can be saved in the same type as read from. 00090 00091 \sa a2dCanvasView 00092 \sa a2dCanvas 00093 \sa wxWorldCanvas 00094 \sa a2dCanvasObject 00095 00096 \ingroup docview canvasobject 00097 */ 00098 class A2DCANVASDLLEXP a2dCanvasDocument : public a2dDocument 00099 { 00100 public: 00101 00102 //!Construct a a2dCanvasDocument to store a complete drawing in 00103 /*! 00104 This class contains nested a2dCanvasObject's and other drawing object derived from a2dCanvasObject's. 00105 The class itself is derived from a2dDocument. 00106 All objects are stored are as childs of the m_rootobject. 00107 A complete drawing is stored here, and displaying the drawing, is done by setting a pointer to this a2dCanvasDocument 00108 for a a2dCanvasView derived class. 00109 Every change inside the wxCavasObject's stored inside this class, will report themselfs as pending to an instance 00110 of this class. 00111 The a2dCanvasView classes, having this instance of a2dCanvasDocument set, will be updated from the document via update events. 00112 a2dCanvasObject that are changed or set pending. Those pending objects are reported to the document also. In Idle time the pending 00113 objects are redrawn on the a2dCanvasView's that display the document. 00114 The same a2dCanvasDocument can be displayed on reveral a2dCanvasView's at the same time. 00115 And therefore a pending a2dCanvasObject maybe be (re)displayed on several a2dCanvasView's also. 00116 The a2dCanvasObjects stored in a a2dCanvasDocument, will have their m_root member set in order to get to the a2dCanvasDocument 00117 in which they are stored. Through the a2dCanvasDocument they will be able to reach the a2dCanvasView class that is currently active. 00118 The a2dCanvasView class is set to the document when needed on a higher level. e.g. when rendering a a2dCanvasDocument. 00119 This way each a2dCanvasObject stored inside the a2dCanvasDocument, can draw itself on the active a2dCanvasView. 00120 The a2dCanvasView in this case can be seen as a sort of drawing context. 00121 Indirectly a a2dCanvasView can use a2dCanvas as the window/device to draw up on. 00122 Another type of a2dCanvasView can draw to a bitmap, image or printer device. 00123 00124 \remark The initially layer setup is defined my a2dCanvasGlobal::GetLayerSetup 00125 00126 \see SetLayerSetup for an example for introduce your own layers 00127 */ 00128 a2dCanvasDocument(); 00129 00130 //! destructor 00131 ~a2dCanvasDocument(); 00132 00133 //! like it to be protected, but this does not work with wxList macros 00134 //void operator delete(void* recordptr); 00135 00136 //! constructor with other document 00137 a2dCanvasDocument( const a2dCanvasDocument &other ); 00138 00139 //! create exact copy 00140 virtual a2dObject* Clone( CloneOptions options ) const; 00141 00142 //! get the root object, which holds the objects in the document. 00143 inline a2dCanvasObject* GetRootObject() const { return m_rootobject; } 00144 00145 //! set new root object ( may not ne NULL ) 00146 void SetRootObject( a2dCanvasObject* newRoot ); 00147 00148 //! get bounding box of document its minimum X 00149 double GetBboxMinX() { return m_rootobject->GetBboxMinX(); } 00150 00151 //! get bounding box of document its minimum Y 00152 double GetBboxMinY() { return m_rootobject->GetBboxMinY(); } 00153 00154 //! get bounding box of document its maximum X 00155 double GetBboxMaxX() { return m_rootobject->GetBboxMaxX(); } 00156 00157 //! get bounding box of document its maximum Y 00158 double GetBboxMaxY() { return m_rootobject->GetBboxMaxY(); } 00159 00160 //! get bounding box of document its width 00161 double GetBboxWidth() { return m_rootobject->GetBboxWidth(); } 00162 00163 //! get bounding box of document its height 00164 double GetBboxHeight() { return m_rootobject->GetBboxHeight(); } 00165 00166 //! get bounding box of document 00167 a2dBoundingBox& GetBbox() { return m_rootobject->GetBbox(); } 00168 00169 //!add at begin an object the root group 00170 void Prepend( a2dCanvasObject* obj ) { m_rootobject->Prepend( obj ); } 00171 00172 //!add at end an object the root group 00173 void Append( a2dCanvasObject* obj ) { m_rootobject->Append( obj ); } 00174 00175 //!insert object at a position in the root group 00176 void Insert( size_t before, a2dCanvasObject* obj ) { m_rootobject->Insert( before, obj ); } 00177 00178 //! release a specific object from the rootobject 00179 /*! 00180 \param obj object to release 00181 \param backwards start at the end 00182 \param all if true remove all references to object 00183 00184 \return number of released objects 00185 */ 00186 int ReleaseChild( a2dCanvasObject* obj, bool backwards = false, bool all = true ) { return m_rootobject->ReleaseChild( obj, backwards, all ); } 00187 00188 //!removes and release only from the childobjects the objects with the given mask 00189 /*! 00190 \return true if some object were released 00191 */ 00192 bool ReleaseChildObjects( a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::ALL ) { return m_rootobject->ReleaseChildObjects( mask ); } 00193 00194 //!set all bit flags in object that or true in mask to true or false 00195 /*! 00196 set specific flags to true or false, also recursive for children objects 00197 00198 \remark the object is not setpending when soemthing changed ( actually the pending flag can be set here also ) 00199 00200 \param setOrClear if true sets the flag to true else to false 00201 \param which set only those flags in object to true or false 00202 \param classname if not empty, object must have this classname 00203 \param whichobjects set flags only for object having this flags set already 00204 */ 00205 void SetSpecificFlags( bool setOrClear, a2dCanvasObjectFlagsMask which, const wxString& classname = wxT(""), a2dCanvasObjectFlagsMask whichobjects = a2dCanvasOFlags::ALL ); 00206 00207 //!return the object if it is part of the given object or 00208 /*! if the given object is part of a childobjects within this object. 00209 For child objects this means recursively search for it. 00210 \param obj object to search for 00211 */ 00212 a2dCanvasObject* Find( a2dCanvasObject* obj ); 00213 00214 //!return the object with (name, classname, id) if it is part of the given object or 00215 /*! if the given object is part of a recursive childobject within this object. 00216 For child objects this means recursively search for it. 00217 00218 \param objectname object with this name to search for. Empty string means ignore this. 00219 \param classname object must have this classname. Empty string means ignore this. 00220 \param id if a id is given, the object must have with this id ( address as wxInt64 ) 00221 */ 00222 a2dCanvasObject* Find( const wxString& objectname, const wxString& classname = wxT(""), wxInt64 id = -1 ); 00223 00224 //! Sets a description of the document 00225 /*! 00226 A description may describe the content of this document or contain keywords etc. 00227 The default value is "a2dCanvasDocument generated by wxArt2D". 00228 00229 \param desc description of the document 00230 */ 00231 void SetDescription( const wxString& desc ) { m_description = desc; } 00232 00233 //! Returns the description of the document 00234 /*! 00235 \see SetDescription 00236 00237 \return the description 00238 */ 00239 wxString& GetDescription() { return m_description; } 00240 00241 //! to name the document as a library (independent of a path and filename ) 00242 void SetLibraryName( const wxString& libraryname ) { m_libraryname = libraryname; } 00243 00244 //! Get name the document as a library (independent of a path and filename ) 00245 wxString& GetLibraryName() { return m_libraryname; } 00246 00247 //! set version of library or document 00248 void SetVersion( int version ) { m_version = version; } 00249 00250 //! get version of library or document 00251 int GetVersion() { return m_version; } 00252 00253 //! delete all object in this document (also nested groups etc.) 00254 virtual void DeleteContents(); 00255 00256 //! get a pointer to the command processor 00257 a2dCanvasCommandProcessor* GetCanvasCommandProcessor(); 00258 00259 //! create the commandprocessor (special designed to work with a2dCanvas code) 00260 void CreateCommandProcessor(); 00261 00262 //!adds current and future boundingbox of the objects with pending flag set, to the pendinglist of all a2dCanvasView's 00263 /*! 00264 which are using this document. 00265 The areas will only be updated from the a2dCanvasView's, which are using this document in idle time. 00266 It first check's for pending object's stored in this a2dCanvasDocument. 00267 If true, it searches those object starting from the displayed showgroup in each drawer, and adds 00268 the boundingbox of the current state the object is in, to the update area list of the those a2dCanvasView's 00269 If the boundingbox of an object is not available, it will be calcualted at that moment. 00270 In Next step the new boundingboxes are calculated for the pending objects and those are also 00271 added to the pending arae list's of all a2dCanvasView's. 00272 This functions adds areas of all places where this object is rendered also when referenced. 00273 In the end, the pending flag in all objects is reset. 00274 00275 AddPendingUpdatesOldNew() makes sure all objects 00276 that where pending are processed. 00277 00278 In idle time a2dCanvasView's will only redraw the areas that are damaged because of changes to canvas objects. 00279 00280 00281 00282 \return if there were pendingobjects it return true 00283 */ 00284 bool AddPendingUpdatesOldNew(); 00285 00286 //! sent Update events to all a2dView which display or use this document. 00287 /*! 00288 Changes in the document are reported by the objects contained in the document, 00289 after a change, they set the pending flag of the document and itself. 00290 Here the document lets the a2dView's know how the views should be updated. 00291 The normal case is Redrawing what is in the old and new boundingbox of each changed object. 00292 00293 The default Updates all a2dCanvasObjects that are pending and adds a redraw area the size of the view to all views, 00294 after that the pending object flags are reset. The result is redrawing all a2dCanvasView views in idle time completely. 00295 00296 \param sender which view did calls this fucntion ( Non = NULL ). 00297 \param hint will be casted to a2dCanViewUpdateFlags in a2dCanvasView the effect will differ on the hint given. 00298 \param objecthint more complex way to deliver hints 00299 */ 00300 virtual void UpdateAllViews(a2dView *sender = (a2dView *) NULL, unsigned int hint = a2dCANVIEW_UPDATE_ALL, wxObject *objecthint = (wxObject *) NULL); 00301 00302 //!sets all associated view/drawers to Frozen to prevent all drawer activity 00303 virtual void Freeze(); 00304 00305 //!sets all associated view/drawers to non Frozen to allow all drawer activity 00306 virtual void Thaw(bool update); 00307 00308 //!write as SVG to a file starting at given object 00309 /*! 00310 \param drawer drawing view context 00311 \param filename filename of stream to write the SVG content to. 00312 \param top start writting at this object. 00313 \param Width width in unit will be the physical width of the drawing. 00314 \param Height height in unit will be the physical height of the drawing. 00315 \param unit Unit of width and height e.g. "cm" "um". 00316 */ 00317 bool WriteSVG( a2dCanvasView* drawer, const wxString& filename, a2dCanvasObject* top, double Width, double Height, wxString unit); 00318 00319 //!load form a file containing the a2dCanvas specific XML called CVG format 00320 virtual a2dDocumentInputStream& LoadObject( a2dDocumentInputStream& stream, a2dIOHandlerStrIn* handler ); 00321 00322 #if wxART2D_USE_CVGIO 00323 //! used by CVG parser 00324 /*! 00325 \remark do not use directly 00326 */ 00327 void Load( wxObject* parent, a2dIOHandlerXmlSerIn& parser ); 00328 #endif //wxART2D_USE_CVGIO 00329 00330 //! load document from a file with the given filename and given parser type 00331 bool Load( const wxString& filename, a2dIOHandlerStrIn* handler ); 00332 00333 //! save layer settings to CVG file 00334 bool SaveLayers( const wxString& filename ); 00335 00336 //! load layers from another file 00337 /*! 00338 Only the layer settings are read from the file and put in place of the 00339 current layers settings in the document. 00340 */ 00341 bool LoadLayers( const wxString& filename ); 00342 00343 //! Update a loaded layer setup 00344 /*! This is called after loading a layer setup. The base class function does 00345 nothing. It is usefull to override this to update a loaded layer setup to 00346 e.g. a new software version */ 00347 virtual void UpdateLoadedLayerSetup(); 00348 00349 //!save as the a2dCanvas specific XML called CVG format 00350 a2dDocumentOutputStream& SaveObject( a2dDocumentOutputStream& stream, a2dIOHandlerStrOut* handler ); 00351 00352 #if wxART2D_USE_CVGIO 00353 void Save( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dObjectList* towrite ); 00354 00355 //! called from a2dIOHandlerCVGOut after a SaveObject. 00356 /*! 00357 \param out CVG io handler 00358 \param start start wrting from this object 00359 */ 00360 void Save( a2dIOHandlerCVGOut &out, a2dCanvasObject* start = 0 ); 00361 #endif //wxART2D_USE_CVGIO 00362 00363 //! save document to a file with the given name and given output writer type 00364 bool Save( const wxString& filename, a2dIOHandlerStrOut* handler ) const; 00365 00366 //!set a2dCanvasDocument recursive for whole tree 00367 void SetCanvasDocumentRecursive(); 00368 00369 //! update all pending objects in the document 00370 /* 00371 At the minumum all boudingboxes are brought up to date, and if a layersetup is set, 00372 in the end all layers used in the document are known. 00373 00374 This function is part of the update cycle e.g. in AddPendingUpdatesOldNew() 00375 */ 00376 void Update( a2dCanvasObject::UpdateMode mode ); 00377 00378 //!set the layersettings for the canvas. 00379 /*! 00380 A default Layer Setting is created in the constructor a2dCanvasDocument::a2dCanvasDocument 00381 00382 An example how to set another layer setup 00383 \code 00384 // Clone the current layer setup 00385 a2dLayers* docLayers = doc->GetLayerSetup()->Clone( bool deep = true ); 00386 00387 // Create a new layer with an index above the predefined layers 00388 a2dLayerInfo* lr = new a2dLayerInfo(wxLAYER_USER_FIRST, "MyLayer"); 00389 00390 // Set layer available 00391 lr->Set_Available(true); 00392 00393 // Add layer to to the a2dLayers 00394 docLayers->Append(lr); 00395 00396 doc->SetLayerSetup(docLayers); 00397 \endcode 00398 00399 \remark 00400 You don't have to call Set_UpdateAvailableLayers it will be done automatically 00401 00402 \param layersetup the new layersetup 00403 */ 00404 void SetLayerSetup( a2dLayers* layersetup ); 00405 00406 //!Get the layersettings for the canvas. 00407 /*! 00408 A default Layer Setting is taken from a2dCanvasGlobal. 00409 \sa a2dCanvasGlobal for central layers settings, used for initializing a a2dCanvasDocument 00410 */ 00411 a2dLayers* GetLayerSetup() { return m_layersetup; } 00412 00413 //!Set true if the document read from a file did not have on erootobject but several 00414 /*! 00415 Some formats as GDS-II and KEY, can contain many structure, which are not placed in 00416 a single parent object. Still in a a2dCanvasDocument they will be placed in the m_rootobject. 00417 This flag can be used when writing the data back in the same way, skipping the rootobject if possible. 00418 */ 00419 void SetMultiRoot( bool multiRoot = true ) { m_multiRoot = multiRoot; } 00420 00421 //! \see SetMultiRoot() 00422 bool GetMultiRoot() { return m_multiRoot; } 00423 00424 //! Tells the document that an object has changed. 00425 /*! 00426 If an object has changed and and needs an update, this method 00427 informes the document about this. 00428 The update of pending objects will be proceed in Idle time. 00429 */ 00430 void SetUpdatesPending(bool onoff); 00431 00432 //! call DependencyPending on root object and recursive on childs. 00433 /*! 00434 This call is repeated until no more a2dCanvasObject were set pending. 00435 \sa a2dCanvasObject::DependencyPending 00436 */ 00437 void DependencyPending(); 00438 00439 //!returns true if some objects have changed recently within this document 00440 bool GetUpdatesPending(); 00441 00442 //! Switches ignorance of pending objects on and off. 00443 /*! 00444 If set to <code>true</code> pending objects won't be updated. 00445 This method is used by several tools (i.e. a2dDragTool) to avoid updates 00446 while the tool is working. 00447 00448 \see GetUpdatesPending() 00449 00450 \param onoff <code>true</code> to ignore pending objects, else <code>false</code> 00451 */ 00452 void SetIgnorePendingObjects( bool onoff ); 00453 00454 //!get setting of ignore pending objects /sa GetUpdatesPending() 00455 bool GetIgnorePendingObjects() { return m_ignorePendingObjects; } 00456 00457 //!this is the number that defines the number of decimal places in the fraction 00458 /*!when writing numbers to a file. 00459 When reading a file, this number is set to the accuracy information available in the file. 00460 1/GetUnitsAccuracy() == 100 means 2 decimal places will be written, or the data just 00461 read is accurate to this number of decimal places. 00462 00463 \remark GetUnitsAccuracy() can also be > 1 00464 */ 00465 double GetUnitsAccuracy() { return m_units_accuracy; } 00466 00467 //!this is the number that defines the number of decimal places in the fraction 00468 /*!when writing numbers to a file. 00469 When reading a file, this number is set to the accuracy information available in the file. 00470 1/GetAccuracyUserUnits() == 100 means 2 decimal places will be written, or the data just 00471 read is accurate to this number of decimal places. 00472 \remark SetUnitsAccuracy() can also be > 1 00473 */ 00474 void SetUnitsAccuracy(double accuracy) { m_units_accuracy = accuracy; } 00475 00476 //!this is the number that defines the physical dimension in meters / inch/ etc. 00477 /*! numbers used for storing length or position or always stored as doubles. 00478 The real dimension is: (anynumber) * GetUnitsScale() * GetUnits() 00479 */ 00480 double GetUnitsScale() { return m_units_scale; } 00481 00482 00483 //!this is the number that defines the physical dimension in meters / inch/ etc. 00484 /*! numbers used for storing length or position or always stored as doubles. 00485 The real dimension is: (anynumber) * GetUnitsScale() * GetUnits() 00486 */ 00487 void SetUnitsScale(double scale) { m_units_scale = scale; } 00488 00489 //! Normalize objects ( defined in coordinates -1 to 1 ranges ) will be multiplied by this factor. 00490 /*! 00491 Libraries containing object which are defined in normalized coordinates, 00492 need to be multiplied by a certain factor before they can be added to a document. 00493 This factor defines by how much that should be done. 00494 As an example a libary containing arrow objects for placing at the end of a2dEndsLine 00495 objects, will use this factor. 00496 */ 00497 double GetNormalizeScale() { return m_normalize_scale; } 00498 00499 //! see GetNormalizeScale() 00500 void SetNormalizeScale(double scale) { m_normalize_scale = scale; } 00501 00502 //!this string defines the unit e.g. meters / inch/ etc. 00503 /*! numbers used for storing length or position or always stored as doubles. 00504 The real dimension is: (anynumber) * GetUnitsScale() * GetUnits() 00505 00506 \remark the value may also be "trees" "pixels" or "people" etc. 00507 00508 \remark conversion to other units is not just simply changing this string. 00509 You must Change the SetUnitsScale(double) or really scale the data itself. 00510 */ 00511 wxString GetUnits() { return m_units; } 00512 00513 //!this string defines the unit e.g. meters / inch/ etc. 00514 /*! numbers used for storing length or position or always stored as doubles. 00515 The real dimension is: (anynumber) * GetUnitsScale() * GetUnits() 00516 00517 \remark the value may also be "trees" "pixels" or "people" etc. 00518 00519 \remark conversion to other units is not just simply changing this string. 00520 You must Change the SetUnitsScale(double) or really scale the data itself. 00521 */ 00522 void SetUnits( const wxString& unitString ) { m_units = unitString; } 00523 00524 //! set size for view in userunits, when still empty 00525 void SetInitialSize( double sizeX, double sizeY ) 00526 { m_initialSizeX = sizeX; m_initialSizeY = sizeY; } 00527 00528 //! get size for view in userunits, when still empty 00529 double GetInitialSizeX() { return m_initialSizeX; } 00530 00531 //! get size for view in userunits, when still empty 00532 double GetInitialSizeY() { return m_initialSizeY; } 00533 00534 //! Sets a time of last modification 00535 /*! 00536 \param datatime new modification time 00537 */ 00538 void SetModificationTime( const wxDateTime& datatime ) { m_modificationtime = datatime; } 00539 00540 //! Returns the time of last modification when the document was saved 00541 /*! 00542 \return time of last modification 00543 */ 00544 wxDateTime& GetModificationTime() { return m_modificationtime; } 00545 00546 //! Sets the time of last access to this doc. 00547 /*! 00548 \param datatime new last access time 00549 */ 00550 void SetAccessTime( const wxDateTime& datatime ) { m_accesstime = datatime; } 00551 00552 //! Returns the time of last access. 00553 wxDateTime& GetAccessTime() { return m_accesstime; } 00554 00555 //! gives time when a change was made to the document which may effect rendering 00556 /*! 00557 Comparing this time in a dialogs its own update time, one can easily keep them up to date. 00558 00559 e.g. set in SetUpdatesPending() 00560 */ 00561 wxDateTime& GetInternalChangedTime() { return m_changedInternalAccesstime; } 00562 00563 00564 DECLARE_DYNAMIC_CLASS(a2dCanvasDocument); 00565 00566 protected: 00567 00568 //! Called by ProcessEvent(wxEvent& event) of document 00569 /*! 00570 Event processing is called by wxView and therefore a2dCanvasView. 00571 In a a2dDocumentCommandProcessor controller application wxDocChildFrame and wxDocParentFrame 00572 redirect events to wxView and a2dDocumentCommandProcessor. 00573 In a non a2dDocumentCommandProcessor the a2dCanvas is calling ProcessEvent(wxEvent& event) of document. 00574 Onidle updates all drawers if pending updates are available 00575 */ 00576 void OnIdle( wxIdleEvent &event ); 00577 00578 //! uses wxBufferedInputStream instead of a2dDocumentInputStream 00579 void OnOpenDocument( a2dDocumentEvent& event ); 00580 00581 protected: 00582 00583 #if wxART2D_USE_CVGIO 00584 //! do not use directly, part of CVG format writing 00585 void DoSave( a2dIOHandlerCVGOut &out, a2dCanvasObjectList* towrite ); 00586 #endif //wxART2D_USE_CVGIO 00587 00588 //! start a2dCanvasObject containing all primitives 00589 a2dCanvasObjectPtr m_rootobject; 00590 00591 //!setup for layers in this document 00592 /*! 00593 \remark will contain if a layer is available/visible for rendering 00594 \remark object without style will take the layer style to draw itself. 00595 */ 00596 a2dSmrtPtr<a2dLayers> m_layersetup; 00597 00598 //! multi root document 00599 bool m_multiRoot; 00600 00601 //!set by object in this a2dCanvasDocument, to tell they have changed and therefore it needs to be rerendered 00602 bool m_updatespending; 00603 00604 //!if set ignore all setting for pendingobjects 00605 bool m_ignorePendingObjects; 00606 00607 //! how many decimal places in fraction are valid 00608 double m_units_accuracy; 00609 00610 //! scaling factor (how many "m_units_measure" is one unit) 00611 double m_units_scale; 00612 00613 //! normalization factor to scale normalized objects. 00614 double m_normalize_scale; 00615 00616 //! unit (e.g. Meters Inch Microns etc.) 00617 wxString m_units; 00618 00619 //! measuring unit (e.g. Meters Inch Microns etc.) 00620 wxString m_units_measure; 00621 00622 //! for new document views what will be the size in userunits in X 00623 double m_initialSizeX; 00624 00625 //! for new document views what will be the size in userunits in Y 00626 double m_initialSizeY; 00627 00628 //! last modification time when this document was stored. 00629 wxDateTime m_modificationtime; 00630 00631 //! when was the document last accessed. 00632 wxDateTime m_accesstime; 00633 00634 //! gives time when a change was made to the document which may effect rendering 00635 /*! 00636 e.g. set in SetUpdatesPending() 00637 */ 00638 wxDateTime m_changedInternalAccesstime; 00639 00640 00641 public: 00642 00643 //! name of library or document 00644 wxString m_libraryname; 00645 00646 //! description for document 00647 wxString m_description; 00648 00649 //! version of library or document 00650 int m_version; 00651 00652 //! layer info changed id sent around when m_layersetup is changed. 00653 static const wxEventType sm_layersetupChanged; 00654 00655 A2D_DECLARE_EVENT_TABLE() 00656 00657 }; 00658 00659 #if defined(WXART2D_USINGDLL) 00660 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dCanvasDocument>; 00661 #endif 00662 00663 #endif /* __WXCANDOC_H__ */