23#include <wx/filename.h>
51#define FMT_UNIMPLEMENTED _( "Plugin '%s' does not implement the '%s' function." )
52#define FMT_NOTFOUND _( "Plugin type '%s' is not found." )
68SCH_IO* SCH_IO_MGR::FindPlugin( SCH_FILE_T aFileType )
91 default:
return nullptr;
104 case SCH_KICAD:
return wxString( wxT(
"KiCad" ) );
105 case SCH_LEGACY:
return wxString( wxT(
"Legacy" ) );
106 case SCH_ALTIUM:
return wxString( wxT(
"Altium" ) );
107 case SCH_CADSTAR_ARCHIVE:
return wxString( wxT(
"CADSTAR Schematic Archive" ) );
108 case SCH_DATABASE:
return wxString( wxT(
"Database" ) );
109 case SCH_EAGLE:
return wxString( wxT(
"EAGLE" ) );
110 case SCH_EASYEDA:
return wxString( wxT(
"EasyEDA (JLCEDA) Std" ) );
111 case SCH_EASYEDAPRO:
return wxString( wxT(
"EasyEDA (JLCEDA) Pro" ) );
112 case SCH_EASYEDAPRO_V3:
return wxString( wxT(
"EasyEDA (JLCEDA) Pro v3" ) );
113 case SCH_GEDA:
return wxString( wxT(
"gEDA / Lepton EDA" ) );
114 case SCH_LTSPICE:
return wxString( wxT(
"LTspice" ) );
115 case SCH_HTTP:
return wxString( wxT(
"HTTP" ) );
116 case SCH_PADS:
return wxString( wxT(
"PADS Logic" ) );
117 case SCH_DIPTRACE:
return wxString( wxT(
"DipTrace" ) );
118 case SCH_PCAD:
return wxString( wxT(
"P-CAD" ) );
119 case SCH_ORCAD:
return wxString( wxT(
"OrCAD" ) );
121 default:
return wxString::Format(
_(
"Unknown SCH_FILE_T value: %d" ), aType );
132 if( aType == wxT(
"KiCad" ) )
134 else if( aType == wxT(
"Legacy" ) )
136 else if( aType == wxT(
"Altium" ) )
138 else if( aType == wxT(
"CADSTAR Schematic Archive" ) )
139 return SCH_CADSTAR_ARCHIVE;
140 else if( aType == wxT(
"Database" ) )
142 else if( aType == wxT(
"EAGLE" ) )
144 else if( aType == wxT(
"EasyEDA (JLCEDA) Std" ) )
146 else if( aType == wxT(
"EasyEDA (JLCEDA) Pro" ) )
147 return SCH_EASYEDAPRO;
148 else if( aType == wxT(
"EasyEDA (JLCEDA) Pro v3" ) )
149 return SCH_EASYEDAPRO_V3;
150 else if( aType == wxT(
"gEDA / Lepton EDA" ) )
152 else if( aType == wxT(
"LTspice" ) )
154 else if( aType == wxT(
"HTTP" ) )
156 else if( aType == wxT(
"PADS Logic" ) )
158 else if( aType == wxT(
"DipTrace" ) )
160 else if( aType == wxT(
"P-CAD" ) )
162 else if( aType == wxT(
"OrCAD" ) )
165 return SCH_NESTED_TABLE;
167 return SCH_FILE_UNKNOWN;
175 if( parser.
Parse( aLibPath.ToStdString() ).has_value() )
176 return SCH_NESTED_TABLE;
178 for(
const SCH_IO_MGR::SCH_FILE_T&
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
180 bool isKiCad =
fileType == SCH_IO_MGR::SCH_KICAD ||
fileType == SCH_IO_MGR::SCH_LEGACY;
199 if( pi->SCH_IO::CanReadLibrary( aLibPath ) )
206 if( pi->CanReadLibrary( aLibPath ) )
211 return SCH_IO_MGR::SCH_FILE_UNKNOWN;
218 for(
const SCH_IO_MGR::SCH_FILE_T&
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
220 bool isKiCad =
fileType == SCH_IO_MGR::SCH_KICAD ||
fileType == SCH_IO_MGR::SCH_LEGACY;
233 if( pi->CanReadSchematicFile( aSchematicPath ) )
237 return SCH_IO_MGR::SCH_FILE_UNKNOWN;
242 const wxString& aNewFilepath )
246 if( oldFileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
251 if( oldFileType == SCH_IO_MGR::SCH_NESTED_TABLE )
257 if( oldFileType == SCH_IO_MGR::SCH_HTTP || oldFileType == SCH_IO_MGR::SCH_DATABASE )
263 if( !oldFilePI || !kicadPI )
266 std::vector<LIB_SYMBOL*> symbols;
267 std::vector<LIB_SYMBOL*> newSymbols;
268 std::map<LIB_SYMBOL*, LIB_SYMBOL*> symbolMap;
272 oldFilePI->EnumerateSymbolLib( symbols, aOldFilePath, aOldFileProps );
277 if( symbol->IsDerived() )
282 newSymbols.push_back(
new LIB_SYMBOL( *symbol ) );
283 symbolMap[symbol] = newSymbols.back();
289 if( !symbol->IsDerived() )
294 newSymbols.push_back(
new LIB_SYMBOL( *symbol ) );
295 newSymbols.back()->SetParent( symbolMap[ symbol->GetParent().lock().get() ] );
299 kicadPI->SaveLibrary( aNewFilepath );
304 kicadPI->SaveSymbol( aNewFilepath, symbol );
tl::expected< LIBRARY_TABLE_IR, LIBRARY_PARSE_ERROR > Parse(const std::filesystem::path &aPath)
static const wxString TABLE_TYPE_NAME
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 DipTrace schematic files (.dch).
A SCH_IO derivation for loading 6.x+ Eagle schematic files.
A SCH_IO derivation for loading gEDA/gschem schematic files (.sch).
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.
A SCH_IO derivation for loading OrCAD Capture schematic designs (.dsn).
A SCH_IO derivation for loading PADS Logic schematic files.
A SCH_IO derivation for loading P-CAD 2006 ASCII schematic files (.SCH).
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.