26 #include <wx/wfstream.h>
50 m_flags.m_ignoreLayer =
true;
53 a2dCanvasObjectReference::a2dCanvasObjectReference(
double x,
double y,
a2dCanvasObject* obj )
61 a2dCanvasObjectReference::~a2dCanvasObjectReference()
78 m_object = other.m_object;
93 wxString name = other->
GetName();
132 if ( m_object.Get() )
133 m_object->
Walker(
this, handler );
153 calc = m_object->
Update( mode );
186 if ( clipparent !=
_IN )
189 if ( childclip !=
_OUT )
192 m_object->
Render( ic, childclip );
201 a2dCanvasObject::DoWalkerWithContext( ic, parent, handler );
206 #if wxART2D_USE_CVGIO
210 if ( xmlparts == a2dXmlSer_attrib )
218 if ( m_object && !m_object->
GetCheck() )
224 m_object->
Save(
this, out, towrite );
233 if ( xmlparts == a2dXmlSer_attrib )
242 if ( parser.
GetTagName() != wxT(
"derived" ) )
254 #endif //wxART2D_USE_CVGIO
260 return m_object->
IsHitWorld( ic, hitEvent ) != 0;
279 a2dCanvasObjectArrayReference::a2dCanvasObjectArrayReference()
284 a2dCanvasObjectArrayReference::a2dCanvasObjectArrayReference(
double x,
double y,
int rows,
int columns,
double horzSpace,
double vertSpace,
a2dCanvasObject* obj )
287 m_horzSpace = horzSpace;
288 m_vertSpace = vertSpace;
293 a2dCanvasObjectArrayReference::~a2dCanvasObjectArrayReference()
305 m_horzSpace = other.m_horzSpace;
306 m_vertSpace = other.m_vertSpace;
307 m_rows = other.m_rows;
308 m_columns = other.m_columns;
323 tmp.
Translate( ( m_columns - 1 )*m_horzSpace, 0 );
326 tmp.
Translate( 0, ( m_rows - 1 )*m_vertSpace );
329 tmp.
Translate( -( m_columns - 1 )*m_horzSpace, 0 );
353 for ( i = 0 ; i < m_rows; i++ )
355 for ( j = 0 ; j < m_columns; j++ )
360 if ( clipparent !=
_IN )
363 if ( childclip !=
_OUT )
366 m_object->
Render( ic, childclip );
372 offsetXY.
Translate( -m_horzSpace * m_columns, m_vertSpace );
376 #if wxART2D_USE_CVGIO
380 if ( xmlparts == a2dXmlSer_attrib )
382 out.WriteAttribute( wxT(
"columns" ), m_columns );
383 out.WriteAttribute( wxT(
"rows" ), m_rows );
384 out.WriteAttribute( wxT(
"horzspace" ), m_horzSpace );
385 out.WriteAttribute( wxT(
"vertspace" ), m_vertSpace );
396 if ( xmlparts == a2dXmlSer_attrib )
407 #endif //wxART2D_USE_CVGIO
424 hitEvent.
m_how = HitTestRectangle( hitEvent.
m_relx, hitEvent.
m_rely, xmin, ymin, xmax, ymax, pw + margin );
438 for ( i = 0 ; i < GetRows(); i++ )
440 for ( j = 0 ; j < GetColumns(); j++ )
457 offsetXY.
Translate( -GetHorzSpace()*GetColumns(), GetVertSpace() );
470 a2dLibraryReference::a2dLibraryReference()
473 m_layer = GetHabitat()->GetSymbolLayer();
474 SetName( wxT(
"libraryref" ) );
480 m_text =
new a2dText( wxT(
"libraryref" ), -m_height / 2 , -m_height / 2 - m_height / 5,
a2dFont( m_height / 5, wxSWISS ) );
486 a2dLibraryReference::a2dLibraryReference(
double x,
double y,
a2dCanvasObject* obj,
const wxString& name,
488 const a2dFont& font,
int imagew,
int imageh )
490 :
a2dImage( wxImage( imagew, imageh ), x, y, totalheight, totalheight )
495 m_layer = GetHabitat()->GetSymbolLayer();
497 RenderObject( symbol ? symbol : obj, imagew, imageh );
501 if ( !name.IsEmpty() )
504 lfont.
SetSize( totalheight / 5.0 );
505 m_text =
new a2dText( name, -totalheight / 2, -totalheight / 2 - totalheight / 5, lfont );
508 m_text->SetLayer( GetHabitat()->GetSymbolLayer() );
517 m_height = totalheight;
518 m_width = totalheight;
528 m_height = other.m_height;
529 m_width = other.m_width;
530 m_description = other.m_description;
532 m_symbol = other.m_symbol;
533 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
535 CurrentSmartPointerOwner =
this;
539 a2dLibraryReference::~a2dLibraryReference()
547 m_symbol->
Walker(
this, handler );
550 m_text->
Walker(
this, handler );
620 m_text->
Render( ic, clipparent );
623 #if wxART2D_USE_CVGIO
632 #endif //wxART2D_USE_CVGIO
636 if ( m_text && m_text->
IsHitWorld( ic, hitEvent ) )
646 a2dExternalReference::a2dExternalReference()
649 m_text = wxT(
"nameref" );
653 a2dExternalReference::a2dExternalReference(
double x,
double y,
a2dCanvasObject* obj,
const wxString& text,
double angle,
const a2dFont& font )
654 :
a2dText( text, x, y, font, angle )
656 if ( m_text.IsEmpty() && obj )
665 :
a2dText( other, options, refs )
670 a2dExternalReference::~a2dExternalReference()
697 a2dNameReference::a2dNameReference()
700 m_text = wxT(
"nameref" );
703 a2dNameReference::a2dNameReference(
double x,
double y,
a2dCanvasObject* obj,
const wxString& text,
double angle,
const a2dFont& font )
704 :
a2dText( text, x, y, font, angle )
706 if (
m_text.IsEmpty() && obj )
715 :
a2dText( other, options, refs )
720 a2dNameReference::~a2dNameReference()
758 wxString name = other->
GetName();
788 #if wxART2D_USE_CVGIO
792 if ( xmlparts == a2dXmlSer_attrib )
815 if ( xmlparts == a2dXmlSer_attrib )
824 if ( parser.
GetTagName() != wxT(
"derived" ) )
836 #endif //wxART2D_USE_CVGIO
842 a2dSymbolicReference::a2dSymbolicReference()
848 a2dSymbolicReference::a2dSymbolicReference(
double x,
double y,
a2dCanvasObject* obj )
858 m_object = other.m_object;
861 a2dSymbolicReference::~a2dSymbolicReference()
870 #if wxART2D_USE_CVGIO
880 #endif //wxART2D_USE_CVGIO
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
a2dCanvasObject * GetCanvasObject()
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
virtual void MakeReferencesUnique()
All direct a2dCanvasObject which are part of this one are made unique.
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
virtual void Render(a2dIterC &ic, OVERLAP clipparent)
Render this object to the active a2dDrawingPart.
void SetRoot(a2dDrawing *root, bool recurse=true)
Sets this object to a a2dCanvasDocument.
virtual bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
a2dCanvasObjectList * CreateChildObjectList()
create and get the list where the child objects are stored in.
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
void RemoveHierarchy()
move childs of childs and members which have hierarchy one level up to this object its child list...
a2dObject * LoadOneObject(wxObject *parent)
load one object from a CVG file.
bool HasAttribute(const wxString &attrib)
Does the current tag have this attribute?
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
virtual a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
void AddPending(a2dIterC &ic)
search objects ( if nested recursive ) that have the pending flag Set
int WorldToDeviceY(double y) const
convert y from world to device coordinates
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
virtual void PopTransform(void)
Recall the previously saved user-to-world transform off the matrix stack.
void SetRelease(bool value)
set release flag
XMLeventType Next()
Walks to next element and returns event type.
bool ResolveOrAdd(a2dSmrtPtr< a2dObject > *storedHere, const wxString &id=wxT(""))
try to resolve the object that is in storedHere when it is a reference.
class to map references to objects stored in XML, in order to make the connection later on...
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
a2dDrawing * m_root
root group for rendering and accessing the canvas's also contains layer settings
a2dCanvasOFlags m_flags
holds flags for objects
a2dNameReference is a text like object, but next to that it holds a reference
a2dSymbolicReference does not render referenced object.
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
bool IsHit() const
true if this is a hit
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
virtual void RemoveHierarchy()
move childs of childs and members which have hierarchy one level up to this object its child list...
Input and output handler for the XmlSer format.
UpdateMode
Various mode flags for Update.
virtual void DoAddPending(a2dIterC &ic)
called by addPending
virtual void SetPending(bool pending)
set this object pending for update
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
bool m_visiblechilds
child objects are visible or not
virtual void DoAddPending(a2dIterC &ic)
called by addPending
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
void RemoveHierarchy()
move childs of childs and members which have hierarchy one level up to this object its child list...
double GetTransformedHitMargin()
transformed to object its coordinate system
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
wxUint16 m_layer
layer of object, default wxLAYER_DEFAULT
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
OVERLAP GetClipStatus(a2dIterC &ic, OVERLAP clipparent)
used for deciding if the object needs to be rendered against the current clipping area of the active ...
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
a2dCanvasObject is the base class for Canvas Objects.
void SetSize(double size)
Set the font size.
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
a2dCanvasObjectArrayReference is an array of a reference to any a2dCanvasObject derived class...
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
special a2dCanvasObject which are used to create hierarchy different from the standard a2dCanvasObjec...
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
virtual void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
a2dCanvasObject * GetCanvasObject()
a2dCanvasObject * GetSymbol()
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Io handler to iterate through a a2dDocument.
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
a2dCanvasObjectPtr m_object
object to which a reference is held.
bool GetCheck() const
general flag use at will.
void WriteNewLine()
Writes a new line and takes care of indentation.
a2dText is an abstract base class.
virtual bool LinkReference(a2dObject *other)
when resolving this refrence via a a2dIOHandler, this is used.
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
const a2dBoundingBox & Translate(a2dPoint2D &)
translate with given vector
virtual a2dBoundingBox GetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_CHILDREN) const
Get boundingbox without the affine matrix transform included.
double GetMinX() const
get minimum X of the boundingbox
void SetCanvasObject(a2dCanvasObject *object)
set the object that is referenced
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
This is used to recursively walk through an object tree.
a2dDrawer2D * GetDrawer2D() const
get current a2dDrawer2D
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
a2dImage (will scale/rotate image when needed)
a2dExternalReference is a text like object, but next to that it holds a reference ...
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
a2dCanvasObjectPtr m_object
object to which a reference is hold.
int WorldToDeviceX(double x) const
convert x from world to device coordinates
virtual void DrawLine(double x1, double y1, double x2, double y2)
Draw line in world coordinates.
Input and output handler for the XmlSer format.
bool m_ignoreLayer
when this is set DoRender() is called even if layer of the object is not the layer to be rendered...
a2dCanvasObject(double x=0, double y=0)
constructor called by derived objects
void RenderObject(a2dCanvasObject *torender, int imagew=100, int imageh=100)
render the given object into the image of this object
void SetCheck(bool check)
general flag use at will.
A 2x3 affine matrix class for 2D transformations.
double GetMaxX() const
get maximum X of the boundingbox
a2dCanvasObjectPtr m_objectRef
object to which a reference is held.
while iterating a a2dCanvasDocument, this holds the context.
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
void MapBbox(const a2dAffineMatrix &matrix)
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
a2dCanvasObject * GetCanvasObject()
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
int RequireAttributeValueInt(const wxString &attrib)
Forces an attribute and returns its integer value.
int GetOwnedBy()
like it to be protected, but this does not work with wxList macros
void SetSymbol(a2dCanvasObject *symbol)
set the object that is used as icon
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
bool GetRelease() const
get release flag
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
bool GetRenderChildDerived()
when set child object in derived a2dCanvasObject are rendered, else only the object itself...
void MakeReferencesUnique()
All direct a2dCanvasObject which are part of this one are made unique.
This is the base class for all kinds of property id's for a2dObject.
double GetMaxY() const
get maximum Y of the boundingbox
double GetWidth() const
returns width of the boundingbox
An object of this class will update a a2dIterC with the required information.
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
wxString GetTagName()
Returns name of the current XML tag.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
bool Translate(double x, double y)
Translate by dx, dy:
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
a2dCanvasObject * GetCanvasObject()
void SetCanvasObject(a2dCanvasObject *object)
set the object that is referenced
a2dCanvasObject * IsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
If the position (x,y) is within the object return this.
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
void SetCanvasObject(a2dCanvasObject *object)
set the object that is referenced
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
double GetMinY() const
get minimum Y of the boundingbox
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
a2dLibraryReference is a symbol object, it holds a reference
virtual void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
write all needed to an XML type of file called the CVG format
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
virtual bool LinkReference(a2dObject *other)
when resolving this refrence via a a2dIOHandler, this is used.
This template class is for property ids with a known data type.
a2dBoundingBox m_bbox
boundingbox in world coordinates
Walker taking iterative context into account.
double RequireAttributeValueDouble(const wxString &attrib)
Forces an attribute and returns its double value.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
virtual a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
wxString m_text
the text to display
const a2dAffineMatrix & GetTransform() const
Get the accumulated transform up to and including m_lworld of the current object. ...
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
CloneOptions
options for cloning
void WalkerWithContext(a2dIterC &ic, wxObject *parent, a2dWalkerIOHandlerWithContext &handler)
This is used to recursively walk through an object tree.
structure to give as parameter to member functions of a2dCanvasObject
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
wxInt64 GetUniqueSerializationId() const
return a unique id for this object
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
virtual void PushIdentityTransform()
push no transform, to draw directly in device coordinates
void SetCanvasObject(a2dCanvasObject *object)
set the object that is referenced
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
general canvas module declarations and classes
void WriteStartElement(const wxString &name, bool newLine=true)
Writes start tag which has no attributes.