26 #include "a2dprivate.h"
35 #include "wx/editor/candoc.h"
44 #include <wx/datetime.h>
58 bool a2dIOHandlerKeyIn::Blanks()
62 while ( a == wxT(
' ' ) || a == wxT(
'\t' ) || a == wxT(
'\\' ) || a == 0xd )
64 if ( a == wxT(
'\\' ) )
66 if ( PeekNextC() != wxT(
'\n' ) )
78 bool a2dIOHandlerKeyIn::Comment()
82 m_error_mes = wxT(
"wrong comment" );
90 while( a != wxT(
'\0' ) )
92 if ( a == wxT(
'\\' ) )
95 if ( a == wxT(
'\n' ) )
102 if ( a == wxT(
'\n' ) )
112 bool a2dIOHandlerKeyIn::Word()
117 if ( a == wxT(
'"' ) )
119 if ( !QuotedString() )
122 else if ( a == wxT(
'{' ) )
124 if ( !BracedString() )
137 bool a2dIOHandlerKeyIn::NormalWord()
139 while( a != wxT(
' ' ) && a != wxT(
'\t' ) && a != wxT(
'\0' ) && a != wxT(
'\n' ) && a != wxT(
';' ) )
141 if ( a == wxT(
'\\' ) )
145 if ( a == wxT(
' ' ) || a == wxT(
'\t' ) || a == wxT(
'\0' ) || a == wxT(
';' ) )
162 bool a2dIOHandlerKeyIn::QuotedString()
164 if( a != wxT(
'"' ) )
166 m_error_mes = wxT(
"wrong quotedstring, begin quote missing" );
172 while( a != wxT(
'"' ) && a != wxT(
'\0' ) )
174 if ( a == wxT(
'\\' ) )
177 if ( a == wxT(
'\0' ) )
190 if( a != wxT(
'"' ) )
192 m_error_mes = wxT(
"wrong quotedstring, end quote missing" );
202 bool a2dIOHandlerKeyIn::BracedString()
204 if( a != wxT(
'{' ) )
206 m_error_mes = wxT(
"wrong bracedstring, begin brace missing" );
213 while( ( a != wxT(
'}' ) || brnr ) && a != wxT(
'\0' ) )
218 if ( a == wxT(
'\0' ) )
227 if ( a == wxT(
'{' ) )
230 if ( a == wxT(
'}' ) )
239 if( a != wxT(
'}' ) )
241 m_error_mes = wxT(
"wrong bracedstring, end brace missing" );
249 bool a2dIOHandlerKeyIn::GetCommand()
262 while( a == wxT(
'\0' ) || a == wxT(
'\n' ) || a == wxT(
';' ) )
264 if ( a == wxT(
'\0' ) )
272 if ( a == wxT(
'\0' ) )
274 else if ( a == wxT(
'#' ) )
278 m_error_mes = wxT(
"comment wrong" );
296 if ( m_error_mes.Len() )
302 if( a == wxT(
'\0' ) || a == wxT(
'\n' ) || a == wxT(
';' ) )
306 m_error_mes = wxT(
"; or EOL expected" );
313 if( a == wxT(
'\0' ) || a == wxT(
'\n' ) || a == wxT(
';' ) )
323 bool a2dIOHandlerKeyIn::ReadItem(
const wxString& type )
341 if ( !m_error_mes.IsEmpty() )
343 m_b.Printf( _T(
"Could not Parse line %d: \n Error: %s" ),
346 throw GDS_Error( m_b, wxT(
"Command Parsing Error" ) );
363 buf = wxT(
"Argument missing (in " );
367 if ( !
m_keyword.CmpNoCase( wxT(
"BGNLIB" ) ) );
369 else if ( !
m_keyword.CmpNoCase( wxT(
"BGNSTR" ) ) );
370 else if ( !
m_keyword.CmpNoCase( wxT(
"BOUNDARY" ) ) );
371 else if ( !
m_keyword.CmpNoCase( wxT(
"SURFACE" ) ) );
372 else if ( !
m_keyword.CmpNoCase( wxT(
"LINE" ) ) );
373 else if ( !
m_keyword.CmpNoCase( wxT(
"CIRCLE" ) ) );
374 else if ( !
m_keyword.CmpNoCase( wxT(
"BOX" ) ) );
375 else if ( !
m_keyword.CmpNoCase( wxT(
"PATH" ) ) );
376 else if ( !
m_keyword.CmpNoCase( wxT(
"TEXT" ) ) );
377 else if ( !
m_keyword.CmpNoCase( wxT(
"AREF" ) ) );
378 else if ( !
m_keyword.CmpNoCase( wxT(
"SREF" ) ) );
379 else if ( !
m_keyword.CmpNoCase( wxT(
"ARC" ) ) );
380 else if ( !
m_keyword.CmpNoCase( wxT(
"ENDEL" ) ) );
381 else if ( !
m_keyword.CmpNoCase( wxT(
"ENDLIB" ) ) );
382 else if ( !
m_keyword.CmpNoCase( wxT(
"ENDMASKS" ) ) );
399 bool a2dIOHandlerKeyIn::SkipXYData()
401 if ( !ReadItem( wxT(
"xy" ) ) )
406 if ( ( ReadItem( wxT(
"x" ) ) ) ||
407 ( ReadItem( wxT(
"y" ) ) ) ||
408 ( ReadItem( wxT(
"xm" ) ) ) ||
409 ( ReadItem( wxT(
"ym" ) ) ) ||
410 ( ReadItem( wxT(
"xo" ) ) ) ||
411 ( ReadItem( wxT(
"yo" ) ) )
421 double a2dIOHandlerKeyIn::ReadDouble()
423 return m_scale_in * wxAtof(
m_value );
426 wxChar a2dIOHandlerKeyIn::PeekNextC()
428 wxChar p = ( wxChar )
Peek();
432 void a2dIOHandlerKeyIn::IncC()
434 a = ( wxChar )
GetC();
436 if ( a == wxT(
'\0' ) || a == wxT(
'\n' ) )
442 if ( a == wxChar( EOF ) )
444 if ( a == wxT(
'\r' ) )
450 a2dIOHandlerKeyIn::a2dIOHandlerKeyIn()
454 m_asCameleons =
false;
457 m_lastElementLayer = 0;
464 a2dIOHandlerKeyIn::~a2dIOHandlerKeyIn()
502 if ( !ReadItem( wxT(
"header" ) ) )
519 bool a2dIOHandlerKeyIn::LinkReferences()
530 a2dCanvasObjectList::iterator delnode = rootchild;
532 if ( ( *delnode )->GetCheck() )
549 if ( wxFileExists( path ) )
561 for ( i = 0; i < wxMAXLAYER; i++ )
563 for ( i = 0; i < wxMAXLAYER; i++ )
568 wxASSERT_MSG( layerIndex >= 0 && layerIndex < wxMAXLAYER, wxT(
"InMap must be > wxMAXLAYER" ) );
572 for ( i = 0; i < wxMAXLAYER; i++ )
592 void a2dIOHandlerKeyIn::ReadKey()
613 if ( !ReadItem( wxT(
"header" ) ) )
614 throw GDS_Error( wxT(
"HEADER is missing (in KEY-file)" ) );
618 throw GDS_Error( wxT(
"BGNLIB is missing (in KEY-file)" ) );
619 if ( !ReadLibrarySettings() )
620 throw GDS_Error( wxT(
"LIBNAME is missing (in KEY-file)" ) );
633 if ( !ReadItem( wxT(
"endlib" ) ) )
634 throw GDS_Error( wxT(
"ENDLIB is missing (in KEY-file)" ) );
647 throw GDS_Error( wxT(
"no structures found" ) );
681 bool a2dIOHandlerKeyIn::ReadBgnlib()
683 if( !ReadItem( wxT(
"bgnlib" ) ) )
685 if( !ReadItem( wxT(
"lastmod" ) ) )
686 throw GDS_Error( wxT(
"BGNLIB: LASTMOD is missing (in KEY-file)" ) );
688 wxString _int_str_ptr =
m_value;
697 year = wxAtoi( _int_str_ptr );
698 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
699 month = wxAtoi( _int_str_ptr ) - 1;
700 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
701 day = wxAtoi( _int_str_ptr );
702 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
" " ) ) + 2;
703 hour = wxAtoi( _int_str_ptr );
704 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
705 minute = wxAtoi( _int_str_ptr );
706 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
707 second = wxAtoi( _int_str_ptr );
711 if( !ReadItem( wxT(
"lastacc" ) ) )
712 throw GDS_Error( wxT(
"BGNLIB: LASTACC is missing (in KEY-file)" ) );
716 year = wxAtoi( _int_str_ptr );
717 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
718 month = wxAtoi( _int_str_ptr ) - 1;
719 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
720 day = wxAtoi( _int_str_ptr );
721 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
" " ) ) + 2;
722 hour = wxAtoi( _int_str_ptr );
723 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
724 minute = wxAtoi( _int_str_ptr );
725 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
726 second = wxAtoi( _int_str_ptr );
728 m_doc->
GetAccessTime().Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
734 bool a2dIOHandlerKeyIn::ReadLibrarySettings()
736 if( !ReadItem( wxT(
"libname" ) ) )
737 throw GDS_Error( wxT(
"libname record missing (in KEY)" ), wxT(
"Error" ) );
742 ReadItem( wxT(
"reflibs" ) );
743 ReadItem( wxT(
"fonts" ) );
744 ReadItem( wxT(
"attrtable" ) );
745 ReadItem( wxT(
"generations" ) );
746 if ( ReadItem( wxT(
"format" ) ) )
749 while( !ReadItem( wxT(
"endmasks" ) ) )
751 if ( ReadItem( wxT(
"mask" ) ) )
762 if ( ReadItem( wxT(
"layernr" ) ) )
765 wxInt16 internalMappedTo =
m_mapping[ layernr ];
767 if ( info != wxNullLayerInfo )
770 layerfill = info->GetFill();
771 layerstroke = info->GetStroke();
774 else if ( ReadItem( wxT(
"color" ) ) )
778 if ( !fillColour.IsEmpty() )
780 if ( fillColour.GetChar( 0 ) == wxT(
'#' ) )
781 fill =
HexToColour( fillColour.After( wxT(
'#' ) ) );
784 fill = wxTheColourDatabase->Find( fillColour );
792 else if ( ReadItem( wxT(
"trans" ) ) )
795 else if ( ReadItem( wxT(
"binding" ) ) )
798 else if ( ReadItem( wxT(
"linestyle" ) ) )
801 layerstroke.SetStyle( style );
803 else if ( ReadItem( wxT(
"stream" ) ) )
806 else if ( ReadItem( wxT(
"iges" ) ) )
809 else if ( ReadItem( wxT(
"type" ) ) )
812 else if ( ReadItem( wxT(
"dxf" ) ) )
815 else if ( ReadItem( wxT(
"plotmode" ) ) )
817 wxUint16 shapestyle = wxAtoi(
m_value );
833 else if ( ReadItem( wxT(
"protected" ) ) )
836 else if ( ReadItem( wxT(
"visible" ) ) )
839 else if ( ReadItem( wxT(
"patternnr" ) ) )
842 else if (
m_keyword.CmpNoCase( wxT(
"mask" ) ) == 0 ||
m_keyword.CmpNoCase( wxT(
"endmasks" ) ) == 0 )
847 if ( info != wxNullLayerInfo )
856 if( !ReadItem( wxT(
"units" ) ) )
860 if( !ReadItem( wxT(
"userunits" ) ) )
861 throw GDS_Error( wxT(
"USERUNITS missing (in KEY-file)" ) );
862 m_userunits_out = ( double )wxAtof(
m_value );
864 if( !ReadItem( wxT(
"physunits" ) ) )
865 throw GDS_Error( wxT(
"PHYSUNITS missing (in KEY-file)" ) );
867 double metersScale = ( ( double )wxAtof(
m_value ) ) / m_userunits_out;
872 unit =
a2dDoMu( 1, metersScale );
885 if ( ReadBoundary( parent ) ||
886 ReadSurface( parent ) ||
887 ReadPath( parent ) ||
888 ReadStructureReference( parent ) ||
889 ReadArrayReference( parent ) ||
890 ReadText( parent ) ||
891 ReadNode( parent ) ||
894 ReadCircle( parent ) ||
895 ReadLine( parent ) ||
906 if ( !ReadItem( wxT(
"endel" ) ) )
907 throw GDS_Error( wxT(
"ENDEL is missing (in KEY-file) (too many points in element?)" ) );
915 if ( !ReadItem( wxT(
"property" ) ) )
925 if ( ReadItem( wxT(
"proptype" ) ) )
927 if ( ReadItem( wxT(
"propvalue" ) ) )
932 if ( type == wxT(
"string" ) )
938 parent->AddPropertyId( propid );
942 else if ( type == wxT(
"integer" ) )
948 parent->AddPropertyId( propid );
952 else if ( type == wxT(
"real" ) )
958 parent->AddPropertyId( propid );
961 value.ToDouble( &doubleval );
964 else if ( type == wxT(
"bool" ) )
970 parent->AddPropertyId( propid );
972 propid->
SetPropertyToObject( parent, value.IsSameAs( wxT(
"true" ),
true ) ?
true : false );
975 wxLogWarning( wxT(
"KEYIO : property type: %s is not implemented" ), type.c_str() );
979 while ( ReadItem( wxT(
"property" ) ) );
986 if ( !ReadItem( wxT(
"parameter" ) ) )
996 if ( ReadItem( wxT(
"parametertype" ) ) )
998 if ( ReadItem( wxT(
"parametervalue" ) ) )
1003 if ( type == wxT(
"string" ) )
1009 parent->AddPropertyId( propid );
1013 else if ( type == wxT(
"integer" ) )
1019 parent->AddPropertyId( propid );
1023 else if ( type == wxT(
"real" ) )
1029 parent->AddPropertyId( propid );
1032 value.ToDouble( &doubleval );
1035 else if ( type == wxT(
"bool" ) )
1041 parent->AddPropertyId( propid );
1043 propid->
SetPropertyToObject( parent, value.IsSameAs( wxT(
"true" ),
true ) ?
true : false );
1046 wxLogWarning( wxT(
"KEYIO : parameter type: %s is not implemented" ), type.c_str() );
1050 while ( ReadItem( wxT(
"parameter" ) ) );
1059 if ( !ReadItem( wxT(
"surface" ) ) )
1065 ReadElflags( Surface );
1067 ReadItem( wxT(
"plex" ) );
1069 if ( !ReadLayer( Surface ) )
1070 throw GDS_Error( wxT(
"Surface: LAYER missing (in KEY-file)" ) );
1072 ReadItem( wxT(
"datatype" ) );
1075 if ( ReadItem( wxT(
"spline" ) ) )
1078 if ( ReadItem( wxT(
"width" ) ) )
1084 throw GDS_Error( wxT(
"Header: XY missing (in Boundary)" ) );
1086 while ( ReadItem( wxT(
"hole" ) ) )
1089 if ( !ReadPolygon( rlist ) )
1090 throw GDS_Error( wxT(
"Header: XY missing (in Surface Hole)" ) );
1091 Surface->AddHole( rlist );
1093 parent->
Append( Surface );
1098 while ( ReadItem( wxT(
"hole" ) ) )
1112 if ( !ReadItem( wxT(
"boundary" ) ) )
1118 ReadElflags( Boundary );
1120 ReadItem( wxT(
"plex" ) );
1122 if ( !ReadLayer( Boundary ) )
1123 throw GDS_Error( wxT(
"Boundary: LAYER missing (in KEY-file)" ) );
1125 ReadItem( wxT(
"datatype" ) );
1128 if ( ReadItem( wxT(
"spline" ) ) )
1131 if ( ReadItem( wxT(
"width" ) ) )
1137 throw GDS_Error( wxT(
"Header: XY missing (in Boundary)" ) );
1139 parent->
Append( Boundary );
1154 if ( !ReadItem( wxT(
"path" ) ) )
1160 ReadElflags( path );
1161 ReadItem( wxT(
"plex" ) );
1163 if ( !ReadLayer( path ) )
1164 throw GDS_Error( wxT(
"record LAYER missing (in Path)" ) );
1166 if ( ReadItem( wxT(
"datatype" ) ) )
1169 if ( ReadItem( wxT(
"pathtype" ) ) )
1172 if ( ReadItem( wxT(
"spline" ) ) )
1175 if ( ReadItem( wxT(
"width" ) ) )
1178 ReadItem( wxT(
"bgnextn" ) );
1179 ReadItem( wxT(
"endextn" ) );
1184 throw GDS_Error( wxT(
"Header: XY missing (in Path)" ) );
1203 if ( !ReadItem( wxT(
"text" ) ) )
1209 ReadElflags( Text );
1210 ReadItem( wxT(
"plex" ) );
1211 if ( !ReadLayer( Text ) )
1212 throw GDS_Error( wxT(
"Text: LAYER is missing (in GDS-file)" ) );
1214 if ( !ReadItem( wxT(
"texttype" ) ) )
1215 throw GDS_Error( wxT(
"Text: TEXTBODY is missing (in GDS-file)" ) );
1218 if ( ReadItem( wxT(
"presentation" ) ) )
1221 wxString _int_str_ptr =
m_value;
1222 Text->SetHorizontal( wxAtoi( _int_str_ptr ) % 4 );
1223 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"," ) ) + 1;
1224 Text->SetVertical( wxAtoi( _int_str_ptr ) % 4 );
1225 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"," ) ) + 1;
1226 Text->SetFontGDS( wxAtoi( _int_str_ptr ) % 4 );
1229 if ( ReadItem( wxT(
"pathtype" ) ) )
1231 Text->SetPathtype( ( TEXT_PATHTYPE )wxAtoi(
m_value ) );
1234 if ( ReadItem( wxT(
"width" ) ) )
1240 ReadStrans( Strans );
1243 double lineheight = Strans.GetScale();
1247 if ( !ReadItem( wxT(
"xy" ) ) )
1248 throw GDS_Error( wxT(
"Text: XY is missing (in KEY-file)" ) );
1259 if ( Strans.GetReflection() )
1260 relative_matrix.
Mirror();
1263 if ( Strans.GetAbsAngle() == 0 )
1264 relative_matrix.
Rotate( Strans.GetAngle(), 0, 0 );
1267 if ( Strans.GetAbsScale() == 0 )
1275 relative_matrix.
Translate( point.m_x, point.m_y );
1283 if ( !ReadItem( wxT(
"string" ) ) )
1284 throw GDS_Error( wxT(
"Text: STRING is missing (in KEY-file)" ) );
1296 bool a2dIOHandlerKeyIn::ReadStructureReference(
a2dCanvasObject* parent )
1302 if ( m_asCameleons )
1303 return ReadStructureCameleonReference( parent );
1306 if ( !ReadItem( wxT(
"sref" ) ) )
1314 ReadElflags( sref );
1315 ReadItem( wxT(
"plex" ) );
1317 if ( !ReadItem( wxT(
"sname" ) ) )
1318 throw GDS_Error( wxT(
"Sref: SNAME is missing (in KEY-file)" ) );
1323 ReadStrans( strans );
1325 if ( !ReadItem( wxT(
"xy" ) ) )
1326 throw GDS_Error( wxT(
"Sref: XY is missing (in Structure Reference)" ) );
1334 if ( strans.GetReflection() )
1335 relative_matrix.
Mirror();
1338 if ( strans.GetAbsAngle() == 0 )
1339 relative_matrix.
Rotate( strans.GetAngle(), 0, 0 );
1342 if ( strans.GetAbsScale() == 0 )
1344 double scale = strans.GetScale();
1345 relative_matrix.
Scale( scale, scale, 0, 0 );
1349 relative_matrix.
Translate( point.m_x, point.m_y );
1365 bool a2dIOHandlerKeyIn::ReadStructureCameleonReference(
a2dCanvasObject* parent )
1372 if ( !ReadItem( wxT(
"sref" ) ) )
1380 ReadElflags( sref );
1381 ReadItem( wxT(
"plex" ) );
1383 if ( !ReadItem( wxT(
"sname" ) ) )
1384 throw GDS_Error( wxT(
"Sref: SNAME is missing (in KEY-file)" ) );
1385 sref->SetAppearanceName(
m_value + wxT(
":layout") );
1391 ReadStrans( strans );
1393 if ( !ReadItem( wxT(
"xy" ) ) )
1394 throw GDS_Error( wxT(
"Sref: XY is missing (in Structure Reference)" ) );
1402 if ( strans.GetReflection() )
1403 relative_matrix.
Mirror();
1406 if ( strans.GetAbsAngle() == 0 )
1407 relative_matrix.
Rotate( strans.GetAngle(), 0, 0 );
1410 if ( strans.GetAbsScale() == 0 )
1412 double scale = strans.GetScale();
1413 relative_matrix.
Scale( scale, scale, 0, 0 );
1417 relative_matrix.
Translate( point.m_x, point.m_y );
1438 if ( !ReadItem( wxT(
"aref" ) ) )
1450 ReadElflags( arrayref );
1452 ReadItem( wxT(
"plex" ) );
1454 if ( !ReadItem( wxT(
"sname" ) ) )
1455 throw GDS_Error( wxT(
"Aref: SNAME missing (in Structure Reference)" ) );
1461 ReadStrans( strans );
1463 if ( !ReadItem( wxT(
"colrow" ) ) )
1464 throw GDS_Error( wxT(
"Aref: COLROW is missing (in Array Reference)" ) );
1466 wxString _int_str_ptr =
m_value;
1467 arrayref->SetColumns( wxAtoi( _int_str_ptr ) );
1468 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"," ) ) + 1;
1469 arrayref->SetRows( wxAtoi( _int_str_ptr ) );
1471 if ( !ReadItem( wxT(
"xy" ) ) )
1472 throw GDS_Error( wxT(
"Aref: XY missing (in Array Reference)" ) );
1478 arrayref->SetHorzSpace( sqrt( pow( HorPoint.m_x - Point.m_x, 2 ) + pow( HorPoint.m_y - Point.m_y, 2 ) ) / arrayref->GetColumns() );
1479 arrayref->SetVertSpace( sqrt( pow( VerPoint.m_x - Point.m_x, 2 ) + pow( VerPoint.m_y - Point.m_y, 2 ) ) / arrayref->GetRows() );
1485 if ( strans.GetReflection() )
1486 relative_matrix.
Mirror();
1489 if ( strans.GetAbsAngle() == 0 )
1490 relative_matrix.
Rotate( strans.GetAngle(), 0, 0 );
1493 if ( strans.GetAbsScale() == 0 )
1495 EIGHT_G_BYTE_REAL scale = strans.GetScale();
1496 relative_matrix.
Scale( scale, scale, 0, 0 );
1500 relative_matrix.
Translate( Point.m_x, Point.m_y );
1503 parent->
Append( arrayref );
1515 bool a2dIOHandlerKeyIn::ReadNode(
a2dCanvasObject* WXUNUSED( parent ) )
1520 if ( ReadItem( wxT(
"node" ) ) )
1521 throw GDS_Error( wxT(
"Node: NODE not implemented yet! (in KEY-file)" ) );
1531 if ( !ReadItem( wxT(
"box" ) ) )
1539 ReadItem( wxT(
"plex" ) );
1542 if ( !ReadLayer( Box ) )
1543 throw GDS_Error( wxT(
"Box: LAYER is missing (in KEY-file)" ) );
1545 if ( !ReadItem( wxT(
"boxtype" ) ) )
1546 throw GDS_Error( wxT(
"Box: boxtype is missing (in KEY-file)" ) );
1549 if ( ReadItem( wxT(
"width" ) ) )
1552 if ( !ReadItem( wxT(
"xy" ) ) )
1555 int points = wxAtoi(
m_value );
1558 throw GDS_Error( wxT(
"Wrong number of points in BOX XY." ), wxT(
"Fatal GDSII error" ) );
1572 double minx, miny, maxx, maxy;
1574 minx = maxx = seg.m_x;
1575 miny = maxy = seg.m_y;
1577 minx = wxMin( minx, seg2.m_x );
1578 maxx = wxMax( maxx, seg2.m_x );
1579 miny = wxMin( miny, seg2.m_y );
1580 maxy = wxMax( maxy, seg2.m_y );
1582 minx = wxMin( minx, seg3.m_x );
1583 maxx = wxMax( maxx, seg3.m_x );
1584 miny = wxMin( miny, seg3.m_y );
1585 maxy = wxMax( maxy, seg3.m_y );
1587 minx = wxMin( minx, seg4.m_x );
1588 maxx = wxMax( maxx, seg4.m_x );
1589 miny = wxMin( miny, seg4.m_y );
1590 maxy = wxMax( maxy, seg4.m_y );
1592 Box->
SetWidth( fabs( maxx - minx ) );
1604 if ( !ReadItem( wxT(
"line" ) ) )
1610 ReadElflags( line );
1611 ReadItem( wxT(
"plex" ) );
1614 if ( !ReadLayer( line ) )
1615 throw GDS_Error( wxT(
"Line: LAYER is missing (in KEY-file)" ) );
1617 if ( ReadItem( wxT(
"width" ) ) )
1620 if ( !ReadItem( wxT(
"xy" ) ) )
1627 line->
SetPosXY12( p1.m_x, p1.m_y, p2.m_x, p2.m_y );
1637 if ( !ReadItem( wxT(
"image" ) ) )
1643 ReadElflags( image );
1644 ReadItem( wxT(
"plex" ) );
1647 if ( !ReadLayer( image ) )
1648 throw GDS_Error( wxT(
"Line: LAYER is missing (in KEY-file)" ) );
1650 ReadItem( wxT(
"width" ) );
1652 if ( ReadItem( wxT(
"w" ) ) )
1653 image->
SetWidth( ReadDouble() * m_userunits_out );
1655 if ( ReadItem( wxT(
"h" ) ) )
1656 image->
SetHeight( ReadDouble() * m_userunits_out );
1658 wxBitmapType type = wxBITMAP_TYPE_INVALID;
1659 if ( ReadItem( wxT(
"type" ) ) )
1661 if (
m_value.CmpNoCase( wxT(
"gif" ) ) == 0 )
1662 type = wxBITMAP_TYPE_GIF;
1663 else if (
m_value.CmpNoCase( wxT(
"png" ) ) == 0 )
1664 type = wxBITMAP_TYPE_PNG;
1665 else if (
m_value.CmpNoCase( wxT(
"bmp" ) ) == 0 )
1666 type = wxBITMAP_TYPE_BMP;
1667 else if (
m_value.CmpNoCase( wxT(
"jpeg" ) ) == 0 )
1668 type = wxBITMAP_TYPE_JPEG;
1670 throw GDS_Error( wxT(
"Image: not supported type" ) );
1673 if ( ReadItem( wxT(
"path" ) ) )
1680 ReadStrans( strans );
1682 if ( !ReadItem( wxT(
"xy" ) ) )
1683 throw GDS_Error( wxT(
"Sref: XY is missing (in Structure Reference)" ) );
1691 if ( strans.GetReflection() )
1692 relative_matrix.
Mirror();
1695 if ( strans.GetAbsAngle() == 0 )
1696 relative_matrix.
Rotate( strans.GetAngle(), 0, 0 );
1699 if ( strans.GetAbsScale() == 0 )
1701 double scale = strans.GetScale();
1702 relative_matrix.
Scale( scale, scale, 0, 0 );
1706 relative_matrix.
Translate( point.m_x, point.m_y );
1719 if ( !ReadItem( wxT(
"elflags" ) ) )
1722 object->SetTemplate( (
bool )( wxAtoi(
m_value ) && 1 ) );
1723 object->SetExternal( (
bool )( wxAtoi(
m_value ) && 2 ) );
1731 if ( !ReadItem( wxT(
"layer" ) ) )
1734 m_lastElementLayer = wxAtoi(
m_value );
1735 object->SetLayer(
m_mapping[ m_lastElementLayer ] );
1740 bool a2dIOHandlerKeyIn::Read(
a2dPoint2D& Point )
1742 if ( !ReadItem( wxT(
"x" ) ) )
1743 throw GDS_Error( wxT(
"Point: X is missing (in KEY-file)" ) );
1744 Point.m_x = ReadDouble();
1745 if ( !ReadItem( wxT(
"y" ) ) )
1746 throw GDS_Error( wxT(
"Point: Y is missing (in KEY-file)" ) );
1747 Point.m_y = ReadDouble();
1752 bool a2dIOHandlerKeyIn::ReadStrans( Strans& Strans )
1755 if ( !ReadItem( wxT(
"strans" ) ) )
1758 wxString _int_str_ptr =
m_value;
1760 Strans.
m_stransflags.bits.reflection = wxAtoi( _int_str_ptr );
1761 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"," ) ) + 1;
1762 Strans.
m_stransflags.bits.abs_angle = wxAtoi( _int_str_ptr );
1763 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"," ) ) + 1;
1764 Strans.
m_stransflags.bits.abs_scale = wxAtoi( _int_str_ptr );
1766 if ( ReadItem( wxT(
"mag" ) ) )
1767 Strans.SetScale( ReadDouble() );
1769 if ( ReadItem( wxT(
"angle" ) ) )
1770 Strans.SetAngle( ReadDouble() );
1781 if( !ReadItem( wxT(
"bgnstr" ) ) )
1784 if( !ReadItem( wxT(
"creation" ) ) )
1785 throw GDS_Error( wxT(
"Structure: CREATION is missing (in KEY-file)" ) );
1787 wxString _int_str_ptr =
m_value;
1791 Structure->SetIgnoreLayer(
true );
1794 wxDateTime m_modificationtime = wxDateTime::Now();
1795 wxDateTime m_accesstime = wxDateTime::Now();
1804 year = wxAtoi( _int_str_ptr );
1805 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1806 month = wxAtoi( _int_str_ptr ) - 1;
1807 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1808 day = wxAtoi( _int_str_ptr );
1809 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
" " ) ) + 2;
1810 hour = wxAtoi( _int_str_ptr );
1811 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1812 minute = wxAtoi( _int_str_ptr );
1813 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1814 second = wxAtoi( _int_str_ptr );
1816 m_modificationtime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
1817 a2dCanvasObject::PROPID_ModificationDateTime->
SetPropertyToObject( Structure, m_modificationtime );
1819 if( !ReadItem( wxT(
"lastmod" ) ) )
1820 throw GDS_Error( wxT(
"Structure: LASTACC is missing (in KEY-file)" ) );
1824 year = wxAtoi( _int_str_ptr );
1825 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1826 month = wxAtoi( _int_str_ptr ) - 1;
1827 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1828 day = wxAtoi( _int_str_ptr );
1829 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
" " ) ) + 2;
1830 hour = wxAtoi( _int_str_ptr );
1831 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1832 minute = wxAtoi( _int_str_ptr );
1833 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1834 second = wxAtoi( _int_str_ptr );
1836 m_accesstime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
1839 if ( !ReadItem( wxT(
"strname" ) ) )
1840 throw GDS_Error( wxT(
"Structure: STRNAME missing (in KEY-file)" ) );
1844 ReadItem( wxT(
"strclass" ) );
1846 while ( ReadParameters( Structure ) );
1848 while ( ReadElement( Structure ) )
1853 if ( !ReadItem( wxT(
"endstr" ) ) )
1856 errbuf.Printf( wxT(
"Unknown Element: %s (in KEY-file)" ),
m_keyword.c_str() );
1860 parent->
Append( Structure );
1869 bool a2dIOHandlerKeyIn::ReadCameleonStructure(
a2dCanvasObject* parent )
1874 if( !ReadItem( wxT(
"bgnstr" ) ) )
1877 if( !ReadItem( wxT(
"creation" ) ) )
1878 throw GDS_Error( wxT(
"Structure: CREATION is missing (in KEY-file)" ) );
1880 wxString _int_str_ptr =
m_value;
1884 cam->AddAppearance( layout );
1889 wxDateTime m_modificationtime = wxDateTime::Now();
1890 wxDateTime m_accesstime = wxDateTime::Now();
1899 year = wxAtoi( _int_str_ptr );
1900 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1901 month = wxAtoi( _int_str_ptr ) - 1;
1902 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1903 day = wxAtoi( _int_str_ptr );
1904 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
" " ) ) + 2;
1905 hour = wxAtoi( _int_str_ptr );
1906 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1907 minute = wxAtoi( _int_str_ptr );
1908 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1909 second = wxAtoi( _int_str_ptr );
1911 m_modificationtime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
1912 a2dCanvasObject::PROPID_ModificationDateTime->
SetPropertyToObject( Structure, m_modificationtime );
1914 if( !ReadItem( wxT(
"lastmod" ) ) )
1915 throw GDS_Error( wxT(
"Structure: LASTACC is missing (in KEY-file)" ) );
1919 year = wxAtoi( _int_str_ptr );
1920 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1921 month = wxAtoi( _int_str_ptr ) - 1;
1922 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
"-" ) ) + 1;
1923 day = wxAtoi( _int_str_ptr );
1924 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
" " ) ) + 2;
1925 hour = wxAtoi( _int_str_ptr );
1926 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1927 minute = wxAtoi( _int_str_ptr );
1928 _int_str_ptr = wxStrstr( _int_str_ptr, wxT(
":" ) ) + 1;
1929 second = wxAtoi( _int_str_ptr );
1931 m_accesstime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
1934 if ( !ReadItem( wxT(
"strname" ) ) )
1935 throw GDS_Error( wxT(
"Structure: STRNAME missing (in KEY-file)" ) );
1940 ReadItem( wxT(
"strclass" ) );
1949 if ( !ReadItem( wxT(
"endstr" ) ) )
1952 errbuf.Printf( wxT(
"Unknown Element: %s (in KEY-file)" ),
m_keyword.c_str() );
1957 int px = m_dx * 30 * 1.5;
1958 int py = -m_dy * 10 * 1.5;
1961 if ( m_dx > m_refMaxx )
1962 { m_dy++; m_dx =0; }
1976 if ( !ReadItem( wxT(
"circle" ) ) )
1982 ReadElflags( circle );
1983 ReadItem( wxT(
"plex" ) );
1985 if ( !ReadLayer( circle ) )
1986 throw GDS_Error( wxT(
"Circle: LAYER is missing (in KEY-file)" ) );
1988 if ( ReadItem( wxT(
"datatype" ) ) )
1991 if ( ReadItem( wxT(
"width" ) ) )
1994 if ( !ReadItem( wxT(
"xy" ) ) )
1995 throw GDS_Error( wxT(
"Circle: XY is missing (in KEY-file)" ) );
1999 circle->
SetPosXY( point.m_x, point.m_y );
2000 if ( !ReadItem( wxT(
"radius" ) ) )
2001 throw GDS_Error( wxT(
"Circle: RADIUS is missing (in KEY-file)" ) );
2005 parent->
Append( circle );
2014 if ( !ReadItem( wxT(
"arc" ) ) )
2023 ReadItem( wxT(
"plex" ) );
2025 if ( !ReadLayer( arc ) )
2026 throw GDS_Error( wxT(
"Arc: LAYER is missing (in KEY-file)" ) );
2028 if ( ReadItem( wxT(
"datatype" ) ) )
2031 if ( ReadItem( wxT(
"width" ) ) )
2036 if ( !ReadItem( wxT(
"xy" ) ) )
2037 throw GDS_Error( wxT(
"Polyline: XY is missing (in KEY-file)" ) );
2039 double xs, ys, xe, ye, xm, ym;
2042 if ( !ReadItem( wxT(
"x" ) ) )
2043 throw GDS_Error( wxT(
"Polygon: X is missing (in KEY-file)" ) );
2047 if ( !ReadItem( wxT(
"y" ) ) )
2048 throw GDS_Error( wxT(
"Polygon: Y is missing (in KEY-file)" ) );
2053 if ( ReadItem( wxT(
"xm" ) ) )
2056 if ( !ReadItem( wxT(
"ym" ) ) )
2057 throw GDS_Error( wxT(
"Polygon: YM is missing (in KEY-file)" ) );
2061 if ( !ReadItem( wxT(
"xo" ) ) )
2062 throw GDS_Error( wxT(
"Polygon: XO is missing (in KEY-file)" ) );
2065 if ( !ReadItem( wxT(
"yo" ) ) )
2066 throw GDS_Error( wxT(
"Polygon: YO is missing (in KEY-file)" ) );
2070 if ( !ReadItem( wxT(
"x" ) ) )
2071 throw GDS_Error( wxT(
"Polygon: X is missing (in KEY-file)" ) );
2074 if ( !ReadItem( wxT(
"y" ) ) )
2075 throw GDS_Error( wxT(
"Polygon: Y is missing (in KEY-file)" ) );
2078 arc->
Set( xs, ys, xm, ym, xe, ye );
2092 if ( !ReadItem( wxT(
"xy" ) ) )
2098 double x, y, xp, yp, xm, ym, xo, yo;
2100 bool lastWasArc =
false;
2101 bool firstRead =
false;
2103 for ( i = 0; i < j - 1; i++ )
2106 if ( ReadItem( wxT(
"st" ) ) )
2108 if (
m_value.CmpNoCase( wxT(
"N" ) ) == 0 )
2110 else if (
m_value.CmpNoCase( wxT(
"H" ) ) == 0 )
2114 else if (
m_value.CmpNoCase( wxT(
"L" ) ) == 0 )
2118 if ( !ReadItem( wxT(
"x" ) ) )
2119 throw GDS_Error( wxT(
"Polygon: X is missing (in KEY-file)" ) );
2123 if ( !ReadItem( wxT(
"y" ) ) )
2124 throw GDS_Error( wxT(
"Polygon: Y is missing (in KEY-file)" ) );
2140 poly->push_back( sega );
2148 poly->push_back( seg );
2156 poly->push_back( seg );
2162 if ( ReadItem( wxT(
"xm" ) ) )
2170 if ( !ReadItem( wxT(
"ym" ) ) )
2171 throw GDS_Error( wxT(
"Polygon: YM is missing (in KEY-file)" ) );
2174 if ( !ReadItem( wxT(
"xo" ) ) )
2175 throw GDS_Error( wxT(
"Polygon: XO is missing (in KEY-file)" ) );
2178 if ( !ReadItem( wxT(
"yo" ) ) )
2179 throw GDS_Error( wxT(
"Polygon: YO is missing (in KEY-file)" ) );
2190 throw GDS_Error( wxT(
"Polygon: X or XM missing (in KEY-file)" ) );
2195 if ( !ReadItem( wxT(
"x" ) ) )
2196 throw GDS_Error( wxT(
"Polygon: X is missing (in KEY-file)" ) );
2200 if ( !ReadItem( wxT(
"y" ) ) )
2201 throw GDS_Error( wxT(
"Polygon: Y is missing (in KEY-file)" ) );
2205 if ( ReadItem( wxT(
"xm" ) ) )
2206 throw GDS_Error( wxT(
"Polygon: expected ENDEL found XM (in KEY-file)" ) );
2219 poly->push_back( sega );
2235 if ( !ReadItem( wxT(
"xy" ) ) )
2236 throw GDS_Error( wxT(
"Polyline: XY is missing (in KEY-file)" ) );
2240 double x, y, xp, yp, xm, ym, xo, yo;
2241 bool lastWasArc =
false;
2242 bool firstRead =
false;
2244 for ( i = 0; i < j; i++ )
2246 if ( !ReadItem( wxT(
"x" ) ) )
2247 throw GDS_Error( wxT(
"Polyline: X is missing (in KEY-file)" ) );
2250 if ( !ReadItem( wxT(
"y" ) ) )
2251 throw GDS_Error( wxT(
"Polyline: Y is missing (in KEY-file)" ) );
2265 poly->push_back( sega );
2272 poly->push_back( seg );
2281 poly->push_back( seg );
2287 if ( ReadItem( wxT(
"xm" ) ) )
2296 if ( !ReadItem( wxT(
"ym" ) ) )
2297 throw GDS_Error( wxT(
"Polygon: YM is missing (in KEY-file)" ) );
2300 if ( !ReadItem( wxT(
"xo" ) ) )
2301 throw GDS_Error( wxT(
"Polygon: XO is missing (in KEY-file)" ) );
2304 if ( !ReadItem( wxT(
"yo" ) ) )
2305 throw GDS_Error( wxT(
"Polygon: YO is missing (in KEY-file)" ) );
2308 else if ( !
m_keyword.CmpNoCase( wxT(
"endel" ) ) || !
m_keyword.CmpNoCase( wxT(
"x" ) )
2309 || !
m_keyword.CmpNoCase( wxT(
"st" ) ) || !
m_keyword.CmpNoCase( wxT(
"property" ) ) )
2316 throw GDS_Error( wxT(
"Polyline: X, XM, ST, PROPERTY or ENDEL missing (in KEY-file)" ) );
2321 throw GDS_Error( wxT(
"Last Segment Should not be an Arc segment (in KEY-file)" ) );
2331 if ( ( Element->GetTemplate() != 0 ) ||
2332 ( Element->GetExternal() != 0 ) )
2336 if ( Element->GetTemplate() != 0 )
2337 m_objectFlags += 1 << 1;
2339 if ( Element->GetExternal() != 0 )
2340 m_objectFlags += 1 << 2;
2373 #if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE
2382 #endif // wxUSE_UNICODE
2387 str.Printf( wxT(
"%d" ), (
signed int )c );
2396 str.Printf( wxT(
"%ld" ), (
signed long )c );
2405 str.Printf( wxT(
"%u" ), (
unsigned int )c );
2414 str.Printf( wxT(
"%lu" ), (
unsigned long )c );
2432 const wxChar a2dIOHandlerKeyOut::Endl()
2439 a2dIOHandlerKeyOut::a2dIOHandlerKeyOut()
2442 m_lastElementLayer = 0;
2444 m_format = wxT(
"%g" );
2445 m_fromViewAsTop =
false;
2446 m_asCameleons =
false;
2449 a2dIOHandlerKeyOut::~a2dIOHandlerKeyOut()
2462 m_points_written = 0;
2473 bool a2dIOHandlerKeyOut::LinkReferences()
2483 a2dCanvasObjectList::iterator delnode = rootchild;
2485 if ( ( *delnode )->GetCheck() )
2502 if ( m_fromViewAsTop )
2513 setflags.
Start( showobject,
false );
2518 for ( i = 0; i < wxMAXLAYER; i++ )
2520 for ( i = 0; i < wxMAXLAYER; i++ )
2522 m_mapping[ m_layers->GetOutMapping( i ) ] = i;
2524 for ( i = 0; i < wxMAXLAYER; i++ )
2545 m_scale_out = pow( 10.0, l );
2547 *
this << wxT(
"# KEY file for GDS-II postprocessing tool" ) << Endl();
2549 *
this << wxT(
"# ====================================================================" ) << Endl() << Endl();
2551 *
this << wxT(
"HEADER " ) <<
m_doc->
GetVersion() << wxT(
"; # version " ) << Endl();
2552 *
this << wxT(
"BGNLIB; " ) << Endl();
2553 *
this << wxT(
"LASTMOD {" )
2560 *
this << wxT(
"LASTACC {" )
2574 *
this << wxT(
"FORMAT 1; " ) << Endl();
2577 for ( j = 0; j < wxMAXLAYER; j++ )
2590 if ( layerobj == wxNullLayerInfo )
2600 *
this << wxT(
"MASK \"" ) << layerobj->
GetName() << wxT(
"\"; " );
2601 *
this << wxT(
"layernr " ) << layerobj->
GetLayer() << wxT(
"; " );
2603 wxString brushColour = wxTheColourDatabase->FindName( layerobj->GetFill().
GetColour() );
2605 if ( brushColour.IsEmpty() )
2606 *
this << wxT(
"color \"" ) << wxT(
"#" ) +
ColourToHex( layerobj->GetFill().
GetColour() ) << wxT(
"\"; " );
2608 *
this << wxT(
"color \"" ) << brushColour << wxT(
"\"; " );
2610 *
this << wxT(
"trans " ) << layerobj->GetFill().GetAlpha() << wxT(
"; " );
2612 *
this << wxT(
"trans " ) << 0 << wxT(
"; " );
2613 *
this << wxT(
"linestyle " ) <<
StrokeStyle2String( layerobj->GetStroke().GetStyle() ) << wxT(
"; " );
2615 *
this << wxT(
"binding {*}; " );
2616 *
this << wxT(
"stream " ) << j << wxT(
"; " );
2617 *
this << wxT(
"iges " ) << j << wxT(
"; " );
2618 *
this << wxT(
"type " ) << 1 << wxT(
"; " );
2619 *
this << wxT(
"dxf " ) << 1 << wxT(
"; " );
2621 *
this << wxT(
"plotmode " ) << 0 << wxT(
"; " );
2623 *
this << wxT(
"plotmode " ) << 1 << wxT(
"; " );
2624 *
this << wxT(
"protected " ) << 0 << wxT(
"; " );
2625 *
this << wxT(
"visible " ) << 1 << wxT(
"; " );
2626 *
this << wxT(
"patternnr " ) << 0 << wxT(
"; " );
2631 *
this << wxT(
"ENDMASKS" ) << Endl();
2635 *
this << wxT(
"UNITS " ) <<
m_doc->
GetUnits() << wxT(
"; " ) << Endl()
2636 << wxT(
"USERUNITS " ) << m_userunits_out << wxT(
"; " )
2637 << wxT(
"PHYSUNITS " ) <<
m_doc->
GetUnitsScale()*m_userunits_out* m_scale_out << wxT(
"; " ) << Endl();
2643 if ( m_fromViewAsTop )
2644 towrite.push_back( showobject );
2656 towrite.push_back( ref );
2666 towrite.push_back( showobject );
2673 a2dCanvasObjectList::iterator iter = towrite.begin();
2674 while ( towrite.size() )
2677 SaveStructure( obj, &towrite );
2679 towrite.erase( iter );
2680 iter = towrite.begin();
2683 *
this << wxT(
"ENDLIB; " ) << Endl();
2701 *
this << Endl() << wxT(
"BGNSTR; # Begin of structure " ) << Endl();
2702 *
this << wxT(
"CREATION {" )
2709 *
this << wxT(
"LASTMOD {" )
2715 <<
m_doc->
GetAccessTime().GetSecond() << wxT(
"}; # last modification time" ) << Endl();
2717 *
this << wxT(
"STRNAME " ) <<
object->GetName() << wxT(
"; " ) << Endl();
2732 if ( !obj->
GetRelease() && m_layers->GetVisible( obj->
GetLayer() ) || obj->GetIgnoreLayer() )
2734 Save( obj, towrite );
2748 if ( !obj->
GetRelease() && m_layers->GetVisible( obj->
GetLayer() ) || obj->GetIgnoreLayer() )
2750 Save( obj, towrite );
2755 *
this << Endl() << wxT(
"ENDSTR " ) <<
object->GetName() << wxT(
"; " ) << Endl();
2775 DoSave( obj, towrite );
2780 DoSave( obj, towrite );
2785 DoSave( obj, towrite );
2795 DoSave( obj, towrite );
2800 DoSave( obj, towrite );
2805 DoSave( obj, towrite );
2810 DoSave( obj, towrite );
2817 DoSave( obj, towrite );
2826 DoSave( obj, towrite );
2834 DoSave( obj, towrite );
2838 vectorpaths =
object->GetAsCanvasVpaths(
false );
2848 vectorpaths =
object->GetAsCanvasVpaths(
false );
2850 else if ( wxString( object->GetClassInfo()->GetClassName() ) == wxT(
"a2dCanvasObject" ) )
2852 *
this << Endl() << wxT(
"SREF; " ) << Endl();
2854 WriteFlags( m_objectFlags );
2856 *
this << wxT(
"SNAME " ) <<
object->GetName() << wxT(
"; " ) << Endl();
2862 Strans strans = Strans();
2864 if ( strans.GetStrans() )
2868 *
this << Endl() << wxT(
" XY 1; " ) << Endl();
2870 WritePoint( object->
GetPosX(),
object->GetPosY() );
2872 *
this << Endl() << wxT(
"ENDEL; " ) << Endl();
2873 towrite->push_back(
object );
2879 wxLogWarning( wxT(
"KEYIO : object %s is not implemented for output" ), object->GetClassInfo()->GetClassName() );
2892 for( a2dCanvasObjectList::iterator iter = vectorpaths->begin(); iter != vectorpaths->end(); ++iter )
2902 *
this << Endl() << wxT(
"ENDEL; " ) << Endl();
2908 *
this << Endl() << wxT(
"SREF; " ) << Endl();
2910 WriteFlags( m_objectFlags );
2912 *
this << wxT(
"SNAME " ) <<
object->GetName() << wxT(
"; " ) << Endl();
2918 Strans strans = Strans();
2920 if ( strans.GetStrans() )
2924 *
this << Endl() << wxT(
" XY 1; " ) << Endl();
2926 WritePoint( object->
GetPosX(),
object->GetPosY() );
2928 *
this << Endl() << wxT(
"ENDEL; " ) << Endl();
2929 towrite->push_back(
object );
3031 m_points_written = 0;
3033 *
this << Endl() << wxT(
"SURFACE; " );
3035 WriteFlags( m_objectFlags );
3040 WritePoly( lworld, points,
true );
3043 for( a2dListOfa2dVertexList::iterator iterp = holes.begin(); iterp != holes.end(); iterp++ )
3045 *
this << Endl() << wxT(
"HOLE; " );
3049 m_points_written = 0;
3050 WritePoly( lworld, vlist,
true );
3056 *
this << Endl() << wxT(
"TEXT; " );
3058 WriteFlags( m_objectFlags );
3060 *
this << wxT(
"LAYER " ) <<
m_mapping[obj->
GetLayer()] << wxT(
"; " ) << Endl();
3062 *
this << wxT(
"TEXTTYPE " ) << TEXT_PATH_END_SQAURE << wxT(
"; " );
3071 Strans strans = Strans();
3075 strans.SetScale( strans.GetScale() * obj->
GetTextHeight() );
3077 if ( strans.GetStrans() )
3080 *
this << Endl() << wxT(
" XY 1; " ) << Endl();
3084 *
this << Endl() << wxT(
"STRING {" ) << obj->
GetText() << wxT(
"}; " );
3089 *
this << Endl() << wxT(
"TEXT; " );
3091 WriteFlags( m_objectFlags );
3093 *
this << wxT(
"LAYER " ) <<
m_mapping[obj->
GetLayer()] << wxT(
"; " ) << Endl();
3095 *
this << wxT(
"TEXTTYPE " ) << obj->
GetTextType() << wxT(
"; " );
3097 if ( obj->GetPresentationFlags() )
3100 if ( ( obj->GetFontGDS() != DEFAULT_PRESENTATION_FONT ) ||
3101 ( obj->GetVertical() != DEFAULT_PRESENTATION_VERTICAL ) ||
3102 ( obj->GetHorizontal() != DEFAULT_PRESENTATION_HORIZONTAL ) )
3104 *
this << wxT(
"PRESENTATION " ) <<
3105 ( int )obj->GetHorizontal() << wxT(
"," ) <<
3106 ( int )obj->GetVertical() << wxT(
"," ) <<
3107 ( int )obj->GetFontGDS() << wxT(
"; " );
3110 if ( obj->GetPathtype() )
3111 *
this << wxT(
"PATHTYPE " ) << obj->GetPathtype() << wxT(
"; " );
3120 Strans strans = Strans();
3124 strans.SetScale( strans.GetScale() * obj->
GetTextHeight() );
3126 if ( strans.GetStrans() )
3129 *
this << Endl() << wxT(
" XY 1; " ) << Endl();
3133 *
this << Endl() << wxT(
"STRING {" ) << obj->
GetText() << wxT(
"}; " );
3138 *
this << Endl() << wxT(
"SREF; " ) << Endl();
3140 WriteFlags( m_objectFlags );
3142 *
this << wxT(
"SNAME " ) << obj->
GetName() << wxT(
"; " ) << Endl();
3148 Strans strans = Strans();
3150 if ( strans.GetStrans() )
3154 *
this << Endl() << wxT(
" XY 1; " ) << Endl();
3164 *
this << Endl() << wxT(
"AREF; " ) << Endl();
3166 WriteFlags( m_objectFlags );
3168 *
this << wxT(
"SNAME " ) << obj->
GetName() << wxT(
"; " );
3173 Strans strans = Strans();
3175 if ( strans.GetStrans() )
3179 *
this << wxT(
"COLROW {" )
3180 << obj->GetColumns() << wxT(
" , " )
3181 << obj->GetRows() << wxT(
"}; " );
3183 m_points_written = 0;
3185 *
this << Endl() << wxT(
" XY 3; " ) << Endl();
3188 WritePoint( obj->
GetPosX() + obj->GetHorzSpace() * obj->GetColumns(), obj->
GetPosY() );
3189 WritePoint( obj->
GetPosX(), obj->
GetPosY() + obj->GetVertSpace() * obj->GetRows() );
3201 *
this << Endl() << wxT(
"SREF; " ) << Endl();
3203 WriteFlags( m_objectFlags );
3211 Strans strans = Strans();
3213 if ( strans.GetStrans() )
3217 *
this << Endl() << wxT(
" XY 1; " ) << Endl();
3227 SaveStructure( obj, towrite );
3233 *
this << Endl() << wxT(
"CIRCLE; " );
3235 WriteFlags( m_objectFlags );
3241 *
this << wxT(
"WIDTH " ) << Circle->
GetContourWidth() / m_scale_out << wxT(
"; " );
3244 m_points_written = 0;
3246 *
this << Endl() << wxT(
" XY 1; " ) << Endl();
3250 *
this << wxT(
"RADIUS " ) << Circle->
GetRadius() / m_scale_out << wxT(
"; " ) << Endl();
3253 void a2dIOHandlerKeyOut::Write( Strans* Strans )
3256 if ( ( Strans->
m_stransflags.bits.abs_angle != DEFAULT_STRANS_ABS_ANGLE ) ||
3257 ( Strans->
m_stransflags.bits.abs_scale != DEFAULT_STRANS_ABS_SCALE ) ||
3258 ( Strans->
m_stransflags.bits.reflection != DEFAULT_STRANS_REFLECTION ) ||
3259 ( Strans->GetScale() != DEFAULT_STRANS_SCALE ) ||
3260 ( Strans->GetAngle() != DEFAULT_STRANS_ANGLE ) )
3263 *
this << wxT(
"STRANS " )
3269 if ( Strans->GetScale() != DEFAULT_STRANS_SCALE )
3270 *
this << wxT(
"MAG " ) << Strans->GetScale() << wxT(
"; " );
3273 if ( Strans->GetAngle() != DEFAULT_STRANS_ANGLE )
3274 *
this << wxT(
"ANGLE " ) << Strans->GetAngle() << wxT(
"; " );
3281 if ( ( Element->GetTemplate() != 0 ) ||
3282 ( Element->GetExternal() != 0 ) )
3286 if ( Element->GetTemplate() != 0 )
3287 m_objectFlags += 1 << 1;
3289 if ( Element->GetExternal() != 0 )
3290 m_objectFlags += 1 << 2;
3294 void a2dIOHandlerKeyOut::WriteFlags(
int flags )
3296 if ( ( flags && 2 != 0 ) ||
3297 ( flags && 1 != 0 ) )
3302 if ( (
bool ) ( flags && 2 ) )
3304 if ( (
bool ) ( flags && 1 ) )
3307 if ( (
bool ) ( flags && 1 ) )
3309 if ( (
bool ) ( flags && 2 ) )
3313 *
this << wxT(
"ELFLAGS " ) << value << wxT(
"; " );
3318 void a2dIOHandlerKeyOut::WritePoint(
double xi,
double yi )
3320 if ( !( m_points_written % 2 ) )
3321 *
this << Endl() << wxT(
" " );
3328 x = xi / m_scale_out;
3330 x = xi / m_scale_out;
3332 y = yi / m_scale_out;
3334 y = yi / m_scale_out;
3337 buf.Printf( wxT(
"%18.6lf" ), x );
3339 *
this << wxT(
"X " ) << buf << wxT(
"; " );
3341 buf.Printf( wxT(
"%18.6lf" ), y );
3343 *
this << wxT(
"Y " ) << buf << wxT(
"; " );
3349 if ( !( m_points_written % 2 ) )
3350 *
this << Endl() << wxT(
" " );
3357 case a2dLINK_SEG: *
this << wxT(
"ST L; " );
break;
3358 case a2dHOLE_SEG: *
this << wxT(
"ST H; " );
break;
3365 buf.Printf( wxT(
"%18.6f" ), x / m_scale_out );
3366 *
this << wxT(
"X " ) << buf << wxT(
"; " );
3367 buf.Printf( wxT(
"%18.6f" ), y / m_scale_out );
3368 *
this << wxT(
"Y " ) << buf << wxT(
"; " );
3370 if ( nextSegment->GetArc() )
3372 if ( !( m_points_written % 2 ) )
3373 *
this << Endl() << wxT(
" " );
3378 buf.Printf( wxT(
"%18.6f" ), x / m_scale_out );
3379 *
this << wxT(
"XM " ) << buf << wxT(
"; " );
3380 buf.Printf( wxT(
"%18.6f" ), y / m_scale_out );
3381 *
this << wxT(
"YM " ) << buf << wxT(
"; " );
3382 if ( !( m_points_written % 2 ) )
3383 *
this << Endl() << wxT(
" " );
3388 buf.Printf( wxT(
"%15.3f" ), x / m_scale_out );
3389 *
this << wxT(
"XO " ) << buf << wxT(
"; " );
3390 buf.Printf( wxT(
"%15.3f" ), y / m_scale_out );
3391 *
this << wxT(
"YO " ) << buf << wxT(
"; " );
3395 void a2dIOHandlerKeyOut::WriteVpath(
const a2dAffineMatrix& lworld,
const a2dVpath* path,
int layer,
int datatype,
int pathtype,
double width )
3405 bool nostrokeparts =
false;
3408 for ( i = 0; i < path->size(); i++ )
3436 nostrokeparts =
true;
3440 nostrokeparts =
true;
3445 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3446 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3453 xw = xwl * pow( 1 - t, 3 ) + cseg->
m_x2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_x3 * ( 1 - t ) * t * t * 3 + cseg->
m_x1 * pow( t, 3 );
3454 yw = ywl * pow( 1 - t, 3 ) + cseg->
m_y2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_y3 * ( 1 - t ) * t * t * 3 + cseg->
m_y1 * pow( t, 3 );
3464 nostrokeparts =
true;
3469 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3470 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3477 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
3478 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
3488 nostrokeparts =
true;
3493 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
3495 if ( cseg->
CalcR( path->Item( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
3498 unsigned int segments;
3501 double theta = beginrad;
3504 for ( step = 0; step < segments + 1; step++ )
3506 lworld.
TransformPoint( center_x + radius * cos ( theta ), center_y + radius * sin ( theta ), x, y );
3509 theta = theta + dphi;
3524 WriteVertexArrayPolyline(
a2dIDENTITY_MATRIX, cpoints, layer, datatype, pathtype, width,
false,
true );
3533 WriteVertexArrayPolygon(
a2dIDENTITY_MATRIX, cpoints, layer, datatype, 0,
false,
true );
3534 nostrokeparts =
true;
3538 WriteVertexArrayPolygon(
a2dIDENTITY_MATRIX, cpoints, layer, datatype, 0,
false,
true );
3546 else if ( i == path->size() - 1 )
3548 WriteVertexArrayPolyline(
a2dIDENTITY_MATRIX, cpoints, layer, datatype, pathtype, width,
false,
true );
3553 if ( nostrokeparts )
3559 nostrokeparts =
false;
3561 double lastmovex = 0;
3562 double lastmovey = 0;
3564 for ( i = 0; i < path->size(); i++ )
3604 nostrokeparts =
true;
3612 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3613 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3620 xw = xwl * pow( 1 - t, 3 ) + cseg->
m_x2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_x3 * ( 1 - t ) * t * t * 3 + cseg->
m_x1 * pow( t, 3 );
3621 yw = ywl * pow( 1 - t, 3 ) + cseg->
m_y2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_y3 * ( 1 - t ) * t * t * 3 + cseg->
m_y1 * pow( t, 3 );
3634 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3635 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3642 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
3643 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
3656 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
3658 if ( cseg->
CalcR( path->Item( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
3661 unsigned int segments;
3664 double theta = beginrad;
3667 for ( step = 0; step < segments + 1; step++ )
3669 lworld.
TransformPoint( center_x + radius * cos ( theta ), center_y + radius * sin ( theta ), x, y );
3672 theta = theta + dphi;
3685 if ( move || nostrokeparts )
3687 WriteVertexArrayPolyline(
a2dIDENTITY_MATRIX, cpoints, layer, datatype, pathtype, width,
true );
3690 nostrokeparts =
false;
3697 cpoints->push_back(
new a2dLineSegment( lastmovex, lastmovey ) );
3700 WriteVertexArrayPolyline(
a2dIDENTITY_MATRIX, cpoints, layer, datatype, pathtype, width,
true );
3702 nostrokeparts =
false;
3706 else if ( i == path->size() )
3708 WriteVertexArrayPolyline(
a2dIDENTITY_MATRIX, cpoints, layer, datatype, pathtype, width,
true );
3719 void a2dIOHandlerKeyOut::WriteVertexArrayPolyline(
const a2dAffineMatrix& lworld,
a2dVertexArray* points,
int layer,
int datatype,
int pathtype,
double width,
bool spline,
bool close )
3721 m_points_written = 0;
3722 *
this << Endl() << wxT(
"PATH; " );
3724 WriteFlags( m_objectFlags );
3726 *
this << wxT(
"LAYER " ) <<
m_mapping[layer] << wxT(
"; " );
3727 *
this << wxT(
"DATATYPE " ) << datatype << wxT(
"; " );
3730 *
this << wxT(
"PATHTYPE " ) << pathtype << wxT(
"; " );
3733 *
this << wxT(
"SPLINE 1 ;" );
3736 *
this << wxT(
"WIDTH " ) << width / m_scale_out << wxT(
"; " );
3738 unsigned int n = points->size();
3740 *
this << Endl() << wxT(
" XY " ) << n << wxT(
"; " ) << Endl();
3745 for ( i = 0; i < n; i++ )
3748 nextseg = points->Item( i + 1 ).Get();
3750 nextseg = points->Item( 0 ).Get();
3751 WriteSegment( lworld, points->Item( i ).Get(), nextseg );
3755 *
this << Endl() << wxT(
"ENDEL; " ) << Endl();
3759 void a2dIOHandlerKeyOut::WriteVertexListPolyline(
const a2dAffineMatrix& lworld,
a2dVertexList* points,
int layer,
int datatype,
int pathtype,
double width,
bool spline,
bool close )
3761 m_points_written = 0;
3763 *
this << Endl() << wxT(
"PATH; " );
3765 WriteFlags( m_objectFlags );
3767 *
this << wxT(
"LAYER " ) <<
m_mapping[layer] << wxT(
"; " );
3768 *
this << wxT(
"DATATYPE " ) << datatype << wxT(
"; " );
3771 *
this << wxT(
"PATHTYPE " ) << pathtype << wxT(
"; " );
3774 *
this << wxT(
"SPLINE 1 ;" );
3777 *
this << wxT(
"WIDTH " ) << width / m_scale_out << wxT(
"; " );
3779 unsigned int n = points->size();
3781 WritePoly( lworld , points,
false );
3784 *
this << Endl() << wxT(
"ENDEL; " ) << Endl();
3788 void a2dIOHandlerKeyOut::WriteVertexArrayPolygon(
const a2dAffineMatrix& lworld,
a2dVertexArray* points,
int layer,
int datatype,
double width,
bool spline,
bool close )
3790 m_points_written = 0;
3792 *
this << Endl() << wxT(
"BOUNDARY; " );
3794 WriteFlags( m_objectFlags );
3796 *
this << wxT(
"LAYER " ) <<
m_mapping[layer] << wxT(
"; " );
3797 *
this << wxT(
"DATATYPE " ) << datatype << wxT(
"; " );
3800 *
this << wxT(
"SPLINE 1 ;" );
3803 *
this << wxT(
"WIDTH " ) << width / m_scale_out << wxT(
"; " );
3805 unsigned int n = points->size();
3808 *
this << Endl() << wxT(
"XY " ) << n + 1 << wxT(
"; " ) << Endl();
3812 for ( i = 0; i < n; i++ )
3815 nextseg = points->Item( i + 1 ).Get();
3817 nextseg = points->Item( 0 ).Get();
3818 WriteSegment( lworld, points->Item( i ).Get(), nextseg );
3823 WritePoint( points->Item( 0 )->
m_x, points->Item( 0 )->
m_y );
3827 *
this << Endl() << wxT(
"ENDEL; " ) << Endl();
3832 void a2dIOHandlerKeyOut::WriteVertexListPolygon(
const a2dAffineMatrix& lworld,
a2dVertexList* points,
int layer,
int datatype,
double width,
bool spline,
bool close )
3834 m_points_written = 0;
3836 *
this << Endl() << wxT(
"BOUNDARY; " );
3838 WriteFlags( m_objectFlags );
3840 *
this << wxT(
"LAYER " ) <<
m_mapping[layer] << wxT(
"; " );
3841 *
this << wxT(
"DATATYPE " ) << datatype << wxT(
"; " );
3844 *
this << wxT(
"SPLINE 1 ;" );
3847 *
this << wxT(
"WIDTH " ) << width / m_scale_out << wxT(
"; " );
3849 unsigned int n = points->size();
3851 WritePoly( lworld , points,
true );
3855 *
this << Endl() << wxT(
"ENDEL; " ) << Endl();
3861 unsigned int n = vlist->size();
3864 *
this << Endl() << wxT(
"XY " ) << ( close ? n + 1 : n ) << wxT(
"; " );
3867 a2dVertexList::iterator iter = vlist->begin();
3877 nextseg = vlist->front();
3879 WriteSegment( lworld, point, nextseg );
3883 WritePoint( vlist->front()->m_x, vlist->front()->m_y );
3889 a2dNamedPropertyList::const_iterator iter;
3890 for( iter = props.begin(); iter != props.end(); ++iter )
3895 *
this << wxT(
"PROPERTY {" ) << prop->
GetName() << wxT(
"}; " );
3898 *
this << wxT(
"PROPTYPE string; " );
3903 *
this << wxT(
"PROPTYPE integer; " );
3908 *
this << wxT(
"PROPTYPE real; " );
3913 *
this << wxT(
"PROPTYPE bool; " );
3922 #endif //wxART2D_USE_KEYIO
a2dCanvasObject * GetCanvasObject()
set check on a2dObject flag false or true
a2dCircle at x,y, and with radius
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
a2dAffineMatrix & Mirror(bool y=true, bool x=false)
mirror a matrix in x, y
a2dPATH_END_TYPE
defines the way a polyline with a contour width is ended.
static const a2dCanvasObjectFlagsMask BIN
(In) Visible property that can be added to Docview Objects.
void SetBoxType(int type)
GDSII compatible to sub identify types of rectangles.
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Base class for all types of strokes, understood by a2dDrawer2D classes.
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
void SetSegType(a2dSegType type)
Set the type of the segment.
virtual void InitializeLoad()
Inits the handler for reading.
void SetVersion(wxString version)
set version of library or document
diagram is an appearance for a2dCameleon
wxColour A2DGENERALDLLEXP HexToColour(const wxString &hex)
3-digit hex to wxColour
virtual bool IsTemporary_DontSave() const
Check if this is a temporary object, which should not be saved.
a2dSegType GetSegType()
get the type of the segment
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
void Set(double xs, double ys, double xm, double ym, double xe, double ye)
set arc using begin, end and middle point.
void SetUnitsScale(double scale)
this is the number that defines the physical dimension in meters / inch/ etc.
void MakeStrans(const a2dAffineMatrix &matrix)
create an Strans record for GDSII file
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
wxString m_keyword
keyword for record in KEY data
a2dDrawingId GetDrawingId()
set special id to differentiate drawings
a2dTextGDS text based on wxDC text drawing.
void SetMultiRoot(bool multiRoot=true)
Set true if the document read from a file did not have on erootobject but several.
void ConvertToLines(double aberation=0)
Convert complex segments to line segments.
const int SPLINE_STEP
number of steps when converting a spline to lines.
void SetPosXY12(double x1, double y1, double x2, double y2, bool afterinversion=true)
sets both positions of line
View on a a2dCanvasDocument.
void SetContourWidth(double width)
set the Contour width of the shape
a2dPropertyIdTyped< wxString, a2dStringProperty > a2dPropertyIdString
property of this type
union Strans::@12 m_stransflags
Strans bit flags for reading and writing to binary file.
unsigned int GetChildObjectsCount() const
get number of child objects
bool GetAvailable()
are there objects on this layer
void SetRadius(double radius)
set radius
double GetRadius() const
return radius
void SetContourWidth(double width)
set a contour width
virtual void InitializeSave()
Inits the handler for writing.
OVERLAP Intersect(const a2dBoundingBox &, double Marge=0) const
virtual void ResetSave()
Reset the object after saving.
a2dCanvasObject * GetRootObject() const
get the root object, which holds the objects in the document
double GetContourWidth() const
get the Contour width of the shape
polygon defined with list of points.
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object.
bool Rotate(double angle)
Rotate clockwise by the given number of degrees:
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
void SetContourWidth(double width)
set the Contour width of the shape
void SetSpline(bool on)
set to true, the polygon will be drawn as a spline
property to hold a double type variable to be associated with a a2dObject
double m_y3
control point 2
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
a2dDocumentInputStream * m_streami
file or other string stream containing the format to parse.
a2dPropertyIdTyped< wxInt32, a2dInt32Property > a2dPropertyIdInt32
property of this type
virtual void SetName(const wxString &name)
Set name for layer.
property to hold a bool type variable to be associated with a a2dObject
bool IsIdentity(void) const
Is the matrix the identity matrix?
double m_x3
control point 2
double m_x2
x2 x of arc midpoint
void SetChord(bool chord)
if true draw as a chord ( no fill end no lines to center )
wxString A2DGENERALDLLEXP ColourToHex(const wxColour &colour)
RGB to 3-digit hex.
a2dGlobal * a2dGlobals
global a2dCanvasGlobal to have easy access to global settings
a2dPropertyIdTyped< bool, a2dBoolProperty > a2dPropertyIdBool
property of this type
a2dDrawing * GetDrawing() const
get the root object, which holds the objects in the document.
a2dRectC is a centered rectangle
virtual void InitializeSave()
Inits the handler for writing.
int GetDataType()
GDSII compatible to sub identify this object.
The base class for all drawable objects in a a2dCanvasDocument.
void SetFilename(const wxString filename, wxBitmapType type, bool doread=true)
set filename and type of image for saving.
wxString GetName() const
Get the name of the a2dPropertyId object.
list of a2dNamedProperty objects
void SetLibraryName(const wxString &libraryname)
to name the document as a library (independent of a path and filename )
Arc Segment in a2dVertexList.
vertex array of line and arc segments.
object to show several appearance views on what it contains
void SetDrawingId(a2dDrawingId id)
get special id to differentiate drawings
a2dCanvasObject is the base class for Canvas Objects.
this segmnet is part of a hole
std::vector< a2dLayerInfoPtr > & GetLayerIndex()
return array index on Layer
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
double m_y2
control point 1
Docview framework its controlling class.
a2dCanvasObjectArrayReference is an array of a reference to any a2dCanvasObject derived class...
a2dPATHSEG_END GetClose() const
is this segment the closing a part since the last move
not specific or part of outer contour
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
void SetWidth(double w)
set width of rectangle
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
vertex list of line and arc segments.
a2dPATH_END_TYPE GetPathType()
get when m_contourwidth != 0 what is the end of the lines looks like.
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
a2dCanvasDocument * m_doc
the document to store/load the data found into
special a2dCanvasObject which are used to create hierarchy different from the standard a2dCanvasObjec...
bool GetVisible()
is the layer visible
virtual void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
wxUint32 m_linenumber
last read line in DATA
store and convert number to number with unit and visa versa. e.g. 1.23e-6 => 1.23 * 1e-6 ...
a2dPATH_END_TYPE GetPathType()
get when m_contourwidth != 0 what is the end of the line looks like.
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)
Should return true if the handler can read from the stream.
void SetBin(bool bin)
general flag use at will.
void SetUnitsAccuracy(double accuracy)
this is the number that defines the number of decimal places in the fraction
void SetContourWidth(double width)
set the Contour width of the shape
void AddToRoot(bool autoPlace=true)
add this to ms_centralCameleonRoot at a suitable position
vector path a2dVectorPath derived from a2dCanvasObject
GDSII format input and output.
a2dIOHandlerStrIn & SeekI(wxFileOffset pos)
set stream at a position
property to hold a 2 byte integer type variable to be associated with a a2dObject ...
void SetHeight(double h)
set height of rectangle
bool GetCheck() const
general flag use at will.
a2dStrokeStyle StrokeString2Style(const wxString &stylestr)
convert a string to a style enum
void SetRootRecursive()
set a2dDrawing to its nested a2dCanvasObject's recursive for whole tree
a2dText is an abstract base class.
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the line should be.
wxUint16 GetTextType()
GDSII compatible to sub identify types of rectangles.
bool HasArcs() const
return true if there are a2dArcSegment segments.
virtual wxString GetName() const
Get name for layer.
wxString GetVersion()
get version of library or document
double GetMinX() const
get minimum X of the boundingbox
a2dCameleon * GetCameleon()
this appearance is for the returned a2dCameleon here.
void SetColour(const wxColour &col)
set colour used for gradient and wxSTROKE_MASK_OPAQUE filling.
virtual void InitializeLoad()
Inits the handler for reading.
#define forEachIn(listtype, list)
easy iteration for a2dlist
bool IsUserDefined() const
true if this property is user defined
a2dEllipse centered at x,y.
polyline defined with list of points.
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
a2dCameleonInst to show one appearance of an a2dCameleon.
double GetPosX() const
get x position from affine matrix
layer settings for a a2dCanvasDocument Holds layers settings classes
void SetTextType(wxUint16 type)
GDSII compatible to sub identify types of rectangles.
wxString GetUnits()
this string defines the unit e.g. meters / inch/ etc.
Normal straight line segment in a2dVpath.
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! )
static a2dPropertyIdBool * PROPID_TemporaryObject
set for objects that do not have to be saved
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
a2dImage (will scale/rotate image when needed)
Normal straight line segment in a2dVertexList and a2dVertexArray.
bool CalcR(a2dVpathSegmentPtr prev, double &radius, double ¢er_x, double ¢er_y, double &beginrad, double &midrad, double &endrad, double &phit)
Calculation of center for the Arc.
void SetTextHeight(double height)
set text height in world coordinates
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
return text as a vector path, where text outline is converted to polyline or polygons.
TWO_G_BYTE_UNSIGNED_INTEGER m_recordsize
size of the last read record
double GetLineHeight() const
Height in world coordinates of one line.
virtual void ResetSave()
Reset the object after saving.
const a2dPropertyId * GetId() const
Get the a2dPropertyId object identifying this property.
wxUint16 GetLayer() const
Returns the layer index where this object is drawn upon.
int CollectObjects(a2dCanvasObjectList *total, const wxString &type=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=NULL, const a2dBoundingBox &bbox=wxNonValidBbox)
Copy objects fitting the given filter to the total list.
void SetColour(const wxColour &col)
set colour used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
void SetMin(double px, double py)
set the bounding box its maximum
contains the layer properties for one layer,
bool GetBin() const
general flag use at will.
double GetTextHeight() const
get text height in world coordinates
Tappear * GetAppearance(bool autoCreate=false)
Get a specific a2dAppear derived class instance from here.
bool GetSpline()
Get the polygon spline setting.
a2dArrow is used for having line begin and ends on specific objects.
a2dHashMapIntToObject & GetObjectHashMap()
This is used to find multiple referenced objects by id.
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument
wxDateTime & GetModificationTime()
Returns the time of last modification when the document was saved.
std::vector< int > m_mapping
mapping of GDSII layers to internal layers
void SetWidth(double width)
set width
property to hold a wxString type variable to be associated with a a2dObject
wxFileName GetFilename() const
Get the file name in use for this document.
double m_x2
control point 1
double GetContourWidth() const
get the Contour width of the shape
A 2x3 affine matrix class for 2D transformations.
a2dView * GetCurrentView() const
return the one that is active right now (e.g. has focus in case of a wxWindow), or NULL ...
double GetOy(const a2dLineSegment &prev) const
Get origin Y of arc.
bool CanSave(const wxObject *obj=NULL)
Should return true if the handler can write this document to a stream.
wxClassInfo * m_docClassInfo
Run-time class information that allows document instances to be constructed dynamically.
double GetMaxX() const
get maximum X of the boundingbox
double m_y2
y2 y of arc midpoint
double GetPosY() const
get y position from affine matrix
bool LoadLayers(const wxString &filename)
load layers from another file
bool GetFilling() const
if true, filling is on else filling is transparent.
void Aberration(double angle, double radius, double &dphi, unsigned int &segments)
based on angle and radius and m_displayaberration calculate a proper delta phi and number of segments...
void SetMax(double px, double py)
set the bounding box its minimum
a2dSegType
defines the type of a segment in a a2dLineSegment
double GetOx(const a2dLineSegment &prev) const
Get origin X of arc.
wxInputStream a2dDocumentInputStream
input stream based wxStreams
virtual void WriteDouble(double d)
write a double number.
double m_x
x endpoint of line
polygon defined with list of points for outer contour plus a list of hole polygons ...
a2dWalker based algorithms
wxString m_value
value for record in KEY data
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! )
a2dCanvasDocument * m_doc
the document to store/load the data found into
special a2dCanvasObject to make a multi view hierachy.
double m_y
y endpoint of line
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
a2dPATHSEG GetType() const
easy way to test type of segment
Output driver for KEY files.
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
std::vector< a2dLayerInfoPtr > & GetReverseOrderIndex()
return array index on ReverseOrder
void SetHeight(double height)
set height
virtual bool Load(a2dDocumentInputStream &stream, wxObject *doc)
override to read the stream and store (part of) the contents in to a specific a2dDocument or othere o...
double GetUnitsAccuracy()
this is the number that defines the number of decimal places in the fraction
void SetText(const wxString &text)
set the text for the object ' ' in string means new line
bool m_textAsPath
if true, vonvert text to a2dVpath
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
bool GetRelease() const
get release flag
void SetAberPolyToArc(const a2dDoMu &aber)
Polygon/polyline to Arc Maximum abberation.
double m_y1
y endpoint of line
class to hold GDS-II transformation info, only used within the GDSII reader
wxString StrokeStyle2String(a2dStrokeStyle style)
convert a style enum to a string
double GetMaxY() const
get maximum Y of the boundingbox
int m_recordtype
type of the record in KEY data
wxString GetMultiplierString() const
get the number 1.1 um -> "um"
bool m_back
last read record is stored
void SetUnits(const wxString &unitString)
this string defines the unit e.g. meters / inch/ etc.
wxColour GetColour() const
return colour
a2dAppear * GetAppearance()
get referenced a2dCameleon
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
bool Scale(double scale)
Scale by scale (isotropic scaling i.e. the same in x and y):
bool Start(a2dCanvasObject *object, bool setTo)
start removing properties from the object given, and down.
bool Translate(double x, double y)
Translate by dx, dy:
virtual void ReportErrorF(const a2dError &error, const wxChar *Format,...)
concatenate to the the error report the given error.
const a2dError a2dError_NotSpecified
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
virtual wxString StringValueRepresentation() const
const a2dNamedPropertyList & GetPropertyList() const
Get the Property List.
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
std::vector< a2dLayerInfoPtr > & GetOrderIndex()
return array index on Order
void SetTitle(const wxString &title, bool notifyViews=false)
Sets the title for this document.
void SetLayerSetup(a2dLayers *layersetup)
set the layersettings for the canvas.
all polygon and polyline a2dCanvasObject are here.
A property id defined by user.
double GetMinY() const
get minimum Y of the boundingbox
void SetFilling(bool OnOff)
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 ResetLoad()
Reset the handler after loading.
double m_x1
x endpoint of line
virtual bool Save(a2dDocumentOutputStream &stream, const wxObject *doc)
Override to write to the stream and store (part of) of the document contents in the stream...
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
a2dVpath * GetSegments()
modify point at index to x,y
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
a2dCanvasObject for a Vector Path
This template class is for property ids with a known data type.
wxMBConv & m_conv
unicode conversion
links an outside contour with a hole
const a2dDoMu & GetAberPolyToArc() const
Polygon/polyline to Arc Maximum abberation.
void SetLineSpacing(double linespace)
Set Space in world coordinates between two lines.
static void SetCameleonRoot(a2dCanvasObject *cameleonRoot)
set the root where all a2dCameleon's are stored
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
a2dStrokeStyle
stroke styles for a2dStroke
wxDateTime & GetAccessTime()
Returns the time of last access.
static a2dPropertyIdUint16 * PROPID_Datatype
used in GDSII and KEY format to specify the DATATYPE of elements
wxString GetText() const
get the text of the object ' ' in string means new line
void SetContourWidth(double width)
set the Contour width of the shape
void SetShowObject(a2dCanvasObject *show)
what to display when document is openened
void SetContourWidth(double width)
set the Contour width of the shape
void SetTopCameleon(a2dCameleon *root)
what is the top a2dcameleon in the drawing to display after opening a document, when m_show is not se...
virtual bool LinkReferences(bool ignoreNonResolved=false)
link references to their destination
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
a2dDocumentOutputStream * m_streamo
file or other string stream containing the format to output to.
wxString GetTitle() const
Returns the title for this document.
virtual void WriteString(const wxString &string)
write a string
double GetContourWidth() const
get the Contour width of the shape
virtual void ResetLoad()
Reset the handler after loading.
bool ResolveOrAddLink(a2dObject *obj, const wxString &id=wxT(""))
try to resolve an object referenced by obj using the LinkReference function
void SetDataTypeProperty(a2dCanvasObject *toobject, wxUint16 type)
set datatype of elements as a property
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
wxString & GetLibraryName()
Get name the document as a library (independent of a path and filename )
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
std::vector< int > m_mapping
mapping of GDSII layers to internal layers
a2dEllipticArc centered at x,y
a2dPropertyIdTyped< double, a2dDoubleProperty > a2dPropertyIdDouble
property of this type
general canvas module declarations and classes