93 static wxPoint
computeCenter(wxPoint aStart, wxPoint aEnd,
int& aRadius,
bool aRotCCW )
97 end.
x = double(aEnd.x - aStart.x);
98 end.
y = double(aEnd.y - aStart.y);
103 if( min_radius <= aRadius )
106 aRadius =
KiROUND( min_radius );
107 center.x = ( aStart.x + aEnd.x + 1 ) / 2;
108 center.y = ( aStart.y + aEnd.y + 1 ) / 2;
118 double seg_angle = end.
Angle();
120 double cX = h_segm.
x/2;
121 double cY1 = sqrt( (
double)aRadius*aRadius - cX*cX );
124 center1 = center1.
Rotate( seg_angle );
125 double arc_angle1 = (end - center1).Angle() - (
VECTOR2D(0.0,0.0) - center1).Angle();
127 center2 = center2.
Rotate( seg_angle );
128 double arc_angle2 = (end - center2).Angle() - (
VECTOR2D(0.0,0.0) - center2).Angle();
132 if( arc_angle1 < 0.0 )
133 arc_angle1 += 2*M_PI;
135 if( arc_angle2 < 0.0 )
136 arc_angle2 += 2*M_PI;
140 if( arc_angle1 > 0.0 )
141 arc_angle1 -= 2*M_PI;
143 if( arc_angle2 > 0.0 )
144 arc_angle2 -= 2*M_PI;
149 if( std::abs( arc_angle1 ) <= M_PI )
160 return center+aStart;
163 extern int ReadInt(
char*& text,
bool aSkipSeparator =
true );
164 extern double ReadDouble(
char*& text,
bool aSkipSeparator =
true );
172 bool aLayerNegative );
176 const wxPoint& aStart,
179 bool aLayerNegative );
182 const wxPoint& aStart,
const wxPoint& aEnd,
183 const wxPoint& aRelCenter, wxSize aPenSize,
184 bool aClockwise,
bool aMultiquadrant,
185 bool aLayerNegative );
249 auto gerber_layer = images->
GetGbrImage( layerId );
258 bool success = drill_layer->
LoadFile( aFullFileName );
263 msg.Printf(
_(
"File %s not found." ), aFullFileName );
268 layerId = images->
AddGbrImage( drill_layer, layerId );
328 if( excellonReader.
ReadLine() == 0 )
331 char* line = excellonReader.
Line();
334 if( *text ==
';' || *text == 0 )
375 msg.Printf(
"Unexpected symbol 0x%2.2X <%c>", *text, *text );
402 for(
unsigned ii = 0; ; ii++ )
405 int len = candidate->
m_Name.size();
410 if( candidate->
m_Name.compare( 0, len, text, len ) == 0 )
420 msg.Printf(
_(
"Unknown Excellon command <%s>" ), text );
508 if( strncasecmp( text,
"OFF", 3 ) == 0 )
510 else if( strncasecmp( text,
"ON", 2 ) == 0 )
566 int iprm =
ReadInt( aText,
false );
569 while( *aText && ( *aText ==
'F' || *aText ==
'S' ) )
578 _(
"Tool definition shape not found" ) ) );
579 else if( *aText !=
'C' )
581 _(
"Tool definition '%c' not supported" ), *aText ) );
623 if( *text ==
'I' || *text ==
'J' )
706 char * startline = text;
720 if( currDcode ==
NULL && tool_id > 0 )
741 bool success =
false;
748 for(
unsigned ii = 0; ; ii++ )
751 int len = candidate->
m_Name.size();
754 if( candidate->
m_Name.compare( 0, len, text, len ) == 0 )
811 if( *text ==
'I' || *text ==
'J' )
824 if( *text ==
'I' || *text ==
'J' )
924 tool->
m_Size, not rot_ccw ,
true,
static EXCELLON_CMD excellon_G_CmdList[]
X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF....
void AddMessageToList(const wxString &aMessage)
Add a message to the message list.
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
char * Line() const
Return a pointer to the last line that was read in.
X2_ATTRIBUTE The attribute value consists of a number of substrings separated by a comma.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
virtual void ResetDefaultValues() override
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
GERBER_DRAW_ITEMS & GetItems()
wxSize m_Size
Horizontal and vertical dimensions.
wxPoint ReadIJCoord(char *&Text)
Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
bool m_InUse
false if the aperure (previously defined) is not used to draw something
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
static EXCELLON_CMD excellonHeaderCmdList[]
static wxPoint computeCenter(wxPoint aStart, wxPoint aEnd, int &aRadius, bool aRotCCW)
static const int fmtMantissaInch
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
static const int fmtIntegerInch
D_CODE * GetDCODE(int aDCODE) const
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
wxSize m_FmtLen
Image rotation (0, 90, 180, 270 only) in degrees.
static const int fmtMantissaMM
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
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 ...
void ClearMessageList()
Clear the message list.
bool Select_Tool(char *&text)
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.
An abstract base class for deriving all objects that can be added to a VIEW.
void Erase_Current_DrawLayer(bool query)
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
wxSize m_FmtScale
< Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
This file contains miscellaneous commonly used macros and functions.
int m_ArcRadius
Identifier for arc data type (IJ (center) or A## (radius)).
bool LoadFile(const wxString &aFullFileName)
Read and load a drill (EXCELLON format) file.
bool m_Defined
false if the aperture is not defined in the header
A LINE_READER that reads from an open file.
void AddItemToList(GERBER_DRAW_ITEM *aItem)
Add a new GERBER_DRAW_ITEM item to the drawings list.
bool Execute_HEADER_And_M_Command(char *&text)
VECTOR2< double > VECTOR2D
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
APERTURE_T
Enum APERTURE_T is the set of all gerber aperture types allowed, according to page 16 of http://gerbv...
const wxArrayString & GetMessages() const
void ListSet(const wxString &aList)
Add a list of items.
int m_Num_Dcode
D code value ( >= 10 )
static const int fmtIntegerMM
bool Execute_Drill_Command(char *&text)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
bool m_Relative
< false = absolute Coord, true = relative Coord.
double Angle() const
Compute the angle of the vector.
wxPoint ReadXYCoord(char *&aText, bool aExcellonMode=false)
Return the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm).
GBR_LAYOUT * GetGerberLayout() const
bool m_Has_DCode
< True if has DCodes in file or false if no DCodes found. Perhaps deprecated RS274D file.
static const char file_attribute[]
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
int TCodeNumber(char *&aText)
bool readToolInformation(char *&aText)
Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 and enter params in TCODE list.
int GetActiveLayer() const
Return the active layer.
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
D_CODE holds a gerber DCODE (also called Aperture) definition.
void FinishRouteCommand()
Ends a route command started by M15 ot G01, G02 or G03 command.
double ReadDouble(char *&text, bool aSkipSeparator=true)
Function ReadDouble reads a double from an ASCII character buffer.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
std::vector< EXCELLON_ROUTE_COORD > m_RoutePositions
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
bool Execute_EXCELLON_G_Command(char *&text)
void SelectUnits(bool aMetric)
void StepAndRepeatItem(const GERBER_DRAW_ITEM &aItem)
Gerber format has a command Step an Repeat.
D_CODE * GetDCODEOrCreate(int aDCODE, bool aCreateIfNoExist=true)
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
void fillArcGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &aRelCenter, wxSize aPenSize, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Function fillArcGBRITEM initializes a given GBRITEM so that it can draw an arc G code.
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.
bool Read_EXCELLON_File(const wxString &aFullFileName)
int ReadInt(char *&text, bool aSkipSeparator=true)
Function ReadInt reads an int from an ASCII character buffer.