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.

707 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. switch( aType )
  238. {
  239. case EDA_DATA_TYPE::VOLUME:
  240. value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print );
  241. KI_FALLTHROUGH;
  242. case EDA_DATA_TYPE::AREA:
  243. value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print );
  244. KI_FALLTHROUGH;
  245. case EDA_DATA_TYPE::DISTANCE:
  246. value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print );
  247. break;
  248. case EDA_DATA_TYPE::UNITLESS:
  249. break;
  250. }
  251. const wxChar* format = nullptr;
  252. switch( aUnits )
  253. {
  254. case EDA_UNITS::MILS:
  255. #if defined( EESCHEMA )
  256. format = wxT( "%.3f" );
  257. #else
  258. format = wxT( "%.5f" );
  259. #endif
  260. break;
  261. case EDA_UNITS::INCHES:
  262. #if defined( EESCHEMA )
  263. format = wxT( "%.6f" );
  264. #else
  265. format = wxT( "%.8f" );
  266. #endif
  267. break;
  268. default:
  269. format = wxT( "%.10f" );
  270. break;
  271. }
  272. wxString text;
  273. text.Printf( format, value_to_print );
  274. removeTrailingZeros( text );
  275. if( value_to_print != 0.0 && ( text == wxS( "0" ) || text == wxS( "-0" ) ) )
  276. {
  277. text.Printf( wxS( "%.10f" ), value_to_print );
  278. removeTrailingZeros( text );
  279. }
  280. if( aAddUnitsText )
  281. text << EDA_UNIT_UTILS::GetText( aUnits, aType );
  282. return text;
  283. }
  284. /**
  285. * Convert a value to a string using double notation.
  286. *
  287. * For readability, the mantissa has 0, 1, 3 or 4 digits, depending on units
  288. * for unit = inch the mantissa has 3 digits (Eeschema) or 4 digits
  289. * for unit = mil the mantissa has 0 digits (Eeschema) or 1 digits
  290. * for unit = mm the mantissa has 3 digits (Eeschema) or 4 digits
  291. * Should be used only to display info in status,
  292. * but not in dialogs, because 4 digits only
  293. * could truncate the actual value
  294. */
  295. // A lower-precision (for readability) version of StringFromValue()
  296. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  297. int aValue,
  298. bool aAddUnitLabel,
  299. EDA_DATA_TYPE aType )
  300. {
  301. return MessageTextFromValue( aIuScale, aUnits, double( aValue ), aAddUnitLabel, aType );
  302. }
  303. // A lower-precision (for readability) version of StringFromValue()
  304. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  305. long long int aValue,
  306. bool aAddUnitLabel,
  307. EDA_DATA_TYPE aType )
  308. {
  309. return MessageTextFromValue( aIuScale, aUnits, double( aValue ), aAddUnitLabel, aType );
  310. }
  311. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel )
  312. {
  313. if( aAddUnitLabel )
  314. return wxString::Format( wxT( "%.1f°" ), aValue.AsDegrees() );
  315. else
  316. return wxString::Format( wxT( "%.1f" ), aValue.AsDegrees() );
  317. }
  318. // A lower-precision (for readability) version of StringFromValue()
  319. wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  320. double aValue, bool aAddUnitsText,
  321. EDA_DATA_TYPE aType )
  322. {
  323. wxString text;
  324. const wxChar* format;
  325. double value = aValue;
  326. switch( aType )
  327. {
  328. case EDA_DATA_TYPE::VOLUME:
  329. value = ToUserUnit( aIuScale, aUnits, value );
  330. // Fall through to continue computation
  331. KI_FALLTHROUGH;
  332. case EDA_DATA_TYPE::AREA:
  333. value = ToUserUnit( aIuScale, aUnits, value );
  334. // Fall through to continue computation
  335. KI_FALLTHROUGH;
  336. case EDA_DATA_TYPE::DISTANCE:
  337. value = ToUserUnit( aIuScale, aUnits, value );
  338. break;
  339. case EDA_DATA_TYPE::UNITLESS:
  340. break;
  341. }
  342. switch( aUnits )
  343. {
  344. default:
  345. case EDA_UNITS::MICROMETRES:
  346. #if defined( EESCHEMA )
  347. format = wxT( "%.0f" );
  348. #else
  349. format = wxT( "%.1f" );
  350. #endif
  351. break;
  352. case EDA_UNITS::MILLIMETRES:
  353. #if defined( EESCHEMA )
  354. format = wxT( "%.2f" );
  355. #else
  356. format = wxT( "%.4f" );
  357. #endif
  358. break;
  359. case EDA_UNITS::CENTIMETRES:
  360. #if defined( EESCHEMA )
  361. format = wxT( "%.3f" );
  362. #else
  363. format = wxT( "%.5f" );
  364. #endif
  365. break;
  366. case EDA_UNITS::MILS:
  367. #if defined( EESCHEMA )
  368. format = wxT( "%.0f" );
  369. #else
  370. format = wxT( "%.2f" );
  371. #endif
  372. break;
  373. case EDA_UNITS::INCHES:
  374. #if defined( EESCHEMA )
  375. format = wxT( "%.3f" );
  376. #else
  377. format = wxT( "%.4f" );
  378. #endif
  379. break;
  380. case EDA_UNITS::DEGREES:
  381. // 3 digits in mantissa should be good for rotation in degree
  382. format = wxT( "%.3f" );
  383. break;
  384. case EDA_UNITS::UNSCALED:
  385. format = wxT( "%.0f" );
  386. break;
  387. }
  388. text.Printf( format, value );
  389. if( aAddUnitsText )
  390. text += EDA_UNIT_UTILS::GetText( aUnits, aType );
  391. return text;
  392. }
  393. wxString EDA_UNIT_UTILS::UI::MessageTextFromMinOptMax( const EDA_IU_SCALE& aIuScale,
  394. EDA_UNITS aUnits,
  395. const MINOPTMAX<int>& aValue )
  396. {
  397. wxString msg;
  398. if( aValue.HasMin() && aValue.Min() > 0 )
  399. {
  400. msg += _( "min" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Min() );
  401. }
  402. if( aValue.HasOpt() )
  403. {
  404. if( !msg.IsEmpty() )
  405. msg += wxS( "; " );
  406. msg += _( "opt" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Opt() );
  407. }
  408. if( aValue.HasMax() )
  409. {
  410. if( !msg.IsEmpty() )
  411. msg += wxS( "; " );
  412. msg += _( "max" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Max() );
  413. }
  414. return msg;
  415. };
  416. double EDA_UNIT_UTILS::UI::FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  417. double aValue )
  418. {
  419. switch( aUnits )
  420. {
  421. case EDA_UNITS::MICROMETRES:
  422. return MM_TO_IU( aValue / 1000.0, aIuScale );
  423. case EDA_UNITS::MILLIMETRES:
  424. return MM_TO_IU( aValue, aIuScale );
  425. case EDA_UNITS::CENTIMETRES:
  426. return MM_TO_IU( aValue * 10, aIuScale );
  427. case EDA_UNITS::MILS:
  428. return MILS_TO_IU( aValue, aIuScale );
  429. case EDA_UNITS::INCHES:
  430. return IN_TO_IU( aValue, aIuScale );
  431. default:
  432. case EDA_UNITS::DEGREES:
  433. case EDA_UNITS::UNSCALED:
  434. case EDA_UNITS::PERCENT:
  435. return aValue;
  436. }
  437. }
  438. double EDA_UNIT_UTILS::UI::DoubleValueFromString( const wxString& aTextValue )
  439. {
  440. double dtmp = 0;
  441. // Acquire the 'right' decimal point separator
  442. const struct lconv* lc = localeconv();
  443. wxChar decimal_point = lc->decimal_point[0];
  444. wxString buf( aTextValue.Strip( wxString::both ) );
  445. // Convert any entered decimal point separators to the 'right' one
  446. buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
  447. buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
  448. // Find the end of the numeric part
  449. unsigned brk_point = 0;
  450. while( brk_point < buf.Len() )
  451. {
  452. wxChar ch = buf[brk_point];
  453. if( !( ( ch >= '0' && ch <= '9' ) || ( ch == decimal_point ) || ( ch == '-' )
  454. || ( ch == '+' ) ) )
  455. {
  456. break;
  457. }
  458. ++brk_point;
  459. }
  460. // Extract the numeric part
  461. buf.Left( brk_point ).ToDouble( &dtmp );
  462. return dtmp;
  463. }
  464. double EDA_UNIT_UTILS::UI::DoubleValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  465. const wxString& aTextValue, EDA_DATA_TYPE aType )
  466. {
  467. double dtmp = 0;
  468. // Acquire the 'right' decimal point separator
  469. const struct lconv* lc = localeconv();
  470. wxChar decimal_point = lc->decimal_point[0];
  471. wxString buf( aTextValue.Strip( wxString::both ) );
  472. // Convert any entered decimal point separators to the 'right' one
  473. buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
  474. buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
  475. // Find the end of the numeric part
  476. unsigned brk_point = 0;
  477. while( brk_point < buf.Len() )
  478. {
  479. wxChar ch = buf[brk_point];
  480. if( !( (ch >= '0' && ch <= '9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
  481. break;
  482. ++brk_point;
  483. }
  484. // Extract the numeric part
  485. buf.Left( brk_point ).ToDouble( &dtmp );
  486. // Check the optional unit designator (2 ch significant)
  487. wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
  488. if( aUnits == EDA_UNITS::MICROMETRES
  489. || aUnits == EDA_UNITS::MILLIMETRES
  490. || aUnits == EDA_UNITS::CENTIMETRES
  491. || aUnits == EDA_UNITS::MILS
  492. || aUnits == EDA_UNITS::INCHES )
  493. {
  494. //check for um, μm (µ is MICRO SIGN) and µm (µ is GREEK SMALL LETTER MU) for micrometre
  495. if( unit == wxT( "um" ) || unit == wxT( "\u00B5m" ) || unit == wxT( "\u03BCm" ) )
  496. {
  497. aUnits = EDA_UNITS::MICROMETRES;
  498. }
  499. else if( unit == wxT( "mm" ) )
  500. {
  501. aUnits = EDA_UNITS::MILLIMETRES;
  502. }
  503. else if( unit == wxT( "cm" ) )
  504. {
  505. aUnits = EDA_UNITS::CENTIMETRES;
  506. }
  507. else if( unit == wxT( "mi" ) || unit == wxT( "th" ) )
  508. {
  509. aUnits = EDA_UNITS::MILS;
  510. }
  511. else if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
  512. {
  513. aUnits = EDA_UNITS::INCHES;
  514. }
  515. else if( unit == wxT( "oz" ) ) // 1 oz = 1.37 mils
  516. {
  517. aUnits = EDA_UNITS::MILS;
  518. dtmp *= 1.37;
  519. }
  520. }
  521. else if( aUnits == EDA_UNITS::DEGREES )
  522. {
  523. if( unit == wxT( "ra" ) ) // Radians
  524. dtmp *= 180.0f / M_PI;
  525. }
  526. switch( aType )
  527. {
  528. case EDA_DATA_TYPE::VOLUME:
  529. dtmp = FromUserUnit( aIuScale, aUnits, dtmp );
  530. KI_FALLTHROUGH;
  531. case EDA_DATA_TYPE::AREA:
  532. dtmp = FromUserUnit( aIuScale, aUnits, dtmp );
  533. KI_FALLTHROUGH;
  534. case EDA_DATA_TYPE::DISTANCE:
  535. dtmp = FromUserUnit( aIuScale, aUnits, dtmp );
  536. break;
  537. case EDA_DATA_TYPE::UNITLESS:
  538. break;
  539. }
  540. return dtmp;
  541. }
  542. long long int EDA_UNIT_UTILS::UI::ValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
  543. const wxString& aTextValue, EDA_DATA_TYPE aType )
  544. {
  545. double value = DoubleValueFromString( aIuScale, aUnits, aTextValue, aType );
  546. return KiROUND<double, long long int>( value );
  547. }
  548. long long int EDA_UNIT_UTILS::UI::ValueFromString( const wxString& aTextValue )
  549. {
  550. double value = DoubleValueFromString( aTextValue );
  551. return KiROUND<double, long long int>( value );
  552. }