Commit b91f11ad authored by dickelbeck's avatar dickelbeck

more amazing free software

parent af1c1564
......@@ -774,7 +774,7 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IOError )
{
DSN_T tok = nextTok();
if( tok==T_SYMBOL || tok==T_STRING )
if( isSymbol(tok) )
{
growth->name = lexer->CurText();
tok = nextTok();
......@@ -789,7 +789,6 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IOError )
expecting( T_LEFT );
tok = nextTok();
switch( tok )
{
case T_sequence_number:
......@@ -814,24 +813,32 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IOError )
break;
case T_rect:
growth->rectangle = new RECTANGLE( growth );
doRECTANGLE( growth->rectangle );
if( growth->shape )
unexpected( tok );
growth->shape = new RECTANGLE( growth );
doRECTANGLE( (RECTANGLE*) growth->shape );
break;
case T_circle:
growth->circle = new CIRCLE( growth );
doCIRCLE( growth->circle );
if( growth->shape )
unexpected( tok );
growth->shape = new CIRCLE( growth );
doCIRCLE( (CIRCLE*) growth->shape );
break;
case T_path:
case T_polygon:
growth->path = new PATH( growth, tok );
doPATH( growth->path );
if( growth->shape )
unexpected( tok );
growth->shape = new PATH( growth, tok );
doPATH( (PATH*) growth->shape );
break;
case T_qarc:
growth->qarc = new QARC( growth );
doQARC( growth->qarc );
if( growth->shape )
unexpected( tok );
growth->shape = new QARC( growth );
doQARC( (QARC*) growth->shape );
break;
case T_window:
......@@ -3700,6 +3707,7 @@ void PARSER::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOErro
if( !via_rotate_first )
out->Print( nestLevel, "(via_rotate_first off)\n" );
if( case_sensitive )
out->Print( nestLevel, "(case_sensitive %s)\n", case_sensitive ? "on" : "off" );
}
......@@ -3736,19 +3744,26 @@ void PLACE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
out->Print( 0, " %.6g", rotation );
}
out->Print( 0, " " );
const char* space = " "; // one space, as c string.
if( mirror != T_NONE )
out->Print( 0, "(mirror %s)", LEXER::GetTokenText( mirror ) );
{
out->Print( 0, "%s(mirror %s)", space, LEXER::GetTokenText( mirror ) );
space = "";
}
if( status != T_NONE )
out->Print( 0, "(status %s)", LEXER::GetTokenText( status ) );
{
out->Print( 0, "%s(status %s)", space, LEXER::GetTokenText( status ) );
space = "";
}
if( logical_part.size() )
{
quote = out->GetQuoteChar( logical_part.c_str() );
out->Print( 0, "(logical_part %s%s%s)",
out->Print( 0, "%s(logical_part %s%s%s)", space,
quote, logical_part.c_str(), quote );
space = "";
}
if( useMultiLine )
......@@ -3789,13 +3804,16 @@ void PLACE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
else
{
if( lock_type != T_NONE )
out->Print( 0, "(lock_type %s)",
{
out->Print( 0, "%s(lock_type %s)", space,
LEXER::GetTokenText(lock_type) );
space = "";
}
if( part_number.size() )
{
const char* quote = out->GetQuoteChar( part_number.c_str() );
out->Print( 0, "(PN %s%s%s)",
out->Print( 0, "%s(PN %s%s%s)", space,
quote, part_number.c_str(), quote );
}
}
......@@ -3824,6 +3842,11 @@ int main( int argc, char** argv )
SPECCTRA_DB db;
bool failed = false;
if( argc == 2 )
{
filename = CONV_FROM_UTF8( argv[1] );
}
try
{
db.LoadPCB( filename );
......@@ -3831,18 +3854,22 @@ int main( int argc, char** argv )
}
catch( IOError ioe )
{
printf( "%s\n", CONV_TO_UTF8(ioe.errorText) );
fprintf( stderr, "%s\n", CONV_TO_UTF8(ioe.errorText) );
failed = true;
}
if( !failed )
printf("loaded OK\n");
fprintf( stderr, "loaded OK\n" );
// export what we read in, making this test program basically a beautifier
// db.ExportSESSION( wxT("/tmp/export.ses") );
db.ExportPCB( wxT("/tmp/export.dsn") );
// db.ExportPCB( wxT("/tmp/export.dsn") );
DSN::PCB* pcb = db.GetPCB();
// hose the beautified DSN file to stdout.
db.SetFILE( stdout );
pcb->Format( &db, 0 );
}
#endif
......
......@@ -939,12 +939,14 @@ protected:
WINDOWS windows;
//----- only one of these is used, like a union -----
PATH* path; ///< used for both path and polygon
RECTANGLE* rectangle;
CIRCLE* circle;
QARC* qarc;
//---------------------------------------------------
/* <shape_descriptor >::=
[<rectangle_descriptor> |
<circle_descriptor> |
<polygon_descriptor> |
<path_descriptor> |
<qarc_descriptor> ]
*/
ELEM* shape;
public:
......@@ -958,11 +960,7 @@ public:
{
rules = 0;
place_rules = 0;
path = 0;
rectangle = 0;
circle = 0;
qarc = 0;
shape = 0;
sequence_number = -1;
}
......@@ -971,11 +969,22 @@ public:
{
delete rules;
delete place_rules;
delete shape;
}
delete path;
delete rectangle;
delete circle;
delete qarc;
void SetShape( ELEM* aShape )
{
delete shape;
shape = aShape;
if( aShape )
{
wxASSERT(aShape->Type()==T_rect || aShape->Type()==T_circle
|| aShape->Type()==T_qarc || aShape->Type()==T_path
|| aShape->Type()==T_polygon);
aShape->SetParent( this );
}
}
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
......@@ -991,18 +1000,8 @@ public:
if( sequence_number != -1 )
out->Print( nestLevel+1, "(sequence_number %d)\n", sequence_number );
// these are mutually exclusive
if( rectangle )
rectangle->Format( out, nestLevel+1 );
else if( path )
path->Format( out, nestLevel+1 );
else if( circle )
circle->Format( out, nestLevel+1 );
else if( qarc )
qarc->Format( out, nestLevel+1 );
if( shape )
shape->Format( out, nestLevel+1 );
if( rules )
rules->Format( out, nestLevel+1 );
......@@ -2296,8 +2295,18 @@ public:
// the quotes unconditional on this one.
const char* newline = nestLevel ? "\n" : "";
#if 0
return out->Print( nestLevel, "\"%s\"-\"%s\"%s",
component_id.c_str(), pin_id.c_str(), newline );
#else
const char* cquote = out->GetQuoteChar( component_id.c_str() );
const char* pquote = out->GetQuoteChar( pin_id.c_str() );
return out->Print( nestLevel, "%s%s%s-%s%s%s%s",
cquote, component_id.c_str(), cquote,
pquote, pin_id.c_str(), pquote,
newline );
#endif
}
};
typedef std::vector<PIN_REF> PIN_REFS;
......@@ -3588,7 +3597,6 @@ public:
*/
static PCB* MakePCB();
/**
* Function SetPCB
* deletes any existing PCB and replaces it with the given one.
......@@ -3598,6 +3606,12 @@ public:
delete pcb;
pcb = aPcb;
}
PCB* GetPCB() { return pcb; }
void SetFILE( FILE* aFile )
{
fp = aFile;
}
/**
* Function SetSESSION
......
......@@ -264,16 +264,13 @@ IMAGE* SPECCTRA_DB::makeIMAGE( MODULE* aModule )
// see if this pad is a through hole with no copper on its perimeter
if( !pad->IsOnLayer( LAYER_CMP_N ) && !pad->IsOnLayer( COPPER_LAYER_N ) )
{
if( pad->m_Drill.x!=0 )
if( pad->m_Drill.x != 0 )
{
KEEPOUT* keepout = new KEEPOUT(image, T_keepout);
image->keepouts.push_back( keepout );
WINDOW* window = new WINDOW(keepout);
keepout->windows.push_back( window );
CIRCLE* circle = new CIRCLE(window);
window->SetShape( circle );
CIRCLE* circle = new CIRCLE(keepout);
keepout->SetShape( circle );
circle->SetDiameter( scale(pad->m_Drill.x) );
circle->SetVertex( POINT( mapPt( pad->m_Pos0 ) ) );
......@@ -801,7 +798,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
COPPER_PLANE* plane = new COPPER_PLANE( pcb->structure );
PATH* polygon = new PATH( plane, T_polygon );
plane->path = polygon;
plane->SetShape( polygon );
plane->name = CONV_TO_UTF8( item->m_Netname );
polygon->layer_id = CONV_TO_UTF8( layerName );
......@@ -869,7 +866,10 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
place->SetRotation( module->m_Orient/10.0 );
place->SetVertex( mapPt( module->m_Pos ) );
place->component_id = CONV_TO_UTF8( module->GetReference() );
/* not supported by freerouting.com yet.
place->part_number = CONV_TO_UTF8( module->GetValue() );
*/
// module is flipped from bottom side, set side to T_back
if( module->flag )
......@@ -906,7 +906,10 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
for( int i=0; i<items.GetCount(); ++i )
{
EQUIPOT* kinet = (EQUIPOT*)items[i];
EQUIPOT* kinet = (EQUIPOT*) items[i];
if( kinet->GetNet() == 0 )
continue;
NET* net = new NET( network );
network->nets.push_back( net );
......@@ -933,6 +936,22 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
}
//-----<create the wires from tracks>-----------------------------------
{
// export all of them for now, later we'll decide what controls we need
// on this.
static KICAD_T scanTRACKs[] = { TYPETRACK, TYPEVIA, EOT };
items.Collect( aBoard, scanTRACKs );
for( int i=0; i<items.GetCount(); ++i )
{
TRACK* torv = (TRACK*) items[i]; // torv == track or via
}
}
//-----<restore MODULEs>------------------------------------------------
// DSN Images (=Kicad MODULES and pads) must be presented from the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment