33#include <fmt/format.h>
50#define GBR_USE_MACROS_FOR_CHAMFERED_ROUND_RECT
51#define GBR_USE_MACROS_FOR_CHAMFERED_RECT
52#define GBR_USE_MACROS_FOR_ROUNDRECT
53#define GBR_USE_MACROS_FOR_TRAPEZOID
54#define GBR_USE_MACROS_FOR_ROTATED_OVAL
55#define GBR_USE_MACROS_FOR_ROTATED_RECT
56#define GBR_USE_MACROS_FOR_CUSTOM_PAD
65#define GBR_MACRO_FOR_CUSTOM_PAD_MAX_CORNER_COUNT 4990
66#define AM_FREEPOLY_BASENAME "FreePoly"
73static bool polyCompare(
const std::vector<VECTOR2I>& aPolygon,
74 const std::vector<VECTOR2I>& aTestPolygon )
77 if( aTestPolygon.size() != aPolygon.size() )
82 for(
size_t jj = 0; jj < aPolygon.size(); jj++ )
84 if(
std::abs( aPolygon[jj].x - aTestPolygon[jj].x ) > margin ||
85 std::abs( aPolygon[jj].y - aTestPolygon[jj].y ) > margin )
124 double aScale,
bool aMirror )
126 wxASSERT( aMirror ==
false );
129 wxASSERT( aScale == 1 );
210 if( aData ==
nullptr )
219 std::string short_attribute_string;
222 aData, clearDict, useX1StructuredComment ) )
228 if( !short_attribute_string.empty() )
229 fmt::print(
m_outputFile,
"{}", short_attribute_string );
279 "G04 Gerber Fmt {}.{}, Leading zero omitted, Abs format (unit {})*",
288 wxDateTime date = wxDateTime::Now();
289 fmt::println(
m_outputFile,
"G04 Created by KiCad ({}) date {}*",
335 while( fgets( line, 1024,
workFile ) )
339 char* substr = strtok( line,
"\n\r" );
341 if( substr && strcmp( substr,
"G04 APERTURE LIST*" ) == 0 )
348 fmt::println(
m_outputFile,
"G04 Aperture macros list*" );
382 fmt::println(
m_outputFile,
"G04 Aperture macros list end*" );
406 wxASSERT_MSG( aWidth >= 0,
"Plotter called to set negative pen width" );
409 int aperture_attribute = 0;
410 std::string custom_attribute =
"";
418 aperture_attribute, custom_attribute );
425 int aApertureAttribute,
426 const std::string& aCustomAttribute )
431 for(
int idx = 0; idx < (int)
m_apertures.size(); ++idx )
451 new_tool.
m_DCode = last_D_code + 1;
463 int aApertureAttribute,
464 const std::string& aCustomAttribute )
480 for(
int idx = 0; idx < (int)
m_apertures.size(); ++idx )
486 if( ( tool->
m_Type == aType ) && ( tool->
m_Corners.size() == aCorners.size() )
507 new_tool.
m_DCode = last_D_code + 1;
519 const std::string& aCustomAttribute )
537 aApertureAttribute, aCustomAttribute );
545 int aApertureAttribute,
const std::string& aCustomAttribute )
554 for(
size_t ii = 0; ii < aCorners.size(); ii++ )
587 int aperture_attribute = 0;
588 std::string custom_attribute =
"";
596 selectAperture( aSize, aRadius, aAngle, aType, aperture_attribute, custom_attribute );
609 bool useX1StructuredComment =
false;
612 useX1StructuredComment =
true;
624 int attribute = tool.m_ApertureAttribute;
630 useX1StructuredComment, tool.m_CustomAttribute ) );
642 switch( tool.m_Type )
645 fmt::println(
m_outputFile,
"C,{:#f}*%", tool.GetDiameter() * fscale );
650 tool.m_Size.x * fscale,
651 tool.m_Size.y * fscale );
655 fmt::println(
m_outputFile,
"C,{:#f}*%", tool.m_Size.x * fscale );
660 tool.m_Size.x * fscale,
661 tool.m_Size.y * fscale );
676 tool.GetDiameter() * fscale,
677 tool.GetRegPolyVerticeCount(),
678 tool.GetRotation().AsDegrees() );
684 std::vector<VECTOR2I> corners;
685 VECTOR2I half_size( tool.m_Size.x/2-tool.m_Radius, tool.m_Size.y/2-tool.m_Radius );
693 const int min_size_value = 10;
694 half_size.
x = std::max( half_size.
x, min_size_value );
695 half_size.
y = std::max( half_size.
y, min_size_value );
697 corners.emplace_back( -half_size.
x, -half_size.
y );
698 corners.emplace_back( half_size.
x, -half_size.
y );
699 corners.emplace_back( half_size.
x, half_size.
y );
700 corners.emplace_back( -half_size.
x, half_size.
y );
703 for(
int ii = 0; ii < 4; ii++ )
708 tool.m_Radius * fscale );
711 for(
int ii = 0; ii < 4; ii++ )
714 corners[ii].x * fscale,
715 corners[ii].y * fscale );
724 tool.m_Size.x * fscale,
725 tool.m_Size.y * fscale,
726 tool.m_Rotation.AsDegrees() );
734 switch( tool.m_Type )
761 for(
const VECTOR2I& corner : tool.m_Corners)
762 fmt::print(
m_outputFile,
"{:#f}X{:#f}X", corner.
x * fscale, -corner.
y * fscale );
765 fmt::println(
m_outputFile,
"{:#f}*%", tool.m_Rotation.AsDegrees() );
774 int seg_len = tool.m_Size.x - tool.m_Size.y;
785 fmt::println(
m_outputFile,
"{},{:#f}X{:#f}X{:#f}X{:#f}X{:#f}X0*%",
787 tool.m_Size.y * fscale,
788 start.
x * fscale, -start.
y * fscale,
804 tool.m_Rotation.AsDegrees() );
851 std::vector<VECTOR2I> cornerList;
853 cornerList.reserve( 5 );
856 cornerList.push_back( p1 );
859 cornerList.push_back( corner );
860 cornerList.push_back( p2 );
863 cornerList.push_back( corner );
864 cornerList.push_back( p1 );
866 PlotPoly( cornerList, fill, width,
nullptr );
893 EDA_ANGLE endAngle = aStartAngle + aAngle;
896 plotArc( aCenter, aStartAngle, endAngle, aRadius,
false );
940 const EDA_ANGLE& aEndAngle,
double aRadius,
bool aPlotInRegion )
943 start.
x =
KiROUND( aCenter.
x + aRadius * aStartAngle.
Cos() );
944 start.
y =
KiROUND( aCenter.
y + aRadius * aStartAngle.
Sin() );
960 if( aStartAngle > aEndAngle )
978 bool clearTA_AperFunction =
false;
984 if( !attrib.empty() )
987 clearTA_AperFunction =
true;
991 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0 , aGbrMetadata );
994 if( clearTA_AperFunction )
999 fmt::println(
m_outputFile,
"G04 #@! TD.AperFunction*" );
1007 if( aCornerList.size() <= 2 )
1010 bool clearTA_AperFunction =
false;
1016 if( !attrib.empty() )
1019 clearTA_AperFunction =
true;
1023 PlotPoly( aCornerList, FILL_T::FILLED_SHAPE, 0, aGbrMetadata );
1026 if( clearTA_AperFunction )
1031 fmt::println(
m_outputFile,
"G04 #@! TD.AperFunction*" );
1041 if( aWidth || aFill == FILL_T::NO_FILL )
1042 PlotPoly( aPoly, FILL_T::NO_FILL, aWidth, aGbrMetadata );
1044 if( aFill != FILL_T::NO_FILL )
1052 if( aPoly.
CPoints().size() <= 1 )
1063 if( aFill != FILL_T::NO_FILL )
1071 for(
int ii = 1; ii < aPoly.
PointCount(); ii++ )
1073 int arcindex = aPoly.
ArcIndex( ii );
1098 else if( aWidth != 0 )
1104 for(
int ii = 1; ii < aPoly.
PointCount(); ii++ )
1106 int arcindex = aPoly.
ArcIndex( ii );
1127 if( ( aPoly.
CPoint( 0 ) != aPoly.
CPoint( -1 ) ) && ( aPoly.
IsClosed() || aFill != FILL_T::NO_FILL ) )
1138 if( aCornerList.size() <= 1 )
1149 if( aFill != FILL_T::NO_FILL )
1153 MoveTo( aCornerList[0] );
1156 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
1157 LineTo( aCornerList[ii] );
1160 if( aCornerList[0] != aCornerList[aCornerList.size()-1] )
1166 if( aWidth != 0 || aFill == FILL_T::NO_FILL )
1170 MoveTo( aCornerList[0] );
1172 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
1173 LineTo( aCornerList[ii] );
1177 if( aFill != FILL_T::NO_FILL && ( aCornerList[aCornerList.size() - 1] != aCornerList[0] ) )
1178 LineTo( aCornerList[0] );
1196 const EDA_ANGLE& aAngle,
double aRadius,
int aWidth,
void* aData )
1252 VECTOR2I size( diametre, diametre );
1273 std::swap( size.
x, size.
y );
1280#ifdef GBR_USE_MACROS_FOR_ROTATED_OVAL
1288 if( size.
x < size.
y )
1290 std::swap( size.
x, size.
y );
1324 std::swap( size.
x, size.
y );
1330#ifdef GBR_USE_MACROS_FOR_ROTATED_RECT
1348 coord[0].
x = -size.
x/2;
1349 coord[0].
y = size.
y/2;
1350 coord[1].
x = -size.
x/2;
1351 coord[1].
y = -size.
y/2;
1352 coord[2].
x = size.
x/2;
1353 coord[2].
y = -size.
y/2;
1354 coord[3].
x = size.
x/2;
1355 coord[3].
y = size.
y/2;
1364 int aCornerRadius,
const EDA_ANGLE& aOrient,
void* aData )
1369#ifdef GBR_USE_MACROS_FOR_ROUNDRECT
1382 bool clearTA_AperFunction =
false;
1389 if( !attrib.empty() )
1392 clearTA_AperFunction =
true;
1400 if( clearTA_AperFunction )
1405 fmt::println(
m_outputFile,
"G04 #@! TD.AperFunction*" );
1411 int aCornerRadius,
const EDA_ANGLE& aOrient )
1431 int hsizeX = aSize.
x/2;
1432 int hsizeY = aSize.
y/2;
1435 std::vector<RR_EDGE> rr_outline;
1437 rr_outline.reserve( 4 );
1442 curr_edge.m_start.x = -hsizeX;
1443 curr_edge.m_start.y = hsizeY - aCornerRadius;
1444 curr_edge.m_end.x = curr_edge.m_start.x;
1445 curr_edge.m_end.y = -hsizeY + aCornerRadius;
1446 curr_edge.m_center.x = -hsizeX + aCornerRadius;
1447 curr_edge.m_center.y = curr_edge.m_end.y;
1448 curr_edge.m_arc_angle_start = aOrient +
ANGLE_180;
1450 rr_outline.push_back( curr_edge );
1453 curr_edge.m_start.x = -hsizeX + aCornerRadius;
1454 curr_edge.m_start.y = -hsizeY;
1455 curr_edge.m_end.x = hsizeX - aCornerRadius;
1456 curr_edge.m_end.y = curr_edge.m_start.y;
1457 curr_edge.m_center.x = curr_edge.m_end.x;
1458 curr_edge.m_center.y = -hsizeY + aCornerRadius;
1459 curr_edge.m_arc_angle_start = aOrient +
ANGLE_90;
1461 rr_outline.push_back( curr_edge );
1464 curr_edge.m_start.x = hsizeX;
1465 curr_edge.m_start.y = -hsizeY + aCornerRadius;
1466 curr_edge.m_end.x = curr_edge.m_start.x;
1467 curr_edge.m_end.y = hsizeY - aCornerRadius;
1468 curr_edge.m_center.x = hsizeX - aCornerRadius;
1469 curr_edge.m_center.y = curr_edge.m_end.y;
1470 curr_edge.m_arc_angle_start = aOrient +
ANGLE_0;
1472 rr_outline.push_back( curr_edge );
1475 curr_edge.m_start.x = hsizeX - aCornerRadius;
1476 curr_edge.m_start.y = hsizeY;
1477 curr_edge.m_end.x = -hsizeX + aCornerRadius;
1478 curr_edge.m_end.y = curr_edge.m_start.y;
1479 curr_edge.m_center.x = curr_edge.m_end.x;
1480 curr_edge.m_center.y = hsizeY - aCornerRadius;
1481 curr_edge.m_arc_angle_start = aOrient -
ANGLE_90;
1483 rr_outline.push_back( curr_edge );
1489 for( RR_EDGE& rr_edge: rr_outline )
1494 rr_edge.m_start += aRectCenter;
1495 rr_edge.m_end += aRectCenter;
1496 rr_edge.m_center += aRectCenter;
1497 arc_last_center = rr_edge.m_center;
1505 last_pt.
x = arc_last_center.
x +
KiROUND( aCornerRadius * arc_last_angle.
Cos() );
1506 last_pt.
y = arc_last_center.
y -
KiROUND( aCornerRadius * arc_last_angle.
Sin() );
1508 VECTOR2I first_pt = rr_outline[0].m_start;
1511 if( last_pt != first_pt )
1512 wxLogMessage( wxS(
"first pt %d %d last pt %d %d" ),
1513 first_pt.
x, first_pt.
y, last_pt.
x, last_pt.
y );
1521 for( RR_EDGE& rr_edge: rr_outline )
1526 plotArc( rr_edge.m_center, -rr_edge.m_arc_angle_start,
1527 -rr_edge.m_arc_angle_start +
ANGLE_90, aCornerRadius,
true );
1551 std::vector<VECTOR2I> cornerList;
1553 for(
int cnt = 0; cnt < polyshape.
OutlineCount(); ++cnt )
1559 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
1560 cornerList.emplace_back( poly.
CPoint( ii ).
x, poly.
CPoint( ii ).
y );
1563 cornerList.push_back( cornerList[0] );
1565#ifdef GBR_USE_MACROS_FOR_CUSTOM_PAD
1574 for(
size_t ii = 0; ii < cornerList.size(); ii++ )
1576 cornerList[ii] -= aPadPos;
1596 int aCornerRadius,
double aChamferRatio,
1597 int aChamferPositions,
const EDA_ANGLE& aPadOrient,
1607 std::vector<VECTOR2I> cornerList;
1609 bool hasRoundedCorner = aCornerRadius != 0 && aChamferPositions != 15;
1611#ifdef GBR_USE_MACROS_FOR_CHAMFERED_RECT
1617 aCornerRadius, aChamferRatio, aChamferPositions, 0,
1623 for(
int ii = 0; ii < corners.
PointCount(); ii++ )
1624 cornerList.emplace_back( corners.
CPoint( ii ).
x, corners.
CPoint( ii ).
y );
1627 cornerList.push_back( cornerList[0] );
1629#ifdef GBR_USE_MACROS_FOR_CHAMFERED_ROUND_RECT
1638 for(
size_t ii = 0; ii < cornerList.size(); ii++ )
1640 cornerList[ii] -= aShapePos;
1660 aChamferRatio, aChamferPositions, 0,
1667 for(
int ii = 0; ii < corners.
PointCount(); ii++ )
1668 cornerList.emplace_back( corners.
CPoint( ii ).
x, corners.
CPoint( ii ).
y );
1670 switch( cornerList.size() )
1703 wxLogMessage( wxS(
"FlashPadChamferRoundRect(): Unexpected number of corners (%d)" ),
1704 (
int)cornerList.size() );
1715 const EDA_ANGLE& aPadOrient,
void* aData )
1718 std::vector<VECTOR2I> cornerList = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] };
1721 for(
unsigned ii = 0; ii < 4; ii++ )
1724 cornerList[ii] += aPadPos;
1728 cornerList.push_back( cornerList[0] );
1734 metadata = *gbr_metadata;
1737#ifdef GBR_USE_MACROS_FOR_TRAPEZOID
1745 std::vector<VECTOR2I> corners = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] };
1746 int aperture_attribute = 0;
1747 std::string custom_attribute =
"";
1770 int aCornerCount,
const EDA_ANGLE& aOrient,
1778 metadata = *gbr_metadata;
1787 aOrient, apert_type );
1793 const wxString& aText,
1801 bool aMultilineAllowed,
1811 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
1812 aItalic, aBold, aMultilineAllowed, aFont, aFontMetrics, aData );
1818 const wxString& aText,
1829 PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aFontMetrics, aData );
1852 fmt::print( aOutput,
"4,1,{},", (
int)
m_Corners.size() );
1855 int curr_line_corner_count = 0;
1856 const int curr_line_count_max = 20;
1858 for(
size_t ii = 0; ii <=
m_Corners.size(); ii++ )
1866 fmt::print( aOutput,
"{:#f},{:#f},",
1869 if( curr_line_count_max >= 0 && ++curr_line_corner_count >= curr_line_count_max )
1871 fmt::println( aOutput,
"" );
1872 curr_line_corner_count = 0;
1877 fmt::println( aOutput,
"$1*%" );
1883 for(
int idx = 0; idx <
AmCount(); idx++ )
1896 for(
int idx = 0; idx <
AmCount(); idx++ )
1898 if(
m_AMList[idx].IsSamePoly( aPolygon ) )
#define GBR_MACRO_FOR_CUSTOM_PAD_MAX_CORNER_COUNT
static bool polyCompare(const std::vector< VECTOR2I > &aPolygon, const std::vector< VECTOR2I > &aTestPolygon)
#define AM_FREEPOLY_BASENAME
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString GetBuildVersion()
Get the full KiCad version string.
std::vector< VECTOR2I > m_Corners
std::string m_CustomAttribute
std::vector< APER_MACRO_FREEPOLY > m_AMList
void Append(const std::vector< VECTOR2I > &aPolygon)
append a new APER_MACRO_FREEPOLY containing the polygon aPolygon to the current list
int FindAm(const std::vector< VECTOR2I > &aPolygon) const
void Format(FILE *aOutput, double aIu2GbrMacroUnit)
print the aperture macro list to aOutput
void Format(FILE *aOutput, double aIu2GbrMacroUnit)
print the aperture macro definition to aOutput
bool IsSamePoly(const std::vector< VECTOR2I > &aPolygon) const
std::vector< VECTOR2I > m_Corners
bool IsCardinal90() const
virtual void FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, void *aData) override
bool m_hasApertureRotRect
std::string m_objectAttributesDictionary
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData) override
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false) override
Selection of Gerber units and resolution (number of digits in mantissa).
void FlashPadChamferRoundRect(const VECTOR2I &aShapePos, const VECTOR2I &aPadSize, int aCornerRadius, double aChamferRatio, int aChamferPositions, const EDA_ANGLE &aPadOrient, void *aData)
Flash a chamfered round rect pad.
void ClearAllAttributes()
Remove (clear) all attributes from object attributes dictionary (TO.
bool m_hasApertureRotOval
int GetOrCreateAperture(const VECTOR2I &aSize, int aRadius, const EDA_ANGLE &aRotation, APERTURE::APERTURE_TYPE aType, int aApertureAttribute, const std::string &aCustomAttribute)
virtual void ThickPoly(const SHAPE_POLY_SET &aPoly, int aWidth, void *aData) override
void PlotPolyAsRegion(const SHAPE_LINE_CHAIN &aPoly, FILL_T aFill, int aWidth, GBR_METADATA *aGbrMetadata)
Similar to PlotPoly(), plot a filled polygon using Gerber region, therefore adding X2 attributes to t...
virtual void FlashPadCircle(const VECTOR2I &pos, int diametre, void *aData) override
Filled circular flashes are stored as apertures.
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, void *aData) override
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
void selectAperture(const VECTOR2I &aSize, int aRadius, const EDA_ANGLE &aRotation, APERTURE::APERTURE_TYPE aType, int aApertureAttribute, const std::string &aCustomAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
void emitDcode(const VECTOR2D &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate.
virtual void FlashRegularPolygon(const VECTOR2I &aShapePos, int aDiameter, int aCornerCount, const EDA_ANGLE &aOrient, void *aData) override
Flash a regular polygon.
APER_MACRO_FREEPOLY_LIST m_am_freepoly_list
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, void *aData) override
std::vector< APERTURE > m_apertures
bool m_hasApertureChamferedRect
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, void *aData) override
Flash a trapezoidal pad.
bool m_hasApertureOutline4P
virtual void SetCurrentLineWidth(int aLineWidth, void *aData=nullptr) override
Set the line width for the next drawing.
void writeApertureList()
Generate the table of D codes.
void plotRoundRectAsRegion(const VECTOR2I &aRectCenter, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient)
Plot a round rect (a round rect shape in fact) as a Gerber region using lines and arcs for corners.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width) override
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth) override
bool m_hasApertureRoundRect
bool m_gerberDisableApertMacros
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool EndPlot() override
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width) override
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
Print a Gerber net attribute object record.
void selectApertureWithAttributes(const VECTOR2I &aPos, GBR_METADATA *aGbrMetadata, VECTOR2I aSize, int aRadius, const EDA_ANGLE &aAngle, APERTURE::APERTURE_TYPE aType)
Pick an aperture or create a new one and emits the DCode.
virtual void ThickRect(const VECTOR2I &p1, const VECTOR2I &p2, int width, void *aData) override
virtual void SetLayerPolarity(bool aPositive) override
Change the plot polarity and begin a new layer.
void PlotGerberRegion(const std::vector< VECTOR2I > &aCornerList, GBR_METADATA *aGbrMetadata)
Plot a Gerber region: similar to PlotPoly but plot only filled polygon, and add the TA....
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, SHAPE_POLY_SET *aPolygons, void *aData) override
virtual void EndBlock(void *aData) override
Define the end of a group of drawing items the group is started by StartBlock().
void clearNetAttribute()
Clear a Gerber net attribute record (clear object attribute dictionary) and output the clear object a...
virtual void StartBlock(void *aData) override
Calling this function allows one to define the beginning of a group of drawing items (used in X2 form...
virtual void ThickArc(const VECTOR2D &aCentre, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, int aWidth, void *aData) override
virtual bool StartPlot(const wxString &pageNumber) override
Write GERBER header to file initialize global variable g_Plot_PlotOutputFile.
virtual void FilledCircle(const VECTOR2I &pos, int diametre, void *aData) override
void plotArc(const VECTOR2I &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, double aRadius, bool aPlotInRegion)
Plot a Gerber arc.
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, void *aData) override
FONT is an abstract base class for both outline and stroke fonts.
A color representation with 4 components: red, green, blue, alpha.
int GetDefaultPenWidth() const
void SetDefaultPenWidth(int aWidth)
wxArrayString m_headerExtraLines
virtual void ThickPoly(const SHAPE_POLY_SET &aPoly, int aWidth, void *aData)
static const int USE_DEFAULT_LINE_WIDTH
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
virtual void polyArc(const VECTOR2D &aCentre, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth)
Generic fallback: arc rendered as a polyline.
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
virtual void ThickArc(const EDA_SHAPE &aArcShape, void *aData, int aWidth)
int GetPlotterArcHighDef() const
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
FILE * m_outputFile
Output file.
void LineTo(const VECTOR2I &pos)
static const int DO_NOT_SET_LINE_WIDTH
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData)
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
virtual void ThickRect(const VECTOR2I &p1, const VECTOR2I &p2, int width, void *aData)
RENDER_SETTINGS * m_renderSettings
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Draw text with the plotter.
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, void *aData)
virtual int GetCurrentLineWidth() const
const VECTOR2I & GetArcMid() const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
const VECTOR2I & GetCenter() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_ARC & Arc(size_t aArc) const
bool IsClosed() const override
int PointCount() const
Return the number of points (vertices) in this line chain.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
specialized plotter for GERBER files format
#define APER_MACRO_OUTLINE6P_NAME
#define APER_MACRO_OUTLINE4P_NAME
#define APER_MACRO_OUTLINE4P_HEADER
#define APER_MACRO_OUTLINE6P_HEADER
#define APER_MACRO_ROT_RECT_HEADER
#define APER_MACRO_OUTLINE8P_HEADER
#define APER_MACRO_SHAPE_OVAL_HEADER
#define APER_MACRO_ROT_RECT_NAME
#define APER_MACRO_SHAPE_OVAL_NAME
#define APER_MACRO_OUTLINE5P_HEADER
#define APER_MACRO_OUTLINE5P_NAME
#define APER_MACRO_ROUNDRECT_HEADER
#define APER_MACRO_OUTLINE8P_NAME
#define APER_MACRO_OUTLINE7P_HEADER
#define APER_MACRO_ROUNDRECT_NAME
#define APER_MACRO_OUTLINE7P_NAME
This file contains miscellaneous commonly used macros and functions.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
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