From 4c5db9681cee5468a9d95d7f6037b65ae1c1f5cf Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 2 Oct 2020 21:25:14 +0100 Subject: [PATCH] Naming conventions. --- eeschema/ee_collectors.cpp | 22 +++---- eeschema/ee_collectors.h | 2 +- gerbview/gerber_collectors.cpp | 6 +- gerbview/gerber_collectors.h | 4 +- include/collector.h | 117 ++++++++++++--------------------- pcbnew/collectors.cpp | 36 +++++----- pcbnew/collectors.h | 4 +- 7 files changed, 80 insertions(+), 111 deletions(-) diff --git a/eeschema/ee_collectors.cpp b/eeschema/ee_collectors.cpp index 9e6b84f0a3..c947511a71 100644 --- a/eeschema/ee_collectors.cpp +++ b/eeschema/ee_collectors.cpp @@ -90,7 +90,7 @@ SEARCH_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData ) return SEARCH_RESULT::CONTINUE; } - if( aItem->HitTest( m_RefPos, m_Threshold ) ) + if( aItem->HitTest( m_refPos, m_Threshold ) ) Append( aItem ); 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 ) sheetsVisited = true; - item->Visit( m_inspector, nullptr, m_ScanTypes ); + item->Visit( m_inspector, nullptr, m_scanTypes ); } } if( !componentsVisited ) { 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 ) { 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 ) { - if( item.Visit( m_inspector, nullptr, m_ScanTypes ) == SEARCH_RESULT::QUIT ) + if( item.Visit( m_inspector, nullptr, m_scanTypes ) == SEARCH_RESULT::QUIT ) break; } } @@ -170,16 +170,16 @@ bool EE_COLLECTOR::IsCorner() const if( GetCount() != 2 ) return false; - bool is_busentry0 = (dynamic_cast( m_List[0] ) != NULL); - bool is_busentry1 = (dynamic_cast( m_List[1] ) != NULL); + bool is_busentry0 = ( dynamic_cast( m_list[0] ) != NULL); + bool is_busentry1 = ( dynamic_cast( m_list[1] ) != NULL); - 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(); + 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(); - if( (m_List[0]->Type() == SCH_LINE_T) && is_busentry1 ) + if(( m_list[0]->Type() == SCH_LINE_T) && is_busentry1 ) 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 false; diff --git a/eeschema/ee_collectors.h b/eeschema/ee_collectors.h index 9e29bd19d9..f8ffbdaa7c 100644 --- a/eeschema/ee_collectors.h +++ b/eeschema/ee_collectors.h @@ -63,7 +63,7 @@ public: SCH_ITEM* operator[]( int aIndex ) const override { if( (unsigned)aIndex < (unsigned)GetCount() ) - return (SCH_ITEM*) m_List[ aIndex ]; + return (SCH_ITEM*) m_list[ aIndex ]; return NULL; } diff --git a/gerbview/gerber_collectors.cpp b/gerbview/gerber_collectors.cpp index 9d9a62a8a7..036cb3a505 100644 --- a/gerbview/gerber_collectors.cpp +++ b/gerbview/gerber_collectors.cpp @@ -39,7 +39,7 @@ const KICAD_T GERBER_COLLECTOR::AllItems[] = { */ SEARCH_RESULT GERBER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) { - if( testItem->HitTest( m_RefPos ) ) + if( testItem->HitTest( m_refPos ) ) Append( testItem ); return SEARCH_RESULT::CONTINUE; @@ -60,8 +60,8 @@ void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aScanList[], // the Inspect() function. 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. - m_PrimaryLength = m_List.size(); + m_PrimaryLength = m_list.size(); } diff --git a/gerbview/gerber_collectors.h b/gerbview/gerber_collectors.h index bbe729cdfb..6c738c24b4 100644 --- a/gerbview/gerber_collectors.h +++ b/gerbview/gerber_collectors.h @@ -95,7 +95,7 @@ public: EDA_ITEM* operator[]( int ndx ) const override { if( (unsigned)ndx < (unsigned)GetCount() ) - return (EDA_ITEM*) m_List[ ndx ]; + return (EDA_ITEM*) m_list[ ndx ]; return NULL; } @@ -123,7 +123,7 @@ public: * @param aItem An EDA_ITEM to scan * @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 - * collection in "m_List". + * collection in "m_list". * @param aRefPos A wxPoint to use in hit-testing. * @param aGuide The COLLECTORS_GUIDE to use in collecting items. */ diff --git a/include/collector.h b/include/collector.h index ac957103f9..f755f711c1 100644 --- a/include/collector.h +++ b/include/collector.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck - * 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 * modify it under the terms of the GNU General Public License @@ -55,13 +55,13 @@ class EDA_ITEM; class COLLECTOR { protected: - std::vector m_List; // Primary list of most likely items - std::vector m_BackupList; // Secondary list with items removed by heuristics + std::vector m_list; // Primary list of most likely items + std::vector m_backupList; // Secondary list with items removed by heuristics - const KICAD_T* m_ScanTypes; + const KICAD_T* m_scanTypes; INSPECTOR_FUNC m_inspector; - wxPoint m_RefPos; // Reference position used to generate the collection. - EDA_RECT m_RefBox; // Selection rectangle 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. public: int m_Threshold; // Hit-test threshold in internal units. @@ -71,11 +71,15 @@ public: public: COLLECTOR() : - m_ScanTypes( 0 ), - // Inspect() is virtual so calling it from a class common inspector preserves polymorphism. - m_inspector( [=] ( EDA_ITEM* aItem, void* aTestData ) { return this->Inspect( aItem, aTestData ); } ), - m_Threshold( 0 ), - m_MenuCancelled( false ) + m_scanTypes( 0 ), + // Inspect() is virtual so calling it from a class common inspector preserves + // polymorphism. + m_inspector( [=]( EDA_ITEM* aItem, void* aTestData ) + { + return this->Inspect( aItem, aTestData ); + } ), + m_Threshold( 0 ), + m_MenuCancelled( false ) { } @@ -89,10 +93,10 @@ public: using ITER = std::vector::iterator; using CITER = std::vector::const_iterator; - ITER begin() { return m_List.begin(); } - ITER end() { return m_List.end(); } - CITER begin() const { return m_List.cbegin(); } - CITER end() const { return m_List.cend(); } + ITER begin() { return m_list.begin(); } + ITER end() { return m_list.end(); } + CITER begin() const { return m_list.cbegin(); } + CITER end() const { return m_list.cend(); } /** * Function GetCount @@ -100,7 +104,7 @@ public: */ int GetCount() const { - return (int) m_List.size(); + return (int) m_list.size(); } /** @@ -109,7 +113,7 @@ public: */ void Empty() { - m_List.clear(); + m_list.clear(); } /** @@ -119,7 +123,7 @@ public: */ void Append( EDA_ITEM* item ) { - m_List.push_back( item ); + m_list.push_back( item ); } /** @@ -129,7 +133,7 @@ public: */ 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 ) { - 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; } } @@ -155,7 +159,7 @@ public: */ bool HasAdditionalItems() { - return !m_BackupList.empty(); + return !m_backupList.empty(); } /** @@ -163,8 +167,8 @@ public: */ void Combine() { - std::copy( m_BackupList.begin(), m_BackupList.end(), std::back_inserter( m_List ) ); - m_BackupList.clear(); + std::copy( m_backupList.begin(), m_backupList.end(), std::back_inserter( m_list ) ); + m_backupList.clear(); } /** @@ -173,8 +177,8 @@ public: */ void Transfer( int aIndex ) { - m_BackupList.push_back( m_List[aIndex] ); - m_List.erase( m_List.begin() + aIndex ); + m_backupList.push_back( m_list[aIndex] ); + m_list.erase( m_list.begin() + aIndex ); } /** @@ -183,12 +187,12 @@ public: */ 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_BackupList.push_back( aItem ); + m_list.erase( m_list.begin() + i ); + m_backupList.push_back( aItem ); return; } } @@ -203,22 +207,11 @@ public: virtual EDA_ITEM* operator[]( int aIndex ) const { if( (unsigned)aIndex < (unsigned)GetCount() ) // (unsigned) excludes aIndex<0 also - return m_List[ aIndex ]; + return m_list[ aIndex ]; 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 * tests if \a aItem has already been collected. @@ -228,9 +221,9 @@ public: */ 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; } @@ -246,12 +239,12 @@ public: */ 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 @@ -262,37 +255,13 @@ public: int CountType( KICAD_T aType ) { 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++; } 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 diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 8afc43b878..b182baa418 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -421,7 +421,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) if( marker ) { // Markers are not sensitive to the layer - if( marker->HitTest( m_RefPos ) ) + if( marker->HitTest( m_refPos ) ) Append( item ); goto exit; @@ -430,7 +430,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) if( group ) { // Groups are not sensitive to the layer ... ? - if( group->HitTest( m_RefPos ) ) + if( group->HitTest( m_refPos ) ) Append( item ); goto exit; @@ -470,9 +470,9 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) { bool testFill = !m_Guide->IgnoreZoneFills(); - if( zone->HitTestForCorner( m_RefPos, accuracy * 2 ) - || zone->HitTestForEdge( m_RefPos, accuracy ) - || ( testFill && zone->HitTestFilledArea( layer, m_RefPos ) ) ) + if( zone->HitTestForCorner( m_refPos, accuracy * 2 ) + || zone->HitTestForEdge( m_refPos, accuracy ) + || ( testFill && zone->HitTestFilledArea( layer, m_refPos ) ) ) { Append( item ); goto exit; @@ -480,8 +480,8 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) } else if( item->Type() == PCB_MODULE_T ) { - if( module->HitTest( m_RefPos, accuracy ) - && module->HitTestAccurate( m_RefPos, accuracy ) ) + if( module->HitTest( m_refPos, accuracy ) + && module->HitTestAccurate( m_refPos, accuracy ) ) { Append( item ); goto exit; @@ -489,7 +489,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) } else if( drawSegment ) { - if( drawSegment->HitTest( m_RefPos, accuracy ) ) + if( drawSegment->HitTest( m_refPos, accuracy ) ) { Append( item ); goto exit; @@ -497,7 +497,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) } else { - if( item->HitTest( m_RefPos, 0 ) ) + if( item->HitTest( m_refPos, 0 ) ) { Append( item ); goto exit; @@ -534,9 +534,9 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) { bool testFill = !m_Guide->IgnoreZoneFills(); - if( zone->HitTestForCorner( m_RefPos, accuracy * 2 ) - || zone->HitTestForEdge( m_RefPos, accuracy ) - || ( testFill && zone->HitTestFilledArea( layer, m_RefPos ) ) ) + if( zone->HitTestForCorner( m_refPos, accuracy * 2 ) + || zone->HitTestForEdge( m_refPos, accuracy ) + || ( testFill && zone->HitTestFilledArea( layer, m_refPos ) ) ) { Append2nd( item ); goto exit; @@ -544,8 +544,8 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) } else if( item->Type() == PCB_MODULE_T ) { - if( module->HitTest( m_RefPos, accuracy ) - && module->HitTestAccurate( m_RefPos, accuracy ) ) + if( module->HitTest( m_refPos, accuracy ) + && module->HitTestAccurate( m_refPos, accuracy ) ) { Append( item ); goto exit; @@ -553,7 +553,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) } else if( drawSegment ) { - if( drawSegment->HitTest( m_RefPos, accuracy ) ) + if( drawSegment->HitTest( m_refPos, accuracy ) ) { Append( item ); goto exit; @@ -561,7 +561,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) } else { - if( item->HitTest( m_RefPos, 0 ) ) + if( item->HitTest( m_refPos, 0 ) ) { Append( item ); goto exit; @@ -592,10 +592,10 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[], // the Inspect() function. 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. - m_PrimaryLength = m_List.size(); + m_PrimaryLength = m_list.size(); // append 2nd list onto end of the first list for( unsigned i = 0; i