Remove duplicate instance data saved in both root SCH_SCREEN and SCH_SHEET
objects that was causing them to be out of sync. All sheet instance data
is stored in the SCH_SHEET object itself and rebuilt on the fly so it is
always current.
Remove Get/SetPageNumber from SCH_SHEET_PATH object so it doesn't obfuscate
where the actual sheet page number information exists.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9782
The tests for file existence and write status perform two file stats
which cause performance issues on slow network shares. Now the file
state is determined at load time and stored in the SCH_SCREEN object
so file access is no longer required.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9343
When swapping SCH_SYMBOL objects during undo, no special processing is
required. The SCH_PIN objects are updated when the LIB_SYMBOL objects
are swapped and the call to SCH_SCREEN::SwapSymbolLinks() didn't do
anything.
They don't define a KiCad string class, so the header file name was
somewhat misleading. But the fact that they didn't match definitely
made coding more difficult.
Found via `codespell -q 3 -S *.po,./thirdparty -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,dout,einstance,modul,ot,overide,serie,te,,tesselate,tesselator,tht`
Differentiates better between the EDA_ITEM IsModified(), referring to
items themselves changing and the EDA_SCREEN IsContentModified(),
referring to whether we have made any unsaved changes.
This fix required sorting all of the LIB_PART draw items to ensure
accurate comparison between the symbols stored in the schematic and the
original library symbols. This has a noticeable impact on symbol library
load performance. It may also cause significant changes the next time
the library is saved due to changes in the draw item sorting. Hashing
may be a better solution here but this addressed the immediate problem.
A skeleton method SCH_SCREEN::SwapSymbolLinks() was added because there
is most likely an issue with orphaned symbols in the schematic library
symbol cache during undo/redo operations. More testing is required to
verify this.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/7263
Junctions should only be wire endings when ending directly on the wire.
This is the requirement for netlisting, so we need to follow it in the
auto-end as well.
SCH_LABEL needs to allow ending because any wire that touches the label
will be connected, so there's a use case for this. However, the
bounding box for local labels did not include their connection point, so
we increase that box a bit. Note that this might have the opposite
effect to https://gitlab.com/kicad/code/kicad/-/issues/7689
Fixes https://gitlab.com/kicad/code/kicad/issues/7714
This also makes sure that the user gets a warning before saving over
an older s-expr format. While that won't always be wanted, it's now
in the infobar (like in PCBNew), so it's not too onerous.§
Fixes https://gitlab.com/kicad/code/kicad/issues/7347
The variable `m_Initialized` in `BASE_SCREEN` is used by
`SCH_EDIT_FRAME` to mark whether a screen had its zoom level initialized
by the "zoom to fit screen" action. When this variable is `false`, the
function `SCH_EDIT_FRAME::DisplayCurrentSheet()` performs "zoom to fit
screen", modifying the zoom level. This function is indirectly called in
the undo routines, so if `m_Initialized` is not set to `true`, a zoom
change will occur when the user undoes an operation, a behavior that is
undesired.
`m_Initialized` was not initialized to `true` for the null schematic
(the schematic that is loaded if no project is loaded), causing the
aforementioned undesired behavior.
To prevent this, I've changed the `SCH_EDIT_FRAME` constructor to set
`m_Initialized` to `true`, since it zooms to fit screen already. I've
moved `m_Initialized` from `BASE_SCREEN` to `SCH_SCREEN`, as it is used
only in Eeschema, and renamed it to `m_zoomInitialized`, a name I
believe that better describes what this variable does.
I've also introduced the function `SCH_EDIT_FRAME::initScreenZoom()` to
group the "zoom to fit screen" action with setting `m_Initialized` to
`true`, as they often should occur together.
I'd also like to say that I'm not confident whether
`SCH_EDIT_FRAME::DisplayCurrentSheet()` should perform the zoom level
initialization at this point, but I have decided to not change this
behavior for now, as the commit history suggests it's several years old.
Fixes https://gitlab.com/kicad/code/kicad/issues/7343
1) Generalize SCH_ITEM owners (SCH_COMPONENT, SCH_SHEET, and now
SCH_GLOBALLABEL)
2) Generalize hypertext items
3) Use SCH_FIELD autoplace infrastructure for placing intersheet
references
4) Use textVar infrastructure for buildin intersheet references.
As an important side-effect this also fixes the undo issues with
intersheet refs.
The groundwork has now been laid for per sheet instance data. Initially
this only supports sheet page numbers but could be expanded to include
other per sheet instance information.
ADDED: Support for user defined schematic page numbers.
Also fixes a couple of bugs where resolving a textVar reference
to the refDes or unit wouldn't get the correct value in a
hierarchical schematic. (Unlogged.)
Fixes https://gitlab.com/kicad/code/kicad/issues/5397
This was causing junctions to not always be added on wire
segments that overlapped component pins, because the pin
might not be part of the component bounding box before
UpdateLocalLibSymbolLinks() is called. When the bbox
was never updated, these symbols weren't collected by
the rtree query for objects overlapping a point.
Set up a new lineage for SCH_ITEMS to get back to the SCHEMATIC
they live on: Items will all be parented to the SCH_SCREEN that
they are added to, and each SCH_SCREEN will point back to the
SCHEMATIC that it is part of. Note that this hierarchy is not
the same as the actual schematic hierarchy, which continues to
be managed through SCH_SHEETs and SCH_SHEET_PATHS.
SCH_SCREEN::UpdateSymbolLinks() should only be called when working with
the legacy schematic file format. Add schematic symbol library symbol
links should be set using SCH_COMPONENT::SetLibSymbol() which updates
the symbol link and pin map accordingly.
Change the schematic symbol LIB_ID edit dialog to properly use the new
SCH_COMPONENT::SetLibSymbol() function.
There has been a long standing (since the beginning of the project?)
issue with sharing schematics between projects. It has been somewhat
supported for complex hierarchies (a sheet shared multiple times in a
single design) but it has not been well supported for simple hierarchies
(the symbol references cannot be changed in the shared schematic). This
issue has been resolved by moving all of the symbol instance sheet paths
from the symbol definitions in the all of the project files and save all
symbol path instances in the root sheet. This ensures that orphaned
symbol instance paths do not accumulate in shared schematic files and
that designs that reuse schematic in simple hierarchies can how have
different references. It also allows the root schematic from one project
to be uses as a sub-sheet in another project.
When legacy schematics are loaded, all sheet and symbol UUIDs are
converted from time stamps to true UUIDs. This is done to ensure there
are no sheet path instance clashes between projects. That being said,
there are no checks for this. It is assumed that the probability of
UUID clashes is so low that it doesn't make sense to test for them.
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.
Also fixes a bug where we were depending on the old deque stuff's
deterministic traversal, which isn't provided by the new RTree stuff.
Fixes https://gitlab.com/kicad/code/kicad/issues/2433