KiCad PCB EDA Suite
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 <fctsys.h>
#include <common.h>
#include <confirm.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_file_image.h>
#include <class_gerber_file_image_list.h>
#include <class_excellon.h>
#include <kicad_string.h>
#include <class_X2_gerber_attributes.h>
#include <cmath>
#include <html_messagebox.h>

Go to the source code of this file.

Functions

int ReadInt (char *&text, bool aSkipSeparator=true)
 Function ReadInt reads an int from an ASCII character buffer. More...
 
double ReadDouble (char *&text, bool aSkipSeparator=true)
 Function ReadDouble reads a double from an ASCII character buffer. More...
 
void fillFlashedGBRITEM (GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const wxPoint &aPos, wxSize aSize, bool aLayerNegative)
 Function fillFlashedGBRITEM initializes a given GBRITEM so that it can draw a circle which is filled and has no pen border. More...
 
void fillLineGBRITEM (GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const wxPoint &aStart, const wxPoint &aEnd, wxSize aPenSize, bool aLayerNegative)
 Function fillLineGBRITEM initializes a given GBRITEM so that it can draw a linear D code. More...
 

Variables

static const int fmtMantissaMM = 3
 
static const int fmtMantissaInch = 4
 
static const int fmtIntegerMM = 3
 
static const int fmtIntegerInch = 2
 
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

void fillFlashedGBRITEM ( GERBER_DRAW_ITEM aGbrItem,
APERTURE_T  aAperture,
int  Dcode_index,
const wxPoint aPos,
wxSize  aSize,
bool  aLayerNegative 
)

Function fillFlashedGBRITEM 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
aLayerThe layer index to set into the GBRITEM
aPosThe center point of the flash
aSizeThe diameter of the round flash
aLayerNegative= true if the current layer is negative

Definition at line 108 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, 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_Shape, 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(), and EXCELLON_IMAGE::Execute_Drill_Command().

114 {
115  aGbrItem->m_Size = aSize;
116  aGbrItem->m_Start = aPos;
117  aGbrItem->m_End = aGbrItem->m_Start;
118  aGbrItem->m_DCode = Dcode_index;
119  aGbrItem->SetLayerPolarity( aLayerNegative );
120  aGbrItem->m_Flashed = true;
121  aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
122 
123  switch( aAperture )
124  {
125  case APT_POLYGON: // flashed regular polygon
126  aGbrItem->m_Shape = GBR_SPOT_POLY;
127  break;
128 
129  case APT_CIRCLE:
130  aGbrItem->m_Shape = GBR_SPOT_CIRCLE;
131  aGbrItem->m_Size.y = aGbrItem->m_Size.x;
132  break;
133 
134  case APT_OVAL:
135  aGbrItem->m_Shape = GBR_SPOT_OVAL;
136  break;
137 
138  case APT_RECT:
139  aGbrItem->m_Shape = GBR_SPOT_RECT;
140  break;
141 
142  case APT_MACRO:
143  aGbrItem->m_Shape = GBR_SPOT_MACRO;
144  break;
145  }
146 }
Definition: dcode.h:52
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
Definition: dcode.h:51
GBR_NETLIST_METADATA m_NetAttributeDict
void SetLayerPolarity(bool aNegative)
GERBER_FILE_IMAGE * m_GerberImageFile
void fillLineGBRITEM ( GERBER_DRAW_ITEM aGbrItem,
int  Dcode_index,
const wxPoint aStart,
const wxPoint aEnd,
wxSize  aPenSize,
bool  aLayerNegative 
)

Function fillLineGBRITEM initializes 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
aLayerThe layer index to set into the GBRITEM
aStartThe starting point of the line
aEndThe ending point of the line
aPenSizeThe size of the flash. Note rectangular shapes are legal.
aLayerNegative= true if the current layer is negative

Definition at line 161 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(), and EXCELLON_IMAGE::Execute_Drill_Command().

167 {
168  aGbrItem->m_Flashed = false;
169 
170  aGbrItem->m_Size = aPenSize;
171 
172  aGbrItem->m_Start = aStart;
173  aGbrItem->m_End = aEnd;
174 
175  aGbrItem->m_DCode = Dcode_index;
176  aGbrItem->SetLayerPolarity( aLayerNegative );
177 
178  aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
179 }
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
GBR_NETLIST_METADATA m_NetAttributeDict
void SetLayerPolarity(bool aNegative)
GERBER_FILE_IMAGE * m_GerberImageFile
double ReadDouble ( char *&  text,
bool  aSkipSeparator = true 
)

Function ReadDouble reads a double from an ASCII character buffer.

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

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

Definition at line 302 of file rs274_read_XY_and_IJ_coordinates.cpp.

Referenced by EXCELLON_IMAGE::readToolInformation().

303 {
304  double ret;
305 
306  // For strtod, a string starting by 0X or 0x is a valid number in hexadecimal or octal.
307  // However, 'X' is a separator in Gerber strings with numbers.
308  // We need to detect that
309  if( strncasecmp( text, "0X", 2 ) == 0 )
310  {
311  text++;
312  ret = 0.0;
313  }
314  else
315  ret = strtod( text, &text );
316 
317  if( *text == ',' || isspace( *text ) )
318  {
319  if( aSkipSeparator )
320  ++text;
321  }
322 
323  return ret;
324 }
int ReadInt ( char *&  text,
bool  aSkipSeparator = true 
)

Function ReadInt reads an int from an ASCII character buffer.

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

Parameters
textA reference to a character pointer from which bytes are read and the pointer is advanced for each byte read.
aSkipSeparator= true (default) to skip comma
Returns
int - The int read in.

Definition at line 268 of file rs274_read_XY_and_IJ_coordinates.cpp.

Referenced by EXCELLON_IMAGE::readToolInformation().

269 {
270  int ret;
271 
272  // For strtol, a string starting by 0X or 0x is a valid number in hexadecimal or octal.
273  // However, 'X' is a separator in Gerber strings with numbers.
274  // We need to detect that
275  if( strncasecmp( text, "0X", 2 ) == 0 )
276  {
277  text++;
278  ret = 0;
279  }
280  else
281  ret = (int) strtol( text, &text, 10 );
282 
283  if( *text == ',' || isspace( *text ) )
284  {
285  if( aSkipSeparator )
286  ++text;
287  }
288 
289  return ret;
290 }

Variable Documentation

EXCELLON_CMD excellon_G_CmdList[]
static
EXCELLON_CMD excellonHeaderCmdList[]
static

Definition at line 112 of file excellon_read_drill_file.cpp.

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

Definition at line 110 of file excellon_read_drill_file.cpp.

Referenced by EXCELLON_IMAGE::LoadFile().

const int fmtIntegerInch = 2
static

Definition at line 87 of file excellon_read_drill_file.cpp.

Referenced by EXCELLON_IMAGE::SelectUnits().

const int fmtIntegerMM = 3
static

Definition at line 86 of file excellon_read_drill_file.cpp.

Referenced by EXCELLON_IMAGE::SelectUnits().

const int fmtMantissaInch = 4
static

Definition at line 84 of file excellon_read_drill_file.cpp.

Referenced by EXCELLON_IMAGE::SelectUnits().

const int fmtMantissaMM = 3
static

Definition at line 83 of file excellon_read_drill_file.cpp.

Referenced by EXCELLON_IMAGE::SelectUnits().