Naming conventions.

This commit is contained in:
Jeff Young 2020-10-02 21:25:14 +01:00
parent cc617b715f
commit 4c5db9681c
7 changed files with 80 additions and 111 deletions

View File

@ -90,7 +90,7 @@ SEARCH_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
return SEARCH_RESULT::CONTINUE; return SEARCH_RESULT::CONTINUE;
} }
if( aItem->HitTest( m_RefPos, m_Threshold ) ) if( aItem->HitTest( m_refPos, m_Threshold ) )
Append( aItem ); Append( aItem );
return SEARCH_RESULT::CONTINUE; return SEARCH_RESULT::CONTINUE;
@ -126,20 +126,20 @@ void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], co
if( *filter == SCH_SHEET_T || *filter == SCH_LOCATE_ANY_T ) if( *filter == SCH_SHEET_T || *filter == SCH_LOCATE_ANY_T )
sheetsVisited = true; sheetsVisited = true;
item->Visit( m_inspector, nullptr, m_ScanTypes ); item->Visit( m_inspector, nullptr, m_scanTypes );
} }
} }
if( !componentsVisited ) if( !componentsVisited )
{ {
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_COMPONENT_T ) ) for( SCH_ITEM* item : aScreen->Items().OfType( SCH_COMPONENT_T ) )
item->Visit( m_inspector, nullptr, m_ScanTypes ); item->Visit( m_inspector, nullptr, m_scanTypes );
} }
if( !sheetsVisited ) if( !sheetsVisited )
{ {
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SHEET_T ) ) for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SHEET_T ) )
item->Visit( m_inspector, nullptr, m_ScanTypes ); item->Visit( m_inspector, nullptr, m_scanTypes );
} }
} }
} }
@ -159,7 +159,7 @@ void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const KICAD_T aFilterLi
for( auto& item : aItems ) for( auto& item : aItems )
{ {
if( item.Visit( m_inspector, nullptr, m_ScanTypes ) == SEARCH_RESULT::QUIT ) if( item.Visit( m_inspector, nullptr, m_scanTypes ) == SEARCH_RESULT::QUIT )
break; break;
} }
} }
@ -170,16 +170,16 @@ bool EE_COLLECTOR::IsCorner() const
if( GetCount() != 2 ) if( GetCount() != 2 )
return false; return false;
bool is_busentry0 = (dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[0] ) != NULL); bool is_busentry0 = ( dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_list[0] ) != NULL);
bool is_busentry1 = (dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[1] ) != NULL); bool is_busentry1 = ( dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_list[1] ) != NULL);
if( (m_List[0]->Type() == SCH_LINE_T) && (m_List[1]->Type() == SCH_LINE_T) ) if(( m_list[0]->Type() == SCH_LINE_T) && ( m_list[1]->Type() == SCH_LINE_T) )
return ( ( SCH_LINE* ) m_List[0])->GetLayer() == ( ( SCH_LINE* ) m_List[1])->GetLayer(); return ( ( SCH_LINE* ) m_list[0])->GetLayer() == ( ( SCH_LINE* ) m_list[1])->GetLayer();
if( (m_List[0]->Type() == SCH_LINE_T) && is_busentry1 ) if(( m_list[0]->Type() == SCH_LINE_T) && is_busentry1 )
return true; return true;
if( is_busentry0 && (m_List[1]->Type() == SCH_LINE_T) ) if( is_busentry0 && ( m_list[1]->Type() == SCH_LINE_T) )
return true; return true;
return false; return false;

View File

@ -63,7 +63,7 @@ public:
SCH_ITEM* operator[]( int aIndex ) const override SCH_ITEM* operator[]( int aIndex ) const override
{ {
if( (unsigned)aIndex < (unsigned)GetCount() ) if( (unsigned)aIndex < (unsigned)GetCount() )
return (SCH_ITEM*) m_List[ aIndex ]; return (SCH_ITEM*) m_list[ aIndex ];
return NULL; return NULL;
} }

View File

