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++ ) );
117 double val = strtod( line.data(),
nullptr );
136 if( nbdigits < digit_count || ( aExcellonMode && ( nbdigits > digit_count ) ) )
137 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
143 real_scale = real_scale / 25.4;
145 current_coord =
KiROUND( val * real_scale * decimal_scale );
148 if( type_coord ==
'X' )
150 pos.
x = current_coord;
152 else if( type_coord ==
'Y' )
154 pos.
y = current_coord;
156 else if( type_coord ==
'A' )
174 bool is_float =
false;
181 if( aText ==
nullptr )
184 while( *aText && ( ( *aText ==
'I' ) || ( *aText ==
'J' ) ) )
186 double decimal_scale = 1.0;
188 int current_coord = 0;
189 char type_coord = *aText++;
199 if( (*aText >=
'0') && (*aText <=
'9') )
202 line.push_back( *( aText++ ) );
205 double val = strtod( line.data(),
nullptr );
224 if( nbdigits < digit_count )
225 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
231 real_scale = real_scale / 25.4;
233 current_coord =
KiROUND( val * real_scale * decimal_scale );
236 if( type_coord ==
'I' )
238 pos.
x = current_coord;
240 else if( type_coord ==
'J' )
242 pos.
y = current_coord;
273 if( strncasecmp(
text,
"0X", 2 ) == 0 )
280 ret = (int) strtol(
text, &
text, 10 );
283 if( *
text ==
',' || isspace( *
text ) )
310 if( strncasecmp(
text,
"0X", 2 ) == 0 )
320 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]