KiCad PCB EDA Suite
DIALOG_BOARD_STATISTICS Class Reference

Dialog to show common board info. More...

#include <dialog_board_statistics.h>

Inheritance diagram for DIALOG_BOARD_STATISTICS:
DIALOG_BOARD_STATISTICS_BASE DIALOG_SHIM KIWAY_HOLDER

Classes

struct  componentsType_t
 Footprint attributes (such as SMD, THT, Virtual and so on), which will be shown in the dialog. More...
 
struct  drillType_t
 
struct  typeContainer_t
 Type information, which will be shown in dialog. More...
 

Public Types

using padsType_t = typeContainer_t< PAD_ATTRIB >
 
using viasType_t = typeContainer_t< VIATYPE >
 
using componentsTypeList_t = std::deque< componentsType_t >
 
using padsTypeList_t = std::deque< padsType_t >
 
using viasTypeList_t = std::deque< viasType_t >
 
using drillTypeList_t = std::deque< drillType_t >
 
enum  HOLDER_TYPE { DIALOG, FRAME, PANEL }
 

Public Member Functions

 DIALOG_BOARD_STATISTICS (PCB_EDIT_FRAME *aParentFrame)
 
 ~DIALOG_BOARD_STATISTICS ()
 Get data from the PCB board and print it to dialog. More...
 
bool TransferDataToWindow () override
 
void SetInitialFocus (wxWindow *aWindow)
 Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown. More...
 
int ShowQuasiModal ()
 
void EndQuasiModal (int retCode)
 
bool IsQuasiModal () const
 
bool Show (bool show) override
 
bool Enable (bool enable) override
 
void OnPaint (wxPaintEvent &event)
 
void OnModify ()
 
void SetPosition (const wxPoint &aNewPosition)
 Force the position of the dialog to a new position. More...
 
EDA_UNITS GetUserUnits () const
 
HOLDER_TYPE GetType () const
 
KIWAYKiway () const
 Return a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Return a reference to the PROJECT associated with this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 It is only used for debugging, since "this" is not a wxWindow*. More...
 

Static Public Member Functions

static bool IsCtrl (int aChar, const wxKeyEvent &e)
 
static bool IsShiftCtrl (int aChar, const wxKeyEvent &e)
 

Protected Member Functions

virtual void windowSize (wxSizeEvent &event)
 
void finishDialogSettings ()
 In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls. More...
 
void setSizeInDU (int x, int y)
 Set the dialog to the given dimensions in "dialog units". More...
 
int horizPixelsFromDU (int x) const
 Convert an integer number of dialog units to pixels, horizontally. More...
 
int vertPixelsFromDU (int y) const
 Convert an integer number of dialog units to pixels, vertically. More...
 
void resetSize ()
 Clear the existing dialog size and position. More...
 
virtual void OnCharHook (wxKeyEvent &aEvt)
 

Protected Attributes

wxNotebook * topNotebook
 
wxPanel * m_generalPanel
 
wxGrid * m_gridComponents
 
wxGrid * m_gridPads
 
wxGrid * m_gridBoard
 
wxStaticText * viasLabel
 
wxGrid * m_gridVias
 
wxCheckBox * m_checkBoxSubtractHoles
 
wxCheckBox * m_checkBoxExcludeComponentsNoPins
 
wxPanel * m_drillsPanel
 
WX_GRIDm_gridDrills
 
wxButton * m_buttonSaveReport
 
wxStdDialogButtonSizer * m_sdbControlSizer
 
wxButton * m_sdbControlSizerCancel
 
EDA_UNITS m_units
 
std::string m_hash_key
 
bool m_useCalculatedSize
 
bool m_firstPaintEvent
 
wxWindow * m_initialFocusTarget
 
WX_EVENT_LOOPm_qmodal_loop
 
bool m_qmodal_showing
 
WDO_ENABLE_DISABLEm_qmodal_parent_disabler
 
std::vector< wxWindow * > m_tabOrder
 
wxSize m_initialSize
 

Private Member Functions

void refreshItemsTypes ()
 < Function to fill up all items types to be shown in the dialog. More...
 
void getDataFromPCB ()
 Apply data to dialog widgets. More...
 
void updateWidets ()
 Update drills grid. More...
 
void updateDrillGrid ()
 Print grid to string in tabular format. More...
 
void printGridToStringAsTable (wxGrid *aGrid, wxString &aStr, bool aUseRowLabels, bool aUseColLabels, bool aUseFirstColAsLabel)
 
void adjustDrillGridColumns ()
 
void checkboxClicked (wxCommandEvent &aEvent) override
 Save board statistics to a file. More...
 
void saveReportClicked (wxCommandEvent &aEvent) override
 
void drillGridSize (wxSizeEvent &aEvent) override
 
void drillGridSort (wxGridEvent &aEvent)
 

Private Attributes

PCB_EDIT_FRAMEm_parentFrame
 
int m_boardWidth
 
int m_boardHeight
 
double m_boardArea
 Show if board outline properly defined. More...
 
bool m_hasOutline
 Hold all components types to be shown in the dialog. More...
 
componentsTypeList_t m_componentsTypes
 Hold all pads types to be shown in the dialog. More...
 
padsTypeList_t m_padsTypes
 Hold all vias types to be shown in the dialog. More...
 
viasTypeList_t m_viasTypes
 Hold all drill hole types to be shown in the dialog. More...
 
drillTypeList_t m_drillTypes
 Width of the start layer column as calculated by the wxWidgets autosizing algorithm. More...
 
int m_startLayerColInitialSize
 Width of the stop layer column as calculated by the wxWidgets autosizing algorithm. More...
 
int m_stopLayerColInitialSize
 

Detailed Description

Dialog to show common board info.

Definition at line 44 of file dialog_board_statistics.h.

Member Typedef Documentation

◆ componentsTypeList_t

◆ drillTypeList_t

Definition at line 174 of file dialog_board_statistics.h.

◆ padsType_t

◆ padsTypeList_t

Definition at line 172 of file dialog_board_statistics.h.

◆ viasType_t

◆ viasTypeList_t

Definition at line 173 of file dialog_board_statistics.h.

Member Enumeration Documentation

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 

Definition at line 39 of file kiway_holder.h.

Constructor & Destructor Documentation

◆ DIALOG_BOARD_STATISTICS()

DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS ( PCB_EDIT_FRAME aParentFrame)

Definition at line 78 of file dialog_board_statistics.cpp.

78  :
79  DIALOG_BOARD_STATISTICS_BASE( aParentFrame ),
80  m_parentFrame(aParentFrame),
81  m_boardWidth( 0 ),
82  m_boardHeight( 0 ),
83  m_boardArea( 0.0 ),
84  m_hasOutline( false ),
87 {
88  m_gridDrills->Connect( wxEVT_GRID_COL_SORT,
89  wxGridEventHandler( DIALOG_BOARD_STATISTICS::drillGridSort ),
90  nullptr, this );
91 
94 
95  // Make labels for grids
96  wxFont headingFont = KIUI::GetStatusFont( this );
97  m_gridComponents->SetCellValue( ROW_LABEL, COL_FRONT_SIDE, _( "Front Side" ) );
98  m_gridComponents->SetCellFont( ROW_LABEL, COL_FRONT_SIDE, headingFont );
99  m_gridComponents->SetCellValue( ROW_LABEL, COL_BOTTOM_SIDE, _( "Back Side" ) );
100  m_gridComponents->SetCellFont( ROW_LABEL, COL_BOTTOM_SIDE, headingFont );
101  m_gridComponents->SetCellValue( ROW_LABEL, COL_TOTAL, _( "Total" ) );
102  m_gridComponents->SetCellFont( ROW_LABEL, COL_TOTAL, headingFont );
103 
104  m_gridBoard->SetCellValue( 0, 0, _( "Width:" ) );
105  m_gridBoard->SetCellAlignment( 0, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
106  m_gridBoard->SetCellValue( 1, 0, _( "Height:" ) );
107  m_gridBoard->SetCellAlignment( 1, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
108  m_gridBoard->SetCellValue( 2, 0, _( "Area:" ) );
109  m_gridBoard->SetCellAlignment( 2, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
110 
111  wxGrid* grids[] = { m_gridComponents, m_gridPads, m_gridVias, m_gridBoard };
112 
113  for( auto& grid : grids )
114  {
115  // Remove wxgrid's selection boxes
116  grid->SetCellHighlightPenWidth( 0 );
117  grid->SetColMinimalAcceptableWidth( 80 );
118  for( int i = 0; i < grid->GetNumberRows(); i++ )
119  grid->SetCellAlignment( i, COL_LABEL, wxALIGN_LEFT, wxALIGN_CENTRE );
120  }
121 
122  wxFileName fn = m_parentFrame->GetBoard()->GetFileName();
123 
125  || s_savedDialogState.m_project != Prj().GetProjectFullName() )
126  {
127  fn.SetName( fn.GetName() + wxT( "_report" ) );
128  fn.SetExt( wxT( "txt" ) );
129  s_savedDialogState.saveReportName = fn.GetFullName();
130  s_savedDialogState.saveReportFolder = wxPathOnly( Prj().GetProjectFullName() );
133  }
134 
135  // The wxStdDialogButtonSizer wxID_CANCLE button is in fact a close button
136  // Nothing to cancel:
137  m_sdbControlSizerCancel->SetLabel( _( "Close" ) );
138 }
bool m_hasOutline
Hold all components types to be shown in the dialog.
const wxString & GetFileName() const
Definition: board.h:229
int m_startLayerColInitialSize
Width of the stop layer column as calculated by the wxWidgets autosizing algorithm.
double m_boardArea
Show if board outline properly defined.
#define COL_TOTAL
void drillGridSort(wxGridEvent &aEvent)
#define COL_BOTTOM_SIDE
#define ROW_LABEL
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
#define COL_FRONT_SIDE
#define _(s)
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)
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:116
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
BOARD * GetBoard() const
#define COL_LABEL
static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState

References _, COL_BOTTOM_SIDE, COL_FRONT_SIDE, COL_LABEL, COL_TOTAL, drillGridSort(), DIALOG_BOARD_STATISTICS_SAVED_STATE::excludeNoPins, PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), PROJECT::GetProjectFullName(), KIUI::GetStatusFont(), grid, DIALOG_BOARD_STATISTICS_BASE::m_checkBoxExcludeComponentsNoPins, DIALOG_BOARD_STATISTICS_BASE::m_checkBoxSubtractHoles, DIALOG_BOARD_STATISTICS_BASE::m_gridBoard, DIALOG_BOARD_STATISTICS_BASE::m_gridComponents, DIALOG_BOARD_STATISTICS_BASE::m_gridDrills, DIALOG_BOARD_STATISTICS_BASE::m_gridPads, DIALOG_BOARD_STATISTICS_BASE::m_gridVias, m_parentFrame, DIALOG_BOARD_STATISTICS_SAVED_STATE::m_project, DIALOG_BOARD_STATISTICS_BASE::m_sdbControlSizerCancel, KIWAY_HOLDER::Prj(), ROW_LABEL, s_savedDialogState, DIALOG_BOARD_STATISTICS_SAVED_STATE::saveReportFolder, DIALOG_BOARD_STATISTICS_SAVED_STATE::saveReportInitialized, DIALOG_BOARD_STATISTICS_SAVED_STATE::saveReportName, and DIALOG_BOARD_STATISTICS_SAVED_STATE::subtractHoles.

◆ ~DIALOG_BOARD_STATISTICS()

DIALOG_BOARD_STATISTICS::~DIALOG_BOARD_STATISTICS ( )

Get data from the PCB board and print it to dialog.

Definition at line 793 of file dialog_board_statistics.cpp.

794 {
795 }

Member Function Documentation

◆ adjustDrillGridColumns()

void DIALOG_BOARD_STATISTICS::adjustDrillGridColumns ( )
private

Definition at line 619 of file dialog_board_statistics.cpp.

