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
58 && ySize == other.ySize
59 && shape == other.shape
60 && isPlated == other.isPlated
61 && isPad == other.isPad
62 && startLayer == other.startLayer
63 && stopLayer == other.stopLayer;
64 }
65
66 struct COMPARE
67 {
68 COMPARE( COL_ID aColId, bool aAscending ) :
69 colId( aColId ),
70 ascending( aAscending )
71 {}
72
73 bool operator()( const DRILL_LINE_ITEM& aLeft, const DRILL_LINE_ITEM& aRight )
74 {
75 switch( colId )
76 {
77 case COL_COUNT:
78 return compareDrillParameters( aLeft.m_Qty, aRight.m_Qty );
79 case COL_SHAPE:
80 return compareDrillParameters( static_cast<int>( aLeft.shape ), static_cast<int>( aRight.shape ) );
81 case COL_X_SIZE:
82 return compareDrillParameters( aLeft.xSize, aRight.xSize );
83 case COL_Y_SIZE:
84 return compareDrillParameters( aLeft.ySize, aRight.ySize );
85 case COL_PLATED:
86 return ascending ? aLeft.isPlated : aRight.isPlated;
87 case COL_VIA_PAD:
88 return ascending ? aLeft.isPad : aRight.isPad;
89 case COL_START_LAYER:
90 return compareDrillParameters( aLeft.startLayer, aRight.startLayer );
91 case COL_STOP_LAYER:
92 return compareDrillParameters( aLeft.stopLayer, aRight.stopLayer );
93 }
94
95 return false;
96 }
97
98 bool compareDrillParameters( int aLeft, int aRight )
99 {
100 return ascending ? aLeft < aRight : aLeft > aRight;
101 }
102
105 };
106
107 int xSize;
108 int ySize;
111 bool isPad;
114 int m_Qty;
115};
116
117void CollectDrillLineItems( BOARD* board, std::vector<DRILL_LINE_ITEM>& out );
118
119#endif
void CollectDrillLineItems(BOARD *board, std::vector< DRILL_LINE_ITEM > &out)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
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