35#define SCALE_LIST_SIZE 9
70 return ( ( x >=
'0' ) && ( x <=
'9' ) )
71 || ( x ==
'-' ) || ( x ==
'+' ) || ( x ==
'.' );
78 bool is_float =
false;
89 if( aText ==
nullptr )
92 while( *aText && ( ( *aText ==
'X' ) || ( *aText ==
'Y' ) || ( *aText ==
'A' ) ) )
94 double decimal_scale = 1.0;
96 int current_coord = 0;
97 char type_coord = *aText++;
107 if( (*aText >=
'0') && (*aText <=
'9') )
110 line.push_back( *( aText++ ) );
114 wxString
text( line.data() );
115 text.ToCDouble( &val );
134 if( nbdigits < digit_count || ( aExcellonMode && ( nbdigits > digit_count ) ) )
135 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
141 real_scale = real_scale / 25.4;
143 current_coord =
KiROUND( val * real_scale * decimal_scale );
146 if( type_coord ==
'X' )
148 pos.
x = current_coord;
150 else if( type_coord ==
'Y' )
152 pos.
y = current_coord;
154 else if( type_coord ==
'A' )
172 bool is_float =
false;
179 if( aText ==
nullptr )
182 while( *aText && ( ( *aText ==
'I' ) || ( *aText ==
'J' ) ) )
184 double decimal_scale = 1.0;
186 int current_coord = 0;
187 char type_coord = *aText++;
197 if( (*aText >=
'0') && (*aText <=
'9') )
200 line.push_back( *( aText++ ) );
204 wxString
text( line.data() );
205 text.Trim(
true ).Trim(
false );
206 text.ToCDouble( &val );
225 if( nbdigits < digit_count )
226 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
232 real_scale = real_scale / 25.4;
234 current_coord =
KiROUND( val * real_scale * decimal_scale );
237 if( type_coord ==
'I' )
239 pos.
x = current_coord;
241 else if( type_coord ==
'J' )
243 pos.
y = current_coord;
274 if( strncasecmp(
text,
"0X", 2 ) == 0 )
281 ret = (int) strtol(
text, &
text, 10 );
284 if( *
text ==
',' || isspace( *
text ) )
310 while( isspace( *
text ) )
316 if( strncasecmp(
text,
"0X", 2 ) == 0 )
323 wxString line(
text );
329 line.Replace(
",",
" ",
false );
330 line.ToCDouble( &ret );
335 if( ( line[0] ==
'+' || line[0] ==
'-' ) && line.Length() > 1 && line[1] !=
'$' )
341 auto endpos = line.find_first_not_of(
"0123456789." );
343 if( endpos != wxString::npos )
351 text += line.length();
355 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]
VECTOR2< int32_t > VECTOR2I