Commit 3b2be428 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew s-expression file parser bug fixes.

* Change save order of drawings to match legacy file format object order.
* Set end point of SEGVIA to start point so the round trip back to legacy
  format is the same.
* Fixed bug saving and loading oval pad drill parameters.
* Fixed bug saving and loading rectangular pad deltas.
* Fixed missing layer for PCB_TARGET.
* Fixed EDA_TEXT italic bug.  Thanks Dick!
* Remove some left over debug logging statements.
parent f7755bdc
common/netlist_keywords.* common/netlist_keywords.*
common/netlist_lexer.h common/netlist_lexer.h
common/pcb_plot_params_lexer.h
include/netlist_lexer.h include/netlist_lexer.h
eeschema/cmp_library_lexer.h eeschema/cmp_library_lexer.h
eeschema/cmp_library_keywords.* eeschema/cmp_library_keywords.*
eeschema/template_fieldnames_keywords.* eeschema/template_fieldnames_keywords.*
eeschema/template_fieldnames_lexer.h eeschema/template_fieldnames_lexer.h
pcbnew/dialogs/dialog_freeroute_exchange_help_html.h pcbnew/dialogs/dialog_freeroute_exchange_help_html.h
pcbnew/pcb_plot_params_keywords.cpp
pcbnew/pcb_plot_params_lexer.h
Makefile Makefile
CMakeFiles CMakeFiles
CMakeCache.txt CMakeCache.txt
......
...@@ -363,7 +363,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl ...@@ -363,7 +363,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
if( m_Bold ) if( m_Bold )
aFormatter->Print( 0, " bold" ); aFormatter->Print( 0, " bold" );
if( m_Bold ) if( IsItalic() )
aFormatter->Print( 0, " italic" ); aFormatter->Print( 0, " italic" );
aFormatter->Print( 0, ")\n"); aFormatter->Print( 0, ")\n");
......
...@@ -129,6 +129,7 @@ priority ...@@ -129,6 +129,7 @@ priority
pts pts
radius radius
rev rev
rect_delta
rectangle rectangle
reference reference
right right
......
...@@ -325,7 +325,9 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const ...@@ -325,7 +325,9 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(visible_elements %X)\n", m_out->Print( aNestLevel+1, "(visible_elements %X)\n",
aBoard->GetDesignSettings().GetVisibleElements() ); aBoard->GetDesignSettings().GetVisibleElements() );
// aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 ); #if SAVE_PCB_PLOT_PARAMS
aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
#endif
m_out->Print( aNestLevel, ")\n\n" ); m_out->Print( aNestLevel, ")\n\n" );
...@@ -351,12 +353,6 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const ...@@ -351,12 +353,6 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
netclass->Format( m_out, aNestLevel, m_ctl ); netclass->Format( m_out, aNestLevel, m_ctl );
} }
// Save the graphical items on the board (not owned by a module)
for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
Format( item, aNestLevel );
m_out->Print( 0, "\n" );
// Save the modules. // Save the modules.
for( MODULE* module = aBoard->m_Modules; module; module = (MODULE*) module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = (MODULE*) module->Next() )
{ {
...@@ -364,6 +360,13 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const ...@@ -364,6 +360,13 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
} }
// Save the graphical items on the board (not owned by a module)
for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
Format( item, aNestLevel );
m_out->Print( 0, "\n" );
m_out->Print( 0, "\n" );
// Do not save MARKER_PCBs, they can be regenerated easily. // Do not save MARKER_PCBs, they can be regenerated easily.
// Save the tracks and vias. // Save the tracks and vias.
...@@ -576,14 +579,14 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const ...@@ -576,14 +579,14 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const
FMT_IU( aTarget->GetSize() ).c_str() ); FMT_IU( aTarget->GetSize() ).c_str() );
if( aTarget->GetWidth() != 0 ) if( aTarget->GetWidth() != 0 )
m_out->Print( aNestLevel, " (width %s)", FMT_IU( aTarget->GetWidth() ).c_str() ); m_out->Print( 0, " (width %s)", FMT_IU( aTarget->GetWidth() ).c_str() );
formatLayer( aTarget ); formatLayer( aTarget );
if( aTarget->GetTimeStamp() ) if( aTarget->GetTimeStamp() )
m_out->Print( aNestLevel, " (tstamp %lX)", aTarget->GetTimeStamp() ); m_out->Print( 0, " (tstamp %lX)", aTarget->GetTimeStamp() );
m_out->Print( aNestLevel, ")\n" ); m_out->Print( 0, ")\n" );
} }
...@@ -741,31 +744,36 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const ...@@ -741,31 +744,36 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
aPad->GetAttribute() ) ); aPad->GetAttribute() ) );
} }
m_out->Print( aNestLevel, "(pad %s %s %s (size %s)\n", m_out->Print( aNestLevel, "(pad %s %s %s (size %s)",
m_out->Quotew( aPad->GetPadName() ).c_str(), m_out->Quotew( aPad->GetPadName() ).c_str(),
type.c_str(), shape.c_str(), type.c_str(), shape.c_str(),
FMT_IU( aPad->GetSize() ).c_str() ); FMT_IU( aPad->GetSize() ).c_str() );
m_out->Print( aNestLevel+1, "(at %s", FMT_IU( aPad->GetPos0() ).c_str() ); m_out->Print( aNestLevel+1, " (at %s", FMT_IU( aPad->GetPos0() ).c_str() );
if( aPad->GetOrientation() != 0.0 ) if( aPad->GetOrientation() != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( aPad->GetOrientation() ).c_str() ); m_out->Print( 0, " %s", FMT_ANGLE( aPad->GetOrientation() ).c_str() );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")" );
if( (aPad->GetDelta().GetWidth()) != 0 || (aPad->GetDelta().GetHeight() != 0 ) )
m_out->Print( 0, " (rect_delta %s )", FMT_IU( aPad->GetDelta() ).c_str() );
m_out->Print( 0, "\n" );
wxSize sz = aPad->GetDrillSize();
if( (aPad->GetDrillSize().GetWidth() > 0) || (aPad->GetDrillSize().GetHeight() > 0) ) if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) )
{ {
std::string drill = (aPad->GetDrillSize().GetHeight() > 0) ? m_out->Print( aNestLevel+1, "(drill" );
FMT_IU( aPad->GetDrillSize() ).c_str() :
FMT_IU( aPad->GetDrillSize().GetWidth() ).c_str();
m_out->Print( aNestLevel+1, "(drill %s", drill.c_str() );
if( (aPad->GetOffset().x > 0) || (aPad->GetOffset().y > 0) ) if( aPad->GetDrillShape() == PAD_OVAL )
{ m_out->Print( 0, " oval" );
std::string drillOffset = ( aPad->GetOffset().x > 0 ) ?
FMT_IU( aPad->GetOffset() ).c_str() : m_out->Print( 0, " (size %s)", (sz.GetHeight() != sz.GetWidth()) ? FMT_IU( sz ).c_str() :
FMT_IU( aPad->GetOffset().x ).c_str(); FMT_IU( sz.GetWidth() ).c_str() );
m_out->Print( 0, " (offset %s)", drillOffset.c_str() );
} if( (aPad->GetOffset().x != 0) || (aPad->GetOffset().y != 0) )
m_out->Print( 0, " (offset %s)", FMT_IU( aPad->GetOffset() ).c_str() );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
......
...@@ -335,10 +335,7 @@ BOARD* PCB_PARSER::parseBOARD() throw( IO_ERROR, PARSE_ERROR ) ...@@ -335,10 +335,7 @@ BOARD* PCB_PARSER::parseBOARD() throw( IO_ERROR, PARSE_ERROR )
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
{
wxLogDebug( "Expect ( in parseBoard() after %s.", PrevTok() );
Expecting( T_LEFT ); Expecting( T_LEFT );
}
token = NextTok(); token = NextTok();
...@@ -806,10 +803,7 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) ...@@ -806,10 +803,7 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
{
wxLogDebug( "Expected ( in parseSetup()." );
Expecting( T_LEFT ); Expecting( T_LEFT );
}
token = NextTok(); token = NextTok();
...@@ -984,18 +978,20 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) ...@@ -984,18 +978,20 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
NeedRIGHT(); NeedRIGHT();
break; break;
// case T_pcbplotparams: #if SAVE_PCB_PLOT_PARAMS
// { case T_pcbplotparams:
// PCB_PLOT_PARAMS plotParams; {
// PCB_PLOT_PARAMS_PARSER parser( reader ); PCB_PLOT_PARAMS plotParams;
PCB_PLOT_PARAMS_PARSER parser( reader );
// plotParams.Parse( &parser ); plotParams.Parse( &parser );
// m_board->SetPlotOptions( plotParams ); m_board->SetPlotOptions( plotParams );
// break; break;
// } }
#endif
default: default:
Expecting( "valid setup token" ); Unexpected( CurText() );
} }
} }
...@@ -1999,52 +1995,62 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR ) ...@@ -1999,52 +1995,62 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR )
break; break;
case T_drill: case T_rect_delta:
sz.SetWidth( parseBoardUnits( "drill size" ) ); {
sz.SetHeight( 0 ); wxSize delta;
token = NextTok(); delta.SetWidth( parseBoardUnits( "rectangle delta width" ) );
delta.SetHeight( parseBoardUnits( "rectangle delta height" ) );
pad->SetDelta( delta );
NeedRIGHT();
break;
}
if( token == T_NUMBER ) case T_drill:
{
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
sz.SetHeight( parseBoardUnits() );
token = NextTok();
if( token == T_LEFT ) if( token == T_LEFT )
{
token = NextTok(); token = NextTok();
if( token != T_offset ) switch( token )
Expecting( T_offset ); {
case T_oval:
pad->SetDrillShape( PAD_OVAL );
break;
pt.x = parseDouble( "drill offset X" ); case T_size:
pt.y = 0; {
int width = parseBoardUnits( "drill width" );
int height = width;
token = NextTok(); token = NextTok();
if( token == T_NUMBER ) if( token == T_NUMBER )
{ {
pt.y = parseDouble(); height = parseBoardUnits();
NeedRIGHT(); NeedRIGHT();
} }
else if( token != T_RIGHT ) else if( token != T_RIGHT )
{ {
Expecting( T_RIGHT ); Expecting( ") or number" );
} }
pad->SetOffset( pt ); pad->SetDrillSize( wxSize( width, height ) );
} break;
else if( token != T_RIGHT )
{
Expecting( T_RIGHT );
} }
pad->SetDrillSize( sz ); case T_offset:
} pad->SetOffset( wxPoint( parseBoardUnits( "drill offset x" ),
else if( token != T_RIGHT ) parseBoardUnits( "drill offset y" ) ) );
{ NeedRIGHT();
Expecting( T_RIGHT ); break;
default:
Expecting( "oval, size, or offset" );
}
} }
break; break;
}
case T_layers: case T_layers:
{ {
...@@ -2213,6 +2219,7 @@ SEGVIA* PCB_PARSER::parseSEGVIA() throw( IO_ERROR, PARSE_ERROR ) ...@@ -2213,6 +2219,7 @@ SEGVIA* PCB_PARSER::parseSEGVIA() throw( IO_ERROR, PARSE_ERROR )
pt.x = parseBoardUnits( "start x" ); pt.x = parseBoardUnits( "start x" );
pt.y = parseBoardUnits( "start y" ); pt.y = parseBoardUnits( "start y" );
via->SetStart( pt ); via->SetStart( pt );
via->SetEnd( pt );
NeedRIGHT(); NeedRIGHT();
break; break;
...@@ -2565,6 +2572,11 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ) ...@@ -2565,6 +2572,11 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR )
NeedRIGHT(); NeedRIGHT();
break; break;
case T_layer:
target->SetLayer( parseBoardItemLayer() );
NeedRIGHT();
break;
case T_tstamp: case T_tstamp:
target->SetTimeStamp( parseHex() ); target->SetTimeStamp( parseHex() );
NeedRIGHT(); NeedRIGHT();
...@@ -2577,4 +2589,3 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ) ...@@ -2577,4 +2589,3 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR )
return target.release(); return target.release();
} }
...@@ -54,8 +54,8 @@ class ZONE_CONTAINER; ...@@ -54,8 +54,8 @@ class ZONE_CONTAINER;
WX_DECLARE_STRING_HASH_MAP( int, LAYER_HASH_MAP ); WX_DECLARE_STRING_HASH_MAP( int, LAYER_HASH_MAP );
#define USE_LAYER_NAMES 1 // Set to 0 to format and parse layers by index number. #define USE_LAYER_NAMES 1 // Set to 0 to format and parse layers by index number.
#define SAVE_PCB_PLOT_PARAMS 0 // Set to 1 to save and load the PCB plot dialog data.
/** /**
* Class PCB_PARSER * Class PCB_PARSER
...@@ -194,10 +194,10 @@ class PCB_PARSER : public PCB_LEXER ...@@ -194,10 +194,10 @@ class PCB_PARSER : public PCB_LEXER
return parseInt(); return parseInt();
} }
inline int parseHex() throw( PARSE_ERROR ) inline long parseHex() throw( PARSE_ERROR )
{ {
NeedSYMBOLorNUMBER(); NextTok();
return (int)strtol( CurText(), NULL, 16 ); return strtol( CurText(), NULL, 16 );
} }
bool parseBool() throw( PARSE_ERROR ); bool parseBool() throw( PARSE_ERROR );
......
...@@ -171,9 +171,9 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, ...@@ -171,9 +171,9 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
m_DrillShapeOpt ); m_DrillShapeOpt );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_scaleselection ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_scaleselection ),
scaleSelection ); scaleSelection );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_outputdirectory ), aFormatter->Print( aNestLevel+1, "(%s %s)", getTokenName( T_outputdirectory ),
aFormatter->Quotew( outputDirectory ).c_str() ); aFormatter->Quotew( outputDirectory ).c_str() );
aFormatter->Print( aNestLevel, ")\n" ); aFormatter->Print( 0, ")\n" );
} }
......
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