Pcbnew: add a dialog to load a legacy file in "old" projects, when the .kicad_pcb file is not existing, and the correspoinding .brd file exists.
Fix also an issue in pcb_parser when a netclass name is just a number (like a track width as name)
This commit is contained in:
parent
4b14415596
commit
3c315005ee
|
@ -1064,7 +1064,8 @@ void PCB_PARSER::parseNETCLASS() throw( IO_ERROR, PARSE_ERROR )
|
||||||
|
|
||||||
auto_ptr<NETCLASS> nc( new NETCLASS( m_board, wxEmptyString ) );
|
auto_ptr<NETCLASS> nc( new NETCLASS( m_board, wxEmptyString ) );
|
||||||
|
|
||||||
NeedSYMBOL();
|
// Read netclass name (can be a name or just a number like track width)
|
||||||
|
NeedSYMBOLorNUMBER();
|
||||||
nc->SetName( FromUTF8() );
|
nc->SetName( FromUTF8() );
|
||||||
NeedSYMBOL();
|
NeedSYMBOL();
|
||||||
nc->SetDescription( FromUTF8() );
|
nc->SetDescription( FromUTF8() );
|
||||||
|
|
|
@ -778,18 +778,18 @@ void PCB_EDIT_FRAME::UpdateTitle()
|
||||||
wxString title;
|
wxString title;
|
||||||
wxFileName fileName = GetBoard()->GetFileName();
|
wxFileName fileName = GetBoard()->GetFileName();
|
||||||
|
|
||||||
|
title.Printf( wxT( "Pcbnew %s " ), GetChars( GetBuildVersion() ) );
|
||||||
|
|
||||||
if( fileName.IsOk() && fileName.FileExists() )
|
if( fileName.IsOk() && fileName.FileExists() )
|
||||||
{
|
{
|
||||||
title.Printf( wxT( "Pcbnew %s %s" ), GetChars( GetBuildVersion() ),
|
title << fileName.GetFullPath();
|
||||||
GetChars( fileName.GetFullPath() ) );
|
|
||||||
|
|
||||||
if( !fileName.IsFileWritable() )
|
if( !fileName.IsFileWritable() )
|
||||||
title += _( " [Read Only]" );
|
title << _( " [Read Only]" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
title.Printf( wxT( "Pcbnew %s " ), GetChars( GetBuildVersion() ) );
|
title << _( " [new file]" ) << wxT(" ") << fileName.GetFullPath();
|
||||||
title << _( " [no file]" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetTitle( title );
|
SetTitle( title );
|
||||||
|
|
|
@ -132,7 +132,8 @@ bool EDA_APP::OnInit()
|
||||||
if( fn.GetExt() != PcbFileExtension )
|
if( fn.GetExt() != PcbFileExtension )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Pcbnew file <%s> has the wrong extension. \
|
wxLogDebug( wxT( "Pcbnew file <%s> has the wrong extension. \
|
||||||
Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
|
Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
|
||||||
|
GetChars( PcbFileExtension ) );
|
||||||
fn.SetExt( PcbFileExtension );
|
fn.SetExt( PcbFileExtension );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,12 +174,48 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
|
||||||
{
|
{
|
||||||
/* Note the first time Pcbnew is called after creating a new project
|
/* Note the first time Pcbnew is called after creating a new project
|
||||||
* the board file may not exist so we load settings only.
|
* the board file may not exist so we load settings only.
|
||||||
|
* However, because legacy board files are named *.brd,
|
||||||
|
* and new files are named *.kicad_pcb,
|
||||||
|
* for all previous projects ( before 2012, december 14 ),
|
||||||
|
* becuse KiCad manager ask to load a .kicad_pcb file
|
||||||
|
* if this file does not exist, it is certainly useful
|
||||||
|
* to test if a legacy file is existing,
|
||||||
|
* under the same name, and therefore if the user want to load it
|
||||||
*/
|
*/
|
||||||
|
bool file_exists = false;
|
||||||
|
|
||||||
if( fn.FileExists() )
|
if( fn.FileExists() )
|
||||||
{
|
{
|
||||||
|
file_exists = true;
|
||||||
frame->LoadOnePcbFile( fn.GetFullPath() );
|
frame->LoadOnePcbFile( fn.GetFullPath() );
|
||||||
}
|
}
|
||||||
else
|
else if( fn.GetExt() == KiCadPcbFileExtension )
|
||||||
|
{
|
||||||
|
// Try to find a legacy file with the same name:
|
||||||
|
wxFileName fn_legacy = fn;
|
||||||
|
fn_legacy.SetExt( LegacyPcbFileExtension );
|
||||||
|
if( fn_legacy.FileExists() )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
msg.Printf( _( "File <%s> does not exist.\n"
|
||||||
|
"However a legacy file <%s> exists.\nDo you want to load it?\n"
|
||||||
|
"It will be saved under the new file format" ),
|
||||||
|
GetChars( fn.GetFullPath() ),
|
||||||
|
GetChars( fn_legacy.GetFullPath() ) );
|
||||||
|
if( IsOK( frame, msg ) )
|
||||||
|
{
|
||||||
|
file_exists = true;
|
||||||
|
frame->LoadOnePcbFile( fn_legacy.GetFullPath() );
|
||||||
|
wxString filename = fn.GetFullPath();
|
||||||
|
filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
||||||
|
frame->GetBoard()->SetFileName( filename );
|
||||||
|
frame->UpdateTitle();
|
||||||
|
frame->OnModify(); // Ready to save theboard inder the new fmt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! file_exists )
|
||||||
{ // File does not exists: prepare an empty board
|
{ // File does not exists: prepare an empty board
|
||||||
wxSetWorkingDirectory( fn.GetPath() );
|
wxSetWorkingDirectory( fn.GetPath() );
|
||||||
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
|
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
|
||||||
|
|
Loading…
Reference in New Issue