Commit 79b48462 authored by Dick Hollenbeck's avatar Dick Hollenbeck

Switch over to *.kicad_pcb format as the default BOARD format.

Add KiCadPcbFileExt global.
parent 312254bc
......@@ -44,7 +44,10 @@ const wxString NetlistFileExtension( wxT( "net" ) );
const wxString LegacyFootprintLibPathExtension( wxT( "mod" ) );
const wxString ComponentFileExtension( wxT( "cmp" ) );
const wxString GerberFileExtension( wxT( "pho" ) );
const wxString PcbFileExtension( wxT( "brd" ) );
const wxString LegacyPcbFileExtension( wxT( "brd" ) );
const wxString KiCadPcbFileExtension( wxT( "kicad_pcb" ) );
const wxString PdfFileExtension( wxT( "pdf" ) );
const wxString MacrosFileExtension( wxT( "mcr" ) );
const wxString DrillFileExtension( wxT( "drl" ) );
......
......@@ -1666,19 +1666,21 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
throw( IO_ERROR )
{
// Don't write the title block information if there is nothing to write.
if( !m_title.IsEmpty() || !m_date.IsEmpty() || !m_revision.IsEmpty()
if( !m_title.IsEmpty() || /* !m_date.IsEmpty() || */ !m_revision.IsEmpty()
|| !m_company.IsEmpty() || !m_comment1.IsEmpty() || !m_comment2.IsEmpty()
|| !m_comment3.IsEmpty() || !m_comment4.IsEmpty() )
{
aFormatter->Print( aNestLevel, "(title_block\n" );
aFormatter->Print( aNestLevel, "(title_block " );
if( !m_title.IsEmpty() )
aFormatter->Print( aNestLevel+1, "(title %s)\n",
aFormatter->Quotew( m_title ).c_str() );
/* version control users were complaining, see mailing list.
if( !m_date.IsEmpty() )
aFormatter->Print( aNestLevel+1, "(date %s)\n",
aFormatter->Quotew( m_date ).c_str() );
*/
if( !m_revision.IsEmpty() )
aFormatter->Print( aNestLevel+1, "(rev %s)\n",
......
......@@ -51,7 +51,11 @@ extern const wxString ProjectFileExtension;
extern const wxString SchematicFileExtension;
extern const wxString NetlistFileExtension;
extern const wxString GerberFileExtension;
extern const wxString PcbFileExtension;
extern const wxString LegacyPcbFileExtension;
extern const wxString KiCadPcbFileExtension;
#define PcbFileExtension KiCadPcbFileExtension // symlink choice
extern const wxString LegacyFootprintLibPathExtension;
extern const wxString PdfFileExtension;
extern const wxString MacrosFileExtension;
......
......@@ -199,10 +199,16 @@ void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
wxFileName legacy_board( m_ProjectFileName );
wxFileName kicad_board( m_ProjectFileName );
legacy_board.SetExt( LegacyPcbFileExtension );
kicad_board.SetExt( KiCadPcbFileExtension );
fn.SetExt( PcbFileExtension );
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) );
if( !legacy_board.FileExists() || kicad_board.FileExists() )
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( kicad_board ) );
else
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( legacy_board ) );
}
......
......@@ -45,8 +45,6 @@
#include <wx/imaglist.h>
#include <menus_helpers.h>
// TODO: use the wxString defined in wildcards_and_files_ext.h, when exists
const wxString PcbSexpFileExtension( wxT("kicad_brd") );
/* Note about the tree project build process:
* Building the tree project can be *very* long if there are a lot of subdirectories
......@@ -419,11 +417,11 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
break;
case TREE_LEGACY_PCB:
ext = PcbFileExtension;
ext = LegacyPcbFileExtension;
break;
case TREE_SEXP_PCB:
ext = PcbSexpFileExtension;
ext = KiCadPcbFileExtension;
break;
case TREE_GERBER:
......
......@@ -188,8 +188,8 @@ the changes?" ) ) )
IO_MGR::PCB_FILE_T pluginType;
} loaders[] =
{
{ LegacyPcbFileWildcard, IO_MGR::LEGACY },
{ PcbFileWildcard, IO_MGR::KICAD },
{ LegacyPcbFileWildcard, IO_MGR::LEGACY },
{ EaglePcbFileWildcard, IO_MGR::EAGLE },
};
......@@ -405,31 +405,41 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
wxString upperTxt;
wxString lowerTxt;
wxString msg;
wxString wildcard;
int wildcardIndex = 0;
bool saveok = true;
wildcard << wxGetTranslation( LegacyPcbFileWildcard ) << wxChar( '|' ) <<
wxGetTranslation( PcbFileWildcard );
IO_MGR::PCB_FILE_T pluginType;
if( aFileName == wxEmptyString )
{
wxString wildcard;
wildcard << wxGetTranslation( PcbFileWildcard ) << wxChar( '|' ) <<
wxGetTranslation( LegacyPcbFileWildcard );
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetBoard()->GetFileName(),
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() != wxID_OK )
return false;
GetBoard()->SetFileName( dlg.GetPath() );
wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format.
pluginType = ( dlg.GetFilterIndex() == 1 ) ? IO_MGR::LEGACY : IO_MGR::KICAD;
pcbFileName = dlg.GetPath();
// enforce file extension, must match plugin's policy.
pcbFileName.SetExt( IO_MGR::GetFileExtension( pluginType ) );
}
else
{
GetBoard()->SetFileName( aFileName );
}
pcbFileName = aFileName;
IO_MGR::PCB_FILE_T pluginType = ( wildcardIndex == 0 ) ? IO_MGR::LEGACY : IO_MGR::KICAD;
if( pcbFileName.GetExt() == LegacyPcbFileExtension )
pluginType = IO_MGR::LEGACY;
else
{
pluginType = IO_MGR::KICAD;
pcbFileName.SetExt( KiCadPcbFileExtension );
}
}
// If changes are made, update the board date
if( GetScreen()->IsModify() )
......@@ -440,11 +450,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
SetTitleBlock( tb );
}
pcbFileName = GetBoard()->GetFileName();
if( pcbFileName.GetExt().IsEmpty() )
pcbFileName.SetExt( IO_MGR::GetFileExtension( pluginType ) );
if( !IsWritable( pcbFileName ) )
return false;
......@@ -462,7 +467,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( backupFileName.FileExists() )
wxRemoveFile( backupFileName.GetFullPath() );
// Rename the "old" file" from xxx.brd to xxx.000
// Rename the "old" file" from xxx.kicad_pcb to xxx.000
if( !wxRenameFile( pcbFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
msg = _( "Warning: unable to create backup file " ) + backupFileName.GetFullPath();
......@@ -495,8 +500,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
GetChars( pcbFileName.GetExt() ) ) );
wxString header = wxString::Format(
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s\n\n" ),
LEGACY_BOARD_FILE_VERSION, DateAndTime().GetData(),
wxT( "PCBNEW-BOARD Version %d\n# Created by Pcbnew%s\n\n" ),
LEGACY_BOARD_FILE_VERSION,
GetBuildVersion().GetData() );
props["header"] = header;
......@@ -515,6 +520,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
{
GetBoard()->SetFileName( pcbFileName.GetFullPath() );
UpdateTitle();
UpdateFileHistory( GetBoard()->GetFileName() );
}
// Display the file names:
......
......@@ -77,7 +77,7 @@ class FP_CACHE_ITEM
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.
wxDateTime m_mod_time; ///< The last file modified time stamp.
auto_ptr< MODULE > m_module;
auto_ptr< MODULE > m_module;
public:
FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName );
......@@ -606,8 +606,8 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
Format( item, aNestLevel );
m_out->Print( 0, "\n" );
m_out->Print( 0, "\n" );
if( aBoard->m_Drawings.GetCount() )
m_out->Print( 0, "\n" );
// Do not save MARKER_PCBs, they can be regenerated easily.
......@@ -615,11 +615,12 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
Format( track, aNestLevel );
if( aBoard->m_Track.GetCount() )
m_out->Print( 0, "\n" );
/// @todo Add warning here that the old segment filed zones are no longer supported and
/// will not be saved.
m_out->Print( 0, "\n" );
// Save the polygon (which are the newer technology) zones.
for( int i=0; i < aBoard->GetAreaCount(); ++i )
Format( aBoard->GetArea( i ), aNestLevel );
......
......@@ -73,6 +73,10 @@ public:
const wxString& GetFileExtension() const
{
// Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension,
// but to be pure, a plugin should not assume that it will always be linked
// with the core of the pcbnew code. (Might someday be a DLL/DSO.) Besides,
// file extension policy should be controlled by the plugin.
static const wxString extension = wxT( "kicad_pcb" );
return extension;
}
......
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