KiCad PCB EDA Suite
SCH_SHEET_PATH Class Reference

SCH_SHEET_PATH. More...

#include <sch_sheet_path.h>

Public Member Functions

 SCH_SHEET_PATH ()
 
 SCH_SHEET_PATH (const SCH_SHEET_PATH &aOther)
 
SCH_SHEET_PATHoperator= (const SCH_SHEET_PATH &aOther)
 
SCH_SHEETat (size_t aIndex) const
 Forwarded method from std::vector. More...
 
void clear ()
 Forwarded method from std::vector. More...
 
bool empty () const
 Forwarded method from std::vector. More...
 
void pop_back ()
 Forwarded method from std::vector. More...
 
void push_back (SCH_SHEET *aSheet)
 Forwarded method from std::vector. More...
 
size_t size () const
 Forwarded method from std::vector. More...
 
void Rehash ()
 
size_t GetCurrentHash () const
 
void SetPageNumber (int aPageNumber)
 
int GetPageNumber () const
 
const SCH_SHEETGetSheet (unsigned aIndex) const
 
int Cmp (const SCH_SHEET_PATH &aSheetPathToTest) const
 Function Cmp Compare if this is the same sheet path as aSheetPathToTest. More...
 
SCH_SHEETLast () const
 Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "path" to reach this last sheet. More...
 
SCH_SCREENLastScreen ()
 Function LastScreen. More...
 
SCH_SCREENLastScreen () const
 

More...
 
wxString PathAsString () const
 Function PathAsString the path uses the time stamps which do not changes even when editing sheet parameters a path is something like / (root) or /34005677 or /34005677/00AE4523. More...
 
KIID_PATH Path () const
 Get the sheet path as an KIID_PATH. More...
 
wxString PathHumanReadable () const
 Function PathHumanReadable returns the sheet path in a human readable form, i.e. More...
 
void UpdateAllScreenReferences ()
 Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) for all components on a screen depending on the actual sheet path. More...
 
void GetComponents (SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false) const
 Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet. More...
 
