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 ) );
|
||||
|
||||
NeedSYMBOL();
|
||||
// Read netclass name (can be a name or just a number like track width)
|
||||
NeedSYMBOLorNUMBER();
|
||||
nc->SetName( FromUTF8() );
|
||||
NeedSYMBOL();
|
||||
nc->SetDescription( FromUTF8() );
|
||||
|
|
|
@ -778,18 +778,18 @@ void PCB_EDIT_FRAME::UpdateTitle()
|
|||
wxString title;
|
||||
wxFileName fileName = GetBoard()->GetFileName();
|
||||
|
||||
title.Printf( wxT( "Pcbnew %s " ), GetChars( GetBuildVersion() ) );
|
||||
|
||||
if( fileName.IsOk() && fileName.FileExists() )
|
||||
{
|
||||
title.Printf( wxT( "Pcbnew %s %s" ), GetChars( GetBuildVersion() ),
|
||||
GetChars( fileName.GetFullPath() ) );
|
||||
title << fileName.GetFullPath();
|
||||
|
||||
if( !fileName.IsFileWritable() )
|
||||
title += _( " [Read Only]" );
|
||||
title << _( " [Read Only]" );
|
||||
}
|
||||
else
|
||||
{
|
||||
title.Printf( wxT( "Pcbnew %s " ), GetChars( GetBuildVersion() ) );
|
||||
title << _( " [no file]" );
|
||||
title << _( " [new file]" ) << wxT(" ") << fileName.GetFullPath();
|
||||
}
|
||||
|
||||
SetTitle( title );
|
||||
|
|
|
@ -132,7 +132,8 @@ bool EDA_APP::OnInit()
|
|||
if( fn.GetExt() != PcbFileExtension )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -173,12 +174,48 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
|
|||
{
|
||||
/* Note the first time Pcbnew is called after creating a new project
|
||||
* 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() )
|
||||
{
|
||||
file_exists = true;
|
||||
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
|
||||
wxSetWorkingDirectory( fn.GetPath() );
|
||||
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
|
||||
|
|
Loading…
Reference in New Issue