KiCad PCB EDA Suite
SCH_SHEET_PATH Class Reference

SCH_SHEET_PATH. More...

#include <sch_sheet_path.h>

Public Member Functions

 SCH_SHEET_PATH ()
 Page numbers are maintained by the sheet load order. More...
 
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)
 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)
 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) const
 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
 

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

Constructor & Destructor Documentation

◆ SCH_SHEET_PATH()

SCH_SHEET_PATH::SCH_SHEET_PATH ( )

Page numbers are maintained by the sheet load order.

Definition at line 50 of file sch_sheet_path.cpp.

51 {
52  m_pageNumber = 0;
53  m_current_hash = 0;
54 }

References m_current_hash, and m_pageNumber.

Member Function Documentation

◆ at()

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

Forwarded method from std::vector.

Definition at line 122 of file sch_sheet_path.h.

122 { 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 125 of file sch_sheet_path.h.

126  {
127  m_sheets.clear();
128  Rehash();
129  }
std::vector< SCH_SHEET * > m_sheets

References m_sheets, and Rehash().

Referenced by SCH_EDIT_FRAME::CreateScreens(), SCH_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), 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 66 of file sch_sheet_path.cpp.

67 {
68  if( size() > aSheetPathToTest.size() )
69  return 1;
70 
71  if( size() < aSheetPathToTest.size() )
72  return -1;
73 
74  //otherwise, same number of sheets.
75  for( unsigned i = 0; i < size(); i++ )
76  {
77  if( at( i )->m_Uuid < aSheetPathToTest.at( i )->m_Uuid )
78  return -1;
79 
80  if( at( i )->m_Uuid != aSheetPathToTest.at( i )->m_Uuid )
81  return 1;
82  }
83 
84  return 0;
85 }
size_t size() const
Forwarded method from std::vector.
const KIID m_Uuid
Definition: base_struct.h:169
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 132 of file sch_sheet_path.h.

132 { 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 
)

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

