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_lexer.h
common/pcb_plot_params_lexer.h
include/netlist_lexer.h
eeschema/cmp_library_lexer.h
eeschema/cmp_library_keywords.*
eeschema/template_fieldnames_keywords.*
eeschema/template_fieldnames_lexer.h
pcbnew/dialogs/dialog_freeroute_exchange_help_html.h
pcbnew/pcb_plot_params_keywords.cpp
pcbnew/pcb_plot_params_lexer.h
Makefile
CMakeFiles
CMakeCache.txt
......
......@@ -363,7 +363,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
if( m_Bold )
aFormatter->Print( 0, " bold" );
if( m_Bold )
if( IsItalic() )
aFormatter->Print( 0, " italic" );
aFormatter->Print( 0, ")\n");
......
......@@ -129,6 +129,7 @@ priority
pts
radius
rev
rect_delta
rectangle
reference
right
......
......@@ -325,7 +325,9 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(visible_elements %X)\n",
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" );
......@@ -351,12 +353,6 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
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.
for( MODULE* module = aBoard->m_Modules; module; module = (MODULE*) module->Next() )
{
......@@ -364,6 +360,13 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
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.
// Save the tracks and vias.
......@@ -576,14 +579,14 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const
FMT_IU( aTarget->GetSize() ).c_str() );
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 );
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
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(),
type.c_str(), shape.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 )
m_out->Print( 0, " %s", FMT_ANGLE( aPad->GetOrientation() ).c_str() );
m_out->Print( 0, ")\n" );
m_out->Print( 0, ")" );
if( (aPad->GetDrillSize().GetWidth() > 0) || (aPad->GetDrillSize().GetHeight() > 0) )
{
std::string drill = (aPad->GetDrillSize().GetHeight() > 0) ?
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->GetDelta().GetWidth()) != 0 || (aPad->GetDelta().GetHeight() != 0 ) )
m_out->Print( 0, " (rect_delta %s )", FMT_IU( aPad->GetDelta() ).c_str() );
if( (aPad->GetOffset().x > 0) || (aPad->GetOffset().y > 0) )
m_out->Print( 0, "\n" );
wxSize sz = aPad->GetDrillSize();
if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) )
{
std::string drillOffset = ( aPad->GetOffset().x > 0 ) ?
FMT_IU( aPad->GetOffset() ).c_str() :
FMT_IU( aPad->GetOffset().x ).c_str();
m_out->Print( 0, " (offset %s)", drillOffset.c_str() );
}
m_out->Print( aNestLevel+1, "(drill" );
if( aPad->GetDrillShape() == PAD_OVAL )
m_out->Print( 0, " oval" );
m_out->Print( 0, " (size %s)", (sz.GetHeight() != sz.GetWidth()) ? FMT_IU( sz ).c_str() :
FMT_IU( sz.GetWidth() ).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" );
}
......
......@@ -335,10 +335,7 @@ BOARD* PCB_PARSER::parseBOARD() throw( IO_ERROR, PARSE_ERROR )
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
if( token != T_LEFT )
{
wxLogDebug( "Expect ( in parseBoard() after %s.", PrevTok() );
Expecting( T_LEFT );
}
token = NextTok();
......@@ -806,10 +803,7 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
if( token != T_LEFT )
{
wxLogDebug( "Expected ( in parseSetup()." );
Expecting( T_LEFT );
}
token = NextTok();
......@@ -984,18 +978,20 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
NeedRIGHT();
break;
// case T_pcbplotparams:
// {
// PCB_PLOT_PARAMS plotParams;
// PCB_PLOT_PARAMS_PARSER parser( reader );
#if SAVE_PCB_PLOT_PARAMS
case T_pcbplotparams:
{
PCB_PLOT_PARAMS plotParams;
PCB_PLOT_PARAMS_PARSER parser( reader );
// plotParams.Parse( &parser );
// m_board->SetPlotOptions( plotParams );
// break;
// }
plotParams.Parse( &parser );
m_board->SetPlotOptions( plotParams );
break;
}
#endif
default:
Expecting( "valid setup token" );
Unexpected( CurText() );
}
}
......@@ -1999,52 +1995,62 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR )
break;
case T_drill:
sz.SetWidth( parseBoardUnits( "drill size" ) );
sz.SetHeight( 0 );
token = NextTok();
if( token == T_NUMBER )
case T_rect_delta:
{
sz.SetHeight( parseBoardUnits() );
token = NextTok();
wxSize delta;
delta.SetWidth( parseBoardUnits( "rectangle delta width" ) );
delta.SetHeight( parseBoardUnits( "rectangle delta height" ) );
pad->SetDelta( delta );
NeedRIGHT();
break;
}
if( token == T_LEFT )
case T_drill:
{
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
if( token == T_LEFT )
token = NextTok();
if( token != T_offset )
Expecting( T_offset );
switch( token )
{
case T_oval:
pad->SetDrillShape( PAD_OVAL );
break;
pt.x = parseDouble( "drill offset X" );
pt.y = 0;
case T_size:
{
int width = parseBoardUnits( "drill width" );
int height = width;
token = NextTok();
if( token == T_NUMBER )
{
pt.y = parseDouble();
height = parseBoardUnits();
NeedRIGHT();
}
else if( token != T_RIGHT )
{
Expecting( T_RIGHT );
Expecting( ") or number" );
}
pad->SetOffset( pt );
}
else if( token != T_RIGHT )
{
Expecting( T_RIGHT );
pad->SetDrillSize( wxSize( width, height ) );
break;
}
pad->SetDrillSize( sz );
case T_offset:
pad->SetOffset( wxPoint( parseBoardUnits( "drill offset x" ),
parseBoardUnits( "drill offset y" ) ) );
NeedRIGHT();
break;
default:
Expecting( "oval, size, or offset" );
}
else if( token != T_RIGHT )
{
Expecting( T_RIGHT );
}
break;
}
case T_layers:
{
......@@ -2213,6 +2219,7 @@ SEGVIA* PCB_PARSER::parseSEGVIA() throw( IO_ERROR, PARSE_ERROR )
pt.x = parseBoardUnits( "start x" );
pt.y = parseBoardUnits( "start y" );
via->SetStart( pt );
via->SetEnd( pt );
NeedRIGHT();
break;
......@@ -2565,6 +2572,11 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR )
NeedRIGHT();
break;
case T_layer:
target->SetLayer( parseBoardItemLayer() );
NeedRIGHT();
break;
case T_tstamp:
target->SetTimeStamp( parseHex() );
NeedRIGHT();
......@@ -2577,4 +2589,3 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR )
return target.release();
}
......@@ -55,7 +55,7 @@ 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 SAVE_PCB_PLOT_PARAMS 0 // Set to 1 to save and load the PCB plot dialog data.
/**
* Class PCB_PARSER
......@@ -194,10 +194,10 @@ class PCB_PARSER : public PCB_LEXER
return parseInt();
}
inline int parseHex() throw( PARSE_ERROR )
inline long parseHex() throw( PARSE_ERROR )
{
NeedSYMBOLorNUMBER();
return (int)strtol( CurText(), NULL, 16 );
NextTok();
return strtol( CurText(), NULL, 16 );
}
bool parseBool() throw( PARSE_ERROR );
......
......@@ -171,9 +171,9 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
m_DrillShapeOpt );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_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->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