620 {
621  wxGridUpdateLocker deferRepaintsTillLeavingScope( m_gridDrills );
622 
624 
625  double remainingWidth = KIPLATFORM::UI::GetUnobscuredSize( m_gridDrills ).x;
626 
627  // Find the total current width
628  for( int i = 0; i < m_gridDrills->GetNumberCols(); i++ )
629  {
631  remainingWidth -= m_gridDrills->GetColSize( i );
632  }
633 
634  double scalingFactor = std::max(
635  1.0, remainingWidth / ( m_startLayerColInitialSize + m_stopLayerColInitialSize ) );
636  int startLayerColWidth = static_cast<int>( m_startLayerColInitialSize * scalingFactor );
637  int stopLayerColWidth = static_cast<int>( m_stopLayerColInitialSize * scalingFactor );
638 
639  m_gridDrills->SetColSize( drillType_t::COL_START_LAYER, startLayerColWidth );
640  m_gridDrills->SetColSize( drillType_t::COL_STOP_LAYER, stopLayerColWidth );
641 }
int m_startLayerColInitialSize
Width of the stop layer column as calculated by the wxWidgets autosizing algorithm.
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:327
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: gtk/ui.cpp:125

References DIALOG_BOARD_STATISTICS::drillType_t::COL_START_LAYER, DIALOG_BOARD_STATISTICS::drillType_t::COL_STOP_LAYER, WX_GRID::EnsureColLabelsVisible(), KIPLATFORM::UI::GetUnobscuredSize(), DIALOG_BOARD_STATISTICS_BASE::m_gridDrills, m_startLayerColInitialSize, and m_stopLayerColInitialSize.

Referenced by drillGridSize(), TransferDataToWindow(), and updateWidets().

◆ checkboxClicked()

void DIALOG_BOARD_STATISTICS::checkboxClicked ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Save board statistics to a file.

Reimplemented from DIALOG_BOARD_STATISTICS_BASE.

Definition at line 644 of file dialog_board_statistics.cpp.

645 {
649  getDataFromPCB();
650  updateWidets();
651  Layout();
652  m_drillsPanel->Layout();
653 }
void refreshItemsTypes()
< Function to fill up all items types to be shown in the dialog.
void getDataFromPCB()
Apply data to dialog widgets.
void updateWidets()
Update drills grid.
static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState

References DIALOG_BOARD_STATISTICS_SAVED_STATE::excludeNoPins, getDataFromPCB(), DIALOG_BOARD_STATISTICS_BASE::m_checkBoxExcludeComponentsNoPins, DIALOG_BOARD_STATISTICS_BASE::m_checkBoxSubtractHoles, DIALOG_BOARD_STATISTICS_BASE::m_drillsPanel, refreshItemsTypes(), s_savedDialogState, DIALOG_BOARD_STATISTICS_SAVED_STATE::subtractHoles, and updateWidets().

◆ drillGridSize()

void DIALOG_BOARD_STATISTICS::drillGridSize ( wxSizeEvent &  aEvent)
overrideprivatevirtual

Reimplemented from DIALOG_BOARD_STATISTICS_BASE.

Definition at line 775 of file dialog_board_statistics.cpp.

776 {
777  aEvent.Skip();
779 }

References adjustDrillGridColumns().

◆ drillGridSort()

void DIALOG_BOARD_STATISTICS::drillGridSort ( wxGridEvent &  aEvent)
private

Definition at line 781 of file dialog_board_statistics.cpp.

782 {
783  drillType_t::COL_ID colId = static_cast<drillType_t::COL_ID>( aEvent.GetCol() );
784  bool ascending =
785  !( m_gridDrills->IsSortingBy( colId ) && m_gridDrills->IsSortOrderAscending() );
786 
787  sort( m_drillTypes.begin(), m_drillTypes.end(), drillType_t::COMPARE( colId, ascending ) );
788 
789  updateDrillGrid();
790 }
void updateDrillGrid()
Print grid to string in tabular format.
drillTypeList_t m_drillTypes
Width of the start layer column as calculated by the wxWidgets autosizing algorithm.

References m_drillTypes, DIALOG_BOARD_STATISTICS_BASE::m_gridDrills, and updateDrillGrid().

Referenced by DIALOG_BOARD_STATISTICS().

◆ Enable()

bool DIALOG_SHIM::Enable ( bool  enable)
overrideinherited

Definition at line 312 of file dialog_shim.cpp.

313 {
314  // so we can do logging of this state change:
315  return wxDialog::Enable( enable );
316 }

◆ EndQuasiModal()

void DIALOG_SHIM::EndQuasiModal ( int  retCode)
inherited

Definition at line 480 of file dialog_shim.cpp.

481 {
482  // Hook up validator and transfer data from controls handling so quasi-modal dialogs
483  // handle validation in the same way as other dialogs.
484  if( ( retCode == wxID_OK ) && ( !Validate() || !TransferDataFromWindow() ) )
485  return;
486 
487  SetReturnCode( retCode );
488 
489  if( !IsQuasiModal() )
490  {
491  wxFAIL_MSG( wxT( "either DIALOG_SHIM::EndQuasiModal called twice or ShowQuasiModal" )
492  wxT( "wasn't called" ) );
493  return;
494  }
495 
496  if( m_qmodal_loop )
497  {
498  if( m_qmodal_loop->IsRunning() )
499  m_qmodal_loop->Exit( 0 );
500  else
501  m_qmodal_loop->ScheduleExit( 0 );
502 
503  m_qmodal_loop = nullptr;
504  }
505 
507  m_qmodal_parent_disabler = nullptr;
508 
509  Show( false );
510 }
bool IsQuasiModal() const
Definition: dialog_shim.h:106
WX_EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:213
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:216

References DIALOG_SHIM::IsQuasiModal(), DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, and DIALOG_SHIM::Show().

Referenced by EDA_3D_CONTROLLER::Main(), NETLIST_DIALOG::OnAddGenerator(), DIALOG_SHIM::OnButton(), DIALOG_EDIT_SYMBOLS_LIBID::onCancel(), DIALOG_LIB_SYMBOL_PROPERTIES::OnCancelButtonClick(), DIALOG_SYMBOL_PROPERTIES::OnCancelButtonClick(), DIALOG_LIB_EDIT_PIN_TABLE::OnClose(), DIALOG_CHOOSE_FOOTPRINT::OnCloseTimer(), DIALOG_SHIM::OnCloseWindow(), NETLIST_DIALOG::OnDelGenerator(), DIALOG_SYMBOL_PROPERTIES::OnEditLibrarySymbol(), DIALOG_SYMBOL_PROPERTIES::OnEditSymbol(), DIALOG_SYMBOL_PROPERTIES::OnExchangeSymbol(), PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick(), PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick(), DIALOG_SYMBOL_PROPERTIES::OnUpdateSymbol(), DIALOG_CHOOSE_FOOTPRINT::OnUseBrowser(), DIALOG_PUSH_PAD_PROPERTIES::PadPropertiesAccept(), and DIALOG_SHIM::~DIALOG_SHIM().

◆ finishDialogSettings()

void DIALOG_SHIM::finishDialogSettings ( )
protectedinherited

In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls.

finishDialogSettings must be called from derived classes after all widgets have been initialized, and therefore their size fixed. If TransferDataToWindow() is used to initialize widgets, at the end of TransferDataToWindow, or better yet, at end of a wxInitDialogEvent handler.

Definition at line 151 of file dialog_shim.cpp.

152 {
153  // must be called from the constructor of derived classes,
154  // when all widgets are initialized, and therefore their size fixed
155 
156  // SetSizeHints fixes the minimal size of sizers in the dialog
157  // (SetSizeHints calls Fit(), so no need to call it)
158  GetSizer()->SetSizeHints( this );
159 }