@ -39,7 +39,7 @@ const KICAD_T GERBER_COLLECTOR::AllItems[] = {
*/ */
SEARCH_RESULT GERBER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) SEARCH_RESULT GERBER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
{ {
if( testItem->HitTest( m_RefPos ) ) if( testItem->HitTest( m_refPos ) )
Append( testItem ); Append( testItem );
return SEARCH_RESULT::CONTINUE; return SEARCH_RESULT::CONTINUE;
@ -60,8 +60,8 @@ void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aScanList[],
// the Inspect() function. // the Inspect() function.
SetRefPos( aRefPos ); SetRefPos( aRefPos );
aItem->Visit( m_inspector, NULL, m_ScanTypes ); aItem->Visit( m_inspector, NULL, m_scanTypes );
// record the length of the primary list before concatenating on to it. // record the length of the primary list before concatenating on to it.
m_PrimaryLength = m_List.size(); m_PrimaryLength = m_list.size();
} }

View File

@ -95,7 +95,7 @@ public:
EDA_ITEM* operator[]( int ndx ) const override EDA_ITEM* operator[]( int ndx ) const override
{ {
if( (unsigned)ndx < (unsigned)GetCount() ) if( (unsigned)ndx < (unsigned)GetCount() )
return (EDA_ITEM*) m_List[ ndx ]; return (EDA_ITEM*) m_list[ ndx ];
return NULL; return NULL;
} }
@ -123,7 +123,7 @@ public:
* @param aItem An EDA_ITEM to scan * @param aItem An EDA_ITEM to scan
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs * @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
* what is to be collected and the priority order of the resultant * what is to be collected and the priority order of the resultant
* collection in "m_List". * collection in "m_list".
* @param aRefPos A wxPoint to use in hit-testing. * @param aRefPos A wxPoint to use in hit-testing.
* @param aGuide The COLLECTORS_GUIDE to use in collecting items. * @param aGuide The COLLECTORS_GUIDE to use in collecting items.
*/ */

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -55,13 +55,13 @@ class EDA_ITEM;
class COLLECTOR class COLLECTOR
{ {
protected: protected:
std::vector<EDA_ITEM*> m_List; // Primary list of most likely items std::vector<EDA_ITEM*> m_list; // Primary list of most likely items
std::vector<EDA_ITEM*> m_BackupList; // Secondary list with items removed by heuristics std::vector<EDA_ITEM*> m_backupList; // Secondary list with items removed by heuristics
const KICAD_T* m_ScanTypes; const KICAD_T* m_scanTypes;
INSPECTOR_FUNC m_inspector; INSPECTOR_FUNC m_inspector;
wxPoint m_RefPos; // Reference position used to generate the collection. wxPoint m_refPos; // Reference position used to generate the collection.
EDA_RECT m_RefBox; // Selection rectangle used to generate the collection. EDA_RECT m_refBox; // Selection rectangle used to generate the collection.
public: public:
int m_Threshold; // Hit-test threshold in internal units. int m_Threshold; // Hit-test threshold in internal units.
@ -71,11 +71,15 @@ public:
public: public:
COLLECTOR() : COLLECTOR() :
m_ScanTypes( 0 ), m_scanTypes( 0 ),
// Inspect() is virtual so calling it from a class common inspector preserves polymorphism. // Inspect() is virtual so calling it from a class common inspector preserves
m_inspector( [=] ( EDA_ITEM* aItem, void* aTestData ) { return this->Inspect( aItem, aTestData ); } ), // polymorphism.
m_Threshold( 0 ), m_inspector( [=]( EDA_ITEM* aItem, void* aTestData )
m_MenuCancelled( false ) {
return this->Inspect( aItem, aTestData );
} ),
m_Threshold( 0 ),
m_MenuCancelled( false )
{ {
} }
@ -89,10 +93,10 @@ public:
using ITER = std::vector<EDA_ITEM*>::iterator; using ITER = std::vector<EDA_ITEM*>::iterator;
using CITER = std::vector<EDA_ITEM*>::const_iterator; using CITER = std::vector<EDA_ITEM*>::const_iterator;
ITER begin() { return m_List.begin(); } ITER begin() { return m_list.begin(); }
ITER end() { return m_List.end(); } ITER end() { return m_list.end(); }
CITER begin() const { return m_List.cbegin(); } CITER begin() const { return m_list.cbegin(); }
CITER end() const { return m_List.cend(); } CITER end() const { return m_list.cend(); }
/** /**
* Function GetCount * Function GetCount
@ -100,7 +104,7 @@ public:
*/ */
int GetCount() const int GetCount() const
{ {
return (int) m_List.size(); return (int) m_list.size();
} }
/** /**
@ -109,7 +113,7 @@ public:
*/ */
void Empty() void Empty()
{ {
m_List.clear(); m_list.clear();
} }
/** /**
@ -119,7 +123,7 @@ public:
*/ */
void Append( EDA_ITEM* item ) void Append( EDA_ITEM* item )
{ {
m_List.push_back( item ); m_list.push_back( item );
} }
/** /**
@ -129,7 +133,7 @@ public:
*/ */
void Remove( int aIndex ) void Remove( int aIndex )
{ {
m_List.erase( m_List.begin() + aIndex ); m_list.erase( m_list.begin() + aIndex );
} }
/** /**
@ -139,11 +143,11 @@ public:
*/ */
void Remove( const EDA_ITEM* aItem ) void Remove( const EDA_ITEM* aItem )
{ {
for( size_t i = 0; i < m_List.size(); i++ ) for( size_t i = 0; i < m_list.size(); i++ )
{ {
if( m_List[i] == aItem ) if( m_list[i] == aItem )
{ {
m_List.erase( m_List.begin() + i); m_list.erase( m_list.begin() + i);
return; return;
} }
} }
@ -155,7 +159,7 @@ public:
*/ */
bool HasAdditionalItems() bool HasAdditionalItems()
{ {
return !m_BackupList.empty(); return !m_backupList.empty();
} }
/** /**
@ -163,8 +167,8 @@ public:
*/ */
void Combine() void Combine()
{ {
std::copy( m_BackupList.begin(), m_BackupList.end(), std::back_inserter( m_List ) ); std::copy( m_backupList.begin(), m_backupList.end(), std::back_inserter( m_list ) );
m_BackupList.clear(); m_backupList.clear();
} }
/** /**
@ -173,8 +177,8 @@ public:
*/ */
void Transfer( int aIndex ) void Transfer( int aIndex )
{ {
m_BackupList.push_back( m_List[aIndex] ); m_backupList.push_back( m_list[aIndex] );
m_List.erase( m_List.begin() + aIndex ); m_list.erase( m_list.begin() + aIndex );
} }
/** /**
@ -183,12 +187,12 @@ public:
*/ */
void Transfer( EDA_ITEM* aItem ) void Transfer( EDA_ITEM* aItem )
{ {
for( size_t i = 0; i < m_List.size(); i++ ) for( size_t i = 0; i < m_list.size(); i++ )
{ {
if( m_List[i] == aItem ) if( m_list[i] == aItem )
{ {
m_List.erase( m_List.begin() + i ); m_list.erase( m_list.begin() + i );
m_BackupList.push_back( aItem ); m_backupList.push_back( aItem );
return; return;
} }
} }
@ -203,22 +207,11 @@ public:
virtual EDA_ITEM* operator[]( int aIndex ) const virtual EDA_ITEM* operator[]( int aIndex ) const
{ {
if( (unsigned)aIndex < (unsigned)GetCount() ) // (unsigned) excludes aIndex<0 also if( (unsigned)aIndex < (unsigned)GetCount() ) // (unsigned) excludes aIndex<0 also
return m_List[ aIndex ]; return m_list[ aIndex ];
return NULL; return NULL;
} }
/**
* 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.
*/
EDA_ITEM* const* BasePtr() const
{
return &m_List[0];
}
/** /**
* Function HasItem * Function HasItem
* tests if \a aItem has already been collected. * tests if \a aItem has already been collected.
@ -228,9 +221,9 @@ public:
*/ */
bool HasItem( const EDA_ITEM* aItem ) const bool HasItem( const EDA_ITEM* aItem ) const
{ {
for( size_t i = 0; i < m_List.size(); i++ ) for( size_t i = 0; i < m_list.size(); i++ )
{ {
if( m_List[i] == aItem ) if( m_list[i] == aItem )
return true; return true;
} }
@ -246,12 +239,12 @@ public:
*/ */
void SetScanTypes( const KICAD_T* scanTypes ) void SetScanTypes( const KICAD_T* scanTypes )
{ {
m_ScanTypes = scanTypes; m_scanTypes = scanTypes;
} }
void SetRefPos( const wxPoint& aRefPos ) { m_RefPos = aRefPos; } void SetRefPos( const wxPoint& aRefPos ) { m_refPos = aRefPos; }
const EDA_RECT& GetBoundingBox() const { return m_RefBox; } const EDA_RECT& GetBoundingBox() const { return m_refBox; }
/** /**
* Function CountType * Function CountType
@ -262,37 +255,13 @@ public:
int CountType( KICAD_T aType ) int CountType( KICAD_T aType )
{ {
int cnt = 0; int cnt = 0;
for( size_t i = 0; i < m_List.size(); i++ ) for( size_t i = 0; i < m_list.size(); i++ )
{ {
if( m_List[i]->Type() == aType ) if( m_list[i]->Type() == aType )
cnt++; cnt++;
} }
return cnt; return cnt;
} }
/**
* Function Collect
* scans an EDA_ITEM using this class's Inspector method, which does
* the collection.
* @param container An EDA_ITEM to scan, including those items it contains.
* @param aRefPos A wxPoint to use in hit-testing.
*
* example implementation, in derived class:
*
void Collect( EDA_ITEM* container, const wxPoint& aRefPos )
{
example implementation:
SetRefPos( aRefPos ); // remember where the snapshot was taken from
Empty(); // empty the collection
// visit the board with the INSPECTOR (me).
container->Visit( inspector, &aRefPos,
m_ScanTypes);
SetTimeNow(); // when it was taken
}
*/
}; };
#endif // COLLECTOR_H #endif // COLLECTOR_H

View File

@ -421,7 +421,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
if( marker ) if( marker )
{ {
// Markers are not sensitive to the layer // Markers are not sensitive to the layer
if( marker->HitTest( m_RefPos ) ) if( marker->HitTest( m_refPos ) )
Append( item ); Append( item );
goto exit; goto exit;
@ -430,7 +430,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
if( group ) if( group )
{ {
// Groups are not sensitive to the layer ... ? // Groups are not sensitive to the layer ... ?
if( group->HitTest( m_RefPos ) ) if( group->HitTest( m_refPos ) )
Append( item ); Append( item );
goto exit; goto exit;
@ -470,9 +470,9 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
{ {
bool testFill = !m_Guide->IgnoreZoneFills(); bool testFill = !m_Guide->IgnoreZoneFills();
if( zone->HitTestForCorner( m_RefPos, accuracy * 2 ) if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
|| zone->HitTestForEdge( m_RefPos, accuracy ) || zone->HitTestForEdge( m_refPos, accuracy )
|| ( testFill && zone->HitTestFilledArea( layer, m_RefPos ) ) ) || ( testFill && zone->HitTestFilledArea( layer, m_refPos ) ) )
{ {
Append( item ); Append( item );
goto exit; goto exit;
@ -480,8 +480,8 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
} }
else if( item->Type() == PCB_MODULE_T ) else if( item->Type() == PCB_MODULE_T )
{ {
if( module->HitTest( m_RefPos, accuracy ) if( module->HitTest( m_refPos, accuracy )
&& module->HitTestAccurate( m_RefPos, accuracy ) ) && module->HitTestAccurate( m_refPos, accuracy ) )
{ {
Append( item ); Append( item );
goto exit; goto exit;
@ -489,7 +489,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
} }
else if( drawSegment ) else if( drawSegment )
{ {
if( drawSegment->HitTest( m_RefPos, accuracy ) ) if( drawSegment->HitTest( m_refPos, accuracy ) )
{ {
Append( item ); Append( item );
goto exit; goto exit;
@ -497,7 +497,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
} }
else else
{ {
if( item->HitTest( m_RefPos, 0 ) ) if( item->HitTest( m_refPos, 0 ) )
{ {
Append( item ); Append( item );
goto exit; goto exit;
@ -534,9 +534,9 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
{ {
bool testFill = !m_Guide->IgnoreZoneFills(); bool testFill = !m_Guide->IgnoreZoneFills();
if( zone->HitTestForCorner( m_RefPos, accuracy * 2 ) if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
|| zone->HitTestForEdge( m_RefPos, accuracy ) || zone->HitTestForEdge( m_refPos, accuracy )
|| ( testFill && zone->HitTestFilledArea( layer, m_RefPos ) ) ) || ( testFill && zone->HitTestFilledArea( layer, m_refPos ) ) )
{ {
Append2nd( item ); Append2nd( item );
goto exit; goto exit;
@ -544,8 +544,8 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
} }
else if( item->Type() == PCB_MODULE_T ) else if( item->Type() == PCB_MODULE_T )
{ {
if( module->HitTest( m_RefPos, accuracy ) if( module->HitTest( m_refPos, accuracy )
&& module->HitTestAccurate( m_RefPos, accuracy ) ) && module->HitTestAccurate( m_refPos, accuracy ) )
{ {
Append( item ); Append( item );
goto exit; goto exit;
@ -553,7 +553,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
} }
else if( drawSegment ) else if( drawSegment )
{ {
if( drawSegment->HitTest( m_RefPos, accuracy ) ) if( drawSegment->HitTest( m_refPos, accuracy ) )
{ {
Append( item ); Append( item );
goto exit; goto exit;
@ -561,7 +561,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
} }
else else
{ {
if( item->HitTest( m_RefPos, 0 ) ) if( item->HitTest( m_refPos, 0 ) )
{ {
Append( item ); Append( item );
goto exit; goto exit;
@ -592,10 +592,10 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
// the Inspect() function. // the Inspect() function.
SetRefPos( aRefPos ); SetRefPos( aRefPos );
aItem->Visit( m_inspector, NULL, m_ScanTypes ); aItem->Visit( m_inspector, NULL, m_scanTypes );
// record the length of the primary list before concatenating on to it. // record the length of the primary list before concatenating on to it.
m_PrimaryLength = m_List.size(); m_PrimaryLength = m_list.size();
// append 2nd list onto end of the first list // append 2nd list onto end of the first list
for( unsigned i = 0; i<m_List2nd.size(); ++i ) for( unsigned i = 0; i<m_List2nd.size(); ++i )

View File

@ -221,7 +221,7 @@ public:
BOARD_ITEM* operator[]( int ndx ) const override BOARD_ITEM* operator[]( int ndx ) const override
{ {
if( (unsigned)ndx < (unsigned)GetCount() ) if( (unsigned)ndx < (unsigned)GetCount() )
return (BOARD_ITEM*) m_List[ ndx ]; return (BOARD_ITEM*) m_list[ ndx ];
return NULL; return NULL;
} }
@ -374,7 +374,7 @@ public:
* @param aItem A BOARD_ITEM to scan, may be a BOARD or MODULE, or whatever. * @param aItem A BOARD_ITEM to scan, may be a BOARD or MODULE, or whatever.
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs * @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
* what is to be collected and the priority order of the resultant * what is to be collected and the priority order of the resultant
* collection in "m_List". * collection in "m_list".
* @param aRefPos A wxPoint to use in hit-testing. * @param aRefPos A wxPoint to use in hit-testing.
* @param aGuide The COLLECTORS_GUIDE to use in collecting items. * @param aGuide The COLLECTORS_GUIDE to use in collecting items.
*/ */