35#define SCALE_LIST_SIZE 9
70 return ( ( x >=
'0' ) && ( x <=
'9' ) )
71 || ( x ==
'-' ) || ( x ==
'+' ) || ( x ==
'.' );
87 if( aText ==
nullptr )
90 while( *aText && ( ( *aText ==
'X' ) || ( *aText ==
'Y' ) || ( *aText ==
'A' ) ) )
92 double decimal_scale = 1.0;
93 bool is_float =
false;
95 int current_coord = 0;
96 char type_coord = *aText++;
106 if( (*aText >=
'0') && (*aText <=
'9') )
109 line.push_back( *( aText++ ) );
113 wxString
text( line.data() );
115 if( !
text.ToCDouble( &val ) )
135 if( nbdigits < digit_count || ( aExcellonMode && ( nbdigits > digit_count ) ) )
136 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
142 real_scale = real_scale / 25.4;
144 current_coord =
KiROUND( val * real_scale * decimal_scale );
147 if( type_coord ==
'X' )
149 pos.
x = current_coord;
151 else if( type_coord ==
'Y' )
153 pos.
y = current_coord;
155 else if( type_coord ==
'A' )
178 if( aText ==
nullptr )
181 while( *aText && ( ( *aText ==
'I' ) || ( *aText ==
'J' ) ) )
183 double decimal_scale = 1.0;
184 bool is_float =
false;
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 );
207 if( !
text.ToCDouble( &val ) )
227 if( nbdigits < digit_count )
228 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
234 real_scale = real_scale / 25.4;
236 current_coord =
KiROUND( val * real_scale * decimal_scale );
239 if( type_coord ==
'I' )
241 pos.
x = current_coord;
243 else if( type_coord ==
'J' )
245 pos.
y = current_coord;
276 if( strncasecmp(
text,
"0X", 2 ) == 0 )
283 ret = (int) strtol(
text, &
text, 10 );
286 if( *
text ==
',' || isspace( *
text ) )
312 while( isspace( *
text ) )
318 if( strncasecmp(
text,
"0X", 2 ) == 0 )
325 wxString line(
text );
331 line.Replace(
",",
" ",
false );
332 line.ToCDouble( &ret );
337 if( line.Length() > 1 && ( line[0] ==
'+' || line[0] ==
'-' ) && line[1] !=
'$' )
343 auto endpos = line.find_first_not_of(
"0123456789." );
345 if( endpos != wxString::npos )
353 text += line.length();
357 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
A value ( = radius in circular routing in Excellon files ).
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
Identifier for arc data type (IJ (center) or A## (radius)).
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
True if a IJ coord was read (for arcs & circles ).
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