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
60#define ROW_FOOTPRINT_COURTYARD_FRONT_AREA 8
61#define ROW_FRONT_COMPONENT_DENSITY 9
62#define ROW_FOOTPRINT_COURTYARD_BACK_AREA 10
63#define ROW_BACK_COMPONENT_DENSITY 11
141 grid->SetCellHighlightPenWidth( 0 );
142 grid->SetColMinimalAcceptableWidth( 80 );
144 for(
int row = 0; row <
grid->GetNumberRows(); row++ )
146 grid->SetCellAlignment( row,
COL_LABEL, wxALIGN_LEFT, wxALIGN_CENTRE );
149 grid->SetCellAlignment( row, col, wxALIGN_RIGHT, wxALIGN_CENTER );
153 wxFileName fn =
m_frame->GetBoard()->GetFileName();
158 fn.SetName( fn.GetName() + wxT(
"_report" ) );
159 fn.SetExt( wxT(
"txt" ) );
181 appendRows =
static_cast<int>(
m_statsData.padEntries.size() ) + 1
209 + wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
237 return wxString::Format( wxT(
"%i" ), aCount );
292 totalFront += line.frontCount;
293 totalBack += line.backCount;
305 wxString::Format( wxT(
"%s x %s" ),
312 wxString::Format(
"%.2f %%",
m_statsData.frontFootprintDensity ) );
315 wxString::Format(
"%.2f %%",
m_statsData.backFootprintDensity ) );
372 wxString startLayerStr;
373 wxString stopLayerStr;
379 default: shapeStr =
_(
"???" );
break;
383 startLayerStr =
_(
"N/A" );
388 stopLayerStr =
_(
"N/A" );
408 wxGridUpdateLocker deferRepaintsTillLeavingScope(
m_gridDrills );
415 for(
int i = 0; i <
m_gridDrills->GetNumberCols(); i++ )
421 double scalingFactor = std::max( 1.0,
450 wxFileName fn =
m_frame->GetBoard()->GetFileName();
451 boardName = fn.GetName();
454 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
456 if( dlg.ShowModal() == wxID_CANCEL )
462 outFile = wxFopen( dlg.GetPath(), wxT(
"wt" ) );
464 if( outFile ==
nullptr )
466 msg.Printf(
_(
"Failed to create file '%s'." ), dlg.GetPath() );
473 Prj().GetProjectName(), boardName );
475 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
477 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_FOOTPRINT_COURTYARD_FRONT_AREA
#define ROW_BOARD_THICKNESS
#define ROW_FRONT_COMPONENT_DENSITY
#define ROW_BACK_COMPONENT_DENSITY
#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
#define ROW_FOOTPRINT_COURTYARD_BACK_AREA
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.