89 end.x = double(aEnd.
x - aStart.
x);
90 end.y = double(aEnd.
y - aStart.
y);
93 double min_radius =
end.EuclideanNorm() / 2;
95 if( min_radius >= aRadius )
98 aRadius =
KiROUND( min_radius );
99 center.x = ( aStart.
x + aEnd.
x + 1 ) / 2;
100 center.y = ( aStart.
y + aEnd.
y + 1 ) / 2;
113 double cX = h_segm.
x/2;
114 double cY1 = sqrt( (
double)aRadius*aRadius - cX*cX );
156extern int ReadInt(
char*&
text,
bool aSkipSeparator =
true );
157extern double ReadDouble(
char*&
text,
bool aSkipSeparator =
true );
165 bool aLayerNegative );
172 bool aLayerNegative );
182 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 );
348 bool foundM48 =
false;
349 bool foundM30 =
false;
350 bool foundPercent =
false;
355 FILE* file = wxFopen( aFullFileName,
"rb" );
357 if( file ==
nullptr )
366 if( excellonReader.
ReadLine() ==
nullptr )
377 size_t len = strlen( line );
379 for(
size_t i = 0; i < len; i++ )
381 if( !isascii( line[i] ) )
387 char* buf = strstr( line,
";" );
392 if( strstr( line,
"M48" ) )
396 if( strstr( line,
"M30" ) )
401 if( strcmp( line,
"%" ) == 0 )
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 )
489 if( excellonReader.
ReadLine() ==
nullptr )
492 char* line = excellonReader.
Line();
545 msg.Printf( wxT(
"Unexpected symbol 0x%2.2X <%c>" ), *
text, *
text );
556 dummy.ParseAttribCmd(
nullptr,
nullptr, 0,
text, dummyline );
572 for(
unsigned ii = 0; ; ii++ )
575 int len = candidate->
m_Name.size();
580 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
592 for(
unsigned ii = 0; ; ii++ )
595 int len = candidate->
m_Name.size();
600 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
611 msg.Printf(
_(
"Unknown Excellon command <%s>" ),
text );
712 if( strncasecmp(
text,
"OFF", 3 ) == 0 )
714 else if( strncasecmp(
text,
"ON", 2 ) == 0 )
763 int mantissaDigits = 0;
764 int characteristicDigits = 0;
775 if( !isdigit( *aText ) )
778 characteristicDigits = *aText -
'0';
786 if( !isdigit( *aText ) )
789 mantissaDigits = *aText -
'0';
792 if( mantissaDigits > 8 )
810 int iprm =
ReadInt( aText,
false );
813 while( *aText && ( *aText ==
'F' || *aText ==
'S' ) )
822 _(
"Tool definition shape not found" ) ) );
823 else if( *aText !=
'C' )
825 _(
"Tool definition '%c' not supported" ), *aText ) );
837 if( dcode ==
nullptr )
841 double conv_scale =
gerbIUScale.IU_PER_MILS * 1000;
968 for(
int ii = 0; ii < count; ++ii )
989 char * startline =
text;
1004 if( currDcode ==
nullptr && tool_id > 0 )
1022 return tool_id >= 0;
1029 bool success =
false;
1036 for(
unsigned ii = 0; ; ii++ )
1039 int len = candidate->
m_Name.size();
1042 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
1244 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 )
static bool IsValidDcodeValue(int aDcodeValue)
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
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, INFOBAR_MESSAGE_TYPE aType=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 KIGFX::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 Execute_Repeat_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
A value ( = radius in circular routing in Excellon files ).
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
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.
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.
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_G_DRILL_IN_HEADER
@ 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 excellonAcceptedIHeaderUnusualCmdList[]
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
static wxString From_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
This file contains miscellaneous commonly used macros and functions.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
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)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D