KiCad PCB EDA Suite
Loading...
Searching...
No Matches
excellon_read_drill_file.cpp File Reference

Functions to read drill files (EXCELLON format) created by Pcbnew These files use only a subset of EXCELLON commands. More...

#include <math/util.h>
#include <trigo.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerber_file_image.h>
#include <gerber_file_image_list.h>
#include <excellon_image.h>
#include <excellon_defaults.h>
#include <macros.h>
#include <richio.h>
#include <string_utils.h>
#include <locale_io.h>
#include <X2_gerber_attributes.h>
#include <view/view.h>
#include <gerbview_settings.h>
#include <cmath>
#include <charconv>
#include <dialogs/html_message_box.h>

Go to the source code of this file.

Functions

static VECTOR2I computeCenter (VECTOR2I aStart, VECTOR2I aEnd, int &aRadius, bool aRotCCW)
 
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.
 
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
 
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.
 
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.
 

Variables

static const char file_attribute [] = ".FileFunction,Other,Drill*"
 
static EXCELLON_CMD excellonHeaderCmdList []
 
static EXCELLON_CMD excellon_G_CmdList []
 

Detailed Description

Functions to read drill files (EXCELLON format) created by Pcbnew These files use only a subset of EXCELLON commands.

Definition in file excellon_read_drill_file.cpp.

Function Documentation

◆ computeCenter()

static VECTOR2I computeCenter ( VECTOR2I  aStart,
VECTOR2I  aEnd,
int &  aRadius,
bool  aRotCCW 
)
static

◆ fillArcGBRITEM()

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.

If multiquadrant == true : arc can be 0 to 360 degrees and rel_center is the center coordinate relative to start point.

If multiquadrant == false arc can be only 0 to 90 deg, and only in the same quadrant :

  • absolute angle 0 to 90 (quadrant 1) or
  • absolute angle 90 to 180 (quadrant 2) or
  • absolute angle 180 to 270 (quadrant 3) or
  • absolute angle 270 to 0 (quadrant 4)
Parameters
aGbrItemis the GBRITEM to fill in.
Dcode_indexis the DCODE value, like D14.
aStartis the starting point.
aEndis the ending point.
aRelCenteris the center coordinate relative to start point, given in ABSOLUTE VALUE and the sign of values x et y de rel_center must be calculated from the previously given constraint: arc only in the same quadrant.
aClockwisetrue if arc must be created clockwise
aPenSizeThe size of the flash. Note rectangular shapes are legal.
aMultiquadrantset to true to create arcs up to 360 degrees, false when arc is inside one quadrant
aLayerNegativeset to true if the current layer is negative.

Definition at line 203 of file rs274d.cpp.

References delta, GBR_ARC, GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_NetAttributeDict, GERBER_DRAW_ITEM::m_ShapeType, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, GERBER_DRAW_ITEM::SetLayerPolarity(), GERBER_DRAW_ITEM::SetNetAttributes(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), fillArcPOLY(), and EXCELLON_IMAGE::FinishRouteCommand().

◆ fillFlashedGBRITEM()

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

Initializes a given GBRITEM so that it can draw a circle which is filled and has no pen border.

Parameters
aGbrItemThe GBRITEM to fill in.
aAperturethe associated type of aperture.
Dcode_indexThe DCODE value, like D14.
aPosThe center point of the flash.
aSizeThe diameter of the round flash.
aLayerNegativeset to true if the current layer is negative.

Definition at line 100 of file rs274d.cpp.

References APT_CIRCLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, GBR_SPOT_CIRCLE, GBR_SPOT_MACRO, GBR_SPOT_OVAL, GBR_SPOT_POLY, GBR_SPOT_RECT, APERTURE_MACRO::GetApertureMacroShape(), GERBER_DRAW_ITEM::GetDcodeDescr(), D_CODE::GetMacro(), GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_NetAttributeDict, GERBER_DRAW_ITEM::m_ShapeType, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, GERBER_DRAW_ITEM::SetLayerPolarity(), GERBER_DRAW_ITEM::SetNetAttributes(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), and EXCELLON_IMAGE::Execute_Drill_Command().

◆ fillLineGBRITEM()

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.

Parameters
aGbrItemThe GERBER_DRAW_ITEM to fill in.
Dcode_indexThe DCODE value, like D14.
aStartThe starting point of the line.
aEndThe ending point of the line.
aPenSizeThe size of the flash. Note rectangular shapes are legal.
aLayerNegativeset to true if the current layer is negative.

Definition at line 154 of file rs274d.cpp.

References GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_NetAttributeDict, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, GERBER_DRAW_ITEM::SetLayerPolarity(), and GERBER_DRAW_ITEM::SetNetAttributes().

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), EXCELLON_IMAGE::Execute_Drill_Command(), and EXCELLON_IMAGE::FinishRouteCommand().

◆ ReadDouble()

double ReadDouble ( char *&  text,
bool  aSkipSeparator = true 
)

Read a double precision floating point number from an ASCII character buffer.

If there is a comma after the number, then skip over that.

Parameters
textis a reference to a character pointer from which the ASCII double is read from and the pointer advanced for each character read.
aSkipSeparatorset to true (default) to skip comma.
Returns
number read.

Definition at line 303 of file rs274_read_XY_and_IJ_coordinates.cpp.

◆ ReadInt()

int ReadInt ( char *&  text,
bool  aSkipSeparator = true 
)

Read an integer from an ASCII character buffer.

If there is a comma after the integer, then skip over that.

Parameters
textis a reference to a character pointer from which bytes are read and the pointer is advanced for each byte read.
aSkipSeparatorset to true (default) to skip comma.
Returns
The integer read in.

Definition at line 266 of file rs274_read_XY_and_IJ_coordinates.cpp.

Variable Documentation

◆ excellon_G_CmdList

EXCELLON_CMD excellon_G_CmdList[]
static
Initial value:
=
{
{ "G90", DRILL_G_ABSOLUTE, 0 },
{ "G91", DRILL_G_INCREMENTAL, 0 },
{ "G90", DRILL_G_ZEROSET, 0 },
{ "G00", DRILL_G_ROUT, 1 },
{ "G05", DRILL_G_DRILL, 0 },
{ "G85", DRILL_G_SLOT, 0 },
{ "G01", DRILL_G_LINEARMOVE, 1 },
{ "G02", DRILL_G_CWMOVE, 1 },
{ "G03", DRILL_G_CCWMOVE, 1 },
{ "G93", DRILL_G_ZERO_SET, 1 },
{ "", DRILL_G_UNKNOWN, 0 },
}
@ DRILL_G_CWMOVE
@ DRILL_G_ZERO_SET
@ DRILL_G_INCREMENTAL
@ DRILL_G_ZEROSET
@ DRILL_G_DRILL
@ DRILL_G_LINEARMOVE
@ DRILL_G_ABSOLUTE
@ DRILL_G_SLOT
@ DRILL_G_ROUT
@ DRILL_G_UNKNOWN
@ DRILL_G_CCWMOVE

Definition at line 233 of file excellon_read_drill_file.cpp.

Referenced by EXCELLON_IMAGE::Execute_EXCELLON_G_Command().

◆ excellonHeaderCmdList

EXCELLON_CMD excellonHeaderCmdList[]
static

◆ file_attribute

const char file_attribute[] = ".FileFunction,Other,Drill*"
static

Definition at line 193 of file excellon_read_drill_file.cpp.

Referenced by EXCELLON_IMAGE::LoadFile().