KiCad PCB EDA Suite
panel_cable_size.cpp File Reference
#include <wx/choicdlg.h>
#include <common_data.h>
#include <calculator_panels/panel_cable_size.h>
#include <pcb_calculator_settings.h>
#include <string_utils.h>
#include <widgets/unit_selector.h>

Go to the source code of this file.

Macros

#define M2_to_MM2   1000000.0
 
#define VACCUM_PERMEABILITY   1.256637e-6
 
#define RELATIVE_PERMEABILITY   1
 

Functions

double DoubleFromString (const wxString &TextValue)
 

Macro Definition Documentation

◆ M2_to_MM2

#define M2_to_MM2   1000000.0

Definition at line 29 of file panel_cable_size.cpp.

◆ RELATIVE_PERMEABILITY

#define RELATIVE_PERMEABILITY   1

Definition at line 32 of file panel_cable_size.cpp.

◆ VACCUM_PERMEABILITY

#define VACCUM_PERMEABILITY   1.256637e-6

Definition at line 31 of file panel_cable_size.cpp.

Function Documentation

◆ DoubleFromString()

double DoubleFromString ( const wxString &  TextValue)

Definition at line 37 of file params_read_write.cpp.

38{
39 double value = 0;
40
41 /* Acquire the 'right' decimal point separator */
42 const struct lconv* lc = localeconv();
43 wxChar decimal_point = lc->decimal_point[0];
44 wxString buf( TextValue.Strip( wxString::both ) );
45
46 /* Convert the period in decimal point */
47 buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
48 // An ugly fix needed by WxWidgets 2.9.1 that sometimes
49 // back to a point as separator, although the separator is the comma
50 buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
51
52 /* Find the end of the numeric part
53 *(when units are append to the number, remove them)
54 */
55 unsigned brk_point = 0;
56 while( brk_point < buf.Len() )
57 {
58 wxChar ch = buf[brk_point];
59 if( !( ( ch >= '0' && ch <= '9' ) || ( ch == decimal_point ) || ( ch == '-' )
60 || ( ch == '+' ) || ( ch == 'e' ) || ( ch == 'E' ) ) )
61 {
62 break;
63 }
64 ++brk_point;
65 }
66
67 // Check for strings that cannot qualify as a number
68 if( brk_point == 0 )
69 return std::nan( "" );
70
71 /* Extract the numeric part */
72 if( !buf.Left( brk_point ).ToDouble( &value ) )
73 return std::nan( "" );
74
75 return value;
76}

Referenced by PANEL_GALVANIC_CORROSION::LoadSettings(), PANEL_E_SERIES::OnCalculateESeries(), PANEL_CABLE_SIZE::OnConductorResistivityChange(), PANEL_CABLE_SIZE::OnConductorThermCoefChange(), PANEL_GALVANIC_CORROSION::OnCorFilterChange(), PANEL_TRACK_WIDTH::OnTWCalculateFromCurrent(), PANEL_TRACK_WIDTH::OnTWCalculateFromExtWidth(), PANEL_TRACK_WIDTH::OnTWCalculateFromIntWidth(), and PANEL_TRACK_WIDTH::TWDisplayValues().