add CTL_OMIT_INITIAL_COMMENTS and CTL_FOR_BOARD PCB_IO::Format()ing flags

This commit is contained in:
Dick Hollenbeck 2013-06-24 00:30:22 -05:00
parent 9d86345ea5
commit 4fad477d1a
2 changed files with 23 additions and 11 deletions

View File

@ -331,7 +331,9 @@ void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProper
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
m_board = aBoard;
init( aProperties );
m_board = aBoard; // after init()
FILE_OUTPUTFORMATTER formatter( aFileName );
@ -881,12 +883,17 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const
void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
throw( IO_ERROR )
{
if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) )
{
const wxArrayString* initial_comments = aModule->GetInitialComments();
if( initial_comments )
{
for( unsigned i=0; i<initial_comments->GetCount(); ++i )
m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) );
m_out->Print( 0, "\n" ); // improve readability?
}
}
m_out->Print( aNestLevel, "(module %s", m_out->Quotew( aModule->GetLibRef() ).c_str() );
@ -1073,7 +1080,7 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const
{
if( aLayerMask & GetLayerMask( layer ) )
{
if( m_board && !(m_ctl & CTL_STD_LAYER_NAMES) )
if( m_board && !( m_ctl & CTL_STD_LAYER_NAMES ) )
layerName = m_board->GetLayerName( layer );
else // I am being called from FootprintSave()
@ -1558,7 +1565,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
PCB_IO::PCB_IO() :
m_cache( 0 ),
m_ctl( 0 ),
m_ctl( CTL_FOR_BOARD ), // expecting to OUTPUTFORMAT into BOARD files.
m_parser( new PCB_PARSER() )
{
init( 0 );
@ -1587,6 +1594,8 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES*
{
FILE_LINE_READER reader( aFileName );
init( aProperties );
m_parser->SetLineReader( &reader );
m_parser->SetBoard( aAppendToMe );

View File

@ -37,12 +37,11 @@ class PCB_PARSER;
/// Current s-expression file format version. 2 was the last legacy format version.
#define SEXPR_BOARD_FILE_VERSION 3
/// Use English Standard layer names
#define CTL_STD_LAYER_NAMES (1 << 0)
#define CTL_STD_LAYER_NAMES (1 << 0) ///< Use English Standard layer names
#define CTL_OMIT_NETS (1 << 1)
#define CTL_OMIT_TSTAMPS (1 << 2)
#define CTL_OMIT_INITIAL_COMMENTS (1 << 3) ///< omit MODULE initial comments
// common combinations of the above:
@ -52,6 +51,10 @@ class PCB_PARSER;
/// Format output for a footprint library instead of clipboard or BOARD
#define CTL_FOR_LIBRARY (CTL_STD_LAYER_NAMES|CTL_OMIT_NETS|CTL_OMIT_TSTAMPS)
/// The zero arg constructor when PCB_IO is used for PLUGIN::Load() and PLUGIN::Save()ing
/// a BOARD file underneath IO_MGR.
#define CTL_FOR_BOARD (CTL_OMIT_INITIAL_COMMENTS)
/**
* Class PCB_IO
* is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.