void GetMultiUnitComponents (SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
 Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sheet. More...
 
bool SetComponentFootprint (const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
 Function SetFootprintField searches last sheet in the path for a component with aReference and set the footprint field to aFootPrint if found. More...
 
bool TestForRecursion (const wxString &aSrcFileName, const wxString &aDestFileName)
 Function TestForRecursion. More...
 
bool operator== (const SCH_SHEET_PATH &d1) const
 
bool operator!= (const SCH_SHEET_PATH &d1) const
 
bool operator< (const SCH_SHEET_PATH &d1) const
 

Static Public Member Functions

static wxString GetRootPathName (bool aUseShortName=true)
 

Protected Attributes

std::vector< SCH_SHEET * > m_sheets
 
size_t m_current_hash
 
int m_pageNumber
 
std::map< std::pair< wxString, wxString >, bool > m_recursion_test_cache
 Page numbers are maintained by the sheet load order. More...
 

Private Member Functions

void initFromOther (const SCH_SHEET_PATH &aOther)
 

Detailed Description

SCH_SHEET_PATH.

handles access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened schematic hierarchy.

The SCH_SHEET objects are stored in a list from first (usually the root sheet) to a given sheet in last position. The last sheet is usually the sheet we want to select or reach (which is what the function Last() returns). Others sheets constitute the "path" from the first to the last sheet.

Definition at line 121 of file sch_sheet_path.h.

Constructor & Destructor Documentation

◆ SCH_SHEET_PATH() [1/2]

SCH_SHEET_PATH::SCH_SHEET_PATH ( )

Definition at line 99 of file sch_sheet_path.cpp.

100 {
101  m_pageNumber = 0;
102  m_current_hash = 0;
103 }

References m_current_hash, and m_pageNumber.

◆ SCH_SHEET_PATH() [2/2]

SCH_SHEET_PATH::SCH_SHEET_PATH ( const SCH_SHEET_PATH aOther)

Definition at line 106 of file sch_sheet_path.cpp.

107 {
108  initFromOther( aOther );
109 }
void initFromOther(const SCH_SHEET_PATH &aOther)

References initFromOther().

Member Function Documentation

◆ at()

SCH_SHEET* SCH_SHEET_PATH::at ( size_t  aIndex) const
inline

Forwarded method from std::vector.

Definition at line 140 of file sch_sheet_path.h.

140 { return m_sheets.at( aIndex ); }
std::vector< SCH_SHEET * > m_sheets

References m_sheets.

Referenced by Cmp(), GetSheet(), SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet(), PathAsString(), PathHumanReadable(), and TestForRecursion().

◆ clear()

void SCH_SHEET_PATH::clear ( )
inline

Forwarded method from std::vector.

Definition at line 143 of file sch_sheet_path.h.

144  {
145  m_sheets.clear();
146  Rehash();
147  }
std::vector< SCH_SHEET * > m_sheets

References m_sheets, and Rehash().

Referenced by SCH_EDIT_FRAME::OnCloseWindow(), SCHEMATIC::Reset(), SCHEMATIC::SetRoot(), and HIERARCHY_NAVIG_DLG::UpdateHierarchyTree().

◆ Cmp()

int SCH_SHEET_PATH::Cmp ( const SCH_SHEET_PATH aSheetPathToTest) const

Function Cmp Compare if this is the same sheet path as aSheetPathToTest.

Parameters
aSheetPathToTest= sheet path to compare
Returns
1 if this sheet path has more sheets than aSheetPathToTest, -1 if this sheet path has fewer sheets than aSheetPathToTest, or 0 if same

Definition at line 139 of file sch_sheet_path.cpp.

140 {
141  if( size() > aSheetPathToTest.size() )
142  return 1;
143 
144  if( size() < aSheetPathToTest.size() )
145  return -1;
146 
147  //otherwise, same number of sheets.
148  for( unsigned i = 0; i < size(); i++ )
149  {
150  if( at( i )->m_Uuid < aSheetPathToTest.at( i )->m_Uuid )
151  return -1;
152 
153  if( at( i )->m_Uuid != aSheetPathToTest.at( i )->m_Uuid )
154  return 1;
155  }
156 
157  return 0;
158 }
size_t size() const
Forwarded method from std::vector.
const KIID m_Uuid
Definition: base_struct.h:162
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), EDA_ITEM::m_Uuid, and size().

Referenced by SCH_REFERENCE_LIST::sortByTimeStamp(), and NETLIST_OBJECT_LIST::sortItemsBySheet().

◆ empty()

bool SCH_SHEET_PATH::empty ( ) const
inline

Forwarded method from std::vector.

Definition at line 150 of file sch_sheet_path.h.

150 { return m_sheets.empty(); }
std::vector< SCH_SHEET * > m_sheets

References m_sheets.

Referenced by Last().

◆ GetComponents()

void SCH_SHEET_PATH::GetComponents ( SCH_REFERENCE_LIST aReferences,
bool  aIncludePowerSymbols = true,
bool  aForceIncludeOrphanComponents = false 
) const

Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet.

Parameters
aReferencesList of references to populate.
aIncludePowerSymbols: false to only get normal components.
aForceIncludeOrphanComponents: true to include components having no symbol found in lib. ( orphan components) The normal option is false, and set to true only to build the full list of components.

Definition at line 257 of file sch_sheet_path.cpp.

259 {
260  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
261  {
262  auto component = static_cast<SCH_COMPONENT*>( item );
263 
264  // Skip pseudo components, which have a reference starting with #. This mainly
265  // affects power symbols.
266  if( aIncludePowerSymbols || component->GetRef( this )[0] != wxT( '#' ) )
267  {
268  LIB_PART* part = component->GetPartRef().get();
269 
270  if( part || aForceIncludeOrphanComponents )
271  {
272  SCH_REFERENCE schReference( component, part, *this );
273 
274  schReference.SetSheetNumber( m_pageNumber );
275  aReferences.AddItem( schReference );
276  }
277  }
278  }
279 }
void AddItem(SCH_REFERENCE &aItem)
Function AddItem adds a SCH_REFERENCE object to the list of references.
Define a library symbol object.
SCH_SCREEN * LastScreen()
Function LastScreen.
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.

References SCH_REFERENCE_LIST::AddItem(), LastScreen(), m_pageNumber, SCH_COMPONENT_T, and SCH_REFERENCE::SetSheetNumber().

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::CheckAnnotate(), CollectOtherUnits(), and SCH_SHEET_LIST::GetComponents().

◆ GetCurrentHash()

size_t SCH_SHEET_PATH::GetCurrentHash ( ) const
inline

Definition at line 171 of file sch_sheet_path.h.

171 { return m_current_hash; }

References m_current_hash.

Referenced by std::hash< SCH_SHEET_PATH >::operator()(), and operator==().

◆ GetMultiUnitComponents()

void SCH_SHEET_PATH::GetMultiUnitComponents ( SCH_MULTI_UNIT_REFERENCE_MAP aRefList,
bool  aIncludePowerSymbols = true 
) const

Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sheet.

The map key for each element will be the reference designator.

Parameters
aRefListMap of reference designators to reference lists
aIncludePowerSymbols: false to only get normal components.

Definition at line 282 of file sch_sheet_path.cpp.

284 {
285  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
286  {
287  auto component = static_cast<SCH_COMPONENT*>( item );
288 
289  // Skip pseudo components, which have a reference starting with #. This mainly
290  // affects power symbols.
291  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
292  continue;
293 
294  LIB_PART* part = component->GetPartRef().get();
295 
296  if( part && part->GetUnitCount() > 1 )
297  {
298  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
299  schReference.SetSheetNumber( m_pageNumber );
300  wxString reference_str = schReference.GetRef();
301 
302  // Never lock unassigned references
303  if( reference_str[reference_str.Len() - 1] == '?' )
304  continue;
305 
306  aRefList[reference_str].AddItem( schReference );
307  }
308  }
309 }
void SetSheetNumber(int aSheetNumber)
wxString GetRef() const
int GetUnitCount() const override
For items with units, return the number of units.
Define a library symbol object.
SCH_SCREEN * LastScreen()
Function LastScreen.
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.

References SCH_REFERENCE::GetRef(), LIB_PART::GetUnitCount(), LastScreen(), m_pageNumber, SCH_COMPONENT_T, and SCH_REFERENCE::SetSheetNumber().

Referenced by SCH_EDIT_FRAME::AnnotateComponents().

◆ GetPageNumber()

int SCH_SHEET_PATH::GetPageNumber ( ) const
inline

Definition at line 175 of file sch_sheet_path.h.

175 { return m_pageNumber; }

References m_pageNumber.

◆ GetRootPathName()

wxString SCH_SHEET_PATH::GetRootPathName ( bool  aUseShortName = true)
static
Returns
a PathName for the root sheet (like "/" or "<root>"
Parameters
aUseShortNametrue to return "/", false to return a longer name

Definition at line 218 of file sch_sheet_path.cpp.

219 {
220  // return a PathName for the root sheet (like "/" or "<root>"
221  // DO NOT use it in netlists, because it can easily break these netlists
222  // especially after translation, because many netlists (i.e. spice) do not accept any char
223  // Use only the short name ("/") and the full name only in messages
224  return aUseShortName ? wxT( "/" ) : _( "<root_sheet>" );
225 }
#define _(s)
Definition: 3d_actions.cpp:33

References _.

Referenced by PathHumanReadable().

◆ GetSheet()

const SCH_SHEET* SCH_SHEET_PATH::GetSheet ( unsigned  aIndex) const
inline

Definition at line 177 of file sch_sheet_path.h.

178  {
179  SCH_SHEET* retv = NULL;
180 
181  if( aIndex < size() )
182  retv = at( aIndex );
183 
184  return const_cast< SCH_SHEET* >( retv );
185  }
#define NULL
size_t size() const
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), NULL, and size().

Referenced by SCH_SHEET_LIST::TestForRecursion().

◆ initFromOther()

void SCH_SHEET_PATH::initFromOther ( const SCH_SHEET_PATH aOther)
private

Definition at line 119 of file sch_sheet_path.cpp.

120 {
121  m_sheets = aOther.m_sheets;
122  m_pageNumber = aOther.m_pageNumber;
124 
125  // Note: don't copy m_recursion_test_cache as it is slow and we want SCH_SHEET_PATHS to be
126  // very fast to construct for use in the connectivity algorithm.
127 }
std::vector< SCH_SHEET * > m_sheets

References m_current_hash, m_pageNumber, and m_sheets.

Referenced by operator=(), and SCH_SHEET_PATH().

◆ Last()

SCH_SHEET * SCH_SHEET_PATH::Last ( ) const

Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "path" to reach this last sheet.

Definition at line 161 of file sch_sheet_path.cpp.

162 {
163  if( !empty() )
164  return m_sheets.back();
165 
166  return nullptr;
167 }
std::vector< SCH_SHEET * > m_sheets
bool empty() const
Forwarded method from std::vector.

References empty(), and m_sheets.

Referenced by SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::Duplicate(), HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG(), SCH_DRAWING_TOOLS::Init(), EE_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), LastScreen(), SCH_EDITOR_CONTROL::LeaveSheet(), SCH_SHEET_LIST::NameExists(), SCH_EDITOR_CONTROL::Paste(), SCH_EDIT_FRAME::ReCreateMenuBar(), and SCH_EDIT_FRAME::SaveEEFile().

