You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

472 lines
22 KiB

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