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(); DSN_T tok = nextTok();
if( tok==T_SYMBOL || tok==T_STRING ) if( isSymbol(tok) )
{ {
growth->name = lexer->CurText(); growth->name = lexer->CurText();
tok = nextTok(); tok = nextTok();
@ -789,7 +789,6 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IOError )
expecting( T_LEFT ); expecting( T_LEFT );
tok = nextTok(); tok = nextTok();
switch( tok ) switch( tok )
{ {
case T_sequence_number: case T_sequence_number:
@ -814,24 +813,32 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IOError )
break; break;
case T_rect: case T_rect:
growth->rectangle = new RECTANGLE( growth ); if( growth->shape )
doRECTANGLE( growth->rectangle ); unexpected( tok );
growth->shape = new RECTANGLE( growth );
doRECTANGLE( (RECTANGLE*) growth->shape );
break; break;
case T_circle: case T_circle:
growth->circle = new CIRCLE( growth ); if( growth->shape )
doCIRCLE( growth->circle ); unexpected( tok );
growth->shape = new CIRCLE( growth );
doCIRCLE( (CIRCLE*) growth->shape );
break; break;
case T_path: case T_path:
case T_polygon: case T_polygon:
growth->path = new PATH( growth, tok ); if( growth->shape )
doPATH( growth->path ); unexpected( tok );
growth->shape = new PATH( growth, tok );
doPATH( (PATH*) growth->shape );
break; break;
case T_qarc: case T_qarc:
growth->qarc = new QARC( growth ); if( growth->shape )
doQARC( growth->qarc ); unexpected( tok );
growth->shape = new QARC( growth );
doQARC( (QARC*) growth->shape );
break; break;
case T_window: case T_window:
@ -3699,8 +3706,9 @@ void PARSER::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOErro
if( !via_rotate_first ) if( !via_rotate_first )
out->Print( nestLevel, "(via_rotate_first off)\n" ); 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, " %.6g", rotation );
} }
out->Print( 0, " " ); const char* space = " "; // one space, as c string.
if( mirror != T_NONE ) 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 ) 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() ) if( logical_part.size() )
{ {
quote = out->GetQuoteChar( logical_part.c_str() ); 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 ); quote, logical_part.c_str(), quote );
space = "";
} }
if( useMultiLine ) if( useMultiLine )
@ -3789,13 +3804,16 @@ void PLACE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
else else
{ {
if( lock_type != T_NONE ) if( lock_type != T_NONE )
out->Print( 0, "(lock_type %s)", {
out->Print( 0, "%s(lock_type %s)", space,
LEXER::GetTokenText(lock_type) ); LEXER::GetTokenText(lock_type) );
space = "";
}
if( part_number.size() ) if( part_number.size() )
{ {
const char* quote = out->GetQuoteChar( part_number.c_str() ); 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 ); quote, part_number.c_str(), quote );
} }
} }
@ -3823,6 +3841,11 @@ int main( int argc, char** argv )
SPECCTRA_DB db; SPECCTRA_DB db;
bool failed = false; bool failed = false;
if( argc == 2 )
{
filename = CONV_FROM_UTF8( argv[1] );
}
try try
{ {
@ -3831,18 +3854,22 @@ int main( int argc, char** argv )
} }
catch( IOError ioe ) catch( IOError ioe )
{ {
printf( "%s\n", CONV_TO_UTF8(ioe.errorText) ); fprintf( stderr, "%s\n", CONV_TO_UTF8(ioe.errorText) );
failed = true; failed = true;
} }
if( !failed ) if( !failed )
printf("loaded OK\n"); fprintf( stderr, "loaded OK\n" );
// export what we read in, making this test program basically a beautifier // export what we read in, making this test program basically a beautifier
// db.ExportSESSION( wxT("/tmp/export.ses") ); // 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 #endif

View File

