try and support Electra *.ses files
This commit is contained in:
parent
4502149368
commit
6d39b53efb
|
@ -872,6 +872,41 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IO_ERROR )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SPECCTRA_DB::doCONNECT( CONNECT* growth ) throw( IO_ERROR )
|
||||||
|
{
|
||||||
|
/* from page 143 of specctra spec:
|
||||||
|
|
||||||
|
(connect
|
||||||
|
{(terminal <object_type> [<pin_reference> ])}
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
|
T tok = NextTok();
|
||||||
|
|
||||||
|
while( tok != T_RIGHT )
|
||||||
|
{
|
||||||
|
if( tok!=T_LEFT )
|
||||||
|
Expecting( T_LEFT );
|
||||||
|
|
||||||
|
tok = NextTok();
|
||||||
|
|
||||||
|
switch( tok )
|
||||||
|
{
|
||||||
|
case T_terminal:
|
||||||
|
// since we do not use the terminal information, simlpy toss it.
|
||||||
|
while( ( tok = NextTok() ) != T_RIGHT && tok != T_EOF )
|
||||||
|
;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Unexpected( CurText() );
|
||||||
|
}
|
||||||
|
|
||||||
|
tok = NextTok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SPECCTRA_DB::doWINDOW( WINDOW* growth ) throw( IO_ERROR )
|
void SPECCTRA_DB::doWINDOW( WINDOW* growth ) throw( IO_ERROR )
|
||||||
{
|
{
|
||||||
T tok = NextTok();
|
T tok = NextTok();
|
||||||
|
@ -2823,10 +2858,8 @@ void SPECCTRA_DB::doWIRE( WIRE* growth ) throw( IO_ERROR )
|
||||||
case T_connect:
|
case T_connect:
|
||||||
if( growth->connect )
|
if( growth->connect )
|
||||||
Unexpected( tok );
|
Unexpected( tok );
|
||||||
/* @todo
|
|
||||||
growth->connect = new CONNECT( growth );
|
growth->connect = new CONNECT( growth );
|
||||||
doCONNECT( growth->connect );
|
doCONNECT( growth->connect );
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_supply:
|
case T_supply:
|
||||||
|
@ -3245,7 +3278,14 @@ void SPECCTRA_DB::doROUTE( ROUTE* growth ) throw( IO_ERROR )
|
||||||
|
|
||||||
case T_parser:
|
case T_parser:
|
||||||
if( growth->parser )
|
if( growth->parser )
|
||||||
|
{
|
||||||
|
#if 0 // Electra 2.9.1 emits two (parser ) elements in a row.
|
||||||
|
// Work around their bug for now.
|
||||||
Unexpected( tok );
|
Unexpected( tok );
|
||||||
|
#else
|
||||||
|
delete growth->parser;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
growth->parser = new PARSER( growth );
|
growth->parser = new PARSER( growth );
|
||||||
doPARSER( growth->parser );
|
doPARSER( growth->parser );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3668,6 +3668,7 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
|
||||||
void doCIRCLE( CIRCLE* growth ) throw( IO_ERROR );
|
void doCIRCLE( CIRCLE* growth ) throw( IO_ERROR );
|
||||||
void doQARC( QARC* growth ) throw( IO_ERROR );
|
void doQARC( QARC* growth ) throw( IO_ERROR );
|
||||||
void doWINDOW( WINDOW* growth ) throw( IO_ERROR );
|
void doWINDOW( WINDOW* growth ) throw( IO_ERROR );
|
||||||
|
void doCONNECT( CONNECT* growth ) throw( IO_ERROR );
|
||||||
void doREGION( REGION* growth ) throw( IO_ERROR );
|
void doREGION( REGION* growth ) throw( IO_ERROR );
|
||||||
void doCLASS_CLASS( CLASS_CLASS* growth ) throw( IO_ERROR );
|
void doCLASS_CLASS( CLASS_CLASS* growth ) throw( IO_ERROR );
|
||||||
void doLAYER_RULE( LAYER_RULE* growth ) throw( IO_ERROR );
|
void doLAYER_RULE( LAYER_RULE* growth ) throw( IO_ERROR );
|
||||||
|
|
|
@ -95,7 +95,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
|
||||||
|
|
||||||
SPECCTRA_DB db;
|
SPECCTRA_DB db;
|
||||||
|
|
||||||
SetLocaleTo_C_standard( ); // Switch the locale to standard C
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -104,8 +104,6 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
SetLocaleTo_Default( ); // revert to the current locale
|
|
||||||
|
|
||||||
ioe.errorText += '\n';
|
ioe.errorText += '\n';
|
||||||
ioe.errorText += _("BOARD may be corrupted, do not save it.");
|
ioe.errorText += _("BOARD may be corrupted, do not save it.");
|
||||||
ioe.errorText += '\n';
|
ioe.errorText += '\n';
|
||||||
|
@ -115,8 +113,6 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLocaleTo_Default( ); // revert to the current locale
|
|
||||||
|
|
||||||
OnModify();
|
OnModify();
|
||||||
GetBoard()->m_Status_Pcb = 0;
|
GetBoard()->m_Status_Pcb = 0;
|
||||||
|
|
||||||
|
@ -363,8 +359,10 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
if( !session )
|
if( !session )
|
||||||
ThrowIOError( _("Session file is missing the \"session\" section") );
|
ThrowIOError( _("Session file is missing the \"session\" section") );
|
||||||
|
|
||||||
|
/* Dick 16-Jan-2012: session need not have a placement section.
|
||||||
if( !session->placement )
|
if( !session->placement )
|
||||||
ThrowIOError( _("Session file is missing the \"placement\" section") );
|
ThrowIOError( _("Session file is missing the \"placement\" section") );
|
||||||
|
*/
|
||||||
|
|
||||||
if( !session->route )
|
if( !session->route )
|
||||||
ThrowIOError( _("Session file is missing the \"routes\" section") );
|
ThrowIOError( _("Session file is missing the \"routes\" section") );
|
||||||
|
@ -379,65 +377,66 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
|
|
||||||
buildLayerMaps( aBoard );
|
buildLayerMaps( aBoard );
|
||||||
|
|
||||||
#if 1
|
if( session->placement )
|
||||||
// Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
|
|
||||||
// each COMPONENT, reposition and re-orient each component and put on
|
|
||||||
// correct side of the board.
|
|
||||||
COMPONENTS& components = session->placement->components;
|
|
||||||
for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
|
|
||||||
{
|
{
|
||||||
PLACES& places = comp->places;
|
// Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
|
||||||
for( unsigned i=0; i<places.size(); ++i )
|
// each COMPONENT, reposition and re-orient each component and put on
|
||||||
|
// correct side of the board.
|
||||||
|
COMPONENTS& components = session->placement->components;
|
||||||
|
for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
|
||||||
{
|
{
|
||||||
PLACE* place = &places[i]; // '&' even though places[] holds a pointer!
|
PLACES& places = comp->places;
|
||||||
|
for( unsigned i=0; i<places.size(); ++i )
|
||||||
wxString reference = FROM_UTF8( place->component_id.c_str() );
|
|
||||||
MODULE* module = aBoard->FindModuleByReference( reference );
|
|
||||||
if( !module )
|
|
||||||
{
|
{
|
||||||
ThrowIOError(
|
PLACE* place = &places[i]; // '&' even though places[] holds a pointer!
|
||||||
_("Session file has 'reference' to non-existent component \"%s\""),
|
|
||||||
GetChars( reference ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !place->hasVertex )
|
wxString reference = FROM_UTF8( place->component_id.c_str() );
|
||||||
continue;
|
MODULE* module = aBoard->FindModuleByReference( reference );
|
||||||
|
if( !module )
|
||||||
UNIT_RES* resolution = place->GetUnits();
|
|
||||||
wxASSERT( resolution );
|
|
||||||
|
|
||||||
wxPoint newPos = mapPt( place->vertex, resolution );
|
|
||||||
module->SetPosition( newPos );
|
|
||||||
|
|
||||||
if( place->side == T_front )
|
|
||||||
{
|
|
||||||
// convert from degrees to tenths of degrees used in KiCad.
|
|
||||||
int orientation = (int) (place->rotation * 10.0);
|
|
||||||
if( module->GetLayer() != LAYER_N_FRONT )
|
|
||||||
{
|
{
|
||||||
// module is on copper layer (back)
|
ThrowIOError(
|
||||||
module->Flip( module->m_Pos );
|
_("Session file has 'reference' to non-existent component \"%s\""),
|
||||||
|
GetChars( reference ) );
|
||||||
}
|
}
|
||||||
module->SetOrientation( orientation );
|
|
||||||
}
|
if( !place->hasVertex )
|
||||||
else if( place->side == T_back )
|
continue;
|
||||||
{
|
|
||||||
int orientation = (int) ((place->rotation + 180.0) * 10.0);
|
UNIT_RES* resolution = place->GetUnits();
|
||||||
if( module->GetLayer() != LAYER_N_BACK )
|
wxASSERT( resolution );
|
||||||
|
|
||||||
|
wxPoint newPos = mapPt( place->vertex, resolution );
|
||||||
|
module->SetPosition( newPos );
|
||||||
|
|
||||||
|
if( place->side == T_front )
|
||||||
{
|
{
|
||||||
// module is on component layer (front)
|
// convert from degrees to tenths of degrees used in KiCad.
|
||||||
module->Flip( module->m_Pos );
|
int orientation = (int) (place->rotation * 10.0);
|
||||||
|
if( module->GetLayer() != LAYER_N_FRONT )
|
||||||
|
{
|
||||||
|
// module is on copper layer (back)
|
||||||
|
module->Flip( module->m_Pos );
|
||||||
|
}
|
||||||
|
module->SetOrientation( orientation );
|
||||||
|
}
|
||||||
|
else if( place->side == T_back )
|
||||||
|
{
|
||||||
|
int orientation = (int) ((place->rotation + 180.0) * 10.0);
|
||||||
|
if( module->GetLayer() != LAYER_N_BACK )
|
||||||
|
{
|
||||||
|
// module is on component layer (front)
|
||||||
|
module->Flip( module->m_Pos );
|
||||||
|
}
|
||||||
|
module->SetOrientation( orientation );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// as I write this, the PARSER *is* catching this, so we should never see below:
|
||||||
|
wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
|
||||||
}
|
}
|
||||||
module->SetOrientation( orientation );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// as I write this, the PARSER *is* catching this, so we should never see below:
|
|
||||||
wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
routeResolution = session->route->GetUnits();
|
routeResolution = session->route->GetUnits();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue