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.

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