KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_statistics.h
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 The 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#ifndef PCBNEW_BOARD_STATISTICS_H
21#define PCBNEW_BOARD_STATISTICS_H
22
23#include <layer_ids.h>
24#include <padstack.h>
25
26class BOARD;
27
29{
41
42 DRILL_LINE_ITEM( int aXSize, int aYSize, PAD_DRILL_SHAPE aShape, bool aIsPlated,
43 bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer ) :
44 xSize( aXSize ),
45 ySize( aYSize ),
46 shape( aShape ),
47 isPlated( aIsPlated ),
48 isPad( aIsPad ),
49 startLayer( aStartLayer ),
50 stopLayer( aStopLayer ),
51 m_Qty( 0 )
52 {
53 }
54
55 bool operator==( const DRILL_LINE_ITEM& other ) const
56 {
57 return xSize == other.xSize && ySize == other.ySize && shape == other.shape
58 && isPlated == other.isPlated && isPad == other.isPad && startLayer == other.startLayer
59 && stopLayer == other.stopLayer;
60 }
61
62 struct COMPARE
63 {
64 COMPARE( COL_ID aColId, bool aAscending ) : colId( aColId ), ascending( aAscending ) {}
65
66 bool operator()( const DRILL_LINE_ITEM& aLeft, const DRILL_LINE_ITEM& aRight )
67 {
68 switch( colId )
69 {
70 case COL_COUNT:
71 return compareDrillParameters( aLeft.m_Qty, aRight.m_Qty );
72 case COL_SHAPE:
73 return compareDrillParameters( static_cast<int>( aLeft.shape ), static_cast<int>( aRight.shape ) );
74 case COL_X_SIZE:
75 return compareDrillParameters( aLeft.xSize, aRight.xSize );
76 case COL_Y_SIZE:
77 return compareDrillParameters( aLeft.ySize, aRight.ySize );
78 case COL_PLATED:
79 return ascending ? aLeft.isPlated : aRight.isPlated;
80 case COL_VIA_PAD:
81 return ascending ? aLeft.isPad : aRight.isPad;
82 case COL_START_LAYER:
83 return compareDrillParameters( aLeft.startLayer, aRight.startLayer );
84 case COL_STOP_LAYER:
85 return compareDrillParameters( aLeft.stopLayer, aRight.stopLayer );
86 }
87
88 return false;
89 }
90
91 bool compareDrillParameters( int aLeft, int aRight )
92 {
93 return ascending ? aLeft < aRight : aLeft > aRight;
94 }
95
98 };
99
100 int xSize;
101 int ySize;
104 bool isPad;
107 int m_Qty;
108};
109
110void CollectDrillLineItems( BOARD* board, std::vector<DRILL_LINE_ITEM>& out );
111
112#endif
void CollectDrillLineItems(BOARD *board, std::vector< DRILL_LINE_ITEM > &out)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:69
bool operator()(const DRILL_LINE_ITEM &aLeft, const DRILL_LINE_ITEM &aRight)
COMPARE(COL_ID aColId, bool aAscending)
bool compareDrillParameters(int aLeft, int aRight)
PCB_LAYER_ID stopLayer
PAD_DRILL_SHAPE shape
bool operator==(const DRILL_LINE_ITEM &other) const
DRILL_LINE_ITEM(int aXSize, int aYSize, PAD_DRILL_SHAPE aShape, bool aIsPlated, bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer)
PCB_LAYER_ID startLayer