◆ LastScreen() [1/2]

SCH_SCREEN * SCH_SHEET_PATH::LastScreen ( )

Function LastScreen.

Returns
the SCH_SCREEN relative to the last sheet in list

Definition at line 170 of file sch_sheet_path.cpp.

171 {
172  SCH_SHEET* lastSheet = Last();
173 
174  if( lastSheet )
175  return lastSheet->GetScreen();
176 
177  return nullptr;
178 }
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216

References SCH_SHEET::GetScreen(), and Last().

Referenced by LIB_CONTROL::AddSymbolToSchematic(), SCH_SHEET_LIST::AnnotatePowerSymbols(), HIERARCHY_NAVIG_DLG::buildHierarchyTree(), NETLIST_OBJECT_LIST::BuildNetListInfo(), SCH_SHEET_LIST::BuildSheetList(), SCH_EDIT_FRAME::CheckSheetForRecursion(), SCH_SHEET_LIST::ClearModifyStatus(), DIALOG_PLOT_SCHEMATIC::CreateDXFFile(), DIALOG_PLOT_SCHEMATIC::createHPGLFile(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::createPSFile(), DIALOG_PLOT_SCHEMATIC::createSVGFile(), ERC_TESTER::diagnose(), SCH_EDIT_FRAME::DisplayCurrentSheet(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), SCH_SHEET_LIST::FillItemMap(), SCH_SHEET_LIST::FindSheetForScreen(), SCH_EDIT_FRAME::FixupJunctions(), GetComponents(), SCH_SHEET_LIST::GetItem(), GetMultiUnitComponents(), SCH_EDIT_FRAME::GetScreen(), DIALOG_EDIT_COMPONENTS_LIBID::initDlg(), SCH_SHEET_LIST::IsModified(), SCH_EDIT_FRAME::LoadSheetFromFile(), SCH_PRINTOUT::OnPrintPage(), DIALOG_SCH_SHEET_PROPS::onSheetFilenameChanged(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), RESCUER::RESCUER(), CONNECTION_SUBGRAPH::ResolveDrivers(), SetComponentFootprint(), SCH_EDIT_FRAME::SetCurrentSheet(), SimilarLabelsDiagnose(), TestForRecursion(), ERC_TESTER::TestMultiunitFootprints(), UpdateAllScreenReferences(), CONNECTION_GRAPH::updateItemConnectivity(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ LastScreen() [2/2]

SCH_SCREEN * SCH_SHEET_PATH::LastScreen ( ) const

Function LastScreen.

Returns
the SCH_SCREEN relative to the last sheet in list

Definition at line 181 of file sch_sheet_path.cpp.

182 {
183  SCH_SHEET* lastSheet = Last();
184 
185  if( lastSheet )
186  return lastSheet->GetScreen();
187 
188  return nullptr;
189 }
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216

References SCH_SHEET::GetScreen(), and Last().

◆ operator!=()

bool SCH_SHEET_PATH::operator!= ( const SCH_SHEET_PATH d1) const
inline

Definition at line 307 of file sch_sheet_path.h.

307 { return !( *this == d1 ) ; }

◆ operator<()

bool SCH_SHEET_PATH::operator< ( const SCH_SHEET_PATH d1) const
inline

Definition at line 309 of file sch_sheet_path.h.

309 { return m_sheets < d1.m_sheets; }
std::vector< SCH_SHEET * > m_sheets

References m_sheets.

◆ operator=()

SCH_SHEET_PATH & SCH_SHEET_PATH::operator= ( const SCH_SHEET_PATH aOther)

Definition at line 112 of file sch_sheet_path.cpp.

113 {
114  initFromOther( aOther );
115  return *this;
116 }
void initFromOther(const SCH_SHEET_PATH &aOther)

References initFromOther().

◆ operator==()

bool SCH_SHEET_PATH::operator== ( const SCH_SHEET_PATH d1) const

Definition at line 324 of file sch_sheet_path.cpp.

325 {
326  return m_current_hash == d1.GetCurrentHash();
327 }
size_t GetCurrentHash() const

References GetCurrentHash(), and m_current_hash.

◆ Path()

KIID_PATH SCH_SHEET_PATH::Path ( ) const

Get the sheet path as an KIID_PATH.

Returns

Definition at line 207 of file sch_sheet_path.cpp.

208 {
209  KIID_PATH path;
210 
211  for( const SCH_SHEET* sheet : m_sheets )
212  path.push_back( sheet->m_Uuid );
213 
214  return path;
215 }
std::vector< SCH_SHEET * > m_sheets
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216

References m_sheets.

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_COMPONENT::ClearAnnotation(), countIndenticalLabels(), SCH_COMPONENT::GetRef(), SCH_COMPONENT::GetUnitSelection(), SCH_COMPONENT::IsAnnotated(), SCH_REFERENCE::IsSameInstance(), SCH_EAGLE_PLUGIN::loadSchematic(), SCH_EDIT_FRAME::mapExistingAnnotation(), compare_paths::operator()(), SCH_COMPONENT::SetRef(), SCH_EDIT_FRAME::SetSheetNumberAndCount(), and SCH_COMPONENT::SetUnitSelection().

◆ PathAsString()

wxString SCH_SHEET_PATH::PathAsString ( ) const

Function PathAsString the path uses the time stamps which do not changes even when editing sheet parameters a path is something like / (root) or /34005677 or /34005677/00AE4523.

Definition at line 192 of file sch_sheet_path.cpp.

193 {
194  wxString s;
195 
196  s = wxT( "/" ); // This is the root path
197 
198  // Start at 1 to avoid the root sheet, which does not need to be added to the path.
199  // It's timestamp changes anyway.
200  for( unsigned i = 1; i < size(); i++ )
201  s += at( i )->m_Uuid.AsString() + "/";
202 
203  return s;
204 }
wxString AsString() const
Definition: common.cpp:165
size_t size() const
Forwarded method from std::vector.
const KIID m_Uuid
Definition: base_struct.h:162
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References KIID::AsString(), at(), EDA_ITEM::m_Uuid, and size().

Referenced by BACK_ANNOTATE::applyChangelist(), SCH_REFERENCE::GetPath(), SCH_EAGLE_PLUGIN::loadInstance(), NETLIST_EXPORTER_GENERIC::makeComponents(), and compare_labels::operator()().

◆ PathHumanReadable()

wxString SCH_SHEET_PATH::PathHumanReadable ( ) const

Function PathHumanReadable returns the sheet path in a human readable form, i.e.

as a path made from sheet names. The the "normal" path instead uses the time stamps in the path. (Time stamps do not change even when editing sheet parameters).

Definition at line 228 of file sch_sheet_path.cpp.

229 {
230  wxString s;
231 
232  if( size() == 1 )
233  return GetRootPathName( true ); // Use only the short name in netlists
234 
235  s = wxT( "/" );
236 
237  // Start at 1 to avoid the root sheet, as above.
238  for( unsigned i = 1; i < size(); i++ )
239  s = s + at( i )->GetFields()[ SHEETNAME ].GetShownText() + wxT( "/" );
240 
241  return s;
242 }
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
static wxString GetRootPathName(bool aUseShortName=true)
size_t size() const
Forwarded method from std::vector.
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), SCH_SHEET::GetFields(), GetRootPathName(), SHEETNAME, and size().

Referenced by evalLabelsPriority(), NETLIST_OBJECT::GetNetName(), SCH_EDIT_FRAME::GetScreenDesc(), NETLIST_EXPORTER_GENERIC::makeComponents(), SCH_CONNECTION::recacheName(), DIALOG_SCH_SHEET_PROPS::TransferDataToWindow(), and SCH_EDIT_FRAME::UpdateTitle().

◆ pop_back()

void SCH_SHEET_PATH::pop_back ( )
inline

Forwarded method from std::vector.

Definition at line 153 of file sch_sheet_path.h.

154  {
155  m_sheets.pop_back();
156  Rehash();
157  }
std::vector< SCH_SHEET * > m_sheets

References m_sheets, and Rehash().

Referenced by HIERARCHY_NAVIG_DLG::buildHierarchyTree(), SCH_SHEET_LIST::BuildSheetList(), SCH_EDITOR_CONTROL::LeaveSheet(), SCH_SHEET::LocatePathOfScreen(), and CONNECTION_GRAPH::propagateToNeighbors().

◆ push_back()

◆ Rehash()

void SCH_SHEET_PATH::Rehash ( )

Definition at line 130 of file sch_sheet_path.cpp.

131 {
132  m_current_hash = 0;
133 
134  for( auto sheet : m_sheets )
135  boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() );
136 }
static void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
Definition: hash_eda.h:64
std::vector< SCH_SHEET * > m_sheets

References hash_combine(), m_current_hash, and m_sheets.

Referenced by clear(), pop_back(), and push_back().

◆ SetComponentFootprint()

bool SCH_SHEET_PATH::SetComponentFootprint ( const wxString &  aReference,
const wxString &  aFootPrint,
bool  aSetVisible 
)

Function SetFootprintField searches last sheet in the path for a component with aReference and set the footprint field to aFootPrint if found.

Parameters
aReferenceThe reference designator of the component.
aFootPrintThe value to set the footprint field.
aSetVisibleThe value to set the field visibility flag.
Returns
true if aReference was found otherwise false.

Definition at line 312 of file sch_sheet_path.cpp.

314 {
315  SCH_SCREEN* screen = LastScreen();
316 
317  if( screen == NULL )
318  return false;
319 
320  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
321 }
#define NULL
SCH_SCREEN * LastScreen()
Function LastScreen.
bool SetComponentFootprint(SCH_SHEET_PATH *aSheetPath, const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Search this screen for a symbol with aReference and set the footprint field to aFootPrint if found.

References LastScreen(), NULL, and SCH_SCREEN::SetComponentFootprint().

Referenced by SCH_SHEET_LIST::SetComponentFootprint().

◆ SetPageNumber()

void SCH_SHEET_PATH::SetPageNumber ( int  aPageNumber)
inline

Definition at line 173 of file sch_sheet_path.h.

173 { m_pageNumber = aPageNumber; }

References m_pageNumber.

Referenced by SCH_SHEET_LIST::BuildSheetList(), and SCH_EDIT_FRAME::SetSheetNumberAndCount().

◆ size()

size_t SCH_SHEET_PATH::size ( ) const
inline

◆ TestForRecursion()

bool SCH_SHEET_PATH::TestForRecursion ( const wxString &  aSrcFileName,
const wxString &  aDestFileName 
)

Function TestForRecursion.

test the SCH_SHEET_PATH file names to check adding the sheet stored in the file aSrcFileName to the sheet stored in file aDestFileName will cause a sheet path recursion.

Parameters
aSrcFileNameis the source file name of the sheet add to aDestFileName.
aDestFileNameis the file name of the destination sheet for aSrcFileName.
Returns
true if aFileName will cause recursion in the sheet path. Otherwise false.
Todo:
Store sheet file names with full path, either relative to project path or absolute path. The current design always assumes subsheet files are located in the project folder which may or may not be desirable.

Definition at line 330 of file sch_sheet_path.cpp.

331 {
332  auto pair = std::make_pair( aSrcFileName, aDestFileName );
333 
334  if( m_recursion_test_cache.count( pair ) )
335  return m_recursion_test_cache.at( pair );
336 
337  SCHEMATIC* sch = LastScreen()->Schematic();
338 
339  wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_PATH::TestForRecursion!" );
340 
341  wxFileName rootFn = sch->GetFileName();
342  wxFileName srcFn = aSrcFileName;
343  wxFileName destFn = aDestFileName;
344 
345  if( srcFn.IsRelative() )
346  srcFn.MakeAbsolute( rootFn.GetPath() );
347 
348  if( destFn.IsRelative() )
349  destFn.MakeAbsolute( rootFn.GetPath() );
350 
351 
352  // The source and destination sheet file names cannot be the same.
353  if( srcFn == destFn )
354  {
355  m_recursion_test_cache[pair] = true;
356  return true;
357  }
358 
362  unsigned i = 0;
363 
364  while( i < size() )
365  {
366  wxFileName cmpFn = at( i )->GetFileName();
367 
368  if( cmpFn.IsRelative() )
369  cmpFn.MakeAbsolute( rootFn.GetPath() );
370 
371  // Test if the file name of the destination sheet is in anywhere in this sheet path.
372  if( cmpFn == destFn )
373  break;
374 
375  i++;
376  }
377 
378  // The destination sheet file name was not found in the sheet path or the destination
379  // sheet file name is the root sheet so no recursion is possible.
380  if( i >= size() || i == 0 )
381  {
382  m_recursion_test_cache[pair] = false;
383  return false;
384  }
385 
386  // Walk back up to the root sheet to see if the source file name is already a parent in
387  // the sheet path. If so, recursion will occur.
388  do
389  {
390  i -= 1;
391 
392  wxFileName cmpFn = at( i )->GetFileName();
393 
394  if( cmpFn.IsRelative() )
395  cmpFn.MakeAbsolute( rootFn.GetPath() );
396 
397  if( cmpFn == srcFn )
398  {
399  m_recursion_test_cache[pair] = true;
400  return true;
401  }
402 
403  } while( i != 0 );
404 
405  // The source sheet file name is not a parent of the destination sheet file name.
406  m_recursion_test_cache[pair] = false;
407  return false;
408 }
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
std::map< std::pair< wxString, wxString >, bool > m_recursion_test_cache
Page numbers are maintained by the sheet load order.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:132
size_t size() const
Forwarded method from std::vector.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:496
SCH_SCREEN * LastScreen()
Function LastScreen.
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:93
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), SCHEMATIC::GetFileName(), SCH_SHEET::GetFileName(), LastScreen(), m_recursion_test_cache, SCH_SCREEN::Schematic(), and size().

