Save and load print parameters and minor code cleaning in new Pcbnew file format.
This commit is contained in:
parent
7f16520498
commit
04a17d3347
|
@ -134,11 +134,7 @@ void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const
|
||||||
|
|
||||||
void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const
|
void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
m_out->Print( 0, " (layer %s)", m_out->Quotew( aItem->GetLayerName() ).c_str() );
|
m_out->Print( 0, " (layer %s)", m_out->Quotew( aItem->GetLayerName() ).c_str() );
|
||||||
#else
|
|
||||||
m_out->Print( 0, " (layer %d)", aItem->GetLayer() );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,15 +177,9 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
|
||||||
{
|
{
|
||||||
if( mask & aBoard->GetEnabledLayers() )
|
if( mask & aBoard->GetEnabledLayers() )
|
||||||
{
|
{
|
||||||
#if USE_LAYER_NAMES
|
|
||||||
m_out->Print( aNestLevel+1, "(%d %s %s", layer,
|
m_out->Print( aNestLevel+1, "(%d %s %s", layer,
|
||||||
m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str(),
|
m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str(),
|
||||||
LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
|
LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
|
||||||
#else
|
|
||||||
m_out->Print( aNestLevel+1, "(%d %s %s", layer,
|
|
||||||
m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str(),
|
|
||||||
LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( !( aBoard->GetVisibleLayers() & mask ) )
|
if( !( aBoard->GetVisibleLayers() & mask ) )
|
||||||
m_out->Print( 0, " hide" );
|
m_out->Print( 0, " hide" );
|
||||||
|
@ -209,13 +199,8 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
|
||||||
{
|
{
|
||||||
if( mask & aBoard->GetEnabledLayers() )
|
if( mask & aBoard->GetEnabledLayers() )
|
||||||
{
|
{
|
||||||
#if USE_LAYER_NAMES
|
|
||||||
m_out->Print( aNestLevel+1, "(%d %s user", layer,
|
m_out->Print( aNestLevel+1, "(%d %s user", layer,
|
||||||
m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str() );
|
m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str() );
|
||||||
#else
|
|
||||||
m_out->Print( aNestLevel+1, "(%d %s user", layer,
|
|
||||||
m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str() );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( !( aBoard->GetVisibleLayers() & mask ) )
|
if( !( aBoard->GetVisibleLayers() & mask ) )
|
||||||
m_out->Print( 0, " hide" );
|
m_out->Print( 0, " hide" );
|
||||||
|
@ -325,9 +310,7 @@ 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() );
|
||||||
|
|
||||||
#if SAVE_PCB_PLOT_PARAMS
|
|
||||||
aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
|
aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
|
||||||
#endif
|
|
||||||
|
|
||||||
m_out->Print( aNestLevel, ")\n\n" );
|
m_out->Print( aNestLevel, ")\n\n" );
|
||||||
|
|
||||||
|
@ -792,11 +775,7 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
|
||||||
{
|
{
|
||||||
if( layerMask & 1 )
|
if( layerMask & 1 )
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
m_out->Print( 0, " %s", m_out->Quotew( m_board->GetLayerName( layer ) ).c_str() );
|
m_out->Print( 0, " %s", m_out->Quotew( m_board->GetLayerName( layer ) ).c_str() );
|
||||||
#else
|
|
||||||
m_out->Print( 0, " %d", layer );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,13 +930,9 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const
|
||||||
if( aTrack->GetDrill() != UNDEFINED_DRILL_DIAMETER )
|
if( aTrack->GetDrill() != UNDEFINED_DRILL_DIAMETER )
|
||||||
m_out->Print( 0, " (drill %s)", FMT_IU( aTrack->GetDrill() ).c_str() );
|
m_out->Print( 0, " (drill %s)", FMT_IU( aTrack->GetDrill() ).c_str() );
|
||||||
|
|
||||||
#if 1
|
|
||||||
m_out->Print( 0, " (layers %s %s)",
|
m_out->Print( 0, " (layers %s %s)",
|
||||||
m_out->Quotew( m_board->GetLayerName( layer1 ) ).c_str(),
|
m_out->Quotew( m_board->GetLayerName( layer1 ) ).c_str(),
|
||||||
m_out->Quotew( m_board->GetLayerName( layer2 ) ).c_str() );
|
m_out->Quotew( m_board->GetLayerName( layer2 ) ).c_str() );
|
||||||
#else
|
|
||||||
m_out->Print( 0, " (layers %d %d)", layer1, layer2 );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -965,11 +940,7 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const
|
||||||
FMT_IU( aTrack->GetStart() ).c_str(), FMT_IU( aTrack->GetEnd() ).c_str(),
|
FMT_IU( aTrack->GetStart() ).c_str(), FMT_IU( aTrack->GetEnd() ).c_str(),
|
||||||
FMT_IU( aTrack->GetWidth() ).c_str() );
|
FMT_IU( aTrack->GetWidth() ).c_str() );
|
||||||
|
|
||||||
#if 1
|
|
||||||
m_out->Print( 0, " (layer %s)", m_out->Quotew( aTrack->GetLayerName() ).c_str() );
|
m_out->Print( 0, " (layer %s)", m_out->Quotew( aTrack->GetLayerName() ).c_str() );
|
||||||
#else
|
|
||||||
m_out->Print( 0, " (layer %d)", aTrack->GetLayer() );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_out->Print( 0, " (net %d)", aTrack->GetNet() );
|
m_out->Print( 0, " (net %d)", aTrack->GetNet() );
|
||||||
|
|
|
@ -698,7 +698,6 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
|
||||||
|
|
||||||
int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
|
int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
|
||||||
{
|
{
|
||||||
#if USE_LAYER_NAMES
|
|
||||||
wxString name = FromUTF8();
|
wxString name = FromUTF8();
|
||||||
const LAYER_HASH_MAP::iterator it = m_layerMap.find( name );
|
const LAYER_HASH_MAP::iterator it = m_layerMap.find( name );
|
||||||
|
|
||||||
|
@ -711,22 +710,6 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_layerMap[ name ];
|
return m_layerMap[ name ];
|
||||||
#else
|
|
||||||
if( CurTok() != T_NUMBER )
|
|
||||||
Expecting( T_NUMBER );
|
|
||||||
|
|
||||||
int layerIndex = parseInt();
|
|
||||||
|
|
||||||
if( !m_board->IsLayerEnabled( layerIndex ) )
|
|
||||||
{
|
|
||||||
wxString error;
|
|
||||||
error.Printf( wxT( "Layer index %d in file <%s> at line %d, offset %d was not defined in the layers section" ),
|
|
||||||
layerIndex, GetChars( CurSource() ), CurLineNumber(), CurOffset() );
|
|
||||||
THROW_IO_ERROR( error );
|
|
||||||
}
|
|
||||||
|
|
||||||
return layerIndex;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -941,8 +924,8 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
|
||||||
|
|
||||||
case T_aux_axis_origin:
|
case T_aux_axis_origin:
|
||||||
{
|
{
|
||||||
int x = parseBoardUnits( "auxilary origin X" );
|
int x = parseBoardUnits( "auxiliary origin X" );
|
||||||
int y = parseBoardUnits( "auxilary origin Y" );
|
int y = parseBoardUnits( "auxiliary origin Y" );
|
||||||
// x, y are not evaluated left to right, since they are push on stack right to left
|
// x, y are not evaluated left to right, since they are push on stack right to left
|
||||||
m_board->SetOriginAxisPosition( wxPoint( x, y ) );
|
m_board->SetOriginAxisPosition( wxPoint( x, y ) );
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
|
@ -954,7 +937,6 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if SAVE_PCB_PLOT_PARAMS
|
|
||||||
case T_pcbplotparams:
|
case T_pcbplotparams:
|
||||||
{
|
{
|
||||||
PCB_PLOT_PARAMS plotParams;
|
PCB_PLOT_PARAMS plotParams;
|
||||||
|
@ -962,9 +944,11 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
|
||||||
|
|
||||||
plotParams.Parse( &parser );
|
plotParams.Parse( &parser );
|
||||||
m_board->SetPlotOptions( plotParams );
|
m_board->SetPlotOptions( plotParams );
|
||||||
|
|
||||||
|
// I don't know why but this seems to fix a problem in PCB_PLOT_PARAMS::Parse().
|
||||||
|
NextTok();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Unexpected( CurText() );
|
Unexpected( CurText() );
|
||||||
|
@ -2308,12 +2292,12 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR )
|
||||||
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) +
|
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) +
|
||||||
wxT( " as ZONE_CONTAINER." ) );
|
wxT( " as ZONE_CONTAINER." ) );
|
||||||
|
|
||||||
int hatchStyle = CPolyLine::NO_HATCH; // Fix compil warning
|
int hatchStyle = CPolyLine::NO_HATCH; // Fix compile warning
|
||||||
int hatchPitch = 0; // Fix compil warning
|
int hatchPitch = 0; // Fix compile warning
|
||||||
wxPoint pt;
|
wxPoint pt;
|
||||||
T token;
|
T token;
|
||||||
|
|
||||||
// bigger scope since each filled_polygon is concatonated in here
|
// bigger scope since each filled_polygon is concatenated in here
|
||||||
std::vector< CPolyPt > pts;
|
std::vector< CPolyPt > pts;
|
||||||
|
|
||||||
auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) );
|
auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) );
|
||||||
|
|
|
@ -54,12 +54,9 @@ 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 SAVE_PCB_PLOT_PARAMS 0 // Set to 1 to save and load the PCB plot dialog data.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PCB_PARSER
|
* Class PCB_PARSER
|
||||||
* reads a Pcbnew s-expression fromatted #LINE_READER object and returns the appropriate
|
* reads a Pcbnew s-expression formatted #LINE_READER object and returns the appropriate
|
||||||
* #BOARD_ITEM object.
|
* #BOARD_ITEM object.
|
||||||
*/
|
*/
|
||||||
class PCB_PARSER : public PCB_LEXER
|
class PCB_PARSER : public PCB_LEXER
|
||||||
|
@ -124,7 +121,7 @@ class PCB_PARSER : public PCB_LEXER
|
||||||
* parses a coordinate pair (xy X Y) in board units (mm).
|
* parses a coordinate pair (xy X Y) in board units (mm).
|
||||||
*
|
*
|
||||||
* The parser checks if the previous token was T_LEFT and parses the remainder of
|
* The parser checks if the previous token was T_LEFT and parses the remainder of
|
||||||
* the token syntax. This is used when parsing a list of coorinate points. This
|
* the token syntax. This is used when parsing a list of coordinate points. This
|
||||||
* way the parser can be used in either case.
|
* way the parser can be used in either case.
|
||||||
*
|
*
|
||||||
* @throw PARSE_ERROR if the coordinate pair syntax is incorrect.
|
* @throw PARSE_ERROR if the coordinate pair syntax is incorrect.
|
||||||
|
|
Loading…
Reference in New Issue