28 #include "a2dprivate.h"
36 #include "wx/editor/candoc.h"
46 #include <wx/datetime.h>
91 #define MAX_G_BYTES 8 // maximum bytes a value can use
96 unsigned char array[MAX_G_BYTES];
100 char array[MAX_G_BYTES];
111 TWO_G_BYTE_SIGNED_INTEGER two_byte_signed_integer;
112 FOUR_G_BYTE_SIGNED_INTEGER four_byte_signed_integer;
113 FOUR_G_BYTE_REAL four_byte_real;
114 EIGHT_G_BYTE_REAL eight_byte_real;
121 unsigned int a2dIOHandlerGDSIn::ReadUnsignedInt()
125 a_value.eight_byte_real = 0;
127 a2dIOHandlerStrIn::Read( a_value.arrayc.array, 2 );
129 #if wxBYTE_ORDER == wxBIG_ENDIAN
131 swap = a_value.array.array[1];
132 a_value.array.array[1] = a_value.array.array[0];
133 a_value.array.array[0] = swap;
135 return a_value.two_byte_signed_integer;
140 int a2dIOHandlerGDSIn::ReadInt()
144 a_value.eight_byte_real = 0;
146 a2dIOHandlerStrIn::Read( a_value.arrayc.array, 2 );
148 #if wxBYTE_ORDER == wxBIG_ENDIAN
150 swap = a_value.array.array[1];
151 a_value.array.array[1] = a_value.array.array[0];
152 a_value.array.array[0] = swap;
154 return a_value.two_byte_signed_integer;
158 long a2dIOHandlerGDSIn::ReadLong()
167 a2dIOHandlerStrIn::Read( array, 4 );
169 #if wxBYTE_ORDER == wxBIG_ENDIAN
170 a_value.array.array = array;
173 a_value.array.array[3] = array[0];
174 a_value.array.array[2] = array[1];
175 a_value.array.array[1] = array[2];
176 a_value.array.array[0] = array[3];
180 return a_value.four_byte_signed_integer;
184 float a2dIOHandlerGDSIn::ReadFloat()
191 #if wxBYTE_ORDER == wxBIG_ENDIAN
192 for(
short int i = 0; i <= 3; i++ )
194 for(
short int i = 3; i >= 0; i-- )
196 a_value.array.array[i] =
GetC();
204 return a_value.four_byte_real;
209 double a2dIOHandlerGDSIn::ReadDouble()
217 for( i = 0; i < 8; i++ )
218 a_value.array.array[i] =
GetC();
223 return a_value.eight_byte_real;
272 bldun() { memset( by, 0,
sizeof( wxFloat64 ) ); }
275 wxByte by[
sizeof( wxFloat64 ) /
sizeof( wxByte ) ];
276 wxUint32 fl[
sizeof( wxFloat64 ) /
sizeof( wxUint32 ) ];
291 wxUint32 carry, e, mantissa[2], s;
292 # if defined(ultrix) || wxBYTE_ORDER == wxLITTLE_ENDIAN
296 #if wxBYTE_ORDER == wxLITTLE_ENDIAN
299 for ( j = 0; j < 8; j++ )
300 bld.by[j] = fb[7 - j];
302 for ( j = 0; j < 8; j++ )
308 if( bld.fl[0] == 0 && bld.fl[1] == 0 )
return;
311 s = ( bld.fl[1] & 0x80000000L ) >> 31;
313 e = ( bld.fl[1] & 0x7F000000L ) >> 24;
316 mantissa[0] = bld.fl[1] & 0x00FFFFFFL;
317 mantissa[1] = bld.fl[0];
320 e = 4 * ( e - 64 ) + 128;
321 if ( mantissa[0] == 0 && mantissa[1] == 0 && e != 0 )
326 for ( j = 0; j < 8; j++ )
332 while( mantissa[0] < 0x00800000L )
335 carry = mantissa[1] >> 31;
337 mantissa[0] = mantissa[0] << 1 | carry;
339 mantissa[1] = mantissa[1] << 1;
350 bld.fl[0] = ( mantissa[0] & 0x007F0000L ) >> 16 |
351 ( mantissa[0] & 0x0000FFFFL ) << 16 |
355 bld.fl[1] = mantissa[1] << 16 | mantissa[1] >> 16;
357 for ( j = 0; j < 8; j++ )
363 if ( bld.fl[0] == 0 && bld.fl[1] == 0 )
366 #if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
368 swap = bld.fl[0] ; bld.fl[0] = bld.fl[1] ; bld.fl[1] = swap ;
371 s = ( bld.fl[0] & 0x80000000L ) >> 31;
373 e = ( bld.fl[0] & 0x7F000000L ) >> 24;
376 mantissa[0] = bld.fl[0] & 0x00FFFFFFL;
377 mantissa[1] = bld.fl[1];
403 e = 4 * ( e - 64 ) + 1023;
405 if ( mantissa[0] == 0 && mantissa[1] == 0 && e != 0 )
409 bld.fl[0] = 0x00000000L;
410 bld.fl[1] = 0x00000000L;
413 for ( j = 0; j < 8; j++ )
419 while ( mantissa[0] < 0x01000000L )
422 carry = mantissa[1] >> 31;
423 mantissa[0] = ( mantissa[0] << 1 ) | carry;
424 mantissa[1] = mantissa[1] << 1;
431 if( e < 1 || e > 2047 )
433 bld.fl[0] = 0x80000000L;
434 bld.fl[1] = 0x00000000L;
436 #if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
438 bld.fl[0] = bld.fl[1];
443 for ( j = 0; j < 8; j++ )
450 bld.fl[0] = ( ( mantissa[0] & 0x00FFFFFFL ) >> 4 ) | ( s << 31 ) | ( e << 20 );
451 bld.fl[1] = ( mantissa[0] << 28 ) | ( mantissa[1] >> 4 );
453 #if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
455 bld.fl[0] = bld.fl[1];
459 for ( j = 0; j < 8; j++ )
501 wxUint32 carry, e, f[2], s;
504 for ( j = 0; j < 8; j++ )
507 hard_check.f[0] = bld.fl[0];
508 hard_check.f[1] = bld.fl[1];
511 s = ( bld.fl[0] & 0x00008000L ) >> 15;
513 e = ( bld.fl[0] & 0x00007F80L ) >> 7;
515 if( s == 0 & e == 0 )
517 bld.fl[0] = bld.fl[1] = 0;
519 for ( j = 0; j < 8; j++ )
525 f[0] = ( bld.fl[0] & 0x0000007FL ) << 16 | bld.fl[0] >> 16 | 0x00800000L;
527 f[1] = bld.fl[1] << 16 | bld.fl[1] >> 16;
533 while ( ( e % 4 ) != 0 )
536 carry = f[0] & 0x00000001L;
538 f[1] = f[1] >> 1 | carry << 31;
547 bld.fl[1] = f[0] | e << 24 | s << 31;
551 if ( hard_check.check == 1E-9 )
552 bld.fl[0] = bld.fl[0] & 0XFFFFFF51L;
554 for ( j = 0; j < 8; j++ )
559 wxUint32 carry, f[2], s;
560 #
if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
566 for ( j = 0; j < 8; j++ )
570 hard_check.f[0] = bld.fl[0];
571 hard_check.f[1] = bld.fl[1];
573 #
if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
575 bld.fl[0] = bld.fl[1];
580 s = ( bld.fl[0] & 0x80000000L ) >> 31;
582 e = ( bld.fl[0] & 0x7FF00000L ) >> 20;
585 if( ( s == 0 ) & ( e == 0 ) )
588 bld.fl[0] = bld.fl[1] = 0;
590 #if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
593 for ( j = 0; j < 8; j++ )
594 fb[j] = bld.by[7 - j];
596 for ( j = 0; j < 8; j++ )
604 f[0] = ( bld.fl[0] & 0x000FFFFFL );
622 while( ( e % 4 ) != 0 )
637 if( e < 0 || e > 127 )
639 bld.fl[0] = 0x80000000L;
640 bld.fl[1] = 0x00000000L;
642 #if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
644 bld.fl[0] = bld.fl[1];
648 #if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
651 for ( j = 0; j < 8; j++ )
652 fb[j] = bld.by[7 - j];
654 for ( j = 0; j < 8; j++ )
662 bld.fl[0] = f[0] | ( e << 24 ) | ( s << 31 );
666 if( hard_check.check == 1E-3 )
667 bld.fl[1] = ( bld.fl[1] & 0XFFFFFF00L ) | 0X000000EFL;
668 if( hard_check.check == 1E-9 )
669 bld.fl[1] = ( bld.fl[1] & 0XFFFFFF00L ) | 0X00000051L;
672 #if wxBYTE_ORDER == wxLITTLE_ENDIAN || defined(ultrix)
674 bld.fl[0] = bld.fl[1];
677 #if wxBYTE_ORDER == wxLITTLE_ENDIAN
680 for ( j = 0; j < 8; j++ )
681 fb[j] = bld.by[7 - j];
683 for ( j = 0; j < 8; j++ )
698 if ( ( ceil( getal ) - getal ) < 0.0001 )
699 return ceil( getal );
701 else if ( ( getal - floor( getal ) ) < 0.0001 )
703 return floor( getal );
718 bool a_abs_angle,
bool a_abs_scale,
bool a_reflection )
722 SetAbsAngle( a_abs_angle );
723 SetAbsScale( a_abs_scale );
724 SetReflection( a_reflection );
733 SetAbsAngle(
bool( a_strans.
m_stransflags.bits.abs_angle ) );
734 SetAbsScale(
bool( a_strans.
m_stransflags.bits.abs_scale ) );
735 SetReflection(
bool( a_strans.
m_stransflags.bits.reflection ) );
736 SetAngle( a_strans.m_angle );
737 SetScale( a_strans.m_scale );
743 bool Strans::GetStrans()
745 return m_strans_need;
748 void Strans::SetAngle(
double a_angle )
752 m_strans_need =
true;
756 void Strans::SetScale(
double a_scale )
760 m_strans_need =
true;
764 void Strans::SetAbsAngle(
bool b )
770 void Strans::SetAbsScale(
bool b )
776 void Strans::SetReflection(
bool b )
783 double Strans::GetAngle()
789 double Strans::GetScale()
795 bool Strans::GetAbsAngle()
801 bool Strans::GetAbsScale()
807 bool Strans::GetReflection()
815 double scale_factor = matrix.
GetValue( 0, 0 );
818 double temp1 = matrix.
GetValue( 0, 0 );
820 double temp2 = matrix.
GetValue( 0, 1 );
821 bool check_1 = ( matrix.
GetValue( 0, 0 ) < 0 );
823 bool check_2 = ( matrix.
GetValue( 1, 1 ) < 0 );
825 m_strans_need =
false;
830 SetReflection(
true );
832 SetAngle( rot_angle );
833 m_strans_need =
true;
839 SetReflection( !GetReflection() );
840 m_strans_need =
true;
849 SetAngle( rot_angle );
850 if ( rot_angle != 90 && rot_angle != -90 )
851 scale_factor = matrix.
GetValue( 0, 0 ) / cos( ( rot_angle / 180 ) *
wxPI );
853 scale_factor = matrix.
GetValue( 1, 0 ) / sin( ( rot_angle / 180 ) *
wxPI );
854 m_strans_need =
true;
860 scale_factor =
Check_int( scale_factor );
862 if ( scale_factor < 0 )
863 scale_factor = -scale_factor;
865 if ( scale_factor != 1 )
867 SetScale( scale_factor );
868 m_strans_need =
true;
877 a2dIOHandlerGDSIn::a2dIOHandlerGDSIn()
879 m_fontType = a2dFONT_STROKED;
883 m_asCameleons =
false;
886 a2dIOHandlerGDSIn::~a2dIOHandlerGDSIn()
929 bool a2dIOHandlerGDSIn::LinkReferences()
940 a2dCanvasObjectList::iterator delnode = rootchild;
942 if ( ( *delnode )->GetCheck() )
959 if ( wxFileExists( path ) )
972 for ( i = 0; i < wxMAXLAYER; i++ )
974 for ( i = 0; i < wxMAXLAYER; i++ )
979 wxASSERT_MSG( layerIndex >= 0 && layerIndex < wxMAXLAYER, _(
"InMap must be > wxMAXLAYER" ) );
984 for ( i = 0; i < wxMAXLAYER; i++ )
1004 void a2dIOHandlerGDSIn::ReadGdsII()
1020 throw GDS_Error( _(
"GDS_HEADER record missing (in GDSII)" ), _(
"Error" ) );
1023 s.Printf(
"%d", ReadInt());
1026 if ( !ReadBgnlib() )
1027 throw GDS_Error( _(
"BGNLIB record missing (in GDSII)" ) );
1029 if ( !ReadLibrarySettings() )
1030 throw GDS_Error( _(
"LIBNAME missing (in GDSII)" ) );
1032 if ( m_asCameleons )
1046 throw GDS_Error( _(
"GDS_ENDLIB record missing (in GDSII)" ), _(
"Error" ) );
1053 if ( m_asCameleons )
1059 throw GDS_Error( wxT(
"no structures found" ) );
1106 bool a2dIOHandlerGDSIn::ReadBgnlib()
1119 month = ReadInt() - 1;
1128 month = ReadInt() - 1;
1134 m_doc->
GetAccessTime().Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
1140 bool a2dIOHandlerGDSIn::ReadLibrarySettings()
1143 throw GDS_Error( _(
"GDS_LIBNAME record missing (in GDSII)" ), _(
"Error" ) );
1166 throw GDS_Error( _(
"UNITS missing (in GDSII)" ) );
1168 m_userunits_out = ReadDouble();
1171 value1 = ReadDouble();
1172 double metersScale = value1 / m_userunits_out;
1177 unit =
a2dDoMu( 1, metersScale );
1197 throw GDS_Error( _(
"Unexpected end of GDSII-file!" ), _(
"Driver Error" ) );
1203 m_recordsize -= ( TWO_G_BYTE_UNSIGNED_INTEGER ) GDS_HEADERSIZE;
1234 int last_read = a2dIOHandlerStrIn::Read( buf,
m_recordsize );
1237 a_string = wxString( buf, wxConvUTF8,
m_recordsize - 1 );
1245 if ( ReadBoundary( parent ) ||
1246 ReadPath( parent ) ||
1247 ReadStructureReference( parent ) ||
1248 ReadArrayReference( parent ) ||
1249 ReadText( parent ) ||
1250 ReadNode( parent ) ||
1257 while ( ReadProperty() )
1261 throw GDS_Error( _(
"ENDEL missing (in Element)" ) );
1268 bool a2dIOHandlerGDSIn::ReadProperty()
1275 propattr = ReadInt();
1278 throw GDS_Error( _(
"Unexpected end of GDSII-file!" ), _(
"GDSII Input parsing Error" ) );
1284 throw GDS_Error( _(
"PROPVALUE missing (in Property)" ) );
1287 G_BYTE propval[126];
1291 throw GDS_Error( _(
"Unexpected end of GDSII-file!" ), _(
"GDSII Input parsing Error" ) );
1293 propval[i] =
GetC();
1317 ReadElflags( _Boundary );
1322 if ( !ReadLayer( _Boundary ) )
1323 throw GDS_Error( _(
"Boundary: LAYER missing (in GDS-file)" ) );
1326 throw GDS_Error( _(
"Boundary: DATATYPE missing (in GDS-file)" ) );
1328 SetDataTypeProperty( _Boundary, ReadInt() );
1332 if ( !Read( _Boundary ) )
1333 throw GDS_Error( _(
"Header: XY missing (in Boundary)" ) );
1335 parent->
Append( _Boundary );
1358 ReadElflags( path );
1363 if ( !ReadLayer( path ) )
1364 throw GDS_Error( _(
"record LAYER missing (in Path)" ) );
1367 throw GDS_Error( _(
"record DATATYPE missing (in Path)" ) );
1369 SetDataTypeProperty( path, ReadInt() );
1386 throw GDS_Error( _(
"Header: XY missing (in Path)" ) );
1417 elflags = ReadInt();
1423 if ( !ReadLayer( layer ) )
1424 throw GDS_Error( _(
"Text: LAYER is missing (in GDS-file)" ) );
1430 throw GDS_Error( _(
"Text: TEXTBODY is missing (in GDS-file)" ) );
1432 int texttype = ReadInt();
1433 int presentation = 0;
1435 long textHeight = 0;
1438 presentation = ReadInt();
1441 pathtype = ReadInt();
1448 textHeight = ReadLong();
1452 ReadStrans( Strans );
1455 throw GDS_Error( _(
"Text: XY is missing (in GDS-file)" ) );
1466 if ( Strans.GetReflection() )
1467 relative_matrix.
Mirror();
1470 if ( Strans.GetAbsAngle() == 0 )
1471 relative_matrix.
Rotate( Strans.GetAngle(), 0, 0 );
1474 if ( Strans.GetAbsScale() == 0 )
1482 relative_matrix.
Translate( point.m_x, point.m_y );
1485 throw GDS_Error( _(
"Text: STRING is missing (in GDS-file)" ) );
1489 a_string.Replace( wxT(
"\t" ), wxT(
" " ) );
1496 Text->SetPathtype( ( TEXT_PATHTYPE )pathtype );
1500 Text->SetTemplate( (
bool ) ( elflags && 2 ) );
1501 Text->SetExternal( (
bool ) ( elflags && 1 ) );
1503 Text->SetTemplate( (
bool ) ( elflags && 1 ) );
1504 Text->SetExternal( (
bool ) ( elflags && 2 ) );
1516 bool a2dIOHandlerGDSIn::ReadStructureReference(
a2dCanvasObject* parent )
1522 if ( m_asCameleons )
1523 return ReadStructureCameleonReference( parent );
1535 ReadElflags( sref );
1541 throw GDS_Error( _(
"Header: SNAME missing (in Structure Reference)" ) );
1548 ReadStrans( strans );
1551 throw GDS_Error( _(
"Header: XY missing (in Structure Reference)" ) );
1559 if ( strans.GetReflection() )
1560 relative_matrix.
Mirror();
1563 if ( strans.GetAbsAngle() == 0 )
1564 relative_matrix.
Rotate( strans.GetAngle(), 0, 0 );
1567 if ( strans.GetAbsScale() == 0 )
1569 double scale = strans.GetScale();
1570 relative_matrix.
Scale( scale, scale, 0, 0 );
1574 relative_matrix.
Translate( point.m_x, point.m_y );
1590 bool a2dIOHandlerGDSIn::ReadStructureCameleonReference(
a2dCanvasObject* parent )
1606 ReadElflags( sref );
1612 throw GDS_Error( _(
"Header: SNAME missing (in Structure Reference)" ) );
1616 sref->SetAppearanceName( strname + wxT(
":layout") );
1620 ReadStrans( strans );
1623 throw GDS_Error( _(
"Header: XY missing (in Structure Reference)" ) );
1631 if ( strans.GetReflection() )
1632 relative_matrix.
Mirror();
1635 if ( strans.GetAbsAngle() == 0 )
1636 relative_matrix.
Rotate( strans.GetAngle(), 0, 0 );
1639 if ( strans.GetAbsScale() == 0 )
1641 double scale = strans.GetScale();
1642 relative_matrix.
Scale( scale, scale, 0, 0 );
1646 relative_matrix.
Translate( point.m_x, point.m_y );
1679 ReadElflags( arrayref );
1685 throw GDS_Error( _(
"Header: SNAME missing (in Structure Reference)" ) );
1692 ReadStrans( strans );
1695 throw GDS_Error( _(
"Header: COLROW missing (in Array Reference)" ) );
1697 int columns = ReadInt();
1698 arrayref->SetColumns( columns );
1700 int rows = ReadInt();
1701 arrayref->SetRows( rows );
1705 throw GDS_Error( _(
"Header: XY missing (in Array Reference)" ) );
1711 arrayref->SetHorzSpace( sqrt( pow( HorPoint.m_x - Point.m_x, 2 ) + pow( HorPoint.m_y - Point.m_y, 2 ) ) / columns );
1712 arrayref->SetVertSpace( sqrt( pow( VerPoint.m_x - Point.m_x, 2 ) + pow( VerPoint.m_y - Point.m_y, 2 ) ) / rows );
1718 if ( strans.GetReflection() )
1719 relative_matrix.
Mirror();
1722 if ( strans.GetAbsAngle() == 0 )
1723 relative_matrix.
Rotate( strans.GetAngle(), 0, 0 );
1726 if ( strans.GetAbsScale() == 0 )
1728 EIGHT_G_BYTE_REAL scale = strans.GetScale();
1729 relative_matrix.
Scale( scale, scale, 0, 0 );
1733 relative_matrix.
Translate( Point.m_x, Point.m_y );
1736 parent->
Append( arrayref );
1748 bool a2dIOHandlerGDSIn::ReadNode(
a2dCanvasObject* WXUNUSED( parent ) )
1770 if ( !ReadLayer( Box ) )
1771 throw GDS_Error( _(
"Box: LAYER missing (in GDS-file)" ) );
1774 throw GDS_Error( _(
"Box: BOXTYPE missing (in GDS-file)" ) );
1781 int points = m_recordsize / ( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) );
1784 throw GDS_Error( _(
"Wrong number of points in BOX XY." ), _(
"Fatal GDSII error" ) );
1797 double minx, miny, maxx, maxy;
1799 minx = maxx = seg.m_x;
1800 miny = maxy = seg.m_y;
1802 minx = wxMin( minx, seg2.m_x );
1803 maxx = wxMax( maxx, seg2.m_x );
1804 miny = wxMin( miny, seg2.m_y );
1805 maxy = wxMax( maxy, seg2.m_y );
1807 minx = wxMin( minx, seg3.m_x );
1808 maxx = wxMax( maxx, seg3.m_x );
1809 miny = wxMin( miny, seg3.m_y );
1810 maxy = wxMax( maxy, seg3.m_y );
1812 minx = wxMin( minx, seg4.m_x );
1813 maxx = wxMax( maxx, seg4.m_x );
1814 miny = wxMin( miny, seg4.m_y );
1815 maxy = wxMax( maxy, seg4.m_y );
1817 Box->
SetWidth( fabs( maxx - minx ) );
1837 object->SetTemplate( (
bool ) ( value && 2 ) );
1838 object->SetExternal( (
bool ) ( value && 1 ) );
1840 object->SetTemplate( (
bool ) ( value && 1 ) );
1841 object->SetExternal( (
bool ) ( value && 2 ) );
1855 if ( layer < 0 || layer >= wxMAXLAYER )
1859 mes.Printf( _(
"Object %s, layer >= wxMAXLAYER put on layer 0 " ), object->GetClassInfo()->GetClassName() );
1869 bool a2dIOHandlerGDSIn::ReadLayer(
int& layer )
1875 if ( layer < 0 || layer >= wxMAXLAYER )
1879 mes.Printf( wxT(
"%s" ), _(
"Object layer >= wxMAXLAYER put on layer 0 " ) );
1887 bool a2dIOHandlerGDSIn::Read(
a2dPoint2D& Point )
1889 FOUR_G_BYTE_SIGNED_INTEGER value;
1898 bool a2dIOHandlerGDSIn::Read(
a2dPolygonL* polygon )
1903 int points = m_recordsize / ( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) ) - 1;
1912 _(
"GDSII: Structure %s Only one point in Polygon: %f, %f " ),
m_strucname.c_str(), seg.m_x, seg.m_y );
1913 polygon->
AddPoint( seg.m_x, seg.m_y );
1918 throw GDS_Error( _(
"Too few points in Polygon." ), _(
"Fatal GDSII error" ) );
1922 for (
int i = 0; i < points; i++ )
1926 polygon->
AddPoint( seg.m_x, seg.m_y );
1941 int points = m_recordsize / ( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) );
1948 FOUR_G_BYTE_SIGNED_INTEGER value;
1955 _(
"GDSII: Structure %s Only one point in Polyline: %f, %f " ),
m_strucname.c_str(), seg->
m_x, seg->
m_y );
1956 segments->push_back( seg );
1959 throw GDS_Error( _(
"Too few points in Polyline." ), _(
"Fatal GDSII error" ) );
1964 for (
int i = 0; i < points; i++ )
1968 FOUR_G_BYTE_SIGNED_INTEGER value;
1973 segments->push_back( seg );
1983 bool a2dIOHandlerGDSIn::ReadStrans( Strans& Strans )
1988 EIGHT_G_BYTE_REAL real;
1994 real = ReadDouble();
1995 Strans.SetScale( real );
2000 real = ReadDouble();
2001 Strans.SetAngle( real );
2018 Structure->SetIgnoreLayer(
true );
2021 wxDateTime m_modificationtime = wxDateTime::Now();
2022 wxDateTime m_accesstime = wxDateTime::Now();
2032 month = ReadInt() - 1;
2038 m_modificationtime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
2039 a2dCanvasObject::PROPID_ModificationDateTime->
SetPropertyToObject( Structure, m_modificationtime );
2042 month = ReadInt() - 1;
2048 m_accesstime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
2052 throw GDS_Error( _(
"STRNAME record missing (in Structure)" ) );
2061 while ( ReadElement( Structure ) )
2067 throw GDS_Error( _(
"ENDSTR record missing (in GDSII)" ) );
2070 parent->
Append( Structure );
2079 bool a2dIOHandlerGDSIn::ReadCameleonStructure(
a2dCanvasObject* parent )
2089 cam->AddAppearance( layout );
2094 wxDateTime m_modificationtime = wxDateTime::Now();
2095 wxDateTime m_accesstime = wxDateTime::Now();
2105 month = ReadInt() - 1;
2111 m_modificationtime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
2112 a2dCanvasObject::PROPID_ModificationDateTime->
SetPropertyToObject( layout, m_modificationtime );
2115 month = ReadInt() - 1;
2121 m_accesstime.Set( day, ( wxDateTime::Month )month, year, hour, minute, second );
2125 throw GDS_Error( _(
"STRNAME record missing (in Structure)" ) );
2141 throw GDS_Error( _(
"ENDSTR record missing (in GDSII)" ) );
2145 int px = m_dx * 30 * 1.5;
2146 int py = -m_dy * 10 * 1.5;
2149 if ( m_dx > m_refMaxx )
2150 { m_dy++; m_dx =0; }
2159 void a2dIOHandlerGDSIn::SetDataTypeProperty(
a2dCanvasObject* toobject, wxUint16 type )
2169 a2dIOHandlerGDSOut::a2dIOHandlerGDSOut()
2173 m_fromViewAsTop =
false;
2174 m_asCameleons =
false;
2177 a2dIOHandlerGDSOut::~a2dIOHandlerGDSOut()
2208 if ( m_fromViewAsTop )
2216 setflags.
Start( showobject,
false );
2221 for ( i = 0; i < wxMAXLAYER; i++ )
2223 for ( i = 0; i < wxMAXLAYER; i++ )
2225 m_mapping[ m_layers->GetOutMapping( i ) ] = i;
2227 for ( i = 0; i < wxMAXLAYER; i++ )
2240 if ( m_userunits_out == 0 )
2242 wxLogWarning( wxT(
"GDS userunits: 0 was set to 0.01" ) );
2243 m_userunits_out = 0.01;
2256 m_scale_out = pow( 10., l );
2258 WriteHeader( 2, GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER, GDS_HEADER );
2263 WriteInt( version );
2267 WriteHeader( 12 *
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2268 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2286 if ( value % 2 != 0 )
2288 WriteHeader( value, GDSTYPE_ASCII_STRING, GDS_LIBNAME );
2291 WriteHeader( 2 *
sizeof( EIGHT_G_BYTE_REAL ),
2292 GDSTYPE_EIGHT_G_BYTE_REAL,
2295 WriteDouble( m_userunits_out );
2300 if ( m_fromViewAsTop )
2301 towrite.push_back( showobject );
2313 towrite.push_back( ref );
2323 towrite.push_back( showobject );
2330 a2dCanvasObjectList::iterator iter = towrite.begin();
2331 while ( towrite.size() )
2334 SaveStructure( obj, &towrite );
2336 towrite.erase( iter );
2337 iter = towrite.begin();
2340 WriteHeader( 0, 0, GDS_ENDLIB );
2357 WriteHeader( 12 *
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2358 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2361 wxDateTime modTime = a2dCanvasObject::PROPID_ModificationDateTime->
GetPropertyValue(
object );
2363 WriteInt( modTime.GetYear() );
2364 WriteInt( modTime.GetMonth() + 1 );
2365 WriteInt( modTime.GetDay() );
2366 WriteInt( modTime.GetHour() );
2367 WriteInt( modTime.GetMinute() );
2368 WriteInt( modTime.GetSecond() );
2370 wxDateTime accesTime = a2dCanvasObject::PROPID_AccessDateTime->
GetPropertyValue(
object );
2372 WriteInt( accesTime.GetYear() );
2373 WriteInt( accesTime.GetMonth() + 1 );
2374 WriteInt( accesTime.GetDay() );
2375 WriteInt( accesTime.GetHour() );
2376 WriteInt( accesTime.GetMinute() );
2377 WriteInt( accesTime.GetSecond() );
2380 TWO_G_BYTE_UNSIGNED_INTEGER value = ( TWO_G_BYTE_UNSIGNED_INTEGER ) wxStrlen( object->
GetName() );
2381 WriteHeader( value, GDSTYPE_ASCII_STRING, GDS_STRNAME );
2397 if ( !obj->
GetRelease() && m_layers->GetVisible( obj->
GetLayer() ) || obj->GetIgnoreLayer() )
2399 Save( obj, towrite );
2413 if ( !obj->
GetRelease() && m_layers->GetVisible( obj->
GetLayer() ) || obj->GetIgnoreLayer() )
2415 Save( obj, towrite );
2420 WriteHeader( 0, 0, GDS_ENDSTR );
2438 DoSave( obj, towrite );
2452 wxLogWarning( _(
"a2dSurface holes are saved as polygons in contour, better convert to polygons first" ) );
2454 for( a2dListOfa2dVertexList::iterator iterp = holes.begin(); iterp != holes.end(); iterp++ )
2466 DoSave( obj, towrite );
2471 DoSave( obj, towrite );
2476 DoSave( obj, towrite );
2481 DoSave( obj, towrite );
2486 DoSave( obj, towrite );
2491 DoSave( obj, towrite );
2498 DoSave( obj, towrite );
2507 DoSave( obj, towrite );
2521 vectorpaths =
object->GetAsCanvasVpaths(
false );
2523 else if ( wxString( object->GetClassInfo()->GetClassName() ) == wxT(
"a2dCanvasObject" ) )
2525 WriteHeader( 0, 0, GDS_SREF );
2526 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2530 WriteInt( m_objectFlags );
2532 int value = wxStrlen( object->
GetName() );
2533 if ( value % 2 != 0 )
2535 WriteHeader( value, GDSTYPE_ASCII_STRING, GDS_SNAME );
2540 if ( !lworld.IsIdentity() )
2542 Strans* strans =
new Strans();
2544 if ( strans->GetStrans() )
2548 WriteHeader( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
2549 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
2552 WritePoint( object->
GetPosX(),
object->GetPosY() );
2554 WriteHeader( 0, 0, GDS_ENDEL );
2555 towrite->push_back(
object );
2559 wxLogWarning( wxT(
"GDSIO : object %s is not implemented for output" ), object->GetClassInfo()->GetClassName() );
2567 for( a2dCanvasObjectList::iterator iter = vectorpaths->begin(); iter != vectorpaths->end(); ++iter )
2577 WriteHeader( 0, 0, GDS_SREF );
2578 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2582 WriteInt( m_objectFlags );
2584 int value = wxStrlen( object->
GetName() );
2585 if ( value % 2 != 0 )
2587 WriteHeader( value, GDSTYPE_ASCII_STRING, GDS_SNAME );
2592 if ( !lworld.IsIdentity() )
2594 Strans* strans =
new Strans();
2596 if ( strans->GetStrans() )
2600 WriteHeader( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
2601 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
2604 WritePoint( object->
GetPosX(),
object->GetPosY() );
2606 WriteHeader( 0, 0, GDS_ENDEL );
2609 towrite->push_back(
object );
2623 *lpoints = *origpoints;
2726 WriteHeader( 0, 0, GDS_TEXT );
2727 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2731 WriteInt( m_objectFlags );
2733 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2734 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2740 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2741 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2744 WriteInt( TEXT_PATH_END_SQAURE );
2759 Strans strans = Strans();
2762 strans.SetScale( strans.GetScale() * obj->
GetTextHeight() );
2764 if ( strans.GetStrans() )
2769 WriteHeader( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
2770 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
2776 int nrChar = wxStrlen( obj->
GetText() );
2777 if ( nrChar % 2 != 0 )
2779 WriteHeader( nrChar, GDSTYPE_ASCII_STRING, GDS_STRING );
2783 WriteHeader( 0, 0, GDS_ENDEL );
2788 WriteHeader( 0, 0, GDS_TEXT );
2790 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2794 WriteInt( m_objectFlags );
2796 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2797 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2803 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2804 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2809 if ( obj->GetPresentationFlags() )
2812 if ( ( obj->GetFontGDS() != DEFAULT_PRESENTATION_FONT ) ||
2813 ( obj->GetVertical() != DEFAULT_PRESENTATION_VERTICAL ) ||
2814 ( obj->GetHorizontal() != DEFAULT_PRESENTATION_HORIZONTAL ) )
2816 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2819 WriteInt( obj->GetPresentationFlags() );
2823 if ( obj->GetPathtype() )
2825 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2826 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2829 WriteInt( obj->GetPathtype() );
2845 Strans strans = Strans();
2850 if ( strans.GetStrans() )
2855 WriteHeader( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
2856 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
2862 int nrChar = wxStrlen( obj->
GetText() );
2863 if ( nrChar % 2 != 0 )
2865 WriteHeader( nrChar, GDSTYPE_ASCII_STRING, GDS_STRING );
2869 WriteHeader( 0, 0, GDS_ENDEL );
2874 WriteHeader( 0, 0, GDS_SREF );
2875 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2879 WriteInt( m_objectFlags );
2881 int value = wxStrlen( obj->
GetName() );
2882 if ( value % 2 != 0 )
2884 WriteHeader( value, GDSTYPE_ASCII_STRING, GDS_SNAME );
2889 if ( !lworld.IsIdentity() )
2891 Strans* strans =
new Strans();
2893 if ( strans->GetStrans() )
2897 WriteHeader( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
2898 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
2903 WriteHeader( 0, 0, GDS_ENDEL );
2911 WriteHeader( 0, 0, GDS_AREF );
2912 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2916 WriteInt( m_objectFlags );
2918 int value = wxStrlen( obj->
GetName() );
2919 if ( value % 2 != 0 )
2921 WriteHeader( value, GDSTYPE_ASCII_STRING, GDS_SNAME );
2926 if ( !lworld.IsIdentity() )
2928 Strans* strans =
new Strans();
2930 if ( strans->GetStrans() )
2934 WriteHeader( 2 *
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2935 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
2938 WriteInt( obj->GetColumns() );
2939 WriteInt( obj->GetRows() );
2941 WriteHeader( 6 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
2942 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
2947 WritePoint( obj->
GetPosX() + obj->GetHorzSpace() * obj->GetColumns(), obj->
GetPosY() );
2948 WritePoint( obj->
GetPosX(), obj->
GetPosY() + obj->GetVertSpace() * obj->GetRows() );
2950 WriteHeader( 0, 0, GDS_ENDEL );
2962 WriteHeader( 0, 0, GDS_SREF );
2963 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
2967 WriteInt( m_objectFlags );
2970 if ( value % 2 != 0 )
2972 WriteHeader( value, GDSTYPE_ASCII_STRING, GDS_SNAME );
2977 if ( !lworld.IsIdentity() )
2979 Strans* strans =
new Strans();
2981 if ( strans->GetStrans() )
2985 WriteHeader( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
2986 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
2991 WriteHeader( 0, 0, GDS_ENDEL );
3002 void a2dIOHandlerGDSOut::Write( Strans* Strans )
3005 if ( ( Strans->
m_stransflags.bits.abs_angle != DEFAULT_STRANS_ABS_ANGLE ) ||
3006 ( Strans->
m_stransflags.bits.abs_scale != DEFAULT_STRANS_ABS_SCALE ) ||
3007 ( Strans->
m_stransflags.bits.reflection != DEFAULT_STRANS_REFLECTION ) ||
3008 ( Strans->GetScale() != DEFAULT_STRANS_SCALE ) ||
3009 ( Strans->GetAngle() != DEFAULT_STRANS_ANGLE ) )
3011 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3017 if ( Strans->GetScale() != DEFAULT_STRANS_SCALE )
3019 WriteHeader(
sizeof( EIGHT_G_BYTE_REAL ),
3020 GDSTYPE_EIGHT_G_BYTE_REAL,
3022 WriteDouble( Strans->GetScale() );
3027 if ( Strans->GetAngle() != DEFAULT_STRANS_ANGLE )
3029 WriteHeader(
sizeof( EIGHT_G_BYTE_REAL ),
3030 GDSTYPE_EIGHT_G_BYTE_REAL,
3032 WriteDouble( Strans->GetAngle() );
3037 void a2dIOHandlerGDSOut::WriteHeader( TWO_G_BYTE_UNSIGNED_INTEGER nw_recordsize, G_BYTE nw_datatype, G_BYTE nw_recordtype )
3040 if ( nw_datatype == GDSTYPE_ASCII_STRING &&
3041 ( nw_recordsize % 2 ) != 0 )
3044 WriteInt( nw_recordsize + GDS_HEADERSIZE );
3045 WriteByte( nw_recordtype );
3046 WriteByte( nw_datatype );
3048 m_recordsize = ( TWO_G_BYTE_UNSIGNED_INTEGER ) nw_recordsize;
3055 int value = a_string.Len();
3056 for (
int i = 0 ; i < value; i++ )
3057 WriteByte( a_string[i] );
3059 if ( value % 2 != 0 )
3060 WriteByte( wxT(
'\0' ) );
3067 if ( ( Element->GetTemplate() != 0 ) ||
3068 ( Element->GetExternal() != 0 ) )
3072 if ( Element->GetTemplate() )
3073 m_objectFlags += 1 << 1;
3075 if ( Element->GetExternal() )
3076 m_objectFlags += 1 << 2;
3081 void a2dIOHandlerGDSOut::WritePoint(
double xi,
double yi )
3086 x = ( long ) ( xi / m_userunits_out / m_scale_out + 0.5 );
3088 x = ( long ) ( xi / m_userunits_out / m_scale_out - 0.5 );
3090 y = ( long ) ( yi / m_userunits_out / m_scale_out + 0.5 );
3092 y = ( long ) ( yi / m_userunits_out / m_scale_out - 0.5 );
3098 void a2dIOHandlerGDSOut::WriteVpath(
const a2dAffineMatrix& lworld,
const a2dVpath* path,
int layer,
int datatype,
int pathtype,
double width )
3108 bool nostrokeparts =
false;
3111 for ( i = 0; i < path->size(); i++ )
3139 nostrokeparts =
true;
3143 nostrokeparts =
true;
3148 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3149 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3156 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 );
3157 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 );
3167 nostrokeparts =
true;
3172 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3173 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3180 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
3181 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
3191 nostrokeparts =
true;
3196 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
3198 if ( cseg->
CalcR( path->Item( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
3201 unsigned int segments;
3204 double theta = beginrad;
3207 for ( step = 0; step < segments + 1; step++ )
3209 lworld.
TransformPoint( center_x + radius * cos ( theta ), center_y + radius * sin ( theta ), x, y );
3212 theta = theta + dphi;
3237 nostrokeparts =
true;
3248 else if ( i == path->size() - 1 )
3255 if ( nostrokeparts )
3261 nostrokeparts =
false;
3263 double lastmovex = 0;
3264 double lastmovey = 0;
3266 for ( i = 0; i < path->size(); i++ )
3306 nostrokeparts =
true;
3314 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3315 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3322 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 );
3323 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 );
3336 double xwl = path->Item( i ? i - 1 : 0 )->m_x1;
3337 double ywl = path->Item( i ? i - 1 : 0 )->m_y1;
3344 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
3345 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
3358 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
3360 if ( cseg->
CalcR( path->Item( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
3363 unsigned int segments;
3366 double theta = beginrad;
3370 for ( step = 0; step < segments + 1; step++ )
3372 lworld.
TransformPoint( center_x + radius * cos ( theta ), center_y + radius * sin ( theta ), x, y );
3375 theta = theta + dphi;
3389 if ( move || nostrokeparts )
3393 nostrokeparts =
false;
3401 cpoints->push_back(
new a2dLineSegment( lastmovex, lastmovey ) );
3405 nostrokeparts =
false;
3410 else if ( i == path->size() )
3423 void a2dIOHandlerGDSOut::WritePath(
const a2dAffineMatrix& lworld,
a2dVertexArray* points,
int layer,
int datatype,
int pathtype,
double width )
3425 WriteHeader( 0, 0, GDS_PATH );
3427 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3431 WriteInt( m_objectFlags );
3433 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3434 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3439 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3440 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3443 WriteInt( datatype );
3447 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3448 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3451 WriteInt( pathtype );
3456 WriteHeader(
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
3457 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
3459 WriteLong(
Round( width / m_userunits_out / m_scale_out ) );
3467 help = 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) * n;
3469 if ( help > 65530L )
3471 wxLogWarning( wxT(
"%s" ), _(
"to many points in Polyline" ) );
3473 n = help / ( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) );
3475 WriteHeader( help, GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER, GDS_XY );
3478 for ( i = 0; i < n; i++ )
3485 WriteHeader( 0, 0, GDS_ENDEL );
3489 void a2dIOHandlerGDSOut::WritePath(
const a2dAffineMatrix& lworld,
a2dVertexList* points,
int layer,
int datatype,
int pathtype,
double width )
3491 WriteHeader( 0, 0, GDS_PATH );
3493 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3497 WriteInt( m_objectFlags );
3499 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3500 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3505 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3506 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3509 WriteInt( datatype );
3513 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3514 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3517 WriteInt( pathtype );
3522 WriteHeader(
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ),
3523 GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER,
3525 WriteLong(
Round( width / m_userunits_out / m_scale_out ) );
3529 unsigned int n = points->size();
3531 long help = 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) * n;
3532 if ( help > 65530L )
3534 wxLogWarning( wxT(
"%s" ), _(
"to many points in Polyline" ) );
3536 n = help / ( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) );
3538 WriteHeader( help, GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER, GDS_XY );
3540 a2dVertexList::iterator iter = points->begin();
3552 WriteHeader( 0, 0, GDS_ENDEL );
3558 WriteHeader( 0, 0, GDS_BOUNDARY );
3560 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3564 WriteInt( m_objectFlags );
3566 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3567 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3572 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3573 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3576 WriteInt( datatype );
3580 unsigned int n = points->size();
3582 help = 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) * ( n + 1 );
3584 if ( help > 65530L )
3586 wxLogWarning( wxT(
"%s" ), _(
"to many points in Polyline" ) );
3590 n = help / ( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) ) - 1;
3592 WriteHeader( help, GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER, GDS_XY );
3596 for ( i = 0; i < n; i++ )
3604 WriteHeader( 0, 0, GDS_ENDEL );
3612 if ( spline || points->
HasArcs() )
3622 WriteHeader( 0, 0, GDS_BOUNDARY );
3624 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3628 WriteInt( m_objectFlags );
3630 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3631 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3636 WriteHeader(
sizeof( TWO_G_BYTE_SIGNED_INTEGER ),
3637 GDSTYPE_TWO_G_BYTE_SIGNED_INTEGER,
3640 WriteInt( datatype );
3643 unsigned int n = points->size();
3645 long help = 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) * ( n + 1 );
3646 if ( help > 65530L )
3648 wxLogWarning( wxT(
"%s" ), _(
"to many points in Polyline" ) );
3650 n = help / ( 2 *
sizeof( FOUR_G_BYTE_SIGNED_INTEGER ) ) - 1;
3652 WriteHeader( help, GDSTYPE_FOUR_G_BYTE_SIGNED_INTEGER, GDS_XY );
3654 a2dVertexList::iterator iter = points->begin();
3665 lworld.
TransformPoint( points->front()->m_x, points->front()->m_y, x, y );
3668 WriteHeader( 0, 0, GDS_ENDEL );
3670 if ( spline || points->
HasArcs() )
3677 void a2dIOHandlerGDSOut::WriteByte( G_BYTE ch )
3679 #if wxUSE_STD_IOSTREAM
3687 void a2dIOHandlerGDSOut::WriteUnsignedInt( TWO_G_BYTE_UNSIGNED_INTEGER i )
3690 a_value.two_byte_signed_integer = i;
3691 #if wxBYTE_ORDER == wxBIG_ENDIAN
3692 WriteByte( a_value.array.array[0] );
3693 WriteByte( a_value.array.array[1] );
3695 WriteByte( a_value.array.array[1] );
3696 WriteByte( a_value.array.array[0] );
3701 void a2dIOHandlerGDSOut::WriteInt( TWO_G_BYTE_SIGNED_INTEGER i )
3704 a_value.two_byte_signed_integer = i;
3705 #if wxBYTE_ORDER == wxBIG_ENDIAN
3706 WriteByte( a_value.array.array[0] );
3707 WriteByte( a_value.array.array[1] );
3709 WriteByte( a_value.array.array[1] );
3710 WriteByte( a_value.array.array[0] );
3716 void a2dIOHandlerGDSOut::WriteLong( FOUR_G_BYTE_SIGNED_INTEGER i )
3719 a_value.four_byte_signed_integer = i;
3725 #if wxBYTE_ORDER == wxBIG_ENDIAN
3727 for( t = 0; t <= 3; t++ )
3730 for( t = 3; t >= 0; t-- )
3732 WriteByte( a_value.array.array[t] );
3737 void a2dIOHandlerGDSOut::WriteFloat( FOUR_G_BYTE_REAL r )
3740 a_value.four_byte_real = r;
3745 #if wxBYTE_ORDER == wxBIG_ENDIAN
3746 for(
short int i = 0; i <= 3; i++ )
3748 for(
short int i = 3; i >= 0; i-- )
3750 WriteByte( a_value.array.array[i] );
3755 void a2dIOHandlerGDSOut::WriteDouble( EIGHT_G_BYTE_REAL r )
3758 a_value.eight_byte_real = r;
3767 for( i = 0; i < 8; i++ )
3768 WriteByte( a_value.array.array[i] );
3773 #endif //wxART2D_USE_GDSIO
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
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.
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
virtual void InitializeLoad()
Inits the handler for reading.
void SetVersion(wxString version)
set version of library or document
diagram is an appearance for a2dCameleon
virtual bool IsTemporary_DontSave() const
Check if this is a temporary object, which should not be saved.
void gds2double(unsigned char fb[])
convert a gdsii real to a machine real
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
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
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.
View on a a2dCanvasDocument.
union Strans::@12 m_stransflags
Strans bit flags for reading and writing to binary file.
unsigned int GetChildObjectsCount() const
get number of child objects
TWO_G_BYTE_UNSIGNED_INTEGER m_recordsize
size of the last read record
static double GetFontScaleFactor()
a factor to modify the internal text height, compared to the GDSII file height.
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:
wxString m_strucname
structure that is being read at the moment
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
void SkipData()
skip the date of the last read record
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
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.
a2dCanvasDocument * m_doc
the document to store/load the data found into
bool IsIdentity(void) const
Is the matrix the identity matrix?
double m_x3
control point 2
double GetValue(int col, int row) const
get the value in the matrix at col,row
a2dGlobal * a2dGlobals
global a2dCanvasGlobal to have easy access to global settings
a2dDrawing * GetDrawing() const
get the root object, which holds the objects in the document.
a2dRectC is a centered rectangle
int GetDataType()
GDSII compatible to sub identify this object.
The base class for all drawable objects in a a2dCanvasDocument.
void SetLibraryName(const wxString &libraryname)
to name the document as a library (independent of a path and filename )
a2dVertexList * ConvertSplinedPolyline(double Aber) const
Spline conversion for polyline.
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...
vertex array of line and arc segments.
bool m_textAsPath
if true, convert text to a2dVpath
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.
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
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
void SetWidth(double w)
set width of rectangle
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
std::vector< int > m_mapping
mapping of GDSII layers to internal layers
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.
special a2dCanvasObject which are used to create hierarchy different from the standard a2dCanvasObjec...
virtual void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
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.
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
bool m_back
last read record is stored
void SetContourWidth(double width)
set the Contour width of the shape
a2dVertexList * ConvertSplinedPolygon(double Aber) const
Spline conversion for polygon.
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.
void double2gds(unsigned char fb[])
convert a machine real to a gdsii real
a2dIOHandlerStrIn & SeekI(wxFileOffset pos)
set stream at a position
void SetHeight(double h)
set height of rectangle
bool GetCheck() const
general flag use at will.
void WriteString(const wxString &a_string)
write a string
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.
wxString GetVersion()
get version of library or document
double GetMinX() const
get minimum X of the boundingbox
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)
Should return true if the handler can read from the stream.
a2dCameleon * GetCameleon()
this appearance is for the returned a2dCameleon here.
bool ReadHeader(int type)
#define forEachIn(listtype, list)
easy iteration for a2dlist
bool CanSave(const wxObject *obj=NULL)
Should return true if the handler can write this document to a stream.
virtual void InitializeSave()
Inits the handler for writing.
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.
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 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.
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! )
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Normal straight line segment in a2dVertexList and a2dVertexArray.
G_BYTE m_datatype
the type of the data in the last read record
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.
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
return text as a vector path, where text outline is converted to polyline or polygons.
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 SetMin(double px, double py)
set the bounding box its maximum
bool GetBin() const
general flag use at will.
for reading bytes from a binary GDS-II file, and convert them to internal types.
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.
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.
a2dCanvasDocument * m_doc
the document to store/load the data found into
a2dView * GetCurrentView() const
return the one that is active right now (e.g. has focus in case of a wxWindow), or NULL ...
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 GetPosY() const
get y position from affine matrix
bool LoadLayers(const wxString &filename)
load layers from another file
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
std::vector< int > m_mapping
mapping of GDSII layers to internal layers
wxInputStream a2dDocumentInputStream
input stream based wxStreams
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
a2dLineSegment * AddPoint(double x, double y, a2dLineSegmentPtr seg=NULL, bool afterinversion=true)
add point/segment after a segment.
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! )
a_union_value()
constructor reset it to 0's
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
double GetUnitsAccuracy()
this is the number that defines the number of decimal places in the fraction
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
double GetMaxY() const
get maximum Y of the boundingbox
wxString GetMultiplierString() const
get the number 1.1 um -> "um"
void SetUnits(const wxString &unitString)
this string defines the unit e.g. meters / inch/ etc.
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.
G_BYTE m_recordtype
recordtype of last read record
const a2dError a2dError_NotSpecified
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
virtual void ResetLoad()
Reset the handler after loading.
void SetLayerSetup(a2dLayers *layersetup)
set the layersettings for the canvas.
array of bytes, which holds a string in GDS-II
virtual void ReportWarningF(const a2dError &error, const wxChar *Format,...)
concatenate to the error report the given warning.
double GetMinY() const
get minimum Y of the boundingbox
double Check_int(double getal)
ckecking of it is near enough to a integer number
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.
Strans(double nw_angle=DEFAULT_STRANS_ANGLE, double nw_scale=DEFAULT_STRANS_SCALE, bool nw_abs_angle=DEFAULT_STRANS_ABS_ANGLE, bool nw_abs_scale=DEFAULT_STRANS_ABS_SCALE, bool nw_reflection=DEFAULT_STRANS_REFLECTION)
constructor
double m_x1
x endpoint of line
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
a2dVpath * GetSegments()
modify point at index to x,y
virtual void ResetSave()
Reset the object after saving.
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
#define Round(x)
round to integer such that e.g 2.5 < x < 3.5 becomes 3
a2dCanvasObject for a Vector Path
virtual void InitializeLoad()
Inits the handler for reading.
const a2dDoMu & GetAberPolyToArc() const
Polygon/polyline to Arc Maximum abberation.
static void SetCameleonRoot(a2dCanvasObject *cameleonRoot)
set the root where all a2dCameleon's are stored
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
wxDateTime & GetAccessTime()
Returns the time of last access.
static a2dPropertyIdUint16 * PROPID_Datatype
used in GDSII and KEY format to specify the DATATYPE of elements
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
GdsII format input and output.
wxString GetText() const
get the text of the object ' ' in string means new line
void SetShowObject(a2dCanvasObject *show)
what to display when document is openened
void ConvertToLines(double aberation=0)
Convert complex segments to line segments.
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
a2dDocumentOutputStream * m_streamo
file or other string stream containing the format to output to.
void ReadString(wxString &a_string)
read string data for Text element, structure names etc.
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
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 )
const double wxPI
defines PI
a2dEllipticArc centered at x,y
const a2dError a2dError_GDSIIparse
general canvas module declarations and classes