@ -938,13 +938,15 @@ protected:
RULE* place_rules; RULE* place_rules;
WINDOWS windows; WINDOWS windows;
//----- only one of these is used, like a union ----- /* <shape_descriptor >::=
PATH* path; ///< used for both path and polygon [<rectangle_descriptor> |
RECTANGLE* rectangle; <circle_descriptor> |
CIRCLE* circle; <polygon_descriptor> |
QARC* qarc; <path_descriptor> |
//--------------------------------------------------- <qarc_descriptor> ]
*/
ELEM* shape;
public: public:
@ -958,11 +960,7 @@ public:
{ {
rules = 0; rules = 0;
place_rules = 0; place_rules = 0;
shape = 0;
path = 0;
rectangle = 0;
circle = 0;
qarc = 0;
sequence_number = -1; sequence_number = -1;
} }
@ -971,13 +969,24 @@ public:
{ {
delete rules; delete rules;
delete place_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 ) void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{ {
out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) ); out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) );
@ -991,19 +1000,9 @@ public:
if( sequence_number != -1 ) if( sequence_number != -1 )
out->Print( nestLevel+1, "(sequence_number %d)\n", sequence_number ); out->Print( nestLevel+1, "(sequence_number %d)\n", sequence_number );
// these are mutually exclusive if( shape )
if( rectangle ) shape->Format( out, nestLevel+1 );
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( rules ) if( rules )
rules->Format( out, nestLevel+1 ); rules->Format( out, nestLevel+1 );
@ -2295,9 +2294,19 @@ public:
// only print the newline if there is a nest level, and make // only print the newline if there is a nest level, and make
// the quotes unconditional on this one. // the quotes unconditional on this one.
const char* newline = nestLevel ? "\n" : ""; const char* newline = nestLevel ? "\n" : "";
#if 0
return out->Print( nestLevel, "\"%s\"-\"%s\"%s", return out->Print( nestLevel, "\"%s\"-\"%s\"%s",
component_id.c_str(), pin_id.c_str(), newline ); 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; typedef std::vector<PIN_REF> PIN_REFS;
@ -3588,7 +3597,6 @@ public:
*/ */
static PCB* MakePCB(); static PCB* MakePCB();
/** /**
* Function SetPCB * Function SetPCB
* deletes any existing PCB and replaces it with the given one. * deletes any existing PCB and replaces it with the given one.
@ -3598,7 +3606,13 @@ public:
delete pcb; delete pcb;
pcb = aPcb; pcb = aPcb;
} }
PCB* GetPCB() { return pcb; }
void SetFILE( FILE* aFile )
{
fp = aFile;
}
/** /**
* Function SetSESSION * Function SetSESSION
* deletes any existing SESSION and replaces it with the given one. * 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 // 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->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); KEEPOUT* keepout = new KEEPOUT(image, T_keepout);
image->keepouts.push_back( keepout ); image->keepouts.push_back( keepout );
WINDOW* window = new WINDOW(keepout); CIRCLE* circle = new CIRCLE(keepout);
keepout->windows.push_back( window ); keepout->SetShape( circle );
CIRCLE* circle = new CIRCLE(window);
window->SetShape( circle );
circle->SetDiameter( scale(pad->m_Drill.x) ); circle->SetDiameter( scale(pad->m_Drill.x) );
circle->SetVertex( POINT( mapPt( pad->m_Pos0 ) ) ); 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 ); COPPER_PLANE* plane = new COPPER_PLANE( pcb->structure );
PATH* polygon = new PATH( plane, T_polygon ); PATH* polygon = new PATH( plane, T_polygon );
plane->path = polygon; plane->SetShape( polygon );
plane->name = CONV_TO_UTF8( item->m_Netname ); plane->name = CONV_TO_UTF8( item->m_Netname );
polygon->layer_id = CONV_TO_UTF8( layerName ); 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->SetRotation( module->m_Orient/10.0 );
place->SetVertex( mapPt( module->m_Pos ) ); place->SetVertex( mapPt( module->m_Pos ) );
place->component_id = CONV_TO_UTF8( module->GetReference() ); 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 // module is flipped from bottom side, set side to T_back
if( module->flag ) if( module->flag )
@ -906,7 +906,10 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
for( int i=0; i<items.GetCount(); ++i ) 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 ); NET* net = new NET( network );
network->nets.push_back( net ); 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>------------------------------------------------ //-----<restore MODULEs>------------------------------------------------