This is a very large and potentially disruptive change so this will be an
unusually long and detailed commit message.
The new file formats are now the default in both the schematic and symbol
library editors. Existing symbol libraries will be saved in their current
format until new features are added to library symbols. Once this happens,
both the legacy schematic and symbol file formats will be no longer be
savable and existing libraries will have to be converted. Saving to the
legacy file formats is still available for round robin testing and should
not be used for normal editing.
When loading the legacy schematic file, it is imperative that the schematic
library symbols are rescued and/or remapped to valid library identifiers.
Otherwise, there will be no way to link to the original library symbol and
the user will be required manually set the library identifier. The cached
symbol will be saved in the schematic file so the last library symbol in
the cache will still be used but there will be no way to update it from the
original library.
The next save after loading a legacy schematic file will be converted to
the s-expression file format. Schematics with hierarchical sheets will
automatically have all sheet file name extensions changed to .kicad_sym
and saved to the new format as well.
Appending schematics requires that the schematic to append has already been
converted to the new file format. This is required to ensure that library
symbols are guaranteed to be valid for the appended schematic.
The schematic symbol library symbol link resolution has been moved out of
the SCH_COMPONENT object and move into the SCH_SCREEN object that owns the
symbol. This was done to ensure that there is a single place where the
library symbol links get resolved rather than the dozen or so different
code paths that previously existed. It also removes the necessity of the
SCH_COMPONENT object of requiring any knowledge of the symbol library table
and/or the cache library.
When opening an s-expression schematic, the legacy cache library is not
loaded so any library symbols not rescued cannot be loaded. Broken library
symbol links will have to be manually resolved by adding the cache library
to the symbol library table and changing the links in the schematic symbol.
Now that the library symbols are embedded in the schematic file, the
SCH_SCREEN object maintains the list of library symbols for the schematic
automatically. No external manipulation of this library cache should ever
occur.
ADDED: S-expression schematic and symbol library file formats.
The code that checked for pin conflicts to determine if a symbol needed
rescued did not check either the pin convert setting so it was possible
for a pin from the other convert on symbols that do not have identical
units to appear to not have a pin conflict. Add tests for pin unit and
convert setting to prevent that from breaking the comparison. This must
have always been broken.
Fix the symbol preview widget to prevent drawing all symbols on top of
each other (if we need to do this the code will have to be revised) and
also show the convert if valid.
Fix broken symbol cache library when saving alias symbols.
Fixes https://gitlab.com/kicad/code/kicad/issues/3879
This moves EESchema DLIST structures to rtree. These changes are more
fundamental than the pcbnew changes from 9163ac543888c01d11d1877d7c1
and 961b22d60 as eeschema operations were more dependent on passing
drawing list references around with SCH_ITEM* objects.
Use the root symbol when comparing against the cached symbol when
checking to see if a symbol changed. When the original symbol is
a derived symbol, the test will always fail.
Force a symbol link refresh on a rescue to prevent stale links from
crashing the connection graph refresh when running the project rescue
on demand.
Force a symbol link refresh on project load to prevent stale links from
symbol link changes from crashing the connection graph when the project
rescue in invoked.
Fixes kicad/code/kicad#3645
This change completely removes the LIB_ALIAS design pattern an replaces
it by allowing LIB_PART objects to inherit from other LIB_PART objects.
The initial implementation only allows for single inheritance and only
supports the mandatory fields in the derived part because that is all
that the current symbol library file format will support. Once the new
file format is implemented and saving to the old file format is deprecated,
more complex inheritance will be added. The LIB_ALIAS information saved
in the document files was move into the LIB_PART object. This change
impacts virtually every part of the schematic and symbol library editor
code so this commit message is woefully incomplete.
REMOVE: Removed the symbol aliases concept from the schematic and symbol
editors and the symbol viewer.
NEW: Replace the symbol alias concept with simple inheritance that allows
a library symbol to be derived from another library symbol.
Do not keep pointer to SCH_EDIT_FRAME in the rescuer object to prevent
it from creating dialogs with itself as the parent when call from the
rescue dialog which is itself a grandchild of the frame window.
The symbol library table rescue candidate was only using the item name
of the library ID object which was being compared to the fully formatted
library ID causing a comparison failure so no instances of any rescued
symbols was shown in the dialog.
Fixes lp:1791805
https://bugs.launchpad.net/kicad/+bug/1791805
This removes the existing constructors so that all parsing must
be explicit and callers are made aware that they need to think
about illegal characters, malformed ids, etc.
Fixes: lp:1783474
* https://bugs.launchpad.net/kicad/+bug/1783474
When parsing component names, we need to account for the possibility of
illegal characters (e.g. "/", ":") in the names from v4 libraries. They
are fixed internally by the cache parser but if we don't fix them
in the rescue routine, the symbol won't match it's cache name.
This standardizes all schematic illegal character routines into LIB_ID
Fixes: lp:1774774
* https://bugs.launchpad.net/kicad/+bug/1774774
Symbol/footprint library and entry have the same set of forbidden
characters with a single exception, space character. To accommodate for
this difference, LIB_ID validation and fix methods have been extended to
specify the LIB_ID type that is checked (schematic/board).
LIB_ID::HasIllegalChars() and LIB_ID::FixIllegalChars() had two different
sets of characters treated as invalid in LIB_IDs. The set has been
factored out to another function to avoid duplication.
Schematic cleanup only makes sense after the libraries are fully updated
and loaded. Before pin caching, this was a minor difference but once we
needed to update pin caches, schematic cleanup can remove junctions from
pin-wire connections incorrectly.
Instead, we use the global OpenProjectFiles() schematic cleanup call to
be sufficient and not call a second time, prior to all libraries being
rescued and loaded.
Fixes: lp:1743148
* https://bugs.launchpad.net/kicad/+bug/1743148
File names with spaces were causing invalid symbol names in both the
rescue library and the cache which would cause both libraries to fail
to load because library symbol names are not escaped so the spaces
tripped up the library parser. Replace the spaces in the file names
with hyphens and in both the rescuer and the remapping code so the
library nickname in the symbol library table does not contain spaces.
Update the symbol library table dialog to prevent users from defining
library nicknames with spaces. This is different than the footprint
library table which allows nicknames with spaces. This solution is
a temporary fix until the new symbol library and schematic file formats
are implemented.
Fix off by one row in illegal nickname error message in the symbol
library table editor.
This commit is a partial revert of aa81f5b9 & 445ac505. LIB_ID should
not be modified when a library is assigned to its part, as the library
nickname cannot be evaluated during the assignment and might be
different than its filename.
Fix a bug where the full LIB_ID was not being used to look up the name
of the symbol in the cache library preventing the rescue to work when
rescuing symbol library table projects.
Add information as to why a symbol was rescued rather than only showing
what symbols were rescued.
Do not add rescue suffix to symbol name for symbol library table rescues
because if a symbol name exists in multiple libraries that need rescued
at the same time will cause subsequent symbol rescues to be overwritten.
Append the nickname of the schematic symbol library to prevent symbol
name clashes in the rescue library.
Use the symbol found in the library when the symbol is not in the cache
library.
Add an assert to prevent dereferncing a null pointer in the future even
thought this should not happen as the rescue algorithm does not add a
candidate when a symbol cannot be found in either the cache or any other
library.
Fixes lp:1741964
https://bugs.launchpad.net/kicad/+bug/1741964
Change the legacy schematic plugin to preserve illegal LIB_ID characters
when load schematics prior to version 4.
Check for illegal LIB_ID symbol names during project rescue. Rename and
rescue any symbols with illegal LIB_ID names.
Add static methods to LIB_ID object for testing for and fixing names
with illegal characters so there is uniform code for doing so.
Update the Eagle plugin symbol loader to fix symbol names using the new
LIB_ID fix illegal names method.
Fixes lp:1732236
https://bugs.launchpad.net/kicad/+bug/1732236
In the rare case when something goes wrong with the symbol library
table remapping, do not attempt to rescue symbols that are neither
in the cache nor in any of the libraries.
The legacy rescue library code overwrote the existing library so
previous rescues would get lost. If the rescue library exists,
copy it's contents into the new rescue library before adding the
new rescued symbols so no previously rescued symbols are lost.
Fix a null pointer bug in the symbol library editor when no symbol
is loaded.
Set LIB_ID item name to name passed to LIB_PART ctor.
Copy LIB_ID in LIB_PART copy ctor.
If a library disappears all together or a symbol name is changed, force
the rescuer to add it to the rescue library. The current rescue code
only looked for differences if they existed between libraries. This was
causing symbols to be unceremoniously dumped from the symbol library
table remapping.
Don't search for cache rescue candidates in the symbol library table
rescuer.
Refactor rescue objects so that they can support derivation.
Factor out legacy rescuer code to perform legacy project rescues.
Create new symbol library table rescuer for rescuing symbol library table
based projects.
Perform the correct rescue type on project load.
Add symbol library table remapping support to the tools menu for run on
demand as applicable.
Add flag to SCH_SCREENS::UpdateSymbolLinks() to allow forcing the symbol
link updates when the library modification hash has not changed.
This forces the compiler class specific features rather than borrowing
from the base class's std::string. In some cases prior to this,
wxString( std::string ) was being called rather than UTF8::operator
wxString() leading to garbled wxStrings.
Added function UTF8::wx_str() which is of great convenience also.
Implicit conversions still work as before, and hopefully more reliably.
This commit was too broad and not cognizant of the purpose of the class
UTF8.
Add MAYBE_VERIFY_UTF8() macro, which can trap non-UTF8 encoded strings in
debug builds.
Use that macro conditionally in class UTF8 to trap non-UTF8 encoded strings
being put into UTF8 instances.
For some reason, the schematic symbol library link was being regenerated
every time the schematic was redrawn in SCH_SCREEN::Draw(). Remove the
re-link call from the Draw() and Plot() functions.
Add function the SCH_SCREENS to update the links in all of the schematic
sheets.
Update all schematic sheet symbol library links whenever the symbol
library list is modified or any library in the library list is modified.
That should cover all cases where the symbol library links could be
broken.
Refresh schematic window after applying library changes to update any
possible symbol changes.
Add KIWAY message to update the schematic when symbol library changes
could change the schematic. The KIWAY mail was used because the schematic
frame is not a parent of the symbol library editor so wxEvents cannot be
used.
LIB_ID was changing the symbol name due to the parser dropping everything
past the first '/' character which is interpreted by LIB_ID as the item
version. Add flag to ignore this in LIB_ID::SetLibItemName() and add a
new ctor so the library nickname, item name, and revision can be set as
required to prevent the standard LIB_ID parsing.
Fix a few places where PART_LIBS functions FindLibraryAlias() and
FindLibPar() were translating wxString symbol names to LIB_IDs where the
LIB_ID parser was truncating the symbol name.
Use LIB_ID instead of wxString for storing the library symbol information
in the schematic symbol in preparation for the upcoming symbol library table
implementation.
Change the FindLibAlias and FindLibPart functions in the PART_LIBS object
instead of wxString. Please note that only the library ID name is used to
search the list of libraries. The library nickname is ignored. Once the
symbol library table is implemented and full LIB_IDs are defined, the
library search code will no longer be used and will only be kept to load
older schematics that have not been converted.
Move SCH_LEGACY_PLUGIN_CACHE definition so that the legacy plugin knows
how to properly delete the cache object.
Add SCH_PLUGIN object to PART_LIB object.
Convert all PART_LIB I/O to use SCH_PLUGIN.
Remove library caching from PART_LIB and use caching provided by SCH_PLUGIN.
Add support to use PROPERTIES for buffering and document file write control
instead of adding code the SCH_PLUGIN object in the SCH_LEGACY_PLUGIN that
will not be required when the new file formats are implemented.
Add buffering to SCH_LEGACY_PLUGIN to prevent cache from writing file on
every change to library. This is to prevent the cache library from being
written every time a new symbol is added.
Add option to not save library document file when saving library. This is
primarily used by the cache library write code.
Move symbol library write code out of LIB_PART and into SCH_LEGACY_PLUGIN.
Add exception handling where LIB_PART caught the exception and returned
an error status.
Remove KICAD_SCH_IO_MANAGER build option as it is no longer optional.
Rename PART_LIB GetEntryNames() and RemoveEntry() to GetAliasNames() and
RemoveAlias() respectively for improved readability.
Rename PART_LIBS FindLibraryEntry() to FindLibraryAlias() improved
readability.
Remove commented out PART_LIBS::FindLibraryEntries().
Remove PART_LIB::GetFirstEntry() and update all effect code accordingly.
Remove unused PART_LIB::SetFileName() method.
Remove unused PART_LIBS::RemoveAllLibraries() method.