KiCad PCB EDA Suite
SCH_FIND_COLLECTOR Class Reference

Class SCH_FIND_COLLECTOR is used to iterate over all of the items in a schematic or sheet and collect all the items that match the given search criteria. More...

#include <sch_collectors.h>

Inheritance diagram for SCH_FIND_COLLECTOR:
COLLECTOR

Public Member Functions

 SCH_FIND_COLLECTOR (const KICAD_T *aScanTypes=SCH_COLLECTOR::AllItems)
 Function dump is a helper to dump the items in the find list for debugging purposes. More...
 
void Empty ()
 
void SetForceSearch (bool doSearch=true)
 
int GetLibHash () const
 
void SetLibHash (int aHash)
 
int GetFoundIndex () const
 
void SetFoundIndex (int aIndex)
 
bool PassedEnd () const
 Function PassedEnd tests if m_foundIndex is beyond the end of the list give the current find/replace criterial in m_findReplaceData. More...
 
void UpdateIndex ()
 Function UpdateIndex updates the list index according to the current find and replace criteria. More...
 
SCH_FIND_COLLECTOR_DATA GetFindData (int aIndex)
 Function GetFindData returns the data associated with the item found at aIndex. More...
 
bool IsSearchRequired (const SCH_FIND_REPLACE_DATA &aFindReplaceData)
 Function IsSearchRequired checks the current collector state against aFindReplaceData to see if a new search needs to be performed to update the collector. More...
 
wxString GetText ()
 Function GetText() More...
 
EDA_ITEMGetItem (SCH_FIND_COLLECTOR_DATA &aFindData)
 Function GetItem returns the item and associated data of the current index. More...
 
bool ReplaceItem (SCH_SHEET_PATH *aSheetPath=NULL)
 Function ReplaceItem performs a string replace of the item at the current index. More...
 
SEARCH_RESULT Inspect (EDA_ITEM *aItem, void *aTestData) override
 
void SetReplaceString (const wxString &aReplaceString)
 Update the replace string without changing anything else. More...
 
void Collect (SCH_FIND_REPLACE_DATA &aFindReplaceData, SCH_SHEET_PATH *aSheetPath=NULL)
 Function Collect scans aSheetPath using this class's Inspector method for items matching aFindReplaceData. More...
 
void IncrementIndex ()
 
bool IsValidIndex (int aIndex)
 Function IsValidIndex tests if aIndex is with the limits of the list of collected items. More...
 
int GetCount () const
 Function GetCount returns the number of objects in the list. More...
 
void Append (EDA_ITEM *item)
 Function Append adds an item to the end of the list. More...
 
void Remove (int aIndex)
 Function Remove removes the item at aIndex (first position is 0);. More...
 
void Remove (const EDA_ITEM *aItem)
 Function Remove removes the item aItem (if exists in the collector). More...
 
EDA_ITEMoperator[] (int aIndex) const
 Function operator[int] is used for read only access and returns the object at aIndex. More...
 
EDA_ITEM *const * BasePtr () const
 Function BasePtr returns the address of the first element in the array. More...
 
bool HasItem (const EDA_ITEM *aItem) const
 Function HasItem tests if aItem has already been collected. More...
 
void SetScanTypes (const KICAD_T *scanTypes)
 Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() function. More...
 
void SetTimeNow ()
 
time_t GetTime ()
 
void SetRefPos (const wxPoint &aRefPos)
 
const wxPointGetRefPos () const
 
void SetBoundingBox (const EDA_RECT &aRefBox)
 
const EDA_RECTGetBoundingBox () const
 
bool IsSimilarPointAndTime (const wxPoint &aRefPos)
 Function IsSimilarPointAndTime returns true if the given reference point is "similar" (defined here) to the internal reference point and the current time is within a few seconds of the internal m_TimeAtCollection. More...
 
int CountType (KICAD_T aType)
 Function CountType counts the number of items matching aType. More...
 

Protected Attributes

INSPECTOR_FUNC m_inspector
 a class common bridge into the polymorphic Inspect() More...
 
const KICAD_Tm_ScanTypes
 Which object types to scan. More...
 
std::vector< EDA_ITEM * > m_List
 A place to hold collected objects without taking ownership of their memory. More...
 
wxPoint m_RefPos
 A point to test against, and that was used to make the collection. More...
 
EDA_RECT m_RefBox
 A bounding box to test against, and that was used to make the collection. More...
 
