00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _KEYIO_H
00019 #define _KEYIO_H
00020
00021 #include <wx/wfstream.h>
00022
00023 #include "a2dprivate.h"
00024
00025 #if wxART2D_USE_KEYIO
00026
00027 #include "wx/canvas/layerinf.h"
00028 #include "wx/gdsio/gdsio.h"
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class A2DCANVASDLLEXP a2dIOHandlerKeyIn : public a2dIOHandlerStrIn
00044 {
00045
00046 public:
00047
00048 a2dIOHandlerKeyIn();
00049 ~a2dIOHandlerKeyIn();
00050
00051 bool LinkReferences();
00052
00053 wxChar PeekNextC();
00054
00055 void IncC();
00056
00057 virtual bool CanLoad( a2dDocumentInputStream& stream, const wxObject* obj = NULL, wxClassInfo* docClassInfo = NULL );
00058
00059 virtual bool Load( a2dDocumentInputStream& stream, wxObject* doc );
00060
00061 virtual void InitializeLoad( );
00062
00063 virtual void ResetLoad();
00064
00065 protected:
00066
00067 bool GetCommand();
00068
00069 bool NormalWord();
00070 bool QuotedString();
00071 bool BracedString();
00072 bool Comment();
00073
00074 bool Blanks();
00075
00076 bool Word();
00077
00078 bool ReadItem(const wxString& type);
00079
00080 bool SkipXYData();
00081
00082 double ReadDouble();
00083
00084
00085 void SetDataTypeProperty( a2dCanvasObject* toobject, wxUint16 type );
00086
00087 void ReadKey();
00088 bool ReadBgnlib();
00089 bool ReadProperties(a2dCanvasObject* parent);
00090 bool ReadBoundary( a2dCanvasObject* parent );
00091 bool ReadSurface( a2dCanvasObject* parent );
00092 bool ReadPath( a2dCanvasObject* parent );
00093 bool ReadText( a2dCanvasObject* parent );
00094 bool ReadStructureReference( a2dCanvasObject* parent );
00095 bool ReadArrayReference( a2dCanvasObject* parent );
00096 bool ReadNode( a2dCanvasObject* parent );
00097 bool ReadBox( a2dCanvasObject* parent );
00098 bool ReadCircle( a2dCanvasObject* parent );
00099 bool ReadArc( a2dCanvasObject* parent );
00100 bool ReadLine( a2dCanvasObject* parent );
00101 bool ReadImage( a2dCanvasObject* parent );
00102
00103 bool ReadElflags( a2dCanvasObject* object );
00104 bool ReadGdsHeader();
00105 bool ReadLayer( a2dCanvasObject* object );
00106 bool ReadLibrarySettings();
00107 bool Read( a2dPoint2D& _Point );
00108 bool ReadStrans( Strans& _Strans);
00109 bool ReadStructure( a2dCanvasObject* parent );
00110 bool ReadElement( a2dCanvasObject* parent );
00111 bool ReadTextBody();
00112
00113 bool ReadPolygon( a2dVertexList* segments );
00114 bool ReadPolyline( a2dVertexList* segments );
00115
00116 void SetFlags( a2dCanvasObject* Element);
00117
00118
00119 bool m_back;
00120
00121
00122 wxString m_keyword;
00123
00124 wxString m_value;
00125
00126
00127 int m_recordtype;
00128
00129
00130 wxUint32 m_linenumber;
00131
00132 wxChar a;
00133 wxString m_error_mes;
00134 wxString m_b;
00135
00136
00137 TWO_G_BYTE_UNSIGNED_INTEGER m_recordsize;
00138
00139
00140 int m_mapping[wxMAXLAYER];
00141
00142
00143 a2dCanvasDocument* m_doc;
00144
00145 double m_scale_in;
00146
00147 double m_userunits_out;
00148
00149 int m_objectFlags;
00150
00151 wxUint16 m_lastElementLayer;
00152 };
00153
00154
00155
00156
00157
00158
00159
00160
00161 class A2DCANVASDLLEXP a2dIOHandlerKeyOut : public a2dIOHandlerStrOut
00162 {
00163
00164 public:
00165
00166 a2dIOHandlerKeyOut();
00167 ~a2dIOHandlerKeyOut();
00168
00169 bool LinkReferences();
00170
00171 bool CanSave( const wxObject* obj = NULL );
00172
00173 virtual bool Save( a2dDocumentOutputStream& stream, const wxObject* doc );
00174
00175 virtual void InitializeSave( );
00176
00177 virtual void ResetSave();
00178
00179
00180 void SetSaveTextAsVpath( bool textAsPath ) { m_textAsPath = textAsPath; }
00181
00182
00183 bool GetSaveTextAsVpath() { return m_textAsPath; }
00184
00185
00186 void SetFormat( const wxString& format ) { m_format = format; }
00187
00188
00189 void SetFromViewAsTop( bool fromViewAsTop ) { m_fromViewAsTop = fromViewAsTop; }
00190
00191
00192 bool GetFromViewAsTop() { return m_fromViewAsTop; }
00193
00194 private:
00195
00196 wxString m_format;
00197
00198 protected:
00199
00200
00201 virtual void WriteDouble(double d)
00202 {
00203 wxString str;
00204 str.Printf( m_format.c_str(), d);
00205 WriteString(str);
00206 }
00207
00208 a2dIOHandlerKeyOut& operator<<(const wxChar *string);
00209 a2dIOHandlerKeyOut& operator<<(const wxString& string);
00210 a2dIOHandlerKeyOut& operator<<(char c);
00211 #if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE
00212 a2dIOHandlerKeyOut& operator<<(wchar_t wc);
00213 #endif // wxUSE_UNICODE
00214 a2dIOHandlerKeyOut& operator<<(wxInt16 c);
00215 a2dIOHandlerKeyOut& operator<<(wxInt32 c);
00216 a2dIOHandlerKeyOut& operator<<(wxUint16 c);
00217 a2dIOHandlerKeyOut& operator<<(wxUint32 c);
00218 a2dIOHandlerKeyOut& operator<<(double f);
00219 a2dIOHandlerKeyOut& operator<<(float f);
00220
00221 const wxChar Endl();
00222
00223 void WriteProperties( const a2dNamedPropertyList& props );
00224
00225 void WriteFlags( int i );
00226
00227 void Write(Strans* Strans);
00228
00229 void SetFlags( a2dCanvasObject* Element);
00230
00231 void WritePoint( double xi, double yi );
00232
00233 void WriteSegment( const a2dAffineMatrix& lworld, a2dLineSegment *prevSegment, a2dLineSegment *Segment );
00234
00235 void WriteVpath( const a2dAffineMatrix& lworld, const a2dVpath* path, int layer, int datatype, int pathtype, double width );
00236
00237 void WritePoly( const a2dAffineMatrix& lworld , a2dVertexList* vlist, bool close );
00238
00239 void WriteVertexArrayPolyline( const a2dAffineMatrix& lworld, a2dVertexArray* points, int layer, int datatype, int pathtype, double width, bool spline = false, bool close = true );
00240
00241 void WriteVertexListPolyline( const a2dAffineMatrix& lworld, a2dVertexList* points, int layer, int datatype, int pathtype, double width, bool spline= false, bool close = true );
00242
00243 void WriteVertexArrayPolygon( const a2dAffineMatrix& lworld, a2dVertexArray* points, int layer, int datatype, double width, bool spline = false, bool close = true );
00244
00245 void WriteVertexListPolygon( const a2dAffineMatrix& lworld, a2dVertexList* points, int layer, int datatype, double width, bool spline = false, bool close = true );
00246
00247 void SaveStructure( a2dCanvasObject* object, a2dCanvasObjectList* towrite );
00248
00249 void Save( a2dCanvasObject* object, a2dCanvasObjectList* towrite );
00250
00251 void DoSave( a2dPolylineL* obj, a2dCanvasObjectList* towrite );
00252
00253 void DoSave( a2dPolygonL* obj, a2dCanvasObjectList* towrite );
00254
00255 void DoSave( a2dSurface* surface, a2dCanvasObjectList* towrite );
00256
00257 void DoSave( a2dText* obj, a2dCanvasObjectList* towrite );
00258
00259 void DoSave( a2dTextGDS* obj, a2dCanvasObjectList* towrite );
00260
00261 void DoSave( a2dCanvasObjectReference* obj, a2dCanvasObjectList* towrite );
00262
00263 void DoSave( a2dCanvasObjectArrayReference* obj, a2dCanvasObjectList* towrite );
00264
00265 void DoSave( a2dCircle* Circle, a2dCanvasObjectList* towrite );
00266
00267
00268 int m_mapping[wxMAXLAYER];
00269
00270
00271 a2dCanvasDocument* m_doc;
00272
00273 double m_scale_out;
00274
00275 double m_userunits_out;
00276
00277 int m_objectFlags;
00278
00279 unsigned int m_points_written;
00280
00281 wxUint16 m_lastElementLayer;
00282
00283
00284 bool m_textAsPath;
00285
00286 bool m_fromViewAsTop;
00287 };
00288
00289 #endif //wxART2D_USE_KEYIO
00290
00291
00292 #endif //_KEYIO_H