Referenced by SCH_SHEET_LIST::BuildSheetList().

◆ UpdateAllScreenReferences()

void SCH_SHEET_PATH::UpdateAllScreenReferences ( )

Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) for all components on a screen depending on the actual sheet path.

Mandatory in complex hierarchies because sheets use the same screen (basic schematic) but with different references and part selections according to the displayed sheet

Definition at line 245 of file sch_sheet_path.cpp.

246 {
247  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
248  {
249  auto component = static_cast<SCH_COMPONENT*>( item );
250  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
251  component->UpdateUnit( component->GetUnitSelection( this ) );
252  }
253 }
Field Reference of part, i.e. "IC21".
SCH_SCREEN * LastScreen()
Function LastScreen.

References LastScreen(), REFERENCE, and SCH_COMPONENT_T.

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), DIALOG_PLOT_SCHEMATIC::CreateDXFFile(), DIALOG_PLOT_SCHEMATIC::createHPGLFile(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::createPSFile(), DIALOG_PLOT_SCHEMATIC::createSVGFile(), SCH_EDIT_FRAME::DeleteAnnotation(), SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_EDITOR_CONTROL::FindNext(), SCH_EDIT_FRAME::FixupJunctions(), DIALOG_MIGRATE_BUSES::onItemSelected(), SCH_PRINTOUT::OnPrintPage(), DIALOG_UPDATE_FROM_PCB::OnUpdateClick(), and DIALOG_PLOT_SCHEMATIC::restoreEnvironment().

Member Data Documentation

◆ m_current_hash

size_t SCH_SHEET_PATH::m_current_hash
protected

Definition at line 126 of file sch_sheet_path.h.

Referenced by GetCurrentHash(), initFromOther(), operator==(), Rehash(), and SCH_SHEET_PATH().

◆ m_pageNumber

int SCH_SHEET_PATH::m_pageNumber
protected

◆ m_recursion_test_cache

std::map<std::pair<wxString, wxString>, bool> SCH_SHEET_PATH::m_recursion_test_cache
protected

Page numbers are maintained by the sheet load order.

Definition at line 130 of file sch_sheet_path.h.

Referenced by TestForRecursion().

◆ m_sheets

std::vector< SCH_SHEET* > SCH_SHEET_PATH::m_sheets
protected

The documentation for this class was generated from the following files: