94 end.
x = double(aEnd.
x - aStart.
x);
95 end.
y = double(aEnd.
y - aStart.
y);
100 if( min_radius <= aRadius )
103 aRadius =
KiROUND( min_radius );
104 center.
x = ( aStart.
x + aEnd.
x + 1 ) / 2;
105 center.
y = ( aStart.
y + aEnd.
y + 1 ) / 2;
118 double cX = h_segm.
x/2;
119 double cY1 = sqrt( (
double)aRadius*aRadius - cX*cX );
158 return center+aStart;
161extern int ReadInt(
char*&
text,
bool aSkipSeparator =
true );
162extern double ReadDouble(
char*&
text,
bool aSkipSeparator =
true );
170 bool aLayerNegative );
177 bool aLayerNegative );
187 bool aLayerNegative );
260 std::unique_ptr<EXCELLON_IMAGE> drill_layer_uptr = std::make_unique<EXCELLON_IMAGE>( layerId );
267 bool success = drill_layer_uptr->LoadFile( aFullFileName, &nc_defaults );
271 drill_layer_uptr.reset();
272 msg.Printf(
_(
"File %s not found." ), aFullFileName );
279 layerId = images->
AddGbrImage( drill_layer, layerId );
349 bool foundM48 =
false;
350 bool foundM30 =
false;
351 bool foundPercent =
false;
356 FILE* file = wxFopen( aFullFileName,
"rb" );
358 if( file ==
nullptr )
367 if( excellonReader.
ReadLine() ==
nullptr )
378 for(
size_t i = 0; i < strlen( line ); i++ )
380 if( !isascii( line[i] ) )
386 char* buf = strstr( line,
";" );
391 if( strstr( line,
"M48" ) )
395 if( strstr( line,
"M30" ) )
400 if( ( letter = strstr( line,
"%" ) ) !=
nullptr )
401 if( ( letter[1] ==
'\r' ) || ( letter[1] ==
'\n' ) )
405 if( ( letter = strstr( line,
"T" ) ) !=
nullptr )
407 if( !foundT && ( foundX || foundY ) )
413 if( wxString( letter + 1 ).ToCDouble( &x_val ) )
419 if( ( letter = strstr( line,
"X" ) ) !=
nullptr )
423 if( wxString( letter + 1 ).ToCDouble( &x_val ) )
427 if( ( letter = strstr( line,
"Y" ) ) !=
nullptr )
431 if( wxString( letter + 1 ).ToCDouble( &x_val ) )
443 if( ( ( foundX || foundY ) && foundT ) && ( foundM48 || ( foundPercent && foundM30 ) ) )
445 else if( foundM48 && foundT && foundPercent && foundM30 )
491 if( excellonReader.
ReadLine() ==
nullptr )
494 char* line = excellonReader.
Line();
543 msg.Printf( wxT(
"Unexpected symbol 0x%2.2X <%c>" ), *
text, *
text );
554 dummy.ParseAttribCmd(
nullptr,
nullptr, 0,
text, dummyline );
570 for(
unsigned ii = 0; ; ii++ )
573 int len = candidate->
m_Name.size();
578 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
588 msg.Printf(
_(
"Unknown Excellon command <%s>" ),
text );
682 if( strncasecmp(
text,
"OFF", 3 ) == 0 )
684 else if( strncasecmp(
text,
"ON", 2 ) == 0 )
733 int mantissaDigits = 0;
734 int characteristicDigits = 0;
745 if( !isdigit( *aText ) )
748 characteristicDigits = *aText -
'0';
756 if( !isdigit( *aText ) )
759 mantissaDigits = *aText -
'0';
776 int iprm =
ReadInt( aText,
false );
779 while( *aText && ( *aText ==
'F' || *aText ==
'S' ) )
788 _(
"Tool definition shape not found" ) ) );
789 else if( *aText !=
'C' )
791 _(
"Tool definition '%c' not supported" ), *aText ) );
803 if( dcode ==
nullptr )
916 char * startline =
text;
931 if( currDcode ==
nullptr && tool_id > 0 )
956 bool success =
false;
963 for(
unsigned ii = 0; ; ii++ )
966 int len = candidate->
m_Name.size();
969 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
1167 tool->
m_Size, not rot_ccw ,
true,
int ReadInt(char *&text, bool aSkipSeparator=true)
Read an integer from an ASCII character buffer.
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number from an ASCII character buffer.
constexpr EDA_IU_SCALE gerbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A gerber DCODE (also called Aperture) definition.
int m_Num_Dcode
D code value ( >= 10 )
VECTOR2I m_Size
Horizontal and vertical dimensions.
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
bool m_Defined
false if the aperture is not defined in the header
bool m_InUse
false if the aperture (previously defined) is not used to draw something
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void readFileFormat(char *&aText)
Read an Altium-specific FILE_FORMAT=X:X attribute that specifies the length and mantissa of the numbe...
static bool TestFileIsExcellon(const wxString &aFullFileName)
Performs a heuristics-based check of whether the file is an Excellon drill file.
bool LoadFile(const wxString &aFullFileName, EXCELLON_DEFAULTS *aDefaults)
Read and load a drill (EXCELLON format) file.
bool Execute_Drill_Command(char *&text)
void FinishRouteCommand()
End a route command started by M15 ot G01, G02 or G03 command.
bool Execute_HEADER_And_M_Command(char *&text)
bool Execute_EXCELLON_G_Command(char *&text)
bool m_hasFormat
Excellon file do not have a format statement to specify the coordinate format like nn:mm.
bool readToolInformation(char *&aText)
Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 and enter params in TCODE list.
virtual void ResetDefaultValues() override
Set all parameters to a default value, before reading a file.
std::vector< EXCELLON_ROUTE_COORD > m_RoutePositions
bool Select_Tool(char *&text)
void SelectUnits(bool aMetric, EXCELLON_DEFAULTS *aDefaults)
Switch unit selection, and the coordinate format (nn:mm) if not yet set.
A LINE_READER that reads from an open file.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
int AddGbrImage(GERBER_FILE_IMAGE *aGbrImage, int aIdx)
Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
Hold the image data and parameters for one gerber file and layer parameters.
VECTOR2I ReadIJCoord(char *&Text)
Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
file function parameters, found in a TF command or a G04
virtual void ResetDefaultValues()
Set all parameters to a default value, before reading a file.
const wxArrayString & GetMessages() const
void ClearMessageList()
Clear the message list.
VECTOR2I m_Offset
Coord Offset, from OF command.
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)).
wxString m_FileName
Full File Name for this layer.
void StepAndRepeatItem(const GERBER_DRAW_ITEM &aItem)
Gerber format has a command Step an Repeat.
VECTOR2I m_PreviousPos
old current specified coord for plot
bool m_InUse
true if this image is currently in use (a file is loaded in it) false if it must be not drawn
void AddMessageToList(const wxString &aMessage)
Add a message to the message list.
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
VECTOR2I m_IJPos
IJ coord (for arcs & circles )
bool m_Relative
false = absolute Coord, true = relative Coord.
D_CODE * GetDCODE(int aDCODE) const
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
bool m_Has_DCode
< True if has DCodes in file or false if no DCodes found. Perhaps deprecated RS274D file.
int m_Current_Tool
Current Tool (Dcode) number selected.
D_CODE * GetDCODEOrCreate(int aDCODE, bool aCreateIfNoExist=true)
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
void AddItemToList(GERBER_DRAW_ITEM *aItem)
Add a new GERBER_DRAW_ITEM item to the drawings list.
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.
int m_Iterpolation
Linear, 90 arc, Circ.
VECTOR2I m_CurrentPos
current specified coord for plot
GERBER_DRAW_ITEMS & GetItems()
int CodeNumber(char *&aText)
Reads the next number and returns the value.
bool Read_EXCELLON_File(const wxString &aFullFileName)
GBR_LAYOUT * GetGerberLayout() const
int GetActiveLayer() const
Return the active layer.
void Erase_Current_DrawLayer(bool query)
void GetExcellonDefaults(EXCELLON_DEFAULTS &aNCDefaults)
return the Excellon default values to read a drill file
void ListSet(const wxString &aList)
Add a list of items.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
An abstract base class for deriving all objects that can be added to a VIEW.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
char * Line() const
Return a pointer to the last line that was read in.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF....
The attribute value consists of a number of substrings separated by a comma.
APERTURE_T
The set of all gerber aperture types allowed from ADD dcode command, like ADD11C,0....
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
static constexpr EDA_ANGLE ANGLE_180
#define FMT_MANTISSA_INCH
@ DRILL_AUTOMATIC_TOOL_CHANGE
@ DRILL_INCREMENTALHEADER
static EXCELLON_CMD excellonHeaderCmdList[]
void fillFlashedGBRITEM(GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const VECTOR2I &aPos, VECTOR2I aSize, bool aLayerNegative)
functions to read the rs274d commands from a rs274d/rs274x file
static EXCELLON_CMD excellon_G_CmdList[]
static const char file_attribute[]
void fillArcGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aRelCenter, VECTOR2I aPenSize, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw an arc G code.
int ReadInt(char *&text, bool aSkipSeparator=true)
Read an integer from an ASCII character buffer.
static VECTOR2I computeCenter(VECTOR2I aStart, VECTOR2I aEnd, int &aRadius, bool aRotCCW)
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number from an ASCII character buffer.
void fillLineGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, VECTOR2I aPenSize, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw a linear D code.
@ GERB_INTERPOL_LINEAR_1X
This file contains miscellaneous commonly used macros and functions.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
std::vector< FAB_LAYER_COLOR > dummy
wxString From_UTF8(const char *cstring)
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
management of default values used to read a Excellon (.nc) drill file Some important parameters are n...
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D