KiCad PCB EDA Suite
SCH_SHEET_PATH Class Reference

Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened schematic hierarchy. 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 SetVirtualPageNumber (int aPageNumber)
 Set the sheet instance virtual page number. More...
 
int GetVirtualPageNumber () const
 
void SetPageNumber (const wxString &aPageNumber)
 Set the sheet instance user definable page number. More...
 
wxString GetPageNumber () const
 
const SCH_SHEETGetSheet (unsigned aIndex) const
 
int Cmp (const SCH_SHEET_PATH &aSheetPathToTest) const
 Compare if this is the same sheet path as aSheetPathToTest. More...
 
SCH_SHEETLast () const
 Return a pointer to the last SCH_SHEET of the list. More...
 
SCH_SCREENLastScreen ()
 
SCH_SCREENLastScreen () const
 

More...
 
wxString PathAsString () const
 Return the path of time stamps which do not changes even when editing sheet parameters. More...
 
KIID_PATH Path () const
 Get the sheet path as an KIID_PATH. More...
 
KIID_PATH PathWithoutRootUuid () const
 Get the sheet path as an KIID_PATH without the root sheet UUID prefix. More...
 
wxString PathHumanReadable (bool aUseShortRootName=true) const
 Return the sheet path in a human readable form made from thesheet names. More...
 
void UpdateAllScreenReferences ()
 Update all the symbol references for this sheet path. More...
 
void GetSymbols (SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false) const
 Adds SCH_REFERENCE object to aReferences for each component in the sheet. More...
 
