31#include <wx/filedlg.h>
54#define COL_FRONT_SIDE 1
55#define COL_BOTTOM_SIDE 2
59#define ROW_BOARD_DIMS 0
60#define ROW_BOARD_AREA 1
61#define ROW_FRONT_COPPER_AREA 2
62#define ROW_BACK_COPPER_AREA 3
63#define ROW_MIN_CLEARANCE 4
64#define ROW_MIN_TRACK_WIDTH 5
65#define ROW_MIN_DRILL_DIAMETER 6
66#define ROW_BOARD_THICKNESS 7
67#define ROW_FOOTPRINT_COURTYARD_FRONT_AREA 8
68#define ROW_FRONT_COMPONENT_DENSITY 9
69#define ROW_FOOTPRINT_COURTYARD_BACK_AREA 10
70#define ROW_BACK_COMPONENT_DENSITY 11
148 grid->SetCellHighlightPenWidth( 0 );
149 grid->SetColMinimalAcceptableWidth( 80 );
151 for(
int row = 0; row <
grid->GetNumberRows(); row++ )
153 grid->SetCellAlignment( row,
COL_LABEL, wxALIGN_LEFT, wxALIGN_CENTRE );
156 grid->SetCellAlignment( row, col, wxALIGN_RIGHT, wxALIGN_CENTER );
160 wxFileName fn =
m_frame->GetBoard()->GetFileName();
165 fn.SetName( fn.GetName() + wxT(
"_report" ) );
166 fn.SetExt( wxT(
"txt" ) );
188 appendRows =
static_cast<int>(
m_statsData.padEntries.size() ) + 1
216 + wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
244 return wxString::Format( wxT(
"%i" ), aCount );
299 totalFront += line.frontCount;
300 totalBack += line.backCount;
312 wxString::Format( wxT(
"%s x %s" ),
319 wxString::Format(
"%.2f %%",
m_statsData.frontFootprintDensity ) );
322 wxString::Format(
"%.2f %%",
m_statsData.backFootprintDensity ) );
379 wxString startLayerStr;
380 wxString stopLayerStr;
386 default: shapeStr =
_(
"???" );
break;
390 startLayerStr =
_(
"N/A" );
395 stopLayerStr =
_(
"N/A" );
415 wxGridUpdateLocker deferRepaintsTillLeavingScope(
m_gridDrills );
422 for(
int i = 0; i <
m_gridDrills->GetNumberCols(); i++ )
428 double scalingFactor = std::max( 1.0,
457 wxFileName fn =
m_frame->GetBoard()->GetFileName();
458 boardName = fn.GetName();
461 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
465 if( dlg.ShowModal() == wxID_CANCEL )
471 outFile = wxFopen( dlg.GetPath(), wxT(
"wt" ) );
473 if( outFile ==
nullptr )
475 msg.Printf(
_(
"Failed to create file '%s'." ), dlg.GetPath() );
482 Prj().GetProjectName(), boardName );
484 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
486 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
Functions to provide common constants and other functions to assist in making a consistent UI.
Definition of file extensions used in Kicad.