KiCad PCB EDA Suite
panel_board_class.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KICAD, a free EDA CAD application.
3  *
4  * Copyright (C) 2011 jean-pierre.charras
5  * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
23 #include <widgets/unit_selector.h>
24 #include <units_scales.h>
25 
26 PANEL_BOARD_CLASS::PANEL_BOARD_CLASS( wxWindow* parent, wxWindowID id,
27  const wxPoint& pos, const wxSize& size,
28  long style, const wxString& name ) :
29  PANEL_BOARD_CLASS_BASE( parent, id, pos, size, style, name )
30 {
31  // Autosize the row label column to be sure label are not truncated
32  m_gridClassesValuesDisplay->SetRowLabelSize( wxGRID_AUTOSIZE );
33 
34  // Needed on wxWidgets 3.0 to ensure sizers are correctly set
35  GetSizer()->SetSizeHints( this );
36 }
37 
38 
40 {
41 }
42 
43 
45 {
46  // TODO: Only the grid needs updating, but it isn't done automatically (https://trac.wxwidgets.org/ticket/19279)
47 }
48 
49 
51 {
52  aCfg->m_BoardClassUnits = m_BoardClassesUnitsSelector->GetSelection();
53 }
54 
55 
57 {
58  m_BoardClassesUnitsSelector->SetSelection( aCfg->m_BoardClassUnits );
60 }
61 
62 
63 // A helper class to handle min values
64 // Values are in meters.
65 // Note : use -1.0 when a value is irrelevant in a class
67 {
68 public:
69  int m_Class; // Class Id
70  double m_Lines; // min copper lines width
71  double m_Clearance; // min dist between copper lines
72  double m_ViaDiamDiff; // Min value for diff between Via diameter
73  // and its hole diameter
74  double m_PadDiamDiffPlated; // Min value for diff between Pad diameter
75  // and its hole diameter (plated)
76  double m_PadDiamDiffNotPlated; // Min value for diff between Pad diameter
77  // and its hole diameter (not plated)
78 public:
79  BOARD_MIN_SIZE_VALUES( int aClass, double aLines, double aClearance, double aViaDiffPlated,
80  double aPadDiffPlated , double aPadDiffNotPlated ) :
81  m_Class( aClass ),
82  m_Lines( aLines ),
83  m_Clearance( aClearance ),
84  m_ViaDiamDiff( aViaDiffPlated ),
85  m_PadDiamDiffPlated( aPadDiffPlated ),
86  m_PadDiamDiffNotPlated( aPadDiffNotPlated )
87  {
88  }
89 };
90 
91 #define BRDCLASS_COUNT 6
93 {
94  // class 1
96  -1.0,
97  1.19*UNIT_MM, 1.57*UNIT_MM ),
98  // class 2
100  -1.0,
101  0.78*UNIT_MM, 1.13*UNIT_MM ),
102  // class 3
103  BOARD_MIN_SIZE_VALUES(1, 0.31*UNIT_MM, 0.31*UNIT_MM,
104  0.45*UNIT_MM,
105  0.6*UNIT_MM, 0.90*UNIT_MM ),
106  // class 4
107  BOARD_MIN_SIZE_VALUES(1, 0.21*UNIT_MM, 0.21*UNIT_MM,
108  0.34*UNIT_MM,
109  0.49*UNIT_MM, -1.0 ),
110  // class 5
111  BOARD_MIN_SIZE_VALUES(1, 0.15*UNIT_MM, 0.15*UNIT_MM,
112  0.24*UNIT_MM,
113  0.39*UNIT_MM, -1.0 ),
114  // class 6
115  BOARD_MIN_SIZE_VALUES(1, 0.12*UNIT_MM, 0.12*UNIT_MM,
116  0.20*UNIT_MM,
117  0.35*UNIT_MM, -1.0 )
118 };
119 
120 
122 {
124 }
125 
126 
128 {
129  wxString txt;
130  #define FMT wxT("%g")
131  #define NO_VALUE wxT("--")
132 
133  for( int ii = 0; ii < BRDCLASS_COUNT; ii ++ )
134  {
135  // Display min tracks width
136  if( clist[ii].m_Lines > -1.0 )
137  txt.Printf( FMT, clist[ii].m_Lines / aUnitScale);
138  else
139  txt = NO_VALUE;
140  m_gridClassesValuesDisplay->SetCellValue(0, ii, txt );
141 
142  // Display min clearance
143  if( clist[ii].m_Clearance > -1.0 )
144  txt.Printf( FMT, clist[ii].m_Clearance / aUnitScale);
145  else
146  txt = NO_VALUE;
147 
148  m_gridClassesValuesDisplay->SetCellValue(1, ii, txt );
149 
150  // Display min Via diam diff
151  if( clist[ii].m_ViaDiamDiff > -1.0 )
152  txt.Printf( FMT, clist[ii].m_ViaDiamDiff / aUnitScale);
153  else
154  txt = NO_VALUE;
155 
156  m_gridClassesValuesDisplay->SetCellValue(2, ii, txt );
157 
158  // Display min Pad diam diff (plated)
159  if( clist[ii].m_PadDiamDiffPlated > -1.0 )
160  txt.Printf( FMT, clist[ii].m_PadDiamDiffPlated / aUnitScale);
161  else
162  txt = NO_VALUE;
163 
164  m_gridClassesValuesDisplay->SetCellValue(3, ii, txt );
165 
166  // Display min Pad diam diff (non plated)
167  if( clist[ii].m_PadDiamDiffNotPlated > -1.0 )
168  txt.Printf( FMT, clist[ii].m_PadDiamDiffNotPlated / aUnitScale);
169  else
170  txt = NO_VALUE;
171 
172  m_gridClassesValuesDisplay->SetCellValue(4, ii, txt );
173  }
174 }
void BoardClassesUpdateData(double aUnitScale)
PANEL_BOARD_CLASS(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void LoadSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Load the settings into the panel.
Class PANEL_BOARD_CLASS_BASE.
void OnBoardClassesUnitsSelection(wxCommandEvent &event) override
static BOARD_MIN_SIZE_VALUES clist[BRDCLASS_COUNT]
void ThemeChanged() override
Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appr...
void SaveSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Save the settings from the panel.
const char * name
Definition: DXF_plotter.cpp:56
double GetUnitScale() override
Function GetUnitScale.
#define NO_VALUE
UNIT_SELECTOR_LEN * m_BoardClassesUnitsSelector
#define BRDCLASS_COUNT
#define UNIT_MM
Definition: units_scales.h:31
BOARD_MIN_SIZE_VALUES(int aClass, double aLines, double aClearance, double aViaDiffPlated, double aPadDiffPlated, double aPadDiffNotPlated)
#define FMT