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 <padstack.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 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( static_cast<int>( aLeft.shape ),
133 static_cast<int>( aRight.shape ) );
134 case COL_X_SIZE:
135 return compareDrillParameters( aLeft.xSize, aRight.xSize );
136 case COL_Y_SIZE:
137 return compareDrillParameters( aLeft.ySize, aRight.ySize );
138 case COL_PLATED:
139 return ascending ? aLeft.isPlated : aRight.isPlated;
140 case COL_VIA_PAD:
141 return ascending ? aLeft.isPad : aRight.isPad;
142 case COL_START_LAYER:
143 return compareDrillParameters( aLeft.startLayer, aRight.startLayer );
144 case COL_STOP_LAYER:
145 return compareDrillParameters( aLeft.stopLayer, aRight.stopLayer );
146 }
147
148 return false;
149 }
150
151 bool compareDrillParameters( int aLeft, int aRight )
152 {
153 return ascending ? aLeft < aRight : aLeft > aRight;
154 }
155
158 };
159
160 int xSize;
161 int ySize;
164 bool isPad;
167 int qty;
168 };
169
172
174 bool TransferDataToWindow() override;
175
176private:
177
179 void refreshItemsTypes();
180
182 void getDataFromPCB();
183
185 void updateWidets();
186
188 void updateDrillGrid();
189
191 void printGridToStringAsTable( wxGrid* aGrid, wxString& aStr, bool aUseColLabels,
192 bool aUseFirstColAsLabel );
193
195
196 void checkboxClicked( wxCommandEvent& aEvent ) override;
197
199 void saveReportClicked( wxCommandEvent& aEvent ) override;
200
201 void drillGridSize( wxSizeEvent& aEvent ) override;
202
203 void drillGridSort( wxGridEvent& aEvent );
204
206
210
212
213 std::deque<FP_LINE_ITEM> m_fpTypes;
214 std::deque<LINE_ITEM<PAD_ATTRIB>> m_padTypes;
215 std::deque<LINE_ITEM<VIATYPE>> m_viaTypes;
216 std::deque<DRILL_LINE_ITEM> m_drillTypes;
217
221};
222
223#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
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: padstack.h:63
bool operator()(const DRILL_LINE_ITEM &aLeft, const DRILL_LINE_ITEM &aRight)
DRILL_LINE_ITEM(int aXSize, int aYSize, PAD_DRILL_SHAPE 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)