29#include <wx/filedlg.h>
47#define COL_FRONT_SIDE 1
48#define COL_BOTTOM_SIDE 2
52#define ROW_BOARD_DIMS 0
53#define ROW_BOARD_AREA 1
54#define ROW_FRONT_COPPER_AREA 2
55#define ROW_BACK_COPPER_AREA 3
56#define ROW_MIN_CLEARANCE 4
57#define ROW_MIN_TRACK_WIDTH 5
58#define ROW_MIN_DRILL_DIAMETER 6
59#define ROW_BOARD_THICKNESS 7
133 grid->SetCellHighlightPenWidth( 0 );
134 grid->SetColMinimalAcceptableWidth( 80 );
136 for(
int row = 0; row <
grid->GetNumberRows(); row++ )
138 grid->SetCellAlignment( row,
COL_LABEL, wxALIGN_LEFT, wxALIGN_CENTRE );
141 grid->SetCellAlignment( row, col, wxALIGN_RIGHT, wxALIGN_CENTER );
145 wxFileName fn =
m_frame->GetBoard()->GetFileName();
150 fn.SetName( fn.GetName() + wxT(
"_report" ) );
151 fn.SetExt( wxT(
"txt" ) );
173 appendRows =
static_cast<int>(
m_statsData.padEntries.size() ) + 1
201 + wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
229 return wxString::Format( wxT(
"%i" ), aCount );
284 totalFront += line.frontCount;
285 totalBack += line.backCount;
297 wxString::Format( wxT(
"%s x %s" ),
350 wxString startLayerStr;
351 wxString stopLayerStr;
357 default: shapeStr =
_(
"???" );
break;
361 startLayerStr =
_(
"N/A" );
366 stopLayerStr =
_(
"N/A" );
386 wxGridUpdateLocker deferRepaintsTillLeavingScope(
m_gridDrills );
393 for(
int i = 0; i <
m_gridDrills->GetNumberCols(); i++ )
399 double scalingFactor = std::max( 1.0,
428 wxFileName fn =
m_frame->GetBoard()->GetFileName();
429 boardName = fn.GetName();
432 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
434 if( dlg.ShowModal() == wxID_CANCEL )
440 outFile = wxFopen( dlg.GetPath(), wxT(
"wt" ) );
442 if( outFile ==
nullptr )
444 msg.Printf(
_(
"Failed to create file '%s'." ), dlg.GetPath() );
451 Prj().GetProjectName(), boardName );
453 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
455 msg.Printf(
_(
"Error writing file '%s'." ), dlg.GetPath() );
void ComputeBoardStatistics(BOARD *aBoard, const BOARD_STATISTICS_OPTIONS &aOptions, BOARD_STATISTICS_DATA &aData)
static wxString formatCount(int aCount)
wxString FormatBoardStatisticsReport(const BOARD_STATISTICS_DATA &aData, BOARD *aBoard, const UNITS_PROVIDER &aUnitsProvider, const wxString &aProjectName, const wxString &aBoardName)
void InitializeBoardStatisticsData(BOARD_STATISTICS_DATA &aData)
Information pertinent to a Pcbnew printed circuit board.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
wxCheckBox * m_checkBoxSubtractHoles
wxStaticText * m_boardLabel
wxButton * m_sdbControlSizerCancel
wxStaticText * m_padsLabel
DIALOG_BOARD_STATISTICS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Board Statistics"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxGrid * m_gridComponents
wxCheckBox * m_checkBoxExcludeComponentsNoPins
wxStaticText * m_componentsLabel
wxStaticText * m_viasLabel
wxCheckBox * m_checkBoxSubtractHolesFromCopper
void checkboxClicked(wxCommandEvent &aEvent) override
Save board statistics to a file.
int m_startLayerColInitialSize
Width of the start layer column as calculated by the wxWidgets autosizing algorithm.
void updateWidgets()
Update drills grid.
void saveReportClicked(wxCommandEvent &aEvent) override
~DIALOG_BOARD_STATISTICS()
Get data from the PCB board and print it to dialog.
int m_stopLayerColInitialSize
Width of the stop layer column.
DIALOG_BOARD_STATISTICS(PCB_EDIT_FRAME *aParentFrame)
void drillGridSort(wxGridEvent &aEvent)
void refreshItemsTypes()
< Function to fill up all items types to be shown in the dialog.
void drillGridSize(wxSizeEvent &aEvent) override
void adjustDrillGridColumns()
bool TransferDataToWindow() override
BOARD_STATISTICS_DATA m_statsData
void getDataFromPCB()
Apply data to dialog widgets.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
The main frame for Pcbnew.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState
#define ROW_BOARD_THICKNESS
#define ROW_BACK_COPPER_AREA
#define ROW_MIN_TRACK_WIDTH
#define ROW_MIN_DRILL_DIAMETER
#define ROW_FRONT_COPPER_AREA
static wxString formatCount(int aCount)
#define ROW_MIN_CLEARANCE
static wxString TextFileWildcard()
This file contains miscellaneous commonly used macros and functions.
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool subtractHolesFromCopperAreas
bool subtractHolesFromBoardArea
bool excludeFootprintsWithoutPads
The dialog last saved state.
bool saveReportInitialized
bool subtractHolesFromCopper
DIALOG_BOARD_STATISTICS_SAVED_STATE()
wxString saveReportFolder
Definition of file extensions used in Kicad.