Commit 1969a511 authored by dickelbeck's avatar dickelbeck

more free specctra dsn work

parent b8b0fc6e
...@@ -737,7 +737,7 @@ L_read: ...@@ -737,7 +737,7 @@ L_read:
goto exit; goto exit;
} }
// else it was something like +5V, reset head back // else it was something like +5V, fall through below
} }
// a quoted string // a quoted string
......
...@@ -212,7 +212,7 @@ void SPECCTRA_DB::readTIME( time_t* time_stamp ) throw( IOError ) ...@@ -212,7 +212,7 @@ void SPECCTRA_DB::readTIME( time_t* time_stamp ) throw( IOError )
const char* ptok = lexer->CurText(); const char* ptok = lexer->CurText();
mytime.tm_mon = 0; // remains of we don't find a month match. mytime.tm_mon = 0; // remains if we don't find a month match.
for( int m=0; months[m]; ++m ) for( int m=0; months[m]; ++m )
{ {
if( !stricmp( months[m], ptok ) ) if( !stricmp( months[m], ptok ) )
...@@ -1985,7 +1985,7 @@ void SPECCTRA_DB::doSHAPE( SHAPE* growth ) throw( IOError ) ...@@ -1985,7 +1985,7 @@ void SPECCTRA_DB::doSHAPE( SHAPE* growth ) throw( IOError )
case T_polygon: case T_polygon:
case T_qarc: case T_qarc:
L_done_that: L_done_that:
if( growth->rectangle || growth->circle || growth->path || growth->qarc ) if( growth->Length() )
unexpected( tok ); unexpected( tok );
break; break;
default: default:
...@@ -2000,24 +2000,32 @@ L_done_that: ...@@ -2000,24 +2000,32 @@ L_done_that:
switch( tok ) switch( tok )
{ {
case T_rect: case T_rect:
growth->rectangle = new RECTANGLE( growth ); RECTANGLE* rectangle;
doRECTANGLE( growth->rectangle ); rectangle = new RECTANGLE( growth );
growth->Append( rectangle );
doRECTANGLE( rectangle );
break; break;
case T_circle: case T_circle:
growth->circle = new CIRCLE( growth ); CIRCLE* circle;
doCIRCLE( growth->circle ); circle = new CIRCLE( growth );
growth->Append( circle );
doCIRCLE( circle );
break; break;
case T_path: case T_path:
case T_polygon: case T_polygon:
growth->path = new PATH( growth, tok ); PATH* path;
doPATH( growth->path ); path = new PATH( growth, tok );
growth->Append( path );
doPATH( path );
break; break;
case T_qarc: case T_qarc:
growth->qarc = new QARC( growth ); QARC* qarc;
doQARC( growth->qarc ); qarc = new QARC( growth );
growth->Append( qarc );
doQARC( qarc );
break; break;
case T_connect: case T_connect:
...@@ -3650,16 +3658,16 @@ int main( int argc, char** argv ) ...@@ -3650,16 +3658,16 @@ int main( int argc, char** argv )
{ {
// wxString filename( wxT("/tmp/fpcroute/Sample_1sided/demo_1sided.dsn") ); // wxString filename( wxT("/tmp/fpcroute/Sample_1sided/demo_1sided.dsn") );
// wxString filename( wxT("/tmp/testdesigns/test.dsn") ); // wxString filename( wxT("/tmp/testdesigns/test.dsn") );
wxString filename( wxT("/tmp/testdesigns/test.ses") ); // wxString filename( wxT("/tmp/testdesigns/test.ses") );
// wxString filename( wxT("/tmp/specctra_big.dsn") ); wxString filename( wxT("/tmp/specctra_big.dsn") );
SPECCTRA_DB db; SPECCTRA_DB db;
bool failed = false; bool failed = false;
try try
{ {
// db.LoadPCB( filename ); db.LoadPCB( filename );
db.LoadSESSION( filename ); // db.LoadSESSION( filename );
} }
catch( IOError ioe ) catch( IOError ioe )
{ {
...@@ -3672,8 +3680,8 @@ int main( int argc, char** argv ) ...@@ -3672,8 +3680,8 @@ int main( int argc, char** argv )
// 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") );
} }
......
...@@ -111,6 +111,11 @@ struct POINT ...@@ -111,6 +111,11 @@ struct POINT
POINT() { x=0.0; y=0.0; } POINT() { x=0.0; y=0.0; }
POINT( double aX, double aY ) :
x(aX), y(aY)
{
}
bool operator==( const POINT& other ) const bool operator==( const POINT& other ) const
{ {
return x==other.x && y==other.y; return x==other.x && y==other.y;
...@@ -406,6 +411,17 @@ public: ...@@ -406,6 +411,17 @@ public:
ELEM( T_rect, aParent ) ELEM( T_rect, aParent )
{ {
} }
void SetLayerId( const char* aLayerId )
{
layer_id = aLayerId;
}
void SetCorners( const POINT& aPoint0, const POINT& aPoint1 )
{
point0 = aPoint0;
point1 = aPoint1;
}
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{ {
...@@ -439,21 +455,22 @@ public: ...@@ -439,21 +455,22 @@ public:
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{ {
out->Print( nestLevel, "(%s ", LEXER::GetTokenText( Type() ) ); out->Print( nestLevel, "(%s", LEXER::GetTokenText( Type() ) );
bool singleLine; bool singleLine;
if( rules.size() == 1 ) if( rules.size() == 1 )
{ {
singleLine = true; singleLine = true;
out->Print( 0, "%s)", rules.begin()->c_str() ); out->Print( 0, " %s)", rules.begin()->c_str() );
} }
else else
{ {
out->Print( 0, "\n" );
singleLine = false; singleLine = false;
for( STRINGS::const_iterator i = rules.begin(); i!=rules.end(); ++i ) for( STRINGS::const_iterator i = rules.begin(); i!=rules.end(); ++i )
out->Print( nestLevel, "%s\n", i->c_str() ); out->Print( nestLevel+1, "%s\n", i->c_str() );
out->Print( nestLevel, ")" ); out->Print( nestLevel, ")" );
} }
...@@ -671,6 +688,16 @@ public: ...@@ -671,6 +688,16 @@ public:
quote, layer_id.c_str(), quote, quote, layer_id.c_str(), quote,
diameter, vertex.x, vertex.y ); diameter, vertex.x, vertex.y );
} }
void SetLayerId( const char* aLayerId )
{
layer_id = aLayerId;
}
void SetDiameter( double aDiameter )
{
diameter = aDiameter;
}
}; };
...@@ -870,28 +897,42 @@ public: ...@@ -870,28 +897,42 @@ public:
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{ {
out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) ); const int RIGHTMARGIN = 80;
int perLine = out->Print( nestLevel, "(%s", LEXER::GetTokenText( Type() ) );
for( STRINGS::iterator i=padstacks.begin(); i!=padstacks.end(); ++i ) for( STRINGS::iterator i=padstacks.begin(); i!=padstacks.end(); ++i )
{ {
if( perLine > RIGHTMARGIN )
{
out->Print( 0, "\n" );
perLine = out->Print( nestLevel+1, "%s", "");
}
const char* quote = out->GetQuoteChar( i->c_str() ); const char* quote = out->GetQuoteChar( i->c_str() );
out->Print( nestLevel+1, "%s%s%s\n", quote, i->c_str(), quote ); perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
} }
if( spares.size() ) if( spares.size() )
{ {
out->Print( nestLevel+1, "(spare\n" ); out->Print( 0, "\n" );
perLine = out->Print( nestLevel+1, "(spare" );
for( STRINGS::iterator i=spares.begin(); i!=spares.end(); ++i ) for( STRINGS::iterator i=spares.begin(); i!=spares.end(); ++i )
{ {
if( perLine > RIGHTMARGIN )
{
out->Print( 0, "\n" );
perLine = out->Print( nestLevel+2, "%s", "");
}
const char* quote = out->GetQuoteChar( i->c_str() ); const char* quote = out->GetQuoteChar( i->c_str() );
out->Print( nestLevel+2, "%s%s%s\n", quote, i->c_str(), quote ); perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
} }
out->Print( nestLevel+1, ")\n" ); out->Print( 0, ")" );
} }
out->Print( nestLevel, ")\n" ); out->Print( 0, ")\n" );
} }
}; };
...@@ -1600,55 +1641,34 @@ public: ...@@ -1600,55 +1641,34 @@ public:
}; };
class SHAPE : public ELEM class SHAPE : public ELEM_HOLDER
{ {
friend class SPECCTRA_DB; friend class SPECCTRA_DB;
DSN_T connect; DSN_T connect;
//----- only one of these is used, like a union ----- /*----- only one of these is used, like a union -----
single item, but now in the kids list
PATH* path; ///< used for both path and polygon PATH* path; ///< used for both path and polygon
RECTANGLE* rectangle; RECTANGLE* rectangle;
CIRCLE* circle; CIRCLE* circle;
QARC* qarc; QARC* qarc;
//--------------------------------------------------- //--------------------------------------------------- */
WINDOWS windows; WINDOWS windows;
public: public:
SHAPE( ELEM* aParent, DSN_T aType = T_shape ) : SHAPE( ELEM* aParent, DSN_T aType = T_shape ) :
ELEM( aType, aParent ) ELEM_HOLDER( aType, aParent )
{ {
connect = T_on; connect = T_on;
path = 0;
rectangle = 0;
circle = 0;
qarc = 0;
}
~SHAPE()
{
delete path;
delete rectangle;
delete circle;
delete qarc;
} }
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{ {
if( path ) ELEM_HOLDER::FormatContents( out, nestLevel );
path->Format( out, nestLevel );
else if( rectangle )
rectangle->Format( out, nestLevel );
else if( circle )
circle->Format( out, nestLevel );
else if( qarc )
qarc->Format( out, nestLevel );
if( connect == T_off ) if( connect == T_off )
out->Print( nestLevel, "(connect %s)\n", LEXER::GetTokenText( connect ) ); out->Print( nestLevel, "(connect %s)\n", LEXER::GetTokenText( connect ) );
...@@ -1817,6 +1837,11 @@ public: ...@@ -1817,6 +1837,11 @@ public:
delete rules; delete rules;
} }
void SetPadstackId( const char* aPadstackId )
{
padstack_id = aPadstackId;
}
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{ {
const char* quote = out->GetQuoteChar( padstack_id.c_str() ); const char* quote = out->GetQuoteChar( padstack_id.c_str() );
...@@ -1865,6 +1890,7 @@ public: ...@@ -1865,6 +1890,7 @@ public:
return ELEM::GetUnits(); return ELEM::GetUnits();
} }
}; };
typedef boost::ptr_vector<PADSTACK> PADSTACKS;
/** /**
...@@ -1882,7 +1908,6 @@ class LIBRARY : public ELEM ...@@ -1882,7 +1908,6 @@ class LIBRARY : public ELEM
typedef boost::ptr_vector<IMAGE> IMAGES; typedef boost::ptr_vector<IMAGE> IMAGES;
IMAGES images; IMAGES images;
typedef boost::ptr_vector<PADSTACK> PADSTACKS;
PADSTACKS padstacks; PADSTACKS padstacks;
public: public:
...@@ -1916,6 +1941,11 @@ public: ...@@ -1916,6 +1941,11 @@ public:
return ELEM::GetUnits(); return ELEM::GetUnits();
} }
void AddPadstack( PADSTACK* aPadstack )
{
padstacks.push_back( aPadstack );
}
}; };
...@@ -2215,35 +2245,32 @@ public: ...@@ -2215,35 +2245,32 @@ public:
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{ {
const int RIGHTMARGIN = 80;
const char* quote = out->GetQuoteChar( class_id.c_str() ); const char* quote = out->GetQuoteChar( class_id.c_str() );
out->Print( nestLevel, "(%s %s%s%s", LEXER::GetTokenText( Type() ),
quote, class_id.c_str(), quote );
const int NETGAP = 2;
const int RIGHTMARGIN = 92;
int perRow=RIGHTMARGIN; int perLine = out->Print( nestLevel, "(%s %s%s%s",
LEXER::GetTokenText( Type() ),
quote, class_id.c_str(), quote );
for( STRINGS::iterator i=net_ids.begin(); i!=net_ids.end(); ++i ) for( STRINGS::iterator i=net_ids.begin(); i!=net_ids.end(); ++i )
{ {
quote = out->GetQuoteChar( i->c_str() ); if( perLine > RIGHTMARGIN )
int slength = strlen( i->c_str() );
if( *quote!='\0' )
slength += 2;
if( perRow + slength + NETGAP > RIGHTMARGIN )
{ {
out->Print( 0, "\n" ); out->Print( 0, "\n" );
perRow = 0; perLine = out->Print( nestLevel+1, "%s", "" );
perRow += out->Print( nestLevel+1, "%s%s%s",
quote, i->c_str(), quote );
}
else
{
perRow += out->Print( 0, "%*c%s%s%s", NETGAP, ' ',
quote, i->c_str(), quote );
} }
quote = out->GetQuoteChar( i->c_str() );
perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
}
bool newLine = false;
if( circuit.size() || layer_rules.size() || topology )
{
out->Print( 0, "\n" );
newLine = true;
} }
out->Print( 0, "\n" );
for( STRINGS::iterator i=circuit.begin(); i!=circuit.end(); ++i ) for( STRINGS::iterator i=circuit.begin(); i!=circuit.end(); ++i )
out->Print( nestLevel+1, "%s\n", i->c_str() ); out->Print( nestLevel+1, "%s\n", i->c_str() );
...@@ -2254,7 +2281,7 @@ public: ...@@ -2254,7 +2281,7 @@ public:
if( topology ) if( topology )
topology->Format( out, nestLevel+1 ); topology->Format( out, nestLevel+1 );
out->Print( nestLevel, ")\n" ); out->Print( newLine ? nestLevel : 0, ")\n" );
} }
}; };
...@@ -2444,6 +2471,9 @@ public: ...@@ -2444,6 +2471,9 @@ public:
perLine += out->Print( 0, "%.6g %.6g", i->x, i->y ); perLine += out->Print( 0, "%.6g %.6g", i->x, i->y );
} }
if( net_id.size() || via_number!=-1 || type!=T_NONE || attr!=T_NONE || supply)
out->Print( 0, " " );
if( net_id.size() ) if( net_id.size() )
{ {
if( perLine > RIGHTMARGIN ) if( perLine > RIGHTMARGIN )
...@@ -3183,13 +3213,6 @@ class SPECCTRA_DB : public OUTPUTFORMATTER ...@@ -3183,13 +3213,6 @@ class SPECCTRA_DB : public OUTPUTFORMATTER
void doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IOError ); void doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IOError );
/**
* Function exportEdges
* exports the EDGES_N layer of the board.
*/
void exportEdges( BOARD* aBoard ) throw( IOError );
public: public:
SPECCTRA_DB() SPECCTRA_DB()
...@@ -3288,7 +3311,17 @@ public: ...@@ -3288,7 +3311,17 @@ public:
/** /**
* Function FromBOARD * Function FromBOARD
* adds the entire BOARD to the PCB but does not write it out. * adds the entire BOARD to the PCB but does not write it out. Note that
* the BOARD given to this function must have all the MODULEs on the component
* side of the BOARD.
*
* See void WinEDA_PcbFrame::ExportToSPECCTRA( wxCommandEvent& event )
* for how this can be done before calling this function.
* @todo
* I would have liked to put the flipping logic into the ExportToSPECCTRA()
* function directly, but for some strange reason,
* void Change_Side_Module( MODULE* Module, wxDC* DC ) is a member of
* of class WinEDA_BasePcbFrame rather than class BOARD.
* *
* @param aBoard The BOARD to convert to a PCB. * @param aBoard The BOARD to convert to a PCB.
* @throw IOError, if the BOARD cannot be converted, and the text of the * @throw IOError, if the BOARD cannot be converted, and the text of the
......
This diff is collapsed.
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