KiCad PCB EDA Suite
board_classes_values.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) 2015 jean-pierre.charras
5  * Copyright (C) 2015 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 
21 #include <wx/app.h>
22 #include <wx/msgdlg.h>
23 
24 #include "pcb_calculator_frame.h"
25 #include "units_scales.h"
26 
27 // A helper class to handle min values
28 // Values are in meters.
29 // Note : use -1.0 when a value is irrelevant in a class
31 {
32 public:
33  int m_Class; // Class Id
34  double m_Lines; // min copper lines width
35  double m_Clearance; // min dist between copper lines
36  double m_ViaDiamDiff; // Min value for diff between Via diameter
37  // and its hole diameter
38  double m_PadDiamDiffPlated; // Min value for diff between Pad diameter
39  // and its hole diameter (plated)
40  double m_PadDiamDiffNotPlated; // Min value for diff between Pad diameter
41  // and its hole diameter (not plated)
42 public:
43  BOARD_MIN_SIZE_VALUES( int aClass, double aLines,
44  double aClearance, double aViaDiffPlated,
45  double aPadDiffPlated , double aPadDiffNotPlated )
46  {
47  m_Class = aClass;
48  m_Lines = aLines;
49  m_Clearance = aClearance;
50  m_ViaDiamDiff = aViaDiffPlated;
51  m_PadDiamDiffPlated = aPadDiffPlated;
52  m_PadDiamDiffNotPlated = aPadDiffNotPlated;
53  }
54 };
55 
56 #define BRDCLASS_COUNT 6
58 {
59  // class 1
61  -1.0,
62  1.19*UNIT_MM, 1.57*UNIT_MM ),
63  // class 2
65  -1.0,
66  0.78*UNIT_MM, 1.13*UNIT_MM ),
67  // class 3
69  0.45*UNIT_MM,
70  0.6*UNIT_MM, 0.90*UNIT_MM ),
71  // class 4
73  0.34*UNIT_MM,
74  0.49*UNIT_MM, -1.0 ),
75  // class 5
77  0.24*UNIT_MM,
78  0.39*UNIT_MM, -1.0 ),
79  // class 6
81  0.20*UNIT_MM,
82  0.35*UNIT_MM, -1.0 )
83 };
84 
85 
87 {
89 }
90 
92 {
93  wxString txt;
94  #define FMT wxT("%g")
95  #define NOVAL wxT("--")
96  for( int ii = 0; ii < BRDCLASS_COUNT; ii ++ )
97  {
98  // Display min tracks width
99  if( clist[ii].m_Lines > -1.0 )
100  txt.Printf( FMT, clist[ii].m_Lines / aUnitScale);
101  else
102  txt = NOVAL;
103  m_gridClassesValuesDisplay->SetCellValue(0, ii, txt );
104 
105  // Display min clearance
106  if( clist[ii].m_Clearance > -1.0 )
107  txt.Printf( FMT, clist[ii].m_Clearance / aUnitScale);
108  else
109  txt = NOVAL;
110  m_gridClassesValuesDisplay->SetCellValue(1, ii, txt );
111 
112  // Display min Via diam diff
113  if( clist[ii].m_ViaDiamDiff > -1.0 )
114  txt.Printf( FMT, clist[ii].m_ViaDiamDiff / aUnitScale);
115  else
116  txt = NOVAL;
117  m_gridClassesValuesDisplay->SetCellValue(2, ii, txt );
118 
119  // Display min Pad diam diff (plated)
120  if( clist[ii].m_PadDiamDiffPlated > -1.0 )
121  txt.Printf( FMT, clist[ii].m_PadDiamDiffPlated / aUnitScale);
122  else
123  txt = NOVAL;
124  m_gridClassesValuesDisplay->SetCellValue(3, ii, txt );
125 
126  // Display min Pad diam diff (non plated)
127  if( clist[ii].m_PadDiamDiffNotPlated > -1.0 )
128  txt.Printf( FMT, clist[ii].m_PadDiamDiffNotPlated / aUnitScale);
129  else
130  txt = NOVAL;
131  m_gridClassesValuesDisplay->SetCellValue(4, ii, txt );
132  }
133 }
134 
#define FMT
#define BRDCLASS_COUNT
static BOARD_MIN_SIZE_VALUES clist[BRDCLASS_COUNT]
virtual double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_LEN * m_BoardClassesUnitsSelector
void OnBoardClassesUnitsSelection(wxCommandEvent &event) override
#define UNIT_MM
Definition: units_scales.h:31
#define NOVAL
BOARD_MIN_SIZE_VALUES(int aClass, double aLines, double aClearance, double aViaDiffPlated, double aPadDiffPlated, double aPadDiffNotPlated)
void BoardClassesUpdateData(double aUnitScale)