00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _WX_CANVASSVGIO_H_
00013 #define _WX_CANVASSVGIO_H_
00014
00015 #include <map>
00016 #include "wx/canvas/xmlpars.h"
00017 #include "wx/canvas/layerinf.h"
00018 #include "wx/canvas/canprop.h"
00019 #include "wx/canvas/vpath.h"
00020 #include "wx/canvas/polygon.h"
00021
00022 #if wxART2D_USE_SVGIO
00023
00024 #if (wxART2D_USE_XMLPARSE == 0)
00025 #error Cannot build with SVG support without XMLPARSE module
00026 #else
00027 #include "wx/xmlparse/genxmlpars.h"
00028 #include "wx/xmlparse/xmlencode.h"
00029 #endif
00030
00031 using namespace std;
00032
00033
00034
00035
00036
00037 class A2DCANVASDLLEXP a2dIOHandlerSVGIn : public a2dIOHandlerXMLPull
00038 {
00039 public:
00040
00041 a2dIOHandlerSVGIn();
00042
00043 ~a2dIOHandlerSVGIn();
00044
00045 virtual bool CanLoad( a2dDocumentInputStream& stream, const wxObject* obj = NULL, wxClassInfo* docClassInfo = NULL );
00046
00047 virtual bool Load( a2dDocumentInputStream& stream , wxObject* doc );
00048
00049 protected:
00050
00051 bool LoadSvg( a2dCanvasDocument* doc );
00052 bool LoadSvgGroup( a2dCanvasObject* parent );
00053 bool LoadSvgAnchor( a2dCanvasObject* parent );
00054 bool LoadSvgGroupElement( a2dCanvasObject* parent );
00055
00056 bool LoadSvgRect( a2dCanvasObject* parent );
00057
00058 bool LoadSvgCircle( a2dCanvasObject* parent );
00059
00060 bool LoadSvgEllipse( a2dCanvasObject* parent );
00061
00062 bool LoadSvgText( a2dCanvasObject* parent );
00063
00064 bool ParsePoints( a2dVertexList* points );
00065
00066 bool LoadSvgPolygon( a2dCanvasObject* parent );
00067
00068 bool LoadSvgPolyline( a2dCanvasObject* parent );
00069
00070 bool LoadSvgLine( a2dCanvasObject* parent );
00071
00072 bool ParsePathPoints( a2dVpath* points );
00073
00074 bool LoadSvgPath( a2dCanvasObject* parent );
00075
00076 bool LoadSvgImage( a2dCanvasObject* parent );
00077
00078 bool ParseSvgTransForm( a2dCanvasObject* parent );
00079
00080 bool ParseSvgStyle( a2dCanvasObject* parent );
00081
00082 bool ParseSvgLink( a2dCanvasObject* parent );
00083
00084
00085 a2dCanvasDocument* m_doc;
00086
00087
00088 a2dCanvasObjectPtr m_currentobject;
00089
00090
00091 a2dFill m_fill;
00092
00093
00094 a2dStroke m_stroke;
00095 };
00096
00097
00098
00099
00100
00101 class A2DCANVASDLLEXP a2dIOHandlerSVGOut : public a2dIOHandlerXMLWrite
00102 {
00103 public:
00104
00105 a2dIOHandlerSVGOut();
00106
00107 ~a2dIOHandlerSVGOut();
00108
00109
00110 void SetShowObject( a2dCanvasObject* showObject ) { m_showObject = showObject; };
00111
00112
00113
00114
00115
00116 a2dCanvasObject* GetShowObject() const { return m_showObject; }
00117
00118 void SetIterC( a2dIterC& ic ) { m_ic = ⁣ }
00119
00120 bool CanSave( const wxObject* obj = NULL );
00121
00122 virtual bool Save( a2dDocumentOutputStream& stream, const wxObject* doc );
00123
00124 protected:
00125 void Save( const a2dCanvasObject* object, int layer );
00126 void SetSVGStyle( const a2dFill& fill, const a2dStroke& stroke, const a2dCanvasObject* object, int layer );
00127 void SaveGradient( const a2dFill& fill, const a2dCanvasObject* object );
00128
00129
00130 void CreateSVGSpline( const a2dVertexList* vertexList, bool asPolygon = false, const wxString &style = _T(""));
00131 void CreateSVGSpline( const a2dVertexArray* vertexArray, bool asPolygon = false, const wxString &style = _T(""));
00132
00133
00134 void DoSave( const a2dCanvasObject* object, int layer );
00135
00136 void DoSaveProperty( const a2dCanvasObject* object, const a2dNamedProperty* property, int layer );
00137
00138 wxString UniqueName(wxString baseName);
00139
00140
00141 a2dCanvasDocument* m_doc;
00142
00143
00144 a2dCanvasObjectPtr m_currentobject;
00145
00146
00147 a2dFill m_fill;
00148
00149
00150 a2dStroke m_stroke;
00151
00152 a2dIterC* m_ic;
00153
00154
00155 a2dCanvasObject* m_showObject;
00156
00157 map<wxString, int> m_nameMap;
00158 };
00159 #endif //wxART2D_USE_SVGIO
00160
00161 #endif