KiCad PCB EDA Suite
SCH_SHEET_PATH Class Reference

Class SCH_SHEET_PATH. More...

#include <sch_sheet_path.h>

Inheritance diagram for SCH_SHEET_PATH:

Public Member Functions

 SCH_SHEET_PATH ()
 Page numbers are maintained by the sheet load order. More...
 
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 AnnotatePowerSymbols (PART_LIBS *aLibs, int *aReference)
 Function AnnotatePowerSymbols annotates the power symbols only starting at aReference in the sheet path. More...
 
void GetComponents (PART_LIBS *aLibs, SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true)
 Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet. More...
 
void GetMultiUnitComponents (PART_LIBS *aLibs, 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
 

Private Attributes

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 ( )

Page numbers are maintained by the sheet load order.

Definition at line 49 of file sch_sheet_path.cpp.

References m_pageNumber.

50 {
51  m_pageNumber = 0;
52 }

Member Function Documentation

void SCH_SHEET_PATH::AnnotatePowerSymbols ( PART_LIBS aLibs,
int *  aReference 
)

Function AnnotatePowerSymbols annotates the power symbols only starting at aReference in the sheet path.

Parameters
aLibsthe library list to use
aReferenceA pointer to the number for the reference designator of the first power symbol to be annotated. If the pointer is NULL the annotation starts at 1. The number is incremented for each power symbol annotated.

Definition at line 184 of file sch_sheet_path.cpp.

References SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetPrefix(), LIB_PART::IsPower(), LastDrawList(), SCH_ITEM::Next(), SCH_COMPONENT_T, and SCH_COMPONENT::SetRef().

185 {
186  int ref = 1;
187 
188  if( aReference )
189  ref = *aReference;
190 
191  for( EDA_ITEM* item = LastDrawList(); item; item = item->Next() )
192  {
193  if( item->Type() != SCH_COMPONENT_T )
194  continue;
195 
196  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
197  LIB_PART* part = component->GetPartRef().lock().get();
198 
199  if( !part || !part->IsPower() )
200  continue;
201 
202  wxString refstr = component->GetPrefix();
203 
204  //str will be "C?" or so after the ClearAnnotation call.
205  while( refstr.Last() == '?' )
206  refstr.RemoveLast();
207 
208  if( !refstr.StartsWith( wxT( "#" ) ) )
209  refstr.insert( refstr.begin(), wxChar( '#' ) );
210 
211  refstr << wxT( "0" ) << ref;
212  component->SetRef( this, refstr );
213  ref++;
214  }
215 
216  if( aReference )
217  *aReference = ref;
218 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
PART_REF & GetPartRef()
bool IsPower() const
wxString GetPrefix() const
void SetRef(const SCH_SHEET_PATH *sheet, const wxString &ref)
Set the reference, for the given sheet path.
SCH_ITEM * Next() const
Class LIB_PART defines a library part object.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
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 55 of file sch_sheet_path.cpp.

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

56 {
57  if( size() > aSheetPathToTest.size() )
58  return 1;
59 
60  if( size() < aSheetPathToTest.size() )
61  return -1;
62 
63  //otherwise, same number of sheets.
64  for( unsigned i = 0; i < size(); i++ )
65  {
66  if( at( i )->GetTimeStamp() > aSheetPathToTest.at( i )->GetTimeStamp() )
67  return 1;
68 
69  if( at( i )->GetTimeStamp() < aSheetPathToTest.at( i )->GetTimeStamp() )
70  return -1;
71  }
72 
73  return 0;
74 }
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 284 of file sch_sheet_path.cpp.

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

Referenced by SCH_EDIT_FRAME::OnFindDrcMarker().

285 {
286  bool hasWrapped = false;
287  bool firstItemFound = false;
288  SCH_ITEM* drawItem = LastDrawList();
289 
290  while( drawItem )
291  {
292  if( drawItem->Type() == aType )
293  {
294  if( !aLastItem || firstItemFound )
295  {
296  return drawItem;
297  }
298  else if( !firstItemFound && drawItem == aLastItem )
299  {
300  firstItemFound = true;
301  }
302  }
303 
304  drawItem = drawItem->Next();
305 
306  if( !drawItem && aLastItem && aWrap && !hasWrapped )
307  {
308  hasWrapped = true;
309  drawItem = LastDrawList();
310  }
311  }
312 
313  return NULL;
314 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_ITEM * Next() const
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
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 317 of file sch_sheet_path.cpp.

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

318 {
319  bool hasWrapped = false;
320  bool firstItemFound = false;
321  SCH_ITEM* drawItem = FirstDrawList();
322 
323  while( drawItem )
324  {
325  if( drawItem->Type() == aType )
326  {
327  if( aLastItem == NULL || firstItemFound )
328  {
329  return drawItem;
330  }
331  else if( !firstItemFound && drawItem == aLastItem )
332  {
333  firstItemFound = true;
334  }
335  }
336 
337  drawItem = drawItem->Back();
338 
339  if( drawItem == NULL && aLastItem && aWrap && !hasWrapped )
340  {
341  hasWrapped = true;
342  drawItem = FirstDrawList();
343  }
344  }
345 
346  return NULL;
347 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_ITEM * Back() const
SCH_ITEM * FirstDrawList() const
Get the last schematic item relative to the first sheet in the list.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
int SCH_SHEET_PATH::FindSheet ( const wxString &  aFileName) const

Definition at line 440 of file sch_sheet_path.cpp.

References SHEET_NOT_FOUND.

441 {
442  for( unsigned i = 0; i < size(); i++ )
443  {
444  if( at( i )->GetFileName().CmpNoCase( aFileName ) == 0 )
445  return (int)i;
446  }
447 
448  return SHEET_NOT_FOUND;
449 }
#define SHEET_NOT_FOUND
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 452 of file sch_sheet_path.cpp.

453 {
454  for( unsigned i = 0; i < size(); i++ )
455  {
456  if( at( i )->GetName().CmpNoCase( aSheetName ) == 0 )
457  return at( i );
458  }
459 
460  return NULL;
461 }
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.
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 108 of file sch_sheet_path.cpp.

References empty(), and SCH_ITEM::Next().

Referenced by FindPreviousItem().

109 {
110  SCH_ITEM* item = NULL;
111 
112  if( !empty() && at( 0 )->GetScreen() )
113  item = at( 0 )->GetScreen()->GetDrawItems();
114 
115  /* @fixme - These lists really should be one of the boost pointer containers. This
116  * is a brain dead hack to allow reverse iteration of EDA_ITEM linked
117  * list.
118  */
119  SCH_ITEM* lastItem = NULL;
120 
121  while( item )
122  {
123  lastItem = item;
124  item = item->Next();
125  }
126 
127  return lastItem;
128 }
SCH_ITEM * Next() const
static bool empty(const wxTextEntryBase *aCtrl)
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void SCH_SHEET_PATH::GetComponents ( PART_LIBS aLibs,
SCH_REFERENCE_LIST aReferences,
bool  aIncludePowerSymbols = true 
)

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

Parameters
aLibsthe library list to use
aReferencesList of references to populate.
aIncludePowerSymbols: false to only get normal components.

Definition at line 221 of file sch_sheet_path.cpp.

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(), and SCH_EDIT_FRAME::CheckAnnotate().

223 {
224  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
225  {
226  if( item->Type() == SCH_COMPONENT_T )
227  {
228  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
229 
230  // Skip pseudo components, which have a reference starting with #. This mainly
231  // affects power symbols.
232  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
233  continue;
234 
235  LIB_PART* part = component->GetPartRef().lock().get();
236 
237  if( part )
238  {
239  SCH_REFERENCE reference( component, part, *this );
240 
241  reference.SetSheetNumber( m_pageNumber );
242  aReferences.AddItem( reference );
243  }
244  }
245  }
246 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
PART_REF & GetPartRef()
void AddItem(SCH_REFERENCE &aItem)
Function AddItem adds a SCH_REFERENCE object to the list of references.
SCH_ITEM * Next() const
Class LIB_PART defines a library part object.
const wxString GetRef(const SCH_SHEET_PATH *sheet)
Function GetRef returns the reference, for the given sheet path.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Class SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic...
void SCH_SHEET_PATH::GetMultiUnitComponents ( PART_LIBS aLibs,
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
aLibsthe library list to use
aRefListMap of reference designators to reference lists
aIncludePowerSymbols: false to only get normal components.

Definition at line 249 of file sch_sheet_path.cpp.

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().

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

Definition at line 123 of file sch_sheet_path.h.

References m_pageNumber.

123 { return m_pageNumber; }
const SCH_SHEET* SCH_SHEET_PATH::GetSheet ( unsigned  aIndex) const
inline

Definition at line 125 of file sch_sheet_path.h.

Referenced by GetSheet(), and SCH_SHEET_LIST::TestForRecursion().

126  {
127  SCH_SHEET* retv = NULL;
128 
129  if( aIndex < size() )
130  retv = at( aIndex );
131 
132  return const_cast< SCH_SHEET* >( retv );
133  }
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
SCH_SHEET* SCH_SHEET_PATH::GetSheet ( unsigned  aIndex)
inline

Definition at line 135 of file sch_sheet_path.h.

References GetSheet().

136  {
137  return const_cast< SCH_SHEET* >( static_cast< const SCH_SHEET_PATH& >( *this ).GetSheet( aIndex ) );
138  }
const SCH_SHEET * GetSheet(unsigned aIndex) const
Class SCH_SHEET_PATH.
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
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 77 of file sch_sheet_path.cpp.

References empty().

Referenced by SCH_EDIT_FRAME::EditSheet(), HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG(), LastDrawList(), LastScreen(), SCH_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnRightClick(), SCH_EDIT_FRAME::PasteListOfItems(), and SCH_EDIT_FRAME::Process_Special_Functions().

78 {
79  if( !empty() )
80  return at( size() - 1 );
81 
82  return NULL;
83 }
static bool empty(const wxTextEntryBase *aCtrl)
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 97 of file sch_sheet_path.cpp.

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

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

98 {
99  SCH_SHEET* lastSheet = Last();
100 
101  if( lastSheet && lastSheet->GetScreen() )
102  return lastSheet->GetScreen()->GetDrawItems();
103 
104  return NULL;
105 }
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:286
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...
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
SCH_ITEM * GetDrawItems() const
Function GetDrawItems().
SCH_SCREEN * SCH_SHEET_PATH::LastScreen ( ) const

Function LastScreen.

Returns
the SCH_SCREEN relative to the last sheet in list

Definition at line 86 of file sch_sheet_path.cpp.

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

Referenced by NETLIST_OBJECT_LIST::BuildNetListInfo(), 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::FindComponentAndItem(), SCH_EDIT_FRAME::OnFindDrcMarker(), SCH_PRINTOUT::OnPrintPage(), SCH_EDIT_FRAME::OpenProjectFiles(), SetComponentFootprint(), SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags(), and SimilarLabelsDiagnose().

87 {
88  SCH_SHEET* lastSheet = Last();
89 
90  if( lastSheet )
91  return lastSheet->GetScreen();
92 
93  return NULL;
94 }
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:286
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...
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
bool SCH_SHEET_PATH::operator!= ( const SCH_SHEET_PATH d1) const
inline

Definition at line 313 of file sch_sheet_path.h.

313 { return !( *this == d1 ) ; }
bool SCH_SHEET_PATH::operator== ( const SCH_SHEET_PATH d1) const

Definition at line 362 of file sch_sheet_path.cpp.

363 {
364  if( size() != d1.size() )
365  return false;
366 
367  for( unsigned i = 0; i < size(); i++ )
368  {
369  if( at( i ) != d1[i] )
370  return false;
371  }
372 
373  return true;
374 }
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 131 of file sch_sheet_path.cpp.

References EDA_ITEM::GetTimeStamp().

Referenced by countIndenticalLabels(), evalLabelsPriority(), SCH_COMPONENT::GetPath(), SCH_REFERENCE::IsSameInstance(), SCH_EDIT_FRAME::OnFindDrcMarker(), compare_labels::operator()(), and compare_paths::operator()().

132 {
133  wxString s, t;
134 
135  s = wxT( "/" ); // This is the root path
136 
137  // start at 1 to avoid the root sheet,
138  // which does not need to be added to the path
139  // it's timestamp changes anyway.
140  for( unsigned i = 1; i < size(); i++ )
141  {
142  t.Printf( _( "%8.8lX/" ), (long unsigned) at( i )->GetTimeStamp() );
143  s = s + t;
144  }
145 
146  return s;
147 }
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 150 of file sch_sheet_path.cpp.

Referenced by evalLabelsPriority(), NETLIST_OBJECT::GetNetName(), SCH_SHEET_LIST::GetSheetByPath(), SCH_FIND_COLLECTOR::Inspect(), SimilarLabelsDiagnose(), and SCH_EDIT_FRAME::updateFindReplaceView().

151 {
152  wxString s;
153 
154  s = wxT( "/" );
155 
156  // start at 1 to avoid the root sheet, as above.
157  for( unsigned i = 1; i < size(); i++ )
158  {
159  s = s + at( i )->GetName() + wxT( "/" );
160  }
161 
162  return s;
163 }
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 350 of file sch_sheet_path.cpp.

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

352 {
353  SCH_SCREEN* screen = LastScreen();
354 
355  if( screen == NULL )
356  return false;
357 
358  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
359 }
SCH_SCREEN * LastScreen() const
Function LastScreen.
bool SetComponentFootprint(SCH_SHEET_PATH *aSheetPath, const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Function SetFootprintField searches screen for a component with aReference and set the footprint fiel...
void SCH_SHEET_PATH::SetPageNumber ( int  aPageNumber)
inline

Definition at line 121 of file sch_sheet_path.h.

Referenced by SCH_SHEET_LIST::BuildSheetList().

121 { m_pageNumber = aPageNumber; }
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 377 of file sch_sheet_path.cpp.

References g_RootSheet, and SCH_SHEET::GetFileName().

379 {
380  wxFileName rootFn = g_RootSheet->GetFileName();
381  wxFileName srcFn = aSrcFileName;
382  wxFileName destFn = aDestFileName;
383 
384  if( srcFn.IsRelative() )
385  srcFn.MakeAbsolute( rootFn.GetPath() );
386 
387  if( destFn.IsRelative() )
388  destFn.MakeAbsolute( rootFn.GetPath() );
389 
390 
391  // The source and destination sheet file names cannot be the same.
392  if( srcFn == destFn )
393  return true;
394 
398  unsigned i = 0;
399 
400  while( i < size() )
401  {
402  wxFileName cmpFn = at( i )->GetFileName();
403 
404  if( cmpFn.IsRelative() )
405  cmpFn.MakeAbsolute( rootFn.GetPath() );
406 
407  // Test if the file name of the destination sheet is in anywhere in this sheet path.
408  if( cmpFn == destFn )
409  break;
410 
411  i++;
412  }
413 
414  // The destination sheet file name was not found in the sheet path or the destination
415  // sheet file name is the root sheet so no recursion is possible.
416  if( i >= size() || i == 0 )
417  return false;
418 
419  // Walk back up to the root sheet to see if the source file name is already a parent in
420  // the sheet path. If so, recursion will occur.
421  do
422  {
423  i -= 1;
424 
425  wxFileName cmpFn = at( i )->GetFileName();
426 
427  if( cmpFn.IsRelative() )
428  cmpFn.MakeAbsolute( rootFn.GetPath() );
429 
430  if( cmpFn == srcFn )
431  return true;
432 
433  } while( i != 0 );
434 
435  // The source sheet file name is not a parent of the destination sheet file name.
436  return false;
437 }
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:54
wxString GetFileName(void) const
Function GetFileName return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:849
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 166 of file sch_sheet_path.cpp.

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_EDIT_FRAME::FindComponentAndItem(), SCH_EDIT_FRAME::OnFindDrcMarker(), DIALOG_ERC::OnLeftClickMarkersList(), SCH_PRINTOUT::OnPrintPage(), DIALOG_PLOT_SCHEMATIC::restoreEnvironment(), and SCH_EDIT_FRAME::updateFindReplaceView().

167 {
168  EDA_ITEM* t = LastDrawList();
169 
170  while( t )
171  {
172  if( t->Type() == SCH_COMPONENT_T )
173  {
174  SCH_COMPONENT* component = (SCH_COMPONENT*) t;
175  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
176  component->UpdateUnit( component->GetUnitSelection( this ) );
177  }
178 
179  t = t->Next();
180  }
181 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void UpdateUnit(int aUnit)
change the unit id to aUnit has maening only for multiple parts per package Do not change the modifie...
int GetUnitSelection(SCH_SHEET_PATH *aSheet)
EDA_ITEM * Next() const
Definition: base_struct.h:206
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
const wxString GetRef(const SCH_SHEET_PATH *sheet)
Function GetRef returns the reference, for the given sheet path.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141

Member Data Documentation

int SCH_SHEET_PATH::m_pageNumber
private

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