KiCad PCB EDA Suite
Loading...
Searching...
No Matches
unit_selector.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-2014 Jean-Pierre Charras
5 * Copyright (C) 2004-2022 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
26#include "unit_selector.h"
27#include "units_scales.h"
28
29UNIT_SELECTOR_LEN::UNIT_SELECTOR_LEN( wxWindow *parent, wxWindowID id,
30 const wxPoint& pos, const wxSize& size,
31 const wxArrayString& choices, long style ) :
32 UNIT_SELECTOR( parent, id, pos, size, choices, style )
33{
34 Append( _( "mm" ) );
35 Append( _( "um" ) );
36 Append( _( "cm" ) );
37 Append( _( "mil" ) );
38 Append( _( "inch" ) );
39}
40
41
42/*
43 * Function GetUnitScale
44 * return the scaling factor to convert users units
45 * to normalized units (meter)
46 */
48{
49 switch( GetCurrentSelection() )
50 {
51 case 0: return UNIT_MM; break;
52 case 1: return UNIT_MICRON; break;
53 case 2: return UNIT_CM; break;
54 case 3: return UNIT_MIL; break;
55 case 4: return UNIT_INCH; break;
56 }
57 return 1.0;
58}
59
60
61UNIT_SELECTOR_THICKNESS::UNIT_SELECTOR_THICKNESS( wxWindow *parent, wxWindowID id,
62 const wxPoint& pos, const wxSize& size,
63 const wxArrayString& choices, long style )
64 : UNIT_SELECTOR( parent, id, pos, size, choices, style )
65{
66 Append( wxT( "mm" ) );
67 Append( wxT( "µm" ) );
68 Append( wxT( "cm" ) );
69 Append( wxT( "mil" ) );
70 Append( wxT( "inch" ) );
71 Append( wxT( "oz/ft²" ) );
72}
73
74
75/*
76 * Function GetUnitScale
77 * return the scaling factor to convert users units
78 * to normalized units (meter) including copper oz/ft^2
79 */
81{
82 switch( GetCurrentSelection() )
83 {
84 case 0: return UNIT_MM; break;
85 case 1: return UNIT_MICRON; break;
86 case 2: return UNIT_CM; break;
87 case 3: return UNIT_MIL; break;
88 case 4: return UNIT_INCH; break;
89 case 5: return UNIT_OZSQFT; break;
90 }
91 return 1.0;
92}
93
94
95UNIT_SELECTOR_FREQUENCY::UNIT_SELECTOR_FREQUENCY( wxWindow *parent, wxWindowID id,
96 const wxPoint& pos, const wxSize& size,
97 const wxArrayString& choices, long style ):
98 UNIT_SELECTOR( parent, id, pos, size, choices, style )
99{
100 Append( _( "GHz" ) );
101 Append( _( "MHz" ) );
102 Append( _( "kHz" ) );
103 Append( _( "Hz" ) );
104}
105
106/*
107 * Function GetUnitScale
108 * return the scaling factor to convert users units
109 * to normalized units (herz )
110 */
112{
113 switch( GetCurrentSelection() )
114 {
115 case 0: return UNIT_GHZ;
116 case 1: return UNIT_MHZ;
117 case 2: return UNIT_KHZ;
118 case 3: return 1.0;
119 }
120 return 1.0;
121}
122
123
124UNIT_SELECTOR_ANGLE::UNIT_SELECTOR_ANGLE( wxWindow *parent, wxWindowID id,
125 const wxPoint& pos, const wxSize& size,
126 const wxArrayString& choices, long style ) :
127 UNIT_SELECTOR( parent, id, pos, size, choices, style )
128{
129 Append( _( "rad" ) );
130 Append( _( "deg" ) );
131}
132
133/*
134 * Function GetUnitScale
135 * return the scaling factor to convert users units
136 * to normalized units ( radian )
137 */
139{
140 switch( GetCurrentSelection() )
141 {
142 case 0: return UNIT_RADIAN; break;
143 case 1: return UNIT_DEGREE; break;
144 }
145 return 1.0;
146}
147
148
149UNIT_SELECTOR_RESISTOR::UNIT_SELECTOR_RESISTOR( wxWindow *parent, wxWindowID id,
150 const wxPoint& pos, const wxSize& size,
151 const wxArrayString& choices, long style )
152 : UNIT_SELECTOR( parent, id, pos, size, choices, style )
153{
154 Append( wxT( "Ω" ) );
155 Append( wxT( "kΩ" ) );
156}
157
158
159/*
160 * Function GetUnitScale
161 * return the scaling factor to convert users units
162 * to normalized units ( ohm )
163 */
165{
166 switch( GetCurrentSelection() )
167 {
168 case 0: return UNIT_OHM; break;
169 case 1: return UNIT_KOHM; break;
170 }
171 return 1.0;
172}
173
174
176 const wxPoint& pos, const wxSize& size,
177 const wxArrayString& choices, long style )
178 : UNIT_SELECTOR( parent, id, pos, size, choices, style )
179{
180 Append( wxT( "Ω/m" ) );
181 Append( wxT( "Ω/km" ) );
182 Append( wxT( "Ω/ft" ) );
183 Append( wxT( "Ω/1000ft" ) );
184}
185
186
187/*
188 * Function GetUnitScale
189 * return the scaling factor to convert users units
190 * to normalized units ( ohm )
191 */
193{
194 switch( GetCurrentSelection() )
195 {
196 case 0: return UNIT_OHM_PER_METER; break;
197 case 1: return UNIT_OHM_PER_KILOMETER; break;
198 case 2: return UNIT_OHM_PER_FEET; break;
199 case 3: return UNIT_OHM_PER_1000FEET; break;
200 }
201 return 1.0;
202}
203
204
206 const wxPoint& pos, const wxSize& size,
207 const wxArrayString& choices, long style ) :
208 UNIT_SELECTOR( parent, id, pos, size, choices, style )
209{
210 Append( _( "cm" ) );
211 Append( _( "m" ) );
212 Append( _( "km" ) );
213 Append( _( "inch" ) );
214 Append( _( "feet" ) );
215}
216
217/*
218 * Function GetUnitScale
219 * return the scaling factor to convert users units
220 * to normalized units ( m )
221 */
223{
224 switch( GetCurrentSelection() )
225 {
226 case 0: return UNIT_CM; break;
227 case 1: return UNIT_M; break;
228 case 2: return UNIT_KM; break;
229 case 3: return UNIT_INCH; break;
230 case 4: return UNIT_FEET; break;
231 }
232 return 1.0;
233}
234
235/*
236 * Function GetUnitScale
237 * return the scaling factor to convert users units
238 * to normalized units ( V )
239 */
241{
242 switch( GetCurrentSelection() )
243 {
244 case 0: return UNIT_MILLIVOLT; break;
245 case 1: return UNIT_VOLT; break;
246 }
247 return 1.0;
248}
249
250UNIT_SELECTOR_VOLTAGE::UNIT_SELECTOR_VOLTAGE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
251 const wxSize& size, const wxArrayString& choices,
252 long style ) :
253 UNIT_SELECTOR( parent, id, pos, size, choices, style )
254{
255 Append( _( "mV" ) );
256 Append( _( "V" ) );
257}
258
259/*
260 * Function GetUnitScale
261 * return the scaling factor to convert users units
262 * to normalized units ( W )
263 */
265{
266 switch( GetCurrentSelection() )
267 {
268 case 0: return UNIT_MILLIWATT; break;
269 case 1: return UNIT_WATT; break;
270 }
271 return 1.0;
272}
273
274UNIT_SELECTOR_POWER::UNIT_SELECTOR_POWER( wxWindow* parent, wxWindowID id, const wxPoint& pos,
275 const wxSize& size, const wxArrayString& choices,
276 long style ) :
277 UNIT_SELECTOR( parent, id, pos, size, choices, style )
278{
279 Append( _( "mW" ) );
280 Append( _( "W" ) );
281}
282
283UNIT_SELECTOR_SPEED::UNIT_SELECTOR_SPEED( wxWindow* parent, wxWindowID id, const wxPoint& pos,
284 const wxSize& size, const wxArrayString& choices,
285 long style ) :
286 UNIT_SELECTOR( parent, id, pos, size, choices, style )
287{
288 Append( _( "m/s" ) );
289 Append( _( "ft/s" ) );
290 Append( _( "km/h" ) );
291 Append( _( "mi/h" ) );
292}
293
294/*
295 * Function GetUnitScale
296 * return the scaling factor to convert users units
297 * to normalized units (meter per second)
298 */
300{
301 switch( GetCurrentSelection() )
302 {
303 case 0: return UNIT_METER_PER_SECOND; break;
304 case 1: return UNIT_FEET_PER_SECOND; break;
305 case 2: return UNIT_KILOMETER_PER_HOUR; break;
306 case 3: return UNIT_MILES_PER_HOUR; break;
307 }
308 return 1.0;
309}
310
311UNIT_SELECTOR_TIME::UNIT_SELECTOR_TIME( wxWindow* parent, wxWindowID id, const wxPoint& pos,
312 const wxSize& size, const wxArrayString& choices,
313 long style ) :
314 UNIT_SELECTOR( parent, id, pos, size, choices, style )
315{
316 Append( _( "ns" ) );
317 Append( _( "ps" ) );
318}
319
320/*
321 * Function GetUnitScale
322 * return the scaling factor to convert users units
323 * to normalized units (second)
324 */
326{
327 switch( GetCurrentSelection() )
328 {
329 case 0: return UNIT_NSECOND; break;
330 case 1: return UNIT_PSECOND; break;
331 }
332 return 1.0;
333}
UNIT_SELECTOR_ANGLE(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_FREQUENCY(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
double GetUnitScale() override
Function GetUnitScale.
double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_LEN_CABLE(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
UNIT_SELECTOR_LEN(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_LINEAR_RESISTANCE(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
double GetUnitScale() override
Function GetUnitScale.
double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_POWER(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
UNIT_SELECTOR_RESISTOR(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
double GetUnitScale() override
Function GetUnitScale.
double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_SPEED(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
UNIT_SELECTOR_THICKNESS(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_TIME(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
double GetUnitScale() override
Function GetUnitScale.
double GetUnitScale() override
Function GetUnitScale.
UNIT_SELECTOR_VOLTAGE(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0)
#define _(s)
std::deque< BOARD_ITEM * > GetCurrentSelection()
Get the list of selected objects.
#define UNIT_DEGREE
Definition: units_scales.h:45
#define UNIT_RADIAN
Definition: units_scales.h:46
#define UNIT_OZSQFT
Definition: units_scales.h:39
#define UNIT_MILES_PER_HOUR
Definition: units_scales.h:68
#define UNIT_NSECOND
Definition: units_scales.h:73
#define UNIT_METER_PER_SECOND
Definition: units_scales.h:65
#define UNIT_OHM_PER_METER
Definition: units_scales.h:51
#define UNIT_PSECOND
Definition: units_scales.h:74
#define UNIT_M
Definition: units_scales.h:32
#define UNIT_KOHM
Definition: units_scales.h:49
#define UNIT_GHZ
Definition: units_scales.h:41
#define UNIT_MICRON
Definition: units_scales.h:35
#define UNIT_KILOMETER_PER_HOUR
Definition: units_scales.h:66
#define UNIT_FEET_PER_SECOND
Definition: units_scales.h:67
#define UNIT_WATT
Definition: units_scales.h:62
#define UNIT_MHZ
Definition: units_scales.h:42
#define UNIT_OHM
Definition: units_scales.h:48
#define UNIT_MM
Definition: units_scales.h:34
#define UNIT_OHM_PER_FEET
Definition: units_scales.h:53
#define UNIT_MILLIVOLT
Definition: units_scales.h:58
#define UNIT_KHZ
Definition: units_scales.h:43
#define UNIT_MIL
Definition: units_scales.h:37
#define UNIT_VOLT
Definition: units_scales.h:57
#define UNIT_INCH
Definition: units_scales.h:36
#define UNIT_OHM_PER_1000FEET
Definition: units_scales.h:54
#define UNIT_FEET
Definition: units_scales.h:38
#define UNIT_MILLIWATT
Definition: units_scales.h:63
#define UNIT_OHM_PER_KILOMETER
Definition: units_scales.h:52
#define UNIT_CM
Definition: units_scales.h:33
#define UNIT_KM
Definition: units_scales.h:31