void GetMultiUnitComponents (SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
 Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sheet. More...
 
bool TestForRecursion (const wxString &aSrcFileName, const wxString &aDestFileName)
 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. 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
 

Protected Attributes

std::vector< SCH_SHEET * > m_sheets
 
size_t m_current_hash
 
int m_virtualPageNumber
 
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

Handle 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 130 of file sch_sheet_path.h.

Constructor & Destructor Documentation

◆ SCH_SHEET_PATH() [1/2]

SCH_SHEET_PATH::SCH_SHEET_PATH ( )

Definition at line 97 of file sch_sheet_path.cpp.

98 {
100  m_current_hash = 0;
101 }

References m_current_hash, and m_virtualPageNumber.

◆ SCH_SHEET_PATH() [2/2]

SCH_SHEET_PATH::SCH_SHEET_PATH ( const SCH_SHEET_PATH aOther)

Definition at line 104 of file sch_sheet_path.cpp.

105 {
106  initFromOther( aOther );
107 }
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 149 of file sch_sheet_path.h.

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

References m_sheets.

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

◆ clear()

void SCH_SHEET_PATH::clear ( )
inline

Forwarded method from std::vector.

Definition at line 152 of file sch_sheet_path.h.

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

References m_sheets, and Rehash().

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

◆ Cmp()

int SCH_SHEET_PATH::Cmp ( const SCH_SHEET_PATH aSheetPathToTest) const

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 137 of file sch_sheet_path.cpp.

138 {
139  if( size() > aSheetPathToTest.size() )
140  return 1;
141 
142  if( size() < aSheetPathToTest.size() )
143  return -1;
144 
145  //otherwise, same number of sheets.
146  for( unsigned i = 0; i < size(); i++ )
147  {
148  if( at( i )->m_Uuid < aSheetPathToTest.at( i )->m_Uuid )
149  return -1;
150 
151  if( at( i )->m_Uuid != aSheetPathToTest.at( i )->m_Uuid )
152  return 1;
153  }
154 
155  return 0;
156 }
size_t size() const
Forwarded method from std::vector.
const KIID m_Uuid
Definition: eda_item.h:151
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().

◆ empty()

bool SCH_SHEET_PATH::empty ( ) const
inline

Forwarded method from std::vector.

Definition at line 159 of file sch_sheet_path.h.

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

References m_sheets.

Referenced by Last(), and PathHumanReadable().

◆ GetCurrentHash()

size_t SCH_SHEET_PATH::GetCurrentHash ( ) const
inline

Definition at line 180 of file sch_sheet_path.h.

180 { 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

Add 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 289 of file sch_sheet_path.cpp.

291 {
292  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
293  {
294  auto component = static_cast<SCH_COMPONENT*>( item );
295 
296  // Skip pseudo components, which have a reference starting with #. This mainly
297  // affects power symbols.
298  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
299  continue;
300 
301  LIB_PART* part = component->GetPartRef().get();
302 
303  if( part && part->GetUnitCount() > 1 )
304  {
305  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
306  schReference.SetSheetNumber( m_virtualPageNumber );
307  wxString reference_str = schReference.GetRef();
308 
309  // Never lock unassigned references
310  if( reference_str[reference_str.Len() - 1] == '?' )
311  continue;
312 
313  aRefList[reference_str].AddItem( schReference );
314  }
315  }
316 }
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()
SCH_REFERENCE is used as a helper to define a symbol's reference designator in a schematic.

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

Referenced by SCH_EDIT_FRAME::AnnotateComponents().

◆ GetPageNumber()

wxString SCH_SHEET_PATH::GetPageNumber ( ) const

Definition at line 406 of file sch_sheet_path.cpp.

407 {
408  SCH_SHEET* sheet = Last();
409 
410  wxCHECK( sheet, wxEmptyString );
411 
412  return sheet->GetPageNumber( *this );
413 }
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
wxString GetPageNumber(const SCH_SHEET_PATH &aInstance) const
Return the sheet page number for aInstance.
Definition: sch_sheet.cpp:1074

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

Referenced by SCH_EDIT_TOOL::EditPageNumber(), SCH_NAVIGATE_TOOL::HypertextCommand(), and SCH_SHEET_LIST::SortByPageNumbers().

◆ GetSheet()

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

Definition at line 204 of file sch_sheet_path.h.

205  {
206  SCH_SHEET* retv = NULL;
207 
208  if( aIndex < size() )
209  retv = at( aIndex );
210 
211  return const_cast< SCH_SHEET* >( retv );
212  }
#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:219
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

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

Referenced by SCH_SHEET_LIST::TestForRecursion().

◆ GetSymbols()

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

Adds 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 264 of file sch_sheet_path.cpp.

266 {
267  for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
268  {
269  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
270 
271  // Skip pseudo components, which have a reference starting with #. This mainly
272  // affects power symbols.
273  if( aIncludePowerSymbols || component->GetRef( this )[0] != wxT( '#' ) )
274  {
275  LIB_PART* part = component->GetPartRef().get();
276 
277  if( part || aForceIncludeOrphanComponents )
278  {
279  SCH_REFERENCE schReference( component, part, *this );
280 
281  schReference.SetSheetNumber( m_virtualPageNumber );
282  aReferences.AddItem( schReference );
283  }
284  }
285  }
286 }
void AddItem(SCH_REFERENCE &aItem)
Define a library symbol object.
std::unique_ptr< LIB_PART > & GetPartRef()
SCH_SCREEN * LastScreen()
Schematic symbol object.
Definition: sch_component.h:79
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
SCH_REFERENCE is used as a helper to define a symbol's reference designator in a schematic.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.

References SCH_REFERENCE_LIST::AddItem(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetRef(), LastScreen(), m_virtualPageNumber, SCH_COMPONENT_T, and SCH_REFERENCE::SetSheetNumber().

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

◆ GetVirtualPageNumber()

int SCH_SHEET_PATH::GetVirtualPageNumber ( ) const
inline

Definition at line 193 of file sch_sheet_path.h.

193 { return m_virtualPageNumber; }

References m_virtualPageNumber.

◆ initFromOther()

void SCH_SHEET_PATH::initFromOther ( const SCH_SHEET_PATH aOther)
private

Definition at line 117 of file sch_sheet_path.cpp.

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

References m_current_hash, m_sheets, and m_virtualPageNumber.

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

◆ Last()

◆ LastScreen() [1/2]

SCH_SCREEN * SCH_SHEET_PATH::LastScreen ( )
Returns
the SCH_SCREEN relative to the last sheet in list.

Definition at line 168 of file sch_sheet_path.cpp.

169 {
170  SCH_SHEET* lastSheet = Last();
171 
172  if( lastSheet )
173  return lastSheet->GetScreen();
174 
175  return nullptr;
176 }
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:284
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219

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

Referenced by LIB_CONTROL::AddSymbolToSchematic(), SCH_EDIT_FRAME::AnnotateComponents(), SCH_SHEET_LIST::AnnotatePowerSymbols(), BACK_ANNOTATE::applyChangelist(), HIERARCHY_NAVIG_DLG::buildHierarchyTree(), 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(), SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_EDIT_TOOL::EditPageNumber(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckFloatingWires(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), SCH_SHEET_LIST::FillItemMap(), SCH_SHEET_LIST::FindSheetForScreen(), SCH_EDIT_FRAME::FixupJunctions(), SCH_SHEET_LIST::GetItem(), GetMultiUnitComponents(), SCH_EDIT_FRAME::GetScreen(), GetSymbols(), DIALOG_EDIT_COMPONENTS_LIBID::initDlg(), SCH_SHEET_LIST::IsModified(), SCH_EDIT_FRAME::LoadSheetFromFile(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_PRINTOUT::OnPrintPage(), DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), BACK_ANNOTATE::processNetNameChange(), DIALOG_CHANGE_SYMBOLS::processSymbol(), RESCUER::RESCUER(), CONNECTION_SUBGRAPH::ResolveDrivers(), SCH_EDIT_FRAME::ResolveERCExclusions(), SCH_EDIT_FRAME::SetCurrentSheet(), TestForRecursion(), ERC_TESTER::TestMultiunitFootprints(), ERC_TESTER::TestMultUnitPinConflicts(), ERC_TESTER::TestPinToPin(), ERC_TESTER::TestSimilarLabels(), UpdateAllScreenReferences(), CONNECTION_GRAPH::updateItemConnectivity(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ LastScreen() [2/2]

SCH_SCREEN * SCH_SHEET_PATH::LastScreen ( ) const

Returns
the SCH_SCREEN relative to the last sheet in list.

Definition at line 179 of file sch_sheet_path.cpp.

180 {
181  SCH_SHEET* lastSheet = Last();
182 
183  if( lastSheet )
184  return lastSheet->GetScreen();
185 
186  return nullptr;
187 }
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:284
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219

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

◆ operator!=()

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

Definition at line 317 of file sch_sheet_path.h.

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

◆ operator<()

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

Definition at line 319 of file sch_sheet_path.h.

319 { 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 110 of file sch_sheet_path.cpp.

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

References initFromOther().

◆ operator==()

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

Definition at line 319 of file sch_sheet_path.cpp.

320 {
321  return m_current_hash == d1.GetCurrentHash();
322 }
size_t GetCurrentHash() const

References GetCurrentHash(), and m_current_hash.

◆ Path()

◆ PathAsString()

wxString SCH_SHEET_PATH::PathAsString ( ) const

Return the path of 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 190 of file sch_sheet_path.cpp.

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

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

Referenced by SCH_REFERENCE::GetPath(), SCH_EAGLE_PLUGIN::loadInstance(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), NETLIST_EXPORTER_XML::makeSymbols(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ PathHumanReadable()

wxString SCH_SHEET_PATH::PathHumanReadable ( bool  aUseShortRootName = true) const

Return the sheet path in a human readable form made from thesheet names.

The the "normal" path instead uses the KIID objects in the path that do not change even when editing sheet parameters.

Definition at line 227 of file sch_sheet_path.cpp.

228 {
229  wxString s;
230  wxString fileName;
231 
232  if( !empty() && at( 0 )->GetScreen() )
233  fileName = at( 0 )->GetScreen()->GetFileName();
234 
235  wxFileName fn = fileName;
236 
237  if( aUseShortRootName )
238  s = wxT( "/" ); // Use only the short name in netlists
239  else
240  s = fn.GetName() + wxT( "/" );
241 
242  // Start at 1 since we've already processed the root sheet.
243  for( unsigned i = 1; i < size(); i++ )
244  s = s + at( i )->GetFields()[ SHEETNAME ].GetShownText() + wxT( "/" );
245 
246  return s;
247 }
const wxString & GetFileName() const
Definition: sch_screen.h:186
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:284
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:270
size_t size() const
Forwarded method from std::vector.
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
bool empty() const
Forwarded method from std::vector.

References at(), empty(), SCH_SHEET::GetFields(), SCH_SCREEN::GetFileName(), SCH_SHEET::GetScreen(), SHEETNAME, and size().

Referenced by SCH_EDIT_TOOL::EditPageNumber(), SCH_SHEET::GetMsgPanelInfo(), SCH_EDIT_FRAME::GetScreenDesc(), inheritNetclass(), NETLIST_EXPORTER_XML::makeSymbols(), DIALOG_SHEET_PROPERTIES::OnUpdateUI(), SCH_CONNECTION::recacheName(), and SCH_EDIT_FRAME::UpdateTitle().

◆ PathWithoutRootUuid()

KIID_PATH SCH_SHEET_PATH::PathWithoutRootUuid ( ) const

Get the sheet path as an KIID_PATH without the root sheet UUID prefix.

Note
This KIID_PATH does not include the root sheet UUID prefixed to the path.
Returns

Definition at line 216 of file sch_sheet_path.cpp.

217 {
218  KIID_PATH path;
219 
220  for( size_t i = 1; i < size(); i++ )
221  path.push_back( at( i )->m_Uuid );
222 
223  return path;
224 }
size_t size() const
Forwarded method from std::vector.
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), and size().

Referenced by SCH_SHEET_LIST::UpdateSheetInstances().

◆ pop_back()

void SCH_SHEET_PATH::pop_back ( )
inline

◆ push_back()

◆ Rehash()

void SCH_SHEET_PATH::Rehash ( )

Definition at line 128 of file sch_sheet_path.cpp.

129 {
130  m_current_hash = 0;
131 
132  for( auto sheet : m_sheets )
133  boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() );
134 }
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().

◆ SetPageNumber()

void SCH_SHEET_PATH::SetPageNumber ( const wxString &  aPageNumber)

Set the sheet instance user definable page number.

Note
User definable page numbers can be any string devoid of white space characters.

Definition at line 416 of file sch_sheet_path.cpp.

417 {
418  SCH_SHEET* sheet = Last();
419 
420  wxCHECK( sheet, /* void */ );
421 
422  sheet->SetPageNumber( *this, aPageNumber );
423 }
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1092
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219

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

Referenced by SCH_EDIT_TOOL::EditPageNumber().

◆ SetVirtualPageNumber()

void SCH_SHEET_PATH::SetVirtualPageNumber ( int  aPageNumber)
inline

Set the sheet instance virtual page number.

Virtual page numbers are incremental integers set automatically when the sheet path hierarchy is created (

See also
SCH_SHEET_LIST::BuildSheetList). The virtual page numbering is ordered by the X and Y position of the sheet in a schematic which mimics the page numbering code prior to the addition of actual user definable page numbers. Virtual page numbers should only be use when annotating schematics.

Definition at line 191 of file sch_sheet_path.h.

191 { m_virtualPageNumber = aPageNumber; }

References m_virtualPageNumber.

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

◆ size()

size_t SCH_SHEET_PATH::size ( ) const
inline

◆ TestForRecursion()

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

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 325 of file sch_sheet_path.cpp.

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

Update all the symbol references for this sheet path.

Mandatory in complex hierarchies because sheets may use the same screen (basic schematic) more than once but with different references and units according to the displayed sheet.

Definition at line 250 of file sch_sheet_path.cpp.

251 {
252  for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
253  {
254  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
255  component->GetField( REFERENCE_FIELD )->SetText( component->GetRef( this ) );
256  component->GetField( VALUE_FIELD )->SetText( component->GetValue( this, false ) );
257  component->GetField( FOOTPRINT_FIELD )->SetText( component->GetFootprint( this, false ) );
258  component->UpdateUnit( component->GetUnitSelection( this ) );
259  }
260 }
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
Field Value of part, i.e. "3.3K".
const wxString GetFootprint(const SCH_SHEET_PATH *sheet, bool aResolve) const
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Field Name Module PCB, i.e. "16DIP300".
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
SCH_SCREEN * LastScreen()
Schematic symbol object.
Definition: sch_component.h:79
Field Reference of part, i.e. "IC21".
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.

References FOOTPRINT_FIELD, SCH_COMPONENT::GetField(), SCH_COMPONENT::GetFootprint(), SCH_COMPONENT::GetRef(), SCH_COMPONENT::GetUnitSelection(), SCH_COMPONENT::GetValue(), LastScreen(), REFERENCE_FIELD, SCH_COMPONENT_T, EDA_TEXT::SetText(), SCH_COMPONENT::UpdateUnit(), and VALUE_FIELD.

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(), DIALOG_CHANGE_SYMBOLS::processMatchingSymbols(), ReannotateFromPCBNew(), and DIALOG_PLOT_SCHEMATIC::restoreEnvironment().

Member Data Documentation

◆ m_current_hash

size_t SCH_SHEET_PATH::m_current_hash
protected

Definition at line 135 of file sch_sheet_path.h.

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

◆ 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 139 of file sch_sheet_path.h.

Referenced by TestForRecursion().

◆ m_sheets

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

◆ m_virtualPageNumber

int SCH_SHEET_PATH::m_virtualPageNumber
protected

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