time_t m_TimeAtCollection
 The time at which the collection was made. More...
 

Private Attributes

std::vector< SCH_FIND_COLLECTOR_DATAm_data
 Data associated with each found item. More...
 
SCH_FIND_REPLACE_DATA m_findReplaceData
 The criteria used to test for matching items. More...
 
SCH_SHEET_PATHm_sheetPath
 The path of the sheet currently being iterated over. More...
 
int m_foundIndex
 The current found item list index. More...
 
bool m_forceSearch
 A flag to indicate that the schemtic has been modified and a new search must be performed even if the search criteria hasn't changed. More...
 
int m_lib_hash
 last known library change hash, used to detect library changes which should trigger cache obsolescence. More...
 

Detailed Description

Class SCH_FIND_COLLECTOR is used to iterate over all of the items in a schematic or sheet and collect all the items that match the given search criteria.

Definition at line 227 of file sch_collectors.h.

Constructor & Destructor Documentation

SCH_FIND_COLLECTOR::SCH_FIND_COLLECTOR ( const KICAD_T aScanTypes = SCH_COLLECTOR::AllItems)
inline

Function dump is a helper to dump the items in the find list for debugging purposes.

Constructor SCH_FIND_COLLECTOR

Definition at line 262 of file sch_collectors.h.

References SetForceSearch(), and COLLECTOR::SetScanTypes().

263  {
264  SetScanTypes( aScanTypes );
265  m_foundIndex = 0;
266  SetForceSearch( false );
267  m_sheetPath = NULL;
268  m_lib_hash = 0;
269  }
SCH_SHEET_PATH * m_sheetPath
The path of the sheet currently being iterated over.
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
void SetForceSearch(bool doSearch=true)
int m_lib_hash
last known library change hash, used to detect library changes which should trigger cache obsolescenc...
int m_foundIndex
The current found item list index.

Member Function Documentation

void COLLECTOR::Append ( EDA_ITEM item)
inlineinherited

Function Append adds an item to the end of the list.

Parameters
itemAn EDA_ITEM* to add.

Definition at line 126 of file class_collector.h.

Referenced by GENERAL_COLLECTOR::Collect(), SELECTION_TOOL::guessSelectionCandidates(), LIB_COLLECTOR::Inspect(), GERBER_COLLECTOR::Inspect(), SCH_COLLECTOR::Inspect(), GENERAL_COLLECTOR::Inspect(), Inspect(), SCH_TYPE_COLLECTOR::Inspect(), and PCB_TYPE_COLLECTOR::Inspect().

