92 end.
x = double(aEnd.
x - aStart.
x);
93 end.
y = double(aEnd.
y - aStart.
y);
98 if( min_radius <= aRadius )
101 aRadius =
KiROUND( min_radius );
102 center.
x = ( aStart.
x + aEnd.
x + 1 ) / 2;
103 center.
y = ( aStart.
y + aEnd.
y + 1 ) / 2;
116 double cX = h_segm.
x/2;
117 double cY1 = sqrt( (
double)aRadius*aRadius - cX*cX );
156 return center+aStart;
159extern int ReadInt(
char*& text,
bool aSkipSeparator =
true );
160extern double ReadDouble(
char*& text,
bool aSkipSeparator =
true );
168 bool aLayerNegative );
175 bool aLayerNegative );
185 bool aLayerNegative );
258 std::unique_ptr<EXCELLON_IMAGE> drill_layer_uptr = std::make_unique<EXCELLON_IMAGE>( layerId );
265 bool success = drill_layer_uptr->LoadFile( aFullFileName, &nc_defaults );
269 drill_layer_uptr.reset();
270 msg.Printf(
_(
"File %s not found." ), aFullFileName );
277 layerId = images->
AddGbrImage( drill_layer, layerId );
347 bool foundM48 =
false;
348 bool foundM30 =
false;
349 bool foundPercent =
false;
354 FILE* file = wxFopen( aFullFileName,
"rb" );
356 if( file ==
nullptr )
365 if( excellonReader.
ReadLine() ==
nullptr )
376 for(
size_t i = 0; i < strlen( line ); i++ )
378 if( !isascii( line[i] ) )
384 char* buf = strstr( line,
";" );
389 if( strstr( line,
"M48" ) )
393 if( strstr( line,
"M30" ) )
398 if( ( letter = strstr( line,
"%" ) ) !=
nullptr )
399 if( ( letter[1] ==
'\r' ) || ( letter[1] ==
'\n' ) )
403 if( ( letter = strstr( line,
"T" ) ) !=
nullptr )
405 if( !foundT && ( foundX || foundY ) )
410 if( isdigit( letter[1] ) )
416 if( ( letter = strstr( line,
"X" ) ) !=
nullptr )
417 if( isdigit( letter[1] ) )
420 if( ( letter = strstr( line,
"Y" ) ) !=
nullptr )
421 if( isdigit( letter[1] ) )
432 if( ( ( foundX || foundY ) && foundT ) && ( foundM48 || ( foundPercent && foundM30 ) ) )
434 else if( foundM48 && foundT && foundPercent && foundM30 )
480 if( excellonReader.
ReadLine() ==
nullptr )
483 char* line = excellonReader.
Line();
532 msg.Printf( wxT(
"Unexpected symbol 0x%2.2X <%c>" ), *
text, *
text );
543 dummy.ParseAttribCmd(
nullptr,
nullptr, 0,
text, dummyline );
559 for(
unsigned ii = 0; ; ii++ )
562 int len = candidate->
m_Name.size();
567 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
577 msg.Printf(
_(
"Unknown Excellon command <%s>" ),
text );
671 if( strncasecmp(
text,
"OFF", 3 ) == 0 )
673 else if( strncasecmp(
text,
"ON", 2 ) == 0 )
722 int mantissaDigits = 0;
723 int characteristicDigits = 0;
734 if( !isdigit( *aText ) )
737 characteristicDigits = *aText -
'0';
745 if( !isdigit( *aText ) )
748 mantissaDigits = *aText -
'0';
765 int iprm =
ReadInt( aText,
false );
768 while( *aText && ( *aText ==
'F' || *aText ==
'S' ) )
777 _(
"Tool definition shape not found" ) ) );
778 else if( *aText !=
'C' )
780 _(
"Tool definition '%c' not supported" ), *aText ) );
792 if( dcode ==
nullptr )
905 char * startline =
text;
920 if( currDcode ==
nullptr && tool_id > 0 )
945 bool success =
false;
952 for(
unsigned ii = 0; ; ii++ )
955 int len = candidate->
m_Name.size();
958 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
1156 tool->
m_Size, not rot_ccw ,
true,
constexpr EDA_IU_SCALE gerbIUScale
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_180
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_0
#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)
Initializes a given GBRITEM so that it can draw a circle which is filled and has no pen border.
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.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::vector< FAB_LAYER_COLOR > dummy
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)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2< double > VECTOR2D