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-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 
21 /**
22  * @file transline_ident.cpp
23  */
24 #include <wx/intl.h>
25 #include <wx/arrstr.h>
26 
27 #include <kiface_base.h>
28 #include <bitmaps.h>
29 
30 // transline specific functions:
31 #include "transline/transline.h"
32 #include "transline/microstrip.h"
33 #include "transline/coplanar.h"
34 #include "transline/rectwaveguide.h"
35 #include "transline/coax.h"
36 #include "transline/c_microstrip.h"
37 #include "transline/stripline.h"
38 #include "transline/twistedpair.h"
39 
40 #include "pcb_calculator_settings.h"
41 #include "widgets/unit_selector.h"
42 #include "transline_ident.h"
43 
44 
TRANSLINE_PRM(PRM_TYPE aType,PRMS_ID aId,const char * aKeywordCfg,const wxString & aDlgLabel,const wxString & aToolTip,double aValue,bool aConvUnit)45 TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg,
46                               const wxString& aDlgLabel, const wxString& aToolTip,
47                               double aValue, bool aConvUnit )
48 {
49     m_Type          = aType;
50     m_Id            = aId;
51     m_DlgLabel      = aDlgLabel;
52     m_KeyWord       = aKeywordCfg;
53     m_ToolTip       = aToolTip;
54     m_Value         = aValue;
55     m_ConvUnit      = aConvUnit;
56     m_ValueCtrl     = nullptr;
57     m_UnitCtrl      = nullptr;
58     m_UnitSelection = 0;
59     m_NormalizedValue = 0;
60  }
61 
62 
ToUserUnit()63 double TRANSLINE_PRM::ToUserUnit()
64 {
65     if( m_UnitCtrl && m_ConvUnit )
66         return 1.0 / ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
67     else
68         return 1.0;
69 }
70 
71 
FromUserUnit()72 double TRANSLINE_PRM::FromUserUnit()
73 {
74     if( m_UnitCtrl )
75         return ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
76     else
77         return 1.0;
78 }
79 
80 
TRANSLINE_IDENT(enum TRANSLINE_TYPE_ID aType)81 TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
82 {
83     m_Type = aType;                         // The type of transline handled
84     m_BitmapName = BITMAPS::INVALID_BITMAP; // The icon to display
85     m_TLine = nullptr;                      // The TRANSLINE itself
86     m_HasPrmSelection = false;              // true if selection of parameters must be enabled in dialog menu
87 
88     // Add common prms:
89     // Default values are for FR4
90     AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, EPSILONR_PRM,
91                                "Er", wxT( "εr" ),
92                                _( "Substrate relative permittivity (dielectric constant)" ),
93                                4.6, false ) );
94     AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TAND_PRM,
95                                "TanD", wxT( "tan δ" ),
96                                _( "Dielectric loss (dissipation factor)" ),
97                                2e-2, false ) );
98 
99     // Default value is for copper
100     AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, RHO_PRM,
101                                "Rho", wxT( "ρ" ),
102                                _( "Electrical resistivity or specific electrical resistance of "
103                                   "conductor (ohm*meter)" ),
104                                1.72e-8, false ) );
105 
106     // Default value is in GHz
107     AddPrm( new TRANSLINE_PRM( PRM_TYPE_FREQUENCY, FREQUENCY_PRM,
108                                "Frequency", _( "Frequency" ),
109                                _( "Frequency of the input signal" ), 1.0, true ) );
110 
111 
112     switch( m_Type )
113     {
114     case MICROSTRIP_TYPE:      // microstrip
115         m_TLine      = new MICROSTRIP();
116         m_BitmapName = BITMAPS::microstrip;
117 
118         m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
119         m_Messages.Add( _( "Conductor losses:" ) );
120         m_Messages.Add( _( "Dielectric losses:" ) );
121         m_Messages.Add( _( "Skin depth:" ) );
122 
123         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
124                                    "H", "H", _( "Height of substrate" ), 0.2, true ) );
125         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_T_PRM,
126                                    "H_t", "H(top)", _( "Height of box top" ), 1e20, true ) );
127         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
128                                    "T", "T",
129                                    _( "Strip thickness" ), 0.035, true ) );
130         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, ROUGH_PRM,
131                                    "Rough", _( "Roughness" ),
132                                    _( "Conductor roughness" ), 0.0, true ) );
133         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
134                                    "mu Rel S", wxString::Format( wxT( "μ(%s)" ),
135                                                                  _( "substrate" ) ),
136                                    _( "Relative permeability (mu) of substrate" ), 1, false ) );
137         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
138                                    "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
139                                                                  _( "conductor" ) ),
140                                    _( "Relative permeability (mu) of conductor" ), 1,
141                                    false ) );
142 
143         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
144                                    "W", "W", _( "Line width" ), 0.2, true ) );
145         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
146                                    "L", "L", _( "Line length" ), 50.0, true ) );
147 
148         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
149                                    "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
150         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
151         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
152                                    "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
153         break;
154 
155     case CPW_TYPE:          // coplanar waveguide
156         m_TLine           = new COPLANAR();
157         m_BitmapName      = BITMAPS::cpw;
158         m_HasPrmSelection = true;
159 
160         m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
161         m_Messages.Add( _( "Conductor losses:" ) );
162         m_Messages.Add( _( "Dielectric losses:" ) );
163         m_Messages.Add( _( "Skin depth:" ) );
164 
165         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
166                                    "H", "H", _( "Height of substrate" ), 0.2, true ) );
167         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
168                                    "T", "T", _( "Strip thickness" ), 0.035, true ) );
169         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
170                                    "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
171                                                                  _( "conductor" ) ),
172                                    _( "Relative permeability (mu) of conductor" ), 1,
173                                    false ) );
174 
175         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
176                                    "W", "W", _( "Line width" ), 0.2, true ) );
177         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
178                                    "S", "S", _( "Gap width" ), 0.2, true ) );
179         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
180                                    "L", "L", _( "Line length" ), 50.0, true ) );
181 
182         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
183                                    "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
184         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
185         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
186                                    "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
187         break;
188 
189     case GROUNDED_CPW_TYPE:      // grounded coplanar waveguide
190         m_TLine           = new GROUNDEDCOPLANAR();
191         m_BitmapName      = BITMAPS::cpw_back;
192         m_HasPrmSelection = true;
193 
194         m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
195         m_Messages.Add( _( "Conductor losses:" ) );
196         m_Messages.Add( _( "Dielectric losses:" ) );
197         m_Messages.Add( _( "Skin depth:" ) );
198 
199         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
200                                    "H", "H", _( "Height of substrate" ), 0.2, true ) );
201         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
202                                    "T", "T", _( "Strip thickness" ), 0.035, true ) );
203         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
204                                    "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
205                                                                  _( "conductor" ) ),
206                                    _( "Relative permeability (mu) of conductor" ), 1,
207                                    false ) );
208 
209         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
210                                    "W", "W", _( "Line width" ), 0.2, true ) );
211         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
212                                    "S", "S", _( "Gap width" ), 0.2, true ) );
213         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
214                                    "L", "L", _( "Line length" ), 50.0, true ) );
215 
216         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
217                                    "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
218         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
219         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
220                                    "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
221         break;
222 
223 
224     case RECTWAVEGUIDE_TYPE:      // rectangular waveguide
225         m_TLine           = new RECTWAVEGUIDE();
226         m_BitmapName      = BITMAPS::rectwaveguide;
227         m_HasPrmSelection = true;
228 
229         m_Messages.Add( _( "ZF(H10) = Ey / Hx:" ) );
230         m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
231         m_Messages.Add( _( "Conductor losses:" ) );
232         m_Messages.Add( _( "Dielectric losses:" ) );
233         m_Messages.Add( _( "TE-modes:" ) );
234         m_Messages.Add( _( "TM-modes:" ) );
235 
236         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
237                                    "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
238                                                                  _( "insulator" ) ),
239                                    _( "Relative permeability (mu) of insulator" ), 1, false ) );
240         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
241                                    "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
242                                                                  _( "conductor" ) ),
243                                    _( "Relative permeability (mu) of conductor" ), 1,
244                                    false ) );
245 
246         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
247                                    "a", "a", _( "Width of waveguide" ), 10.0, true ) );
248         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
249                                    "b", "b", _( "Height of waveguide" ), 5.0, true ) );
250         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
251                                    "L", "L", _( "Waveguide length" ), 50.0, true ) );
252 
253         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
254                                    "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
255         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
256         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
257                                    "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
258         break;
259 
260     case COAX_TYPE:      // coaxial cable
261         m_TLine           = new COAX();
262         m_BitmapName      = BITMAPS::coax;
263         m_HasPrmSelection = true;
264 
265         m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
266         m_Messages.Add( _( "Conductor losses:" ) );
267         m_Messages.Add( _( "Dielectric losses:" ) );
268         m_Messages.Add( _( "TE-modes:" ) );
269         m_Messages.Add( _( "TM-modes:" ) );
270 
271         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
272                                    "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
273                                                                  _( "insulator" ) ),
274                                    _( "Relative permeability (mu) of insulator" ), 1, false ) );
275         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
276                                    "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
277                                                                  _( "conductor" ) ),
278                                    _( "Relative permeability (mu) of conductor" ), 1,
279                                    false ) );
280 
281         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_IN_PRM,
282                                    "Din", _( "Din" ),
283                                    _( "Inner diameter (conductor)" ), 1.0, true ) );
284         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_OUT_PRM,
285                                    "Dout", _( "Dout" ),
286                                    _( "Outer diameter (insulator)" ), 8.0, true ) );
287         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
288                                    "L", "L", _( "Line length" ), 50.0, true ) );
289 
290         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
291                                    "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
292         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
293         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
294                                    "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
295         break;
296 
297     case C_MICROSTRIP_TYPE:      // coupled microstrip
298         m_TLine           = new C_MICROSTRIP();
299         m_BitmapName      = BITMAPS::c_microstrip;
300         m_HasPrmSelection = true;
301 
302         m_Messages.Add( wxString::Format( _( "Effective %s (even):" ), wxT( "εr" ) ) );
303         m_Messages.Add( wxString::Format( _( "Effective %s (odd):" ), wxT( "εr" ) ) );
304         m_Messages.Add( _( "Conductor losses (even):" ) );
305         m_Messages.Add( _( "Conductor losses (odd):" ) );
306         m_Messages.Add( _( "Dielectric losses (even):" ) );
307         m_Messages.Add( _( "Dielectric losses (odd):" ) );
308         m_Messages.Add( _( "Skin depth:" ) );
309         m_Messages.Add( _( "Differential Impedance (Zd):" ) );
310 
311         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
312                                    "H", "H", _( "Height of substrate" ), 0.2, true ) );
313         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_T_PRM,
314                                    "H_t", "H_t", _( "Height of box top" ), 1e20, true ) );
315         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
316                                    "T", "T", _( "Strip thickness" ), 0.035, true ) );
317         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, ROUGH_PRM,
318                                    "Rough", _( "Roughness" ),
319                                    _( "Conductor roughness" ), 0.0, true ) );
320         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
321                                    "mu rel C", wxString::Format( wxT( "μ(%s)" ),
322                                                                  _( "conductor" ) ),
323                                    _( "Relative permeability (mu) of conductor" ), 1,
324                                    false ) );
325 
326         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
327                                    "W", "W", _( "Line width" ), 0.2, true ) );
328         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
329                                    "S", "S", _( "Gap width" ), 0.2, true ) );
330         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
331                                    "L", "L", _( "Line length" ), 50.0, true ) );
332 
333         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_E_PRM,
334                                    "Zeven", _( "Zeven" ),
335                                    _( "Even mode impedance (lines driven by common voltages)" ),
336                                    50.0, true ) );
337         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_O_PRM,
338                                    "Zodd", _( "Zodd" ),
339                                    _( "Odd mode impedance (lines driven by opposite "
340                                       "(differential) voltages)" ), 50.0, true ) );
341         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
342                                    "Ang_l", "Ang_l",
343                                    _( "Electrical length" ), 0.0, true ) );
344         break;
345 
346     case STRIPLINE_TYPE:      // stripline
347         m_TLine      = new STRIPLINE();
348         m_BitmapName = BITMAPS::stripline;
349 
350         m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
351         m_Messages.Add( _( "Conductor losses:" ) );
352         m_Messages.Add( _( "Dielectric losses:" ) );
353         m_Messages.Add( _( "Skin depth:" ) );
354 
355         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
356                                    "H", "H", _( "Height of substrate" ), 0.2, true ) );
357         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, STRIPLINE_A_PRM,
358                                    "a", "a", _( "Distance between strip and top metal" ), 0.2,
359                                    true ) );
360         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
361                                    "T", "T", _( "Strip thickness" ), 0.035, true ) );
362         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
363                                    "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
364                                                                  _( "conductor" ) ),
365                                    _( "Relative permeability (mu) of conductor" ), 1, false ) );
366 
367         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
368                                    "W", "W", _( "Line width" ), 0.2, true ) );
369         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
370                                    "L", "L", _( "Line length" ), 50.0, true ) );
371 
372         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
373                                    "Z0", "Z0", _( "Characteristic impedance" ), 50, true ) );
374         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
375         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
376                                    "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
377         break;
378 
379     case TWISTEDPAIR_TYPE:      // twisted pair
380         m_TLine           = new TWISTEDPAIR();
381         m_BitmapName      = BITMAPS::twistedpair;
382         m_HasPrmSelection = true;
383 
384         m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
385         m_Messages.Add( _( "Conductor losses:" ) );
386         m_Messages.Add( _( "Dielectric losses:" ) );
387         m_Messages.Add( _( "Skin depth:" ) );
388 
389         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TWISTEDPAIR_TWIST_PRM,
390                                    "Twists", _( "Twists" ),
391                                    _( "Number of twists per length" ), 0.0, false ) );
392         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
393                                    "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
394                                                                  _( "conductor" ) ),
395                                    _( "Relative permeability (mu) of conductor" ), 1,
396                                    false ) );
397         AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TWISTEDPAIR_EPSILONR_ENV_PRM,
398                                    "ErEnv", wxString::Format( wxT( "εr(%s)" ),
399                                                               _( "environment" ) ),
400                                    _( "Relative permittivity of environment" ), 1,
401                                    false ) );
402         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_IN_PRM,
403                                    "Din", _( "Din" ),
404                                    _( "Inner diameter (conductor)" ), 1.0, true ) );
405         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_OUT_PRM,
406                                    "Dout", _( "Dout" ),
407                                    _( "Outer diameter (insulator)" ), 8.0, true ) );
408         AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
409                                    "L", "L", _( "Cable length" ), 50.0, true ) );
410 
411         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
412                                    "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
413         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
414         AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
415                                    "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
416         break;
417 
418     case END_OF_LIST_TYPE:      // Not really used
419         break;
420     }
421 }
422 
~TRANSLINE_IDENT()423 TRANSLINE_IDENT::~TRANSLINE_IDENT()
424 {
425     delete m_TLine;
426 
427     for( auto& ii : m_prms_List )
428         delete ii;
429 
430     m_prms_List.clear();
431 }
432 
433 
ReadConfig()434 void TRANSLINE_IDENT::ReadConfig()
435 {
436     auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
437     std::string name( m_TLine->m_Name );
438 
439     if( cfg->m_TransLine.param_values.count( name ) )
440     {
441         wxASSERT( cfg->m_TransLine.param_units.count( name ) );
442 
443         for( auto& p : m_prms_List )
444         {
445             try
446             {
447                 p->m_Value = cfg->m_TransLine.param_values.at( name ).at( p->m_KeyWord );
448                 p->m_UnitSelection =  cfg->m_TransLine.param_units.at( name ).at( p->m_KeyWord );
449             }
450             catch( ... )
451             {}
452         }
453     }
454 }
455 
456 
WriteConfig()457 void TRANSLINE_IDENT::WriteConfig()
458 {
459     auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
460     std::string name( m_TLine->m_Name );
461 
462     for( auto& param : m_prms_List )
463     {
464         if( !std::isfinite( param->m_Value ) )
465             param->m_Value = 0;
466 
467         cfg->m_TransLine.param_values[ name ][ param->m_KeyWord ] = param->m_Value;
468         cfg->m_TransLine.param_units[ name ][ param->m_KeyWord ] = param->m_UnitSelection;
469     }
470 }
471 
472