186 {
187  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
188  {
189  auto component = static_cast<SCH_COMPONENT*>( item );
190 
191  // Skip pseudo components, which have a reference starting with #. This mainly
192  // affects power symbols.
193  if( aIncludePowerSymbols || component->GetRef( this )[0] != wxT( '#' ) )
194  {
195  LIB_PART* part = component->GetPartRef().get();
196 
197  if( part || aForceIncludeOrphanComponents )
198  {
199  SCH_REFERENCE schReference( component, part, *this );
200 
201  schReference.SetSheetNumber( m_pageNumber );
202  aReferences.AddItem( schReference );
203  }
204  }
205  }
206 }
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(), SCH_SHEET_LIST::GetComponents(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

◆ GetCurrentHash()

size_t SCH_SHEET_PATH::GetCurrentHash ( ) const
inline

Definition at line 153 of file sch_sheet_path.h.

153 { 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 
)

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

211 {
212  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
213  {
214  auto component = static_cast<SCH_COMPONENT*>( item );
215 
216  // Skip pseudo components, which have a reference starting with #. This mainly
217  // affects power symbols.
218  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
219  continue;
220 
221  LIB_PART* part = component->GetPartRef().get();
222 
223  if( part && part->GetUnitCount() > 1 )
224  {
225  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
226  schReference.SetSheetNumber( m_pageNumber );
227  wxString reference_str = schReference.GetRef();
228 
229  // Never lock unassigned references
230  if( reference_str[reference_str.Len() - 1] == '?' )
231  continue;
232 
233  aRefList[reference_str].AddItem( schReference );
234  }
235  }
236 }
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 157 of file sch_sheet_path.h.

157 { 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 145 of file sch_sheet_path.cpp.

146 {
147  // return a PathName for the root sheet (like "/" or "<root>"
148  // DO NOT use it in netlists, because it can easily break these netlists
149  // especially after translation, because many netlists (i.e. spice) do not accept any char
150  // Use only the short name ("/") and the full name only in messages
151  return aUseShortName ? wxT( "/" ) : _( "<root_sheet>" );
152 }
#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 159 of file sch_sheet_path.h.

160  {
161  SCH_SHEET* retv = NULL;
162 
163  if( aIndex < size() )
164  retv = at( aIndex );
165 
166  return const_cast< SCH_SHEET* >( retv );
167  }
#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:215
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

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

Referenced by SCH_SHEET_LIST::TestForRecursion().

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

89 {
90  if( !empty() )
91  return m_sheets.back();
92 
93  return nullptr;
94 }
std::vector< SCH_SHEET * > m_sheets
bool empty() const
Forwarded method from std::vector.

References empty(), and m_sheets.

Referenced by 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(), and SCH_EDIT_FRAME::ReCreateMenuBar().

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

98 {
99  SCH_SHEET* lastSheet = Last();
100 
101  if( lastSheet )
102  return lastSheet->GetScreen();
103 
104  return nullptr;
105 }
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()
Definition: sch_sheet.h:282
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215

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

Referenced by 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(), Diagnose(), SCH_EDIT_FRAME::DisplayCurrentSheet(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), SCH_EDITOR_CONTROL::FindComponentAndItem(), SCH_SHEET_LIST::FindSheetForScreen(), SCH_EDIT_FRAME::FixupJunctions(), GetComponents(), SCH_SHEET_LIST::GetItem(), GetMultiUnitComponents(), SCH_EDIT_FRAME::GetScreen(), SCH_EDIT_FRAME::HardRedraw(), SCH_EDIT_FRAME::importFile(), DIALOG_EDIT_COMPONENTS_LIBID::initDlg(), SCH_SHEET_LIST::IsModified(), SCH_EDIT_FRAME::LoadSheetFromFile(), DIALOG_ERC::OnERCItemSelected(), SCH_PRINTOUT::OnPrintPage(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::Paste(), CONNECTION_SUBGRAPH::ResolveDrivers(), SetComponentFootprint(), SCH_EDIT_FRAME::SetCurrentSheet(), SimilarLabelsDiagnose(), TestMultiunitFootprints(), DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow(), UpdateAllScreenReferences(), CONNECTION_GRAPH::updateItemConnectivity(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

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

109 {
110  SCH_SHEET* lastSheet = Last();
111 
112  if( lastSheet )
113  return lastSheet->GetScreen();
114 
115  return nullptr;
116 }
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()
Definition: sch_sheet.h:282
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215

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

◆ operator!=()

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

Definition at line 289 of file sch_sheet_path.h.

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

◆ operator<()

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

Definition at line 291 of file sch_sheet_path.h.

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

References m_sheets.

◆ operator==()

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

Definition at line 251 of file sch_sheet_path.cpp.

252 {
253  return m_current_hash == d1.GetCurrentHash();
254 }
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 134 of file sch_sheet_path.cpp.

135 {
136  KIID_PATH path;
137 
138  for( const SCH_SHEET* sheet : m_sheets )
139  path.push_back( sheet->m_Uuid );
140 
141  return path;
142 }
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:215

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(), 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 119 of file sch_sheet_path.cpp.

120 {
121  wxString s;
122 
123  s = wxT( "/" ); // This is the root path
124 
125  // Start at 1 to avoid the root sheet, which does not need to be added to the path.
126  // It's timestamp changes anyway.
127  for( unsigned i = 1; i < size(); i++ )
128  s += at( i )->m_Uuid.AsString() + "/";
129 
130  return s;
131 }
wxString AsString() const
Definition: common.cpp:170
size_t size() const
Forwarded method from std::vector.
const KIID m_Uuid
Definition: base_struct.h:169
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(), 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 155 of file sch_sheet_path.cpp.

156 {
157  wxString s;
158 
159  if( size() == 1 )
160  return GetRootPathName( true ); // Use only the short name in netlists
161 
162  s = wxT( "/" );
163 
164  // Start at 1 to avoid the root sheet, as above.
165  for( unsigned i = 1; i < size(); i++ )
166  s = s + at( i )->GetName() + wxT( "/" );
167 
168  return s;
169 }
static wxString GetRootPathName(bool aUseShortName=true)
wxString GetName() const
Definition: sch_sheet.h:280
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::GetName(), GetRootPathName(), and size().

Referenced by evalLabelsPriority(), SCH_SHEET::GetMsgPanelInfo(), NETLIST_OBJECT::GetNetName(), SCH_EDIT_FRAME::GetScreenDesc(), SCH_CONNECTION::Name(), 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 135 of file sch_sheet_path.h.

136  {
137  m_sheets.pop_back();
138  Rehash();
139  }
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 57 of file sch_sheet_path.cpp.

58 {
59  m_current_hash = 0;
60 
61  for( auto sheet : m_sheets )
62  boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() );
63 }
std::vector< SCH_SHEET * > m_sheets

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

241 {
242  SCH_SCREEN* screen = LastScreen();
243 
244  if( screen == NULL )
245  return false;
246 
247  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
248 }
#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.
Definition: sch_screen.cpp:848

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

155 { 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 
) const

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

259 {
260  wxFileName rootFn = g_RootSheet->GetFileName();
261  wxFileName srcFn = aSrcFileName;
262  wxFileName destFn = aDestFileName;
263 
264  if( srcFn.IsRelative() )
265  srcFn.MakeAbsolute( rootFn.GetPath() );
266 
267  if( destFn.IsRelative() )
268  destFn.MakeAbsolute( rootFn.GetPath() );
269 
270 
271  // The source and destination sheet file names cannot be the same.
272  if( srcFn == destFn )
273  return true;
274 
278  unsigned i = 0;
279 
280  while( i < size() )
281  {
282  wxFileName cmpFn = at( i )->GetFileName();
283 
284  if( cmpFn.IsRelative() )
285  cmpFn.MakeAbsolute( rootFn.GetPath() );
286 
287  // Test if the file name of the destination sheet is in anywhere in this sheet path.
288  if( cmpFn == destFn )
289  break;
290 
291  i++;
292  }
293 
294  // The destination sheet file name was not found in the sheet path or the destination
295  // sheet file name is the root sheet so no recursion is possible.
296  if( i >= size() || i == 0 )
297  return false;
298 
299  // Walk back up to the root sheet to see if the source file name is already a parent in
300  // the sheet path. If so, recursion will occur.
301  do
302  {
303  i -= 1;
304 
305  wxFileName cmpFn = at( i )->GetFileName();
306 
307  if( cmpFn.IsRelative() )
308  cmpFn.MakeAbsolute( rootFn.GetPath() );
309 
310  if( cmpFn == srcFn )
311  return true;
312 
313  } while( i != 0 );
314 
315  // The source sheet file name is not a parent of the destination sheet file name.
316  return false;
317 }
size_t size() const
Forwarded method from std::vector.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:491
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
SCH_SHEET * g_RootSheet

References at(), g_RootSheet, SCH_SHEET::GetFileName(), 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 172 of file sch_sheet_path.cpp.

173 {
174  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
175  {
176  auto component = static_cast<SCH_COMPONENT*>( item );
177  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
178  component->UpdateUnit( component->GetUnitSelection( this ) );
179  }
180 }
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 114 of file sch_sheet_path.h.

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

◆ m_pageNumber

int SCH_SHEET_PATH::m_pageNumber
protected

◆ m_sheets

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

Definition at line 112 of file sch_sheet_path.h.

Referenced by at(), clear(), empty(), Last(), operator<(), Path(), pop_back(), push_back(), Rehash(), and size().


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