KiCad PCB EDA Suite
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, jasuramme@gmail.com
5  * Copyright (C) 2019 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 <base_units.h>
31 #include <class_board.h>
32 #include <class_drawsegment.h>
33 #include <class_track.h>
34 #include <confirm.h>
36 #include <pad_shapes.h>
37 #include <pcb_base_frame.h>
38 #include <pcb_edit_frame.h>
39 #include <project.h>
40 #include <wx/datetime.h>
41 
48 {
49 public:
53  template <typename T>
55  {
56  typeContainer_t<T>( T aAttribute, wxString aTitle )
57  : attribute( aAttribute ),
58  title( aTitle ),
59  qty( 0 )
60  {
61  }
63  wxString title;
64  int qty;
65  };
66 
69 
76  {
77  componentsType_t( MODULE_ATTR_T aAttribute, wxString aTitle )
78  : attribute( aAttribute ),
79  title( aTitle ),
80  frontSideQty( 0 ),
81  backSideQty( 0 )
82  {
83  }
85  wxString title;
88  };
89 
90  struct drillType_t
91  {
92  enum COL_ID
93  {
102  };
103  drillType_t( int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated, bool aIsPad,
104  PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer, int aQty = 0 )
105  : xSize( aXSize ),
106  ySize( aYSize ),
107  shape( aShape ),
108  isPlated( aIsPlated ),
109  isPad( aIsPad ),
110  startLayer( aStartLayer ),
111  stopLayer( aStopLayer ),
112  qty( aQty )
113  {
114  }
115  bool operator==( const drillType_t& other )
116  {
117  return xSize == other.xSize && ySize == other.ySize && shape == other.shape
118  && isPlated == other.isPlated && isPad == other.isPad
119  && startLayer == other.startLayer && stopLayer == other.stopLayer;
120  }
121  struct COMPARE
122  {
123  COMPARE( COL_ID aColId, bool aAscending ) : colId( aColId ), ascending( aAscending )
124  {
125  }
126  bool operator()( const drillType_t& aLeft, const drillType_t& aRight )
127  {
128  switch( colId )
129  {
130  case COL_COUNT:
131  return compareDrillParameters( aLeft.qty, aRight.qty );
132  case COL_SHAPE:
133  return compareDrillParameters( aLeft.shape, 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  bool compareDrillParameters( int aLeft, int aRight )
151  {
152  return ascending ? aLeft < aRight : aLeft > aRight;
153  }
155  bool ascending;
156  };
157  int xSize;
158  int ySize;
160  bool isPlated;
161  bool isPad;
164  int qty;
165  };
166 
167  using componentsTypeList_t = std::deque<componentsType_t>;
168  using padsTypeList_t = std::deque<padsType_t>;
169  using viasTypeList_t = std::deque<viasType_t>;
170  using drillTypeList_t = std::deque<drillType_t>;
171 
172  DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame );
174 
176  bool TransferDataToWindow() override;
177 
178 private:
180 
183  double m_boardArea;
184 
187 
190 
193 
196 
199 
201  void refreshItemsTypes();
202 
204  void getDataFromPCB();
205 
207  void updateWidets();
208 
210  void updateDrillGrid();
211 
213  void printGridToStringAsTable( wxGrid* aGrid, wxString& aStr, bool aUseRowLabels,
214  bool aUseColLabels, bool aUseFirstColAsLabel );
215 
216  void adjustDrillGridColumns();
217 
218  void checkboxClicked( wxCommandEvent& aEvent ) override;
219 
221  void saveReportClicked( wxCommandEvent& aEvent ) override;
222 
223  void drillGridSize( wxSizeEvent& aEvent ) override;
224 
225  void drillGridSort( wxGridEvent& aEvent );
226 };
227 
228 #endif // __DIALOG_BOARD_STATISTICS_H
bool m_hasOutline
Shows if board outline properly defined
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
void refreshItemsTypes()
Function to fill up all items types to be shown in the dialog.
bool TransferDataToWindow() override
Get data from the PCB board and print it to dialog
viasTypeList_t m_viasTypes
Holds all vias types to be shown in the dialog
void getDataFromPCB()
Gets data from board
bool operator==(const drillType_t &other)
T
enum T contains all this lexer's tokens.
Struct holds information about component type (such as SMD, THT, Virtual and so on),...
std::deque< drillType_t > drillTypeList_t
PAD_DRILL_SHAPE_T
Enum PAD_DRILL_SHAPE_T is the set of pad drill shapes, used with D_PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:66
void drillGridSize(wxSizeEvent &aEvent) override
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
Classes used in Pcbnew, CvPcb and GerbView.
bool operator()(const drillType_t &aLeft, const drillType_t &aRight)
Struct to hold type information, which will be shown in dialog.
PCB_LAYER_ID
A quick note on layer IDs:
void drillGridSort(wxGridEvent &aEvent)
std::deque< viasType_t > viasTypeList_t
std::deque< padsType_t > padsTypeList_t
void updateDrillGrid()
Updates drills grid
DIALOG_BOARD_STATISTICS(PCB_EDIT_FRAME *aParentFrame)
MODULE_ATTR_T
Enum MODULE_ATTR_T is the set of attributes allowed within a MODULE, using MODULE::SetAttributes() an...
Definition: class_module.h:65
drillType_t(int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated, bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer, int aQty=0)
void printGridToStringAsTable(wxGrid *aGrid, wxString &aStr, bool aUseRowLabels, bool aUseColLabels, bool aUseFirstColAsLabel)
Prints grid to string in tabular format
void updateWidets()
Applies data to dialog widgets
Class DIALOG_BOARD_STATISTICS_BASE.
Class to handle a graphic segment.
DIALOG_BOARD_STATISTIC.
PCB_EDIT_FRAME is the main frame for Pcbnew.
void saveReportClicked(wxCommandEvent &aEvent) override
Save board statistics to a file
padsTypeList_t m_padsTypes
Holds all pads types to be shown in the dialog
componentsType_t(MODULE_ATTR_T aAttribute, wxString aTitle)
void checkboxClicked(wxCommandEvent &aEvent) override
drillTypeList_t m_drillTypes
Holds all drill hole types to be shown in the dialog
componentsTypeList_t m_componentsTypes
Holds all components types to be shown in the dialog
std::deque< componentsType_t > componentsTypeList_t