KiCad PCB EDA Suite
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 (C) 2020 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 along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KICAD_SCHEMATIC_H
21 #define KICAD_SCHEMATIC_H
22 
23 #include <eda_item.h>
24 #include <sch_sheet_path.h>
25 #include <schematic_settings.h>
26 
27 
28 class BUS_ALIAS;
29 class CONNECTION_GRAPH;
30 class EDA_BASE_FRAME;
31 class ERC_SETTINGS;
32 class PROJECT;
33 class SCH_SCREEN;
34 class SCH_SHEET;
35 class SCH_SHEET_LIST;
36 
37 
44 class SCHEMATIC : public EDA_ITEM
45 {
46  friend class SCH_EDIT_FRAME;
47 
48 private:
50 
53 
61 
64 
69  std::map<wxString, std::set<wxString>> m_labelToPageRefsMap;
70 
71 public:
72  SCHEMATIC( PROJECT* aPrj );
73 
74  ~SCHEMATIC();
75 
76  virtual wxString GetClass() const override
77  {
78  return wxT( "SCHEMATIC" );
79  }
80 
82  void Reset();
83 
85  PROJECT& Prj() const
86  {
87  return *const_cast<PROJECT*>( m_project );
88  }
89 
90  void SetProject( PROJECT* aPrj );
91 
98  {
99  return SCH_SHEET_LIST( m_rootSheet );
100  }
101 
102  SCH_SHEET& Root() const
103  {
104  return *m_rootSheet;
105  }
106 
113  void SetRoot( SCH_SHEET* aRootSheet );
114 
116  bool IsValid() const
117  {
118  return m_rootSheet != nullptr;
119  }
120 
122  SCH_SCREEN* RootScreen() const;
123 
125  wxString GetFileName() const;
126 
128  {
129  return *m_currentSheet;
130  }
131 
132  void SetCurrentSheet( const SCH_SHEET_PATH& aPath )
133  {
134  *m_currentSheet = aPath;
135  }
136 
138  {
139  return m_connectionGraph;
140  }
141 
142  SCHEMATIC_SETTINGS& Settings() const;
143 
144  ERC_SETTINGS& ErcSettings() const;
145 
146  std::vector<SCH_MARKER*> ResolveERCExclusions();
147 
152  std::shared_ptr<BUS_ALIAS> GetBusAlias( const wxString& aLabel ) const;
153 
159  std::vector<wxString> GetNetClassAssignmentCandidates();
160 
166  bool ResolveCrossReference( wxString* token, int aDepth ) const;
167 
168  std::map<wxString, std::set<wxString>>& GetPageRefsMap() { return m_labelToPageRefsMap; }
169 
170  wxString ConvertRefsToKIIDs( const wxString& aSource ) const;
171  wxString ConvertKIIDsToRefs( const wxString& aSource ) const;
172 
177 
178 
179 #if defined(DEBUG)
180  void Show( int nestLevel, std::ostream& os ) const override {}
181 #endif
182 };
183 
184 #endif
std::vector< SCH_MARKER * > ResolveERCExclusions()
Definition: schematic.cpp:139
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
PROJECT holds project specific data.
Definition: project.h:63
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: schematic.h:76
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:44
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:137
SCH_SHEET_PATH * m_currentSheet
The sheet path of the sheet currently being edited or displayed.
Definition: schematic.h:60
SCHEMATIC(PROJECT *aPrj)
Definition: schematic.cpp:31
Calculates the connectivity of a schematic and generates netlists.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:125
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:116
Schematic editor (Eeschema) main window.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:119
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
Definition: schematic.h:63
std::map< wxString, std::set< wxString > > m_labelToPageRefsMap
Holds a map of labels to the page numbers that they appear on.
Definition: schematic.h:69
void SetRoot(SCH_SHEET *aRootSheet)
Initializes the schematic with a new root sheet.
Definition: schematic.cpp:100
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aLabel) const
Returns a pointer to a bus alias object for the given label, or null if one doesn't exist.
Definition: schematic.cpp:178
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:243
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:210
PROJECT * m_project
Definition: schematic.h:49
Container for ERC settings.
Definition: erc_settings.h:97
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:73
SCH_SHEET * m_rootSheet
The top-level sheet in this schematic hierarchy (or potentially the only one)
Definition: schematic.h:52
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:303
void Reset()
Initializes this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:50
SCH_SHEET & Root() const
Definition: schematic.h:102
The base frame for deriving all KiCad main window classes.
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:85
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
These settings were stored in SCH_BASE_FRAME previously.
std::map< wxString, std::set< wxString > > & GetPageRefsMap()
Definition: schematic.h:168
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:132
SCH_SCREEN * RootScreen() const
Helper to retreive the screen of the root sheet.
Definition: schematic.cpp:113
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< wxString > GetNetClassAssignmentCandidates()
Returns a list of name candidates for netclass assignment.
Definition: schematic.cpp:193
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:132
SCH_SHEET_LIST & GetFullHierarchy() const
Return the full schematic flattened hiearchical sheet list.
Definition: schematic.cpp:354
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:127