39#define SCALE_LIST_SIZE 9
74 return ( ( x >=
'0' ) && ( x <=
'9' ) )
75 || ( x ==
'-' ) || ( x ==
'+' ) || ( x ==
'.' );
82 bool is_float =
false;
93 if( aText ==
nullptr )
96 while( *aText && ( ( *aText ==
'X' ) || ( *aText ==
'Y' ) || ( *aText ==
'A' ) ) )
98 double decimal_scale = 1.0;
100 int current_coord = 0;
101 char type_coord = *aText++;
111 if( (*aText >=
'0') && (*aText <=
'9') )
114 line.push_back( *( aText++ ) );
118 wxString
text( line.data() );
119 text.ToCDouble( &val );
138 if( nbdigits < digit_count || ( aExcellonMode && ( nbdigits > digit_count ) ) )
139 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
145 real_scale = real_scale / 25.4;
147 current_coord =
KiROUND( val * real_scale * decimal_scale );
150 if( type_coord ==
'X' )
152 pos.
x = current_coord;
154 else if( type_coord ==
'Y' )
156 pos.
y = current_coord;
158 else if( type_coord ==
'A' )
176 bool is_float =
false;
183 if( aText ==
nullptr )
186 while( *aText && ( ( *aText ==
'I' ) || ( *aText ==
'J' ) ) )
188 double decimal_scale = 1.0;
190 int current_coord = 0;
191 char type_coord = *aText++;
201 if( (*aText >=
'0') && (*aText <=
'9') )
204 line.push_back( *( aText++ ) );
208 wxString
text( line.data() );
209 text.Trim(
true ).Trim(
false );
210 text.ToCDouble( &val );
229 if( nbdigits < digit_count )
230 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
236 real_scale = real_scale / 25.4;
238 current_coord =
KiROUND( val * real_scale * decimal_scale );
241 if( type_coord ==
'I' )
243 pos.
x = current_coord;
245 else if( type_coord ==
'J' )
247 pos.
y = current_coord;
278 if( strncasecmp(
text,
"0X", 2 ) == 0 )
285 ret = (int) strtol(
text, &
text, 10 );
288 if( *
text ==
',' || isspace( *
text ) )
315 if( strncasecmp(
text,
"0X", 2 ) == 0 )
322 wxString line(
text );
323 auto endpos = line.find_first_not_of(
"0123456789.-+eE" );
325 line.ToCDouble( &ret );
327 if( endpos != wxString::npos )
335 text += line.length();
339 if( *
text ==
',' || isspace( *
text ) )
int scaletoIU(double aCoord, bool isMetric)
Convert a distance given in floating point to our internal units.
constexpr double GERB_IU_PER_MM
some macros and functions to convert a value in mils, decimils or mm to the internal unit used in pcb...
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
VECTOR2I ReadIJCoord(char *&Text)
Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
wxSize m_FmtScale
Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
int m_ArcRadius
Identifier for arc data type (IJ (center) or A## (radius)).
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
VECTOR2I m_IJPos
IJ coord (for arcs & circles )
bool m_Relative
false = absolute Coord, true = relative Coord.
VECTOR2I ReadXYCoord(char *&aText, bool aExcellonMode=false)
Return the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm).
wxSize m_FmtLen
Nb chars per coord. ex fmt 2.3, m_FmtLen = 5.
bool m_GerbMetric
false = Inches, true = metric
bool m_NoTrailingZeros
true: remove tailing zeros.
VECTOR2I m_CurrentPos
current specified coord for plot
bool m_LastCoordIsIJPos
A value ( = radius in circular routing in Excellon files ).
int scaletoIU(double aCoord, bool isMetric)
Convert a coordinate given in floating point to GerbView's internal units (currently = 10 nanometers)...
int ReadInt(char *&text, bool aSkipSeparator=true)
Read an integer from an ASCII character buffer.
static bool IsNumber(char x)
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number from an ASCII character buffer.
static double scale_list[SCALE_LIST_SIZE]