KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_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 (C) 2019 Alexander Shuklin, [email protected]
5 * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25
26#ifndef _DIALOG_BOARD_STATISTICS_H
27#define _DIALOG_BOARD_STATISTICS_H
28
29
30#include <board.h>
31#include <footprint.h>
32#include <pcb_track.h>
34#include <pad_shapes.h>
35#include <pcb_base_frame.h>
36#include <pcb_edit_frame.h>
37#include <project.h>
38#include <wx/datetime.h>
39
44{
45public:
49 template <typename T>
50 struct LINE_ITEM
51 {
52 LINE_ITEM( T aAttribute, const wxString& aTitle ) :
53 attribute( aAttribute ),
54 title( aTitle ),
55 qty( 0 )
56 {
57 }
58
60 wxString title;
61 int qty;
62 };
63
69 {
70 FP_LINE_ITEM( int aAttributeMask, int aAttributeValue, wxString aTitle ) :
71 attribute_mask( aAttributeMask ),
72 attribute_value( aAttributeValue ),
73 title( aTitle ),
74 frontSideQty( 0 ),
75 backSideQty( 0 )
76 {
77 }
78
81 wxString title;
84 };
85
87 {
88 enum COL_ID
89 {
98 };
99
100 DRILL_LINE_ITEM( int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated,
101 bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer ) :
102 xSize( aXSize ),
103 ySize( aYSize ),
104 shape( aShape ),
105 isPlated( aIsPlated ),
106 isPad( aIsPad ),
107 startLayer( aStartLayer ),
108 stopLayer( aStopLayer ),
109 qty( 0 )
110 {
111 }
112
113 bool operator==( const DRILL_LINE_ITEM& other ) const
114 {
115 return xSize == other.xSize && ySize == other.ySize && shape == other.shape
116 && isPlated == other.isPlated && isPad == other.isPad
117 && startLayer == other.startLayer && stopLayer == other.stopLayer;
118 }
119
120 struct COMPARE
121 {
122 COMPARE( COL_ID aColId, bool aAscending ) : colId( aColId ), ascending( aAscending )
123 {
124 }
125 bool operator()( const DRILL_LINE_ITEM& aLeft, const DRILL_LINE_ITEM& aRight )
126 {
127 switch( colId )
128 {
129 case COL_COUNT:
130 return compareDrillParameters( aLeft.qty, aRight.qty );
131 case COL_SHAPE:
132 return compareDrillParameters( aLeft.shape, aRight.shape );
133 case COL_X_SIZE:
134 return compareDrillParameters( aLeft.xSize, aRight.xSize );
135 case COL_Y_SIZE:
136 return compareDrillParameters( aLeft.ySize, aRight.ySize );
137 case COL_PLATED:
138 return ascending ? aLeft.isPlated : aRight.isPlated;
139 case COL_VIA_PAD:
140 return ascending ? aLeft.isPad : aRight.isPad;
141 case COL_START_LAYER:
142 return compareDrillParameters( aLeft.startLayer, aRight.startLayer );
143 case COL_STOP_LAYER:
144 return compareDrillParameters( aLeft.stopLayer, aRight.stopLayer );
145 }
146
147 return false;
148 }
149
150 bool compareDrillParameters( int aLeft, int aRight )
151 {
152 return ascending ? aLeft < aRight : aLeft > aRight;
153 }
154
157 };
158
159 int xSize;
160 int ySize;
163 bool isPad;
166 int qty;
167 };
168
171
173 bool TransferDataToWindow() override;
174
175private:
176
178 void refreshItemsTypes();
179
181 void getDataFromPCB();
182
184 void updateWidets();
185
187 void updateDrillGrid();
188
190 void printGridToStringAsTable( wxGrid* aGrid, wxString& aStr, bool aUseColLabels,
191 bool aUseFirstColAsLabel );
192
194
195 void checkboxClicked( wxCommandEvent& aEvent ) override;
196
198 void saveReportClicked( wxCommandEvent& aEvent ) override;
199
200 void drillGridSize( wxSizeEvent& aEvent ) override;
201
202 void drillGridSort( wxGridEvent& aEvent );
203
205
209
211
212 std::deque<FP_LINE_ITEM> m_fpTypes;
213 std::deque<LINE_ITEM<PAD_ATTRIB>> m_padTypes;
214 std::deque<LINE_ITEM<VIATYPE>> m_viaTypes;
215 std::deque<DRILL_LINE_ITEM> m_drillTypes;
216
220};
221
222#endif // __DIALOG_BOARD_STATISTICS_H
Class DIALOG_BOARD_STATISTICS_BASE.
Dialog to show common board info.
void checkboxClicked(wxCommandEvent &aEvent) override
Save board statistics to a file.
void printGridToStringAsTable(wxGrid *aGrid, wxString &aStr, bool aUseColLabels, bool aUseFirstColAsLabel)
std::deque< FP_LINE_ITEM > m_fpTypes
int m_startLayerColInitialSize
Width of the start layer column as calculated by the wxWidgets autosizing algorithm.
void updateWidets()
Update drills grid.
void saveReportClicked(wxCommandEvent &aEvent) override
std::deque< LINE_ITEM< PAD_ATTRIB > > m_padTypes
void updateDrillGrid()
Print grid to string in tabular format.
~DIALOG_BOARD_STATISTICS()
Get data from the PCB board and print it to dialog.
int m_stopLayerColInitialSize
Width of the stop layer column.
void drillGridSort(wxGridEvent &aEvent)
void refreshItemsTypes()
< Function to fill up all items types to be shown in the dialog.
void drillGridSize(wxSizeEvent &aEvent) override
bool m_hasOutline
Show if board outline properly defined.
std::deque< DRILL_LINE_ITEM > m_drillTypes
std::deque< LINE_ITEM< VIATYPE > > m_viaTypes
void getDataFromPCB()
Apply data to dialog widgets.
The main frame for Pcbnew.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:53
bool operator()(const DRILL_LINE_ITEM &aLeft, const DRILL_LINE_ITEM &aRight)
DRILL_LINE_ITEM(int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated, bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer)
bool operator==(const DRILL_LINE_ITEM &other) const
Footprint attributes (such as SMD, THT, Virtual and so on), which will be shown in the dialog.
FP_LINE_ITEM(int aAttributeMask, int aAttributeValue, wxString aTitle)
Type information, which will be shown in dialog.
LINE_ITEM(T aAttribute, const wxString &aTitle)