23#include <wx/filename.h>
44#define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." )
45#define FMT_NOTFOUND _( "Plugin type \"%s\" is not found." )
61SCH_IO* SCH_IO_MGR::FindPlugin( SCH_FILE_T aFileType )
78 default:
return nullptr;
91 case SCH_KICAD:
return wxString( wxT(
"KiCad" ) );
92 case SCH_LEGACY:
return wxString( wxT(
"Legacy" ) );
93 case SCH_ALTIUM:
return wxString( wxT(
"Altium" ) );
94 case SCH_CADSTAR_ARCHIVE:
return wxString( wxT(
"CADSTAR Schematic Archive" ) );
95 case SCH_DATABASE:
return wxString( wxT(
"Database" ) );
96 case SCH_EAGLE:
return wxString( wxT(
"EAGLE" ) );
97 case SCH_EASYEDA:
return wxString( wxT(
"EasyEDA (JLCEDA) Std" ) );
98 case SCH_EASYEDAPRO:
return wxString( wxT(
"EasyEDA (JLCEDA) Pro" ) );
99 case SCH_LTSPICE:
return wxString( wxT(
"LTspice" ) );
100 case SCH_HTTP:
return wxString( wxT(
"HTTP" ) );
101 default:
return wxString::Format(
_(
"Unknown SCH_FILE_T value: %d" ),
113 if( aType == wxT(
"KiCad" ) )
115 else if( aType == wxT(
"Legacy" ) )
117 else if( aType == wxT(
"Altium" ) )
119 else if( aType == wxT(
"CADSTAR Schematic Archive" ) )
120 return SCH_CADSTAR_ARCHIVE;
121 else if( aType == wxT(
"Database" ) )
123 else if( aType == wxT(
"EAGLE" ) )
125 else if( aType == wxT(
"EasyEDA (JLCEDA) Std" ) )
127 else if( aType == wxT(
"EasyEDA (JLCEDA) Pro" ) )
128 return SCH_EASYEDAPRO;
129 else if( aType == wxT(
"LTspice" ) )
131 else if( aType == wxT(
"HTTP" ) )
136 return SCH_FILE_UNKNOWN;
142 for(
const SCH_IO_MGR::SCH_FILE_T&
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
144 bool isKiCad =
fileType == SCH_IO_MGR::SCH_KICAD ||
fileType == SCH_IO_MGR::SCH_LEGACY;
163 if( pi->SCH_IO::CanReadLibrary( aLibPath ) )
170 if( pi->CanReadLibrary( aLibPath ) )
175 return SCH_IO_MGR::SCH_FILE_UNKNOWN;
182 for(
const SCH_IO_MGR::SCH_FILE_T&
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
184 bool isKiCad =
fileType == SCH_IO_MGR::SCH_KICAD ||
fileType == SCH_IO_MGR::SCH_LEGACY;
197 if( pi->CanReadSchematicFile( aSchematicPath ) )
201 return SCH_IO_MGR::SCH_FILE_UNKNOWN;
206 const wxString& aNewFilepath )
210 if( oldFileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
215 std::vector<LIB_SYMBOL*> symbols;
216 std::vector<LIB_SYMBOL*> newSymbols;
217 std::map<LIB_SYMBOL*, LIB_SYMBOL*> symbolMap;
221 oldFilePI->EnumerateSymbolLib( symbols, aOldFilePath, aOldFileProps );
226 if( symbol->IsDerived() )
231 newSymbols.push_back(
new LIB_SYMBOL( *symbol ) );
232 symbolMap[symbol] = newSymbols.back();
238 if( !symbol->IsDerived() )
243 newSymbols.push_back(
new LIB_SYMBOL( *symbol ) );
244 newSymbols.back()->SetParent( symbolMap[ symbol->GetParent().lock().get() ] );
248 kicadPI->SaveLibrary( aNewFilepath );
253 kicadPI->SaveSymbol( aNewFilepath, symbol );
Define a library symbol object.
A KiCad database library provides both symbol and footprint metadata, so there are "shim" plugins on ...
A SCH_IO derivation for loading 6.x+ Eagle schematic files.
A KiCad HTTP library provides both symbol and footprint metadata, so there are "shim" plugins on both...
A SCH_IO derivation for loading schematic files created before the new s-expression file format.
A SCH_IO derivation for loading schematic files using the new s-expression file format.
static bool ConvertLibrary(std::map< std::string, UTF8 > *aOldFileProps, const wxString &aOldFilePath, const wxString &aNewFilepath)
Convert a schematic symbol library to the latest KiCad format.
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy",...
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
static SCH_FILE_T GuessPluginTypeFromSchPath(const wxString &aSchematicPath, int aCtl=0)
Return a plugin type given a schematic using the file extension of aSchematicPath.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Base class that schematic file and library loading and saving plugins should derive from.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
#define KICTL_CREATE
caller thinks requested project files may not exist.
#define KICTL_KICAD_ONLY
chosen file is from KiCad according to user
#define KICTL_NONKICAD_ONLY
chosen file is non-KiCad according to user
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Definition of file extensions used in Kicad.