36 #define COL_FRONT_SIDE 1 37 #define COL_BOTTOM_SIDE 2 41 #define ROW_BOARD_WIDTH 0 42 #define ROW_BOARD_HEIGHT 1 43 #define ROW_BOARD_AREA 2 87 wxFont headingFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
88 headingFont.SetSymbolicSize( wxFONTSIZE_SMALL );
97 m_gridBoard->SetCellAlignment( 0, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
99 m_gridBoard->SetCellAlignment( 1, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
101 m_gridBoard->SetCellAlignment( 2, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
104 for(
auto& grid : grids )
107 grid->SetCellHighlightPenWidth( 0 );
108 grid->SetColMinimalAcceptableWidth( 80 );
109 for(
int i = 0; i < grid->GetNumberRows(); i++ )
110 grid->SetCellAlignment( i,
COL_LABEL, wxALIGN_LEFT, wxALIGN_CENTRE );
118 fn.SetName( fn.GetName() +
"_report" );
193 if(( footprint->GetAttributes() & type.attribute ) > 0 )
195 if( footprint->IsFlipped() )
203 for(
PAD* pad : footprint->Pads() )
208 if( pad->GetAttribute() == type.attribute )
215 if( pad->GetDrillSize().x > 0 && pad->GetDrillSize().y > 0 )
219 if( pad->GetLayerSet().CuStack().empty() )
227 top = pad->GetLayerSet().CuStack().front();
228 bottom = pad->GetLayerSet().CuStack().back();
231 drillType_t drill( pad->GetDrillSize().x, pad->GetDrillSize().y,
259 if(
VIA* via = dyn_cast<VIA*>( track ) )
263 if( via->GetViaType() == type.attribute )
271 true,
false, via->TopLayer(), via->BottomLayer() );
296 bool boundingBoxCreated =
false;
303 bool edgeCutsExists =
false;
309 edgeCutsExists =
true;
314 if( !edgeCutsExists )
329 for(
int j = 0; j < polySet.
HoleCount( i ); j++ )
333 if( boundingBoxCreated )
339 bbox = outline.
BBox();
340 boundingBoxCreated =
true;
359 totalPads += type.qty;
374 totalVias += type.qty;
397 totalFront += type.frontSideQty;
398 totalBack += type.backSideQty;
445 wxString startLayerStr;
446 wxString stopLayerStr;
451 shapeStr =
_(
"Round" );
454 shapeStr =
_(
"Slot" );
457 shapeStr =
_(
"???" );
462 startLayerStr =
_(
"N/A" );
467 stopLayerStr =
_(
"N/A" );
490 bool aUseRowLabels,
bool aUseColLabels,
bool aUseFirstColAsLabel )
492 std::vector<int> widths( aGrid->GetNumberCols(), 0 );
493 int rowLabelsWidth = 0;
499 for(
int col = 0; col < aGrid->GetNumberCols(); col++ )
500 widths[col] = aGrid->GetColLabelValue( col ).length();
503 for(
int row = 0; row < aGrid->GetNumberRows(); row++ )
505 rowLabelsWidth = std::max<int>( rowLabelsWidth, aGrid->GetRowLabelValue( row ).length() );
507 for(
int col = 0; col < aGrid->GetNumberCols(); col++ )
508 widths[col] = std::max<int>( widths[col], aGrid->GetCellValue( row, col ).length() );
521 aStr.Append(
' ', rowLabelsWidth );
525 for(
int col = 0; col < aGrid->GetNumberCols(); col++ )
528 tmp.Printf(
" %*s |", widths[col], aGrid->GetColLabelValue( col ) );
530 tmp.Printf(
" %*s |", widths[col], aGrid->GetCellValue( 0, col ) );
542 aStr.Append(
'-', rowLabelsWidth );
546 for(
int col = 0; col < aGrid->GetNumberCols(); col++ )
549 aStr.Append(
'-', widths[col] );
557 int firstRow = 0, firstCol = 0;
562 if( !aUseRowLabels && aUseFirstColAsLabel )
565 for(
int row = firstRow; row < aGrid->GetNumberRows(); row++ )
568 tmp.Printf(
"|%-*s |", rowLabelsWidth, aGrid->GetRowLabelValue( row ) );
569 else if( aUseFirstColAsLabel )
570 tmp.Printf(
"|%-*s |", widths[0], aGrid->GetCellValue( row, 0 ) );
575 for(
int col = firstCol; col < aGrid->GetNumberCols(); col++ )
577 tmp.Printf(
" %*s |", widths[col], aGrid->GetCellValue( row, col ) );
586 int newTotalWidth =
m_gridDrills->GetClientSize().GetWidth();
587 int curTotalWidth = 0;
590 for(
int i = 0; i <
m_gridDrills->GetNumberCols(); i++ )
598 int remainingWidth = newTotalWidth - curTotalWidth;
625 boardName = fn.GetName();
626 wxFileDialog saveFileDialog(
this,
_(
"Save Report File" ),
630 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
632 if( saveFileDialog.ShowModal() == wxID_CANCEL )
638 outFile = wxFopen( saveFileDialog.GetPath(),
"wt" );
640 if( outFile ==
NULL )
642 msg.Printf(
_(
"Unable to create file \"%s\"" ), saveFileDialog.GetPath() );
647 msg <<
_(
"PCB statistics report\n=====================" ) <<
"\n";
648 msg << wxS(
"- " ) <<
_(
"Date" ) << wxS(
": " ) << wxDateTime::Now().Format() <<
"\n";
650 msg << wxS(
"- " ) <<
_(
"Board name" ) << wxS(
": " )<< boardName <<
"\n";
653 msg <<
_(
"Board" ) <<
"\n-----\n";
664 msg << wxS(
"- " ) <<
_(
"Width" ) << wxS(
": " ) <<
_(
"unknown" ) <<
"\n";
665 msg << wxS(
"- " ) <<
_(
"Height" ) << wxS(
": " ) <<
_(
"unknown" ) <<
"\n";
666 msg << wxS(
"- " ) <<
_(
"Area" ) << wxS(
": " ) <<
_(
"unknown" ) <<
"\n";
670 msg <<
_(
"Pads" ) <<
"\n----\n";
673 msg <<
"- " << type.title <<
" " << type.qty <<
"\n";
676 msg <<
_(
"Vias" ) <<
"\n----\n";
679 msg <<
"- " << type.title <<
" " << type.qty <<
"\n";
683 std::vector<int> widths;
684 std::vector<wxString> labels{
"",
_(
"Front Side" ),
_(
"Back Side" ),
_(
"Total" ) };
687 widths.reserve( labels.size() );
688 for(
const auto& label : labels )
689 widths.push_back( label.size() );
697 widths[0] = std::max<int>( type.title.size(), widths[0] );
698 frontTotal += type.frontSideQty;
699 backTotal += type.backSideQty;
703 tmp.Printf(
"%i", frontTotal );
704 widths[1] = std::max<int>( tmp.size(), widths[1] );
705 tmp.Printf(
"%i", backTotal );
706 widths[2] = std::max<int>( tmp.size(), widths[2] );
707 tmp.Printf(
"%i", frontTotal + backTotal );
708 widths[3] = std::max<int>( tmp.size(), widths[3] );
712 msg <<
_(
"Components" ) <<
"\n----------\n";
718 msg <<
_(
"Drill holes" ) <<
"\n-----------\n";
723 if( fprintf( outFile,
"%s",
TO_UTF8( msg ) ) < 0 )
725 msg.Printf(
_(
"Error writing to file \"%s\"" ), saveFileDialog.GetPath() );
bool m_hasOutline
Hold all components types to be shown in the dialog.
typeContainer_t< VIATYPE > viasType_t
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Implementation of conversion functions that require both schematic and board internal units.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void refreshItemsTypes()
< Function to fill up all items types to be shown in the dialog.
bool TransferDataToWindow() override
Smd pad, appears on the solder paste layer (default)
wxGrid * m_gridComponents
viasTypeList_t m_viasTypes
Hold all drill hole types to be shown in the dialog.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
void getDataFromPCB()
Apply data to dialog widgets.
wxButton * m_sdbControlSizerCancel
Footprint attributes (such as SMD, THT, Virtual and so on), which will be shown in the dialog.
like PAD_PTH, but not plated mechanical use only, no connection allowed
const wxString & GetFileName() const
void drillGridSize(wxSizeEvent &aEvent) override
double m_boardArea
Show if board outline properly defined.
EDA_UNITS GetUserUnits() const
wxCheckBox * m_checkBoxSubtractHoles
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
PCB_LAYER_ID
A quick note on layer IDs:
void drillGridSort(wxGridEvent &aEvent)
~DIALOG_BOARD_STATISTICS()
Get data from the PCB board and print it to dialog.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
coord_type GetWidth() const
FOOTPRINTS & Footprints()
void updateDrillGrid()
Print grid to string in tabular format.
Definition of file extensions used in Kicad.
PCB_EDIT_FRAME * m_parentFrame
DIALOG_BOARD_STATISTICS(PCB_EDIT_FRAME *aParentFrame)
void adjustDrillGridColumns()
typeContainer_t< PAD_ATTR_T > padsType_t
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
void printGridToStringAsTable(wxGrid *aGrid, wxString &aStr, bool aUseRowLabels, bool aUseColLabels, bool aUseFirstColAsLabel)
wxString saveReportFolder
void updateWidets()
Update drills grid.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_BOARD_STATISTICS_BASE.
DIALOG_BOARD_STATISTICS_SAVED_STATE()
Information pertinent to a Pcbnew printed circuit board.
The main frame for Pcbnew.
wxCheckBox * m_checkBoxExcludeComponentsNoPins
coord_type GetHeight() const
wxString TextFileWildcard()
void saveReportClicked(wxCommandEvent &aEvent) override
bool saveReportInitialized
padsTypeList_t m_padsTypes
Hold all vias types to be shown in the dialog.
virtual const wxString GetProjectName() const
Return the short name of the project.
static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState
void checkboxClicked(wxCommandEvent &aEvent) override
Save board statistics to a file.
drillTypeList_t m_drillTypes
componentsTypeList_t m_componentsTypes
Hold all pads types to be shown in the dialog.
Struct containing the dialog last saved state.