Commit 3802629a authored by unknown's avatar unknown Committed by jean-pierre charras

Fix kicad_plugin.cpp coding style fully broken by commit 4887 (patch from...

Fix kicad_plugin.cpp coding style fully broken by commit 4887 (patch from Orson, AKA maciej suminski).
parent 0d5c7f44
...@@ -83,38 +83,27 @@ void filterNetClass( const BOARD& aBoard, NETCLASS& aNetClass ) ...@@ -83,38 +83,27 @@ void filterNetClass( const BOARD& aBoard, NETCLASS& aNetClass )
*/ */
class FP_CACHE_ITEM class FP_CACHE_ITEM
{ {
wxFileName m_file_name; ///< The the full file name and path of the footprint to cache. wxFileName m_file_name; ///< The the full file name and path of the footprint to cache.
bool m_writable; ///< Writability status of the footprint file. bool m_writable; ///< Writability status of the footprint file.
wxDateTime m_mod_time; ///< The last file modified time stamp. wxDateTime m_mod_time; ///< The last file modified time stamp.
std::auto_ptr<MODULE> m_module; std::auto_ptr<MODULE> m_module;
public: public:
FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ); FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName );
wxString GetName() const wxString GetName() const { return m_file_name.GetDirs().Last(); }
{ wxFileName GetFileName() const { return m_file_name; }
return m_file_name.GetDirs().Last();
}
wxFileName GetFileName() const
{
return m_file_name;
}
/// Tell if the disk content or the lib_path has changed. /// Tell if the disk content or the lib_path has changed.
bool IsModified() const; bool IsModified() const;
MODULE* GetModule() const MODULE* GetModule() const { return m_module.get(); }
{ void UpdateModificationTime() { m_mod_time = m_file_name.GetModificationTime(); }
return m_module.get();
}
void UpdateModificationTime()
{
m_mod_time = m_file_name.GetModificationTime();
}
}; };
FP_CACHE_ITEM::FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ) : FP_CACHE_ITEM::FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ) :
m_module( aModule ) m_module( aModule )
{ {
m_file_name = aFileName; m_file_name = aFileName;
...@@ -124,50 +113,41 @@ FP_CACHE_ITEM::FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ) : ...@@ -124,50 +113,41 @@ FP_CACHE_ITEM::FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ) :
m_mod_time.Now(); m_mod_time.Now();
} }
bool FP_CACHE_ITEM::IsModified() const bool FP_CACHE_ITEM::IsModified() const
{ {
if( !m_file_name.FileExists() ) if( !m_file_name.FileExists() )
return false; return false;
wxLogTrace( traceFootprintLibrary, wxT( "File '%s', m_mod_time %s-%s, file mod time: %s-%s." ), wxLogTrace( traceFootprintLibrary, wxT( "File '%s', m_mod_time %s-%s, file mod time: %s-%s." ),
GetChars( m_file_name.GetFullPath() ), GetChars( m_mod_time.FormatDate() ), GetChars( m_file_name.GetFullPath() ),
GetChars( m_mod_time.FormatTime() ), GetChars( m_mod_time.FormatDate() ), GetChars( m_mod_time.FormatTime() ),
GetChars( m_file_name.GetModificationTime().FormatDate() ), GetChars( m_file_name.GetModificationTime().FormatDate() ),
GetChars( m_file_name.GetModificationTime().FormatTime() ) ); GetChars( m_file_name.GetModificationTime().FormatTime() ) );
return m_file_name.GetModificationTime() != m_mod_time; return m_file_name.GetModificationTime() != m_mod_time;
} }
typedef boost::ptr_map<std::string, FP_CACHE_ITEM> MODULE_MAP;
typedef MODULE_MAP::iterator MODULE_ITER; typedef boost::ptr_map< std::string, FP_CACHE_ITEM > MODULE_MAP;
typedef MODULE_MAP::const_iterator MODULE_CITER; typedef MODULE_MAP::iterator MODULE_ITER;
typedef MODULE_MAP::const_iterator MODULE_CITER;
class FP_CACHE class FP_CACHE
{ {
PCB_IO* m_owner; /// Plugin object that owns the cache. PCB_IO* m_owner; /// Plugin object that owns the cache.
wxFileName m_lib_path; /// The path of the library. wxFileName m_lib_path; /// The path of the library.
wxDateTime m_mod_time; /// Footprint library path modified time stamp. wxDateTime m_mod_time; /// Footprint library path modified time stamp.
MODULE_MAP m_modules; /// Map of footprint file name per MODULE*. MODULE_MAP m_modules; /// Map of footprint file name per MODULE*.
public: public:
FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath ); FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath );
wxString GetPath() const wxString GetPath() const { return m_lib_path.GetPath(); }
{ wxDateTime GetLastModificationTime() const { return m_mod_time; }
return m_lib_path.GetPath(); bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
} MODULE_MAP& GetModules() { return m_modules; }
wxDateTime GetLastModificationTime() const
{
return m_mod_time;
}
bool IsWritable() const
{
return m_lib_path.IsOk() && m_lib_path.IsDirWritable();
}
MODULE_MAP& GetModules()
{
return m_modules;
}
// Most all functions in this class throw IO_ERROR exceptions. There are no // Most all functions in this class throw IO_ERROR exceptions. There are no
// error codes nor user interface calls from here, nor in any PLUGIN. // error codes nor user interface calls from here, nor in any PLUGIN.
...@@ -211,34 +191,35 @@ public: ...@@ -211,34 +191,35 @@ public:
bool IsPath( const wxString& aPath ) const; bool IsPath( const wxString& aPath ) const;
}; };
FP_CACHE::FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath ) FP_CACHE::FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath )
{ {
m_owner = aOwner; m_owner = aOwner;
m_lib_path.SetPath( aLibraryPath ); m_lib_path.SetPath( aLibraryPath );
} }
wxDateTime FP_CACHE::GetLibModificationTime() const wxDateTime FP_CACHE::GetLibModificationTime() const
{ {
return m_lib_path.GetModificationTime(); return m_lib_path.GetModificationTime();
} }
void FP_CACHE::Save() void FP_CACHE::Save()
{ {
if( !m_lib_path.DirExists() && !m_lib_path.Mkdir() ) if( !m_lib_path.DirExists() && !m_lib_path.Mkdir() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "Cannot create footprint library path '%s'" ),
wxString::Format( _( "Cannot create footprint library path '%s'" ), m_lib_path.GetPath().GetData() ) );
m_lib_path.GetPath().GetData() ) );
} }
if( !m_lib_path.IsDirWritable() ) if( !m_lib_path.IsDirWritable() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "Footprint library path '%s' is read only" ),
wxString::Format( _( "Footprint library path '%s' is read only" ), GetChars( m_lib_path.GetPath() ) ) );
GetChars( m_lib_path.GetPath() ) ) );
} }
for( MODULE_ITER it = m_modules.begin(); it != m_modules.end(); ++it ) for( MODULE_ITER it = m_modules.begin(); it != m_modules.end(); ++it )
{ {
wxFileName fn = it->second->GetFileName(); wxFileName fn = it->second->GetFileName();
...@@ -251,7 +232,7 @@ void FP_CACHE::Save() ...@@ -251,7 +232,7 @@ void FP_CACHE::Save()
// renaming the file. // renaming the file.
{ {
wxLogTrace( traceFootprintLibrary, wxT( "Creating temporary library file %s" ), wxLogTrace( traceFootprintLibrary, wxT( "Creating temporary library file %s" ),
GetChars( tempFileName ) ); GetChars( tempFileName ) );
FILE_OUTPUTFORMATTER formatter( tempFileName ); FILE_OUTPUTFORMATTER formatter( tempFileName );
...@@ -265,7 +246,9 @@ void FP_CACHE::Save() ...@@ -265,7 +246,9 @@ void FP_CACHE::Save()
{ {
wxString msg = wxString::Format( wxString msg = wxString::Format(
_( "Cannot rename temporary file '%s' to footprint library file '%s'" ), _( "Cannot rename temporary file '%s' to footprint library file '%s'" ),
GetChars( tempFileName ), GetChars( fn.GetFullPath() ) ); GetChars( tempFileName ),
GetChars( fn.GetFullPath() )
);
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
...@@ -274,14 +257,17 @@ void FP_CACHE::Save() ...@@ -274,14 +257,17 @@ void FP_CACHE::Save()
} }
} }
void FP_CACHE::Load() void FP_CACHE::Load()
{ {
wxDir dir( m_lib_path.GetPath() ); wxDir dir( m_lib_path.GetPath() );
if( !dir.IsOpened() ) if( !dir.IsOpened() )
{ {
wxString msg = wxString::Format( _( "Footprint library path '%s' does not exist" ), wxString msg = wxString::Format(
GetChars( m_lib_path.GetPath() ) ); _( "Footprint library path '%s' does not exist" ),
GetChars( m_lib_path.GetPath() )
);
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
...@@ -296,12 +282,12 @@ void FP_CACHE::Load() ...@@ -296,12 +282,12 @@ void FP_CACHE::Load()
// prepend the libpath into fullPath // prepend the libpath into fullPath
wxFileName fullPath( m_lib_path.GetPath(), fpFileName ); wxFileName fullPath( m_lib_path.GetPath(), fpFileName );
FILE_LINE_READER reader( fullPath.GetFullPath() ); FILE_LINE_READER reader( fullPath.GetFullPath() );
m_owner->m_parser->SetLineReader( &reader ); m_owner->m_parser->SetLineReader( &reader );
std::string name = TO_UTF8( fullPath.GetName() ); std::string name = TO_UTF8( fullPath.GetName() );
MODULE* footprint = (MODULE*) m_owner->m_parser->Parse(); MODULE* footprint = (MODULE*) m_owner->m_parser->Parse();
// The footprint name is the file name without the extension. // The footprint name is the file name without the extension.
footprint->SetFPID( FPID( fullPath.GetName() ) ); footprint->SetFPID( FPID( fullPath.GetName() ) );
...@@ -316,6 +302,7 @@ void FP_CACHE::Load() ...@@ -316,6 +302,7 @@ void FP_CACHE::Load()
} }
} }
void FP_CACHE::Remove( const wxString& aFootprintName ) void FP_CACHE::Remove( const wxString& aFootprintName )
{ {
...@@ -325,8 +312,11 @@ void FP_CACHE::Remove( const wxString& aFootprintName ) ...@@ -325,8 +312,11 @@ void FP_CACHE::Remove( const wxString& aFootprintName )
if( it == m_modules.end() ) if( it == m_modules.end() )
{ {
wxString msg = wxString::Format( _( "library '%s' has no footprint '%s' to delete" ), wxString msg = wxString::Format(
GetChars( m_lib_path.GetPath() ), GetChars( aFootprintName ) ); _( "library '%s' has no footprint '%s' to delete" ),
GetChars( m_lib_path.GetPath() ),
GetChars( aFootprintName )
);
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
...@@ -336,6 +326,7 @@ void FP_CACHE::Remove( const wxString& aFootprintName ) ...@@ -336,6 +326,7 @@ void FP_CACHE::Remove( const wxString& aFootprintName )
wxRemoveFile( fullPath ); wxRemoveFile( fullPath );
} }
bool FP_CACHE::IsPath( const wxString& aPath ) const bool FP_CACHE::IsPath( const wxString& aPath ) const
{ {
// Converts path separators to native path separators // Converts path separators to native path separators
...@@ -345,6 +336,7 @@ bool FP_CACHE::IsPath( const wxString& aPath ) const ...@@ -345,6 +336,7 @@ bool FP_CACHE::IsPath( const wxString& aPath ) const
return m_lib_path == newPath; return m_lib_path == newPath;
} }
bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintName ) const bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintName ) const
{ {
// The library is modified if the library path got deleted or changed. // The library is modified if the library path got deleted or changed.
...@@ -355,7 +347,7 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN ...@@ -355,7 +347,7 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN
// it was loaded. // it was loaded.
if( aFootprintName.IsEmpty() ) if( aFootprintName.IsEmpty() )
{ {
for( MODULE_CITER it = m_modules.begin(); it != m_modules.end(); ++it ) for( MODULE_CITER it = m_modules.begin(); it != m_modules.end(); ++it )
{ {
wxFileName fn = m_lib_path; wxFileName fn = m_lib_path;
...@@ -365,20 +357,21 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN ...@@ -365,20 +357,21 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN
if( !fn.FileExists() ) if( !fn.FileExists() )
{ {
wxLogTrace( traceFootprintLibrary, wxLogTrace( traceFootprintLibrary,
wxT( "Footprint cache file '%s' does not exist." ), wxT( "Footprint cache file '%s' does not exist." ),
fn.GetFullPath().GetData() ); fn.GetFullPath().GetData() );
return true; return true;
} }
if( it->second->IsModified() ) if( it->second->IsModified() )
{ {
wxLogTrace( traceFootprintLibrary, wxLogTrace( traceFootprintLibrary,
wxT( "Footprint cache file '%s' has been modified." ), wxT( "Footprint cache file '%s' has been modified." ),
fn.GetFullPath().GetData() ); fn.GetFullPath().GetData() );
return true; return true;
} }
} }
} else }
else
{ {
MODULE_CITER it = m_modules.find( TO_UTF8( aFootprintName ) ); MODULE_CITER it = m_modules.find( TO_UTF8( aFootprintName ) );
...@@ -389,9 +382,10 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN ...@@ -389,9 +382,10 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN
return false; return false;
} }
void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties ) void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
init( aProperties ); init( aProperties );
...@@ -400,41 +394,44 @@ void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* a ...@@ -400,41 +394,44 @@ void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* a
// Prepare net mapping that assures that net codes saved in a file are consecutive integers // Prepare net mapping that assures that net codes saved in a file are consecutive integers
m_mapping->SetBoard( aBoard ); m_mapping->SetBoard( aBoard );
FILE_OUTPUTFORMATTER formatter( aFileName ); FILE_OUTPUTFORMATTER formatter( aFileName );
m_out = &formatter; // no ownership m_out = &formatter; // no ownership
m_out->Print( 0, "(kicad_pcb (version %d) (host pcbnew %s)\n", SEXPR_BOARD_FILE_VERSION, m_out->Print( 0, "(kicad_pcb (version %d) (host pcbnew %s)\n", SEXPR_BOARD_FILE_VERSION,
formatter.Quotew( GetBuildVersion() ).c_str() ); formatter.Quotew( GetBuildVersion() ).c_str() );
Format( aBoard, 1 ); Format( aBoard, 1 );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
BOARD_ITEM* PCB_IO::Parse( const wxString& aClipboardSourceInput ) throw( PARSE_ERROR, IO_ERROR ) BOARD_ITEM* PCB_IO::Parse( const wxString& aClipboardSourceInput ) throw( PARSE_ERROR, IO_ERROR )
{ {
std::string input = TO_UTF8( aClipboardSourceInput ); std::string input = TO_UTF8( aClipboardSourceInput );
STRING_LINE_READER reader( input, wxT( "clipboard" ) ); STRING_LINE_READER reader( input, wxT( "clipboard" ) );
m_parser->SetLineReader( &reader ); m_parser->SetLineReader( &reader );
return m_parser->Parse(); return m_parser->Parse();
} }
void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const
throw( IO_ERROR )
{ {
LOCALE_IO toggle; // public API function, perform anything convenient for caller LOCALE_IO toggle; // public API function, perform anything convenient for caller
switch (aItem->Type()) switch( aItem->Type() )
{ {
case PCB_T: case PCB_T:
format( (BOARD*) aItem, aNestLevel ); format( (BOARD*) aItem, aNestLevel );
break; break;
case PCB_DIMENSION_T: case PCB_DIMENSION_T:
format( (DIMENSION*) aItem, aNestLevel ); format( ( DIMENSION*) aItem, aNestLevel );
break; break;
case PCB_LINE_T: case PCB_LINE_T:
...@@ -479,6 +476,7 @@ void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const throw( IO_ERROR ) ...@@ -479,6 +476,7 @@ void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const throw( IO_ERROR )
} }
} }
void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const
{ {
if( m_ctl & CTL_STD_LAYER_NAMES ) if( m_ctl & CTL_STD_LAYER_NAMES )
...@@ -487,34 +485,37 @@ void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const ...@@ -487,34 +485,37 @@ void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const
// English layer names should never need quoting. // English layer names should never need quoting.
m_out->Print( 0, " (layer %s)", TO_UTF8( BOARD::GetStandardLayerName( layer ) ) ); m_out->Print( 0, " (layer %s)", TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
} else }
else
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() );
} }
void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
throw( IO_ERROR )
{ {
const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings(); const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
m_out->Print( aNestLevel, "(general\n" ); m_out->Print( aNestLevel, "(general\n" );
m_out->Print( aNestLevel + 1, "(links %d)\n", aBoard->GetRatsnestsCount() ); m_out->Print( aNestLevel+1, "(links %d)\n", aBoard->GetRatsnestsCount() );
m_out->Print( aNestLevel + 1, "(no_connects %d)\n", aBoard->GetUnconnectedNetCount() ); m_out->Print( aNestLevel+1, "(no_connects %d)\n", aBoard->GetUnconnectedNetCount() );
// Write Bounding box info // Write Bounding box info
m_out->Print( aNestLevel + 1, "(area %s %s %s %s)\n", m_out->Print( aNestLevel+1, "(area %s %s %s %s)\n",
FMTIU( aBoard->GetBoundingBox().GetX() ).c_str(), FMTIU( aBoard->GetBoundingBox().GetX() ).c_str(),
FMTIU( aBoard->GetBoundingBox().GetY() ).c_str(), FMTIU( aBoard->GetBoundingBox().GetY() ).c_str(),
FMTIU( aBoard->GetBoundingBox().GetRight() ).c_str(), FMTIU( aBoard->GetBoundingBox().GetRight() ).c_str(),
FMTIU( aBoard->GetBoundingBox().GetBottom() ).c_str() ); FMTIU( aBoard->GetBoundingBox().GetBottom() ).c_str() );
m_out->Print( aNestLevel + 1, "(thickness %s)\n", m_out->Print( aNestLevel+1, "(thickness %s)\n",
FMTIU( dsnSettings.GetBoardThickness() ).c_str() ); FMTIU( dsnSettings.GetBoardThickness() ).c_str() );
m_out->Print( aNestLevel + 1, "(drawings %d)\n", aBoard->m_Drawings.GetCount() ); m_out->Print( aNestLevel+1, "(drawings %d)\n", aBoard->m_Drawings.GetCount() );
m_out->Print( aNestLevel + 1, "(tracks %d)\n", aBoard->GetNumSegmTrack() ); m_out->Print( aNestLevel+1, "(tracks %d)\n", aBoard->GetNumSegmTrack() );
m_out->Print( aNestLevel + 1, "(zones %d)\n", aBoard->GetNumSegmZone() ); m_out->Print( aNestLevel+1, "(zones %d)\n", aBoard->GetNumSegmZone() );
m_out->Print( aNestLevel + 1, "(modules %d)\n", aBoard->m_Modules.GetCount() ); m_out->Print( aNestLevel+1, "(modules %d)\n", aBoard->m_Modules.GetCount() );
m_out->Print( aNestLevel + 1, "(nets %d)\n", (int) m_mapping->GetSize() ); m_out->Print( aNestLevel+1, "(nets %d)\n", (int) m_mapping->GetSize() );
m_out->Print( aNestLevel, ")\n\n" ); m_out->Print( aNestLevel, ")\n\n" );
aBoard->GetPageSettings().Format( m_out, aNestLevel, m_ctl ); aBoard->GetPageSettings().Format( m_out, aNestLevel, m_ctl );
...@@ -524,16 +525,16 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -524,16 +525,16 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
m_out->Print( aNestLevel, "(layers\n" ); m_out->Print( aNestLevel, "(layers\n" );
// Save only the used copper layers from front to back. // Save only the used copper layers from front to back.
for( LAYER_NUM layer = LAST_COPPER_LAYER; layer >= FIRST_COPPER_LAYER; --layer ) for( LAYER_NUM layer = LAST_COPPER_LAYER; layer >= FIRST_COPPER_LAYER; --layer)
{ {
LAYER_MSK mask = GetLayerMask( layer ); LAYER_MSK mask = GetLayerMask( layer );
if( mask & aBoard->GetEnabledLayers() ) if( mask & aBoard->GetEnabledLayers() )
{ {
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 ) ) );
if( ! ( aBoard->GetVisibleLayers() & mask ) ) if( !( aBoard->GetVisibleLayers() & mask ) )
m_out->Print( 0, " hide" ); m_out->Print( 0, " hide" );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
...@@ -541,15 +542,15 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -541,15 +542,15 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
} }
// Save used non-copper layers in the order they are defined. // Save used non-copper layers in the order they are defined.
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; ++layer ) for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; ++layer)
{ {
LAYER_MSK mask = GetLayerMask( layer ); LAYER_MSK mask = GetLayerMask( layer );
if( mask & aBoard->GetEnabledLayers() ) if( mask & aBoard->GetEnabledLayers() )
{ {
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() );
if( ! ( aBoard->GetVisibleLayers() & mask ) ) if( !( aBoard->GetVisibleLayers() & mask ) )
m_out->Print( 0, " hide" ); m_out->Print( 0, " hide" );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
...@@ -562,110 +563,111 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -562,110 +563,111 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
m_out->Print( aNestLevel, "(setup\n" ); m_out->Print( aNestLevel, "(setup\n" );
// Save current default track width, for compatibility with older Pcbnew version; // Save current default track width, for compatibility with older Pcbnew version;
m_out->Print( aNestLevel + 1, "(last_trace_width %s)\n", m_out->Print( aNestLevel+1, "(last_trace_width %s)\n",
FMTIU( dsnSettings.GetCurrentTrackWidth() ).c_str() ); FMTIU( dsnSettings.GetCurrentTrackWidth() ).c_str() );
// Save custom tracks width list (the first is not saved here: this is the netclass value // Save custom tracks width list (the first is not saved here: this is the netclass value
for( unsigned ii = 1; ii < dsnSettings.m_TrackWidthList.size(); ii++ ) for( unsigned ii = 1; ii < dsnSettings.m_TrackWidthList.size(); ii++ )
m_out->Print( aNestLevel + 1, "(user_trace_width %s)\n", m_out->Print( aNestLevel+1, "(user_trace_width %s)\n",
FMTIU( dsnSettings.m_TrackWidthList[ii] ).c_str() ); FMTIU( dsnSettings.m_TrackWidthList[ii] ).c_str() );
m_out->Print( aNestLevel + 1, "(trace_clearance %s)\n", m_out->Print( aNestLevel+1, "(trace_clearance %s)\n",
FMTIU( dsnSettings.GetDefault()->GetClearance() ).c_str() ); FMTIU( dsnSettings.GetDefault()->GetClearance() ).c_str() );
// ZONE_SETTINGS // ZONE_SETTINGS
m_out->Print( aNestLevel + 1, "(zone_clearance %s)\n", m_out->Print( aNestLevel+1, "(zone_clearance %s)\n",
FMTIU( aBoard->GetZoneSettings().m_ZoneClearance ).c_str() ); FMTIU( aBoard->GetZoneSettings().m_ZoneClearance ).c_str() );
m_out->Print( aNestLevel + 1, "(zone_45_only %s)\n", m_out->Print( aNestLevel+1, "(zone_45_only %s)\n",
aBoard->GetZoneSettings().m_Zone_45_Only ? "yes" : "no" ); aBoard->GetZoneSettings().m_Zone_45_Only ? "yes" : "no" );
m_out->Print( aNestLevel + 1, "(trace_min %s)\n", m_out->Print( aNestLevel+1, "(trace_min %s)\n",
FMTIU( dsnSettings.m_TrackMinWidth ).c_str() ); FMTIU( dsnSettings.m_TrackMinWidth ).c_str() );
m_out->Print( aNestLevel + 1, "(segment_width %s)\n", m_out->Print( aNestLevel+1, "(segment_width %s)\n",
FMTIU( dsnSettings.m_DrawSegmentWidth ).c_str() ); FMTIU( dsnSettings.m_DrawSegmentWidth ).c_str() );
m_out->Print( aNestLevel + 1, "(edge_width %s)\n", m_out->Print( aNestLevel+1, "(edge_width %s)\n",
FMTIU( dsnSettings.m_EdgeSegmentWidth ).c_str() ); FMTIU( dsnSettings.m_EdgeSegmentWidth ).c_str() );
// Save current default via size, for compatibility with older Pcbnew version; // Save current default via size, for compatibility with older Pcbnew version;
m_out->Print( aNestLevel + 1, "(via_size %s)\n", m_out->Print( aNestLevel+1, "(via_size %s)\n",
FMTIU( dsnSettings.GetDefault()->GetViaDiameter() ).c_str() ); FMTIU( dsnSettings.GetDefault()->GetViaDiameter() ).c_str() );
m_out->Print( aNestLevel + 1, "(via_drill %s)\n", m_out->Print( aNestLevel+1, "(via_drill %s)\n",
FMTIU( dsnSettings.GetDefault()->GetViaDrill() ).c_str() ); FMTIU( dsnSettings.GetDefault()->GetViaDrill() ).c_str() );
m_out->Print( aNestLevel + 1, "(via_min_size %s)\n", m_out->Print( aNestLevel+1, "(via_min_size %s)\n",
FMTIU( dsnSettings.m_ViasMinSize ).c_str() ); FMTIU( dsnSettings.m_ViasMinSize ).c_str() );
m_out->Print( aNestLevel + 1, "(via_min_drill %s)\n", m_out->Print( aNestLevel+1, "(via_min_drill %s)\n",
FMTIU( dsnSettings.m_ViasMinDrill ).c_str() ); FMTIU( dsnSettings.m_ViasMinDrill ).c_str() );
// Save custom vias diameters list (the first is not saved here: this is // Save custom vias diameters list (the first is not saved here: this is
// the netclass value // the netclass value
for( unsigned ii = 1; ii < dsnSettings.m_ViasDimensionsList.size(); ii++ ) for( unsigned ii = 1; ii < dsnSettings.m_ViasDimensionsList.size(); ii++ )
m_out->Print( aNestLevel + 1, "(user_via %s %s)\n", m_out->Print( aNestLevel+1, "(user_via %s %s)\n",
FMTIU( dsnSettings.m_ViasDimensionsList[ii].m_Diameter ).c_str(), FMTIU( dsnSettings.m_ViasDimensionsList[ii].m_Diameter ).c_str(),
FMTIU( dsnSettings.m_ViasDimensionsList[ii].m_Drill ).c_str() ); FMTIU( dsnSettings.m_ViasDimensionsList[ii].m_Drill ).c_str() );
// for old versions compatibility: // for old versions compatibility:
if( dsnSettings.m_BlindBuriedViaAllowed ) if( dsnSettings.m_BlindBuriedViaAllowed )
m_out->Print( aNestLevel + 1, "(blind_buried_vias_allowed yes)\n" ); m_out->Print( aNestLevel+1, "(blind_buried_vias_allowed yes)\n" );
m_out->Print( aNestLevel + 1, "(uvia_size %s)\n", m_out->Print( aNestLevel+1, "(uvia_size %s)\n",
FMTIU( dsnSettings.GetDefault()->GetuViaDiameter() ).c_str() ); FMTIU( dsnSettings.GetDefault()->GetuViaDiameter() ).c_str() );
m_out->Print( aNestLevel + 1, "(uvia_drill %s)\n", m_out->Print( aNestLevel+1, "(uvia_drill %s)\n",
FMTIU( dsnSettings.GetDefault()->GetuViaDrill() ).c_str() ); FMTIU( dsnSettings.GetDefault()->GetuViaDrill() ).c_str() );
m_out->Print( aNestLevel + 1, "(uvias_allowed %s)\n", m_out->Print( aNestLevel+1, "(uvias_allowed %s)\n",
( dsnSettings.m_MicroViasAllowed ) ? "yes" : "no" ); ( dsnSettings.m_MicroViasAllowed ) ? "yes" : "no" );
m_out->Print( aNestLevel + 1, "(uvia_min_size %s)\n", m_out->Print( aNestLevel+1, "(uvia_min_size %s)\n",
FMTIU( dsnSettings.m_MicroViasMinSize ).c_str() ); FMTIU( dsnSettings.m_MicroViasMinSize ).c_str() );
m_out->Print( aNestLevel + 1, "(uvia_min_drill %s)\n", m_out->Print( aNestLevel+1, "(uvia_min_drill %s)\n",
FMTIU( dsnSettings.m_MicroViasMinDrill ).c_str() ); FMTIU( dsnSettings.m_MicroViasMinDrill ).c_str() );
m_out->Print( aNestLevel + 1, "(pcb_text_width %s)\n", m_out->Print( aNestLevel+1, "(pcb_text_width %s)\n",
FMTIU( dsnSettings.m_PcbTextWidth ).c_str() ); FMTIU( dsnSettings.m_PcbTextWidth ).c_str() );
m_out->Print( aNestLevel + 1, "(pcb_text_size %s %s)\n", m_out->Print( aNestLevel+1, "(pcb_text_size %s %s)\n",
FMTIU( dsnSettings.m_PcbTextSize.x ).c_str(), FMTIU( dsnSettings.m_PcbTextSize.x ).c_str(),
FMTIU( dsnSettings.m_PcbTextSize.y ).c_str() ); FMTIU( dsnSettings.m_PcbTextSize.y ).c_str() );
m_out->Print( aNestLevel + 1, "(mod_edge_width %s)\n", m_out->Print( aNestLevel+1, "(mod_edge_width %s)\n",
FMTIU( dsnSettings.m_ModuleSegmentWidth ).c_str() ); FMTIU( dsnSettings.m_ModuleSegmentWidth ).c_str() );
m_out->Print( aNestLevel + 1, "(mod_text_size %s %s)\n", m_out->Print( aNestLevel+1, "(mod_text_size %s %s)\n",
FMTIU( dsnSettings.m_ModuleTextSize.x ).c_str(), FMTIU( dsnSettings.m_ModuleTextSize.x ).c_str(),
FMTIU( dsnSettings.m_ModuleTextSize.y ).c_str() ); FMTIU( dsnSettings.m_ModuleTextSize.y ).c_str() );
m_out->Print( aNestLevel + 1, "(mod_text_width %s)\n", m_out->Print( aNestLevel+1, "(mod_text_width %s)\n",
FMTIU( dsnSettings.m_ModuleTextWidth ).c_str() ); FMTIU( dsnSettings.m_ModuleTextWidth ).c_str() );
m_out->Print( aNestLevel + 1, "(pad_size %s %s)\n", m_out->Print( aNestLevel+1, "(pad_size %s %s)\n",
FMTIU( dsnSettings.m_Pad_Master.GetSize().x ).c_str(), FMTIU( dsnSettings.m_Pad_Master.GetSize().x ).c_str(),
FMTIU( dsnSettings.m_Pad_Master.GetSize().y ).c_str() ); FMTIU( dsnSettings.m_Pad_Master.GetSize().y ).c_str() );
m_out->Print( aNestLevel + 1, "(pad_drill %s)\n", m_out->Print( aNestLevel+1, "(pad_drill %s)\n",
FMTIU( dsnSettings.m_Pad_Master.GetDrillSize().x ).c_str() ); FMTIU( dsnSettings.m_Pad_Master.GetDrillSize().x ).c_str() );
m_out->Print( aNestLevel + 1, "(pad_to_mask_clearance %s)\n", m_out->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n",
FMTIU( dsnSettings.m_SolderMaskMargin ).c_str() ); FMTIU( dsnSettings.m_SolderMaskMargin ).c_str() );
if( dsnSettings.m_SolderMaskMinWidth ) if( dsnSettings.m_SolderMaskMinWidth )
m_out->Print( aNestLevel + 1, "(solder_mask_min_width %s)\n", m_out->Print( aNestLevel+1, "(solder_mask_min_width %s)\n",
FMTIU( dsnSettings.m_SolderMaskMinWidth ).c_str() ); FMTIU( dsnSettings.m_SolderMaskMinWidth ).c_str() );
if( dsnSettings.m_SolderPasteMargin != 0 ) if( dsnSettings.m_SolderPasteMargin != 0 )
m_out->Print( aNestLevel + 1, "(pad_to_paste_clearance %s)\n", m_out->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n",
FMTIU( dsnSettings.m_SolderPasteMargin ).c_str() ); FMTIU( dsnSettings.m_SolderPasteMargin ).c_str() );
if( dsnSettings.m_SolderPasteMarginRatio != 0 ) if( dsnSettings.m_SolderPasteMarginRatio != 0 )
m_out->Print( aNestLevel + 1, "(pad_to_paste_clearance_ratio %s)\n", m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n",
Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() ); Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() );
m_out->Print( aNestLevel + 1, "(aux_axis_origin %s %s)\n", m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
FMTIU( aBoard->GetAuxOrigin().x ).c_str(), FMTIU( aBoard->GetAuxOrigin().x ).c_str(),
FMTIU( aBoard->GetAuxOrigin().y ).c_str() ); FMTIU( aBoard->GetAuxOrigin().y ).c_str() );
if( aBoard->GetGridOrigin().x || aBoard->GetGridOrigin().y ) if( aBoard->GetGridOrigin().x || aBoard->GetGridOrigin().y )
m_out->Print( aNestLevel + 1, "(grid_origin %s %s)\n", m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n",
FMTIU( aBoard->GetGridOrigin().x ).c_str(), FMTIU( aBoard->GetGridOrigin().x ).c_str(),
FMTIU( aBoard->GetGridOrigin().y ).c_str() ); FMTIU( aBoard->GetGridOrigin().y ).c_str() );
m_out->Print( aNestLevel + 1, "(visible_elements %X)\n", dsnSettings.GetVisibleElements() ); m_out->Print( aNestLevel+1, "(visible_elements %X)\n",
dsnSettings.GetVisibleElements() );
aBoard->GetPlotOptions().Format( m_out, aNestLevel + 1 ); aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
m_out->Print( aNestLevel, ")\n\n" ); m_out->Print( aNestLevel, ")\n\n" );
...@@ -673,8 +675,9 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -673,8 +675,9 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
for( NETINFO_MAPPING::iterator net = m_mapping->begin(), netEnd = m_mapping->end(); for( NETINFO_MAPPING::iterator net = m_mapping->begin(), netEnd = m_mapping->end();
net != netEnd; ++net ) net != netEnd; ++net )
{ {
m_out->Print( aNestLevel, "(net %d %s)\n", m_mapping->Translate( net->GetNet() ), m_out->Print( aNestLevel, "(net %d %s)\n",
m_out->Quotew( net->GetNetname() ).c_str() ); m_mapping->Translate( net->GetNet() ),
m_out->Quotew( net->GetNetname() ).c_str() );
} }
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
...@@ -686,7 +689,8 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -686,7 +689,8 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
// Save the rest of the net classes alphabetically. // Save the rest of the net classes alphabetically.
for( NETCLASSES::const_iterator it = dsnSettings.m_NetClasses.begin(); for( NETCLASSES::const_iterator it = dsnSettings.m_NetClasses.begin();
it != dsnSettings.m_NetClasses.end(); ++it ) it != dsnSettings.m_NetClasses.end();
++it )
{ {
NETCLASS netclass = *it->second; NETCLASS netclass = *it->second;
filterNetClass( *aBoard, netclass ); // Remove empty nets (from a copy of a netclass) filterNetClass( *aBoard, netclass ); // Remove empty nets (from a copy of a netclass)
...@@ -694,14 +698,14 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -694,14 +698,14 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
} }
// 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() )
{ {
Format( module, aNestLevel ); Format( module, aNestLevel );
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
} }
// Save the graphical items on the board (not owned by a module) // Save the graphical items on the board (not owned by a module)
for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
Format( item, aNestLevel ); Format( item, aNestLevel );
if( aBoard->m_Drawings.GetCount() ) if( aBoard->m_Drawings.GetCount() )
...@@ -710,7 +714,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -710,7 +714,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
// 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.
for( TRACK* track = aBoard->m_Track; track; track = track->Next() ) for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
Format( track, aNestLevel ); Format( track, aNestLevel );
if( aBoard->m_Track.GetCount() ) if( aBoard->m_Track.GetCount() )
...@@ -720,117 +724,121 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR ) ...@@ -720,117 +724,121 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const throw( IO_ERROR )
/// will not be saved. /// will not be saved.
// Save the polygon (which are the newer technology) zones. // Save the polygon (which are the newer technology) zones.
for( int i = 0; i < aBoard->GetAreaCount(); ++i ) for( int i = 0; i < aBoard->GetAreaCount(); ++i )
Format( aBoard->GetArea( i ), aNestLevel ); Format( aBoard->GetArea( i ), aNestLevel );
} }
void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const
throw( IO_ERROR )
{ {
m_out->Print( aNestLevel, "(dimension %s (width %s)", m_out->Print( aNestLevel, "(dimension %s (width %s)",
FMT_IU( aDimension->GetValue() ).c_str(), FMT_IU( aDimension->GetValue() ).c_str(),
FMT_IU( aDimension->GetWidth() ).c_str() ); FMT_IU( aDimension->GetWidth() ).c_str() );
formatLayer( aDimension ); formatLayer( aDimension );
if( aDimension->GetTimeStamp() ) if( aDimension->GetTimeStamp() )
m_out->Print( 0, " (tstamp %lX)", aDimension->GetTimeStamp() ); m_out->Print( 0, " (tstamp %lX)", aDimension->GetTimeStamp() );
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
Format( (TEXTE_PCB*) &aDimension->Text(), aNestLevel+1 ); Format( (TEXTE_PCB*) &aDimension->Text(), aNestLevel+1 );
m_out->Print( aNestLevel+1, "(feature1 (pts (xy %s %s) (xy %s %s)))\n", m_out->Print( aNestLevel+1, "(feature1 (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_featureLineDO.x ).c_str(), FMT_IU( aDimension->m_featureLineDO.x ).c_str(),
FMT_IU( aDimension->m_featureLineDO.y ).c_str(), FMT_IU( aDimension->m_featureLineDO.y ).c_str(),
FMT_IU( aDimension->m_featureLineDF.x ).c_str(), FMT_IU( aDimension->m_featureLineDF.x ).c_str(),
FMT_IU( aDimension->m_featureLineDF.y ).c_str() ); FMT_IU( aDimension->m_featureLineDF.y ).c_str() );
m_out->Print( aNestLevel+1, "(feature2 (pts (xy %s %s) (xy %s %s)))\n", m_out->Print( aNestLevel+1, "(feature2 (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_featureLineGO.x ).c_str(), FMT_IU( aDimension->m_featureLineGO.x ).c_str(),
FMT_IU( aDimension->m_featureLineGO.y ).c_str(), FMT_IU( aDimension->m_featureLineGO.y ).c_str(),
FMT_IU( aDimension->m_featureLineGF.x ).c_str(), FMT_IU( aDimension->m_featureLineGF.x ).c_str(),
FMT_IU( aDimension->m_featureLineGF.y ).c_str() ); FMT_IU( aDimension->m_featureLineGF.y ).c_str() );
m_out->Print( aNestLevel+1, "(crossbar (pts (xy %s %s) (xy %s %s)))\n", m_out->Print( aNestLevel+1, "(crossbar (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_crossBarO.x ).c_str(), FMT_IU( aDimension->m_crossBarO.x ).c_str(),
FMT_IU( aDimension->m_crossBarO.y ).c_str(), FMT_IU( aDimension->m_crossBarO.y ).c_str(),
FMT_IU( aDimension->m_crossBarF.x ).c_str(), FMT_IU( aDimension->m_crossBarF.x ).c_str(),
FMT_IU( aDimension->m_crossBarF.y ).c_str() ); FMT_IU( aDimension->m_crossBarF.y ).c_str() );
m_out->Print( aNestLevel+1, "(arrow1a (pts (xy %s %s) (xy %s %s)))\n", m_out->Print( aNestLevel+1, "(arrow1a (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_crossBarF.x ).c_str(), FMT_IU( aDimension->m_crossBarF.x ).c_str(),
FMT_IU( aDimension->m_crossBarF.y ).c_str(), FMT_IU( aDimension->m_crossBarF.y ).c_str(),
FMT_IU( aDimension->m_arrowD1F.x ).c_str(), FMT_IU( aDimension->m_arrowD1F.x ).c_str(),
FMT_IU( aDimension->m_arrowD1F.y ).c_str() ); FMT_IU( aDimension->m_arrowD1F.y ).c_str() );
m_out->Print( aNestLevel+1, "(arrow1b (pts (xy %s %s) (xy %s %s)))\n", m_out->Print( aNestLevel+1, "(arrow1b (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_crossBarF.x ).c_str(), FMT_IU( aDimension->m_crossBarF.x ).c_str(),
FMT_IU( aDimension->m_crossBarF.y ).c_str(), FMT_IU( aDimension->m_crossBarF.y ).c_str(),
FMT_IU( aDimension->m_arrowD2F.x ).c_str(), FMT_IU( aDimension->m_arrowD2F.x ).c_str(),
FMT_IU( aDimension->m_arrowD2F.y ).c_str() ); FMT_IU( aDimension->m_arrowD2F.y ).c_str() );
m_out->Print( aNestLevel+1, "(arrow2a (pts (xy %s %s) (xy %s %s)))\n", m_out->Print( aNestLevel+1, "(arrow2a (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_crossBarO.x ).c_str(), FMT_IU( aDimension->m_crossBarO.x ).c_str(),
FMT_IU( aDimension->m_crossBarO.y ).c_str(), FMT_IU( aDimension->m_crossBarO.y ).c_str(),
FMT_IU( aDimension->m_arrowG1F.x ).c_str(), FMT_IU( aDimension->m_arrowG1F.x ).c_str(),
FMT_IU( aDimension->m_arrowG1F.y ).c_str() ); FMT_IU( aDimension->m_arrowG1F.y ).c_str() );
m_out->Print( aNestLevel+1, "(arrow2b (pts (xy %s %s) (xy %s %s)))\n", m_out->Print( aNestLevel+1, "(arrow2b (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_crossBarO.x ).c_str(), FMT_IU( aDimension->m_crossBarO.x ).c_str(),
FMT_IU( aDimension->m_crossBarO.y ).c_str(), FMT_IU( aDimension->m_crossBarO.y ).c_str(),
FMT_IU( aDimension->m_arrowG2F.x ).c_str(), FMT_IU( aDimension->m_arrowG2F.x ).c_str(),
FMT_IU( aDimension->m_arrowG2F.y ).c_str() ); FMT_IU( aDimension->m_arrowG2F.y ).c_str() );
m_out->Print( aNestLevel, ")\n" ); m_out->Print( aNestLevel, ")\n" );
} }
void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const
throw( IO_ERROR )
{ {
unsigned i; unsigned i;
switch (aSegment->GetShape()) switch( aSegment->GetShape() )
{ {
case S_SEGMENT: // Line case S_SEGMENT: // Line
m_out->Print( aNestLevel, "(gr_line (start %s) (end %s)", m_out->Print( aNestLevel, "(gr_line (start %s) (end %s)",
FMT_IU( aSegment->GetStart() ).c_str(), FMT_IU( aSegment->GetStart() ).c_str(),
FMT_IU( aSegment->GetEnd() ).c_str() ); FMT_IU( aSegment->GetEnd() ).c_str() );
if( aSegment->GetAngle() != 0.0 ) if( aSegment->GetAngle() != 0.0 )
m_out->Print( 0, " (angle %s)", FMT_ANGLE( aSegment->GetAngle() ).c_str() ); m_out->Print( 0, " (angle %s)", FMT_ANGLE( aSegment->GetAngle() ).c_str() );
break; break;
case S_CIRCLE: // Circle case S_CIRCLE: // Circle
m_out->Print( aNestLevel, "(gr_circle (center %s) (end %s)", m_out->Print( aNestLevel, "(gr_circle (center %s) (end %s)",
FMT_IU( aSegment->GetStart() ).c_str(), FMT_IU( aSegment->GetStart() ).c_str(),
FMT_IU( aSegment->GetEnd() ).c_str() ); FMT_IU( aSegment->GetEnd() ).c_str() );
break; break;
case S_ARC:// Arc case S_ARC: // Arc
m_out->Print( aNestLevel, "(gr_arc (start %s) (end %s) (angle %s)", m_out->Print( aNestLevel, "(gr_arc (start %s) (end %s) (angle %s)",
FMT_IU( aSegment->GetStart() ).c_str(), FMT_IU( aSegment->GetStart() ).c_str(),
FMT_IU( aSegment->GetEnd() ).c_str(), FMT_IU( aSegment->GetEnd() ).c_str(),
FMT_ANGLE( aSegment->GetAngle() ).c_str() ); FMT_ANGLE( aSegment->GetAngle() ).c_str() );
break; break;
case S_POLYGON:// Polygon case S_POLYGON: // Polygon
m_out->Print( aNestLevel, "(gr_poly (pts" ); m_out->Print( aNestLevel, "(gr_poly (pts" );
for( i = 0; i < aSegment->GetPolyPoints().size(); ++i ) for( i = 0; i < aSegment->GetPolyPoints().size(); ++i )
m_out->Print( 0, " (xy %s)", FMT_IU( aSegment->GetPolyPoints()[i] ).c_str() ); m_out->Print( 0, " (xy %s)", FMT_IU( aSegment->GetPolyPoints()[i] ).c_str() );
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
break; break;
case S_CURVE:// Bezier curve case S_CURVE: // Bezier curve
m_out->Print( aNestLevel, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))", m_out->Print( aNestLevel, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
FMT_IU( aSegment->GetStart() ).c_str(), FMT_IU( aSegment->GetStart() ).c_str(),
FMT_IU( aSegment->GetBezControl1() ).c_str(), FMT_IU( aSegment->GetBezControl1() ).c_str(),
FMT_IU( aSegment->GetBezControl2() ).c_str(), FMT_IU( aSegment->GetBezControl2() ).c_str(),
FMT_IU( aSegment->GetEnd() ).c_str() ); FMT_IU( aSegment->GetEnd() ).c_str() );
break; break;
default: default:
wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) ); wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) );
}; };
...@@ -848,33 +856,35 @@ void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const throw( IO_ERR ...@@ -848,33 +856,35 @@ void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const throw( IO_ERR
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const
throw( IO_ERROR )
{ {
switch (aModuleDrawing->GetShape()) switch( aModuleDrawing->GetShape() )
{ {
case S_SEGMENT: // Line case S_SEGMENT: // Line
m_out->Print( aNestLevel, "(fp_line (start %s) (end %s)", m_out->Print( aNestLevel, "(fp_line (start %s) (end %s)",
FMT_IU( aModuleDrawing->GetStart0() ).c_str(), FMT_IU( aModuleDrawing->GetStart0() ).c_str(),
FMT_IU( aModuleDrawing->GetEnd0() ).c_str() ); FMT_IU( aModuleDrawing->GetEnd0() ).c_str() );
break; break;
case S_CIRCLE: // Circle case S_CIRCLE: // Circle
m_out->Print( aNestLevel, "(fp_circle (center %s) (end %s)", m_out->Print( aNestLevel, "(fp_circle (center %s) (end %s)",
FMT_IU( aModuleDrawing->GetStart0() ).c_str(), FMT_IU( aModuleDrawing->GetStart0() ).c_str(),
FMT_IU( aModuleDrawing->GetEnd0() ).c_str() ); FMT_IU( aModuleDrawing->GetEnd0() ).c_str() );
break; break;
case S_ARC:// Arc case S_ARC: // Arc
m_out->Print( aNestLevel, "(fp_arc (start %s) (end %s) (angle %s)", m_out->Print( aNestLevel, "(fp_arc (start %s) (end %s) (angle %s)",
FMT_IU( aModuleDrawing->GetStart0() ).c_str(), FMT_IU( aModuleDrawing->GetStart0() ).c_str(),
FMT_IU( aModuleDrawing->GetEnd0() ).c_str(), FMT_IU( aModuleDrawing->GetEnd0() ).c_str(),
FMT_ANGLE( aModuleDrawing->GetAngle() ).c_str() ); FMT_ANGLE( aModuleDrawing->GetAngle() ).c_str() );
break; break;
case S_POLYGON:// Polygon case S_POLYGON: // Polygon
m_out->Print( aNestLevel, "(fp_poly (pts" ); m_out->Print( aNestLevel, "(fp_poly (pts" );
for( unsigned i = 0; i < aModuleDrawing->GetPolyPoints().size(); ++i ) for( unsigned i = 0; i < aModuleDrawing->GetPolyPoints().size(); ++i )
{ {
int nestLevel = 0; int nestLevel = 0;
...@@ -885,75 +895,80 @@ void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const throw( ...@@ -885,75 +895,80 @@ void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const throw(
} }
m_out->Print( nestLevel, "%s(xy %s)", m_out->Print( nestLevel, "%s(xy %s)",
nestLevel ? "" : " ", nestLevel ? "" : " ",
FMT_IU( aModuleDrawing->GetPolyPoints()[i] ).c_str() ); FMT_IU( aModuleDrawing->GetPolyPoints()[i] ).c_str() );
} }
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
break; break;
case S_CURVE: // Bezier curve case S_CURVE: // Bezier curve
m_out->Print( aNestLevel, "(fp_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))", m_out->Print( aNestLevel, "(fp_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
FMT_IU( aModuleDrawing->GetStart0() ).c_str(), FMT_IU( aModuleDrawing->GetStart0() ).c_str(),
FMT_IU( aModuleDrawing->GetBezControl1() ).c_str(), FMT_IU( aModuleDrawing->GetBezControl1() ).c_str(),
FMT_IU( aModuleDrawing->GetBezControl2() ).c_str(), FMT_IU( aModuleDrawing->GetBezControl2() ).c_str(),
FMT_IU( aModuleDrawing->GetEnd0() ).c_str() ); FMT_IU( aModuleDrawing->GetEnd0() ).c_str() );
break; break;
default: default:
wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) ); wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) );
}; };
formatLayer( aModuleDrawing ); formatLayer( aModuleDrawing );
if( aModuleDrawing->GetWidth() != 0 ) if( aModuleDrawing->GetWidth() != 0 )
m_out->Print( 0, " (width %s)", FMT_IU( aModuleDrawing->GetWidth() ).c_str() ); m_out->Print( 0, " (width %s)", FMT_IU( aModuleDrawing->GetWidth() ).c_str() );
/* 11-Nov-2021 remove if no one whines after a couple of months. Simple graphic items /* 11-Nov-2021 remove if no one whines after a couple of months. Simple graphic items
perhaps do not need these. perhaps do not need these.
if( aModuleDrawing->GetTimeStamp() ) if( aModuleDrawing->GetTimeStamp() )
m_out->Print( 0, " (tstamp %lX)", aModuleDrawing->GetTimeStamp() ); m_out->Print( 0, " (tstamp %lX)", aModuleDrawing->GetTimeStamp() );
if( aModuleDrawing->GetStatus() ) if( aModuleDrawing->GetStatus() )
m_out->Print( 0, " (status %X)", aModuleDrawing->GetStatus() ); m_out->Print( 0, " (status %X)", aModuleDrawing->GetStatus() );
*/ */
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const
throw( IO_ERROR )
{ {
m_out->Print( aNestLevel, "(target %s (at %s) (size %s)", m_out->Print( aNestLevel, "(target %s (at %s) (size %s)",
( aTarget->GetShape() ) ? "x" : "plus", ( aTarget->GetShape() ) ? "x" : "plus",
FMT_IU( aTarget->GetPosition() ).c_str(), FMT_IU( aTarget->GetPosition() ).c_str(),
FMT_IU( aTarget->GetSize() ).c_str() ); FMT_IU( aTarget->GetSize() ).c_str() );
if( aTarget->GetWidth() != 0 ) if( aTarget->GetWidth() != 0 )
m_out->Print( 0, " (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( 0, " (tstamp %lX)", aTarget->GetTimeStamp() ); m_out->Print( 0, " (tstamp %lX)", aTarget->GetTimeStamp() );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
void PCB_IO::format( MODULE* aModule, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
throw( IO_ERROR )
{ {
if( ! ( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) ) 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( 0, "\n" ); // improve readability?
} }
} }
m_out->Print( aNestLevel, "(module %s", m_out->Quotes( aModule->GetFPID().Format() ).c_str() ); m_out->Print( aNestLevel, "(module %s",
m_out->Quotes( aModule->GetFPID().Format() ).c_str() );
if( aModule->IsLocked() ) if( aModule->IsLocked() )
m_out->Print( 0, " locked" ); m_out->Print( 0, " locked" );
...@@ -963,71 +978,73 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const throw( IO_ERROR ) ...@@ -963,71 +978,73 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const throw( IO_ERROR )
formatLayer( aModule ); formatLayer( aModule );
if( ! ( m_ctl & CTL_OMIT_TSTAMPS ) ) if( !( m_ctl & CTL_OMIT_TSTAMPS ) )
{ {
m_out->Print( 0, " (tedit %lX) (tstamp %lX)\n", aModule->GetLastEditTime(), m_out->Print( 0, " (tedit %lX) (tstamp %lX)\n",
aModule->GetTimeStamp() ); aModule->GetLastEditTime(), aModule->GetTimeStamp() );
} else }
else
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
if( ! ( m_ctl & CTL_OMIT_AT ) ) if( !( m_ctl & CTL_OMIT_AT ) )
{ {
m_out->Print( aNestLevel + 1, "(at %s", FMT_IU( aModule->GetPosition() ).c_str() ); m_out->Print( aNestLevel+1, "(at %s", FMT_IU( aModule->GetPosition() ).c_str() );
if( aModule->GetOrientation() != 0.0 ) if( aModule->GetOrientation() != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( aModule->GetOrientation() ).c_str() ); m_out->Print( 0, " %s", FMT_ANGLE( aModule->GetOrientation() ).c_str() );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
if( !aModule->GetDescription().IsEmpty() ) if( !aModule->GetDescription().IsEmpty() )
m_out->Print( aNestLevel + 1, "(descr %s)\n", m_out->Print( aNestLevel+1, "(descr %s)\n",
m_out->Quotew( aModule->GetDescription() ).c_str() ); m_out->Quotew( aModule->GetDescription() ).c_str() );
if( !aModule->GetKeywords().IsEmpty() ) if( !aModule->GetKeywords().IsEmpty() )
m_out->Print( aNestLevel + 1, "(tags %s)\n", m_out->Print( aNestLevel+1, "(tags %s)\n",
m_out->Quotew( aModule->GetKeywords() ).c_str() ); m_out->Quotew( aModule->GetKeywords() ).c_str() );
if( ! ( m_ctl & CTL_OMIT_PATH ) && !!aModule->GetPath() ) if( !( m_ctl & CTL_OMIT_PATH ) && !!aModule->GetPath() )
m_out->Print( aNestLevel + 1, "(path %s)\n", m_out->Quotew( aModule->GetPath() ).c_str() ); m_out->Print( aNestLevel+1, "(path %s)\n",
m_out->Quotew( aModule->GetPath() ).c_str() );
if( aModule->GetPlacementCost90() != 0 ) if( aModule->GetPlacementCost90() != 0 )
m_out->Print( aNestLevel + 1, "(autoplace_cost90 %d)\n", aModule->GetPlacementCost90() ); m_out->Print( aNestLevel+1, "(autoplace_cost90 %d)\n", aModule->GetPlacementCost90() );
if( aModule->GetPlacementCost180() != 0 ) if( aModule->GetPlacementCost180() != 0 )
m_out->Print( aNestLevel + 1, "(autoplace_cost180 %d)\n", aModule->GetPlacementCost180() ); m_out->Print( aNestLevel+1, "(autoplace_cost180 %d)\n", aModule->GetPlacementCost180() );
if( aModule->GetLocalSolderMaskMargin() != 0 ) if( aModule->GetLocalSolderMaskMargin() != 0 )
m_out->Print( aNestLevel + 1, "(solder_mask_margin %s)\n", m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
FMT_IU( aModule->GetLocalSolderMaskMargin() ).c_str() ); FMT_IU( aModule->GetLocalSolderMaskMargin() ).c_str() );
if( aModule->GetLocalSolderPasteMargin() != 0 ) if( aModule->GetLocalSolderPasteMargin() != 0 )
m_out->Print( aNestLevel + 1, "(solder_paste_margin %s)\n", m_out->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
FMT_IU( aModule->GetLocalSolderPasteMargin() ).c_str() ); FMT_IU( aModule->GetLocalSolderPasteMargin() ).c_str() );
if( aModule->GetLocalSolderPasteMarginRatio() != 0 ) if( aModule->GetLocalSolderPasteMarginRatio() != 0 )
m_out->Print( aNestLevel + 1, "(solder_paste_ratio %s)\n", m_out->Print( aNestLevel+1, "(solder_paste_ratio %s)\n",
Double2Str( aModule->GetLocalSolderPasteMarginRatio() ).c_str() ); Double2Str( aModule->GetLocalSolderPasteMarginRatio() ).c_str() );
if( aModule->GetLocalClearance() != 0 ) if( aModule->GetLocalClearance() != 0 )
m_out->Print( aNestLevel + 1, "(clearance %s)\n", m_out->Print( aNestLevel+1, "(clearance %s)\n",
FMT_IU( aModule->GetLocalClearance() ).c_str() ); FMT_IU( aModule->GetLocalClearance() ).c_str() );
if( aModule->GetZoneConnection() != UNDEFINED_CONNECTION ) if( aModule->GetZoneConnection() != UNDEFINED_CONNECTION )
m_out->Print( aNestLevel + 1, "(zone_connect %d)\n", aModule->GetZoneConnection() ); m_out->Print( aNestLevel+1, "(zone_connect %d)\n", aModule->GetZoneConnection() );
if( aModule->GetThermalWidth() != 0 ) if( aModule->GetThermalWidth() != 0 )
m_out->Print( aNestLevel + 1, "(thermal_width %s)\n", m_out->Print( aNestLevel+1, "(thermal_width %s)\n",
FMT_IU( aModule->GetThermalWidth() ).c_str() ); FMT_IU( aModule->GetThermalWidth() ).c_str() );
if( aModule->GetThermalGap() != 0 ) if( aModule->GetThermalGap() != 0 )
m_out->Print( aNestLevel + 1, "(thermal_gap %s)\n", m_out->Print( aNestLevel+1, "(thermal_gap %s)\n",
FMT_IU( aModule->GetThermalGap() ).c_str() ); FMT_IU( aModule->GetThermalGap() ).c_str() );
// Attributes // Attributes
if( aModule->GetAttributes() != MOD_DEFAULT ) if( aModule->GetAttributes() != MOD_DEFAULT )
{ {
m_out->Print( aNestLevel + 1, "(attr" ); m_out->Print( aNestLevel+1, "(attr" );
if( aModule->GetAttributes() & MOD_CMS ) if( aModule->GetAttributes() & MOD_CMS )
m_out->Print( 0, " smd" ); m_out->Print( 0, " smd" );
...@@ -1038,50 +1055,52 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1038,50 +1055,52 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const throw( IO_ERROR )
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
Format( (BOARD_ITEM*) &aModule->Reference(), aNestLevel + 1 ); Format( (BOARD_ITEM*) &aModule->Reference(), aNestLevel+1 );
Format( (BOARD_ITEM*) &aModule->Value(), aNestLevel + 1 ); Format( (BOARD_ITEM*) &aModule->Value(), aNestLevel+1 );
// Save drawing elements. // Save drawing elements.
for( BOARD_ITEM* gr = aModule->GraphicalItems(); gr; gr = gr->Next() ) for( BOARD_ITEM* gr = aModule->GraphicalItems(); gr; gr = gr->Next() )
Format( gr, aNestLevel + 1 ); Format( gr, aNestLevel+1 );
// Save pads. // Save pads.
for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() ) for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
format( pad, aNestLevel + 1 ); format( pad, aNestLevel+1 );
// Save 3D info. // Save 3D info.
for( S3D_MASTER* t3D = aModule->Models(); t3D; t3D = t3D->Next() ) for( S3D_MASTER* t3D = aModule->Models(); t3D; t3D = t3D->Next() )
{ {
if( !t3D->GetShape3DName().IsEmpty() ) if( !t3D->GetShape3DName().IsEmpty() )
{ {
m_out->Print( aNestLevel + 1, "(model %s\n", m_out->Print( aNestLevel+1, "(model %s\n",
m_out->Quotew( t3D->GetShape3DName() ).c_str() ); m_out->Quotew( t3D->GetShape3DName() ).c_str() );
m_out->Print( aNestLevel + 2, "(at (xyz %s %s %s))\n", m_out->Print( aNestLevel+2, "(at (xyz %s %s %s))\n",
Double2Str( t3D->m_MatPosition.x ).c_str(), Double2Str( t3D->m_MatPosition.x ).c_str(),
Double2Str( t3D->m_MatPosition.y ).c_str(), Double2Str( t3D->m_MatPosition.y ).c_str(),
Double2Str( t3D->m_MatPosition.z ).c_str() ); Double2Str( t3D->m_MatPosition.z ).c_str() );
m_out->Print( aNestLevel + 2, "(scale (xyz %s %s %s))\n", m_out->Print( aNestLevel+2, "(scale (xyz %s %s %s))\n",
Double2Str( t3D->m_MatScale.x ).c_str(), Double2Str( t3D->m_MatScale.x ).c_str(),
Double2Str( t3D->m_MatScale.y ).c_str(), Double2Str( t3D->m_MatScale.y ).c_str(),
Double2Str( t3D->m_MatScale.z ).c_str() ); Double2Str( t3D->m_MatScale.z ).c_str() );
m_out->Print( aNestLevel + 2, "(rotate (xyz %s %s %s))\n", m_out->Print( aNestLevel+2, "(rotate (xyz %s %s %s))\n",
Double2Str( t3D->m_MatRotation.x ).c_str(), Double2Str( t3D->m_MatRotation.x ).c_str(),
Double2Str( t3D->m_MatRotation.y ).c_str(), Double2Str( t3D->m_MatRotation.y ).c_str(),
Double2Str( t3D->m_MatRotation.z ).c_str() ); Double2Str( t3D->m_MatRotation.z ).c_str() );
m_out->Print( aNestLevel + 1, ")\n" ); m_out->Print( aNestLevel+1, ")\n" );
} }
} }
m_out->Print( aNestLevel, ")\n" ); m_out->Print( aNestLevel, ")\n" );
} }
void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const
throw( IO_ERROR )
{ {
std::string output; std::string output;
if( aNestLevel == 0 ) if( aNestLevel == 0 )
output += ' '; output += ' ';
...@@ -1099,38 +1118,35 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( I ...@@ -1099,38 +1118,35 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( I
{ {
output += " *.Cu"; output += " *.Cu";
aLayerMask &= ~ALL_CU_LAYERS; // clear bits, so they are not output again below aLayerMask &= ~ALL_CU_LAYERS; // clear bits, so they are not output again below
} else if( ( aLayerMask & cuMask ) == ( LAYER_BACK | LAYER_FRONT ) ) }
else if( ( aLayerMask & cuMask ) == (LAYER_BACK | LAYER_FRONT) )
{ {
output += " F&B.Cu"; output += " F&B.Cu";
aLayerMask &= ~ ( LAYER_BACK | LAYER_FRONT ); aLayerMask &= ~(LAYER_BACK | LAYER_FRONT);
} }
if( ( aLayerMask & ( ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT ) ) if( ( aLayerMask & (ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT)) == (ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT) )
== ( ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT ) )
{ {
output += " *.Adhes"; output += " *.Adhes";
aLayerMask &= ~ ( ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT ); aLayerMask &= ~(ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT);
} }
if( ( aLayerMask & ( SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT ) ) if( ( aLayerMask & (SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT)) == (SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT) )
== ( SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT ) )
{ {
output += " *.Paste"; output += " *.Paste";
aLayerMask &= ~ ( SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT ); aLayerMask &= ~(SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT);
} }
if( ( aLayerMask & ( SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT ) ) if( ( aLayerMask & (SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT)) == (SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT) )
== ( SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT ) )
{ {
output += " *.SilkS"; output += " *.SilkS";
aLayerMask &= ~ ( SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT ); aLayerMask &= ~(SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT);
} }
if( ( aLayerMask & ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ) ) if( ( aLayerMask & (SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT)) == (SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT) )
== ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ) )
{ {
output += " *.Mask"; output += " *.Mask";
aLayerMask &= ~ ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ); aLayerMask &= ~(SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT);
} }
// output any individual layers not handled in wildcard combos above // output any individual layers not handled in wildcard combos above
...@@ -1144,11 +1160,10 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( I ...@@ -1144,11 +1160,10 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( I
{ {
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 else // I am being called from FootprintSave()
// I am being called from FootprintSave()
layerName = BOARD::GetStandardLayerName( layer ); layerName = BOARD::GetStandardLayerName( layer );
output += ' '; output += ' ';
...@@ -1159,53 +1174,40 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( I ...@@ -1159,53 +1174,40 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( I
m_out->Print( aNestLevel, "%s)", output.c_str() ); m_out->Print( aNestLevel, "%s)", output.c_str() );
} }
void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
throw( IO_ERROR )
{ {
const char* shape; const char* shape;
switch (aPad->GetShape()) switch( aPad->GetShape() )
{ {
case PAD_CIRCLE: case PAD_CIRCLE: shape = "circle"; break;
shape = "circle"; case PAD_RECT: shape = "rect"; break;
break; case PAD_OVAL: shape = "oval"; break;
case PAD_RECT: case PAD_TRAPEZOID: shape = "trapezoid"; break;
shape = "rect";
break;
case PAD_OVAL:
shape = "oval";
break;
case PAD_TRAPEZOID:
shape = "trapezoid";
break;
default: default:
THROW_IO_ERROR( wxString::Format( _( "unknown pad type: %d" ), aPad->GetShape() ) ); THROW_IO_ERROR( wxString::Format( _( "unknown pad type: %d"), aPad->GetShape() ) );
} }
const char* type; const char* type;
switch (aPad->GetAttribute()) switch( aPad->GetAttribute() )
{ {
case PAD_STANDARD: case PAD_STANDARD: type = "thru_hole"; break;
type = "thru_hole"; case PAD_SMD: type = "smd"; break;
break; case PAD_CONN: type = "connect"; break;
case PAD_SMD: case PAD_HOLE_NOT_PLATED: type = "np_thru_hole"; break;
type = "smd";
break;
case PAD_CONN:
type = "connect";
break;
case PAD_HOLE_NOT_PLATED:
type = "np_thru_hole";
break;
default: default:
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "unknown pad attribute: %d" ),
wxString::Format( _( "unknown pad attribute: %d" ), aPad->GetAttribute() ) ); aPad->GetAttribute() ) );
} }
m_out->Print( aNestLevel, "(pad %s %s %s", m_out->Quotew( aPad->GetPadName() ).c_str(), type, m_out->Print( aNestLevel, "(pad %s %s %s",
shape ); m_out->Quotew( aPad->GetPadName() ).c_str(),
type, shape );
m_out->Print( 0, " (at %s", FMT_IU( aPad->GetPos0() ).c_str() ); m_out->Print( 0, " (at %s", FMT_IU( aPad->GetPos0() ).c_str() );
if( aPad->GetOrientation() != 0.0 ) if( aPad->GetOrientation() != 0.0 )
...@@ -1214,14 +1216,14 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1214,14 +1216,14 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR )
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
m_out->Print( 0, " (size %s)", FMT_IU( aPad->GetSize() ).c_str() ); m_out->Print( 0, " (size %s)", FMT_IU( aPad->GetSize() ).c_str() );
if( ( aPad->GetDelta().GetWidth() ) != 0 || ( aPad->GetDelta().GetHeight() != 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, " (rect_delta %s )", FMT_IU( aPad->GetDelta() ).c_str() );
wxSize sz = aPad->GetDrillSize(); wxSize sz = aPad->GetDrillSize();
wxPoint shapeoffset = aPad->GetOffset(); wxPoint shapeoffset = aPad->GetOffset();
if( ( sz.GetWidth() > 0 ) || ( sz.GetHeight() > 0 ) || ( shapeoffset.x != 0 ) if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
|| ( shapeoffset.y != 0 ) ) (shapeoffset.x != 0) || (shapeoffset.y != 0) )
{ {
m_out->Print( 0, " (drill" ); m_out->Print( 0, " (drill" );
...@@ -1229,12 +1231,12 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1229,12 +1231,12 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR )
m_out->Print( 0, " oval" ); m_out->Print( 0, " oval" );
if( sz.GetWidth() > 0 ) if( sz.GetWidth() > 0 )
m_out->Print( 0, " %s", FMT_IU( sz.GetWidth() ).c_str() ); m_out->Print( 0, " %s", FMT_IU( sz.GetWidth() ).c_str() );
if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() ) if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
m_out->Print( 0, " %s", FMT_IU( sz.GetHeight() ).c_str() ); m_out->Print( 0, " %s", FMT_IU( sz.GetHeight() ).c_str() );
if( ( shapeoffset.x != 0 ) || ( shapeoffset.y != 0 ) ) if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
m_out->Print( 0, " (offset %s)", FMT_IU( aPad->GetOffset() ).c_str() ); m_out->Print( 0, " (offset %s)", FMT_IU( aPad->GetOffset() ).c_str() );
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
...@@ -1245,9 +1247,9 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1245,9 +1247,9 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR )
std::string output; std::string output;
// Unconnected pad is default net so don't save it. // Unconnected pad is default net so don't save it.
if( ! ( m_ctl & CTL_OMIT_NETS ) && aPad->GetNetCode() != NETINFO_LIST::UNCONNECTED ) if( !( m_ctl & CTL_OMIT_NETS ) && aPad->GetNetCode() != NETINFO_LIST::UNCONNECTED )
StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ), StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ),
m_out->Quotew( aPad->GetNetname() ).c_str() ); m_out->Quotew( aPad->GetNetname() ).c_str() );
if( aPad->GetPadToDieLength() != 0 ) if( aPad->GetPadToDieLength() != 0 )
StrPrintf( &output, " (die_length %s)", FMT_IU( aPad->GetPadToDieLength() ).c_str() ); StrPrintf( &output, " (die_length %s)", FMT_IU( aPad->GetPadToDieLength() ).c_str() );
...@@ -1277,26 +1279,29 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1277,26 +1279,29 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const throw( IO_ERROR )
if( output.size() ) if( output.size() )
{ {
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
m_out->Print( aNestLevel + 1, "%s", output.c_str() + 1 ); // +1 skips 1st space on 1st element m_out->Print( aNestLevel+1, "%s", output.c_str()+1 ); // +1 skips 1st space on 1st element
} }
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const
throw( IO_ERROR )
{ {
m_out->Print( aNestLevel, "(gr_text %s (at %s", m_out->Quotew( aText->GetText() ).c_str(), m_out->Print( aNestLevel, "(gr_text %s (at %s",
FMT_IU( aText->GetTextPosition() ).c_str() ); m_out->Quotew( aText->GetText() ).c_str(),
FMT_IU( aText->GetTextPosition() ).c_str() );
if( aText->GetOrientation() != 0.0 ) if( aText->GetOrientation() != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( aText->GetOrientation() ).c_str() ); m_out->Print( 0, " %s", FMT_ANGLE( aText->GetOrientation() ).c_str() );
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
formatLayer( aText ); formatLayer( aText );
if( aText->GetTimeStamp() ) if( aText->GetTimeStamp() )
m_out->Print( 0, " (tstamp %lX)", aText->GetTimeStamp() ); m_out->Print( 0, " (tstamp %lX)", aText->GetTimeStamp() );
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
...@@ -1305,22 +1310,19 @@ void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1305,22 +1310,19 @@ void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const throw( IO_ERROR )
m_out->Print( aNestLevel, ")\n" ); m_out->Print( aNestLevel, ")\n" );
} }
void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const
throw( IO_ERROR )
{ {
MODULE* parent = (MODULE*) aText->GetParent(); MODULE* parent = (MODULE*) aText->GetParent();
double orient = aText->GetOrientation(); double orient = aText->GetOrientation();
wxString type; wxString type;
switch (aText->GetType()) switch( aText->GetType() )
{ {
case TEXTE_MODULE::TEXT_is_REFERENCE: case TEXTE_MODULE::TEXT_is_REFERENCE: type = wxT( "reference" ); break;
type = wxT( "reference" ); case TEXTE_MODULE::TEXT_is_VALUE: type = wxT( "value" ); break;
break; default: type = wxT( "user" );
case TEXTE_MODULE::TEXT_is_VALUE:
type = wxT( "value" );
break;
default:
type = wxT( "user" );
} }
// Due to the Pcbnew history, m_Orient is saved in screen value // Due to the Pcbnew history, m_Orient is saved in screen value
...@@ -1328,9 +1330,10 @@ void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const throw( IO_ERROR ...@@ -1328,9 +1330,10 @@ void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const throw( IO_ERROR
if( parent ) if( parent )
orient += parent->GetOrientation(); orient += parent->GetOrientation();
m_out->Print( aNestLevel, "(fp_text %s %s (at %s", m_out->Quotew( type ).c_str(), m_out->Print( aNestLevel, "(fp_text %s %s (at %s",
m_out->Quotew( aText->GetText() ).c_str(), m_out->Quotew( type ).c_str(),
FMT_IU( aText->GetPos0() ).c_str() ); m_out->Quotew( aText->GetText() ).c_str(),
FMT_IU( aText->GetPos0() ).c_str() );
if( orient != 0.0 ) if( orient != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( orient ).c_str() ); m_out->Print( 0, " %s", FMT_ANGLE( orient ).c_str() );
...@@ -1348,23 +1351,25 @@ void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const throw( IO_ERROR ...@@ -1348,23 +1351,25 @@ void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const throw( IO_ERROR
m_out->Print( aNestLevel, ")\n" ); m_out->Print( aNestLevel, ")\n" );
} }
void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const
throw( IO_ERROR )
{ {
if( aTrack->Type() == PCB_VIA_T ) if( aTrack->Type() == PCB_VIA_T )
{ {
LAYER_NUM layer1, layer2; LAYER_NUM layer1, layer2;
const VIA* via = static_cast<const VIA*>( aTrack ); const VIA* via = static_cast<const VIA*>(aTrack);
BOARD* board = (BOARD*) via->GetParent(); BOARD* board = (BOARD*) via->GetParent();
wxCHECK_RET( board != 0, wxCHECK_RET( board != 0, wxT( "Via " ) + via->GetSelectMenuText() +
wxT( "Via " ) + via->GetSelectMenuText() + wxT( " has no parent." ) ); wxT( " has no parent." ) );
m_out->Print( aNestLevel, "(via" ); m_out->Print( aNestLevel, "(via" );
via->LayerPair( &layer1, &layer2 ); via->LayerPair( &layer1, &layer2 );
switch (via->GetViaType()) switch( via->GetViaType() )
{ {
case VIA_THROUGH: // Default shape not saved. case VIA_THROUGH: // Default shape not saved.
break; break;
...@@ -1378,24 +1383,25 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1378,24 +1383,25 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const throw( IO_ERROR )
break; break;
default: default:
THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), via->GetViaType() ) ); THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), via->GetViaType() ) );
} }
m_out->Print( 0, " (at %s) (size %s)", m_out->Print( 0, " (at %s) (size %s)",
FMT_IU( aTrack->GetStart() ).c_str(), FMT_IU( aTrack->GetStart() ).c_str(),
FMT_IU( aTrack->GetWidth() ).c_str() ); FMT_IU( aTrack->GetWidth() ).c_str() );
if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER ) if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER )
m_out->Print( 0, " (drill %s)", FMT_IU( via->GetDrill() ).c_str() ); m_out->Print( 0, " (drill %s)", FMT_IU( via->GetDrill() ).c_str() );
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 }
else
{ {
m_out->Print( aNestLevel, "(segment (start %s) (end %s) (width %s)", m_out->Print( aNestLevel, "(segment (start %s) (end %s) (width %s)",
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() );
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() );
} }
...@@ -1403,22 +1409,24 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const throw( IO_ERROR ) ...@@ -1403,22 +1409,24 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const throw( IO_ERROR )
m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) ); m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
if( aTrack->GetTimeStamp() != 0 ) if( aTrack->GetTimeStamp() != 0 )
m_out->Print( 0, " (tstamp %lX)", aTrack->GetTimeStamp() ); m_out->Print( 0, " (tstamp %lX)", aTrack->GetTimeStamp() );
if( aTrack->GetStatus() != 0 ) if( aTrack->GetStatus() != 0 )
m_out->Print( 0, " (status %X)", aTrack->GetStatus() ); m_out->Print( 0, " (status %X)", aTrack->GetStatus() );
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERROR )
void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
throw( IO_ERROR )
{ {
// Save the NET info; For keepout zones, net code and net name are irrelevant // Save the NET info; For keepout zones, net code and net name are irrelevant
// so be sure a dummy value is stored, just for ZONE_CONTAINER compatibility // so be sure a dummy value is stored, just for ZONE_CONTAINER compatibility
// (perhaps netcode and netname should be not stored) // (perhaps netcode and netname should be not stored)
m_out->Print( aNestLevel, "(zone (net %d) (net_name %s)", m_out->Print( aNestLevel, "(zone (net %d) (net_name %s)",
aZone->GetIsKeepout() ? 0 : m_mapping->Translate( aZone->GetNetCode() ), aZone->GetIsKeepout() ? 0 : m_mapping->Translate( aZone->GetNetCode() ),
m_out->Quotew( aZone->GetIsKeepout() ? wxT( "" ) : aZone->GetNetname() ).c_str() ); m_out->Quotew( aZone->GetIsKeepout() ? wxT("") : aZone->GetNetname() ).c_str() );
formatLayer( aZone ); formatLayer( aZone );
...@@ -1427,29 +1435,23 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR ...@@ -1427,29 +1435,23 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR
// Save the outline aux info // Save the outline aux info
std::string hatch; std::string hatch;
switch (aZone->GetHatchStyle()) switch( aZone->GetHatchStyle() )
{ {
default: default:
case CPolyLine::NO_HATCH: case CPolyLine::NO_HATCH: hatch = "none"; break;
hatch = "none"; case CPolyLine::DIAGONAL_EDGE: hatch = "edge"; break;
break; case CPolyLine::DIAGONAL_FULL: hatch = "full"; break;
case CPolyLine::DIAGONAL_EDGE:
hatch = "edge";
break;
case CPolyLine::DIAGONAL_FULL:
hatch = "full";
break;
} }
m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(), m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(),
FMT_IU( aZone->Outline()->GetHatchPitch() ).c_str() ); FMT_IU( aZone->Outline()->GetHatchPitch() ).c_str() );
if( aZone->GetPriority() > 0 ) if( aZone->GetPriority() > 0 )
m_out->Print( aNestLevel + 1, "(priority %d)\n", aZone->GetPriority() ); m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetPriority() );
m_out->Print( aNestLevel + 1, "(connect_pads" ); m_out->Print( aNestLevel+1, "(connect_pads" );
switch (aZone->GetPadConnection()) switch( aZone->GetPadConnection() )
{ {
default: default:
case THERMAL_PAD: // Default option not saved or loaded. case THERMAL_PAD: // Default option not saved or loaded.
...@@ -1469,20 +1471,20 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR ...@@ -1469,20 +1471,20 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR
} }
m_out->Print( 0, " (clearance %s))\n", m_out->Print( 0, " (clearance %s))\n",
FMT_IU( aZone->GetZoneClearance() ).c_str() ); FMT_IU( aZone->GetZoneClearance() ).c_str() );
m_out->Print( aNestLevel + 1, "(min_thickness %s)\n", m_out->Print( aNestLevel+1, "(min_thickness %s)\n",
FMT_IU( aZone->GetMinThickness() ).c_str() ); FMT_IU( aZone->GetMinThickness() ).c_str() );
if( aZone->GetIsKeepout() ) if( aZone->GetIsKeepout() )
{ {
m_out->Print( aNestLevel + 1, "(keepout (tracks %s) (vias %s) (copperpour %s))\n", m_out->Print( aNestLevel+1, "(keepout (tracks %s) (vias %s) (copperpour %s))\n",
aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed", aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed", aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed" ); aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed" );
} }
m_out->Print( aNestLevel + 1, "(fill" ); m_out->Print( aNestLevel+1, "(fill" );
// Default is not filled. // Default is not filled.
if( aZone->IsFilled() ) if( aZone->IsFilled() )
...@@ -1493,35 +1495,34 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR ...@@ -1493,35 +1495,34 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR
m_out->Print( 0, " (mode segment)" ); m_out->Print( 0, " (mode segment)" );
m_out->Print( 0, " (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)", m_out->Print( 0, " (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)",
aZone->GetArcSegmentCount(), aZone->GetArcSegmentCount(),
FMT_IU( aZone->GetThermalReliefGap() ).c_str(), FMT_IU( aZone->GetThermalReliefGap() ).c_str(),
FMT_IU( aZone->GetThermalReliefCopperBridge() ).c_str() ); FMT_IU( aZone->GetThermalReliefCopperBridge() ).c_str() );
if( aZone->GetCornerSmoothingType() != ZONE_SETTINGS::SMOOTHING_NONE ) if( aZone->GetCornerSmoothingType() != ZONE_SETTINGS::SMOOTHING_NONE )
{ {
m_out->Print( 0, " (smoothing" ); m_out->Print( 0, " (smoothing" );
switch (aZone->GetCornerSmoothingType()) switch( aZone->GetCornerSmoothingType() )
{ {
case ZONE_SETTINGS::SMOOTHING_CHAMFER: case ZONE_SETTINGS::SMOOTHING_CHAMFER:
m_out->Print( 0, " chamfer" ); m_out->Print( 0, " chamfer" );
break; break;
case ZONE_SETTINGS::SMOOTHING_FILLET: case ZONE_SETTINGS::SMOOTHING_FILLET:
m_out->Print( 0, " fillet" ); m_out->Print( 0, " fillet" );
break; break;
default: default:
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
wxString::Format( _( "unknown zone corner smoothing type %d" ), aZone->GetCornerSmoothingType() ) );
aZone->GetCornerSmoothingType() ) );
} }
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
if( aZone->GetCornerRadius() != 0 ) if( aZone->GetCornerRadius() != 0 )
m_out->Print( 0, " (radius %s)", m_out->Print( 0, " (radius %s)",
FMT_IU( aZone->GetCornerRadius() ).c_str() ); FMT_IU( aZone->GetCornerRadius() ).c_str() );
} }
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
...@@ -1530,46 +1531,46 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR ...@@ -1530,46 +1531,46 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR
if( cv.GetCornersCount() ) if( cv.GetCornersCount() )
{ {
m_out->Print( aNestLevel + 1, "(polygon\n" ); m_out->Print( aNestLevel+1, "(polygon\n");
m_out->Print( aNestLevel + 2, "(pts\n" ); m_out->Print( aNestLevel+2, "(pts\n" );
for( unsigned it = 0; it < cv.GetCornersCount(); ++it ) for( unsigned it = 0; it < cv.GetCornersCount(); ++it )
{ {
if( newLine == 0 ) if( newLine == 0 )
m_out->Print( aNestLevel + 3, "(xy %s %s)", m_out->Print( aNestLevel+3, "(xy %s %s)",
FMT_IU( cv.GetX( it ) ).c_str(), FMT_IU( cv.GetY( it ) ).c_str() ); FMT_IU( cv.GetX( it ) ).c_str(), FMT_IU( cv.GetY( it ) ).c_str() );
else else
m_out->Print( 0, " (xy %s %s)", m_out->Print( 0, " (xy %s %s)",
FMT_IU( cv.GetX( it ) ).c_str(), FMT_IU( cv.GetY( it ) ).c_str() ); FMT_IU( cv.GetX( it ) ).c_str(), FMT_IU( cv.GetY( it ) ).c_str() );
if( newLine < 4 ) if( newLine < 4 )
{ {
newLine += 1; newLine += 1;
} }
else else
{ {
newLine = 0; newLine = 0;
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
} }
if( cv.IsEndContour( it ) ) if( cv.IsEndContour( it ) )
{ {
if( newLine != 0 ) if( newLine != 0 )
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
m_out->Print( aNestLevel+2, ")\n" ); m_out->Print( aNestLevel+2, ")\n" );
if( it+1 != cv.GetCornersCount() ) if( it+1 != cv.GetCornersCount() )
{ {
newLine = 0; newLine = 0;
m_out->Print( aNestLevel+1, ")\n" ); m_out->Print( aNestLevel+1, ")\n" );
m_out->Print( aNestLevel+1, "(polygon\n" ); m_out->Print( aNestLevel+1, "(polygon\n" );
m_out->Print( aNestLevel+2, "(pts" ); m_out->Print( aNestLevel+2, "(pts" );
}
} }
} }
}
m_out->Print( aNestLevel + 1, ")\n" ); m_out->Print( aNestLevel+1, ")\n" );
} }
// Save the PolysList // Save the PolysList
...@@ -1578,76 +1579,80 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR ...@@ -1578,76 +1579,80 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const throw( IO_ERR
if( fv.GetCornersCount() ) if( fv.GetCornersCount() )
{ {
m_out->Print( aNestLevel + 1, "(filled_polygon\n" ); m_out->Print( aNestLevel+1, "(filled_polygon\n" );
m_out->Print( aNestLevel + 2, "(pts\n" ); m_out->Print( aNestLevel+2, "(pts\n" );
for( unsigned it = 0; it < fv.GetCornersCount(); ++it ) for( unsigned it = 0; it < fv.GetCornersCount(); ++it )
{ {
if( newLine == 0 ) if( newLine == 0 )
m_out->Print( aNestLevel + 3, "(xy %s %s)", m_out->Print( aNestLevel+3, "(xy %s %s)",
FMT_IU( fv.GetX( it ) ).c_str(), FMT_IU( fv.GetY( it ) ).c_str() ); FMT_IU( fv.GetX( it ) ).c_str(), FMT_IU( fv.GetY( it ) ).c_str() );
else else
m_out->Print( 0, " (xy %s %s)", m_out->Print( 0, " (xy %s %s)",
FMT_IU( fv.GetX( it ) ).c_str(), FMT_IU( fv.GetY( it ) ).c_str() ); FMT_IU( fv.GetX( it ) ).c_str(), FMT_IU( fv.GetY( it ) ).c_str() );
if( newLine < 4 ) if( newLine < 4 )
{ {
newLine += 1; newLine += 1;
} }
else else
{ {
newLine = 0; newLine = 0;
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
} }
if( fv.IsEndContour( it ) ) if( fv.IsEndContour( it ) )
{ {
if( newLine != 0 ) if( newLine != 0 )
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
m_out->Print( aNestLevel+2, ")\n" ); m_out->Print( aNestLevel+2, ")\n" );
if( it+1 != fv.GetCornersCount() ) if( it+1 != fv.GetCornersCount() )
{ {
newLine = 0; newLine = 0;
m_out->Print( aNestLevel+1, ")\n" ); m_out->Print( aNestLevel+1, ")\n" );
m_out->Print( aNestLevel+1, "(filled_polygon\n" ); m_out->Print( aNestLevel+1, "(filled_polygon\n" );
m_out->Print( aNestLevel+2, "(pts\n" ); m_out->Print( aNestLevel+2, "(pts\n" );
}
} }
} }
}
m_out->Print( aNestLevel + 1, ")\n" ); m_out->Print( aNestLevel+1, ")\n" );
} }
// Save the filling segments list // Save the filling segments list
const std::vector<SEGMENT>& segs = aZone->FillSegments(); const std::vector< SEGMENT >& segs = aZone->FillSegments();
if( segs.size() ) if( segs.size() )
{ {
m_out->Print( aNestLevel + 1, "(fill_segments\n" ); m_out->Print( aNestLevel+1, "(fill_segments\n" );
for( std::vector<SEGMENT>::const_iterator it = segs.begin(); it != segs.end(); ++it ) for( std::vector< SEGMENT >::const_iterator it = segs.begin(); it != segs.end(); ++it )
{ {
m_out->Print( aNestLevel + 2, "(pts (xy %s) (xy %s))\n", m_out->Print( aNestLevel+2, "(pts (xy %s) (xy %s))\n",
FMT_IU( it->m_Start ).c_str(), FMT_IU( it->m_Start ).c_str(),
FMT_IU( it->m_End ).c_str() ); FMT_IU( it->m_End ).c_str() );
} }
m_out->Print( aNestLevel + 1, ")\n" ); m_out->Print( aNestLevel+1, ")\n" );
} }
m_out->Print( aNestLevel, ")\n" ); m_out->Print( aNestLevel, ")\n" );
} }
PCB_IO::PCB_IO( int aControlFlags ) : PCB_IO::PCB_IO( int aControlFlags ) :
m_cache( 0 ), m_ctl( aControlFlags ), m_parser( new PCB_PARSER() ), m_cache( 0 ),
m_mapping( new NETINFO_MAPPING() ) m_ctl( aControlFlags ),
m_parser( new PCB_PARSER() ),
m_mapping( new NETINFO_MAPPING() )
{ {
init( 0 ); init( 0 );
m_out = &m_sf; m_out = &m_sf;
} }
PCB_IO::~PCB_IO() PCB_IO::~PCB_IO()
{ {
delete m_cache; delete m_cache;
...@@ -1655,9 +1660,10 @@ PCB_IO::~PCB_IO() ...@@ -1655,9 +1660,10 @@ PCB_IO::~PCB_IO()
delete m_mapping; delete m_mapping;
} }
BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties ) BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
{ {
FILE_LINE_READER reader( aFileName ); FILE_LINE_READER reader( aFileName );
init( aProperties ); init( aProperties );
...@@ -1674,12 +1680,14 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPER ...@@ -1674,12 +1680,14 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPER
return board; return board;
} }
void PCB_IO::init( const PROPERTIES* aProperties ) void PCB_IO::init( const PROPERTIES* aProperties )
{ {
m_board = NULL; m_board = NULL;
m_props = aProperties; m_props = aProperties;
} }
void PCB_IO::cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName ) void PCB_IO::cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName )
{ {
if( !m_cache || m_cache->IsModified( aLibraryPath, aFootprintName ) ) if( !m_cache || m_cache->IsModified( aLibraryPath, aFootprintName ) )
...@@ -1691,18 +1699,18 @@ void PCB_IO::cacheLib( const wxString& aLibraryPath, const wxString& aFootprintN ...@@ -1691,18 +1699,18 @@ void PCB_IO::cacheLib( const wxString& aLibraryPath, const wxString& aFootprintN
} }
} }
wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath,
wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath,
const PROPERTIES* aProperties ) const PROPERTIES* aProperties )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
wxArrayString ret; wxArrayString ret;
wxDir dir( aLibraryPath ); wxDir dir( aLibraryPath );
if( !dir.IsOpened() ) if( !dir.IsOpened() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "footprint library path '%s' does not exist" ),
wxString::Format( _( "footprint library path '%s' does not exist" ), GetChars( aLibraryPath ) ) );
GetChars( aLibraryPath ) ) );
} }
init( aProperties ); init( aProperties );
...@@ -1712,7 +1720,8 @@ wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath, ...@@ -1712,7 +1720,8 @@ wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath,
const MODULE_MAP& mods = m_cache->GetModules(); const MODULE_MAP& mods = m_cache->GetModules();
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
{ {
ret.Add( FROM_UTF8( it->first.c_str() ) ); ret.Add( FROM_UTF8( it->first.c_str() ) );
} }
...@@ -1726,17 +1735,18 @@ wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath, ...@@ -1726,17 +1735,18 @@ wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath,
{ {
wxFileName fn( aLibraryPath, fpFileName ); wxFileName fn( aLibraryPath, fpFileName );
ret.Add( fn.GetName() ); ret.Add( fn.GetName() );
}while( dir.GetNext( &fpFileName ) ); } while( dir.GetNext( &fpFileName ) );
} }
#endif #endif
return ret; return ret;
} }
MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
const PROPERTIES* aProperties ) const PROPERTIES* aProperties )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
init( aProperties ); init( aProperties );
...@@ -1755,10 +1765,11 @@ MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFo ...@@ -1755,10 +1765,11 @@ MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFo
return new MODULE( *it->second->GetModule() ); return new MODULE( *it->second->GetModule() );
} }
void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
const PROPERTIES* aProperties ) const PROPERTIES* aProperties )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
init( aProperties ); init( aProperties );
...@@ -1770,8 +1781,10 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri ...@@ -1770,8 +1781,10 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
if( !m_cache->IsWritable() ) if( !m_cache->IsWritable() )
{ {
wxString msg = wxString::Format( _( "Library '%s' is read only" ), wxString msg = wxString::Format(
GetChars( aLibraryPath ) ); _( "Library '%s' is read only" ),
GetChars( aLibraryPath )
);
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
...@@ -1781,21 +1794,18 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri ...@@ -1781,21 +1794,18 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
MODULE_MAP& mods = m_cache->GetModules(); MODULE_MAP& mods = m_cache->GetModules();
// Quietly overwrite module and delete module file from path for any by same name. // Quietly overwrite module and delete module file from path for any by same name.
wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetFootprintName(), wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetFootprintName(), KiCadFootprintFileExtension );
KiCadFootprintFileExtension );
if( !fn.IsOk() ) if( !fn.IsOk() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "Footprint file name '%s' is not valid." ),
wxString::Format( _( "Footprint file name '%s' is not valid." ), GetChars( fn.GetFullPath() ) ) );
GetChars( fn.GetFullPath() ) ) );
} }
if( fn.FileExists() && !fn.IsFileWritable() ) if( fn.FileExists() && !fn.IsFileWritable() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "user does not have write permission to delete file '%s' " ),
wxString::Format( _( "user does not have write permission to delete file '%s' " ), GetChars( fn.GetFullPath() ) ) );
GetChars( fn.GetFullPath() ) ) );
} }
MODULE_CITER it = mods.find( footprintName ); MODULE_CITER it = mods.find( footprintName );
...@@ -1803,7 +1813,7 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri ...@@ -1803,7 +1813,7 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
if( it != mods.end() ) if( it != mods.end() )
{ {
wxLogTrace( traceFootprintLibrary, wxT( "Removing footprint library file '%s'." ), wxLogTrace( traceFootprintLibrary, wxT( "Removing footprint library file '%s'." ),
fn.GetFullPath().GetData() ); fn.GetFullPath().GetData() );
mods.erase( footprintName ); mods.erase( footprintName );
wxRemoveFile( fn.GetFullPath() ); wxRemoveFile( fn.GetFullPath() );
} }
...@@ -1821,15 +1831,15 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri ...@@ -1821,15 +1831,15 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
module->Flip( module->GetPosition() ); module->Flip( module->GetPosition() );
wxLogTrace( traceFootprintLibrary, wxT( "Creating s-expression footprint file: %s." ), wxLogTrace( traceFootprintLibrary, wxT( "Creating s-expression footprint file: %s." ),
fn.GetFullPath().GetData() ); fn.GetFullPath().GetData() );
mods.insert( footprintName, new FP_CACHE_ITEM( module, fn ) ); mods.insert( footprintName, new FP_CACHE_ITEM( module, fn ) );
m_cache->Save(); m_cache->Save();
} }
void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
const PROPERTIES* aProperties ) void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
init( aProperties ); init( aProperties );
...@@ -1837,23 +1847,23 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo ...@@ -1837,23 +1847,23 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo
if( !m_cache->IsWritable() ) if( !m_cache->IsWritable() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ),
wxString::Format( _( "Library '%s' is read only" ), aLibraryPath.GetData() ) ); aLibraryPath.GetData() ) );
} }
m_cache->Remove( aFootprintName ); m_cache->Remove( aFootprintName );
} }
void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties ) void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{ {
if( wxDir::Exists( aLibraryPath ) ) if( wxDir::Exists( aLibraryPath ) )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "cannot overwrite library path '%s'" ),
wxString::Format( _( "cannot overwrite library path '%s'" ), aLibraryPath.GetData() ) );
aLibraryPath.GetData() ) );
} }
LOCALE_IO toggle; LOCALE_IO toggle;
init( aProperties ); init( aProperties );
...@@ -1862,6 +1872,7 @@ void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* ...@@ -1862,6 +1872,7 @@ void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES*
m_cache->Save(); m_cache->Save();
} }
bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties ) bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{ {
wxFileName fn; wxFileName fn;
...@@ -1873,58 +1884,53 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* ...@@ -1873,58 +1884,53 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES*
if( !fn.IsDirWritable() ) if( !fn.IsDirWritable() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "user does not have permission to delete directory '%s'" ),
wxString::Format( _( "user does not have permission to delete directory '%s'" ), aLibraryPath.GetData() ) );
aLibraryPath.GetData() ) );
} }
wxDir dir( aLibraryPath ); wxDir dir( aLibraryPath );
if( dir.HasSubDirs() ) if( dir.HasSubDirs() )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "library directory '%s' has unexpected sub-directories" ),
wxString::Format( _( "library directory '%s' has unexpected sub-directories" ), aLibraryPath.GetData() ) );
aLibraryPath.GetData() ) );
} }
// All the footprint files must be deleted before the directory can be deleted. // All the footprint files must be deleted before the directory can be deleted.
if( dir.HasFiles() ) if( dir.HasFiles() )
{ {
unsigned i; unsigned i;
wxFileName tmp; wxFileName tmp;
wxArrayString files; wxArrayString files;
wxDir::GetAllFiles( aLibraryPath, &files ); wxDir::GetAllFiles( aLibraryPath, &files );
for( i = 0; i < files.GetCount(); i++ ) for( i = 0; i < files.GetCount(); i++ )
{ {
tmp = files[i]; tmp = files[i];
if( tmp.GetExt() != KiCadFootprintFileExtension ) if( tmp.GetExt() != KiCadFootprintFileExtension )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "unexpected file '%s' was found in library path '%s'" ),
wxString::Format( files[i].GetData(), aLibraryPath.GetData() ) );
_( "unexpected file '%s' was found in library path '%s'" ),
files[i].GetData(), aLibraryPath.GetData() ) );
} }
} }
for( i = 0; i < files.GetCount(); i++ ) for( i = 0; i < files.GetCount(); i++ )
{ {
wxRemoveFile( files[i] ); wxRemoveFile( files[i] );
} }
} }
wxLogTrace( traceFootprintLibrary, wxT( "Removing footprint library '%s'" ), wxLogTrace( traceFootprintLibrary, wxT( "Removing footprint library '%s'" ),
aLibraryPath.GetData() ); aLibraryPath.GetData() );
// Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
// we don't want that. we want bare metal portability with no UI here. // we don't want that. we want bare metal portability with no UI here.
if( !wxRmdir( aLibraryPath ) ) if( !wxRmdir( aLibraryPath ) )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( wxString::Format( _( "footprint library '%s' cannot be deleted" ),
wxString::Format( _( "footprint library '%s' cannot be deleted" ), aLibraryPath.GetData() ) );
aLibraryPath.GetData() ) );
} }
// For some reason removing a directory in Windows is not immediately updated. This delay // For some reason removing a directory in Windows is not immediately updated. This delay
...@@ -1943,9 +1949,10 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* ...@@ -1943,9 +1949,10 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES*
return true; return true;
} }
bool PCB_IO::IsFootprintLibWritable( const wxString& aLibraryPath ) bool PCB_IO::IsFootprintLibWritable( const wxString& aLibraryPath )
{ {
LOCALE_IO toggle; LOCALE_IO toggle;
init( NULL ); init( NULL );
......
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