Switch over to *.kicad_pcb format as the default BOARD format.
Add KiCadPcbFileExt global.
This commit is contained in:
parent
312254bc8a
commit
79b4846200
|
@ -44,7 +44,10 @@ const wxString NetlistFileExtension( wxT( "net" ) );
|
||||||
const wxString LegacyFootprintLibPathExtension( wxT( "mod" ) );
|
const wxString LegacyFootprintLibPathExtension( wxT( "mod" ) );
|
||||||
const wxString ComponentFileExtension( wxT( "cmp" ) );
|
const wxString ComponentFileExtension( wxT( "cmp" ) );
|
||||||
const wxString GerberFileExtension( wxT( "pho" ) );
|
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 PdfFileExtension( wxT( "pdf" ) );
|
||||||
const wxString MacrosFileExtension( wxT( "mcr" ) );
|
const wxString MacrosFileExtension( wxT( "mcr" ) );
|
||||||
const wxString DrillFileExtension( wxT( "drl" ) );
|
const wxString DrillFileExtension( wxT( "drl" ) );
|
||||||
|
|
|
@ -1666,19 +1666,21 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
|
||||||
throw( IO_ERROR )
|
throw( IO_ERROR )
|
||||||
{
|
{
|
||||||
// Don't write the title block information if there is nothing to write.
|
// 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_company.IsEmpty() || !m_comment1.IsEmpty() || !m_comment2.IsEmpty()
|
||||||
|| !m_comment3.IsEmpty() || !m_comment4.IsEmpty() )
|
|| !m_comment3.IsEmpty() || !m_comment4.IsEmpty() )
|
||||||
{
|
{
|
||||||
aFormatter->Print( aNestLevel, "(title_block\n" );
|
aFormatter->Print( aNestLevel, "(title_block " );
|
||||||
|
|
||||||
if( !m_title.IsEmpty() )
|
if( !m_title.IsEmpty() )
|
||||||
aFormatter->Print( aNestLevel+1, "(title %s)\n",
|
aFormatter->Print( aNestLevel+1, "(title %s)\n",
|
||||||
aFormatter->Quotew( m_title ).c_str() );
|
aFormatter->Quotew( m_title ).c_str() );
|
||||||
|
|
||||||
|
/* version control users were complaining, see mailing list.
|
||||||
if( !m_date.IsEmpty() )
|
if( !m_date.IsEmpty() )
|
||||||
aFormatter->Print( aNestLevel+1, "(date %s)\n",
|
aFormatter->Print( aNestLevel+1, "(date %s)\n",
|
||||||
aFormatter->Quotew( m_date ).c_str() );
|
aFormatter->Quotew( m_date ).c_str() );
|
||||||
|
*/
|
||||||
|
|
||||||
if( !m_revision.IsEmpty() )
|
if( !m_revision.IsEmpty() )
|
||||||
aFormatter->Print( aNestLevel+1, "(rev %s)\n",
|
aFormatter->Print( aNestLevel+1, "(rev %s)\n",
|
||||||
|
|
|
@ -51,7 +51,11 @@ extern const wxString ProjectFileExtension;
|
||||||
extern const wxString SchematicFileExtension;
|
extern const wxString SchematicFileExtension;
|
||||||
extern const wxString NetlistFileExtension;
|
extern const wxString NetlistFileExtension;
|
||||||
extern const wxString GerberFileExtension;
|
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 LegacyFootprintLibPathExtension;
|
||||||
extern const wxString PdfFileExtension;
|
extern const wxString PdfFileExtension;
|
||||||
extern const wxString MacrosFileExtension;
|
extern const wxString MacrosFileExtension;
|
||||||
|
|
|
@ -199,10 +199,16 @@ void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxFileName fn( m_ProjectFileName );
|
wxFileName legacy_board( m_ProjectFileName );
|
||||||
|
wxFileName kicad_board( m_ProjectFileName );
|
||||||
|
|
||||||
fn.SetExt( PcbFileExtension );
|
legacy_board.SetExt( LegacyPcbFileExtension );
|
||||||
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) );
|
kicad_board.SetExt( KiCadPcbFileExtension );
|
||||||
|
|
||||||
|
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 <wx/imaglist.h>
|
||||||
#include <menus_helpers.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:
|
/* Note about the tree project build process:
|
||||||
* Building the tree project can be *very* long if there are a lot of subdirectories
|
* 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;
|
break;
|
||||||
|
|
||||||
case TREE_LEGACY_PCB:
|
case TREE_LEGACY_PCB:
|
||||||
ext = PcbFileExtension;
|
ext = LegacyPcbFileExtension;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_SEXP_PCB:
|
case TREE_SEXP_PCB:
|
||||||
ext = PcbSexpFileExtension;
|
ext = KiCadPcbFileExtension;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_GERBER:
|
case TREE_GERBER:
|
||||||
|
|
|
@ -188,8 +188,8 @@ the changes?" ) ) )
|
||||||
IO_MGR::PCB_FILE_T pluginType;
|
IO_MGR::PCB_FILE_T pluginType;
|
||||||
} loaders[] =
|
} loaders[] =
|
||||||
{
|
{
|
||||||
{ LegacyPcbFileWildcard, IO_MGR::LEGACY },
|
|
||||||
{ PcbFileWildcard, IO_MGR::KICAD },
|
{ PcbFileWildcard, IO_MGR::KICAD },
|
||||||
|
{ LegacyPcbFileWildcard, IO_MGR::LEGACY },
|
||||||
{ EaglePcbFileWildcard, IO_MGR::EAGLE },
|
{ EaglePcbFileWildcard, IO_MGR::EAGLE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -405,31 +405,41 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
wxString upperTxt;
|
wxString upperTxt;
|
||||||
wxString lowerTxt;
|
wxString lowerTxt;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
wxString wildcard;
|
|
||||||
|
|
||||||
int wildcardIndex = 0;
|
|
||||||
bool saveok = true;
|
bool saveok = true;
|
||||||
|
|
||||||
wildcard << wxGetTranslation( LegacyPcbFileWildcard ) << wxChar( '|' ) <<
|
IO_MGR::PCB_FILE_T pluginType;
|
||||||
wxGetTranslation( PcbFileWildcard );
|
|
||||||
|
|
||||||
if( aFileName == wxEmptyString )
|
if( aFileName == wxEmptyString )
|
||||||
{
|
{
|
||||||
|
wxString wildcard;
|
||||||
|
wildcard << wxGetTranslation( PcbFileWildcard ) << wxChar( '|' ) <<
|
||||||
|
wxGetTranslation( LegacyPcbFileWildcard );
|
||||||
|
|
||||||
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetBoard()->GetFileName(),
|
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetBoard()->GetFileName(),
|
||||||
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GetBoard()->SetFileName( dlg.GetPath() );
|
pluginType = ( dlg.GetFilterIndex() == 1 ) ? IO_MGR::LEGACY : IO_MGR::KICAD;
|
||||||
wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format.
|
|
||||||
|
pcbFileName = dlg.GetPath();
|
||||||
|
|
||||||
|
// enforce file extension, must match plugin's policy.
|
||||||
|
pcbFileName.SetExt( IO_MGR::GetFileExtension( pluginType ) );
|
||||||
}
|
}
|
||||||
else
|
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 changes are made, update the board date
|
||||||
if( GetScreen()->IsModify() )
|
if( GetScreen()->IsModify() )
|
||||||
|
@ -440,11 +450,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
SetTitleBlock( tb );
|
SetTitleBlock( tb );
|
||||||
}
|
}
|
||||||
|
|
||||||
pcbFileName = GetBoard()->GetFileName();
|
|
||||||
|
|
||||||
if( pcbFileName.GetExt().IsEmpty() )
|
|
||||||
pcbFileName.SetExt( IO_MGR::GetFileExtension( pluginType ) );
|
|
||||||
|
|
||||||
if( !IsWritable( pcbFileName ) )
|
if( !IsWritable( pcbFileName ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -462,7 +467,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
if( backupFileName.FileExists() )
|
if( backupFileName.FileExists() )
|
||||||
wxRemoveFile( backupFileName.GetFullPath() );
|
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() ) )
|
if( !wxRenameFile( pcbFileName.GetFullPath(), backupFileName.GetFullPath() ) )
|
||||||
{
|
{
|
||||||
msg = _( "Warning: unable to create backup file " ) + 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() ) ) );
|
GetChars( pcbFileName.GetExt() ) ) );
|
||||||
|
|
||||||
wxString header = wxString::Format(
|
wxString header = wxString::Format(
|
||||||
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s\n\n" ),
|
wxT( "PCBNEW-BOARD Version %d\n# Created by Pcbnew%s\n\n" ),
|
||||||
LEGACY_BOARD_FILE_VERSION, DateAndTime().GetData(),
|
LEGACY_BOARD_FILE_VERSION,
|
||||||
GetBuildVersion().GetData() );
|
GetBuildVersion().GetData() );
|
||||||
|
|
||||||
props["header"] = header;
|
props["header"] = header;
|
||||||
|
@ -515,6 +520,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
{
|
{
|
||||||
GetBoard()->SetFileName( pcbFileName.GetFullPath() );
|
GetBoard()->SetFileName( pcbFileName.GetFullPath() );
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
|
UpdateFileHistory( GetBoard()->GetFileName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the file names:
|
// 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.
|
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.
|
||||||
auto_ptr< MODULE > m_module;
|
auto_ptr< MODULE > m_module;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName );
|
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() )
|
for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
|
||||||
Format( item, aNestLevel );
|
Format( item, aNestLevel );
|
||||||
|
|
||||||
m_out->Print( 0, "\n" );
|
if( aBoard->m_Drawings.GetCount() )
|
||||||
m_out->Print( 0, "\n" );
|
m_out->Print( 0, "\n" );
|
||||||
|
|
||||||
// Do not save MARKER_PCBs, they can be regenerated easily.
|
// 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() )
|
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
|
||||||
Format( track, aNestLevel );
|
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
|
/// @todo Add warning here that the old segment filed zones are no longer supported and
|
||||||
/// will not be saved.
|
/// will not be saved.
|
||||||
|
|
||||||
m_out->Print( 0, "\n" );
|
|
||||||
|
|
||||||
// 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 );
|
||||||
|
|
|
@ -73,6 +73,10 @@ public:
|
||||||
|
|
||||||
const wxString& GetFileExtension() const
|
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" );
|
static const wxString extension = wxT( "kicad_pcb" );
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue