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

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

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

Referenced by SCH_EDIT_FRAME::OnFindDrcMarker().

249 {
250  bool hasWrapped = false;
251  bool firstItemFound = false;
252  SCH_ITEM* drawItem = LastDrawList();
253 
254  while( drawItem )
255  {
256  if( drawItem->Type() == aType )
257  {
258  if( !aLastItem || firstItemFound )
259  {
260  return drawItem;
261  }
262  else if( !firstItemFound && drawItem == aLastItem )
263  {
264  firstItemFound = true;
265  }
266  }
267 
268  drawItem = drawItem->Next();
269 
270  if( !drawItem && aLastItem && aWrap && !hasWrapped )
271  {
272  hasWrapped = true;
273  drawItem = LastDrawList();
274  }
275  }
276 
277  return NULL;
278 }
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 281 of file sch_sheet_path.cpp.

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

282 {
283  bool hasWrapped = false;
284  bool firstItemFound = false;
285  SCH_ITEM* drawItem = FirstDrawList();
286 
287  while( drawItem )
288  {
289  if( drawItem->Type() == aType )
290  {
291  if( aLastItem == NULL || firstItemFound )
292  {
293  return drawItem;
294  }
295  else if( !firstItemFound && drawItem == aLastItem )
296  {
297  firstItemFound = true;
298  }
299  }
300 
301  drawItem = drawItem->Back();
302 
303  if( drawItem == NULL && aLastItem && aWrap && !hasWrapped )
304  {
305  hasWrapped = true;
306  drawItem = FirstDrawList();
307  }
308  }
309 
310  return NULL;
311 }
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 404 of file sch_sheet_path.cpp.

References SHEET_NOT_FOUND.

405 {
406  for( unsigned i = 0; i < size(); i++ )
407  {
408  if( at( i )->GetFileName().CmpNoCase( aFileName ) == 0 )
409  return (int)i;
410  }
411 
412  return SHEET_NOT_FOUND;
413 }
#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 416 of file sch_sheet_path.cpp.

417 {
418  for( unsigned i = 0; i < size(); i++ )
419  {
420  if( at( i )->GetName().CmpNoCase( aSheetName ) == 0 )
421  return at( i );
422  }
423 
424  return NULL;
425 }
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 185 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().

187 {
188  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
189  {
190  if( item->Type() == SCH_COMPONENT_T )
191  {
192  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
193 
194  // Skip pseudo components, which have a reference starting with #. This mainly
195  // affects power symbols.
196  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
197  continue;
198 
199  LIB_PART* part = component->GetPartRef().lock().get();
200 
201  if( part )
202  {
203  SCH_REFERENCE reference( component, part, *this );
204 
205  reference.SetSheetNumber( m_pageNumber );
206  aReferences.AddItem( reference );
207  }
208  }
209  }
210 }
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 *aSheet)
Return 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 213 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().

216 {
217 
218  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
219  {
220  if( item->Type() != SCH_COMPONENT_T )
221  continue;
222 
223  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
224 
225  // Skip pseudo components, which have a reference starting with #. This mainly
226  // affects power symbols.
227  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
228  continue;
229 
230  LIB_PART* part = component->GetPartRef().lock().get();
231 
232  if( part && part->GetUnitCount() > 1 )
233  {
234  SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
235  reference.SetSheetNumber( m_pageNumber );
236  wxString reference_str = reference.GetRef();
237 
238  // Never lock unassigned references
239  if( reference_str[reference_str.Len() - 1] == '?' )
240  continue;
241 
242  aRefList[reference_str].AddItem( reference );
243  }
244  }
245 }
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.
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
int GetUnitCount() const
wxString GetRef() const
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 121 of file sch_sheet_path.h.

References m_pageNumber.

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

Definition at line 123 of file sch_sheet_path.h.

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

124  {
125  SCH_SHEET* retv = NULL;
126 
127  if( aIndex < size() )
128  retv = at( aIndex );
129 
130  return const_cast< SCH_SHEET* >( retv );
131  }
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 133 of file sch_sheet_path.h.

References GetSheet().

134  {
135  return const_cast< SCH_SHEET* >( static_cast< const SCH_SHEET_PATH& >( *this ).GetSheet( aIndex ) );
136  }
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::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 SCH_SHEET_LIST::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 300 of file sch_sheet_path.h.

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

Definition at line 326 of file sch_sheet_path.cpp.

327 {
328  if( size() != d1.size() )
329  return false;
330 
331  for( unsigned i = 0; i < size(); i++ )
332  {
333  if( at( i ) != d1[i] )
334  return false;
335  }
336 
337  return true;
338 }
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 314 of file sch_sheet_path.cpp.

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

316 {
317  SCH_SCREEN* screen = LastScreen();
318 
319  if( screen == NULL )
320  return false;
321 
322  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
323 }
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 119 of file sch_sheet_path.h.

Referenced by SCH_SHEET_LIST::BuildSheetList().

119 { 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 341 of file sch_sheet_path.cpp.

References g_RootSheet, and SCH_SHEET::GetFileName().

343 {
344  wxFileName rootFn = g_RootSheet->GetFileName();
345  wxFileName srcFn = aSrcFileName;
346  wxFileName destFn = aDestFileName;
347 
348  if( srcFn.IsRelative() )
349  srcFn.MakeAbsolute( rootFn.GetPath() );
350 
351  if( destFn.IsRelative() )
352  destFn.MakeAbsolute( rootFn.GetPath() );
353 
354 
355  // The source and destination sheet file names cannot be the same.
356  if( srcFn == destFn )
357  return true;
358 
362  unsigned i = 0;
363 
364  while( i < size() )
365  {
366  wxFileName cmpFn = at( i )->GetFileName();
367 
368  if( cmpFn.IsRelative() )
369  cmpFn.MakeAbsolute( rootFn.GetPath() );
370 
371  // Test if the file name of the destination sheet is in anywhere in this sheet path.
372  if( cmpFn == destFn )
373  break;
374 
375  i++;
376  }
377 
378  // The destination sheet file name was not found in the sheet path or the destination
379  // sheet file name is the root sheet so no recursion is possible.
380  if( i >= size() || i == 0 )
381  return false;
382 
383  // Walk back up to the root sheet to see if the source file name is already a parent in
384  // the sheet path. If so, recursion will occur.
385  do
386  {
387  i -= 1;
388 
389  wxFileName cmpFn = at( i )->GetFileName();
390 
391  if( cmpFn.IsRelative() )
392  cmpFn.MakeAbsolute( rootFn.GetPath() );
393 
394  if( cmpFn == srcFn )
395  return true;
396 
397  } while( i != 0 );
398 
399  // The source sheet file name is not a parent of the destination sheet file name.
400  return false;
401 }
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 number to aUnit without setting any internal flags.
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
Returns a field in this symbol.
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return 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: