87 static wxPoint
computeCenter(wxPoint aStart, wxPoint aEnd,
int& aRadius,
bool aRotCCW )
91 end.
x = double(aEnd.x - aStart.x);
92 end.
y = double(aEnd.y - aStart.y);
97 if( min_radius <= aRadius )
100 aRadius =
KiROUND( min_radius );
101 center.x = ( aStart.x + aEnd.x + 1 ) / 2;
102 center.y = ( aStart.y + aEnd.y + 1 ) / 2;
112 double seg_angle = end.
Angle();
114 double cX = h_segm.
x/2;
115 double cY1 = sqrt( (
double)aRadius*aRadius - cX*cX );
118 center1 = center1.
Rotate( seg_angle );
119 double arc_angle1 = (end - center1).Angle() - (
VECTOR2D(0.0,0.0) - center1).Angle();
121 center2 = center2.
Rotate( seg_angle );
122 double arc_angle2 = (end - center2).Angle() - (
VECTOR2D(0.0,0.0) - center2).Angle();
126 if( arc_angle1 < 0.0 )
127 arc_angle1 += 2*M_PI;
129 if( arc_angle2 < 0.0 )
130 arc_angle2 += 2*M_PI;
134 if( arc_angle1 > 0.0 )
135 arc_angle1 -= 2*M_PI;
137 if( arc_angle2 > 0.0 )
138 arc_angle2 -= 2*M_PI;
143 if( std::abs( arc_angle1 ) <= M_PI )
154 return center+aStart;
157 extern int ReadInt(
char*& text,
bool aSkipSeparator =
true );
158 extern double ReadDouble(
char*& text,
bool aSkipSeparator =
true );
166 bool aLayerNegative );
170 const wxPoint& aStart,
173 bool aLayerNegative );
176 const wxPoint& aStart,
const wxPoint& aEnd,
177 const wxPoint& aRelCenter, wxSize aPenSize,
178 bool aClockwise,
bool aMultiquadrant,
179 bool aLayerNegative );
252 std::unique_ptr<EXCELLON_IMAGE> drill_layer_uptr = std::make_unique<EXCELLON_IMAGE>( layerId );
259 bool success = drill_layer_uptr->LoadFile( aFullFileName, &nc_defaults );
263 drill_layer_uptr.reset();
264 msg.Printf(
_(
"File %s not found." ), aFullFileName );
271 layerId = images->
AddGbrImage( drill_layer, layerId );
349 if( excellonReader.
ReadLine() == nullptr )
352 char* line = excellonReader.
Line();
401 msg.Printf( wxT(
"Unexpected symbol 0x%2.2X <%c>" ), *
text, *
text );
412 dummy.ParseAttribCmd(
nullptr,
nullptr, 0,
text, dummyline );
428 for(
unsigned ii = 0; ; ii++ )
431 int len = candidate->
m_Name.size();
436 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
446 msg.Printf(
_(
"Unknown Excellon command <%s>" ),
text );
540 if( strncasecmp(
text,
"OFF", 3 ) == 0 )
542 else if( strncasecmp(
text,
"ON", 2 ) == 0 )
591 int mantissaDigits = 0;
592 int characteristicDigits = 0;
603 if( !isdigit( *aText ) )
606 characteristicDigits = *aText -
'0';
614 if( !isdigit( *aText ) )
617 mantissaDigits = *aText -
'0';
634 int iprm =
ReadInt( aText,
false );
637 while( *aText && ( *aText ==
'F' || *aText ==
'S' ) )
646 _(
"Tool definition shape not found" ) ) );
647 else if( *aText !=
'C' )
649 _(
"Tool definition '%c' not supported" ), *aText ) );
661 if( dcode ==
nullptr )
774 char * startline =
text;
789 if( currDcode ==
nullptr && tool_id > 0 )
814 bool success =
false;
821 for(
unsigned ii = 0; ; ii++ )
824 int len = candidate->
m_Name.size();
827 if( candidate->
m_Name.compare( 0, len,
text, len ) == 0 )
1025 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.
int CodeNumber(char *&aText)
Reads the next number and returns the value.
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
bool LoadFile(const wxString &aFullFileName, EXCELLON_DEFAULTS *aDefaults)
Read and load a drill (EXCELLON format) file.
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.
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.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
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 aperture (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)
void SelectUnits(bool aMetric, EXCELLON_DEFAULTS *aDefaults)
Switch unit selection, and the coordinate format (nn:mm) if not yet set.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
D_CODE * GetDCODE(int aDCODE) const
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
Hold the image data and parameters for one gerber file and layer parameters.
wxSize m_FmtLen
Image rotation (0, 90, 180, 270 only) in degrees.
void fillFlashedGBRITEM(GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const wxPoint &aPos, wxSize aSize, bool aLayerNegative)
Initializes a given GBRITEM so that it can draw a circle which is filled and has no pen border.
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)).
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
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...
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
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 )
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
bool Execute_Drill_Command(char *&text)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
bool m_hasFormat
Excellon file do not have a format statement to specify the coordinate format like nn:mm.
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).
#define FMT_MANTISSA_INCH
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.
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
A gerber DCODE (also called Aperture) definition.
void readFileFormat(char *&aText)
Read an Altium-specific FILE_FORMAT=X:X attribute that specifies the length and mantissa of the numbe...
virtual void ResetDefaultValues() override
Set all parameters to a default value, before reading a file.
void FinishRouteCommand()
End a route command started by M15 ot G01, G02 or G03 command.
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number 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".
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).
void GetExcellonDefaults(EXCELLON_DEFAULTS &aNCDefaults)
return the Excellon default values to read a drill file
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
bool Execute_EXCELLON_G_Command(char *&text)
management of default values used to read a Excellon (.nc) drill file Some important parameters are n...
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)
Initialize a given GBRITEM so that it can draw an arc G code.
virtual void ResetDefaultValues()
Set all parameters to a default value, before reading a file.
void fillLineGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const wxPoint &aStart, const wxPoint &aEnd, wxSize aPenSize, bool aLayerNegative)
Initialize 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)
Read an integer from an ASCII character buffer.