KiCad PCB EDA Suite
SCH_SHEET_PATH Class Reference

Class 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
 
SCH_SHEETGetSheet (unsigned aIndex)
 
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 () const
 Function LastScreen. More...
 
SCH_ITEMLastDrawList () const
 Function LastDrawList. More...
 
SCH_ITEMFirstDrawList () const
 Get the last schematic item relative to the first sheet in the list. More...
 
wxString Path () const
 Function Path 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...
 
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...
 
SCH_ITEMFindNextItem (KICAD_T aType, SCH_ITEM *aLastItem=NULL, bool aWrap=false) const
 Find the next schematic item in this sheet object. More...
 
SCH_ITEMFindPreviousItem (KICAD_T aType, SCH_ITEM *aLastItem=NULL, bool aWrap=false) const
 Find the previous schematic item in this sheet path object. More...
 
bool TestForRecursion (const wxString &aSrcFileName, const wxString &aDestFileName) const
 Function TestForRecursion. More...
 
int FindSheet (const wxString &aFileName) const
 
SCH_SHEETFindSheetByName (const wxString &aSheetName)
 Function FindSheetByName. More...
 
SCH_SHEETFindSheetByPageNumber (int aPageNumber)
 Function FindSheetByPageNumber. 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

Class 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 112 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 59 of file sch_sheet_path.cpp.

60 {
61  m_pageNumber = 0;
62  m_current_hash = 0;
63 }

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

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

References m_sheets.

Referenced by Cmp(), FindSheet(), FindSheetByName(), FirstDrawList(), GetSheet(), Last(), Path(), PathHumanReadable(), and TestForRecursion().

◆ clear()

void SCH_SHEET_PATH::clear ( )
inline

Forwarded method from std::vector.

Definition at line 128 of file sch_sheet_path.h.

129  {
130  m_sheets.clear();
131  Rehash();
132  }
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(), and SCH_EDIT_FRAME::OpenProjectFiles().

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

76 {
77  if( size() > aSheetPathToTest.size() )
78  return 1;
79 
80  if( size() < aSheetPathToTest.size() )
81  return -1;
82 
83  //otherwise, same number of sheets.
84  for( unsigned i = 0; i < size(); i++ )
85  {
86  if( at( i )->GetTimeStamp() > aSheetPathToTest.at( i )->GetTimeStamp() )
87  return 1;
88 
89  if( at( i )->GetTimeStamp() < aSheetPathToTest.at( i )->GetTimeStamp() )
90  return -1;
91  }
92 
93  return 0;
94 }
size_t size() const
Forwarded method from std::vector.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:216
size_t i
Definition: json11.cpp:597
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), EDA_ITEM::GetTimeStamp(), i, 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 135 of file sch_sheet_path.h.

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

References m_sheets.

Referenced by FirstDrawList(), and Last().

◆ FindNextItem()

SCH_ITEM * SCH_SHEET_PATH::FindNextItem ( KICAD_T  aType,
SCH_ITEM aLastItem = NULL,
bool  aWrap = false 
) const

Find the next schematic item in this sheet object.

Parameters
aType- The type of schematic item object to search for.
aLastItem- Start search from aLastItem. If no aLastItem, search from the beginning of the list.
aWrap- Wrap around the end of the list to find the next item if aLastItem is defined.
Returns
- The next schematic item if found. Otherwise, NULL is returned.

Definition at line 277 of file sch_sheet_path.cpp.

278 {
279  bool hasWrapped = false;
280  bool firstItemFound = false;
281  SCH_ITEM* drawItem = LastDrawList();
282 
283  while( drawItem )
284  {
285  if( drawItem->Type() == aType )
286  {
287  if( !aLastItem || firstItemFound )
288  {
289  return drawItem;
290  }
291  else if( !firstItemFound && drawItem == aLastItem )
292  {
293  firstItemFound = true;
294  }
295  }
296 
297  drawItem = drawItem->Next();
298 
299  if( !drawItem && aLastItem && aWrap && !hasWrapped )
300  {
301  hasWrapped = true;
302  drawItem = LastDrawList();
303  }
304  }
305 
306  return NULL;
307 }
SCH_ITEM * Next() const
Definition: sch_item.h:153
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

References LastDrawList(), SCH_ITEM::Next(), and EDA_ITEM::Type().

◆ FindPreviousItem()

SCH_ITEM * SCH_SHEET_PATH::FindPreviousItem ( KICAD_T  aType,
SCH_ITEM aLastItem = NULL,
bool  aWrap = false 
) const

Find the previous schematic item in this sheet path object.

Parameters
aType- The type of schematic item object to search for.
aLastItem- Start search from aLastItem. If no aLastItem, search from the end of the list.
aWrap- Wrap around the beginning of the list to find the next item if aLastItem is defined.
Returns
- The previous schematic item if found. Otherwise, NULL is returned.

Definition at line 310 of file sch_sheet_path.cpp.

311 {
312  bool hasWrapped = false;
313  bool firstItemFound = false;
314  SCH_ITEM* drawItem = FirstDrawList();
315 
316  while( drawItem )
317  {
318  if( drawItem->Type() == aType )
319  {
320  if( aLastItem == NULL || firstItemFound )
321  {
322  return drawItem;
323  }
324  else if( !firstItemFound && drawItem == aLastItem )
325  {
326  firstItemFound = true;
327  }
328  }
329 
330  drawItem = drawItem->Back();
331 
332  if( drawItem == NULL && aLastItem && aWrap && !hasWrapped )
333  {
334  hasWrapped = true;
335  drawItem = FirstDrawList();
336  }
337  }
338 
339  return NULL;
340 }
SCH_ITEM * FirstDrawList() const
Get the last schematic item relative to the first sheet in the list.
SCH_ITEM * Back() const
Definition: sch_item.h:154
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

References SCH_ITEM::Back(), FirstDrawList(), and EDA_ITEM::Type().

◆ FindSheet()

int SCH_SHEET_PATH::FindSheet ( const wxString &  aFileName) const

Definition at line 424 of file sch_sheet_path.cpp.

425 {
426  for( unsigned i = 0; i < size(); i++ )
427  {
428  if( at( i )->GetFileName().CmpNoCase( aFileName ) == 0 )
429  return (int)i;
430  }
431 
432  return SHEET_NOT_FOUND;
433 }
#define SHEET_NOT_FOUND
size_t size() const
Forwarded method from std::vector.
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:629
size_t i
Definition: json11.cpp:597
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), SCH_SHEET::GetFileName(), i, SHEET_NOT_FOUND, and size().

◆ FindSheetByName()

SCH_SHEET * SCH_SHEET_PATH::FindSheetByName ( const wxString &  aSheetName)

Function FindSheetByName.

searches the SCH_SHEET_PATH for a sheet named aSheetName.

Parameters
aSheetNameis the name of the sheet to find.
Returns
a pointer to the sheet named aSheetName if found or NULL if not found.

Definition at line 436 of file sch_sheet_path.cpp.

437 {
438  for( unsigned i = 0; i < size(); i++ )
439  {
440  if( at( i )->GetName().CmpNoCase( aSheetName ) == 0 )
441  return at( i );
442  }
443 
444  return NULL;
445 }
wxString GetName() const
Definition: sch_sheet.h:262
size_t size() const
Forwarded method from std::vector.
size_t i
Definition: json11.cpp:597
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), SCH_SHEET::GetName(), i, and size().

◆ FindSheetByPageNumber()

SCH_SHEET* SCH_SHEET_PATH::FindSheetByPageNumber ( int  aPageNumber)

Function FindSheetByPageNumber.

searches the SCH_SHEET_LIST for a sheet with aPageNumber.

Parameters
aPageNumberis the number of the sheet to find.
Returns
a pointer to a SCH_SHEET object page aPageNumber if found or NULL if not found.

◆ FirstDrawList()

SCH_ITEM * SCH_SHEET_PATH::FirstDrawList ( ) const

Get the last schematic item relative to the first sheet in the list.

Returns
Last schematic item relative to the first sheet in the list if list is not empty. Otherwise NULL.

Definition at line 128 of file sch_sheet_path.cpp.

129 {
130  SCH_ITEM* item = NULL;
131 
132  if( !empty() && at( 0 )->GetScreen() )
133  item = at( 0 )->GetScreen()->GetDrawItems();
134 
135  /* @fixme - These lists really should be one of the boost pointer containers. This
136  * is a brain dead hack to allow reverse iteration of EDA_ITEM linked
137  * list.
138  */
139  SCH_ITEM* lastItem = NULL;
140 
141  while( item )
142  {
143  lastItem = item;
144  item = item->Next();
145  }
146 
147  return lastItem;
148 }
SCH_ITEM * Next() const
Definition: sch_item.h:153
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:271
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
bool empty() const
Forwarded method from std::vector.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:147

References at(), empty(), SCH_SCREEN::GetDrawItems(), SCH_SHEET::GetScreen(), and SCH_ITEM::Next().

