49#define GBR_USE_MACROS_FOR_CHAMFERED_ROUND_RECT
50#define GBR_USE_MACROS_FOR_CHAMFERED_RECT
51#define GBR_USE_MACROS_FOR_ROUNDRECT
52#define GBR_USE_MACROS_FOR_TRAPEZOID
53#define GBR_USE_MACROS_FOR_ROTATED_OVAL
54#define GBR_USE_MACROS_FOR_ROTATED_RECT
55#define GBR_USE_MACROS_FOR_CUSTOM_PAD
64#define GBR_MACRO_FOR_CUSTOM_PAD_MAX_CORNER_COUNT 4990
65#define AM_FREEPOLY_BASENAME "FreePoly"
72static bool polyCompare(
const std::vector<VECTOR2I>& aPolygon,
73 const std::vector<VECTOR2I>& aTestPolygon )
76 if( aTestPolygon.size() != aPolygon.size() )
81 for(
size_t jj = 0; jj < aPolygon.size(); jj++ )
83 if(
std::abs( aPolygon[jj].x - aTestPolygon[jj].x ) > margin ||
84 std::abs( aPolygon[jj].y - aTestPolygon[jj].y ) > margin )
123 double aScale,
bool aMirror )
125 wxASSERT( aMirror ==
false );
128 wxASSERT( aScale == 1 );
209 if( aData ==
nullptr )
218 std::string short_attribute_string;
221 aData, clearDict, useX1StructuredComment ) )
227 if( !short_attribute_string.empty() )
278 "G04 Gerber Fmt %d.%d, Leading zero omitted, Abs format (unit %s)*\n",
287 wxDateTime date = wxDateTime::Now();
288 fprintf(
m_outputFile,
"G04 Created by KiCad (%s) date %s*\n",
334 while( fgets( line, 1024,
workFile ) )
338 char* substr = strtok( line,
"\n\r" );
340 if( substr && strcmp( substr,
"G04 APERTURE LIST*" ) == 0 )
381 fputs(
"G04 Aperture macros list end*\n",
m_outputFile );
405 wxASSERT_MSG( aWidth >= 0,
"Plotter called to set negative pen width" );
411 aperture_attribute );
418 int aApertureAttribute )
423 for(
int idx = 0; idx < (int)
m_apertures.size(); ++idx )
428 if( (tool->
m_Type == aType) && (tool->
m_Size == aSize) &&
440 new_tool.
m_DCode = last_D_code + 1;
451 int aApertureAttribute )
467 for(
int idx = 0; idx < (int)
m_apertures.size(); ++idx )
473 if( (tool->
m_Type == aType) &&
474 (tool->
m_Corners.size() == aCorners.size() ) &&
494 new_tool.
m_DCode = last_D_code + 1;
519 aApertureAttribute );
527 int aApertureAttribute )
536 for(
size_t ii = 0; ii < aCorners.size(); ii++ )
553 aApertureAttribute );
578 bool useX1StructuredComment =
false;
581 useX1StructuredComment =
true;
593 int attribute = tool.m_ApertureAttribute;
611 switch( tool.m_Type )
614 fprintf(
m_outputFile,
"C,%#f*%%\n", tool.GetDiameter() * fscale );
618 fprintf(
m_outputFile,
"R,%#fX%#f*%%\n", tool.m_Size.x * fscale,
619 tool.m_Size.y * fscale );
623 fprintf(
m_outputFile,
"C,%#f*%%\n", tool.m_Size.x * fscale );
627 fprintf(
m_outputFile,
"O,%#fX%#f*%%\n", tool.m_Size.x * fscale,
628 tool.m_Size.y * fscale );
642 fprintf(
m_outputFile,
"P,%#fX%dX%#f*%%\n", tool.GetDiameter() * fscale,
643 tool.GetRegPolyVerticeCount(), tool.GetRotation().AsDegrees() );
649 std::vector<VECTOR2I> corners;
650 VECTOR2I half_size( tool.m_Size.x/2-tool.m_Radius, tool.m_Size.y/2-tool.m_Radius );
658 const int min_size_value = 10;
659 half_size.
x = std::max( half_size.
x, min_size_value );
660 half_size.
y = std::max( half_size.
y, min_size_value );
662 corners.emplace_back( -half_size.
x, -half_size.
y );
663 corners.emplace_back( half_size.
x, -half_size.
y );
664 corners.emplace_back( half_size.
x, half_size.
y );
665 corners.emplace_back( -half_size.
x, half_size.
y );
668 for(
int ii = 0; ii < 4; ii++ )
674 for(
int ii = 0; ii < 4; ii++ )
676 fprintf(
m_outputFile,
"%#fX%#fX", corners[ii].x * fscale, corners[ii].y * fscale );
685 tool.m_Size.x * fscale, tool.m_Size.y * fscale, tool.m_Rotation.AsDegrees() );
693 switch( tool.m_Type )
717 for(
size_t ii = 0; ii < tool.m_Corners.size(); ii++ )
719 fprintf(
m_outputFile,
"%#fX%#fX", tool.m_Corners[ii].x * fscale,
720 -tool.m_Corners[ii].y * fscale );
724 fprintf(
m_outputFile,
"%#f*%%\n", tool.m_Rotation.AsDegrees() );
733 int seg_len = tool.m_Size.x - tool.m_Size.y;
745 tool.m_Size.y * fscale,
746 start.
x * fscale, -start.
y * fscale,
747 end.
x * fscale, -end.
y * fscale );
760 tool.m_Rotation.AsDegrees() );
807 std::vector<VECTOR2I> cornerList;
809 cornerList.reserve( 5 );
812 cornerList.push_back( p1 );
815 cornerList.push_back( corner );
816 cornerList.push_back( p2 );
819 cornerList.push_back( corner );
820 cornerList.push_back( p1 );
822 PlotPoly( cornerList, fill, width );
845 polyArc( aCenter, aStartAngle, aAngle, aRadius, aFill, aWidth );
849 EDA_ANGLE endAngle = aStartAngle + aAngle;
852 plotArc( aCenter, aStartAngle, endAngle, aRadius,
false );
896 const EDA_ANGLE& aEndAngle,
double aRadius,
bool aPlotInRegion )
899 start.
x =
KiROUND( aCenter.
x + aRadius * aStartAngle.
Cos() );
900 start.
y =
KiROUND( aCenter.
y + aRadius * aStartAngle.
Sin() );
907 end.
x =
KiROUND( aCenter.
x + aRadius * aEndAngle.
Cos() );
908 end.
y =
KiROUND( aCenter.
y + aRadius * aEndAngle.
Sin() );
916 if( aStartAngle > aEndAngle )
934 bool clearTA_AperFunction =
false;
940 if( !attrib.empty() )
943 clearTA_AperFunction =
true;
947 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0 , aGbrMetadata );
950 if( clearTA_AperFunction )
967 if( aCornerList.size() <= 2 )
970 bool clearTA_AperFunction =
false;
976 if( !attrib.empty() )
979 clearTA_AperFunction =
true;
983 PlotPoly( aCornerList, FILL_T::FILLED_SHAPE, 0, aGbrMetadata );
986 if( clearTA_AperFunction )
1005 if( aWidth || aFill == FILL_T::NO_FILL )
1006 PlotPoly( aPoly, FILL_T::NO_FILL, aWidth, aGbrMetadata );
1008 if( aFill != FILL_T::NO_FILL )
1016 if( aPoly.
CPoints().size() <= 1 )
1027 if( aFill != FILL_T::NO_FILL )
1035 for(
int ii = 1; ii < aPoly.
PointCount(); ii++ )
1037 int arcindex = aPoly.
ArcIndex( ii );
1063 if( aWidth > 0 || aFill == FILL_T::NO_FILL )
1069 for(
int ii = 1; ii < aPoly.
PointCount(); ii++ )
1071 int arcindex = aPoly.
ArcIndex( ii );
1093 && ( aPoly.
IsClosed() || aFill != FILL_T::NO_FILL ) )
1104 if( aCornerList.size() <= 1 )
1115 if( aFill != FILL_T::NO_FILL )
1119 MoveTo( aCornerList[0] );
1122 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
1123 LineTo( aCornerList[ii] );
1126 if( aCornerList[0] != aCornerList[aCornerList.size()-1] )
1132 if( aWidth > 0 || aFill == FILL_T::NO_FILL )
1136 MoveTo( aCornerList[0] );
1138 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
1139 LineTo( aCornerList[ii] );
1143 if( aFill != FILL_T::NO_FILL && ( aCornerList[aCornerList.size() - 1] != aCornerList[0] ) )
1144 LineTo( aCornerList[0] );
1154 if( tracemode ==
FILLED )
1174 const EDA_ANGLE& aAngle,
double aRadius,
int aWidth,
1183 if( aTraceMode ==
FILLED )
1207 if( tracemode ==
FILLED )
1218 Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
1237 if( tracemode ==
FILLED )
1262 if( tracemode ==
FILLED )
1280 VECTOR2I size( diametre, diametre );
1283 if( trace_mode ==
SKETCH )
1321 std::swap( size.
x, size.
y );
1335 if( aTraceMode ==
FILLED )
1337 #ifdef GBR_USE_MACROS_FOR_ROTATED_OVAL
1345 if( size.
x < size.
y )
1347 std::swap( size.
x, size.
y );
1373 if( size.
x > size.
y )
1375 std::swap( size.
x, size.
y );
1404 std::swap( size.
x, size.
y );
1406 if( aTraceMode ==
SKETCH )
1413 VECTOR2I( pos.
x + ( size.
x / 2 ), pos.
y + (size.
y / 2 ) ),
1430 #ifdef GBR_USE_MACROS_FOR_ROTATED_RECT
1454 coord[0].
x = -size.
x/2;
1455 coord[0].
y = size.
y/2;
1456 coord[1].
x = -size.
x/2;
1457 coord[1].
y = -size.
y/2;
1458 coord[2].
x = size.
x/2;
1459 coord[2].
y = -size.
y/2;
1460 coord[3].
x = size.
x/2;
1461 coord[3].
y = size.
y/2;
1470 int aCornerRadius,
const EDA_ANGLE& aOrient,
1476 if( aTraceMode !=
FILLED )
1484 std::vector<VECTOR2I> cornerList;
1490 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
1491 cornerList.emplace_back( poly.
CPoint( ii ).
x, poly.
CPoint( ii ).
y );
1494 cornerList.push_back( cornerList[0] );
1501 #ifdef GBR_USE_MACROS_FOR_ROUNDRECT
1521 bool clearTA_AperFunction =
false;
1528 if( !attrib.empty() )
1531 clearTA_AperFunction =
true;
1539 if( clearTA_AperFunction )
1551 int aCornerRadius,
const EDA_ANGLE& aOrient )
1571 int hsizeX = aSize.
x/2;
1572 int hsizeY = aSize.
y/2;
1575 std::vector<RR_EDGE> rr_outline;
1577 rr_outline.reserve( 4 );
1582 curr_edge.m_start.x = -hsizeX;
1583 curr_edge.m_start.y = hsizeY - aCornerRadius;
1584 curr_edge.m_end.x = curr_edge.m_start.x;
1585 curr_edge.m_end.y = -hsizeY + aCornerRadius;
1586 curr_edge.m_center.x = -hsizeX + aCornerRadius;
1587 curr_edge.m_center.y = curr_edge.m_end.y;
1588 curr_edge.m_arc_angle_start = aOrient +
ANGLE_180;
1590 rr_outline.push_back( curr_edge );
1593 curr_edge.m_start.x = -hsizeX + aCornerRadius;
1594 curr_edge.m_start.y = -hsizeY;
1595 curr_edge.m_end.x = hsizeX - aCornerRadius;
1596 curr_edge.m_end.y = curr_edge.m_start.y;
1597 curr_edge.m_center.x = curr_edge.m_end.x;
1598 curr_edge.m_center.y = -hsizeY + aCornerRadius;
1599 curr_edge.m_arc_angle_start = aOrient +
ANGLE_90;
1601 rr_outline.push_back( curr_edge );
1604 curr_edge.m_start.x = hsizeX;
1605 curr_edge.m_start.y = -hsizeY + aCornerRadius;
1606 curr_edge.m_end.x = curr_edge.m_start.x;
1607 curr_edge.m_end.y = hsizeY - aCornerRadius;
1608 curr_edge.m_center.x = hsizeX - aCornerRadius;
1609 curr_edge.m_center.y = curr_edge.m_end.y;
1610 curr_edge.m_arc_angle_start = aOrient +
ANGLE_0;
1612 rr_outline.push_back( curr_edge );
1615 curr_edge.m_start.x = hsizeX - aCornerRadius;
1616 curr_edge.m_start.y = hsizeY;
1617 curr_edge.m_end.x = -hsizeX + aCornerRadius;
1618 curr_edge.m_end.y = curr_edge.m_start.y;
1619 curr_edge.m_center.x = curr_edge.m_end.x;
1620 curr_edge.m_center.y = hsizeY - aCornerRadius;
1621 curr_edge.m_arc_angle_start = aOrient -
ANGLE_90;
1623 rr_outline.push_back( curr_edge );
1629 for( RR_EDGE& rr_edge: rr_outline )
1634 rr_edge.m_start += aRectCenter;
1635 rr_edge.m_end += aRectCenter;
1636 rr_edge.m_center += aRectCenter;
1637 arc_last_center = rr_edge.m_center;
1645 last_pt.
x = arc_last_center.
x +
KiROUND( aCornerRadius * arc_last_angle.
Cos() );
1646 last_pt.
y = arc_last_center.
y -
KiROUND( aCornerRadius * arc_last_angle.
Sin() );
1648 VECTOR2I first_pt = rr_outline[0].m_start;
1651 if( last_pt != first_pt )
1652 wxLogMessage( wxS(
"first pt %d %d last pt %d %d" ),
1653 first_pt.
x, first_pt.
y, last_pt.
x, last_pt.
y );
1661 for( RR_EDGE& rr_edge: rr_outline )
1666 plotArc( rr_edge.m_center, -rr_edge.m_arc_angle_start,
1667 -rr_edge.m_arc_angle_start +
ANGLE_90, aCornerRadius,
true );
1692 if( aTraceMode !=
FILLED )
1697 std::vector<VECTOR2I> cornerList;
1699 for(
int cnt = 0; cnt < polyshape.
OutlineCount(); ++cnt )
1705 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
1706 cornerList.emplace_back( poly.
CPoint( ii ).
x, poly.
CPoint( ii ).
y );
1709 cornerList.push_back( cornerList[0] );
1711 if( aTraceMode ==
SKETCH )
1717#ifdef GBR_USE_MACROS_FOR_CUSTOM_PAD
1727 for(
size_t ii = 0; ii < cornerList.size(); ii++ )
1729 cornerList[ii] -= aPadPos;
1749 int aCornerRadius,
double aChamferRatio,
1750 int aChamferPositions,
const EDA_ANGLE& aPadOrient,
1761 std::vector<VECTOR2I> cornerList;
1763 bool hasRoundedCorner = aCornerRadius != 0 && aChamferPositions != 15;
1765#ifdef GBR_USE_MACROS_FOR_CHAMFERED_RECT
1771 aCornerRadius, aChamferRatio, aChamferPositions, 0,
1777 for(
int ii = 0; ii < corners.
PointCount(); ii++ )
1778 cornerList.emplace_back( corners.
CPoint( ii ).
x, corners.
CPoint( ii ).
y );
1781 cornerList.push_back( cornerList[0] );
1783 if( aPlotMode ==
SKETCH )
1789#ifdef GBR_USE_MACROS_FOR_CHAMFERED_ROUND_RECT
1798 for(
size_t ii = 0; ii < cornerList.size(); ii++ )
1800 cornerList[ii] -= aShapePos;
1820 aChamferRatio, aChamferPositions, 0,
1827 for(
int ii = 0; ii < corners.
PointCount(); ii++ )
1828 cornerList.emplace_back( corners.
CPoint( ii ).
x, corners.
CPoint( ii ).
y );
1830 switch( cornerList.size() )
1863 wxLogMessage( wxS(
"FlashPadChamferRoundRect(): Unexpected number of corners (%d)" ),
1864 (
int)cornerList.size() );
1880 std::vector<VECTOR2I> cornerList = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] };
1883 for(
unsigned ii = 0; ii < 4; ii++ )
1886 cornerList[ii] += aPadPos;
1890 cornerList.push_back( cornerList[0] );
1896 metadata = *gbr_metadata;
1898 if( aTraceMode ==
SKETCH )
1905 #ifdef GBR_USE_MACROS_FOR_TRAPEZOID
1913 std::vector<VECTOR2I> corners = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] };
1929 int aCornerCount,
const EDA_ANGLE& aOrient,
1937 metadata = *gbr_metadata;
1939 if( aTraceMode ==
SKETCH )
1942 std::vector<VECTOR2I> cornerList;
1946 for(
int ii = 0; ii < aCornerCount; ii++ )
1948 EDA_ANGLE rot = aOrient + ( angle_delta * ii );
1949 VECTOR2I vertice( aDiameter / 2, 0 );
1952 vertice += aShapePos;
1953 cornerList.push_back( vertice );
1956 cornerList.push_back( cornerList[0] );
1967 selectAperture( aDiameter, aOrient, apert_type, aperture_attrib );
1979 const wxString& aText,
1987 bool aMultilineAllowed,
1997 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
1998 aItalic, aBold, aMultilineAllowed, aFont, aFontMetrics, aData );
2004 const wxString& aText,
2015 PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aFontMetrics, aData );
2038 fprintf( aOutput,
"4,1,%d,", (
int)
m_Corners.size() );
2041 int curr_line_corner_count = 0;
2042 const int curr_line_count_max = 20;
2044 for(
size_t ii = 0; ii <=
m_Corners.size(); ii++ )
2052 fprintf( aOutput,
"%#f,%#f,",
2055 if( curr_line_count_max >= 0 && ++curr_line_corner_count >= curr_line_count_max )
2057 fprintf( aOutput,
"\n" );
2058 curr_line_corner_count = 0;
2063 fputs(
"$1*%\n", aOutput );
2069 for(
int idx = 0; idx <
AmCount(); idx++ )
2082 for(
int idx = 0; idx <
AmCount(); idx++ )
2084 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::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 Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
bool m_hasApertureRotRect
std::string m_objectAttributesDictionary
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false) override
Selection of Gerber units and resolution (number of digits in mantissa).
virtual void ThickArc(const VECTOR2D &aCentre, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, int aWidth, OUTLINE_MODE aTraceMode, void *aData) override
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData) override
void ClearAllAttributes()
Remove (clear) all attributes from object attributes dictionary (TO.
void selectAperture(const VECTOR2I &aSize, int aRadius, const EDA_ANGLE &aRotation, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
bool m_hasApertureRotOval
int GetOrCreateAperture(const VECTOR2I &aSize, int aRadius, const EDA_ANGLE &aRotation, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
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 PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
void emitDcode(const VECTOR2D &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate.
APER_MACRO_FREEPOLY_LIST m_am_freepoly_list
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual void FlashPadCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
std::vector< APERTURE > m_apertures
bool m_hasApertureChamferedRect
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, 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 FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
void FlashPadChamferRoundRect(const VECTOR2I &aShapePos, const VECTOR2I &aPadSize, int aCornerRadius, double aChamferRatio, int aChamferPositions, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aPlotMode, void *aData)
Flash a chamfered round rect pad.
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
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
Print a Gerber net attribute object record.
virtual void SetLayerPolarity(bool aPositive) override
Change the plot polarity and begin a new layer.
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
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 EndBlock(void *aData) override
Define the end of a group of drawing items the group is started by StartBlock().
virtual void ThickRect(const VECTOR2I &p1, const VECTOR2I &p2, int width, OUTLINE_MODE tracemode, void *aData) override
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
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 FlashRegularPolygon(const VECTOR2I &aShapePos, int aDiameter, int aCornerCount, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a regular polygon.
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, OUTLINE_MODE tracemode, void *aData) override
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) 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.
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
static const int USE_DEFAULT_LINE_WIDTH
virtual void polyArc(const VECTOR2D &aCentre, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
void sketchOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, 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 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)
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.
void segmentAsOval(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode)
Convert a thick segment and plot it as an oval.
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_270
static constexpr EDA_ANGLE ANGLE_360
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