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

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

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

Referenced by SCH_EDIT_FRAME::OnFindDrcMarker().

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

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

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

References SHEET_NOT_FOUND.

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

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

215 {
216 
217  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
218  {
219  if( item->Type() != SCH_COMPONENT_T )
220  continue;
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 && part->GetUnitCount() > 1 )
232  {
233  SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
234  reference.SetSheetNumber( m_pageNumber );
235  wxString reference_str = reference.GetRef();
236 
237  // Never lock unassigned references
238  if( reference_str[reference_str.Len() - 1] == '?' )
239  continue;
240 
241  aRefList[reference_str].AddItem( reference );
242  }
243  }
244 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
void SetSheetNumber(int aSheetNumber)
PART_REF & GetPartRef()
SCH_ITEM * Next() const
Define a library symbol 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  }
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
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(), HIERARCHY_NAVIG_DLG::buildHierarchyTree(), SCH_SHEET_LIST::BuildSheetList(), 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:279
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...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
SCH_ITEM * GetDrawItems() const
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::ImportFile(), DIALOG_EDIT_COMPONENTS_LIBID::initDlg(), 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:279
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...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
bool SCH_SHEET_PATH::operator!= ( const SCH_SHEET_PATH d1) const
inline

Definition at line 303 of file sch_sheet_path.h.

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

Definition at line 325 of file sch_sheet_path.cpp.

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

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

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

References g_RootSheet, and SCH_SHEET::GetFileName().

342 {
343  wxFileName rootFn = g_RootSheet->GetFileName();
344  wxFileName srcFn = aSrcFileName;
345  wxFileName destFn = aDestFileName;
346 
347  if( srcFn.IsRelative() )
348  srcFn.MakeAbsolute( rootFn.GetPath() );
349 
350  if( destFn.IsRelative() )
351  destFn.MakeAbsolute( rootFn.GetPath() );
352 
353 
354  // The source and destination sheet file names cannot be the same.
355  if( srcFn == destFn )
356  return true;
357 
361  unsigned i = 0;
362 
363  while( i < size() )
364  {
365  wxFileName cmpFn = at( i )->GetFileName();
366 
367  if( cmpFn.IsRelative() )
368  cmpFn.MakeAbsolute( rootFn.GetPath() );
369 
370  // Test if the file name of the destination sheet is in anywhere in this sheet path.
371  if( cmpFn == destFn )
372  break;
373 
374  i++;
375  }
376 
377  // The destination sheet file name was not found in the sheet path or the destination
378  // sheet file name is the root sheet so no recursion is possible.
379  if( i >= size() || i == 0 )
380  return false;
381 
382  // Walk back up to the root sheet to see if the source file name is already a parent in
383  // the sheet path. If so, recursion will occur.
384  do
385  {
386  i -= 1;
387 
388  wxFileName cmpFn = at( i )->GetFileName();
389 
390  if( cmpFn.IsRelative() )
391  cmpFn.MakeAbsolute( rootFn.GetPath() );
392 
393  if( cmpFn == srcFn )
394  return true;
395 
396  } while( i != 0 );
397 
398  // The source sheet file name is not a parent of the destination sheet file name.
399  return false;
400 }
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:645
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:225
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:233
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:178
virtual void SetText(const wxString &aText)
Definition: eda_text.h:139

Member Data Documentation

int SCH_SHEET_PATH::m_pageNumber
private

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