Referenced by FindPreviousItem().

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

217 {
218  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
219  {
220  if( item->Type() == SCH_COMPONENT_T )
221  {
222  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
223 
224  // Skip pseudo components, which have a reference starting with #. This mainly
225  // affects power symbols.
226  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
227  continue;
228 
229  LIB_PART* part = component->GetPartRef().lock().get();
230 
231  if( part || aForceIncludeOrphanComponents )
232  {
233  SCH_REFERENCE schReference( component, part, *this );
234 
235  schReference.SetSheetNumber( m_pageNumber );
236  aReferences.AddItem( schReference );
237  }
238  }
239  }
240 }
PART_REF & GetPartRef()
SCH_ITEM * Next() const
Definition: sch_item.h:153
void AddItem(SCH_REFERENCE &aItem)
Function AddItem adds a SCH_REFERENCE object to the list of references.
Define a library symbol object.
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
Class SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.

References SCH_REFERENCE_LIST::AddItem(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetRef(), LastDrawList(), m_pageNumber, SCH_ITEM::Next(), SCH_COMPONENT_T, and SCH_REFERENCE::SetSheetNumber().

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::CheckAnnotate(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

◆ GetCurrentHash()

size_t SCH_SHEET_PATH::GetCurrentHash ( ) const
inline

Definition at line 156 of file sch_sheet_path.h.

156 { 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 243 of file sch_sheet_path.cpp.

245 {
246 
247  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
248  {
249  if( item->Type() != SCH_COMPONENT_T )
250  continue;
251 
252  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
253 
254  // Skip pseudo components, which have a reference starting with #. This mainly
255  // affects power symbols.
256  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
257  continue;
258 
259  LIB_PART* part = component->GetPartRef().lock().get();
260 
261  if( part && part->GetUnitCount() > 1 )
262  {
263  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
264  schReference.SetSheetNumber( m_pageNumber );
265  wxString reference_str = schReference.GetRef();
266 
267  // Never lock unassigned references
268  if( reference_str[reference_str.Len() - 1] == '?' )
269  continue;
270 
271  aRefList[reference_str].AddItem( schReference );
272  }
273  }
274 }
void SetSheetNumber(int aSheetNumber)
int GetUnitCount() const
PART_REF & GetPartRef()
SCH_ITEM * Next() const
Definition: sch_item.h:153
wxString GetRef() const
Define a library symbol object.
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
Class SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.

References SCH_COMPONENT::GetPartRef(), SCH_REFERENCE::GetRef(), SCH_COMPONENT::GetRef(), LIB_PART::GetUnitCount(), LastDrawList(), m_pageNumber, SCH_ITEM::Next(), SCH_COMPONENT_T, and SCH_REFERENCE::SetSheetNumber().

Referenced by SCH_EDIT_FRAME::AnnotateComponents().

◆ GetPageNumber()

int SCH_SHEET_PATH::GetPageNumber ( ) const
inline

Definition at line 160 of file sch_sheet_path.h.

160 { 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 169 of file sch_sheet_path.cpp.

170 {
171  // return a PathName for the root sheet (like "/" or "<root>"
172  // DO NOT use it in netlists, because it can easily break these netlists
173  // especially after translation, because many netlists (i.e. spice) do not accept any char
174  // Use only the short name ("/") and the full name only in messages
175  return aUseShortName ? wxT( "/" ) : _( "<root_sheet>" );
176 }
#define _(s)

References _.

Referenced by SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet(), and PathHumanReadable().

◆ GetSheet() [1/2]

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

Definition at line 162 of file sch_sheet_path.h.

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

References at(), and size().

Referenced by SCH_SHEET_LIST::TestForRecursion().

◆ GetSheet() [2/2]

SCH_SHEET* SCH_SHEET_PATH::GetSheet ( unsigned  aIndex)
inline

Definition at line 172 of file sch_sheet_path.h.

173  {
174  return const_cast< SCH_SHEET* >( static_cast< const SCH_SHEET_PATH& >( *this ).GetSheet( aIndex ) );
175  }

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

98 {
99  if( !empty() )
100  return at( size() - 1 );
101 
102  return NULL;
103 }
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(), and size().

Referenced by HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG(), SCH_DRAWING_TOOLS::Init(), EE_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), LastDrawList(), LastScreen(), SCH_EDITOR_CONTROL::LeaveSheet(), SCH_EDITOR_CONTROL::Paste(), and SCH_EDIT_FRAME::ReCreateMenuBar().

◆ LastDrawList()

SCH_ITEM * SCH_SHEET_PATH::LastDrawList ( ) const

Function LastDrawList.

Returns
a pointer to the first schematic item handled by the SCH_SCREEN relative to the last sheet in list

Definition at line 117 of file sch_sheet_path.cpp.

118 {
119  SCH_SHEET* lastSheet = Last();
120 
121  if( lastSheet && lastSheet->GetScreen() )
122  return lastSheet->GetScreen()->GetDrawItems();
123 
124  return NULL;
125 }
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:271
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:204
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:147

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

Referenced by SCH_SHEET_LIST::AnnotatePowerSymbols(), HIERARCHY_NAVIG_DLG::buildHierarchyTree(), SCH_SHEET_LIST::BuildSheetList(), FindNextItem(), GetComponents(), GetMultiUnitComponents(), and UpdateAllScreenReferences().

◆ LastScreen()

SCH_SCREEN * SCH_SHEET_PATH::LastScreen ( ) const

Function LastScreen.

Returns
the SCH_SCREEN relative to the last sheet in list

Definition at line 106 of file sch_sheet_path.cpp.

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

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

Referenced by NETLIST_OBJECT_LIST::BuildNetListInfo(), SCH_EDIT_FRAME::checkSheetForRecursion(), 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(), SCH_EDIT_FRAME::EditSheet(), 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(), SCH_EDIT_FRAME::GetScreen(), SCH_EDIT_FRAME::HardRedraw(), SCH_EDIT_FRAME::importFile(), DIALOG_EDIT_COMPONENTS_LIBID::initDlg(), SCH_EDIT_FRAME::LoadSheetFromFile(), SCH_PRINTOUT::OnPrintPage(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::Paste(), CONNECTION_SUBGRAPH::ResolveDrivers(), SetComponentFootprint(), SCH_EDIT_FRAME::SetCurrentSheet(), SimilarLabelsDiagnose(), TestMultiunitFootprints(), CONNECTION_GRAPH::updateItemConnectivity(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ operator!=()

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

Definition at line 348 of file sch_sheet_path.h.

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

◆ operator<()

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

Definition at line 350 of file sch_sheet_path.h.

350 { 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 355 of file sch_sheet_path.cpp.

356 {
357  return m_current_hash == d1.GetCurrentHash();
358 }
size_t GetCurrentHash() const

References GetCurrentHash(), and m_current_hash.

◆ Path()

wxString SCH_SHEET_PATH::Path ( ) const

Function Path 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 151 of file sch_sheet_path.cpp.

152 {
153  wxString s, t;
154 
155  s = wxT( "/" ); // This is the root path
156 
157  // Start at 1 to avoid the root sheet, which does not need to be added to the path.
158  // It's timestamp changes anyway.
159  for( unsigned i = 1; i < size(); i++ )
160  {
161  t.Printf( _( "%8.8lX/" ), (long unsigned) at( i )->GetTimeStamp() );
162  s = s + t;
163  }
164 
165  return s;
166 }
size_t size() const
Forwarded method from std::vector.
#define _(s)
size_t i
Definition: json11.cpp:597
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References _, at(), i, and size().

Referenced by countIndenticalLabels(), evalLabelsPriority(), SCH_COMPONENT::GetPath(), SCH_REFERENCE::IsSameInstance(), SCH_EAGLE_PLUGIN::loadInstance(), SCH_EAGLE_PLUGIN::loadSchematic(), compare_labels::operator()(), compare_paths::operator()(), and SCH_EDIT_FRAME::SetSheetNumberAndCount().

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

180 {
181  wxString s;
182 
183  if( size() == 1 )
184  return GetRootPathName( true ); // Use only the short name in netlists
185 
186  s = wxT( "/" );
187 
188  // Start at 1 to avoid the root sheet, as above.
189  for( unsigned i = 1; i < size(); i++ )
190  s = s + at( i )->GetName() + wxT( "/" );
191 
192  return s;
193 }
static wxString GetRootPathName(bool aUseShortName=true)
wxString GetName() const
Definition: sch_sheet.h:262
size_t size() const
Forwarded method from std::vector.
size_t i
Definition: json11.cpp:597
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), SCH_SHEET::GetName(), GetRootPathName(), i, and size().

Referenced by evalLabelsPriority(), NETLIST_OBJECT::GetNetName(), SCH_EDIT_FRAME::GetScreenDesc(), SCH_SHEET_LIST::GetSheetByPath(), SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet(), SCH_CONNECTION::Name(), SimilarLabelsDiagnose(), and SCH_EDIT_FRAME::UpdateTitle().

◆ pop_back()

void SCH_SHEET_PATH::pop_back ( )
inline

Forwarded method from std::vector.

Definition at line 138 of file sch_sheet_path.h.

139  {
140  m_sheets.pop_back();
141  Rehash();
142  }
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 66 of file sch_sheet_path.cpp.

67 {
68  m_current_hash = 0;
69 
70  for( auto sheet : m_sheets )
71  boost::hash_combine( m_current_hash, sheet->GetTimeStamp() );
72 }
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 343 of file sch_sheet_path.cpp.

345 {
346  SCH_SCREEN* screen = LastScreen();
347 
348  if( screen == NULL )
349  return false;
350 
351  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
352 }
SCH_SCREEN * LastScreen() const
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:871

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

◆ SetPageNumber()

void SCH_SHEET_PATH::SetPageNumber ( int  aPageNumber)
inline

Definition at line 158 of file sch_sheet_path.h.

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

Forwarded method from std::vector.

Definition at line 152 of file sch_sheet_path.h.

152 { return m_sheets.size(); }
std::vector< SCH_SHEET * > m_sheets

References m_sheets.

Referenced by Cmp(), FindSheet(), FindSheetByName(), GetSheet(), Last(), Path(), PathHumanReadable(), CONNECTION_GRAPH::propagateToNeighbors(), TestForRecursion(), and SCH_SHEET_LIST::TestForRecursion().

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

363 {
364  wxFileName rootFn = g_RootSheet->GetFileName();
365  wxFileName srcFn = aSrcFileName;
366  wxFileName destFn = aDestFileName;
367 
368  if( srcFn.IsRelative() )
369  srcFn.MakeAbsolute( rootFn.GetPath() );
370 
371  if( destFn.IsRelative() )
372  destFn.MakeAbsolute( rootFn.GetPath() );
373 
374 
375  // The source and destination sheet file names cannot be the same.
376  if( srcFn == destFn )
377  return true;
378 
382  unsigned i = 0;
383 
384  while( i < size() )
385  {
386  wxFileName cmpFn = at( i )->GetFileName();
387 
388  if( cmpFn.IsRelative() )
389  cmpFn.MakeAbsolute( rootFn.GetPath() );
390 
391  // Test if the file name of the destination sheet is in anywhere in this sheet path.
392  if( cmpFn == destFn )
393  break;
394 
395  i++;
396  }
397 
398  // The destination sheet file name was not found in the sheet path or the destination
399  // sheet file name is the root sheet so no recursion is possible.
400  if( i >= size() || i == 0 )
401  return false;
402 
403  // Walk back up to the root sheet to see if the source file name is already a parent in
404  // the sheet path. If so, recursion will occur.
405  do
406  {
407  i -= 1;
408 
409  wxFileName cmpFn = at( i )->GetFileName();
410 
411  if( cmpFn.IsRelative() )
412  cmpFn.MakeAbsolute( rootFn.GetPath() );
413 
414  if( cmpFn == srcFn )
415  return true;
416 
417  } while( i != 0 );
418 
419  // The source sheet file name is not a parent of the destination sheet file name.
420  return false;
421 }
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
size_t size() const
Forwarded method from std::vector.
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:629
size_t i
Definition: json11.cpp:597
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.

References at(), g_RootSheet, SCH_SHEET::GetFileName(), i, and size().

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

197 {
198  EDA_ITEM* t = LastDrawList();
199 
200  while( t )
201  {
202  if( t->Type() == SCH_COMPONENT_T )
203  {
204  SCH_COMPONENT* component = (SCH_COMPONENT*) t;
205  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
206  component->UpdateUnit( component->GetUnitSelection( this ) );
207  }
208 
209  t = t->Next();
210  }
211 }
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
int GetUnitSelection(SCH_SHEET_PATH *aSheet)
Field Reference of part, i.e. "IC21".
EDA_ITEM * Next() const
Definition: base_struct.h:218
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:112
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

References SCH_COMPONENT::GetField(), SCH_COMPONENT::GetRef(), SCH_COMPONENT::GetUnitSelection(), LastDrawList(), EDA_ITEM::Next(), REFERENCE, SCH_COMPONENT_T, EDA_TEXT::SetText(), EDA_ITEM::Type(), and SCH_COMPONENT::UpdateUnit().

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

Member Data Documentation

◆ m_current_hash

size_t SCH_SHEET_PATH::m_current_hash
protected

Definition at line 117 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 115 of file sch_sheet_path.h.

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


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