Deprecate saving legacy schematic and symbol library file formats.

REMOVED: The ability to save schematics in the legacy file format.
This commit is contained in:
Wayne Stambaugh 2020-05-15 09:25:11 -04:00
parent 39ec63c4e9
commit b624c7090a
17 changed files with 65 additions and 61 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2010 jean-pierre.charras
* Copyright (C) 1992-2019 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -799,7 +799,7 @@ void BM2CMP_FRAME::exportEeschemaFormat()
wxFileDialog fileDlg( this, _( "Create Symbol Library" ),
path, wxEmptyString,
SchematicLibraryFileWildcard(),
LegacySymbolLibFileWildcard(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = fileDlg.ShowModal();
@ -808,7 +808,7 @@ void BM2CMP_FRAME::exportEeschemaFormat()
return;
fn = fileDlg.GetPath();
fn.SetExt( SchematicLibraryFileExtension );
fn.SetExt( LegacySymbolLibFileExtension );
m_ConvertedFileName = fn.GetFullPath();
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );

View File

@ -116,7 +116,7 @@ wxString AddFileExtListToFilter( const std::vector<std::string>& aExts )
const std::string KiCadSymbolLibFileExtension( "kicad_sym" );
const std::string SchematicSymbolFileExtension( "sym" );
const std::string SchematicLibraryFileExtension( "lib" );
const std::string LegacySymbolLibFileExtension( "lib" );
const std::string VrmlFileExtension( "wrl" );
@ -180,7 +180,7 @@ wxString KiCadSymbolLibFileWildcard()
}
wxString SchematicLibraryFileWildcard()
wxString LegacySymbolLibFileWildcard()
{
return _( "KiCad legacy symbol library files" ) + AddFileExtListToFilter( { "lib" } );
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -489,7 +489,7 @@ const wxString PART_LIBS::CacheName( const wxString& aFullProjectFilename )
wxFileName name = aFullProjectFilename;
name.SetName( name.GetName() + "-cache" );
name.SetExt( SchematicLibraryFileExtension );
name.SetExt( LegacySymbolLibFileExtension );
if( name.FileExists() )
return name.GetFullPath();
@ -538,7 +538,7 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress )
// lib_names[] does not store the file extension. Set it.
// Remember lib_names[i] can contain a '.' in name, so using a wxFileName
// before adding the extension can create incorrect full filename
wxString fullname = lib_names[i] + "." + SchematicLibraryFileExtension;
wxString fullname = lib_names[i] + "." + LegacySymbolLibFileExtension;
// Now the full name is set, we can use a wxFileName.
wxFileName fn( fullname );

View File

@ -434,7 +434,7 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter )
// Back up the cache library.
srcFileName.SetPath( Prj().GetProjectPath() );
srcFileName.SetName( Prj().GetProjectName() + "-cache" );
srcFileName.SetExt( SchematicLibraryFileExtension );
srcFileName.SetExt( LegacySymbolLibFileExtension );
destFileName = srcFileName;
destFileName.SetName( destFileName.GetName() + timeStamp );

View File

@ -80,7 +80,7 @@ static const std::map<int, supportedFileType>& fileTypes()
{ ID_PANEL_SYM_LIB_LEGACY,
{
"KiCad legacy symbol library file (*.lib)",
SchematicSymbolFileWildcard(),
LegacySymbolLibFileWildcard(),
"",
true,
SCH_IO_MGR::SCH_LEGACY
@ -255,7 +255,7 @@ PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent,
attr = new wxGridCellAttr;
attr->SetEditor( new GRID_CELL_SYMLIB_EDITOR( m_parent, &m_lastBrowseDir,
SchematicLibraryFileWildcard() ) );
KiCadSymbolLibFileWildcard() ) );
g->SetColAttr( COL_URI, attr );
attr = new wxGridCellAttr;
@ -410,9 +410,9 @@ void PANEL_SYM_LIB_TABLE::pageChangedHandler( wxAuiNotebookEvent& event )
void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
{
wxString wildcards = SchematicLibraryFileWildcard();
wxString wildcards = KiCadSymbolLibFileWildcard();
wildcards += "|" + KiCadSymbolLibFileWildcard();
wildcards += "|" + LegacySymbolLibFileWildcard();
wxFileDialog dlg( this, _( "Select Library" ), m_lastBrowseDir,
wxEmptyString, wildcards,

View File

@ -83,8 +83,6 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName,
{
wxString wildcards = KiCadSchematicFileWildcard();
wildcards += "|" + LegacySchematicFileWildcard();
wxFileDialog dlg( this, _( "Schematic Files" ), wxPathOnly( Prj().GetProjectFullName() ),
schematicFileName.GetFullName(), wildcards,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
@ -94,11 +92,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName,
schematicFileName = dlg.GetPath();
if( dlg.GetFilterIndex() == 1
&& schematicFileName.GetExt() != LegacySchematicFileExtension )
schematicFileName.SetExt( LegacySchematicFileExtension );
else if( dlg.GetFilterIndex() == 0
&& schematicFileName.GetExt() != KiCadSchematicFileExtension )
if( schematicFileName.GetExt().IsEmpty() )
schematicFileName.SetExt( KiCadSchematicFileExtension );
}

View File

@ -50,7 +50,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile( bool aUseCurrentSheetFilenam
fn = Schematic().RootScreen()->GetFileName();
fn.SetName( fn.GetName() + "-cache" );
fn.SetExt( SchematicLibraryFileExtension );
fn.SetExt( LegacySymbolLibFileExtension );
bool success = CreateArchiveLibrary( fn.GetFullPath() );

View File

@ -47,17 +47,27 @@ void LIB_EDIT_FRAME::ImportPart()
return;
}
wxString wildcards = KiCadSymbolLibFileWildcard();
wildcards += "|" + LegacySymbolLibFileWildcard();
wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath, wxEmptyString,
SchematicLibraryFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxFileName fn = dlg.GetPath();
if( fn.GetExt().IsEmpty() )
fn.SetExt( (dlg.GetFilterIndex() == 0) ?
KiCadSymbolLibFileExtension : LegacySymbolLibFileExtension );
m_mruPath = fn.GetPath();
wxArrayString symbols;
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
SCH_IO_MGR::SCH_FILE_T piType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( piType ) );
// TODO dialog to select the part to be imported if there is more than one
try
@ -108,10 +118,10 @@ void LIB_EDIT_FRAME::ExportPart()
wxFileName fn;
fn.SetName( part->GetName().Lower() );
fn.SetExt( SchematicLibraryFileExtension );
fn.SetExt( KiCadSymbolLibFileExtension );
wxFileDialog dlg( this, _( "Export Symbol" ), m_mruPath, fn.GetFullName(),
SchematicLibraryFileWildcard(), wxFD_SAVE );
KiCadSymbolLibFileWildcard(), wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
@ -121,7 +131,7 @@ void LIB_EDIT_FRAME::ExportPart()
LIB_PART* old_part = NULL;
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
if( fn.FileExists() )
{
@ -165,7 +175,10 @@ void LIB_EDIT_FRAME::ExportPart()
if( !fn.FileExists() )
pi->CreateSymbolLib( fn.GetFullPath() );
pi->SaveSymbol( fn.GetFullPath(), new LIB_PART( *part ) );
// The flattened symbol is most likely what the user would want. As some point in
// the future as more of the symbol library inheritance is implemented, this may have
// to be changes to save parts of inherited symbols.
pi->SaveSymbol( fn.GetFullPath(), part->Flatten().release() );
}
catch( const IO_ERROR& ioe )
{

View File

@ -133,7 +133,7 @@ SYMBOL_LIB_TABLE_ROW* LIB_MANAGER::GetLibrary( const wxString& aLibrary ) const
bool LIB_MANAGER::SaveLibrary( const wxString& aLibrary, const wxString& aFileName,
SCH_IO_MGR::SCH_FILE_T aFileType )
{
wxCHECK( LibraryExists( aLibrary ), false );
wxCHECK( aFileType != SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY && LibraryExists( aLibrary ), false );
wxFileName fn( aFileName );
wxCHECK( !fn.FileExists() || fn.IsFileWritable(), false );
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( aFileType ) );
@ -271,8 +271,19 @@ bool LIB_MANAGER::ClearPartModified( const wxString& aAlias, const wxString& aLi
bool LIB_MANAGER::IsLibraryReadOnly( const wxString& aLibrary ) const
{
wxCHECK( LibraryExists( aLibrary ), true );
wxFileName fn( symTable()->GetFullURI( aLibrary ) );
return ( fn.FileExists() && !fn.IsFileWritable() ) || !fn.IsDirWritable();
// From hence forth, legacy symbol libraries are not writable.
const SYMBOL_LIB_TABLE_ROW* row = dynamic_cast<const SYMBOL_LIB_TABLE_ROW*>(
symTable()->FindRowByURI( fn.GetFullPath() ) );
SCH_IO_MGR::SCH_FILE_T fileType = SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN;
if( row )
fileType = SCH_IO_MGR::EnumFromStr( row->GetType() );
return ( fileType != SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY ) && fn.FileExists() &&
( !fn.IsFileWritable() || !fn.IsDirWritable() );
}
@ -648,6 +659,8 @@ bool LIB_MANAGER::addLibrary( const wxString& aFilePath, bool aCreate, SYMBOL_LI
if( aCreate )
{
wxCHECK( schFileType != SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY, false );
try
{
aTable->CreateSymbolLib( libName );

View File

@ -813,7 +813,6 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
fn.SetExt( KiCadSymbolLibFileExtension );
wxString wildcards = KiCadSymbolLibFileWildcard();
wildcards += "|" + SchematicLibraryFileWildcard();
wxFileDialog dlg( this, wxString::Format( _( "Save Library \"%s\" As..." ), aLibrary ),
default_path, fn.GetFullName(), wildcards,
@ -824,16 +823,8 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
fn = dlg.GetPath();
// Update the file extension and plugin if a different library type was selected.
if( dlg.GetFilterIndex() == 1 )
{
fn.SetExt( SchematicLibraryFileExtension );
fileType = SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY;
}
else
{
if( fn.GetExt().IsEmpty() )
fn.SetExt( KiCadSymbolLibFileExtension );
}
}
else
{
@ -841,11 +832,8 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
fileType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
}
wxFileName docFileName = fn;
docFileName.SetExt( DOC_EXT );
// Verify the user has write privileges before attempting to save the library file.
if( !IsWritable( fn ) || !IsWritable( docFileName ) )
if( !IsWritable( fn ) )
return false;
ClearMsgPanel();
@ -854,10 +842,6 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
if( !backupFile( fn, "bak" ) )
return false;
// Copy .dcm file to .bck.
if( !backupFile( docFileName, "bck" ) )
return false;
if( !m_libMgr->SaveLibrary( aLibrary, fn.GetFullPath(), fileType ) )
{
msg.Printf( _( "Failed to save changes to symbol library file \"%s\"" ),
@ -871,9 +855,6 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
ClearMsgPanel();
msg.Printf( _( "Symbol library file \"%s\" saved" ), fn.GetFullPath() );
wxString msg1;
msg1.Printf( _( "Symbol library documentation file \"%s\" saved" ), docFileName.GetFullPath() );
AppendMsgPanel( msg, msg1, BLUE );
RebuildSymbolUnitsList();
return true;

View File

@ -113,7 +113,7 @@ static wxFileName GetRescueLibraryFileName( SCHEMATIC* aSchematic )
{
wxFileName fn = aSchematic->GetFileName();
fn.SetName( fn.GetName() + wxT( "-rescue" ) );
fn.SetExt( SchematicLibraryFileExtension );
fn.SetExt( LegacySymbolLibFileExtension );
return fn;
}

View File

@ -157,7 +157,7 @@ wxString SCH_EAGLE_PLUGIN::getLibName()
wxFileName SCH_EAGLE_PLUGIN::getLibFileName()
{
wxFileName fn( m_kiway->Prj().GetProjectPath(), getLibName(), SchematicLibraryFileExtension );
wxFileName fn( m_kiway->Prj().GetProjectPath(), getLibName(), KiCadSymbolLibFileExtension );
return fn;
}
@ -432,7 +432,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
wxCHECK_MSG( libTable, NULL, "Could not load symbol lib table." );
m_pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
m_pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
m_properties = std::make_unique<PROPERTIES>();
( *m_properties )[SCH_LEGACY_PLUGIN::PropBuffering] = "";
@ -446,7 +446,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
// Add the new library to the project symbol library table.
libTable->InsertRow(
new SYMBOL_LIB_TABLE_ROW( getLibName(), libTableUri, wxString( "Legacy" ) ) );
new SYMBOL_LIB_TABLE_ROW( getLibName(), libTableUri, wxString( "KiCad" ) ) );
// Save project symbol library table.
wxFileName fn(
@ -501,9 +501,9 @@ void SCH_EAGLE_PLUGIN::loadDrawing( wxXmlNode* aDrawingNode )
// wxXmlNode* settings = drawingChildren["settings"]
// Load schematic
auto schematic = drawingChildren["schematic"];
if( schematic )
loadSchematic( schematic );
}

View File

@ -60,6 +60,8 @@ SCH_PLUGIN* SCH_IO_MGR::FindPlugin( SCH_FILE_T aFileType )
return new SCH_SEXPR_PLUGIN();
case SCH_EAGLE:
return new SCH_EAGLE_PLUGIN();
default:
;
}
return NULL;
@ -153,7 +155,7 @@ SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::GuessPluginTypeFromLibPath( const wxString& a
SCH_FILE_T ret = SCH_KICAD; // default guess, unless detected otherwise.
wxFileName fn( aLibPath );
if( fn.GetExt() == SchematicLibraryFileExtension )
if( fn.GetExt() == LegacySymbolLibFileExtension )
{
ret = SCH_LEGACY;
}

View File

@ -60,6 +60,7 @@ public:
// ALTIUM,
// etc.
SCH_FILE_UNKNOWN
} )
/**

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2016-2017 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2016-2020 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -56,7 +56,7 @@ public:
}
SYMBOL_LIB_TABLE_ROW() :
type( SCH_IO_MGR::SCH_LEGACY )
type( SCH_IO_MGR::SCH_KICAD )
{
SetEnabled( true );
}

View File

@ -110,7 +110,7 @@ wxString AddFileExtListToFilter( const std::vector<std::string>& aExts );
wxString formatWildcardExt( const wxString& aWildcard );
extern const std::string SchematicSymbolFileExtension;
extern const std::string SchematicLibraryFileExtension;
extern const std::string LegacySymbolLibFileExtension;
extern const std::string SchematicBackupFileExtension;
extern const std::string VrmlFileExtension;
@ -173,7 +173,7 @@ extern wxString ComponentFileWildcard();
extern wxString PageLayoutDescrFileWildcard();
extern wxString SchematicSymbolFileWildcard();
extern wxString KiCadSymbolLibFileWildcard();
extern wxString SchematicLibraryFileWildcard();
extern wxString LegacySymbolLibFileWildcard();
extern wxString ProjectFileWildcard();
extern wxString KiCadSchematicFileWildcard();
extern wxString LegacySchematicFileWildcard();

View File

@ -283,7 +283,7 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
case TREE_SVG: return SVGFileExtension;
case TREE_PAGE_LAYOUT_DESCR: return PageLayoutDescrFileExtension;
case TREE_FOOTPRINT_FILE: return KiCadFootprintFileExtension;
case TREE_SCHEMATIC_LIBFILE: return SchematicLibraryFileExtension;
case TREE_SCHEMATIC_LIBFILE: return LegacySymbolLibFileExtension;
default: return wxEmptyString;
}
}