Referenced by DIALOG_ANNOTATE::DIALOG_ANNOTATE(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP(), DIALOG_BOM::DIALOG_BOM(), DIALOG_BUS_MANAGER::DIALOG_BUS_MANAGER(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), DIALOG_CLEANUP_TRACKS_AND_VIAS::DIALOG_CLEANUP_TRACKS_AND_VIAS(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_DRC::DIALOG_DRC(), DIALOG_EDIT_SYMBOLS_LIBID::DIALOG_EDIT_SYMBOLS_LIBID(), DIALOG_ENUM_PADS::DIALOG_ENUM_PADS(), DIALOG_ERC::DIALOG_ERC(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), DIALOG_EXPORT_3DFILE::DIALOG_EXPORT_3DFILE(), DIALOG_EXPORT_IDF3::DIALOG_EXPORT_IDF3(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG(), DIALOG_FOOTPRINT_CHECKER::DIALOG_FOOTPRINT_CHECKER(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST(), DIALOG_GENCAD_EXPORT_OPTIONS::DIALOG_GENCAD_EXPORT_OPTIONS(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS(), DIALOG_GLOBAL_LIB_TABLE_CONFIG::DIALOG_GLOBAL_LIB_TABLE_CONFIG(), DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS(), DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES(), DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR(), DIALOG_IMPORTED_LAYERS::DIALOG_IMPORTED_LAYERS(), DIALOG_INSPECTOR::DIALOG_INSPECTOR(), DIALOG_JUNCTION_PROPS::DIALOG_JUNCTION_PROPS(), DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL(), DIALOG_LIB_SHAPE_PROPERTIES::DIALOG_LIB_SHAPE_PROPERTIES(), DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES(), DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES(), DIALOG_LINE_WIRE_BUS_PROPERTIES::DIALOG_LINE_WIRE_BUS_PROPERTIES(), DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS(), DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY(), DIALOG_MANAGE_REPOSITORIES::DIALOG_MANAGE_REPOSITORIES(), DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT(), DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR(), DIALOG_NETLIST_IMPORT::DIALOG_NETLIST_IMPORT(), DIALOG_NON_COPPER_ZONES_EDITOR::DIALOG_NON_COPPER_ZONES_EDITOR(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::DIALOG_PAD_PRIMITIVE_POLY_PROPS(), DIALOG_PAD_PRIMITIVES_PROPERTIES::DIALOG_PAD_PRIMITIVES_PROPERTIES(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PASTE_SPECIAL::DIALOG_PASTE_SPECIAL(), DIALOG_PCM::DIALOG_PCM(), DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE(), DIALOG_PRINT_GENERIC::DIALOG_PRINT_GENERIC(), DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER(), DIALOG_PUSH_PAD_PROPERTIES::DIALOG_PUSH_PAD_PROPERTIES(), DIALOG_REGULATOR_FORM::DIALOG_REGULATOR_FORM(), DIALOG_RULE_AREA_PROPERTIES::DIALOG_RULE_AREA_PROPERTIES(), DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP(), DIALOG_SELECT_3DMODEL::DIALOG_SELECT_3DMODEL(), DIALOG_SHEET_PIN_PROPERTIES::DIALOG_SHEET_PIN_PROPERTIES(), DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES(), DIALOG_SWAP_LAYERS::DIALOG_SWAP_LAYERS(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), DIALOG_TARGET_PROPERTIES::DIALOG_TARGET_PROPERTIES(), DIALOG_TEXT_AND_LABEL_PROPERTIES::DIALOG_TEXT_AND_LABEL_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE(), DIALOG_UNUSED_PAD_LAYERS::DIALOG_UNUSED_PAD_LAYERS(), DIALOG_UPDATE_FROM_PCB::DIALOG_UPDATE_FROM_PCB(), DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB(), DIALOG_UPDATE_SYMBOL_FIELDS::DIALOG_UPDATE_SYMBOL_FIELDS(), DIALOG_CONSTRAINTS_REPORTER::FinishInitialization(), PAGED_DIALOG::finishInitialization(), DIALOG_FIELD_PROPERTIES::init(), DIALOG_EDIT_LIBRARY_TABLES::InstallPanel(), NETLIST_DIALOG::NETLIST_DIALOG(), DIALOG_GRAPHIC_ITEM_PROPERTIES::OnInitDlg(), DIALOG_SHEET_PROPERTIES::OnInitDlg(), DIALOG_SYMBOL_PROPERTIES::OnInitDlg(), DIALOG_SPICE_MODEL::onInitDlg(), DIALOG_SIM_SETTINGS::onInitDlg(), DIALOG_SIGNAL_LIST::TransferDataToWindow(), TransferDataToWindow(), and DIALOG_COLOR_PICKER::TransferDataToWindow().

◆ getDataFromPCB()

void DIALOG_BOARD_STATISTICS::getDataFromPCB ( )
private

Apply data to dialog widgets.

Definition at line 203 of file dialog_board_statistics.cpp.

204 {
205  BOARD* board = m_parentFrame->GetBoard();
206  m_drillTypes.clear();
207 
208  // Get footprints and pads count
209  for( FOOTPRINT* footprint : board->Footprints() )
210  {
211  // Do not proceed footprints with no pads if checkbox checked
212  if( m_checkBoxExcludeComponentsNoPins->GetValue() && ! footprint->Pads().size() )
213  continue;
214 
215  // Go through components types list
216  for( auto& type : m_componentsTypes )
217  {
218  if(( footprint->GetAttributes() & type.attribute ) > 0 )
219  {
220  if( footprint->IsFlipped() )
221  type.backSideQty++;
222  else
223  type.frontSideQty++;
224  break;
225  }
226  }
227 
228  for( PAD* pad : footprint->Pads() )
229  {
230  // Go through pads types list
231  for( auto& type : m_padsTypes )
232  {
233  if( pad->GetAttribute() == type.attribute )
234  {
235  type.qty++;
236  break;
237  }
238  }
239 
240  if( pad->GetDrillSize().x > 0 && pad->GetDrillSize().y > 0 )
241  {
242  PCB_LAYER_ID top, bottom;
243 
244  if( pad->GetLayerSet().CuStack().empty() )
245  {
246  // The pad is not on any copper layer
247  top = UNDEFINED_LAYER;
248  bottom = UNDEFINED_LAYER;
249  }
250  else
251  {
252  top = pad->GetLayerSet().CuStack().front();
253  bottom = pad->GetLayerSet().CuStack().back();
254  }
255 
256  drillType_t drill( pad->GetDrillSize().x, pad->GetDrillSize().y,
257  pad->GetDrillShape(), pad->GetAttribute() != PAD_ATTRIB::NPTH,
258  true, top, bottom );
259 
260  auto it = m_drillTypes.begin();
261 
262  for( ; it != m_drillTypes.end(); ++it )
263  {
264  if( *it == drill )
265  {
266  it->qty++;
267  break;
268  }
269  }
270 
271  if( it == m_drillTypes.end() )
272  {
273  drill.qty = 1;
274  m_drillTypes.push_back( drill );
275  m_gridDrills->InsertRows();
276  }
277  }
278  }
279  }
280 
281  // Get via counts
282  for( PCB_TRACK* track : board->Tracks() )
283  {
284  if( PCB_VIA* via = dyn_cast<PCB_VIA*>( track ) )
285  {
286  for( auto& type : m_viasTypes )
287  {
288  if( via->GetViaType() == type.attribute )
289  {
290  type.qty++;
291  break;
292  }
293  }
294 
295  drillType_t drill( via->GetDrillValue(), via->GetDrillValue(), PAD_DRILL_SHAPE_CIRCLE,
296  true, false, via->TopLayer(), via->BottomLayer() );
297 
298  auto it = m_drillTypes.begin();
299 
300  for( ; it != m_drillTypes.end(); ++it )
301  {
302  if( *it == drill )
303  {
304  it->qty++;
305  break;
306  }
307  }
308 
309  if( it == m_drillTypes.end() )
310  {
311  drill.qty = 1;
312  m_drillTypes.push_back( drill );
313  m_gridDrills->InsertRows();
314  }
315  }
316  }
317 
318  sort( m_drillTypes.begin(), m_drillTypes.end(),
319  drillType_t::COMPARE( drillType_t::COL_COUNT, false ) );
320 
321  bool boundingBoxCreated = false; //flag if bounding box initialized
322  BOX2I bbox;
323  SHAPE_POLY_SET polySet;
324  m_hasOutline = board->GetBoardPolygonOutlines( polySet );
325 
326  // If board has no Edge Cuts lines, board->GetBoardPolygonOutlines will
327  // return small rectangle, so we double check that
328  bool edgeCutsExists = false;
329 
330  for( BOARD_ITEM* drawing : board->Drawings() )
331  {
332  if( drawing->GetLayer() == Edge_Cuts )
333  {
334  edgeCutsExists = true;
335  break;
336  }
337  }
338 
339  if( !edgeCutsExists )
340  m_hasOutline = false;
341 
342  if( m_hasOutline )
343  {
344  m_boardArea = 0.0;
345 
346  for( int i = 0; i < polySet.OutlineCount(); i++ )
347  {
348  SHAPE_LINE_CHAIN& outline = polySet.Outline( i );
349  m_boardArea += outline.Area();
350 
351  // If checkbox "subtract holes" is checked
352  if( m_checkBoxSubtractHoles->GetValue() )
353  {
354  for( int j = 0; j < polySet.HoleCount( i ); j++ )
355  m_boardArea -= polySet.Hole( i, j ).Area();
356  }
357 
358  if( boundingBoxCreated )
359  {
360  bbox.Merge( outline.BBox() );
361  }
362  else
363  {
364  bbox = outline.BBox();
365  boundingBoxCreated = true;
366  }
367  }
368 
369  m_boardWidth = bbox.GetWidth();
370  m_boardHeight = bbox.GetHeight();
371  }
372 }
bool m_hasOutline
Hold all components types to be shown in the dialog.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
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...
Definition: board.cpp:1835
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
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.
double Area(bool aAbsolute=true) const
Return the area of this chain.
double m_boardArea
Show if board outline properly defined.
like PAD_PTH, but not plated
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)
coord_type GetWidth() const
Definition: box2.h:180
FOOTPRINTS & Footprints()
Definition: board.h:234
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:363
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
coord_type GetHeight() const
Definition: box2.h:181
padsTypeList_t m_padsTypes
Hold all vias types to be shown in the dialog.
BOARD * GetBoard() const
Definition: pad.h:57
drillTypeList_t m_drillTypes
Width of the start layer column as calculated by the wxWidgets autosizing algorithm.
componentsTypeList_t m_componentsTypes
Hold all pads types to be shown in the dialog.
DRAWINGS & Drawings()
Definition: board.h:237
TRACKS & Tracks()
Definition: board.h:231

References SHAPE_LINE_CHAIN::Area(), SHAPE_LINE_CHAIN::BBox(), DIALOG_BOARD_STATISTICS::drillType_t::COL_COUNT, BOARD::Drawings(), Edge_Cuts, BOARD::Footprints(), PCB_BASE_FRAME::GetBoard(), BOARD::GetBoardPolygonOutlines(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), SHAPE_POLY_SET::Hole(), SHAPE_POLY_SET::HoleCount(), m_boardArea, m_boardHeight, m_boardWidth, DIALOG_BOARD_STATISTICS_BASE::m_checkBoxExcludeComponentsNoPins, DIALOG_BOARD_STATISTICS_BASE::m_checkBoxSubtractHoles, m_componentsTypes, m_drillTypes, DIALOG_BOARD_STATISTICS_BASE::m_gridDrills, m_hasOutline, m_padsTypes, m_parentFrame, m_viasTypes, BOX2< Vec >::Merge(), NPTH, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), pad, PAD_DRILL_SHAPE_CIRCLE, BOARD::Tracks(), UNDEFINED_LAYER, and via.

Referenced by checkboxClicked(), and TransferDataToWindow().

◆ GetType()

HOLDER_TYPE KIWAY_HOLDER::GetType ( ) const
inlineinherited

Definition at line 46 of file kiway_holder.h.

46 { return m_type; }
HOLDER_TYPE m_type
Definition: kiway_holder.h:76

References KIWAY_HOLDER::m_type.

Referenced by DIALOG_SHIM::DIALOG_SHIM().

◆ GetUserUnits()

◆ horizPixelsFromDU()

int DIALOG_SHIM::horizPixelsFromDU ( int  x) const
protectedinherited

Convert an integer number of dialog units to pixels, horizontally.

See SetSizeInDU or wxDialog documentation for more information.

Definition at line 169 of file dialog_shim.cpp.

170 {
171  wxSize sz( x, 0 );
172  return ConvertDialogToPixels( sz ).x;
173 }

Referenced by DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT(), and DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL().

◆ IsCtrl()

static bool DIALOG_SHIM::IsCtrl ( int  aChar,
const wxKeyEvent &  e 
)
inlinestaticinherited

Definition at line 126 of file dialog_shim.h.

127  {
128  return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() &&
129  !e.ShiftDown() && !e.MetaDown();
130  }

◆ IsQuasiModal()

◆ IsShiftCtrl()

static bool DIALOG_SHIM::IsShiftCtrl ( int  aChar,
const wxKeyEvent &  e 
)
inlinestaticinherited

Definition at line 132 of file dialog_shim.h.

133  {
134  return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() &&
135  e.ShiftDown() && !e.MetaDown();
136  }

◆ Kiway()

KIWAY& KIWAY_HOLDER::Kiway ( ) const
inlineinherited

Return a reference to the KIWAY that this object has an opportunity to participate in.

A KIWAY_HOLDER is not necessarily a KIWAY_PLAYER.

Definition at line 53 of file kiway_holder.h.

54  {
55  wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
56  return *m_kiway;
57  }
KIWAY * m_kiway
Definition: kiway_holder.h:75

References KIWAY_HOLDER::m_kiway.

Referenced by PROJECT_TREE_ITEM::Activate(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::AddLibraryFile(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), SCH_EDIT_FRAME::AskToSaveChanges(), SYMBOL_EDIT_FRAME::CanCloseSymbolFromSchematic(), SCH_EDIT_FRAME::canCloseWindow(), KICAD_MANAGER_FRAME::CloseProject(), COMMON_CONTROL::ConfigurePaths(), DIALOG_CHOOSE_FOOTPRINT::ConstructRightPanel(), DIALOG_CHOOSE_SYMBOL::ConstructRightPanel(), PCB_BASE_FRAME::CreateAndShow3D_Frame(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH(), DIALOG_SHIM::DIALOG_SHIM(), SCH_EDIT_FRAME::doCloseWindow(), FIELDS_GRID_TRICKS::doPopupSelection(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), BACK_ANNOTATE::FetchNetlistFromPCB(), KICAD_MANAGER_FRAME::ImportNonKiCadProject(), SCRIPTING_TOOL::Init(), EDA_DRAW_FRAME::IsScriptingConsoleVisible(), KICAD_MANAGER_FRAME::language_change(), KIWAY_PLAYER::language_change(), DIALOG_CHANGE_SYMBOLS::launchMatchIdSymbolBrowser(), DIALOG_CHANGE_SYMBOLS::launchNewIdSymbolBrowser(), LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), TEXT_BUTTON_FP_CHOOSER::OnButtonClick(), PL_EDITOR_FRAME::OnExit(), SCH_EDIT_FRAME::OnExit(), FOOTPRINT_EDIT_FRAME::OnExitKiCad(), FOOTPRINT_VIEWER_FRAME::OnExitKiCad(), SYMBOL_EDIT_FRAME::OnExitKiCad(), SAVE_AS_TRAVERSER::OnFile(), DIALOG_CHOOSE_SYMBOL::OnInitDialog(), SCH_EDIT_FRAME::OnOpenCvpcb(), SCH_EDIT_FRAME::OnOpenPcbnew(), EDA_BASE_FRAME::OnPreferences(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), DIALOG_FIELD_PROPERTIES::OnTextValueSelectButtonClick(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard(), SCH_EDIT_FRAME::OnUpdatePCB(), FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard(), PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS(), SCH_BASE_FRAME::PickSymbolFromLibBrowser(), KIWAY_HOLDER::Prj(), SCH_EDIT_TOOL::Properties(), BACK_ANNOTATE::PushNewLinksToPCB(), FOOTPRINT_WIZARD_FRAME::PythonPluginsReload(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), SCH_EDITOR_CONTROL::rescueProject(), EE_INSPECTION_TOOL::RunSimulation(), SYMBOL_EDIT_FRAME::Save(), SYMBOL_EDIT_FRAME::saveCurrentSymbol(), CVPCB_MAINFRAME::SaveFootprintAssociation(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), LIB_TREE_MODEL_ADAPTER::SavePinnedItems(), EDA_DRAW_FRAME::ScriptingConsoleEnableDisable(), SCH_EDIT_FRAME::SendCrossProbeClearHighlight(), SCH_EDIT_FRAME::SendCrossProbeNetName(), PCB_EDIT_FRAME::SendCrossProbeNetName(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlistToCvpcb(), SCH_EDIT_FRAME::SetCrossProbeConnection(), SYMBOL_EDIT_FRAME::SetCurSymbol(), CVPCB_CONTROL::ShowFootprintViewer(), COMMON_CONTROL::ShowLibraryTable(), COMMON_CONTROL::ShowPlayer(), KICAD_MANAGER_CONTROL::ShowPlayer(), SCH_EDIT_FRAME::ShowSchematicSetupDialog(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), and DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint().

◆ OnCharHook()

void DIALOG_SHIM::OnCharHook ( wxKeyEvent &  aEvt)
protectedvirtualinherited

Reimplemented in DIALOG_CHOOSE_SYMBOL, HK_PROMPT_DIALOG, and HTML_MESSAGE_BOX.

Definition at line 570 of file dialog_shim.cpp.

571 {
572  if( aEvt.GetKeyCode() == 'U' && aEvt.GetModifiers() == wxMOD_CONTROL )
573  {
574  if( m_parentFrame )
575  {
577  return;
578  }
579  }
580  // shift-return (Mac default) or Ctrl-Return (GTK) for OK
581  else if( aEvt.GetKeyCode() == WXK_RETURN && ( aEvt.ShiftDown() || aEvt.ControlDown() ) )
582  {
583  wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
584  return;
585  }
586  else if( aEvt.GetKeyCode() == WXK_TAB && !aEvt.ControlDown() )
587  {
588  wxWindow* currentWindow = wxWindow::FindFocus();
589  int currentIdx = -1;
590  int delta = aEvt.ShiftDown() ? -1 : 1;
591 
592  auto advance = [&]( int& idx )
593  {
594  // Wrap-around modulus
595  int size = m_tabOrder.size();
596  idx = ( ( idx + delta ) % size + size ) % size;
597  };
598 
599  for( size_t i = 0; i < m_tabOrder.size(); ++i )
600  {
601  if( m_tabOrder[i] == currentWindow )
602  {
603  currentIdx = (int) i;
604  break;
605  }
606  }
607 
608  if( currentIdx >= 0 )
609  {
610  advance( currentIdx );
611 
612  //todo: We don't currently have non-textentry dialog boxes but this will break if
613  // we add them.
614 #ifdef __APPLE__
615  while( dynamic_cast<wxTextEntry*>( m_tabOrder[ currentIdx ] ) == nullptr )
616  advance( currentIdx );
617 #endif
618 
619  m_tabOrder[ currentIdx ]->SetFocus();
620  return;
621  }
622  }
623 
624  aEvt.Skip();
625 }
std::vector< wxWindow * > m_tabOrder
Definition: dialog_shim.h:220
EDA_BASE_FRAME * m_parentFrame
Definition: dialog_shim.h:218
virtual void ToggleUserUnits()
constexpr int delta

References delta, DIALOG_SHIM::m_parentFrame, DIALOG_SHIM::m_tabOrder, and EDA_BASE_FRAME::ToggleUserUnits().

Referenced by DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), and DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES().

◆ OnModify()

◆ OnPaint()

void DIALOG_SHIM::OnPaint ( wxPaintEvent &  event)
inherited

Definition at line 380 of file dialog_shim.cpp.

381 {
382  if( m_firstPaintEvent )
383  {
385 
386  selectAllInTextCtrls( GetChildren() );
387 
390  else
391  KIPLATFORM::UI::ForceFocus( this ); // Focus the dialog itself
392 
393  m_firstPaintEvent = false;
394  }
395 
396  event.Skip();
397 }
wxWindow * m_initialFocusTarget
Definition: dialog_shim.h:211
bool m_firstPaintEvent
Definition: dialog_shim.h:210
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition: gtk/ui.cpp:44
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition: gtk/ui.cpp:71
static void selectAllInTextCtrls(wxWindowList &children)

References KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision(), KIPLATFORM::UI::ForceFocus(), DIALOG_SHIM::m_firstPaintEvent, DIALOG_SHIM::m_initialFocusTarget, and selectAllInTextCtrls().

Referenced by DIALOG_SHIM::DIALOG_SHIM().

◆ printGridToStringAsTable()

void DIALOG_BOARD_STATISTICS::printGridToStringAsTable ( wxGrid *  aGrid,
wxString &  aStr,
bool  aUseRowLabels,
bool  aUseColLabels,
bool  aUseFirstColAsLabel 
)
private

Definition at line 519 of file dialog_board_statistics.cpp.

522 {
523  std::vector<int> widths( aGrid->GetNumberCols(), 0 );
524  int rowLabelsWidth = 0;
525 
526  // Determine column widths.
527 
528  if( aUseColLabels )
529  {
530  for( int col = 0; col < aGrid->GetNumberCols(); col++ )
531  widths[col] = aGrid->GetColLabelValue( col ).length();
532  }
533 
534  for( int row = 0; row < aGrid->GetNumberRows(); row++ )
535  {
536  rowLabelsWidth = std::max<int>( rowLabelsWidth, aGrid->GetRowLabelValue( row ).length() );
537 
538  for( int col = 0; col < aGrid->GetNumberCols(); col++ )
539  widths[col] = std::max<int>( widths[col], aGrid->GetCellValue( row, col ).length() );
540  }
541 
542  // Print the cells.
543 
544  wxString tmp;
545 
546  // Print column labels.
547 
548  aStr << wxT( "|" );
549 
550  if( aUseRowLabels )
551  {
552  aStr.Append( ' ', rowLabelsWidth );
553  aStr << wxT( " |" );
554  }
555 
556  for( int col = 0; col < aGrid->GetNumberCols(); col++ )
557  {
558  if( aUseColLabels )
559  tmp.Printf( wxT( " %*s |" ), widths[col], aGrid->GetColLabelValue( col ) );
560  else
561  tmp.Printf( wxT( " %*s |" ), widths[col], aGrid->GetCellValue( 0, col ) );
562 
563  aStr << tmp;
564  }
565 
566  aStr << wxT( "\n" );
567 
568  // Print column label horizontal separators.
569 
570  aStr << wxT( "|" );
571 
572  if( aUseRowLabels )
573  {
574  aStr.Append( '-', rowLabelsWidth );
575  aStr << wxT( "-|" );
576  }
577 
578  for( int col = 0; col < aGrid->GetNumberCols(); col++ )
579  {
580  aStr << wxT( "-" );
581  aStr.Append( '-', widths[col] );
582  aStr << wxT( "-|" );
583  }
584 
585  aStr << wxT( "\n" );
586 
587  // Print regular cells.
588 
589  int firstRow = 0, firstCol = 0;
590 
591  if( !aUseColLabels )
592  firstRow = 1;
593 
594  if( !aUseRowLabels && aUseFirstColAsLabel )
595  firstCol = 1;
596 
597  for( int row = firstRow; row < aGrid->GetNumberRows(); row++ )
598  {
599  if( aUseRowLabels )
600  tmp.Printf( wxT( "|%-*s |" ), rowLabelsWidth, aGrid->GetRowLabelValue( row ) );
601  else if( aUseFirstColAsLabel )
602  tmp.Printf( wxT( "|%-*s |" ), widths[0], aGrid->GetCellValue( row, 0 ) );
603  else
604  tmp.Printf( wxT( "|" ) );
605 
606  aStr << tmp;
607 
608  for( int col = firstCol; col < aGrid->GetNumberCols(); col++ )
609  {
610  tmp.Printf( wxT( " %*s |" ), widths[col], aGrid->GetCellValue( row, col ) );
611  aStr << tmp;
612  }
613 
614  aStr << wxT( "\n" );
615  }
616 }

Referenced by saveReportClicked().

◆ Prj()

PROJECT & KIWAY_HOLDER::Prj ( ) const
inherited

Return a reference to the PROJECT associated with this KIWAY.

Definition at line 36 of file kiway_holder.cpp.

37 {
38  return Kiway().Prj();
39 }
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:191

References KIWAY_HOLDER::Kiway(), and KIWAY::Prj().

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_LIBRARY_MANAGER::addLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), SCH_EDIT_FRAME::AppendSchematic(), AskSaveBoardFileName(), DIALOG_SYMBOL_REMAP::backupProject(), CVPCB_MAINFRAME::buildEquivalenceList(), CVPCB_MAINFRAME::BuildLibrariesListBox(), SIM_PLOT_FRAME::canCloseWindow(), PANEL_FP_PROPERTIES_3D_MODEL::Cfg3DPath(), KICAD_MANAGER_FRAME::CloseProject(), PCB_BASE_EDIT_FRAME::createNewLibrary(), PCB_BASE_EDIT_FRAME::CreateNewProjectLibrary(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), SCH_EDIT_FRAME::CreateScreens(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), DIALOG_ANNOTATE::DIALOG_ANNOTATE(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP(), DIALOG_BOARD_STATISTICS(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT(), DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG(), DIALOG_GEN_FOOTPRINT_POSITION::DIALOG_GEN_FOOTPRINT_POSITION(), DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES(), DIALOG_NETLIST_IMPORT::DIALOG_NETLIST_IMPORT(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_PLOT::DIALOG_PLOT(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_SYMBOL_REMAP::DIALOG_SYMBOL_REMAP(), DIALOG_UPDATE_FROM_PCB::DIALOG_UPDATE_FROM_PCB(), DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB(), PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), FOOTPRINT_PREVIEW_PANEL::DisplayFootprint(), SYMBOL_VIEWER_FRAME::DisplayLibInfos(), CVPCB_MAINFRAME::DisplayStatus(), PCB_EDIT_FRAME::doAutoSave(), SCH_EDIT_FRAME::doAutoSave(), PCB_BASE_EDIT_FRAME::doCloseWindow(), FOOTPRINT_EDIT_FRAME::doCloseWindow(), SCH_EDIT_FRAME::doCloseWindow(), FIELDS_GRID_TRICKS::doPopupSelection(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), KICAD_MANAGER_CONTROL::Execute(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), BOARD_EDITOR_CONTROL::ExportNetlist(), SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG(), SYMBOL_EDITOR_CONTROL::ExportView(), PCB_EDIT_FRAME::ExportVRML_File(), BACK_ANNOTATE::FetchNetlistFromPCB(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::GenD356File(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), SYMBOL_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), SIM_PLOT_FRAME::getDefaultFilename(), SIM_PLOT_FRAME::getDefaultPath(), PCB_BASE_EDIT_FRAME::GetDesignRulesPath(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable(), SCH_BASE_FRAME::GetLibSymbol(), DIALOG_PLOT_SCHEMATIC::getOutputPath(), KICAD_MANAGER_FRAME::GetProjectFileName(), SCH_EDIT_FRAME::GetSchematicJunctionSize(), SYMBOL_VIEWER_FRAME::GetSelectedSymbol(), SCH_EDIT_FRAME::importFile(), SCH_EDITOR_CONTROL::ImportFPAssignments(), DIALOG_CONFIG_EQUFILES::Init(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), SCH_EDIT_FRAME::KiwayMailIn(), SYMBOL_EDIT_FRAME::KiwayMailIn(), EDA_DRAW_FRAME::LibraryFileBrowser(), CVPCB_MAINFRAME::LoadFootprintFiles(), DIALOG_SPICE_MODEL::loadLibrary(), KICAD_MANAGER_FRAME::LoadProject(), SCH_EDIT_FRAME::LoadProject(), SCH_EDIT_FRAME::LoadProjectSettings(), PCB_EDIT_FRAME::LoadProjectSettings(), SIM_PLOT_FRAME::LoadSettings(), SCH_EDIT_FRAME::LoadSheetFromFile(), SYMBOL_EDIT_FRAME::LoadSymbolFromCurrentLib(), EDA_BASE_FRAME::LoadWindowState(), SIM_PLOT_FRAME::loadWorkbook(), SIM_PLOT_FRAME::menuSaveWorkbook(), SIM_PLOT_FRAME::menuSaveWorkbookAs(), PANEL_FP_PROPERTIES_3D_MODEL::On3DModelCellChanged(), FOOTPRINT_VIEWER_FRAME::OnActivate(), PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DModel(), DIALOG_BOARD_SETUP::OnAuxiliaryAction(), KICAD_MANAGER_FRAME::OnBrowseInFileExplorer(), DIALOG_NETLIST_IMPORT::onBrowseNetlistFiles(), WX_HTML_REPORT_PANEL::onBtnSaveToFile(), TEXT_BUTTON_URL::OnButtonClick(), TEXT_BUTTON_FILE_BROWSER::OnButtonClick(), DIALOG_EDIT_SYMBOLS_LIBID::onClickOrphansButton(), DIALOG_EXPORT_STEP::onExportButton(), DIALOG_GENDRILL::OnGenReportFile(), KICAD_MANAGER_FRAME::OnIdle(), SCH_EDIT_FRAME::OnImportProject(), DIALOG_CHOOSE_SYMBOL::OnInitDialog(), DIALOG_CONFIG_EQUFILES::OnOkClick(), SCH_EDIT_FRAME::OnOpenCvpcb(), KICAD_MANAGER_FRAME::OnOpenFileInTextEditor(), SCH_EDIT_FRAME::OnOpenPcbnew(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_SCHEMATIC_SETUP::OnPageChange(), DIALOG_BOARD_SETUP::OnPageChange(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), DIALOG_TEXT_AND_LABEL_PROPERTIES::onScintillaCharAdded(), PROPERTIES_FRAME::onScintillaCharAdded(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), DIALOG_SPICE_MODEL::onSelectLibrary(), SYMBOL_VIEWER_FRAME::OnSelectSymbol(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), SCH_EDIT_FRAME::OnUpdatePCB(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), PANEL_FP_PROPERTIES_3D_MODEL::PANEL_FP_PROPERTIES_3D_MODEL(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), SCH_EDITOR_CONTROL::Paste(), FOOTPRINT_EDITOR_CONTROL::PasteFootprint(), SCH_BASE_FRAME::PickSymbolFromLibTree(), DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl(), DIALOG_CHOOSE_SYMBOL::PopulateFootprintSelector(), SCH_EDITOR_CONTROL::Print(), EDA_DRAW_FRAME::PrintDrawingSheet(), SCH_EDIT_FRAME::PrintPage(), KICAD_MANAGER_FRAME::PrintPrjInfo(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), SYMBOL_VIEWER_FRAME::ReCreateSymbolList(), PANEL_FP_PROPERTIES_3D_MODEL::ReloadModelsFromFootprint(), EDA_3D_VIEWER_FRAME::ReloadRequest(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), SCH_EDITOR_CONTROL::RescueLegacyProject(), SCH_EDITOR_CONTROL::RescueSymbolLibTableProject(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), FOOTPRINT_EDITOR_CONTROL::SaveAs(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), SYMBOL_EDIT_FRAME::saveLibrary(), PCB_EDIT_FRAME::SavePcbFile(), SCH_EDIT_FRAME::SaveProject(), PCB_EDIT_FRAME::SaveProjectSettings(), saveReportClicked(), SCH_EDIT_FRAME::saveSchematicFile(), SIM_PLOT_FRAME::SaveSettings(), EDA_BASE_FRAME::SaveSettings(), SYMBOL_EDIT_FRAME::saveSymbolAs(), SCH_BASE_FRAME::saveSymbolLibTables(), SIM_PLOT_FRAME::saveWorkbook(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), PCB_BASE_FRAME::SelectLibrary(), SYMBOL_EDIT_FRAME::SelectLibraryFromList(), PCB_BASE_EDIT_FRAME::selectLibTable(), SYMBOL_EDIT_FRAME::selectSymLibTable(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), SYMBOL_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), SYMBOL_EDIT_FRAME::SetCurSymbol(), GERBVIEW_FRAME::SetPageSettings(), EE_INSPECTION_TOOL::ShowDatasheet(), DIALOG_CHOOSE_SYMBOL::ShowFootprintFor(), COMMON_CONTROL::ShowHelp(), SYMBOL_VIEWER_FRAME::ShowModal(), FOOTPRINT_VIEWER_FRAME::ShowModal(), SCH_EDIT_FRAME::ShowSchematicSetupDialog(), SYMBOL_LIBRARY_MANAGER::symTable(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), EDA_3D_VIEWER_FRAME::takeScreenshot(), PANEL_SETUP_RULES::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), NETLIST_DIALOG::TransferDataFromWindow(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), PANEL_SETUP_RULES::TransferDataToWindow(), SCH_EDIT_FRAME::updateAutoSaveFile(), DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), SIM_PLOT_FRAME::updateTitle(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), SCH_EDIT_FRAME::UpdateTitle(), PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_FOOTPRINT_PROPERTIES::~DIALOG_FOOTPRINT_PROPERTIES(), PANEL_FP_PROPERTIES_3D_MODEL::~PANEL_FP_PROPERTIES_3D_MODEL(), and SCH_EDIT_FRAME::~SCH_EDIT_FRAME().

◆ refreshItemsTypes()

void DIALOG_BOARD_STATISTICS::refreshItemsTypes ( )
private

< Function to fill up all items types to be shown in the dialog.

Get data from board.

Definition at line 141 of file dialog_board_statistics.cpp.

142 {
143  m_componentsTypes.clear();
144 
145  // If you need some more types to be shown, simply add them to the
146  // corresponding list
147  m_componentsTypes.push_back( componentsType_t( FP_THROUGH_HOLE, _( "THT:" ) ) );
148  m_componentsTypes.push_back( componentsType_t( FP_SMD, _( "SMD:" ) ) );
149 
150  m_padsTypes.clear();
151  m_padsTypes.push_back( padsType_t( PAD_ATTRIB::PTH, _( "Through hole:" ) ) );
152  m_padsTypes.push_back( padsType_t( PAD_ATTRIB::SMD, _( "SMD:" ) ) );
153  m_padsTypes.push_back( padsType_t( PAD_ATTRIB::CONN, _( "Connector:" ) ) );
154  m_padsTypes.push_back( padsType_t( PAD_ATTRIB::NPTH, _( "NPTH:" ) ) );
155 
156  m_viasTypes.clear();
157  m_viasTypes.push_back( viasType_t( VIATYPE::THROUGH, _( "Through vias:" ) ) );
158  m_viasTypes.push_back( viasType_t( VIATYPE::BLIND_BURIED, _( "Blind/buried:" ) ) );
159  m_viasTypes.push_back( viasType_t( VIATYPE::MICROVIA, _( "Micro vias:" ) ) );
160 
161  // If there not enough rows in grids, append some
162  int appendRows = m_componentsTypes.size() + 2 - m_gridComponents->GetNumberRows();
163 
164  if( appendRows > 0 )
165  m_gridComponents->AppendRows( appendRows );
166 
167  appendRows = m_padsTypes.size() + 1 - m_gridPads->GetNumberRows();
168 
169  if( appendRows > 0 )
170  m_gridPads->AppendRows( appendRows );
171 
172  appendRows = m_viasTypes.size() + 1 - m_gridVias->GetNumberRows();
173 
174  if( appendRows )
175  m_gridVias->AppendRows( appendRows );
176 }
typeContainer_t< VIATYPE > viasType_t
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
viasTypeList_t m_viasTypes
Hold all drill hole types to be shown in the dialog.
Plated through hole pad.
like PAD_PTH, but not plated
#define _(s)
padsTypeList_t m_padsTypes
Hold all vias types to be shown in the dialog.
componentsTypeList_t m_componentsTypes
Hold all pads types to be shown in the dialog.
typeContainer_t< PAD_ATTRIB > padsType_t

References _, BLIND_BURIED, CONN, FP_SMD, FP_THROUGH_HOLE, m_componentsTypes, DIALOG_BOARD_STATISTICS_BASE::m_gridComponents, DIALOG_BOARD_STATISTICS_BASE::m_gridPads, DIALOG_BOARD_STATISTICS_BASE::m_gridVias, m_padsTypes, m_viasTypes, MICROVIA, NPTH, PTH, SMD, and THROUGH.

Referenced by checkboxClicked(), and TransferDataToWindow().

◆ resetSize()

void DIALOG_SHIM::resetSize ( )
protectedinherited

Clear the existing dialog size and position.

This will cause the dialog size to be clear so the next time the dialog is shown the sizers will layout the dialog accordingly. This useful when there are dialog windows that size changes due to layout dependency hidden controls.

Definition at line 287 of file dialog_shim.cpp.

288 {
289  const char* hash_key;
290 
291  if( m_hash_key.size() )
292  {
293  // a special case like EDA_LIST_DIALOG, which has multiple uses.
294  hash_key = m_hash_key.c_str();
295  }
296  else
297  {
298  hash_key = typeid(*this).name();
299  }
300 
301  std::unordered_map<std::string, wxRect>::iterator it = class_map.find( hash_key );
302 
303  if( it == class_map.end() )
304  return;
305 
306  wxRect rect = it->second;
307  rect.SetSize( wxSize( 0, 0 ) );
308  class_map[ hash_key ] = rect;
309 }
std::string m_hash_key
Definition: dialog_shim.h:201
static std::unordered_map< std::string, wxRect > class_map

References class_map, and DIALOG_SHIM::m_hash_key.

Referenced by DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES().

◆ saveReportClicked()

void DIALOG_BOARD_STATISTICS::saveReportClicked ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Reimplemented from DIALOG_BOARD_STATISTICS_BASE.

Definition at line 656 of file dialog_board_statistics.cpp.

657 {
658  FILE* outFile;
659  wxString msg;
660  wxString boardName;
661 
662  wxFileName fn = m_parentFrame->GetBoard()->GetFileName();
663  boardName = fn.GetName();
664  wxFileDialog saveFileDialog( this, _( "Save Report File" ),
668  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
669 
670  if( saveFileDialog.ShowModal() == wxID_CANCEL )
671  return;
672 
673  s_savedDialogState.saveReportFolder = wxPathOnly( saveFileDialog.GetPath() );
674  s_savedDialogState.saveReportName = saveFileDialog.GetFilename();
675 
676  outFile = wxFopen( saveFileDialog.GetPath(), wxT( "wt" ) );
677 
678  if( outFile == nullptr )
679  {
680  msg.Printf( _( "Failed to create file '%s'." ), saveFileDialog.GetPath() );
681  DisplayErrorMessage( this, msg );
682  return;
683  }
684 
685  msg << _( "PCB statistics report\n=====================" ) << wxT( "\n" );
686  msg << wxS( "- " ) << _( "Date" ) << wxS( ": " ) << wxDateTime::Now().Format() << wxT( "\n" );
687  msg << wxS( "- " ) << _( "Project" ) << wxS( ": " )<< Prj().GetProjectName() << wxT( "\n" );
688  msg << wxS( "- " ) << _( "Board name" ) << wxS( ": " )<< boardName << wxT( "\n" );
689 
690  msg << wxT( "\n" );
691  msg << _( "Board" ) << wxT( "\n-----\n" );
692 
693  if( m_hasOutline )
694  {
695  msg << wxS( "- " ) << _( "Width" ) << wxS( ": " ) <<
696  MessageTextFromValue( GetUserUnits(), m_boardWidth ) << wxT( "\n" );
697  msg << wxS( "- " ) << _( "Height" ) << wxS( ": " ) <<
698  MessageTextFromValue( GetUserUnits(), m_boardHeight ) << wxT( "\n" );
699  msg << wxS( "- " ) << _( "Area" ) + wxS( ": " ) <<
701  msg << wxT( "\n" );
702  }
703  else
704  {
705  msg << wxS( "- " ) << _( "Width" ) << wxS( ": " ) << _( "unknown" ) << wxT( "\n" );
706  msg << wxS( "- " ) << _( "Height" ) << wxS( ": " ) << _( "unknown" ) << wxT( "\n" );
707  msg << wxS( "- " ) << _( "Area" ) << wxS( ": " ) << _( "unknown" ) << wxT( "\n" );
708  }
709 
710  msg << wxT( "\n" );
711  msg << _( "Pads" ) << wxT( "\n----\n" );
712 
713  for( auto& type : m_padsTypes )
714  msg << wxT( "- " ) << type.title << wxS( " " ) << type.qty << wxT( "\n" );
715 
716  msg << wxT( "\n" );
717  msg << _( "Vias" ) << wxT( "\n----\n" );
718 
719  for( auto& type : m_viasTypes )
720  msg << wxT( "- " ) << type.title << wxS( " " ) << type.qty << wxT( "\n" );
721 
722  // We will save data about components in the table.
723  // We have to calculate column widths
724  std::vector<int> widths;
725  std::vector<wxString> labels{ wxEmptyString, _( "Front Side" ), _( "Back Side" ), _( "Total" ) };
726  wxString tmp;
727 
728  widths.reserve( labels.size() );
729 
730  for( const auto& label : labels )
731  widths.push_back( label.size() );
732 
733  int frontTotal = 0;
734  int backTotal = 0;
735 
736  for( const auto& type : m_componentsTypes )
737  {
738  // Get maximum width for left label column
739  widths[0] = std::max<int>( type.title.size(), widths[0] );
740  frontTotal += type.frontSideQty;
741  backTotal += type.backSideQty;
742  }
743 
744  // Get maximum width for other columns
745  tmp.Printf( wxT( "%i" ), frontTotal );
746  widths[1] = std::max<int>( tmp.size(), widths[1] );
747  tmp.Printf( wxT( "%i" ), backTotal );
748  widths[2] = std::max<int>( tmp.size(), widths[2] );
749  tmp.Printf( wxT( "%i" ), frontTotal + backTotal );
750  widths[3] = std::max<int>( tmp.size(), widths[3] );
751 
752  //Write components amount to file
753  msg << wxT( "\n" );
754  msg << _( "Components" ) << wxT( "\n----------\n" );
755  msg << wxT( "\n" );
756 
757  printGridToStringAsTable( m_gridComponents, msg, false, false, true );
758 
759  msg << wxT( "\n" );
760  msg << _( "Drill holes" ) << wxT( "\n-----------\n" );
761  msg << wxT( "\n" );
762 
763  printGridToStringAsTable( m_gridDrills, msg, false, true, false );
764 
765  if( fprintf( outFile, "%s", TO_UTF8( msg ) ) < 0 )
766  {
767  msg.Printf( _( "Error writing file '%s'." ), saveFileDialog.GetPath() );
768  DisplayErrorMessage( this, msg );
769  }
770 
771  fclose( outFile );
772 }
bool m_hasOutline
Hold all components types to be shown in the dialog.
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
viasTypeList_t m_viasTypes
Hold all drill hole types to be shown in the dialog.
const wxString & GetFileName() const
Definition: board.h:229
double m_boardArea
Show if board outline properly defined.
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:121
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
#define _(s)
void printGridToStringAsTable(wxGrid *aGrid, wxString &aStr, bool aUseRowLabels, bool aUseColLabels, bool aUseFirstColAsLabel)
wxString TextFileWildcard()
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.
Definition: project.cpp:128
BOARD * GetBoard() const
static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState
componentsTypeList_t m_componentsTypes
Hold all pads types to be shown in the dialog.

References _, AREA, DisplayErrorMessage(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), PROJECT::GetProjectName(), DIALOG_SHIM::GetUserUnits(), m_boardArea, m_boardHeight, m_boardWidth, m_componentsTypes, DIALOG_BOARD_STATISTICS_BASE::m_gridComponents, DIALOG_BOARD_STATISTICS_BASE::m_gridDrills, m_hasOutline, m_padsTypes, m_parentFrame, m_viasTypes, MessageTextFromValue(), printGridToStringAsTable(), KIWAY_HOLDER::Prj(), s_savedDialogState, DIALOG_BOARD_STATISTICS_SAVED_STATE::saveReportFolder, DIALOG_BOARD_STATISTICS_SAVED_STATE::saveReportName, TextFileWildcard(), and TO_UTF8.

◆ SetInitialFocus()

void DIALOG_SHIM::SetInitialFocus ( wxWindow *  aWindow)
inlineinherited

Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.

Definition at line 97 of file dialog_shim.h.

98  {
99  m_initialFocusTarget = aWindow;
100  }
wxWindow * m_initialFocusTarget
Definition: dialog_shim.h:211

References DIALOG_SHIM::m_initialFocusTarget.

Referenced by DIALOG_BOM::DIALOG_BOM(), DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT(), DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL(), DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS(), DIALOG_FIND::DIALOG_FIND(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), DIALOG_GET_FOOTPRINT_BY_NAME::DIALOG_GET_FOOTPRINT_BY_NAME(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS(), DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), DIALOG_JUNCTION_PROPS::DIALOG_JUNCTION_PROPS(), DIALOG_LIB_SHAPE_PROPERTIES::DIALOG_LIB_SHAPE_PROPERTIES(), DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES(), DIALOG_LINE_WIRE_BUS_PROPERTIES::DIALOG_LINE_WIRE_BUS_PROPERTIES(), DIALOG_PAD_PRIMITIVES_PROPERTIES::DIALOG_PAD_PRIMITIVES_PROPERTIES(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE(), DIALOG_SCH_FIND::DIALOG_SCH_FIND(), DIALOG_SHEET_PIN_PROPERTIES::DIALOG_SHEET_PIN_PROPERTIES(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_TARGET_PROPERTIES::DIALOG_TARGET_PROPERTIES(), DIALOG_TEXT_AND_LABEL_PROPERTIES::DIALOG_TEXT_AND_LABEL_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), EDA_VIEW_SWITCHER::EDA_VIEW_SWITCHER(), HK_PROMPT_DIALOG::HK_PROMPT_DIALOG(), DIALOG_FIELD_PROPERTIES::init(), DIALOG_EXCHANGE_FOOTPRINTS::OnMatchAllClicked(), DIALOG_EXCHANGE_FOOTPRINTS::OnMatchIDClicked(), DIALOG_EXCHANGE_FOOTPRINTS::OnMatchRefClicked(), DIALOG_EXCHANGE_FOOTPRINTS::OnMatchSelectedClicked(), DIALOG_EXCHANGE_FOOTPRINTS::OnMatchValueClicked(), PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE(), PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_EDIT_FRAME::saveSymbolAs(), DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataToWindow(), DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow(), DIALOG_COPPER_ZONE::TransferDataToWindow(), and WX_TEXT_ENTRY_DIALOG::WX_TEXT_ENTRY_DIALOG().

◆ SetKiway()

void KIWAY_HOLDER::SetKiway ( wxWindow *  aDest,
KIWAY aKiway 
)
inherited

It is only used for debugging, since "this" is not a wxWindow*.

"this" is a KIWAY_HOLDER mix-in.

Parameters
aDestis the recipient of aKiway pointer.
aKiwayis often from a parent window or from KIFACE::CreateWindow().

Definition at line 43 of file kiway_holder.cpp.

44 {
45 #if defined(DEBUG)
46  // offer a trap point for debugging most any window
47  wxASSERT( aDest );
48  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
49  {
50  int breakhere=1;
51  ignore_unused( breakhere );
52  }
53 #endif
54 
55  ignore_unused( aDest );
56 
57  m_kiway = aKiway;
58 }
KIWAY * m_kiway
Definition: kiway_holder.h:75
const char * name
Definition: DXF_plotter.cpp:56
void ignore_unused(const T &)
Definition: ignore.h:24

References ignore_unused(), KIWAY_HOLDER::m_kiway, and name.

Referenced by BM2CMP_FRAME::BM2CMP_FRAME(), PCB::IFACE::CreateWindow(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

◆ SetPosition()

void DIALOG_SHIM::SetPosition ( const wxPoint &  aNewPosition)
inherited

Force the position of the dialog to a new position.

Parameters
aNewPositionis the new forced position

Definition at line 190 of file dialog_shim.cpp.

191 {
192  wxDialog::SetPosition( aNewPosition );
193 
194  // Now update the stored position:
195  const char* hash_key;
196 
197  if( m_hash_key.size() )
198  {
199  // a special case like EDA_LIST_DIALOG, which has multiple uses.
200  hash_key = m_hash_key.c_str();
201  }
202  else
203  {
204  hash_key = typeid(*this).name();
205  }
206 
207  std::unordered_map<std::string, wxRect>::iterator it = class_map.find( hash_key );
208 
209  if( it == class_map.end() )
210  return;
211 
212  wxRect rect = it->second;
213  rect.SetPosition( aNewPosition );
214 
215  class_map[ hash_key ] = rect;
216 }
std::string m_hash_key
Definition: dialog_shim.h:201
static std::unordered_map< std::string, wxRect > class_map
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)

References class_map, DIALOG_SHIM::m_hash_key, and PCAD2KICAD::SetPosition().

Referenced by PCB_BASE_FRAME::SelectOneLayer().

◆ setSizeInDU()

void DIALOG_SHIM::setSizeInDU ( int  x,
int  y 
)
protectedinherited

Set the dialog to the given dimensions in "dialog units".

These are units equivalent to 4* the average character width and 8* the average character height, allowing a dialog to be sized in a way that scales it with the system font.

Definition at line 162 of file dialog_shim.cpp.

163 {
164  wxSize sz( x, y );
165  SetSize( ConvertDialogToPixels( sz ) );
166 }

Referenced by DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH(), HTML_MESSAGE_BOX::HTML_MESSAGE_BOX(), and HTML_MESSAGE_BOX::SetDialogSizeInDU().

◆ Show()

bool DIALOG_SHIM::Show ( bool  show)
overrideinherited

Definition at line 219 of file dialog_shim.cpp.

220 {
221  bool ret;
222  const char* hash_key;
223 
224  if( m_hash_key.size() )
225  {
226  // a special case like EDA_LIST_DIALOG, which has multiple uses.
227  hash_key = m_hash_key.c_str();
228  }
229  else
230  {
231  hash_key = typeid(*this).name();
232  }
233 
234  // Show or hide the window. If hiding, save current position and size.
235  // If showing, use previous position and size.
236  if( show )
237  {
238 #ifndef __WINDOWS__
239  wxDialog::Raise(); // Needed on OS X and some other window managers (i.e. Unity)
240 #endif
241  ret = wxDialog::Show( show );
242 
243  // classname is key, returns a zeroed out default EDA_RECT if none existed before.
244  wxRect savedDialogRect = class_map[ hash_key ];
245 
246  if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 )
247  {
248  if( m_useCalculatedSize )
249  {
250  SetSize( savedDialogRect.GetPosition().x, savedDialogRect.GetPosition().y,
251  wxDialog::GetSize().x, wxDialog::GetSize().y, 0 );
252  }
253  else
254  {
255  SetSize( savedDialogRect.GetPosition().x, savedDialogRect.GetPosition().y,
256  std::max( wxDialog::GetSize().x, savedDialogRect.GetSize().x ),
257  std::max( wxDialog::GetSize().y, savedDialogRect.GetSize().y ),
258  0 );
259  }
260  }
261  else if( m_initialSize != wxDefaultSize )
262  SetSize( m_initialSize );
263 
264  // Be sure that the dialog appears in a visible area
265  // (the dialog position might have been stored at the time when it was
266  // shown on another display)
267  if( wxDisplay::GetFromWindow( this ) == wxNOT_FOUND )
268  Centre();
269  }
270  else
271  {
272  // Save the dialog's position & size before hiding, using classname as key
273  class_map[ hash_key ] = wxRect( wxDialog::GetPosition(), wxDialog::GetSize() );
274 
275 #ifdef __WXMAC__
276  if ( m_eventLoop )
277  m_eventLoop->Exit( GetReturnCode() ); // Needed for APP-MODAL dlgs on OSX
278 #endif
279 
280  ret = wxDialog::Show( show );
281  }
282 
283  return ret;
284 }
std::string m_hash_key
Definition: dialog_shim.h:201
static std::unordered_map< std::string, wxRect > class_map
bool m_useCalculatedSize
Definition: dialog_shim.h:205
wxSize m_initialSize
Definition: dialog_shim.h:223

References class_map, DIALOG_SHIM::m_hash_key, DIALOG_SHIM::m_initialSize, and DIALOG_SHIM::m_useCalculatedSize.

Referenced by FOOTPRINT_EDITOR_CONTROL::CheckFootprint(), DRC_TOOL::CrossProbe(), DIALOG_SHIM::EndQuasiModal(), GROUP_TOOL::GroupProperties(), EE_INSPECTION_TOOL::NextMarker(), DRC_TOOL::NextMarker(), SCH_EDIT_FRAME::OnAnnotate(), DIALOG_DRC::OnDRCItemDClick(), DIALOG_ERC::OnERCItemDClick(), DIALOG_CLEANUP_GRAPHICS::OnLeftDClickItem(), DIALOG_CLEANUP_TRACKS_AND_VIAS::OnLeftDClickItem(), DIALOG_FOOTPRINT_CHECKER::OnLeftDClickItem(), GROUP_TOOL::PickNewMember(), POSITION_RELATIVE_TOOL::PositionRelative(), EE_INSPECTION_TOOL::PrevMarker(), DRC_TOOL::PrevMarker(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), EDA_VIEW_SWITCHER::Show(), DIALOG_PAD_PROPERTIES::Show(), DIALOG_FIND::Show(), DRC_TOOL::ShowDRCDialog(), EE_INSPECTION_TOOL::ShowERCDialog(), SCH_EDIT_FRAME::ShowFindReplaceDialog(), HTML_MESSAGE_BOX::ShowModeless(), DIALOG_SHIM::ShowQuasiModal(), DIALOG_POSITION_RELATIVE::UpdateAnchor(), and SCH_EDIT_FRAME::UpdateHierarchyNavigator().

◆ ShowQuasiModal()

int DIALOG_SHIM::ShowQuasiModal ( )
inherited

Definition at line 430 of file dialog_shim.cpp.

431 {
432  // This is an exception safe way to zero a pointer before returning.
433  // Yes, even though DismissModal() clears this first normally, this is
434  // here in case there's an exception before the dialog is dismissed.
435  struct NULLER
436  {
437  void*& m_what;
438  NULLER( void*& aPtr ) : m_what( aPtr ) {}
439  ~NULLER() { m_what = nullptr; } // indeed, set it to NULL on destruction
440  } clear_this( (void*&) m_qmodal_loop );
441 
442  // release the mouse if it's currently captured as the window having it
443  // will be disabled when this dialog is shown -- but will still keep the
444  // capture making it impossible to do anything in the modal dialog itself
445  wxWindow* win = wxWindow::GetCapture();
446  if( win )
447  win->ReleaseMouse();
448 
449  // Get the optimal parent
450  wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );
451 
452  wxASSERT_MSG( !m_qmodal_parent_disabler,
453  wxT( "Caller using ShowQuasiModal() twice on same window?" ) );
454 
455  // quasi-modal: disable only my "optimal" parent
457 
458  // Apple in its infinite wisdom will raise a disabled window before even passing
459  // us the event, so we have no way to stop it. Instead, we must set an order on
460  // the windows so that the quasi-modal will be pushed in front of the disabled
461  // window when it is raised.
463 
464  Show( true );
465 
466  m_qmodal_showing = true;
467 
468  WX_EVENT_LOOP event_loop;
469 
470  m_qmodal_loop = &event_loop;
471 
472  event_loop.Run();
473 
474  m_qmodal_showing = false;
475 
476  return GetReturnCode();
477 }
bool m_qmodal_showing
Definition: dialog_shim.h:215
#define WX_EVENT_LOOP
Definition: kiway_player.h:41
WX_EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:213
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:216
Toggle a window's "enable" status to disabled, then enabled on destruction.
Definition: dialog_shim.cpp:44
void ReparentQuasiModal(wxNonOwnedWindow *aWindow)
Move a window's parent to be the top-level window and force the window to be on top.
Definition: gtk/ui.cpp:65

References DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, DIALOG_SHIM::m_qmodal_showing, KIPLATFORM::UI::ReparentQuasiModal(), DIALOG_SHIM::Show(), and WX_EVENT_LOOP.

Referenced by SCH_EDIT_TOOL::ChangeSymbols(), S3D::Configure3DPaths(), COMMON_CONTROL::ConfigurePaths(), MICROWAVE_TOOL::createFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), SCH_DRAWING_TOOLS::createNewText(), SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties(), SCH_EDIT_TOOL::editFieldText(), SCH_EDITOR_CONTROL::EditSymbolFields(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), GLOBAL_EDIT_TOOL::EditTracksAndVias(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), InvokeCopperZonesEditor(), InvokeDialogCreateBOM(), InvokeDialogEditSymbolsLibId(), InvokeDialogRescueEach(), InvokeNonCopperZonesEditor(), SYMBOL_VIEWER_FRAME::OnSelectSymbol(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), SCH_EDITOR_CONTROL::RemapSymbols(), S3D::Select3DModel(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), PCB_EDIT_FRAME::ShowBoardSetupDialog(), PCB_EDIT_FRAME::ShowDimensionPropertiesDialog(), PCB_EDIT_FRAME::ShowExchangeFootprintsDialog(), PCB_EDIT_FRAME::ShowFootprintPropertiesDialog(), PCB_BASE_EDIT_FRAME::ShowGraphicItemPropertiesDialog(), PCB_BASE_FRAME::ShowPadPropertiesDialog(), SCH_EDIT_FRAME::ShowSchematicSetupDialog(), PCB_BASE_EDIT_FRAME::ShowTextPropertiesDialog(), and PCB_EDIT_FRAME::ToPlotter().

◆ TransferDataToWindow()

bool DIALOG_BOARD_STATISTICS::TransferDataToWindow ( )
override

Definition at line 179 of file dialog_board_statistics.cpp.

180 {
182  getDataFromPCB();
183  updateWidets();
184 
185  Layout();
186  m_drillsPanel->Layout();
187 
188  m_gridDrills->AutoSizeColumns();
191 
192  // Add space for the vertical scrollbar, so that it won't overlap with the cells.
193  m_gridDrills->SetMinSize( m_gridDrills->GetEffectiveMinSize()
194  + wxSize( wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ), 0 ) );
195 
197 
199  return true;
200 }
void refreshItemsTypes()
< Function to fill up all items types to be shown in the dialog.
void getDataFromPCB()
Apply data to dialog widgets.
int m_startLayerColInitialSize
Width of the stop layer column as calculated by the wxWidgets autosizing algorithm.
void updateWidets()
Update drills grid.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...

References adjustDrillGridColumns(), DIALOG_BOARD_STATISTICS::drillType_t::COL_START_LAYER, DIALOG_BOARD_STATISTICS::drillType_t::COL_STOP_LAYER, DIALOG_SHIM::finishDialogSettings(), getDataFromPCB(), DIALOG_BOARD_STATISTICS_BASE::m_drillsPanel, DIALOG_BOARD_STATISTICS_BASE::m_gridDrills, m_startLayerColInitialSize, m_stopLayerColInitialSize, refreshItemsTypes(), and updateWidets().

◆ updateDrillGrid()

void DIALOG_BOARD_STATISTICS::updateDrillGrid ( )
private

Print grid to string in tabular format.

Definition at line 466 of file dialog_board_statistics.cpp.

467 {
468  BOARD* board = m_parentFrame->GetBoard();
469  int currentRow = 0;
470 
471  for( const auto& type : m_drillTypes )
472  {
473  wxString shapeStr;
474  wxString startLayerStr;
475  wxString stopLayerStr;
476 
477  switch( type.shape )
478  {
480  shapeStr = _( "Round" );
481  break;
483  shapeStr = _( "Slot" );
484  break;
485  default:
486  shapeStr = _( "???" );
487  break;
488  }
489 
490  if( type.startLayer == UNDEFINED_LAYER )
491  startLayerStr = _( "N/A" );
492  else
493  startLayerStr = board->GetLayerName( type.startLayer );
494 
495  if( type.stopLayer == UNDEFINED_LAYER )
496  stopLayerStr = _( "N/A" );
497  else
498  stopLayerStr = board->GetLayerName( type.stopLayer );
499 
500  m_gridDrills->SetCellValue(
501  currentRow, drillType_t::COL_COUNT, wxString::Format( wxT( "%i" ), type.qty ) );
502  m_gridDrills->SetCellValue( currentRow, drillType_t::COL_SHAPE, shapeStr );
503  m_gridDrills->SetCellValue( currentRow, drillType_t::COL_X_SIZE,
504  MessageTextFromValue( GetUserUnits(), type.xSize ) );
505  m_gridDrills->SetCellValue( currentRow, drillType_t::COL_Y_SIZE,
506  MessageTextFromValue( GetUserUnits(), type.ySize ) );
507  m_gridDrills->SetCellValue(
508  currentRow, drillType_t::COL_PLATED, type.isPlated ? _( "PTH" ) : _( "NPTH" ) );
509  m_gridDrills->SetCellValue(
510  currentRow, drillType_t::COL_VIA_PAD, type.isPad ? _( "Pad" ) : _( "Via" ) );
511  m_gridDrills->SetCellValue( currentRow, drillType_t::COL_START_LAYER, startLayerStr );
512  m_gridDrills->SetCellValue( currentRow, drillType_t::COL_STOP_LAYER, stopLayerStr );
513 
514  currentRow++;
515  }
516 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:362
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:121
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
BOARD * GetBoard() const
drillTypeList_t m_drillTypes
Width of the start layer column as calculated by the wxWidgets autosizing algorithm.

References _, DIALOG_BOARD_STATISTICS::drillType_t::COL_COUNT, DIALOG_BOARD_STATISTICS::drillType_t::COL_PLATED, DIALOG_BOARD_STATISTICS::drillType_t::COL_SHAPE, DIALOG_BOARD_STATISTICS::drillType_t::COL_START_LAYER, DIALOG_BOARD_STATISTICS::drillType_t::COL_STOP_LAYER, DIALOG_BOARD_STATISTICS::drillType_t::COL_VIA_PAD, DIALOG_BOARD_STATISTICS::drillType_t::COL_X_SIZE, DIALOG_BOARD_STATISTICS::drillType_t::COL_Y_SIZE, Format(), PCB_BASE_FRAME::GetBoard(), BOARD::GetLayerName(), DIALOG_SHIM::GetUserUnits(), m_drillTypes, DIALOG_BOARD_STATISTICS_BASE::m_gridDrills, m_parentFrame, MessageTextFromValue(), PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG, and UNDEFINED_LAYER.

Referenced by drillGridSort(), and updateWidets().

◆ updateWidets()

void DIALOG_BOARD_STATISTICS::updateWidets ( )
private

Update drills grid.

Definition at line 375 of file dialog_board_statistics.cpp.

376 {
377  int totalPads = 0;
378  int currentRow = 0;
379 
380  for( const auto& type : m_padsTypes )
381  {
382  m_gridPads->SetCellValue( currentRow, COL_LABEL, type.title );
383  m_gridPads->SetCellValue( currentRow, COL_AMOUNT,
384  wxString::Format( wxT( "%i " ), type.qty ) );
385  totalPads += type.qty;
386  currentRow++;
387  }
388 
389  m_gridPads->SetCellValue( currentRow, COL_LABEL, _( "Total:" ) );
390  m_gridPads->SetCellValue( currentRow, COL_AMOUNT, wxString::Format( wxT( "%i " ), totalPads ) );
391 
392  int totalVias = 0;
393  currentRow = 0;
394 
395  for( const auto& type : m_viasTypes )
396  {
397  m_gridVias->SetCellValue( currentRow, COL_LABEL, type.title );
398  m_gridVias->SetCellValue( currentRow, COL_AMOUNT, wxString::Format( wxT( "%i " ), type.qty ) );
399  totalVias += type.qty;
400  currentRow++;
401  }
402 
403  m_gridVias->SetCellValue( currentRow, COL_LABEL, _( "Total:" ) );
404  m_gridVias->SetCellValue( currentRow, COL_AMOUNT, wxString::Format( wxT( "%i " ), totalVias ) );
405 
406 
407  int totalFront = 0;
408  int totalBack = 0;
409 
410  // We don't use row 0, as there labels are
411  currentRow = 1;
412 
413  for( const auto& type : m_componentsTypes )
414  {
415  m_gridComponents->SetCellValue( currentRow, COL_LABEL, type.title );
416  m_gridComponents->SetCellValue( currentRow, COL_FRONT_SIDE,
417  wxString::Format( wxT( "%i " ), type.frontSideQty ) );
418  m_gridComponents->SetCellValue( currentRow, COL_BOTTOM_SIDE,
419  wxString::Format( wxT( "%i " ), type.backSideQty ) );
420  m_gridComponents->SetCellValue( currentRow, 3,
421  wxString::Format( wxT( "%i " ),
422  type.frontSideQty + type.backSideQty ) );
423  totalFront += type.frontSideQty;
424  totalBack += type.backSideQty;
425  currentRow++;
426  }
427 
428  m_gridComponents->SetCellValue( currentRow, COL_LABEL, _( "Total:" ) );
429  m_gridComponents->SetCellValue( currentRow, COL_FRONT_SIDE,
430  wxString::Format( wxT( "%i " ), totalFront ) );
431  m_gridComponents->SetCellValue( currentRow, COL_BOTTOM_SIDE,
432  wxString::Format( wxT( "%i " ), totalBack ) );
433  m_gridComponents->SetCellValue( currentRow, COL_TOTAL,
434  wxString::Format( wxT( "%i " ), totalFront + totalBack ) );
435 
436  if( m_hasOutline )
437  {
438  m_gridBoard->SetCellValue( ROW_BOARD_WIDTH, COL_AMOUNT,
440  m_boardWidth ) + wxS( " " ) );
441  m_gridBoard->SetCellValue( ROW_BOARD_HEIGHT, COL_AMOUNT,
443  m_boardHeight ) + wxS( " " ) );
444  m_gridBoard->SetCellValue( ROW_BOARD_AREA, COL_AMOUNT,
447  }
448  else
449  {
450  m_gridBoard->SetCellValue( ROW_BOARD_WIDTH, COL_AMOUNT, _( "unknown" ) );
451  m_gridBoard->SetCellValue( ROW_BOARD_HEIGHT, COL_AMOUNT, _( "unknown" ) );
452  m_gridBoard->SetCellValue( ROW_BOARD_AREA, COL_AMOUNT, _( "unknown" ) );
453  }
454 
455  updateDrillGrid();
456 
457  m_gridComponents->AutoSize();
458  m_gridPads->AutoSize();
459  m_gridBoard->AutoSize();
460  m_gridVias->AutoSize();
461 
463 }
bool m_hasOutline
Hold all components types to be shown in the dialog.
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
#define COL_AMOUNT
viasTypeList_t m_viasTypes
Hold all drill hole types to be shown in the dialog.
#define ROW_BOARD_AREA
#define ROW_BOARD_HEIGHT
double m_boardArea
Show if board outline properly defined.
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:121
#define COL_TOTAL
#define COL_BOTTOM_SIDE
#define COL_FRONT_SIDE
void updateDrillGrid()
Print grid to string in tabular format.
#define _(s)
#define ROW_BOARD_WIDTH
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
padsTypeList_t m_padsTypes
Hold all vias types to be shown in the dialog.
#define COL_LABEL
componentsTypeList_t m_componentsTypes
Hold all pads types to be shown in the dialog.

References _, adjustDrillGridColumns(), AREA, COL_AMOUNT, COL_BOTTOM_SIDE, COL_FRONT_SIDE, COL_LABEL, COL_TOTAL, Format(), DIALOG_SHIM::GetUserUnits(), m_boardArea, m_boardHeight, m_boardWidth, m_componentsTypes, DIALOG_BOARD_STATISTICS_BASE::m_gridBoard, DIALOG_BOARD_STATISTICS_BASE::m_gridComponents, DIALOG_BOARD_STATISTICS_BASE::m_gridPads, DIALOG_BOARD_STATISTICS_BASE::m_gridVias, m_hasOutline, m_padsTypes, m_viasTypes, MessageTextFromValue(), ROW_BOARD_AREA, ROW_BOARD_HEIGHT, ROW_BOARD_WIDTH, and updateDrillGrid().

Referenced by checkboxClicked(), and TransferDataToWindow().

◆ vertPixelsFromDU()

int DIALOG_SHIM::vertPixelsFromDU ( int  y) const
protectedinherited

Convert an integer number of dialog units to pixels, vertically.

See SetSizeInDU or wxDialog documentation for more information.

Definition at line 176 of file dialog_shim.cpp.

177 {
178  wxSize sz( 0, y );
179  return ConvertDialogToPixels( sz ).y;
180 }

Referenced by DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL().

◆ windowSize()

virtual void DIALOG_BOARD_STATISTICS_BASE::windowSize ( wxSizeEvent &  event)
inlineprotectedvirtualinherited

Member Data Documentation

◆ m_boardArea

double DIALOG_BOARD_STATISTICS::m_boardArea
private

Show if board outline properly defined.

Definition at line 215 of file dialog_board_statistics.h.

Referenced by getDataFromPCB(), saveReportClicked(), and updateWidets().

◆ m_boardHeight

int DIALOG_BOARD_STATISTICS::m_boardHeight
private

Definition at line 214 of file dialog_board_statistics.h.

Referenced by getDataFromPCB(), saveReportClicked(), and updateWidets().

◆ m_boardWidth

int DIALOG_BOARD_STATISTICS::m_boardWidth
private

Definition at line 213 of file dialog_board_statistics.h.

Referenced by getDataFromPCB(), saveReportClicked(), and updateWidets().

◆ m_buttonSaveReport

wxButton* DIALOG_BOARD_STATISTICS_BASE::m_buttonSaveReport
protectedinherited

◆ m_checkBoxExcludeComponentsNoPins

wxCheckBox* DIALOG_BOARD_STATISTICS_BASE::m_checkBoxExcludeComponentsNoPins
protectedinherited

◆ m_checkBoxSubtractHoles

wxCheckBox* DIALOG_BOARD_STATISTICS_BASE::m_checkBoxSubtractHoles
protectedinherited

◆ m_componentsTypes

componentsTypeList_t DIALOG_BOARD_STATISTICS::m_componentsTypes
private

Hold all pads types to be shown in the dialog.

Definition at line 221 of file dialog_board_statistics.h.

Referenced by getDataFromPCB(), refreshItemsTypes(), saveReportClicked(), and updateWidets().

◆ m_drillsPanel

wxPanel* DIALOG_BOARD_STATISTICS_BASE::m_drillsPanel
protectedinherited

◆ m_drillTypes

drillTypeList_t DIALOG_BOARD_STATISTICS::m_drillTypes
private

Width of the start layer column as calculated by the wxWidgets autosizing algorithm.

Definition at line 230 of file dialog_board_statistics.h.

Referenced by drillGridSort(), getDataFromPCB(), and updateDrillGrid().

◆ m_firstPaintEvent

bool DIALOG_SHIM::m_firstPaintEvent
protectedinherited

Definition at line 210 of file dialog_shim.h.

Referenced by DIALOG_SHIM::OnPaint().

◆ m_generalPanel

wxPanel* DIALOG_BOARD_STATISTICS_BASE::m_generalPanel
protectedinherited

◆ m_gridBoard

wxGrid* DIALOG_BOARD_STATISTICS_BASE::m_gridBoard
protectedinherited

◆ m_gridComponents

wxGrid* DIALOG_BOARD_STATISTICS_BASE::m_gridComponents
protectedinherited

◆ m_gridDrills

◆ m_gridPads

wxGrid* DIALOG_BOARD_STATISTICS_BASE::m_gridPads
protectedinherited

◆ m_gridVias

wxGrid* DIALOG_BOARD_STATISTICS_BASE::m_gridVias
protectedinherited

◆ m_hash_key

◆ m_hasOutline

bool DIALOG_BOARD_STATISTICS::m_hasOutline
private

Hold all components types to be shown in the dialog.

Definition at line 218 of file dialog_board_statistics.h.

Referenced by getDataFromPCB(), saveReportClicked(), and updateWidets().

◆ m_initialFocusTarget

wxWindow* DIALOG_SHIM::m_initialFocusTarget
protectedinherited

Definition at line 211 of file dialog_shim.h.

Referenced by DIALOG_SHIM::OnPaint(), and DIALOG_SHIM::SetInitialFocus().

◆ m_initialSize

wxSize DIALOG_SHIM::m_initialSize
protectedinherited

Definition at line 223 of file dialog_shim.h.

Referenced by DIALOG_SHIM::Show().

◆ m_padsTypes

padsTypeList_t DIALOG_BOARD_STATISTICS::m_padsTypes
private

Hold all vias types to be shown in the dialog.

Definition at line 224 of file dialog_board_statistics.h.

Referenced by getDataFromPCB(), refreshItemsTypes(), saveReportClicked(), and updateWidets().

◆ m_parentFrame

PCB_EDIT_FRAME* DIALOG_BOARD_STATISTICS::m_parentFrame
private

◆ m_qmodal_loop

WX_EVENT_LOOP* DIALOG_SHIM::m_qmodal_loop
protectedinherited

Definition at line 213 of file dialog_shim.h.

Referenced by DIALOG_SHIM::EndQuasiModal(), and DIALOG_SHIM::ShowQuasiModal().

◆ m_qmodal_parent_disabler

WDO_ENABLE_DISABLE* DIALOG_SHIM::m_qmodal_parent_disabler
protectedinherited

◆ m_qmodal_showing

bool DIALOG_SHIM::m_qmodal_showing
protectedinherited

Definition at line 215 of file dialog_shim.h.

Referenced by DIALOG_SHIM::IsQuasiModal(), and DIALOG_SHIM::ShowQuasiModal().

◆ m_sdbControlSizer

wxStdDialogButtonSizer* DIALOG_BOARD_STATISTICS_BASE::m_sdbControlSizer
protectedinherited

◆ m_sdbControlSizerCancel

wxButton* DIALOG_BOARD_STATISTICS_BASE::m_sdbControlSizerCancel
protectedinherited

◆ m_startLayerColInitialSize

int DIALOG_BOARD_STATISTICS::m_startLayerColInitialSize
private

Width of the stop layer column as calculated by the wxWidgets autosizing algorithm.

Definition at line 233 of file dialog_board_statistics.h.

Referenced by adjustDrillGridColumns(), and TransferDataToWindow().

◆ m_stopLayerColInitialSize

int DIALOG_BOARD_STATISTICS::m_stopLayerColInitialSize
private

Definition at line 236 of file dialog_board_statistics.h.

Referenced by adjustDrillGridColumns(), and TransferDataToWindow().

◆ m_tabOrder

◆ m_units

◆ m_useCalculatedSize

bool DIALOG_SHIM::m_useCalculatedSize
protectedinherited

◆ m_viasTypes

viasTypeList_t DIALOG_BOARD_STATISTICS::m_viasTypes
private

Hold all drill hole types to be shown in the dialog.

Definition at line 227 of file dialog_board_statistics.h.

Referenced by getDataFromPCB(), refreshItemsTypes(), saveReportClicked(), and updateWidets().

◆ topNotebook

wxNotebook* DIALOG_BOARD_STATISTICS_BASE::topNotebook
protectedinherited

◆ viasLabel

wxStaticText* DIALOG_BOARD_STATISTICS_BASE::viasLabel
protectedinherited

The documentation for this class was generated from the following files: