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.

685 lines
19 KiB

3 years ago
3 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #include <eda_units.h>
  24. #include <fmt/core.h>
  25. #include <math/util.h> // for KiROUND
  26. #include <macros.h>
  27. #include <charconv>
  28. #include <wx/translation.h>
  29. static void removeTrailingZeros( wxString& aText )
  30. {
  31. int len = aText.length();
  32. int removeLast = 0;
  33. while( --len > 0 && aText[len] == '0' )
  34. removeLast++;
  35. if( len >= 0 && ( aText[len] == '.' || aText[len] == ',' ) )
  36. removeLast++;
  37. aText = aText.RemoveLast( removeLast );
  38. }
  39. bool EDA_UNIT_UTILS::IsImperialUnit( EDA_UNITS aUnit )
  40. {
  41. switch( aUnit )
  42. {
  43. case EDA_UNITS::INCHES:
  44. case EDA_UNITS::MILS:
  45. return true;
  46. default:
  47. return false;
  48. }
  49. }
  50. bool EDA_UNIT_UTILS::IsMetricUnit( EDA_UNITS aUnit )
  51. {
  52. switch( aUnit )
  53. {
  54. case EDA_UNITS::MICROMETRES:
  55. case EDA_UNITS::MILLIMETRES:
  56. case EDA_UNITS::CENTIMETRES:
  57. return true;
  58. default:
  59. return false;
  60. }
  61. }
  62. int EDA_UNIT_UTILS::Mm2mils( double aVal )
  63. {
  64. return KiROUND( aVal * 1000. / 25.4 );
  65. }
  66. int EDA_UNIT_UTILS::Mils2mm( double aVal )
  67. {
  68. return KiROUND( aVal * 25.4 / 1000. );
  69. }
  70. bool EDA_UNIT_UTILS::FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS& aUnits )
  71. {
  72. wxString buf( aTextValue.Strip( wxString::both ) );
  73. unsigned brk_point = 0;
  74. while( brk_point < buf.Len() )
  75. {
  76. wxChar c = buf[brk_point];
  77. if( !( ( c >= '0' && c <= '9' ) || ( c == '.' ) || ( c == ',' ) || ( c == '-' )
  78. || ( c == '+' ) ) )
  79. break;
  80. ++brk_point;
  81. }
  82. // Check the unit designator (2 ch significant)
  83. wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
  84. //check for um, μm (µ is MICRO SIGN) and µm (µ is GREEK SMALL LETTER MU) for micrometre
  85. if( unit == wxT( "um" ) || unit == wxT( "\u00B5m" ) || unit == wxT( "\u03BCm" ) )
  86. aUnits = EDA_UNITS::MICROMETRES;
  87. else if( unit == wxT( "mm" ) )
  88. aUnits = EDA_UNITS::MILLIMETRES;
  89. if( unit == wxT( "cm" ) )
  90. aUnits = EDA_UNITS::CENTIMETRES;
  91. else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // "mils" or "thou"
  92. aUnits = EDA_UNITS::MILS;
  93. else if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
  94. aUnits = EDA_UNITS::INCHES;
  95. else if( unit == wxT( "de" ) || unit == wxT( "ra" ) ) // "deg" or "rad"
  96. aUnits = EDA_UNITS::DEGREES;
  97. else
  98. return false;
  99. return true;
  100. }
  101. wxString EDA_UNIT_UTILS::GetText( EDA_UNITS aUnits, EDA_DATA_TYPE aType )
  102. {
  103. wxString label;
  104. switch( aUnits )
  105. {
  106. case EDA_UNITS::MICROMETRES: label = wxT( " \u00B5m" ); break; //00B5 for µ
  107. case EDA_UNITS::MILLIMETRES: label = wxT( " mm" ); break;
  108. case EDA_UNITS::CENTIMETRES: label = wxT( " cm" ); break;
  109. case EDA_UNITS::DEGREES: label = wxT( "°" ); break;
  110. case EDA_UNITS::MILS: label = wxT( " mils" ); break;
  111. case EDA_UNITS::INCHES: label = wxT( " in" ); break;
  112. case EDA_UNITS::PERCENT: label = wxT( "%" ); break;
  113. case EDA_UNITS::UNSCALED: break;
  114. default: UNIMPLEMENTED_FOR( wxS( "Unknown units" ) ); break;
  115. }
  116. switch( aType )
  117. {
  118. case EDA_DATA_TYPE::VOLUME: label += wxT( "³" ); break;
  119. case EDA_DATA_TYPE::AREA: label += wxT( "²" ); break;
  120. case EDA_DATA_TYPE::DISTANCE: break;
  121. default: UNIMPLEMENTED_FOR( wxS( "Unknown measurement" ) ); break;
  122. }
  123. return label;
  124. }
  125. wxString EDA_UNIT_UTILS::GetLabel( EDA_UNITS aUnits, EDA_DATA_TYPE aType )
  126. {
  127. return GetText( aUnits, aType ).Trim( false );
  128. }
  129. std::string EDA_UNIT_UTILS::FormatAngle( const EDA_ANGLE& aAngle )
  130. {
  131. std::string temp = fmt::format( "{:.10g}", aAngle.AsDegrees() );
  132. return temp;
  133. }
  134. std::string EDA_UNIT_UTILS::FormatInternalUnits( const EDA_IU_SCALE& aIuScale, int aValue )
  135. {
  136. std::string buf;
  137. double engUnits = aValue;
  138. engUnits /= aIuScale.IU_PER_MM;
  139. if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
  140. {
  141. buf = fmt::format( "{:.10f}", engUnits );
  142. // remove trailing zeros
  143. while( !buf.empty() && buf[buf.size() - 1] == '0' )
  144. {
  145. buf.pop_back();
  146. }
  147. // if the value was really small
  148. // we may have just stripped all the zeros after the decimal
  149. if( buf[buf.size() - 1] == '.' )
  150. {
  151. buf.pop_back();
  152. }
  153. }
  154. else
  155. {
  156. buf = fmt::format( "{:.10g}", engUnits );
  157. }
  158. return buf;
  159. }
  160. std::string EDA_UNIT_UTILS::FormatInternalUnits( const EDA_IU_SCALE& aIuScale,
  161. const VECTOR2I& aPoint )
  162. {
  163. return FormatInternalUnits( aIuScale, aPoint.x ) + " "
  164. + FormatInternalUnits( aIuScale, aPoint.y );
  165. }
  166. #if 0 // No support for std::from_chars on MacOS yet
  167. bool EDA_UNIT_UTILS::ParseInternalUnits( const std::string& aInput, const EDA_IU_SCALE& aIuScale,
  168. int& aOut )
  169. {
  170. double value;
  171. if( std::from_chars( aInput.data(), aInput.data() + aInput.size(), value ).ec != std::errc() )
  172. return false;
  173. aOut = value * aIuScale.IU_PER_MM;
  174. return true;
  175. }
  176. bool EDA_UNIT_UTILS::ParseInternalUnits( const std::string& aInput, const EDA_IU_SCALE& aIuScale,
  177. VECTOR2I& aOut )
  178. {
  179. size_t pos = aInput.find( ' ' );
  180. if( pos == std::string::npos )
  181. return false;
  182. std::string first = aInput.substr( 0, pos );
  183. std::string second = aInput.substr( pos + 1 );
  184. VECTOR2I vec;
  185. if( !ParseInternalUnits( first, aIuScale, vec.x ) )
  186. return false;
  187. if( !ParseInternalUnits( second, aIuScale, vec.y ) )
  188. return false;
  189. aOut = vec;
  190. return true;
  191. }
  192. #endif
  193. #define IU_TO_MM( x, scale ) ( x / scale.IU_PER_MM )
  194. #define IU_TO_IN( x, scale ) ( x / scale.IU_PER_MILS / 1000 )
  195. #define IU_TO_MILS( x, scale ) ( x / scale.IU_PER_MILS )
  196. #define MM_TO_IU( x, scale ) ( x * scale.IU_PER_MM )
  197. #define IN_TO_IU( x, scale ) ( x * scale.IU_PER_MILS * 1000 )
  198. #define MILS_TO_IU( x, scale ) ( x * scale.IU_PER_MILS )
  199. double EDA_UNIT_UTILS::UI::ToUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnit,
  200. double aValue )
  201. {
  202. switch( aUnit )
  203. {
  204. case EDA_UNITS::MICROMETRES:
  205. return IU_TO_MM( aValue, aIuScale ) * 1000;
  206. case EDA_UNITS::MILLIMETRES:
  207. return IU_TO_MM( aValue, aIuScale );
  208. case EDA_UNITS::CENTIMETRES:
  209. return IU_TO_MM( aValue, aIuScale ) / 10;
  210. case EDA_UNITS::MILS:
  211. return IU_TO_MILS( aValue, aIuScale );
  212. case EDA_UNITS::INCHES:
  213. return IU_TO_IN( aValue, aIuScale );
  214. case EDA_UNITS::DEGREES:
  215. return aValue;
  216. default:
  217. return aValue;
  218. }
  219. }
  220. /**
  221. * Convert a value to a string using double notation.
  222. *
  223. * For readability, the mantissa has 3 or more digits,
  224. * the trailing 0 are removed if the mantissa has more than 3 digits
  225. * and some trailing 0
  226. * This function should be used to display values in dialogs because a value
  227. * entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa
  228. * if displayed in inch to avoid truncation or rounding made just by the printf function.
  229. * otherwise the actual value is rounded when read from dialog and converted
  230. * in internal units, and therefore modified.
  231. */
  232. wxString EDA_UNIT_UTILS::UI::StringFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  233. double aValue, bool aAddUnitsText,
  234. EDA_DATA_TYPE aType )
  235. {
  236. double value_to_print = aValue;
  237. bool is_eeschema = ( aIuScale.IU_PER_MM == SCH_IU_PER_MM );
  238. switch( aType )
  239. {
  240. case EDA_DATA_TYPE::VOLUME:
  241. value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print );
  242. KI_FALLTHROUGH;
  243. case EDA_DATA_TYPE::AREA:
  244. value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print );
  245. KI_FALLTHROUGH;
  246. case EDA_DATA_TYPE::DISTANCE:
  247. value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print );
  248. break;
  249. case EDA_DATA_TYPE::UNITLESS:
  250. break;
  251. }
  252. const wxChar* format = nullptr;
  253. switch( aUnits )
  254. {
  255. case EDA_UNITS::MILS:
  256. format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.5f" );
  257. break;
  258. case EDA_UNITS::INCHES:
  259. format = is_eeschema ? wxT( "%.6f" ) : wxT( "%.8f" );
  260. break;
  261. case EDA_UNITS::DEGREES:
  262. format = wxT( "%.4f" );
  263. break;
  264. default:
  265. format = wxT( "%.10f" );
  266. break;
  267. }
  268. wxString text;
  269. text.Printf( format, value_to_print );
  270. removeTrailingZeros( text );
  271. if( value_to_print != 0.0 && ( text == wxS( "0" ) || text == wxS( "-0" ) ) )
  272. {
  273. text.Printf( wxS( "%.10f" ), value_to_print );
  274. removeTrailingZeros( text );
  275. }
  276. if( aAddUnitsText )
  277. text << EDA_UNIT_UTILS::GetText( aUnits, aType );
  278. return text;
  279. }
  280. /**
  281. * Convert a value to a string using double notation.
  282. *
  283. * For readability, the mantissa has 0, 1, 3 or 4 digits, depending on units
  284. * for unit = inch the mantissa has 3 digits (Eeschema) or 4 digits
  285. * for unit = mil the mantissa has 0 digits (Eeschema) or 1 digits
  286. * for unit = mm the mantissa has 3 digits (Eeschema) or 4 digits
  287. * Should be used only to display info in status,
  288. * but not in dialogs, because 4 digits only
  289. * could truncate the actual value
  290. */
  291. // A lower-precision (for readability) version of StringFromValue()
  292. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  293. int aValue,
  294. bool aAddUnitLabel,
  295. EDA_DATA_TYPE aType )
  296. {
  297. return MessageTextFromValue( aIuScale, aUnits, double( aValue ), aAddUnitLabel, aType );
  298. }
  299. // A lower-precision (for readability) version of StringFromValue()
  300. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  301. long long int aValue,
  302. bool aAddUnitLabel,
  303. EDA_DATA_TYPE aType )
  304. {
  305. return MessageTextFromValue( aIuScale, aUnits, double( aValue ), aAddUnitLabel, aType );
  306. }
  307. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel )
  308. {
  309. if( aAddUnitLabel )
  310. return wxString::Format( wxT( "%.1f°" ), aValue.AsDegrees() );
  311. else
  312. return wxString::Format( wxT( "%.1f" ), aValue.AsDegrees() );
  313. }
  314. // A lower-precision (for readability) version of StringFromValue()
  315. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  316. double aValue, bool aAddUnitsText,
  317. EDA_DATA_TYPE aType )
  318. {
  319. wxString text;
  320. const wxChar* format;
  321. double value = aValue;
  322. bool is_eeschema = ( aIuScale.IU_PER_MM == SCH_IU_PER_MM );
  323. switch( aType )
  324. {
  325. case EDA_DATA_TYPE::VOLUME:
  326. value = ToUserUnit( aIuScale, aUnits, value );
  327. // Fall through to continue computation
  328. KI_FALLTHROUGH;
  329. case EDA_DATA_TYPE::AREA:
  330. value = ToUserUnit( aIuScale, aUnits, value );
  331. // Fall through to continue computation
  332. KI_FALLTHROUGH;
  333. case EDA_DATA_TYPE::DISTANCE:
  334. value = ToUserUnit( aIuScale, aUnits, value );
  335. break;
  336. case EDA_DATA_TYPE::UNITLESS:
  337. break;
  338. }
  339. switch( aUnits )
  340. {
  341. default:
  342. case EDA_UNITS::MICROMETRES:
  343. format = is_eeschema ? wxT( "%.0f" ) : wxT( "%.1f" );
  344. break;
  345. case EDA_UNITS::MILLIMETRES:
  346. format = is_eeschema ? wxT( "%.2f" ) : wxT( "%.4f" );
  347. break;
  348. case EDA_UNITS::CENTIMETRES:
  349. format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.5f" );
  350. break;
  351. case EDA_UNITS::MILS:
  352. format = is_eeschema ? wxT( "%.0f" ) : wxT( "%.2f" );
  353. break;
  354. case EDA_UNITS::INCHES:
  355. format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.4f" );
  356. break;
  357. case EDA_UNITS::DEGREES:
  358. // 3 digits in mantissa should be good for rotation in degree
  359. format = wxT( "%.3f" );
  360. break;
  361. case EDA_UNITS::UNSCALED:
  362. format = wxT( "%.0f" );
  363. break;
  364. }
  365. text.Printf( format, value );
  366. if( aAddUnitsText )
  367. text += EDA_UNIT_UTILS::GetText( aUnits, aType );
  368. return text;
  369. }
  370. wxString EDA_UNIT_UTILS::UI::MessageTextFromMinOptMax( const EDA_IU_SCALE& aIuScale,
  371. EDA_UNITS aUnits,
  372. const MINOPTMAX<int>& aValue )
  373. {
  374. wxString msg;
  375. if( aValue.HasMin() && aValue.Min() > 0 )
  376. {
  377. msg += _( "min" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Min() );
  378. }
  379. if( aValue.HasOpt() )
  380. {
  381. if( !msg.IsEmpty() )
  382. msg += wxS( "; " );
  383. msg += _( "opt" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Opt() );
  384. }
  385. if( aValue.HasMax() )
  386. {
  387. if( !msg.IsEmpty() )
  388. msg += wxS( "; " );
  389. msg += _( "max" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Max() );
  390. }
  391. return msg;
  392. };
  393. double EDA_UNIT_UTILS::UI::FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  394. double aValue )
  395. {
  396. switch( aUnits )
  397. {
  398. case EDA_UNITS::MICROMETRES:
  399. return MM_TO_IU( aValue / 1000.0, aIuScale );
  400. case EDA_UNITS::MILLIMETRES:
  401. return MM_TO_IU( aValue, aIuScale );
  402. case EDA_UNITS::CENTIMETRES:
  403. return MM_TO_IU( aValue * 10, aIuScale );
  404. case EDA_UNITS::MILS:
  405. return MILS_TO_IU( aValue, aIuScale );
  406. case EDA_UNITS::INCHES:
  407. return IN_TO_IU( aValue, aIuScale );
  408. default:
  409. case EDA_UNITS::DEGREES:
  410. case EDA_UNITS::UNSCALED:
  411. case EDA_UNITS::PERCENT:
  412. return aValue;
  413. }
  414. }
  415. double EDA_UNIT_UTILS::UI::DoubleValueFromString( const wxString& aTextValue )
  416. {
  417. double dtmp = 0;
  418. // Acquire the 'right' decimal point separator
  419. const struct lconv* lc = localeconv();
  420. wxChar decimal_point = lc->decimal_point[0];
  421. wxString buf( aTextValue.Strip( wxString::both ) );
  422. // Convert any entered decimal point separators to the 'right' one
  423. buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
  424. buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
  425. // Find the end of the numeric part
  426. unsigned brk_point = 0;
  427. while( brk_point < buf.Len() )
  428. {
  429. wxChar ch = buf[brk_point];
  430. if( !( ( ch >= '0' && ch <= '9' ) || ( ch == decimal_point ) || ( ch == '-' )
  431. || ( ch == '+' ) ) )
  432. {
  433. break;
  434. }
  435. ++brk_point;
  436. }
  437. // Extract the numeric part
  438. buf.Left( brk_point ).ToDouble( &dtmp );
  439. return dtmp;
  440. }
  441. double EDA_UNIT_UTILS::UI::DoubleValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  442. const wxString& aTextValue, EDA_DATA_TYPE aType )
  443. {
  444. double dtmp = 0;
  445. // Acquire the 'right' decimal point separator
  446. const struct lconv* lc = localeconv();
  447. wxChar decimal_point = lc->decimal_point[0];
  448. wxString buf( aTextValue.Strip( wxString::both ) );
  449. // Convert any entered decimal point separators to the 'right' one
  450. buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
  451. buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
  452. // Find the end of the numeric part
  453. unsigned brk_point = 0;
  454. while( brk_point < buf.Len() )
  455. {
  456. wxChar ch = buf[brk_point];
  457. if( !( (ch >= '0' && ch <= '9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
  458. break;
  459. ++brk_point;
  460. }
  461. // Extract the numeric part
  462. buf.Left( brk_point ).ToDouble( &dtmp );
  463. // Check the optional unit designator (2 ch significant)
  464. wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
  465. if( aUnits == EDA_UNITS::MICROMETRES
  466. || aUnits == EDA_UNITS::MILLIMETRES
  467. || aUnits == EDA_UNITS::CENTIMETRES
  468. || aUnits == EDA_UNITS::MILS
  469. || aUnits == EDA_UNITS::INCHES )
  470. {
  471. //check for um, μm (µ is MICRO SIGN) and µm (µ is GREEK SMALL LETTER MU) for micrometre
  472. if( unit == wxT( "um" ) || unit == wxT( "\u00B5m" ) || unit == wxT( "\u03BCm" ) )
  473. {
  474. aUnits = EDA_UNITS::MICROMETRES;
  475. }
  476. else if( unit == wxT( "mm" ) )
  477. {
  478. aUnits = EDA_UNITS::MILLIMETRES;
  479. }
  480. else if( unit == wxT( "cm" ) )
  481. {
  482. aUnits = EDA_UNITS::CENTIMETRES;
  483. }
  484. else if( unit == wxT( "mi" ) || unit == wxT( "th" ) )
  485. {
  486. aUnits = EDA_UNITS::MILS;
  487. }
  488. else if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
  489. {
  490. aUnits = EDA_UNITS::INCHES;
  491. }
  492. else if( unit == wxT( "oz" ) ) // 1 oz = 1.37 mils
  493. {
  494. aUnits = EDA_UNITS::MILS;
  495. dtmp *= 1.37;
  496. }
  497. }
  498. else if( aUnits == EDA_UNITS::DEGREES )
  499. {
  500. if( unit == wxT( "ra" ) ) // Radians
  501. dtmp *= 180.0f / M_PI;
  502. }
  503. switch( aType )
  504. {
  505. case EDA_DATA_TYPE::VOLUME:
  506. dtmp = FromUserUnit( aIuScale, aUnits, dtmp );
  507. KI_FALLTHROUGH;
  508. case EDA_DATA_TYPE::AREA:
  509. dtmp = FromUserUnit( aIuScale, aUnits, dtmp );
  510. KI_FALLTHROUGH;
  511. case EDA_DATA_TYPE::DISTANCE:
  512. dtmp = FromUserUnit( aIuScale, aUnits, dtmp );
  513. break;
  514. case EDA_DATA_TYPE::UNITLESS:
  515. break;
  516. }
  517. return dtmp;
  518. }
  519. long long int EDA_UNIT_UTILS::UI::ValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  520. const wxString& aTextValue, EDA_DATA_TYPE aType )
  521. {
  522. double value = DoubleValueFromString( aIuScale, aUnits, aTextValue, aType );
  523. return KiROUND<double, long long int>( value );
  524. }
  525. long long int EDA_UNIT_UTILS::UI::ValueFromString( const wxString& aTextValue )
  526. {
  527. double value = DoubleValueFromString( aTextValue );
  528. return KiROUND<double, long long int>( value );
  529. }