more amazing free software

This commit is contained in:
dickelbeck 2008-01-30 19:16:46 +00:00
parent af1c15646f
commit b91f11ad38
3 changed files with 124 additions and 64 deletions

View File

@ -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:
@ -3699,8 +3706,9 @@ void PARSER::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOErro
if( !via_rotate_first )
out->Print( nestLevel, "(via_rotate_first off)\n" );
out->Print( nestLevel, "(case_sensitive %s)\n", case_sensitive ? "on" : "off" );
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 );
}
}
@ -3823,6 +3841,11 @@ int main( int argc, char** argv )
SPECCTRA_DB db;
bool failed = false;
if( argc == 2 )
{
filename = CONV_FROM_UTF8( argv[1] );
}
try
{
@ -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

View File

@ -938,13 +938,15 @@ protected:
RULE* place_rules;
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,13 +969,24 @@ public:
{
delete rules;
delete place_rules;
delete path;
delete rectangle;
delete circle;
delete qarc;
delete shape;
}
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 )
{
out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) );
@ -991,19 +1000,9 @@ 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 );
if( shape )
shape->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( rules )
rules->Format( out, nestLevel+1 );
@ -2295,9 +2294,19 @@ public:
// only print the newline if there is a nest level, and make
// 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,7 +3606,13 @@ public:
delete pcb;
pcb = aPcb;
}
PCB* GetPCB() { return pcb; }
void SetFILE( FILE* aFile )
{
fp = aFile;
}
/**
* Function SetSESSION
* deletes any existing SESSION and replaces it with the given one.

View File

@ -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() );
place->part_number = CONV_TO_UTF8( module->GetValue() );
/* 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 );
@ -931,7 +934,23 @@ 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>------------------------------------------------