127  {
128  m_List.push_back( item );
129  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
EDA_ITEM* const* COLLECTOR::BasePtr ( ) const
inlineinherited

Function BasePtr returns the address of the first element in the array.

Only call this if there is at least one element in the vector m_List, otherwise a C++ exception should get thrown.

Definition at line 178 of file class_collector.h.

179  {
180  return &m_List[0];
181  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void SCH_FIND_COLLECTOR::Collect ( SCH_FIND_REPLACE_DATA aFindReplaceData,
SCH_SHEET_PATH aSheetPath = NULL 
)

Function Collect scans aSheetPath using this class's Inspector method for items matching aFindReplaceData.

Parameters
aFindReplaceDataA SCH_FIND_REPLACE_DATA object containing the search criteria.
aSheetPathA pointer to a SCH_SHEET_PATH object to test for matches. A NULL value searches the entire schematic hierarchy.

Definition at line 522 of file sch_collectors.cpp.

References Empty(), g_RootSheet, IsSearchRequired(), EDA_ITEM::IterateForward(), SCH_SHEET_PATH::LastDrawList(), m_data, m_findReplaceData, m_forceSearch, m_foundIndex, COLLECTOR::m_inspector, COLLECTOR::m_List, COLLECTOR::m_ScanTypes, m_sheetPath, and SetForceSearch().

Referenced by SCH_EDIT_FRAME::OnFindReplace(), and SCH_EDIT_FRAME::OnFindSchematicItem().

524 {
525  if( !IsSearchRequired( aFindReplaceData ) && !m_List.empty() && !m_forceSearch )
526  return;
527 
528  m_findReplaceData = aFindReplaceData;
529  Empty(); // empty the collection just in case
530  m_data.clear();
531  m_foundIndex = 0;
532  SetForceSearch( false );
533 
534  if( aSheetPath )
535  {
536  m_sheetPath = aSheetPath;
538  }
539  else
540  {
541  SCH_SHEET_LIST schematic( g_RootSheet );
542 
543  for( unsigned i = 0; i < schematic.size(); i++ )
544  {
545  m_sheetPath = &schematic[i];
547  }
548  }
549 
550 #if defined(DEBUG)
551  dump();
552 #endif
553 
554  if( m_List.size() != m_data.size() )
555  {
556  wxFAIL_MSG( wxT( "List size mismatch." ) );
557  m_List.clear();
558  m_data.clear();
559  }
560 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Class SCH_SHEET_LIST.
static SEARCH_RESULT IterateForward(EDA_ITEM *listStart, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function IterateForward walks through the object tree calling the inspector() on each object type req...
bool IsSearchRequired(const SCH_FIND_REPLACE_DATA &aFindReplaceData)
Function IsSearchRequired checks the current collector state against aFindReplaceData to see if a new...
SCH_SHEET_PATH * m_sheetPath
The path of the sheet currently being iterated over.
std::vector< SCH_FIND_COLLECTOR_DATA > m_data
Data associated with each found item.
INSPECTOR_FUNC m_inspector
a class common bridge into the polymorphic Inspect()
void SetForceSearch(bool doSearch=true)
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
int m_foundIndex
The current found item list index.
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
const KICAD_T * m_ScanTypes
Which object types to scan.
bool m_forceSearch
A flag to indicate that the schemtic has been modified and a new search must be performed even if the...
SCH_FIND_REPLACE_DATA m_findReplaceData
The criteria used to test for matching items.
int COLLECTOR::CountType ( KICAD_T  aType)
inlineinherited

Function CountType counts the number of items matching aType.

Parameters
aTypetype we are interested in
Returns
number of occurences

Definition at line 258 of file class_collector.h.

Referenced by SELECTION_TOOL::guessSelectionCandidates().

259  {
260  int cnt = 0;
261  for( size_t i = 0; i < m_List.size(); i++ )
262  {
263  if( m_List[i]->Type() == aType )
264  cnt++;
265  }
266  return cnt;
267  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void SCH_FIND_COLLECTOR::Empty ( )
inline

Definition at line 271 of file sch_collectors.h.

References COLLECTOR::Empty().

Referenced by Collect().

272  {
273  m_foundIndex = 0;
275  m_data.clear();
276  }
void Empty()
Function Empty sets the list to empty.
std::vector< SCH_FIND_COLLECTOR_DATA > m_data
Data associated with each found item.
int m_foundIndex
The current found item list index.
const EDA_RECT& COLLECTOR::GetBoundingBox ( ) const
inlineinherited

Definition at line 227 of file class_collector.h.

References COLLECTOR::m_RefBox.

227 { return m_RefBox; }
EDA_RECT m_RefBox
A bounding box to test against, and that was used to make the collection.
SCH_FIND_COLLECTOR_DATA SCH_FIND_COLLECTOR::GetFindData ( int  aIndex)

Function GetFindData returns the data associated with the item found at aIndex.

Parameters
aIndexThe list index of the data to return.
Returns
The associated found item data at aIndex if aIndex is within the list limits. Otherwise an empty data item will be returned.

Definition at line 419 of file sch_collectors.cpp.

References m_data.

420 {
421  wxCHECK_MSG( (unsigned) aIndex < m_data.size(), SCH_FIND_COLLECTOR_DATA(),
422  wxT( "Attempt to get find data outside of list boundary." ) );
423 
424  return m_data[ aIndex ];
425 }
Class SCH_FIND_COLLECTOR_DATA is used as a data container for the associated item found by the SCH_FI...
std::vector< SCH_FIND_COLLECTOR_DATA > m_data
Data associated with each found item.
int SCH_FIND_COLLECTOR::GetFoundIndex ( ) const
inline

Definition at line 283 of file sch_collectors.h.

References m_foundIndex.

Referenced by SCH_EDIT_FRAME::OnFindReplace().

283 { return m_foundIndex; }
int m_foundIndex
The current found item list index.
EDA_ITEM * SCH_FIND_COLLECTOR::GetItem ( SCH_FIND_COLLECTOR_DATA aFindData)

Function GetItem returns the item and associated data of the current index.

Parameters
aFindDataA reference to a SCH_FIND_COLLECTOR_DATA object to place the associated data for the current item into if the current item index is valid.
Returns
A pointer to the current EDA_ITEM in the list if the list index is valid Otherwise NULL is returned and the aFindData object is not updated.

Definition at line 458 of file sch_collectors.cpp.

References m_data, m_foundIndex, COLLECTOR::m_List, and PassedEnd().

Referenced by SCH_EDIT_FRAME::OnFindReplace(), SCH_EDIT_FRAME::OnFindSchematicItem(), and SCH_EDIT_FRAME::updateFindReplaceView().

459 {
460  if( PassedEnd() )
461  return NULL;
462 
463  aData = m_data[ m_foundIndex ];
464  return m_List[ m_foundIndex ];
465 }
std::vector< SCH_FIND_COLLECTOR_DATA > m_data
Data associated with each found item.
int m_foundIndex
The current found item list index.
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
bool PassedEnd() const
Function PassedEnd tests if m_foundIndex is beyond the end of the list give the current find/replace ...
int SCH_FIND_COLLECTOR::GetLibHash ( ) const
inline

Definition at line 280 of file sch_collectors.h.

References m_lib_hash.

Referenced by SCH_EDIT_FRAME::IsSearchCacheObsolete().

280 { return m_lib_hash; }
int m_lib_hash
last known library change hash, used to detect library changes which should trigger cache obsolescenc...
const wxPoint& COLLECTOR::GetRefPos ( ) const
inlineinherited

Definition at line 224 of file class_collector.h.

References COLLECTOR::m_RefPos.

Referenced by PCB_EDIT_FRAME::OnRightClick().

224 { return m_RefPos; }
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
wxString SCH_FIND_COLLECTOR::GetText ( )

Function GetText()

Returns
A wxString object containing the description of the item found at the current index or a wxEmptyString if the list is empty or the index is invalid.

Definition at line 428 of file sch_collectors.cpp.

References GetChars(), COLLECTOR::GetCount(), SCH_FIND_COLLECTOR_DATA::GetParent(), EDA_ITEM::GetSelectMenuText(), SCH_FIND_COLLECTOR_DATA::GetSheetPath(), COLLECTOR::IsValidIndex(), m_data, m_foundIndex, and COLLECTOR::m_List.

Referenced by SCH_EDIT_FRAME::updateFindReplaceView().

429 {
430  wxCHECK_MSG( (GetCount() != 0) && IsValidIndex( m_foundIndex ), wxEmptyString,
431  wxT( "Cannot get found item at invalid index." ) );
432 
434  EDA_ITEM* foundItem = m_List[ m_foundIndex ];
435 
436  wxCHECK_MSG( foundItem != NULL, wxEmptyString, wxT( "Invalid found item pointer." ) );
437 
438  wxString msg;
439 
440  if( data.GetParent() )
441  {
442  msg.Printf( _( "Child item %s of parent item %s found in sheet %s" ),
443  GetChars( foundItem->GetSelectMenuText() ),
444  GetChars( data.GetParent()->GetSelectMenuText() ),
445  GetChars( data.GetSheetPath() ) );
446  }
447  else
448  {
449  msg.Printf( _( "Item %s found in sheet %s" ),
450  GetChars( foundItem->GetSelectMenuText() ),
451  GetChars( data.GetSheetPath() ) );
452  }
453 
454  return msg;
455 }
int GetCount() const
Function GetCount returns the number of objects in the list.
bool IsValidIndex(int aIndex)
Function IsValidIndex tests if aIndex is with the limits of the list of collected items...
wxString GetSheetPath() const
Class SCH_FIND_COLLECTOR_DATA is used as a data container for the associated item found by the SCH_FI...
std::vector< SCH_FIND_COLLECTOR_DATA > m_data
Data associated with each found item.
virtual wxString GetSelectMenuText() const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
SCH_ITEM * GetParent() const
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
int m_foundIndex
The current found item list index.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
time_t COLLECTOR::GetTime ( )
inlineinherited

Definition at line 218 of file class_collector.h.

References COLLECTOR::m_TimeAtCollection.

219  {
220  return m_TimeAtCollection;
221  }
time_t m_TimeAtCollection
The time at which the collection was made.
bool COLLECTOR::HasItem ( const EDA_ITEM aItem) const
inlineinherited

Function HasItem tests if aItem has already been collected.

Parameters
aItemThe EDA_ITEM* to be tested.
Returns
True if aItem is already collected.

Definition at line 190 of file class_collector.h.

191  {
192  for( size_t i = 0; i < m_List.size(); i++ )
193  {
194  if( m_List[i] == aItem )
195  return true;
196  }
197 
198  return false;
199  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void SCH_FIND_COLLECTOR::IncrementIndex ( )
inline

Definition at line 376 of file sch_collectors.h.

Referenced by SCH_EDIT_FRAME::OnFindReplace().

376 { m_foundIndex += 1; }
int m_foundIndex
The current found item list index.
SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect ( EDA_ITEM aItem,
void *  aTestData 
)
overridevirtual

Implements COLLECTOR.

Definition at line 487 of file sch_collectors.cpp.

References COLLECTOR::Append(), SCH_COMPONENT::GetPosition(), SCH_COMPONENT::GetTransform(), LIB_PIN_T, m_data, m_findReplaceData, m_sheetPath, EDA_ITEM::Matches(), SCH_SHEET_PATH::PathHumanReadable(), SCH_COMPONENT_T, SEARCH_CONTINUE, TRANSFORM::TransformCoordinate(), EDA_ITEM::Type(), and wxPoint::y.

488 {
489  wxPoint position;
490 
491  if( aItem->Matches( m_findReplaceData, m_sheetPath, &position ) )
492  {
493  if( aItem->Type() == LIB_PIN_T )
494  {
495  wxCHECK_MSG( aTestData && ( (EDA_ITEM*) aTestData )->Type() == SCH_COMPONENT_T,
496  SEARCH_CONTINUE, wxT( "Cannot inspect invalid data. Bad programmer!" ) );
497 
498  // Pin positions are relative to their parent component's position and
499  // orientation in the schematic. The pin's position must be converted
500  // schematic coordinates.
501  SCH_COMPONENT* component = (SCH_COMPONENT*) aTestData;
502  TRANSFORM transform = component->GetTransform();
503  position.y = -position.y;
504  position = transform.TransformCoordinate( position ) + component->GetPosition();
505  }
506 
507  Append( aItem );
509  (SCH_ITEM*) aTestData ) );
510  }
511 
512  return SEARCH_CONTINUE;
513 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
TRANSFORM & GetTransform() const
SCH_SHEET_PATH * m_sheetPath
The path of the sheet currently being iterated over.
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:414
Class SCH_FIND_COLLECTOR_DATA is used as a data container for the associated item found by the SCH_FI...
std::vector< SCH_FIND_COLLECTOR_DATA > m_data
Data associated with each found item.
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
wxPoint GetPosition() const override
Function GetPosition.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
SCH_FIND_REPLACE_DATA m_findReplaceData
The criteria used to test for matching items.
bool SCH_FIND_COLLECTOR::IsSearchRequired ( const SCH_FIND_REPLACE_DATA aFindReplaceData)
inline

Function IsSearchRequired checks the current collector state against aFindReplaceData to see if a new search needs to be performed to update the collector.

Parameters
aFindReplaceDataA SCH_FIND_REPLACE_DATA object containing the search criteria to test for changes against the current search criteria.
Returns
True if aFindReplaceData would require a new search to be performaed or the force search flag is true. Otherwise, false is returned.

Definition at line 324 of file sch_collectors.h.

References SCH_FIND_REPLACE_DATA::ChangesCompare(), and SCH_FIND_REPLACE_DATA::IsWrapping().

Referenced by Collect(), and SCH_EDIT_FRAME::IsSearchCacheObsolete().

325  {
326  return m_findReplaceData.ChangesCompare( aFindReplaceData ) || m_forceSearch ||
327  (m_findReplaceData.IsWrapping() != aFindReplaceData.IsWrapping());
328  }
bool ChangesCompare(const SCH_FIND_REPLACE_DATA &aFindReplaceData)
Function ChangesCompare tests aFindReplaceData to see if it would result in a change in the search st...
bool m_forceSearch
A flag to indicate that the schemtic has been modified and a new search must be performed even if the...
SCH_FIND_REPLACE_DATA m_findReplaceData
The criteria used to test for matching items.
bool COLLECTOR::IsSimilarPointAndTime ( const wxPoint aRefPos)
inlineinherited

Function IsSimilarPointAndTime returns true if the given reference point is "similar" (defined here) to the internal reference point and the current time is within a few seconds of the internal m_TimeAtCollection.

Parameters
aRefPosA wxPoint to compare to.
Returns
bool - true if the point and time are similar, else false.

Definition at line 238 of file class_collector.h.

References abs, GetNewTimeStamp(), wxPoint::x, and wxPoint::y.

239  {
240  const int distMax = 2; // adjust these here
241  const time_t timeMax = 3; // seconds
242 
243  int dx = abs( aRefPos.x - m_RefPos.x );
244  int dy = abs( aRefPos.y - m_RefPos.y );
245 
246  if( dx <= distMax && dy <= distMax &&
247  (int)GetNewTimeStamp() - m_TimeAtCollection <= timeMax )
248  return true;
249  else
250  return false;
251  }
time_t GetNewTimeStamp()
Definition: common.cpp:166
#define abs(a)
Definition: auxiliary.h:84
time_t m_TimeAtCollection
The time at which the collection was made.
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
bool COLLECTOR::IsValidIndex ( int  aIndex)
inlineinherited

Function IsValidIndex tests if aIndex is with the limits of the list of collected items.

Parameters
aIndexThe index to test.
Returns
True if aIndex is with the limits of the list of collected items, otherwise false.

Definition at line 98 of file class_collector.h.

Referenced by GetText(), and ReplaceItem().

99  {
100  return ( (unsigned) aIndex < m_List.size() );
101  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
EDA_ITEM* COLLECTOR::operator[] ( int  aIndex) const
inlineinherited

Function operator[int] is used for read only access and returns the object at aIndex.

Parameters
aIndexThe index into the list.
Returns
EDA_ITEM* - or something derived from it, or NULL.

Definition at line 164 of file class_collector.h.

References COLLECTOR::GetCount().

165  {
166  if( (unsigned)aIndex < (unsigned)GetCount() ) // (unsigned) excludes aIndex<0 also
167  return m_List[ aIndex ];
168 
169  return NULL;
170  }
int GetCount() const
Function GetCount returns the number of objects in the list.
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
bool SCH_FIND_COLLECTOR::PassedEnd ( ) const

Function PassedEnd tests if m_foundIndex is beyond the end of the list give the current find/replace criterial in m_findReplaceData.

Returns
True if m_foundIndex has crossed the end of the found item list.

Definition at line 352 of file sch_collectors.cpp.

References FR_SEARCH_REPLACE, FR_SEARCH_WRAP, COLLECTOR::GetCount(), m_findReplaceData, and m_foundIndex.

Referenced by GetItem(), SCH_EDIT_FRAME::OnFindReplace(), and ReplaceItem().

353 {
354  bool retv = false;
355 
356  wxUint32 flags = m_findReplaceData.GetFlags();
357 
358  if( GetCount() == 0 )
359  return true;
360 
361  if( !(flags & FR_SEARCH_WRAP) || (flags & FR_SEARCH_REPLACE) )
362  {
363  if( flags & wxFR_DOWN )
364  {
365  if( m_foundIndex >= GetCount() )
366  retv = true;
367  }
368  else
369  {
370  if( m_foundIndex < 0 )
371  retv = true;
372  }
373  }
374 
375  return retv;
376 }
int GetCount() const
Function GetCount returns the number of objects in the list.
Wrap around the beginning or end of search list.
int m_foundIndex
The current found item list index.
Perform a search for a item that has replaceable text.
SCH_FIND_REPLACE_DATA m_findReplaceData
The criteria used to test for matching items.
void COLLECTOR::Remove ( int  aIndex)
inlineinherited

Function Remove removes the item at aIndex (first position is 0);.

Parameters
aIndexThe index into the list.

Definition at line 136 of file class_collector.h.

Referenced by SELECTION_TOOL::guessSelectionCandidates(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), GERBVIEW_SELECTION_TOOL::selectPoint(), and SELECTION_TOOL::selectPoint().

137  {
138  m_List.erase( m_List.begin() + aIndex );
139  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void COLLECTOR::Remove ( const EDA_ITEM aItem)
inlineinherited

Function Remove removes the item aItem (if exists in the collector).

Parameters
aItemthe item to be removed.

Definition at line 146 of file class_collector.h.

147  {
148  for( size_t i = 0; i < m_List.size(); i++ )
149  {
150  if( m_List[i] == aItem )
151  {
152  m_List.erase( m_List.begin() + i);
153  return;
154  }
155  }
156  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
bool SCH_FIND_COLLECTOR::ReplaceItem ( SCH_SHEET_PATH aSheetPath = NULL)

Function ReplaceItem performs a string replace of the item at the current index.

Returns
True if the text replace occurred otherwise false.

Definition at line 468 of file sch_collectors.cpp.

References COLLECTOR::IsValidIndex(), m_findReplaceData, m_foundIndex, COLLECTOR::m_List, PassedEnd(), EDA_ITEM::Replace(), and SetForceSearch().

Referenced by SCH_EDIT_FRAME::OnFindReplace().

469 {
470  if( PassedEnd() )
471  return false;
472 
473  wxCHECK_MSG( IsValidIndex( m_foundIndex ), false,
474  wxT( "Invalid replace list index in SCH_FIND_COLLECTOR." ) );
475 
476  EDA_ITEM* item = m_List[ m_foundIndex ];
477 
478  bool replaced = item->Replace( m_findReplaceData, aSheetPath );
479 
480  if( replaced )
481  SetForceSearch();
482 
483  return replaced;
484 }
bool IsValidIndex(int aIndex)
Function IsValidIndex tests if aIndex is with the limits of the list of collected items...
bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
void SetForceSearch(bool doSearch=true)
int m_foundIndex
The current found item list index.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
bool PassedEnd() const
Function PassedEnd tests if m_foundIndex is beyond the end of the list give the current find/replace ...
SCH_FIND_REPLACE_DATA m_findReplaceData
The criteria used to test for matching items.
void COLLECTOR::SetBoundingBox ( const EDA_RECT aRefBox)
inlineinherited

Definition at line 226 of file class_collector.h.

226 { m_RefBox = aRefBox; }
EDA_RECT m_RefBox
A bounding box to test against, and that was used to make the collection.
void SCH_FIND_COLLECTOR::SetForceSearch ( bool  doSearch = true)
inline

Definition at line 278 of file sch_collectors.h.

Referenced by Collect(), SCH_EDIT_FRAME::IsSearchCacheObsolete(), ReplaceItem(), and SCH_FIND_COLLECTOR().

278 { m_forceSearch = doSearch; }
bool m_forceSearch
A flag to indicate that the schemtic has been modified and a new search must be performed even if the...
void SCH_FIND_COLLECTOR::SetFoundIndex ( int  aIndex)
inline

Definition at line 284 of file sch_collectors.h.

Referenced by SCH_EDIT_FRAME::OnFindReplace().

285  {
286  m_foundIndex = ( (unsigned) aIndex < m_data.size() ) ? aIndex : 0;
287  }
std::vector< SCH_FIND_COLLECTOR_DATA > m_data
Data associated with each found item.
int m_foundIndex
The current found item list index.
void SCH_FIND_COLLECTOR::SetLibHash ( int  aHash)
inline

Definition at line 281 of file sch_collectors.h.

Referenced by SCH_EDIT_FRAME::IsSearchCacheObsolete().

281 { m_lib_hash = aHash; }
int m_lib_hash
last known library change hash, used to detect library changes which should trigger cache obsolescenc...
void COLLECTOR::SetRefPos ( const wxPoint aRefPos)
inlineinherited

Definition at line 223 of file class_collector.h.

Referenced by LIB_COLLECTOR::Collect(), GERBER_COLLECTOR::Collect(), SCH_COLLECTOR::Collect(), and GENERAL_COLLECTOR::Collect().

223 { m_RefPos = aRefPos; }
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
void SCH_FIND_COLLECTOR::SetReplaceString ( const wxString &  aReplaceString)

Update the replace string without changing anything else.

Definition at line 516 of file sch_collectors.cpp.

References m_findReplaceData.

Referenced by SCH_EDIT_FRAME::OnFindReplace().

517 {
518  m_findReplaceData.SetReplaceString( aReplaceString );
519 }
SCH_FIND_REPLACE_DATA m_findReplaceData
The criteria used to test for matching items.
void COLLECTOR::SetScanTypes ( const KICAD_T scanTypes)
inlineinherited

Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() function.

Parameters
scanTypesAn array of KICAD_T, terminated by EOT. No copy is is made of this array (so cannot come from caller's stack).

Definition at line 208 of file class_collector.h.

Referenced by LIB_COLLECTOR::Collect(), GERBER_COLLECTOR::Collect(), SCH_COLLECTOR::Collect(), GENERAL_COLLECTOR::Collect(), SCH_TYPE_COLLECTOR::Collect(), GENERAL_COLLECTOR::GENERAL_COLLECTOR(), GERBER_COLLECTOR::GERBER_COLLECTOR(), LIB_COLLECTOR::LIB_COLLECTOR(), SCH_COLLECTOR::SCH_COLLECTOR(), and SCH_FIND_COLLECTOR().

209  {
210  m_ScanTypes = scanTypes;
211  }
const KICAD_T * m_ScanTypes
Which object types to scan.
void COLLECTOR::SetTimeNow ( )
inlineinherited

Definition at line 213 of file class_collector.h.

References GetNewTimeStamp().

Referenced by GERBER_COLLECTOR::Collect(), and GENERAL_COLLECTOR::Collect().

214  {
216  }
time_t GetNewTimeStamp()
Definition: common.cpp:166
time_t m_TimeAtCollection
The time at which the collection was made.
void SCH_FIND_COLLECTOR::UpdateIndex ( )

Function UpdateIndex updates the list index according to the current find and replace criteria.

Definition at line 398 of file sch_collectors.cpp.

References FR_SEARCH_WRAP, COLLECTOR::GetCount(), m_findReplaceData, and m_foundIndex.

Referenced by SCH_EDIT_FRAME::OnFindSchematicItem().

399 {
400  wxUint32 flags = m_findReplaceData.GetFlags();
401 
402  if( flags & wxFR_DOWN )
403  {
404  if( m_foundIndex < GetCount() )
405  m_foundIndex += 1;
406  if( (m_foundIndex >= GetCount()) && (flags & FR_SEARCH_WRAP) )
407  m_foundIndex = 0;
408  }
409  else
410  {
411  if( m_foundIndex >= 0 )
412  m_foundIndex -= 1;
413  if( (m_foundIndex < 0) && (flags & FR_SEARCH_WRAP) )
414  m_foundIndex = GetCount() - 1;
415  }
416 }
int GetCount() const
Function GetCount returns the number of objects in the list.
Wrap around the beginning or end of search list.
int m_foundIndex
The current found item list index.
SCH_FIND_REPLACE_DATA m_findReplaceData
The criteria used to test for matching items.

Member Data Documentation

std::vector< SCH_FIND_COLLECTOR_DATA > SCH_FIND_COLLECTOR::m_data
private

Data associated with each found item.

Definition at line 230 of file sch_collectors.h.

Referenced by Collect(), GetFindData(), GetItem(), GetText(), and Inspect().

SCH_FIND_REPLACE_DATA SCH_FIND_COLLECTOR::m_findReplaceData
private

The criteria used to test for matching items.

Definition at line 233 of file sch_collectors.h.

Referenced by Collect(), Inspect(), PassedEnd(), ReplaceItem(), SetReplaceString(), and UpdateIndex().

bool SCH_FIND_COLLECTOR::m_forceSearch
private

A flag to indicate that the schemtic has been modified and a new search must be performed even if the search criteria hasn't changed.

Definition at line 243 of file sch_collectors.h.

Referenced by Collect().

int SCH_FIND_COLLECTOR::m_foundIndex
private

The current found item list index.

Definition at line 239 of file sch_collectors.h.

Referenced by Collect(), GetFoundIndex(), GetItem(), GetText(), PassedEnd(), ReplaceItem(), and UpdateIndex().

INSPECTOR_FUNC COLLECTOR::m_inspector
protectedinherited
int SCH_FIND_COLLECTOR::m_lib_hash
private

last known library change hash, used to detect library changes which should trigger cache obsolescence.

Definition at line 247 of file sch_collectors.h.

Referenced by GetLibHash().

EDA_RECT COLLECTOR::m_RefBox
protectedinherited

A bounding box to test against, and that was used to make the collection.

Definition at line 72 of file class_collector.h.

Referenced by COLLECTOR::GetBoundingBox().

wxPoint COLLECTOR::m_RefPos
protectedinherited

A point to test against, and that was used to make the collection.

Definition at line 69 of file class_collector.h.

Referenced by COLLECTOR::GetRefPos(), LIB_COLLECTOR::Inspect(), GERBER_COLLECTOR::Inspect(), SCH_COLLECTOR::Inspect(), GENERAL_COLLECTOR::Inspect(), and SCH_COLLECTOR::IsDraggableJunction().

const KICAD_T* COLLECTOR::m_ScanTypes
protectedinherited
SCH_SHEET_PATH* SCH_FIND_COLLECTOR::m_sheetPath
private

The path of the sheet currently being iterated over.

Definition at line 236 of file sch_collectors.h.

Referenced by Collect(), and Inspect().

time_t COLLECTOR::m_TimeAtCollection
protectedinherited

The time at which the collection was made.

Definition at line 75 of file class_collector.h.

Referenced by COLLECTOR::GetTime().


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