Commit 4fad477d authored by Dick Hollenbeck's avatar Dick Hollenbeck

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

parent 9d86345e
...@@ -331,7 +331,9 @@ void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProper ...@@ -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. LOCALE_IO toggle; // toggles on, then off, the C locale.
m_board = aBoard; init( aProperties );
m_board = aBoard; // after init()
FILE_OUTPUTFORMATTER formatter( aFileName ); FILE_OUTPUTFORMATTER formatter( aFileName );
...@@ -881,12 +883,17 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const ...@@ -881,12 +883,17 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const
void PCB_IO::format( MODULE* aModule, int aNestLevel ) const void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
throw( IO_ERROR ) throw( IO_ERROR )
{ {
if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) )
{
const wxArrayString* initial_comments = aModule->GetInitialComments(); const wxArrayString* initial_comments = aModule->GetInitialComments();
if( initial_comments ) if( initial_comments )
{ {
for( unsigned i=0; i<initial_comments->GetCount(); ++i ) for( unsigned i=0; i<initial_comments->GetCount(); ++i )
m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[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() ); 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 ...@@ -1073,7 +1080,7 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const
{ {
if( aLayerMask & GetLayerMask( layer ) ) 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 ); layerName = m_board->GetLayerName( layer );
else // I am being called from FootprintSave() else // I am being called from FootprintSave()
...@@ -1558,7 +1565,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const ...@@ -1558,7 +1565,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
PCB_IO::PCB_IO() : PCB_IO::PCB_IO() :
m_cache( 0 ), m_cache( 0 ),
m_ctl( 0 ), m_ctl( CTL_FOR_BOARD ), // expecting to OUTPUTFORMAT into BOARD files.
m_parser( new PCB_PARSER() ) m_parser( new PCB_PARSER() )
{ {
init( 0 ); init( 0 );
...@@ -1587,6 +1594,8 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* ...@@ -1587,6 +1594,8 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES*
{ {
FILE_LINE_READER reader( aFileName ); FILE_LINE_READER reader( aFileName );
init( aProperties );
m_parser->SetLineReader( &reader ); m_parser->SetLineReader( &reader );
m_parser->SetBoard( aAppendToMe ); m_parser->SetBoard( aAppendToMe );
......
...@@ -37,12 +37,11 @@ class PCB_PARSER; ...@@ -37,12 +37,11 @@ class PCB_PARSER;
/// Current s-expression file format version. 2 was the last legacy format version. /// Current s-expression file format version. 2 was the last legacy format version.
#define SEXPR_BOARD_FILE_VERSION 3 #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_NETS (1 << 1)
#define CTL_OMIT_TSTAMPS (1 << 2) #define CTL_OMIT_TSTAMPS (1 << 2)
#define CTL_OMIT_INITIAL_COMMENTS (1 << 3) ///< omit MODULE initial comments
// common combinations of the above: // common combinations of the above:
...@@ -52,6 +51,10 @@ class PCB_PARSER; ...@@ -52,6 +51,10 @@ class PCB_PARSER;
/// Format output for a footprint library instead of clipboard or BOARD /// 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) #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 * Class PCB_IO
* is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files. * is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
......
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