KiCad PCB EDA Suite
Loading...
Searching...
No Matches
schematic.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_SCHEMATIC_H
21#define KICAD_SCHEMATIC_H
22
23#include <eda_item.h>
24#include <embedded_files.h>
25#include <erc/erc_exclusion.h>
27#include <schematic_holder.h>
28#include <sch_rtree.h>
29#include <sch_sheet_path.h>
30#include <schematic_settings.h>
31#include <project.h>
32#include <import_net_map.h>
33
34#include <memory>
35#include <map>
36#include <set>
37#include <mutex>
38#include <optional>
39#include <unordered_map>
40#include <vector>
41
42
45class BUS_ALIAS;
47class EDA_BASE_FRAME;
48class ERC_SETTINGS;
49class LIB_SYMBOL;
50class PROJECT;
51class SCH_COMMIT;
52class SCH_LINE;
53class SCH_SCREEN;
54class SCH_SHEET;
55class SCH_SHEET_LIST;
56class SCH_GLOBALLABEL;
57class SCH_REFERENCE;
59class TOOL_MANAGER;
60class wxFileName;
62
63namespace SCH_CONNECTIVITY
64{
65class FACADE;
67}
68
69namespace KIFONT
70{
71class OUTLINE_FONT;
72}
73
74namespace KIGFX
75{
76class SCH_VIEW;
77}
78
79
80class SCHEMATIC;
81
83{
84public:
86 virtual void OnSchItemsAdded( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) {}
87 virtual void OnSchItemsRemoved( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) {}
88 virtual void OnSchItemsChanged( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) {}
89
90 // This is called when the user changes to a new sheet, not when a sheet is altered.
91 // Sheet alteration events will call OnSchItems*
92 virtual void OnSchSheetChanged( SCHEMATIC& aSch ) {}
93
94 virtual void OnSchSelectionChanged( SCHEMATIC& aSch ) {}
95};
96
103
115{
118
121 std::unique_ptr<SCH_SCREEN> screen;
122
126
128 std::unique_ptr<SCH_SCREEN> screenLibSymbols;
129
131 std::vector<std::unique_ptr<SCH_ITEM>> itemOwners;
132
134 std::vector<SCH_SHEET*> topLevelSheets;
135
137 std::optional<SCH_SHEET_PATH> currentSheet;
138 std::unique_ptr<CONNECTION_GRAPH> connectionGraph;
139
141 bool preserveNetChains = false;
142
143 std::optional<EMBEDDED_FILES> embeddedFiles;
145};
146
154class SCHEMATIC : public EDA_ITEM, public EMBEDDED_FILES, public PROJECT::_ELEM
155{
156public:
157 SCHEMATIC( PROJECT* aPrj );
158
159 virtual ~SCHEMATIC();
160
161 virtual wxString GetClass() const override
162 {
163 return wxT( "SCHEMATIC" );
164 }
165
167 void Reset();
168
170 {
171 return m_importNetMap ? &*m_importNetMap : nullptr;
172 }
173
174 void SetImportNetMap( IMPORT_NET_MAP aMap ) { m_importNetMap = std::move( aMap ); }
175
177 PROJECT& Project() const { return *m_project; }
178 void SetProject( PROJECT* aPrj );
179
180 const std::map<wxString, wxString>* GetProperties() { return &m_properties; }
181
183
185
190
197 bool IsHierarchyModified() const;
198
204 bool HasHierarchy() const { return !m_hierarchy.empty(); }
205
206 void RefreshHierarchy();
207
213 wxString GetRefSuffix( const SCH_SHEET_PATH& aPath ) const;
214
215 wxString GetRefSuffix( const KIID_PATH& aPath ) const;
216
218 void AppendRefSuffix( wxString& aRef, const SCH_SHEET_PATH& aPath ) const;
219
227 wxString GetPackageRefSuffix( const SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aPath ) const;
228
229 wxString GetPackageRefSuffix( const SCH_SYMBOL* aSymbol, const KIID_PATH& aPath ) const;
230
235 wxString GetUnitRefSuffix( const SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aPath, int aUnit ) const;
236
241 bool CopiesSelectDifferentUnits( const SCH_SYMBOL* aSymbol ) const;
242
244 std::set<KIID> SplitUnitSymbols() const;
245
250 std::string FormatRefSuffixes() const;
251
253 std::map<std::pair<KIID, KIID_PATH>, wxString> PackageRefSuffixes() const;
254
261 std::vector<std::pair<SCH_SHEET_PATH, SCH_SHEET_PATH>> RefSuffixCollisions( bool aIncludeEmpty ) const;
262
265
268
274 void RefreshRefSuffixes();
275
276 SCH_ITEM* ResolveItem( const KIID& aID, SCH_SHEET_PATH* aPathOut = nullptr,
277 bool aAllowNullptrReturn = false ) const
278 {
279 return m_hierarchy.ResolveItem( aID, aPathOut, aAllowNullptrReturn );
280 }
281
283 {
284 return *m_rootSheet;
285 }
286
292 std::vector<SCH_SHEET*> GetTopLevelSheets() const;
293
294 SCH_SHEET* GetTopLevelSheet( int aIndex = 0 ) const;
295
297 std::vector<TOP_LEVEL_SHEET_INFO> TopLevelSheetInfos() const;
298
303 bool TopLevelSheetsMatch( const std::vector<TOP_LEVEL_SHEET_INFO>& aSheets ) const;
304
306 static wxFileName TopLevelSheetFile( const TOP_LEVEL_SHEET_INFO& aSheet, const wxString& aProjectPath,
307 bool aLegacy );
308
316 bool IsTopLevelSheetUuid( const KIID& aUuid ) const;
317
325 KIID_PATH NormalizeInstancePath( const KIID_PATH& aPath ) const;
326
334 bool IsInstancePathInProject( const KIID_PATH& aPath ) const;
335
345 void SetTopLevelSheets( const std::vector<SCH_SHEET*>& aSheets );
346
358 void AdoptContent( SCHEMATIC_CONTENT&& aContent ) noexcept;
359
365 void AddTopLevelSheet( SCH_SHEET* aSheet );
366
373 bool RemoveTopLevelSheet( SCH_SHEET* aSheet );
374
381 bool IsTopLevelSheet( const SCH_SHEET* aSheet ) const;
382
384 bool IsValid() const
385 {
386 return m_project && m_rootSheet != nullptr;
387 }
388
390 SCH_SCREEN* RootScreen() const;
391
392 void GetContextualTextVars( wxArrayString* aVars ) const;
393
394 bool ResolveTextVar( const SCH_SHEET_PATH* aSheetPath, wxString* token, int aDepth ) const;
395
397 wxString GetFileName() const;
398
400 {
401 return *m_currentSheet;
402 }
403
404 void SetCurrentSheet( const SCH_SHEET_PATH& aPath )
405 {
406 *m_currentSheet = aPath;
407 }
408
410
413
415 {
416 return m_connectionGraph;
417 }
418
419 const wxString& GetHighlightedNetChain() const { return m_highlightedNetChain; }
420 void SetHighlightedNetChain( const wxString& aNetChain ) { m_highlightedNetChain = aNetChain; }
421
423
424 ERC_SETTINGS& ErcSettings() const;
425
426 std::vector<SCH_MARKER*> ResolveERCExclusions();
427
429 const EMBEDDED_FILES* GetEmbeddedFiles() const;
430
435 std::shared_ptr<BUS_ALIAS> GetBusAlias( const wxString& aLabel ) const;
436
437 void AddBusAlias( std::shared_ptr<BUS_ALIAS> aAlias );
438
439 void SetBusAliases( const std::vector<std::shared_ptr<BUS_ALIAS>>& aAliases );
440
441 // An explicit project table, including an empty one, supersedes legacy sheet definitions.
442 bool HasProjectBusAliases() const;
443
450
456
457 const std::vector<std::shared_ptr<BUS_ALIAS>>& GetAllBusAliases() const
458 {
459 return m_busAliases;
460 }
461
468 std::set<wxString> GetNetClassAssignmentCandidates();
469
476 bool ResolveCrossReference( wxString* token, int aDepth ) const;
477
478 std::map<wxString, std::set<int>>& GetPageRefsMap() { return m_labelToPageRefsMap; }
479
480 std::map<int, wxString> GetVirtualPageToSheetNamesMap() const;
481 std::map<int, wxString> GetVirtualPageToSheetPagesMap() const;
482
483 wxString ConvertRefsToKIIDs( const wxString& aSource ) const;
484 wxString ConvertKIIDsToRefs( const wxString& aSource ) const;
485
494
507
514
520
521 void SyncLibSymbolPinMaps( const wxString& aSchLibSymbolName, const LIB_SYMBOL& aSource, SCH_COMMIT* aCommit );
522
527 {
528 m_operatingPoints.clear();
529 }
530
536 void SetOperatingPoint( const wxString& aNetChain, double aValue )
537 {
538 m_operatingPoints[ aNetChain ] = aValue;
539 }
540
541 wxString GetOperatingPoint( const wxString& aNetName, int aPrecision, const wxString& aRange );
542
550 int FixupJunctionsAfterImport( const std::function<void( SCH_LINE*, SCH_LINE* )>& aOnSplit = {} );
551
555 void RecordERCExclusions();
556
558
559 void ClearUnresolvedERCExclusions( int aErrorCode = -1 );
560
565
572 std::vector<SCH_MARKER*> ReloadERCExclusions();
573
578 void OnItemsAdded( std::vector<SCH_ITEM*>& aNewItems );
579
584 void OnItemsRemoved( std::vector<SCH_ITEM*>& aRemovedItems );
585
590 void OnItemsChanged( std::vector<SCH_ITEM*>& aItems );
591
598 void OnSchSheetChanged();
599
604
614 void AddListener( SCHEMATIC_LISTENER* aListener );
615
621 void RemoveListener( SCHEMATIC_LISTENER* aListener );
622
626 void RemoveAllListeners();
627
628 void RunOnNestedEmbeddedFiles( const std::function<void( EMBEDDED_FILES* )>& aFunction ) override;
629
633 void EmbedFonts() override;
634
638 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
639
646 std::set<const SCH_SCREEN*> GetSchematicsSharedByMultipleProjects() const;
647
653 bool IsComplexHierarchy() const;
654
656
664 void CleanUp( SCH_COMMIT* aCommit, SCH_SCREEN* aScreen = nullptr );
665
666 // Prepare source geometry and intersheet references before rebuilding connectivity.
667 void CleanUpConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags,
668 const std::set<SCH_SCREEN*>& aLocalScreens = {} );
669
670 // Fully rebuild the selected connectivity backend without changing source geometry.
671 void RebuildConnectivity( std::function<void( SCH_ITEM* )>* aChangedItemHandler = nullptr,
672 PROGRESS_REPORTER* aProgressReporter = nullptr,
673 KIGFX::SCH_VIEW* aSchView = nullptr );
674
687 void RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags,
688 TOOL_MANAGER* aToolManager,
689 PROGRESS_REPORTER* aProgressReporter = nullptr,
690 KIGFX::SCH_VIEW* aSchView = nullptr,
691 std::function<void( SCH_ITEM* )>* aChangedItemHandler = nullptr,
692 PICKED_ITEMS_LIST* aLastChangeList = nullptr,
693 bool aCleanupDone = false );
694
702
709 bool Contains( const SCH_REFERENCE& aRef ) const;
710
712
723 wxArrayString GetVariantNamesForUI() const;
724
730 wxString GetCurrentVariant() const;
731
732 void SetCurrentVariant( const wxString& aVariantName );
733
740 void DeleteVariant( const wxString& aVariantName, SCH_COMMIT* aCommit );
741
742 void AddVariant( const wxString& aVariantName );
743
753 void RenameVariant( const wxString& aOldName, const wxString& aNewName, SCH_COMMIT* aCommit );
754
765 void CopyVariant( const wxString& aSourceVariant, const wxString& aNewVariant, SCH_COMMIT* aCommit );
766
770 const std::set<wxString>& GetVariantNames() const { return m_variantNames; }
771
775 bool HasVariant( const wxString& aVariantName ) const;
776
783 wxString GetVariantDescription( const wxString& aVariantName ) const;
784
791 void SetVariantDescription( const wxString& aVariantName, const wxString& aDescription );
792
799 void LoadVariants();
800
806 void DeleteVariantDefinition( const wxString& aVariantName );
807
815
816#if defined(DEBUG)
817 void Show( int nestLevel, std::ostream& os ) const override {}
818#endif
819
821
831 void SaveToHistory( const wxString& aProjectPath, std::vector<HISTORY_FILE_DATA>& aFileData );
832
837 std::weak_ptr<void> GetHistoryLifetimeToken() const { return m_historyLifetime; }
838
839private:
840 bool resolveCrossReference( wxString* aToken, int aDepth ) const;
841
842 friend class SCH_EDIT_FRAME;
843
844 template <typename Func, typename... Args>
845 void InvokeListeners( Func&& aFunc, Args&&... args )
846 {
847 for( auto&& l : m_listeners )
848 ( l->*aFunc )( std::forward<Args>( args )... );
849 }
850
851 void ensureVirtualRoot();
854 void rebuildHierarchyState( bool aResetConnectionGraph );
855
857 std::optional<IMPORT_NET_MAP> m_importNetMap;
858
860 std::shared_ptr<void> m_historyLifetime = std::make_shared<char>();
861
864
866 std::vector<SCH_SHEET*> m_topLevelSheets;
867
876
879 std::unique_ptr<SCH_CONNECTIVITY::FACADE> m_connectivity;
880 std::unique_ptr<SCH_CONNECTIVITY::NETCHAIN_MANAGER> m_netChains;
881
883
889 std::map<wxString, std::set<int>> m_labelToPageRefsMap;
890
894 std::map<wxString, wxString> m_properties;
895
899 std::map<wxString, double> m_operatingPoints;
900
905
907 std::unordered_map<KIID_PATH, wxString> m_refSuffixes;
908
910 std::unordered_map<size_t, wxString> m_refSuffixesBySheetHash;
912
914 void updatePackageSuffixes() const;
915
917 const wxString* findRefSuffix( const SCH_SHEET_PATH& aPath ) const;
918
920 std::optional<wxString> spanningPackageSuffix( const SCH_SYMBOL* aSymbol, const KIID_PATH& aPath ) const;
921
923 mutable std::map<std::pair<KIID, KIID_PATH>, wxString> m_packageSuffixes;
924
926 mutable std::map<std::pair<wxString, wxString>, std::map<int, wxString>> m_packageUnitSuffixes;
927
929 mutable std::set<KIID> m_unitSplitSymbols;
930 mutable std::optional<uint64_t> m_packageSuffixesGeneration;
931 mutable std::mutex m_packageSuffixesMutex;
932
934 std::vector<ERC_EXCLUSION> m_unresolvedErcExclusions;
935
939 std::vector<SCHEMATIC_LISTENER*> m_listeners;
940
945
947
949
950 std::vector<std::shared_ptr<BUS_ALIAS>> m_busAliases;
951
954
956
957 std::set<wxString> m_variantNames;
958
962
965 std::unique_ptr<class SCHEMATIC_TEXT_VAR_ADAPTER> m_textVarAdapter;
966
971
972public:
974};
975
976#endif
Calculate the connectivity of a schematic and generate netlists.
The base frame for deriving all KiCad main window classes.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
Implement an R-tree for fast spatial and type indexing of schematic items.
Definition sch_rtree.h:37
EMBEDDED_FILES()=default
Container for ERC settings.
Implement outline font drawing.
Definition kiid.h:46
Define a library symbol object.
Definition lib_symbol.h:114
A holder to handle information on schematic or board items.
A progress reporter interface for use in multi-threaded environments.
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
Definition project.h:90
Container for project specific data.
Definition project.h:63
ELEM
The set of _ELEM objects that a PROJECT can hold.
Definition project.h:69
Move-only RAII wrapper around a single listener registration.
This is a bridge class to help the schematic be able to affect SCH_EDIT_FRAME without doing anything ...
virtual void OnSchItemsRemoved(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
Definition schematic.h:87
virtual ~SCHEMATIC_LISTENER()
Definition schematic.h:85
virtual void OnSchItemsChanged(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
Definition schematic.h:88
virtual void OnSchSelectionChanged(SCHEMATIC &aSch)
Definition schematic.h:94
virtual void OnSchSheetChanged(SCHEMATIC &aSch)
Definition schematic.h:92
virtual void OnSchItemsAdded(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
Definition schematic.h:86
These are loaded from Eeschema settings but then overwritten by the project settings.
Bridges SCHEMATIC's listener stream into the generic TEXT_VAR_TRACKER.
Holds all the data relating to one schematic.
Definition schematic.h:155
void DeleteVariantDefinition(const wxString &aVariantName)
Delete the definition of a variant.
void SetCurrentVariant(const wxString &aVariantName)
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition schematic.h:404
bool m_settingTopLevelSheets
Re-entry guard to prevent infinite recursion between ensureDefaultTopLevelSheet and RefreshHierarchy ...
Definition schematic.h:961
std::unique_ptr< SCH_CONNECTIVITY::NETCHAIN_MANAGER > m_netChains
Definition schematic.h:880
void updatePackageSuffixes() const
Rebuild m_packageSuffixes when a reference changed; the caller holds m_packageSuffixesMutex.
wxString GetUnitRefSuffix(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPath, int aUnit) const
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
std::set< const SCH_SCREEN * > GetSchematicsSharedByMultipleProjects() const
Return a list of schematic files in the current project that contain instance data for multiple proje...
std::map< std::pair< KIID, KIID_PATH >, wxString > m_packageSuffixes
Package suffix of each instance whose package spans suffixes and is not its own sheet's.
Definition schematic.h:923
void CreateDefaultScreens()
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
void OnItemsAdded(std::vector< SCH_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
SCH_CONNECTIVITY::NETCHAIN_MANAGER & NetChains() const
Definition schematic.h:412
CONNECTION_GRAPH * m_connectionGraph
Hold and calculate connectivity information of this schematic.
Definition schematic.h:878
std::shared_ptr< void > m_historyLifetime
Sentinel whose expiry signals to LOCAL_HISTORY that this schematic has been destroyed.
Definition schematic.h:860
virtual wxString GetClass() const override
Return the class name.
Definition schematic.h:161
bool IsTopLevelSheet(const SCH_SHEET *aSheet) const
Check if a sheet is a top-level sheet (direct child of virtual root).
void loadBusAliasesFromProject()
std::unordered_map< size_t, wxString > m_refSuffixesBySheetHash
Every hierarchy path's suffix by its cached sheet path hash, which SCH_SHEET_PATH equality also relie...
Definition schematic.h:910
void AddTopLevelSheet(SCH_SHEET *aSheet)
Add a new top-level sheet to the schematic.
SCH_SHEET_LIST m_hierarchy
Cache of the entire schematic hierarchy sorted by sheet page number.
Definition schematic.h:904
@ TABLE_REMOVED
The reread file has no table; the one in use is kept, even empty, and saved back.
Definition schematic.h:448
@ CHANGED
The project table changed the aliases in use, so connectivity needs a rebuild.
Definition schematic.h:447
void rebuildHierarchyState(bool aResetConnectionGraph)
void ResolveERCExclusionsPostUpdate()
Update markers to match recorded exclusions.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
std::vector< SCH_MARKER * > ReloadERCExclusions()
Resolve exclusions again after the project file was reread.
void CacheExistingAnnotation()
Store all existing annotations in the REFDES_TRACKER.
wxString GetVariantDescription(const wxString &aVariantName) const
Return the description for a variant.
void LoadVariants()
This is a throw away method for variant testing.
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
void RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
const std::vector< std::shared_ptr< BUS_ALIAS > > & GetAllBusAliases() const
Definition schematic.h:457
bool HasVariant(const wxString &aVariantName) const
Return true if a variant with this name exists in the schematic (case-insensitively).
const wxString & GetHighlightedNetChain() const
Definition schematic.h:419
std::set< KIID > m_unitSplitSymbols
Symbols whose copies select different units.
Definition schematic.h:929
std::vector< std::pair< SCH_SHEET_PATH, SCH_SHEET_PATH > > RefSuffixCollisions(bool aIncludeEmpty) const
Find instances of one sheet file whose composed reference suffixes collide.
bool resolveCrossReference(wxString *aToken, int aDepth) const
bool IsComplexHierarchy() const
Test if the schematic is a complex hierarchy.
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
void SetSchematicHolder(SCHEMATIC_HOLDER *aHolder)
Definition schematic.h:655
SCH_SHEET_PATH * m_currentSheet
The sheet path of the sheet currently being edited or displayed.
Definition schematic.h:875
std::vector< SCH_SHEET * > m_topLevelSheets
List of top-level sheets (direct children of virtual root)
Definition schematic.h:866
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
void CleanUp(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void CopyVariant(const wxString &aSourceVariant, const wxString &aNewVariant, SCH_COMMIT *aCommit)
Copy a variant from aSourceVariant to aNewVariant.
bool TopLevelSheetsMatch(const std::vector< TOP_LEVEL_SHEET_INFO > &aSheets) const
Check a project file's top-level sheet list against the sheets this schematic loaded.
bool IsTopLevelSheetUuid(const KIID &aUuid) const
Check if a UUID names one of this schematic's top level sheets.
void OnItemsRemoved(std::vector< SCH_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
void AddVariant(const wxString &aVariantName)
void OnSchSelectionChanged()
Notify the schematic and its listeners that the editor selection has changed.
std::string FormatRefSuffixes() const
virtual ~SCHEMATIC()
void AdoptContent(SCHEMATIC_CONTENT &&aContent) noexcept
Take a staged schematic over from an importer in one indivisible step.
bool m_hasRefSuffixFields
Definition schematic.h:911
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aLabel) const
Return a pointer to a bus alias object for the given label, or null if one doesn't exist.
bool HasRefSuffixes() const
True when suffix numbering is enabled and a hierarchy path has a composed suffix.
Definition schematic.h:267
std::vector< SCH_MARKER * > ResolveERCExclusions()
void SaveToHistory(const wxString &aProjectPath, std::vector< HISTORY_FILE_DATA > &aFileData)
Serialize schematic sheets into HISTORY_FILE_DATA for non-blocking history commit.
const wxString * findRefSuffix(const SCH_SHEET_PATH &aPath) const
The cached suffix of aPath, or nullptr when it has none.
void EmbedFonts() override
Embed fonts in the schematic.
SCHEMATIC_SETTINGS & Settings() const
void ClearOperatingPoints()
Clear operating points from a .op simulation.
Definition schematic.h:526
wxString GetPackageRefSuffix(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPath) const
Return the suffix the package of a multi-unit symbol's instance composes with.
SCH_SCREEN * GetCurrentScreen() const
Definition schematic.h:409
wxString ConvertKIIDsToRefs(const wxString &aSource) const
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Definition schematic.h:276
void ensureVirtualRoot()
void ensureCurrentSheetIsTopLevel()
void SyncLibSymbolPinMaps(const wxString &aSchLibSymbolName, const LIB_SYMBOL &aSource, SCH_COMMIT *aCommit)
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
std::map< std::pair< wxString, wxString >, std::map< int, wxString > > m_packageUnitSuffixes
Sheet suffix of each placed unit of a package spanning suffixes, keyed by base and LIB_ID.
Definition schematic.h:926
wxString m_currentVariant
Definition schematic.h:955
std::map< wxString, std::set< int > > & GetPageRefsMap()
Definition schematic.h:478
SCH_SHEET_LIST BuildUnorderedSheetList() const
std::unordered_map< KIID_PATH, wxString > m_refSuffixes
Composed reference suffix of each hierarchy path that has one.
Definition schematic.h:907
class SCHEMATIC_TEXT_VAR_ADAPTER * GetTextVarAdapter() const
Definition schematic.h:973
void SetHighlightedNetChain(const wxString &aNetChain)
Definition schematic.h:420
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:177
std::map< wxString, std::set< int > > m_labelToPageRefsMap
Holds a map of labels to the page sequence (virtual page number) that they appear on.
Definition schematic.h:889
std::mutex m_packageSuffixesMutex
Definition schematic.h:931
bool HasHierarchy() const
Check if the hierarchy has been built.
Definition schematic.h:204
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
Get a set of fonts used in the schematic.
SCH_SHEET * GetTopLevelSheet(int aIndex=0) const
bool RemoveTopLevelSheet(SCH_SHEET *aSheet)
Remove a top-level sheet from the schematic.
std::optional< IMPORT_NET_MAP > m_importNetMap
Definition schematic.h:857
bool Contains(const SCH_REFERENCE &aRef) const
Check if the schematic contains the specified reference.
std::optional< wxString > spanningPackageSuffix(const SCH_SYMBOL *aSymbol, const KIID_PATH &aPath) const
The suffix of a package spanning sheets that aSymbol on aPath belongs to, if any.
const IMPORT_NET_MAP * GetImportNetMap() const
Definition schematic.h:169
void ClearUnresolvedERCExclusions(int aErrorCode=-1)
std::vector< ERC_EXCLUSION > m_unresolvedErcExclusions
Exclusions whose saved identity cannot currently be reconstructed as a marker.
Definition schematic.h:934
SCH_CONNECTIVITY::FACADE & Connectivity() const
Definition schematic.h:411
size_t GetUnresolvedERCExclusionCount() const
Definition schematic.h:557
wxString ConvertRefsToKIIDs(const wxString &aSource) const
void SetProject(PROJECT *aPrj)
void DeleteVariant(const wxString &aVariantName, SCH_COMMIT *aCommit)
Delete all information for aVariantName.
bool IsHierarchyModified() const
True when any sheet in the hierarchy has unsaved changes.
wxString GetCurrentVariant() const
Return the current variant being edited.
void AddListener(SCHEMATIC_LISTENER *aListener)
Add a listener to the schematic to receive calls whenever something on the schematic has been modifie...
void CleanUpConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, const std::set< SCH_SCREEN * > &aLocalScreens={})
std::map< int, wxString > GetVirtualPageToSheetPagesMap() const
EMBEDDED_FILES * GetEmbeddedFiles() override
wxString GetRefSuffix(const SCH_SHEET_PATH &aPath) const
Return the composed reference suffix of aPath as of the last RefreshHierarchy().
PROJECT * m_project
Definition schematic.h:856
CONNECTION_GRAPH * ConnectionGraph() const
Definition schematic.h:414
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
SCHEMATIC(PROJECT *aPrj)
Definition schematic.cpp:82
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
std::set< wxString > GetNetClassAssignmentCandidates()
Return the set of netname candidates for netclass assignment.
std::vector< std::shared_ptr< BUS_ALIAS > > m_busAliases
Definition schematic.h:950
bool ReloadProjectVariants()
Take the variant list from the project file again after it was reread.
void RefreshRefSuffixes()
Recompose the reference suffix of every sheet path in the hierarchy.
void InvokeListeners(Func &&aFunc, Args &&... args)
Definition schematic.h:845
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition schematic.h:384
void updateProjectBusAliases()
void SetVariantDescription(const wxString &aVariantName, const wxString &aDescription)
Set the description for a variant.
void RemoveAllListeners()
Remove all listeners.
std::optional< uint64_t > m_packageSuffixesGeneration
Definition schematic.h:930
void SetTopLevelSheets(const std::vector< SCH_SHEET * > &aSheets)
Replace the top level sheets, rebuilding the hierarchy and connectivity around them.
void RebuildConnectivity(std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr)
std::unique_ptr< class SCHEMATIC_TEXT_VAR_ADAPTER > m_textVarAdapter
Reactive text-variable dependency adapter.
Definition schematic.h:965
void RenameVariant(const wxString &aOldName, const wxString &aNewName, SCH_COMMIT *aCommit)
Rename a variant from aOldName to aNewName.
bool HasProjectBusAliases() const
PROPERTY_LISTENER_SUBSCRIPTION m_fieldListenerSubscription
PROPERTY_MANAGER listener subscription installed in the ctor.
Definition schematic.h:970
BUS_ALIAS_RELOAD ReloadProjectBusAliases()
Take the bus aliases from the project file again after it was reread.
const std::set< wxString > & GetVariantNames() const
Return the set of variant names (without the default placeholder).
Definition schematic.h:770
const std::map< wxString, wxString > * GetProperties()
Definition schematic.h:180
void GetContextualTextVars(wxArrayString *aVars) const
void SetOperatingPoint(const wxString &aNetChain, double aValue)
Set operating points from a .op simulation.
Definition schematic.h:536
friend class SCH_EDIT_FRAME
Definition schematic.h:842
void ensureDefaultTopLevelSheet()
SCH_SHEET & Root() const
Definition schematic.h:282
std::set< KIID > SplitUnitSymbols() const
Symbols whose copies select different units, for loops that change references as they go.
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER *aToolManager, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PICKED_ITEMS_LIST *aLastChangeList=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
std::vector< SCH_SHEET * > GetTopLevelSheets() const
Get the list of top-level sheets.
wxArrayString GetVariantNamesForUI() const
Return an array of variant names for using in wxWidgets UI controls.
bool CopiesSelectDifferentUnits(const SCH_SYMBOL *aSymbol) const
void RunOnNestedEmbeddedFiles(const std::function< void(EMBEDDED_FILES *)> &aFunction) override
Provide access to nested embedded files, such as symbols in schematics and footprints in boards.
std::unique_ptr< SCH_CONNECTIVITY::FACADE > m_connectivity
Definition schematic.h:879
SCHEMATIC_HOLDER * m_schematicHolder
What currently "Holds" the schematic, i.e.
Definition schematic.h:944
wxString GetUniqueFilenameForCurrentSheet()
Get the unique file name for the current sheet.
std::weak_ptr< void > GetHistoryLifetimeToken() const
Liveness token handed to LOCAL_HISTORY::RegisterSaver so a shared autosave timer skips this schematic...
Definition schematic.h:837
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SetImportNetMap(IMPORT_NET_MAP aMap)
Definition schematic.h:174
void SetBusAliases(const std::vector< std::shared_ptr< BUS_ALIAS > > &aAliases)
std::vector< SCHEMATIC_LISTENER * > m_listeners
Currently installed listeners.
Definition schematic.h:939
void AppendRefSuffix(wxString &aRef, const SCH_SHEET_PATH &aPath) const
Append the composed reference suffix of aPath to aRef without copying it.
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:399
bool m_busAliasesFromTable
The aliases in use came from a project table rather than from the sheets.
Definition schematic.h:953
std::vector< TOP_LEVEL_SHEET_INFO > TopLevelSheetInfos() const
The top-level sheets as the project file records them, with file names relative to the project.
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
wxString m_highlightedNetChain
Definition schematic.h:882
int FixupJunctionsAfterImport(const std::function< void(SCH_LINE *, SCH_LINE *)> &aOnSplit={})
Add junctions to this schematic where required.
KIID_PATH NormalizeInstancePath(const KIID_PATH &aPath) const
Strip the leading virtual root from a stored instance path, which SCH_SHEET_PATH::Path() omits but st...
std::map< wxString, double > m_operatingPoints
Simulation operating points for text variable substitution.
Definition schematic.h:899
std::map< wxString, wxString > m_properties
Properties for text variable substitution (and perhaps other uses in future).
Definition schematic.h:894
ERC_SETTINGS & ErcSettings() const
std::set< wxString > m_variantNames
Definition schematic.h:957
std::map< std::pair< KIID, KIID_PATH >, wxString > PackageRefSuffixes() const
Symbol and sheet path of each instance whose package suffix is another sheet's, with that suffix.
void RefreshHierarchy()
void OnItemsChanged(std::vector< SCH_ITEM * > &aItems)
Notify the schematic and its listeners that an item on the schematic has been modified in some way.
bool HasRefSuffixFields() const
True when a sheet in the hierarchy has suffix text, even text that resolves to nothing.
Definition schematic.h:264
static wxFileName TopLevelSheetFile(const TOP_LEVEL_SHEET_INFO &aSheet, const wxString &aProjectPath, bool aLegacy)
The file loaded for a listed top-level sheet. A legacy project reads it under the legacy extension.
PROJECT::ELEM ProjectElementType() override
Definition schematic.h:820
SCH_SHEET * m_rootSheet
The virtual root sheet (has no screen, contains all top-level sheets)
Definition schematic.h:863
bool IsInstancePathInProject(const KIID_PATH &aPath) const
Test whether an instance path is rooted in this schematic's top level sheets.
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
Model-owned source resolver.
Persistent chain configuration and the derived chains for one schematic.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:39
A helper to define a symbol's reference designator in a schematic.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:50
Schematic symbol object.
Definition sch_symbol.h:76
Master controller class:
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
Value keys and the key session of the schematic connectivity engine.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
SCH_CLEANUP_FLAGS
Definition schematic.h:98
@ LOCAL_CLEANUP
Definition schematic.h:100
@ NO_CLEANUP
Definition schematic.h:99
@ GLOBAL_CLEANUP
Definition schematic.h:101
Data produced by a registered saver on the UI thread, consumed by either the background local-history...
Import provenance, held only for the lifetime of the importing SCHEMATIC.
A schematic staged off to the side by an importer, ready to be swapped into a live SCHEMATIC in one s...
Definition schematic.h:115
std::optional< EMBEDDED_FILES > embeddedFiles
Definition schematic.h:143
std::unique_ptr< SCH_SCREEN > screen
Screen that replaces the target sheet's screen outright.
Definition schematic.h:121
std::optional< SCH_SHEET_PATH > currentSheet
Definition schematic.h:137
std::vector< std::unique_ptr< SCH_ITEM > > itemOwners
Items in screenItems that nothing else owns yet.
Definition schematic.h:131
SCH_SHEET_LIST hierarchy
Definition schematic.h:136
std::unique_ptr< CONNECTION_GRAPH > connectionGraph
Definition schematic.h:138
bool preserveNetChains
Keep the schematic's net chains instead of the staged graph's, for append.
Definition schematic.h:141
std::vector< SCH_SHEET * > topLevelSheets
Replacement top level sheets. Empty leaves the schematic's own in place.
Definition schematic.h:134
SCH_SHEET * targetSheet
Sheet whose screen receives the content. Null names the schematic's virtual root.
Definition schematic.h:117
std::unique_ptr< SCH_SCREEN > screenLibSymbols
Screen holding only the library cache that the target screen adopts.
Definition schematic.h:128
EE_RTREE screenItems
Spatial index that replaces the target screen's own.
Definition schematic.h:125
wxString drawingSheetFileName
Definition schematic.h:144
Information about a top-level schematic sheet.