KiCad PCB EDA Suite
gerber_collectors.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "gerber_collectors.h"
21 
26  EOT
27 };
28 
29 
42 SEARCH_RESULT GERBER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
43 {
44  if( testItem->HitTest( m_RefPos ) )
45  Append( testItem );
46 
47  return SEARCH_CONTINUE;
48 }
49 
50 
51 void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aScanList[],
52  const wxPoint& aRefPos/*, const COLLECTORS_GUIDE& aGuide*/ )
53 {
54  Empty(); // empty the collection, primary criteria list
55 
56  // remember guide, pass it to Inspect()
57  //SetGuide( &aGuide );
58 
59  SetScanTypes( aScanList );
60 
61  // remember where the snapshot was taken from and pass refPos to
62  // the Inspect() function.
63  SetRefPos( aRefPos );
64 
65  aItem->Visit( m_inspector, NULL, m_ScanTypes );
66 
67  SetTimeNow(); // when snapshot was taken
68 
69  // record the length of the primary list before concatenating on to it.
70  m_PrimaryLength = m_List.size();
71 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:123
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
Definition: collector.h:215
int m_PrimaryLength
Determines which items are to be collected by Inspect()
static const KICAD_T AllItems[]
A scan list for all selectable gerber items.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:133
INSPECTOR_FUNC m_inspector
a class common bridge into the polymorphic Inspect()
Definition: collector.h:59
void Collect(EDA_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos)
Function Collect scans an EDA_ITEM using this class&#39;s Inspector method, which does the collection...
void SetRefPos(const wxPoint &aRefPos)
Definition: collector.h:230
virtual bool HitTest(const wxPoint &aPosition) const
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Definition: base_struct.h:308
SEARCH_RESULT Inspect(EDA_ITEM *testItem, void *testData) override
Function Inspect is the examining function within the INSPECTOR which is passed to the Iterate functi...
void SetTimeNow()
Definition: collector.h:220
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
Definition: collector.h:68
SEARCH_RESULT
Definition: base_struct.h:66
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
const KICAD_T * m_ScanTypes
Which object types to scan.
Definition: collector.h:62