30#include <boost/ptr_container/ptr_vector.hpp>
33#include <boost/ptr_container/ptr_set.hpp>
35#include <specctra_import_export/specctra_lexer.h>
116 return x==other.
x &&
y==other.
y;
121 return !( *
this == other );
162 out->
Print( nestLevel,
" %.6g %.6g",
x,
y );
186 out->
Print( nestLevel,
"(%s%s%s %s%s%s)\n",
187 quoteName,
name.c_str(), quoteName,
188 quoteValue,
value.c_str(), quoteValue );
212 const char*
Name()
const;
293 ELEM( aType, aParent )
324 kids.push_back( aElem );
329 ELEM_ARRAY::auto_type ret =
kids.replace( aIndex, aElem );
330 return ret.release();
335 ELEM_ARRAY::auto_type ret =
kids.release(
kids.begin() + aIndex );
336 return ret.release();
413 ELEM( aType, aParent )
443 ELEM( T_rect, aParent )
466 const char* newline = nestLevel ?
"\n" :
"";
470 out->
Print( nestLevel,
"(%s %s%s%s %.6g %.6g %.6g %.6g)%s",
496 ELEM( aType, aParent )
506 if(
rules.size() == 1 )
509 out->
Print( 0,
" %s)",
rules.begin()->c_str() );
514 out->
Print( 0,
"\n" );
517 for( STRINGS::const_iterator i =
rules.begin(); i !=
rules.end(); ++i )
518 out->
Print( nestLevel+1,
"%s\n", i->c_str() );
520 out->
Print( nestLevel,
")" );
523 if( nestLevel || !singleLine )
524 out->
Print( 0,
"\n" );
539 ELEM( T_layer_rule, aParent )
556 out->
Print( 0,
" %s%s%s", quote, i->c_str(), quote );
559 out->
Print( 0 ,
"\n" );
564 out->
Print( nestLevel,
")\n" );
587 ELEM( aType, aParent )
595 points.push_back( aPoint );
612 const char* newline = nestLevel ?
"\n" :
"";
616 const int RIGHTMARGIN = 70;
617 int perLine = out->
Print( nestLevel,
"(%s %s%s%s %.6g",
622 int wrapNest = std::max( nestLevel+1, 6 );
624 for(
unsigned i = 0; i <
points.size(); ++i )
626 if( perLine > RIGHTMARGIN )
628 out->
Print( 0,
"\n" );
629 perLine = out->
Print( wrapNest,
"%s",
"" );
633 perLine += out->
Print( 0,
" " );
641 out->
Print( 0,
"(aperture_type square)" );
644 out->
Print( 0,
")%s", newline );
657typedef boost::ptr_vector<PATH>
PATHS;
665 ELEM( aType, aParent )
696 for( PATHS::iterator i=
paths.begin(); i!=
paths.end(); ++i )
698 POINTS& plist = i->GetPoints();
700 for(
unsigned jj = 0; jj < plist.size(); jj++ )
702 aBuffer.push_back( plist[jj].x );
703 aBuffer.push_back( plist[jj].y );
712 out->
Print( nestLevel,
"(%s\n",
Name() );
718 for( PATHS::iterator i =
paths.begin(); i !=
paths.end(); ++i )
719 i->Format( out, nestLevel+1 );
722 out->
Print( nestLevel,
")\n" );
738 ELEM( T_circle, aParent )
745 const char* newline = nestLevel ?
"\n" :
"";
748 out->
Print( nestLevel,
"(%s %s%s%s %.6g",
Name(), quote,
layer_id.c_str(), quote,
754 out->
Print( 0,
")%s", newline );
786 ELEM( T_qarc, aParent )
793 const char* newline = nestLevel ?
"\n" :
"";
796 out->
Print( nestLevel,
"(%s %s%s%s %.6g",
Name(), quote,
layer_id.c_str(), quote,
799 for(
int i=0; i<3; ++i )
802 out->
Print( 0,
")%s", newline );
848 ELEM( aType, aParent )
865 wxASSERT( aShape->
Type()==T_rect
866 || aShape->
Type()==T_circle
867 || aShape->
Type()==T_qarc
868 || aShape->
Type()==T_path
869 || aShape->
Type()==T_polygon);
882 out->
Print( 0,
")\n" );
914 ELEM( aType, aParent )
937 wxASSERT( aShape->
Type()==T_rect
938 || aShape->
Type()==T_circle
939 || aShape->
Type()==T_qarc
940 || aShape->
Type()==T_path
941 || aShape->
Type()==T_polygon);
955 const char* newline =
"\n";
962 out->
Print( 0,
" %s%s%s", quote,
name.c_str(), quote );
968 out->
Print( 0,
" \"\"" );
977 out->
Print( 0,
" " );
983 out->
Print( 0,
"%s", newline );
990 out->
Print( 0,
"%s", newline );
997 out->
Print( 0,
"%s", newline );
1000 for( WINDOWS::iterator i =
windows.begin(); i !=
windows.end(); ++i )
1001 i->Format( out, nestLevel+1 );
1003 out->
Print( nestLevel,
")\n" );
1007 out->
Print( 0,
")\n" );
1043 ELEM( T_via, aParent )
1054 const int RIGHTMARGIN = 80;
1055 int perLine = out->
Print( nestLevel,
"(%s",
Name() );
1059 if( perLine > RIGHTMARGIN )
1061 out->
Print( 0,
"\n" );
1062 perLine = out->
Print( nestLevel+1,
"%s",
"");
1066 perLine += out->
Print( 0,
" %s%s%s", quote, i->c_str(), quote );
1071 out->
Print( 0,
"\n" );
1073 perLine = out->
Print( nestLevel+1,
"(spare" );
1075 for( STRINGS::iterator i =
spares.begin(); i !=
spares.end(); ++i )
1077 if( perLine > RIGHTMARGIN )
1079 out->
Print( 0,
"\n" );
1080 perLine = out->
Print( nestLevel+2,
"%s",
"");
1084 perLine += out->
Print( 0,
" %s%s%s", quote, i->c_str(), quote );
1087 out->
Print( 0,
")" );
1090 out->
Print( 0,
")\n" );
1105 ELEM( T_classes, aParent )
1114 out->
Print( nestLevel,
"%s%s%s\n", quote, i->c_str(), quote );
1178 out->
Print( nestLevel,
"(%s\n",
Name() );
1180 out->
Print( nestLevel+1,
"(via_at_smd %s",
via_at_smd ?
"on" :
"off" );
1185 out->
Print( 0,
")\n" );
1187 for(
int i = 0; i <
Length(); ++i )
1190 out->
Print( nestLevel,
")\n" );
1205 ELEM( T_layer, aParent )
1224 out->
Print( nestLevel,
"(%s %s%s%s\n",
Name(), quote,
name.c_str(), quote );
1230 out->
Print( nestLevel+1,
"(property\n" );
1234 i->Format( out, nestLevel+2 );
1236 out->
Print( nestLevel+1,
")\n" );
1249 out->
Print( nestLevel+1,
"(cost %d", -
cost );
1256 out->
Print( 0,
")\n" );
1261 out->
Print( nestLevel+1,
"(use_net" );
1263 for( STRINGS::const_iterator i =
use_net.begin(); i !=
use_net.end(); ++i )
1266 out->
Print( 0,
" %s%s%s", quote, i->c_str(), quote );
1269 out->
Print( 0,
")\n" );
1272 out->
Print( nestLevel,
")\n" );
1298 ELEM( T_layer_pair, aParent )
1308 out->
Print( nestLevel,
"(%s %s%s%s %s%s%s %.6g)\n",
Name(), quote0,
layer_id0.c_str(),
1333 ELEM( T_layer_noise_weight, aParent )
1339 out->
Print( nestLevel,
"(%s\n",
Name() );
1342 i->Format( out, nestLevel+1 );
1344 out->
Print( nestLevel,
")\n" );
1375 ELEM( aType, aParent )
1402 ELEM( aType, aParent )
1410 out->
Print( nestLevel,
"(%s %s%s%s)\n",
1412 quote,
value.c_str(), quote );
1445 out->
Print( nestLevel,
"%s%s%s\n", quote,
region_id.c_str(), quote );
1482 ELEM( T_grid, aParent )
1509 out->
Print( 0,
")\n");
1527 ELEM( T_structure_out, aParent )
1539 for( LAYERS::iterator i =
layers.begin(); i !=
layers.end(); ++i )
1540 i->Format( out, nestLevel );
1605 for( LAYERS::iterator i=
layers.begin(); i!=
layers.end(); ++i )
1606 i->Format( out, nestLevel );
1617 for( COPPER_PLANES::iterator i=
planes.begin(); i!=
planes.end(); ++i )
1618 i->Format( out, nestLevel );
1620 for( REGIONS::iterator i=
regions.begin(); i!=
regions.end(); ++i )
1621 i->Format( out, nestLevel );
1624 i->Format( out, nestLevel );
1632 for(
int i=0; i<
Length(); ++i )
1643 for( GRIDS::iterator i=
grids.begin(); i!=
grids.end(); ++i )
1644 i->Format( out, nestLevel );
1691 ELEM( T_place, aParent )
1771 ELEM( T_component, aParent )
1790 out->
Print( nestLevel,
"(%s %s%s%s\n",
Name(), quote,
image_id.c_str(), quote );
1794 out->
Print( nestLevel,
")\n" );
1799 for( PLACES::iterator i=
places.begin(); i!=
places.end(); ++i )
1800 i->Format( out, nestLevel );
1819 ELEM( T_placement, aParent )
1840 for(
unsigned i = 0; i <
components.size(); ++i )
1842 if( 0 ==
components[i].GetImageId().compare( imageName ) )
1859 out->
Print( nestLevel,
"(place_control (flip_style %s))\n",
1864 i->Format( out, nestLevel );
1912 out->
Print( nestLevel,
"(%s ",
Name() );
1922 out->
Print( 0,
"\n" );
1924 for( WINDOWS::iterator i=
windows.begin(); i!=
windows.end(); ++i )
1925 i->Format( out, nestLevel+1 );
1927 out->
Print( nestLevel,
")\n" );
1931 out->
Print( 0,
")\n" );
1957 ELEM( T_pin, aParent )
1980 out->
Print( nestLevel,
"(pin %s%s%s (rotate %.6g)", quote,
padstack_id.c_str(), quote,
2001typedef boost::ptr_vector<PIN>
PINS;
2051 const char* quote = out->
GetQuoteChar( imageId.c_str() );
2053 out->
Print( nestLevel,
"(%s %s%s%s",
Name(), quote, imageId.c_str(), quote );
2057 out->
Print( nestLevel,
")\n" );
2063 if(
side != T_both )
2066 out->
Print( 0,
"\n");
2074 for( PINS::iterator i=
pins.begin(); i!=
pins.end(); ++i )
2075 i->Format( out, nestLevel );
2084 i->Format( out, nestLevel );
2173 out->
Print( nestLevel,
")\n" );
2185 out->
Print( nestLevel,
"%s",
"" );
2191 out->
Print( 0,
"(attach off)" );
2193 else if(
attach == T_on )
2197 out->
Print( 0,
"(attach on (use_via %s%s%s))", quote,
via_id.c_str(), quote );
2206 out->
Print( 0,
"\n" );
2261 ELEM( aType, aParent )
2298 for( i=0; i<
images.size(); ++i )
2308 for( i=0; i<
images.size(); ++i )
2324 images.push_back( aImage );
2353 for(
unsigned i = 0; i <
vias.size(); ++i )
2368 vias.push_back( aVia );
2407 for(
unsigned i = 0; i <
padstacks.size(); ++i )
2423 for( IMAGES::iterator i =
images.begin(); i !=
images.end(); ++i )
2424 i->Format( out, nestLevel );
2427 i->Format( out, nestLevel );
2429 for( PADSTACKS::iterator i =
vias.begin(); i !=
vias.end(); ++i )
2430 i->Format( out, nestLevel );
2458 ELEM( T_pin, aParent )
2472 const char* newline = nestLevel ?
"\n" :
"";
2477 return out->
Print( nestLevel,
"%s%s%s-%s%s%s%s", cquote,
component_id.c_str(), cquote,
2478 pquote,
pin_id.c_str(), pquote, newline );
2492 ELEM( T_fromto, aParent )
2505 out->
Print( nestLevel,
"(%s %s %s ",
2514 out->
Print( 0,
"(net %s%s%s)", quote,
net_id.c_str(), quote );
2517 bool singleLine =
true;
2521 out->
Print( 0,
"\n" );
2534 i->Format( out, nestLevel+1 );
2536 out->
Print( singleLine ? 0 : nestLevel,
")" );
2538 if( nestLevel || !singleLine )
2539 out->
Print( 0,
"\n" );
2565 ELEM( T_comp_order, aParent )
2576 out->
Print( 0,
" %s%s%s", quote, i->c_str(), quote );
2579 out->
Print( 0,
")" );
2582 out->
Print( 0,
"\n" );
2600 ELEM( T_net, aParent )
2621 for(
unsigned i = 0; i <
pins.size(); ++i )
2623 if( aComponent.compare(
pins[i].component_id ) == 0 )
2633 const char* space =
" ";
2635 out->
Print( nestLevel,
"(%s %s%s%s",
Name(), quote,
net_id.c_str(), quote );
2639 out->
Print( 0,
"%s(unassigned)", space );
2649 out->
Print( 0,
"\n" );
2653 const int RIGHTMARGIN = 80;
2656 for( PIN_REFS::iterator i =
pins.begin(); i !=
pins.end(); ++i )
2658 if( perLine > RIGHTMARGIN )
2660 out->
Print( 0,
"\n");
2661 perLine = out->
Print( nestLevel+2,
"%s",
"" );
2665 perLine += out->
Print( 0,
" " );
2668 perLine += i->FormatIt( out, 0 );
2671 out->
Print( 0,
")\n" );
2677 if(
type != T_NONE )
2684 i->Format( out, nestLevel+1 );
2686 for( FROMTOS::iterator i =
fromtos.begin(); i !=
fromtos.end(); ++i )
2687 i->Format( out, nestLevel+1 );
2689 out->
Print( nestLevel,
")\n" );
2721typedef boost::ptr_vector<NET>
NETS;
2728 ELEM( T_topology, aParent )
2734 for( FROMTOS::iterator i =
fromtos.begin(); i !=
fromtos.end(); ++i )
2735 i->Format( out, nestLevel );
2738 i->Format( out, nestLevel );
2757 ELEM( T_class, aParent )
2773 int perLine = out->
Print( nestLevel,
"(%s %s%s%s",
Name(), quote,
class_id.c_str(), quote );
2775 const int RIGHTMARGIN = 72;
2777 for( STRINGS::iterator i=
net_ids.begin(); i!=
net_ids.end(); ++i )
2779 const char* space =
" ";
2781 if( perLine > RIGHTMARGIN )
2783 out->
Print( 0,
"\n" );
2784 perLine = out->
Print( nestLevel+1,
"%s",
"" );
2789 perLine += out->
Print( 0,
"%s%s%s%s", space, quote, i->c_str(), quote );
2792 bool newLine =
false;
2796 out->
Print( 0,
"\n" );
2802 out->
Print( nestLevel+1,
"(circuit\n" );
2804 for( STRINGS::iterator i =
circuit.begin(); i !=
circuit.end(); ++i )
2805 out->
Print( nestLevel + 2,
"%s\n", i->c_str() );
2807 out->
Print( nestLevel+1,
")\n" );
2814 i->Format( out, nestLevel + 1 );
2819 out->
Print( newLine ? nestLevel : 0,
")\n" );
2846 ELEM( T_network, aParent )
2852 for( NETS::iterator i =
nets.begin(); i !=
nets.end(); ++i )
2853 i->Format( out, nestLevel );
2855 for( CLASSLIST::iterator i =
classes.begin(); i !=
classes.end(); ++i )
2856 i->Format( out, nestLevel );
2873 ELEM( T_connect, aParent ) {}
2884 ELEM( T_wire, aParent )
2908 wxASSERT(aShape->
Type()==T_rect || aShape->
Type()==T_circle
2909 || aShape->
Type()==T_qarc || aShape->
Type()==T_path
2910 || aShape->
Type()==T_polygon);
2918 out->
Print( nestLevel,
"(%s ",
Name() );
2926 out->
Print( 0,
"(net %s%s%s)", quote,
net_id.c_str(), quote );
2935 if(
attr != T_NONE )
2941 out->
Print( 0,
"(shield %s%s%s)", quote,
shield.c_str(), quote );
2946 out->
Print( 0,
"\n" );
2948 for( WINDOWS::iterator i =
windows.begin(); i !=
windows.end(); ++i )
2949 i->Format( out, nestLevel + 1 );
2956 out->
Print( 0,
"(supply)" );
2958 out->
Print( 0,
")\n" );
2993 ELEM( T_via, aParent )
3010 const int RIGHTMARGIN = 80;
3016 if( perLine > RIGHTMARGIN )
3018 out->
Print( 0,
"\n" );
3019 perLine = out->
Print( nestLevel+1,
"%s",
"" );
3023 perLine += out->
Print( 0,
" " );
3026 perLine += out->
Print( 0,
"%.6g %.6g", i->x, i->y );
3030 out->
Print( 0,
" " );
3034 if( perLine > RIGHTMARGIN )
3036 out->
Print( 0,
"\n" );
3037 perLine = out->
Print( nestLevel+1,
"%s",
"" );
3041 perLine += out->
Print( 0,
"(net %s%s%s)", quote,
net_id.c_str(), quote );
3046 if( perLine > RIGHTMARGIN )
3048 out->
Print( 0,
"\n" );
3049 perLine = out->
Print( nestLevel+1,
"%s",
"" );
3057 if( perLine > RIGHTMARGIN )
3059 out->
Print( 0,
"\n" );
3060 perLine = out->
Print( nestLevel+1,
"%s",
"" );
3066 if(
attr != T_NONE )
3068 if( perLine > RIGHTMARGIN )
3070 out->
Print( 0,
"\n" );
3071 perLine = out->
Print( nestLevel+1,
"%s",
"" );
3074 if(
attr == T_virtual_pin )
3077 perLine += out->
Print( 0,
"(attr virtual_pin %s%s%s)", quote,
3088 if( perLine > RIGHTMARGIN )
3090 out->
Print( 0,
"\n" );
3091 perLine = out->
Print( nestLevel+1,
"%s",
"" );
3094 perLine += out->
Print( 0,
"(supply)" );
3099 out->
Print( 0,
"\n" );
3100 out->
Print( nestLevel+1,
"(contact\n" );
3105 out->
Print( nestLevel+2,
"%s%s%s\n", quote, i->c_str(), quote );
3108 out->
Print( nestLevel+1,
"))\n" );
3112 out->
Print( 0,
")\n" );
3140 ELEM( T_wiring, aParent )
3155 for( WIRES::iterator i =
wires.begin(); i !=
wires.end(); ++i )
3156 i->Format( out, nestLevel );
3159 i->Format( out, nestLevel );
3183 ELEM( T_pcb, aParent )
3211 out->
Print( nestLevel,
"(%s %s%s%s\n",
Name(), quote,
pcbname.c_str(), quote );
3237 out->
Print( nestLevel,
")\n" );
3270 ELEM( T_ancestor, aParent )
3281 strftime( temp,
sizeof(temp),
"%b %d %H : %M : %S %Y", tmp );
3285 out->
Print( nestLevel,
"(%s \"%s\" (created_time %s)\n",
Name(),
filename.c_str(), temp );
3290 out->
Print( nestLevel+1,
"(comment %s%s%s)\n", quote,
comment.c_str(), quote );
3293 out->
Print( nestLevel,
")\n" );
3311 ELEM( T_history, aParent )
3319 i->Format( out, nestLevel );
3325 strftime( temp,
sizeof( temp ),
"%b %d %H : %M : %S %Y", tmp );
3328 out->
Print( nestLevel,
"(self (created_time %s)\n", temp );
3333 out->
Print( nestLevel+1,
"(comment %s%s%s)\n", quote, i->c_str(), quote );
3336 out->
Print( nestLevel,
")\n" );
3355 ELEM( T_supply_pin, aParent )
3361 bool singleLine =
pin_refs.size() <= 1;
3366 out->
Print( 0,
"%s",
" " );
3367 pin_refs.begin()->Format( out, 0 );
3372 i->FormatIt( out, nestLevel + 1 );
3377 const char* newline = singleLine ?
"" :
"\n";
3380 out->
Print( singleLine ? 0 : nestLevel+1,
" (net %s%s%s)%s",
3381 quote,
net_id.c_str(), quote, newline );
3384 out->
Print( singleLine ? 0 : nestLevel,
")\n");
3404 ELEM( T_net_out, aParent )
3420 out->
Print( nestLevel,
"(net %s%s%s\n", quote,
net_id.c_str(), quote );
3428 for( WIRES::iterator i =
wires.begin(); i !=
wires.end(); ++i )
3429 i->Format( out, nestLevel + 1 );
3432 i->Format( out, nestLevel + 1 );
3435 i->Format( out, nestLevel + 1 );
3437 out->
Print( nestLevel,
")\n" );
3458 ELEM( T_route, aParent )
3499 out->
Print( nestLevel,
"(network_out\n" );
3502 i->Format( out, nestLevel + 1 );
3504 out->
Print( nestLevel,
")\n" );
3549 ELEM( T_was_is, aParent )
3557 out->
Print( nestLevel,
"(pins " );
3558 i->was.Format( out, 0 );
3559 out->
Print( 0,
" " );
3560 i->is.Format( out, 0 );
3561 out->
Print( 0,
")\n" );
3579 ELEM( T_session, aParent )
3619 out->
Print( nestLevel,
")\n" );
3656 wxASSERT( !iOwnReaders );
3663 SetSpecctraMode(
true );
3716 void LoadPCB(
const wxString& aFilename );
3738 void ExportPCB(
const wxString& aFilename,
bool aNameChange=
false );
3821 void readCOMPnPIN( std::string* component_id, std::string* pid_id );
3834 void readTIME( time_t* time_stamp );
3932 int aTopLayer,
int aBotLayer );
3947 for(
unsigned n = 0; n <
m_nets.size(); ++n )
3972 int aViaDrillDefault );
Information pertinent to a Pcbnew printed circuit board.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
BOUNDARY(ELEM *aParent, DSN_T aType=T_boundary)
void GetCorners(std::vector< double > &aBuffer)
GetCorners fills aBuffer with a list of coordinates (x,y) of corners.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetLayerId(const char *aLayerId)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetVertex(const POINT &aVertex)
void SetDiameter(double aDiameter)
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
CLASS_CLASS(ELEM *aParent, DSN_T aType)
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
The <class_descriptor> in the specctra spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
STRINGS circuit
circuit descriptor list
Implement a <component_descriptor> in the specctra dsn spec.
const std::string & GetImageId() const
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetImageId(const std::string &aImageId)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Compare two objects of this type and returns <0, 0, or >0.
The <component_order_descriptor>.
COMP_ORDER(ELEM *aParent)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A <plane_descriptor> in the specctra dsn spec.
COPPER_PLANE(ELEM *aParent)
A holder for any DSN class.
int FindElem(DSN_T aType, int instanceNum=0)
Find a particular instance number of a given type of ELEM.
ELEM * operator[](int aIndex) const
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
ELEM * Replace(int aIndex, ELEM *aElem)
void Insert(int aIndex, ELEM *aElem)
ELEM_ARRAY kids
ELEM pointers.
ELEM * Remove(int aIndex)
ELEM * At(int aIndex) const
boost::ptr_vector< ELEM > ELEM_ARRAY
int Length() const
Return the number of ELEMs in this holder.
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
A base class for any DSN element class.
std::string makeHash()
Return a string which uniquely represents this ELEM among other ELEMs of the same derived class as "t...
const char * Name() const
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetParent(ELEM *aParent)
virtual UNIT_RES * GetUnits() const
Return the units for this section.
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
ELEM(DSN_T aType, ELEM *aParent=0)
static STRING_FORMATTER sf
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
DSN_T direction
T_x | T_y | -1 for both.
DSN_T grid_type
T_via | T_wire | T_via_keepout | T_place | T_snap.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
std::string hash
a hash string used by Compare(), not Format()ed/exported.
static int Compare(IMAGE *lhs, IMAGE *rhs)
Compare two objects of this type and returns <0, 0, or >0.
UNIT_RES * GetUnits() const override
Return the units for this section.
int duplicated
no. times this image_id is duplicated
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Used for <keepout_descriptor> and <plane_descriptor>.
void AddWindow(WINDOW *aWindow)
KEEPOUT(ELEM *aParent, DSN_T aType)
Require a DSN_T because this class is used for T_place_keepout, T_via_keepout, T_wire_keepout,...
void SetShape(ELEM *aShape)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
LAYER_NOISE_WEIGHT(ELEM *aParent)
SPECCTRA_LAYER_PAIRS layer_pairs
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
LAYER_RULE(ELEM *aParent)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
DSN_T layer_type
one of: T_signal, T_power, T_mixed, T_jumper
int cost_type
T_length | T_way.
int direction
[forbidden | high | medium | low | free | <positive_integer> | -1]
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A <library_descriptor> in the specctra dsn specification.
PADSTACK * LookupVia(PADSTACK *aVia)
Add the via only if one exactly like it does not already exist in the padstack container.
PADSTACK * FindPADSTACK(const std::string &aPadstackId)
Search the padstack container by name.
PADSTACKS padstacks
all except vias, which are in 'vias'
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void AppendVia(PADSTACK *aVia)
Add aVia to the internal via container.
int FindIMAGE(IMAGE *aImage)
Search this LIBRARY for an image which matches the argument.
UNIT_RES * GetUnits() const override
Return the units for this section.
IMAGE * LookupIMAGE(IMAGE *aImage)
Add the image only if one exactly like it does not already exist in the image container.
void AppendPADSTACK(PADSTACK *aPadstack)
Add the padstack to the padstack container.
LIBRARY(ELEM *aParent, DSN_T aType=T_library)
void AddPadstack(PADSTACK *aPadstack)
void AppendIMAGE(IMAGE *aImage)
Add the image to the image list.
int FindVia(PADSTACK *aVia)
Search this LIBRARY for a via which matches the argument.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A <net_out_descriptor> of the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A <net_descriptor> in the DSN spec.
DSN_T pins_type
T_pins | T_order, type of field 'pins' below.
DSN_T type
T_fix | T_normal.
int FindPIN_REF(const std::string &aComponent)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
DSN_T supply
T_power | T_ground.
Hold either a via or a pad definition.
const std::string & GetPadstackId()
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Compare two objects of this type and returns <0, 0, or >0.
std::string hash
a hash string used by Compare(), not Format()ed/exported.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
PADSTACK()
Cannot take ELEM* aParent because PADSTACKSET confuses this with a copy constructor and causes havoc.
void SetPadstackId(const char *aPadstackId)
UNIT_RES * GetUnits() const override
Return the units for this section.
A configuration record per the SPECCTRA DSN file spec.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
bool routes_include_image_conductor
bool routes_include_guides
bool wires_include_testpoint
STRINGS constants
This holds pairs of strings, one pair for each constant definition.
bool routes_include_testpoint
bool generated_by_freeroute
bool space_in_quoted_tokens
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
void SetLayerId(const char *aLayerId)
PATH(ELEM *aParent, DSN_T aType=T_path)
void SetAperture(double aWidth)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void AppendPoint(const POINT &aPoint)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
UNIT_RES * GetUnits() const override
Return the units for this section.
void SetVertex(const POINT &aPoint)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetRotation(double aRotation)
int kiNetCode
KiCad netcode.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
UNIT_RES * GetUnits() const override
Return the units for this section.
COMPONENT * LookupCOMPONENT(const std::string &imageName)
Look up a COMPONENT by name.
Implement a <placement_reference> in the specctra dsn spec.
void SetVertex(const POINT &aVertex)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
std::string component_id
reference designator
void SetRotation(double aRotation)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetStart(const POINT &aStart)
void SetLayerId(const char *aLayerId)
void SetCenter(const POINT &aCenter)
void SetEnd(const POINT &aEnd)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetCorners(const POINT &aPoint0, const POINT &aPoint1)
POINT point0
one of two opposite corners
void SetLayerId(const char *aLayerId)
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
STRUCTURE_OUT * structure_out
UNIT_RES * GetUnits() const override
Return the units for this section.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A <rule_descriptor> in the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
RULE(ELEM *aParent, DSN_T aType)
STRINGS rules
rules are saved in std::string form.
A <session_file_descriptor> in the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A "(shape ..)" element in the specctra dsn spec.
SHAPE(ELEM *aParent, DSN_T aType=T_shape)
Takes a DSN_T aType of T_outline.
void SetConnect(DSN_T aConnect)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A DSN data tree, usually coming from a DSN file.
PADSTACK * makeVia(const ::PCB_VIA *aVia)
Make any kind of #PADSTACK using the given KiCad #VIA.
void doUNIT(UNIT_RES *growth)
int m_top_via_layer
specctra cu layers, 0 based index:
void doCOMPONENT(COMPONENT *growth)
IMAGE * makeIMAGE(BOARD *aBoard, FOOTPRINT *aFootprint)
Allocates an I::MAGE on the heap and creates all the PINs according to the PADs in the FOOTPRINT.
void doWAS_IS(WAS_IS *growth)
void doPLACEMENT(PLACEMENT *growth)
void doNET_OUT(NET_OUT *growth)
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
PCB_TRACK * makeTRACK(WIRE *wire, PATH *aPath, int aPointIndex, int aNetcode)
Create a #TRACK form the #PATH and BOARD info.
void doCLASS(CLASS *growth)
void SetSESSION(SESSION *aSession)
Delete any existing SESSION and replaces it with the given one.
void doSTRUCTURE_OUT(STRUCTURE_OUT *growth)
void doCIRCLE(CIRCLE *growth)
void doANCESTOR(ANCESTOR *growth)
void doLAYER_NOISE_WEIGHT(LAYER_NOISE_WEIGHT *growth)
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Write the internal PCB instance out as a SPECTRA DSN format file.
void doCLASS_CLASS(CLASS_CLASS *growth)
void doSESSION(SESSION *growth)
void doWINDOW(WINDOW *growth)
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
SHAPE_POLY_SET m_brd_outlines
void doSHAPE(SHAPE *growth)
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
void FlipFOOTPRINTs(BOARD *aBoard)
Flip the footprints which are on the back side of the board to the front.
void doQARC(QARC *growth)
void doRESOLUTION(UNIT_RES *growth)
void LoadPCB(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "design" file.
void doSTRINGPROP(STRINGPROP *growth)
STRINGS m_layerIds
indexed by PCB layer number
void doBOUNDARY(BOUNDARY *growth)
void doSPECCTRA_LAYER_PAIR(SPECCTRA_LAYER_PAIR *growth)
bool m_footprintsAreFlipped
void doRECTANGLE(RECTANGLE *growth)
void deleteNETs()
Delete all the NETs that may be in here.
void doREGION(REGION *growth)
void fillBOUNDARY(BOARD *aBoard, BOUNDARY *aBoundary)
Make the board perimeter for the DSN file by filling the BOUNDARY element in the specctra element tre...
void ExportSESSION(const wxString &aFilename)
Write the internal #SESSION instance out as a #SPECTRA DSN format file.
void doWIRE(WIRE *growth)
static const KICAD_T scanPADs[]
PADSTACK * makePADSTACK(BOARD *aBoard, PAD *aPad)
Create a #PADSTACK which matches the given pad.
void SetPCB(PCB *aPcb)
Delete any existing PCB and replaces it with the given one.
void doTOKPROP(TOKPROP *growth)
void doIMAGE(IMAGE *growth)
void doCONNECT(CONNECT *growth)
void doCOMP_ORDER(COMP_ORDER *growth)
static PCB * MakePCB()
Make a PCB with all the default ELEMs and parts on the heap.
void doTOPOLOGY(TOPOLOGY *growth)
void doKEEPOUT(KEEPOUT *growth)
void doRULE(RULE *growth)
void doPATH(PATH *growth)
std::vector< PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
void doSUPPLY_PIN(SUPPLY_PIN *growth)
void doLAYER(LAYER *growth)
bool BuiltBoardOutlines(BOARD *aBoard)
Build the board outlines and store it in m_brd_outlines.
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
void doLIBRARY(LIBRARY *growth)
std::vector< int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
PADSTACK * makeVia(int aCopperDiameter, int aDrillDiameter, int aTopLayer, int aBotLayer)
Make a round through hole #PADSTACK using the given KiCad diameter in deci-mils.
std::vector< NET * > m_nets
we don't want ownership here permanently, so we don't use boost::ptr_vector
void doFROMTO(FROMTO *growth)
void doPLACE(PLACE *growth)
PADSTACKSET m_padstackset
void doGRID(GRID *growth)
void doLAYER_RULE(LAYER_RULE *growth)
void FromSESSION(BOARD *aBoard)
Add the entire #SESSION info to a BOARD but does not write it out.
void exportNETCLASS(const std::shared_ptr< NETCLASS > &aNetClass, BOARD *aBoard)
Export aNetClass to the DSN file.
void doWIRE_VIA(WIRE_VIA *growth)
void doCLASSES(CLASSES *growth)
void readCOMPnPIN(std::string *component_id, std::string *pid_id)
Read a <pin_reference> and splits it into the two parts which are on either side of the hyphen.
PCB_VIA * makeVIA(WIRE_VIA *aVia, PADSTACK *aPadstack, const POINT &aPoint, int aNetCode, int aViaDrillDefault)
Instantiate a KiCad #VIA on the heap and initializes it with internal values consistent with the give...
void FromBOARD(BOARD *aBoard)
Add the entire BOARD to the PCB but does not write it out.
void doPARSER(PARSER *growth)
void doNETWORK(NETWORK *growth)
void RevertFOOTPRINTs(BOARD *aBoard)
Flip the footprints which were on the back side of the board back to the back.
void doSTRUCTURE(STRUCTURE *growth)
int findLayerName(const std::string &aLayerName) const
Return the PCB layer index for a given layer name, within the specctra sessionfile.
void doROUTE(ROUTE *growth)
void readTIME(time_t *time_stamp)
Read a <time_stamp> which consists of 8 lexer tokens: "month date hour : minute : second year".
void doPADSTACK(PADSTACK *growth)
void doWIRING(WIRING *growth)
static const KEYWORD keywords[]
specctra DSN keywords
void doHISTORY(HISTORY *growth)
void doCONTROL(CONTROL *growth)
void doPROPERTIES(PROPERTIES *growth)
SPECCTRA_LAYER_PAIR(ELEM *aParent)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A container for a single property whose value is a string.
STRINGPROP(ELEM *aParent, DSN_T aType)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
STRUCTURE_OUT(ELEM *aParent)
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
UNIT_RES * GetUnits() const override
Return the units for this section.
boost::ptr_vector< GRID > GRIDS
BOUNDARY * place_boundary
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetBOUNDARY(BOUNDARY *aBoundary)
void SetPlaceBOUNDARY(BOUNDARY *aBoundary)
boost::ptr_vector< REGION > REGIONS
LAYER_NOISE_WEIGHT * layer_noise_weight
A <supply_pin_descriptor> in the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
SUPPLY_PIN(ELEM *aParent)
A container for a single property whose value is another DSN_T token.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
TOKPROP(ELEM *aParent, DSN_T aType)
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A holder for either a T_unit or T_resolution object which are usually mutually exclusive in the dsn g...
UNIT_RES(ELEM *aParent, DSN_T aType)
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
DSN_T GetEngUnits() const
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A <via_descriptor> in the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void AppendVia(const char *aViaName)
A <was_is_descriptor> in the specctra dsn spec.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
WINDOW(ELEM *aParent, DSN_T aType=T_window)
void SetShape(ELEM *aShape)
A <wire_via_descriptor> in the specctra dsn spec.
std::string virtual_pin_name
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
const std::string & GetPadstackId()
A <wire_shape_descriptor> in the specctra dsn spec.
void SetShape(ELEM *aShape)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A <wiring_descriptor> in the specctra dsn spec.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
UNIT_RES * GetUnits() const override
Return the units for this section.
A collection of nets and the parameters used to route or test these nets.
Helper class to centralize the paths used throughout kicad.
Represent a set of closed polygons.
This source file implements export and import capabilities to the specctra dsn file format.
boost::ptr_vector< KEEPOUT > KEEPOUTS
std::vector< std::string > STRINGS
boost::ptr_vector< NET_OUT > NET_OUTS
boost::ptr_vector< PATH > PATHS
boost::ptr_vector< WINDOW > WINDOWS
boost::ptr_vector< CLASS > CLASSLIST
std::vector< PIN_REF > PIN_REFS
boost::ptr_vector< PIN > PINS
boost::ptr_vector< COMP_ORDER > COMP_ORDERS
std::vector< PIN_PAIR > PIN_PAIRS
bool operator<(const PADSTACK &lhs, const PADSTACK &rhs)
Used by the PADSTACKSET boost::ptr_set below.
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
boost::ptr_vector< WIRE > WIRES
boost::ptr_vector< SUPPLY_PIN > SUPPLY_PINS
std::vector< PROPERTY > PROPERTIES
boost::ptr_vector< PADSTACK > PADSTACKS
std::vector< POINT > POINTS
boost::ptr_vector< PLACE > PLACES
boost::ptr_vector< IMAGE > IMAGES
boost::ptr_vector< LAYER > LAYERS
boost::ptr_vector< FROMTO > FROMTOS
boost::ptr_vector< ANCESTOR > ANCESTORS
boost::ptr_vector< WIRE_VIA > WIRE_VIAS
boost::ptr_vector< COPPER_PLANE > COPPER_PLANES
boost::ptr_vector< SPECCTRA_LAYER_PAIR > SPECCTRA_LAYER_PAIRS
boost::ptr_vector< COMPONENT > COMPONENTS
boost::ptr_vector< NET > NETS
boost::ptr_vector< LAYER_RULE > LAYER_RULES
boost::ptr_set< PADSTACK > PADSTACKSET
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
Used within the WAS_IS class below to hold a pair of PIN_REFs and corresponds to the (pins was is) co...
PIN_PAIR(ELEM *aParent=0)
A <pin_reference> definition in the specctra dsn spec.
int FormatIt(OUTPUTFORMATTER *out, int nestLevel)
Like Format() but is not virtual.
A point in the SPECCTRA DSN coordinate system.
POINT & operator=(const POINT &other)
void FixNegativeZero()
Change negative zero to positive zero in the IEEE floating point storage format.
bool operator!=(const POINT &other) const
bool operator==(const POINT &other) const
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
POINT(double aX, double aY)
POINT & operator+=(const POINT &other)
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Hold a keyword string and its unique integer token.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.