128#define IU_PER_MILS ( m_IUsPerDecimil * 10 )
150 FILL_T aFill,
int aWidth,
int aMaxError )
152 EDA_ANGLE startAngle( aStart - aCenter );
156 if( startAngle > endAngle )
167 std::swap( startAngle, endAngle );
168 startAngle = -startAngle;
169 endAngle = -endAngle;
171 Arc( aCenter, startAngle, endAngle, radius, aFill, aWidth );
184 if( startAngle > endAngle )
185 std::swap( startAngle, endAngle );
189 start.
x = aCenter.
x +
KiROUND( aRadius * startAngle.
Cos() );
204 end.
x = aCenter.
x +
KiROUND( aRadius * ii.Cos() );
209 end.
x = aCenter.
x +
KiROUND( aRadius * endAngle.
Cos() );
226 int aTolerance,
int aLineThickness )
229 int minSegLen = aLineThickness;
231 std::vector<VECTOR2I> ctrlPoints;
232 ctrlPoints.reserve( 4 );
234 ctrlPoints.push_back( aStart );
235 ctrlPoints.push_back( aControl1 );
236 ctrlPoints.push_back( aControl2 );
237 ctrlPoints.push_back( aEnd );
241 std::vector<VECTOR2I> approxPoints;
242 bezier_converter.
GetPoly( approxPoints, minSegLen );
247 for(
unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
248 LineTo( approxPoints[ii] );
256 VECTOR2I size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
259 start.
x -= size.
x / 2;
260 start.
y -= size.
y / 2;
272 double r =
KiROUND( radius / 1.4142 );
273 std::vector<VECTOR2I> corner_list;
276 corner_list.reserve( 4 );
278 corner.
x = position.
x + r;
279 corner.
y = position.
y + r;
280 corner_list.push_back( corner );
281 corner.
x = position.
x + r;
282 corner.
y = position.
y - r;
283 corner_list.push_back( corner );
284 corner.
x = position.
x - r;
285 corner.
y = position.
y - r;
286 corner_list.push_back( corner );
287 corner.
x = position.
x - r;
288 corner.
y = position.
y + r;
289 corner_list.push_back( corner );
290 corner.
x = position.
x + r;
291 corner.
y = position.
y + r;
292 corner_list.push_back( corner );
306 std::vector<VECTOR2I> corner_list;
309 corner_list.reserve( 4 );
311 corner.
x = position.
x;
312 corner.
y = position.
y + radius;
313 corner_list.push_back( corner );
314 corner.
x = position.
x + radius;
315 corner.
y = position.
y,
316 corner_list.push_back( corner );
317 corner.
x = position.
x;
318 corner.
y = position.
y - radius;
319 corner_list.push_back( corner );
320 corner.
x = position.
x - radius;
321 corner.
y = position.
y;
322 corner_list.push_back( corner );
323 corner.
x = position.
x;
324 corner.
y = position.
y + radius;
325 corner_list.push_back( corner );
361 int radius = diametre / 2;
371 static const unsigned char marker_patterns[
MARKER_COUNT] = {
455 unsigned char pat = marker_patterns[aShapeId];
484 VECTOR2I center( ( start.
x + end.
x ) / 2, ( start.
y + end.
y ) / 2 );
492 FlashPadOval( center, size, orient, aTraceMode,
nullptr );
504 if( size.
x > size.
y )
506 std::swap( size.
x, size.
y );
510 int deltaxy = size.
y - size.
x;
511 int radius = size.
x / 2;
515 std::vector<VECTOR2I> corners;
516 corners.reserve( 6 );
521 int half_height = deltaxy / 2;
522 corners.emplace_back( -radius, -half_height );
523 corners.emplace_back( -radius, half_height );
524 corners.emplace_back( 0, half_height );
525 corners.emplace_back( radius, half_height );
526 corners.emplace_back( radius, -half_height );
527 corners.emplace_back( 0, -half_height );
530 for(
size_t ii = 0; ii < corners.size(); ii++ )
574 const EDA_ANGLE& aEndAngle,
int aRadius,
int aWidth,
577 if( aTraceMode ==
FILLED )
596 if( aTraceMode ==
FILLED )
606 VECTOR2I start = ( aStart - aCentre ).Resize( new_radius ) + aCentre;
607 VECTOR2I end = ( aEnd - aCentre ).Resize( new_radius ) + aCentre;
612 start = ( aStart - aCentre ).Resize( new_radius ) + aCentre;
613 end = ( aEnd - aCentre ).Resize( new_radius ) + aCentre;
624 aArcShape.
GetWidth(), aTraceMode, aData );
684 std::vector<VECTOR2I> cornerList;
685 cornerList.reserve( aCornerList.
PointCount() );
687 for(
int ii = 0; ii < aCornerList.
PointCount(); ii++ )
688 cornerList.emplace_back( aCornerList.
CPoint( ii ) );
690 if( aCornerList.
IsClosed() && cornerList.front() != cornerList.back() )
691 cornerList.emplace_back( aCornerList.
CPoint( 0 ) );
693 PlotPoly( cornerList, aFill, aWidth, aData );
699 const wxString& aText,
707 bool aMultilineAllowed,
716 if( aPenWidth == 0 && aBold )
720 aPenWidth = -aPenWidth;
738 attributes.m_StrokeWidth = aPenWidth;
739 attributes.m_Italic = aItalic;
740 attributes.m_Bold = aBold;
741 attributes.m_Halign = aH_justify;
742 attributes.m_Valign = aV_justify;
743 attributes.m_Size = aSize;
746 if( attributes.m_Size.x < 0 )
748 attributes.m_Size.
x = -attributes.m_Size.x;
749 attributes.m_Mirrored =
true;
755 aFont->
Draw( &callback_gal, aText, aPos, attributes );
759 const wxString& aText,
772 if( penWidth == 0 && attributes.
m_Bold )
776 penWidth = -penWidth;
797 aFont->
Draw( &callback_gal, aText, aPos, attributes );
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
VECTOR2I getCenter() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
A color representation with 4 components: red, green, blue, alpha.
double GetGapLength(int aLineWidth) const
double GetDotLength(int aLineWidth) const
double GetDashLength(int aLineWidth) const
double GetDotMarkLenIU(int aLineWidth) const
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
virtual void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor)
Only PostScript plotters can plot bitmaps.
virtual void ThickRect(const VECTOR2I &p1, const VECTOR2I &p2, int width, OUTLINE_MODE tracemode, void *aData)
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData)
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map).
double GetDashGapLenIU(int aLineWidth) const
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
bool m_mirrorIsHorizontal
virtual void FilledCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
void MoveTo(const VECTOR2I &pos)
virtual void Arc(const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aEnd, FILL_T aFill, int aWidth, int aMaxError)
Generic fallback: arc rendered as a polyline.
void markerSlash(const VECTOR2I &pos, int radius)
Plot a / bar centered on the position.
void FinishTo(const VECTOR2I &pos)
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness=USE_DEFAULT_LINE_WIDTH)
Generic fallback: Cubic Bezier curve rendered as a polyline In KiCad the bezier curves have 4 control...
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
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, void *aData=nullptr)
Draw text with the plotter.
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
void sketchOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, int aWidth)
int GetPlotterArcHighDef() const
void Marker(const VECTOR2I &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
void markerHBar(const VECTOR2I &pos, int radius)
Plot a - bar centered on the position.
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
void markerCircle(const VECTOR2I &pos, int radius)
Plot a circle centered on the position.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
FILE * m_outputFile
Output file.
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void LineTo(const VECTOR2I &pos)
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
void markerLozenge(const VECTOR2I &position, int radius)
Plot a lozenge centered on the position.
RENDER_SETTINGS * m_renderSettings
void markerBackSlash(const VECTOR2I &pos, int radius)
Plot a \ bar centered on the position.
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
void segmentAsOval(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode)
Convert a thick segment and plot it as an oval.
void markerVBar(const VECTOR2I &pos, int radius)
Plot a | bar centered on the position.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void ThickArc(const VECTOR2I &aCentre, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, OUTLINE_MODE aTraceMode, void *aData)
void markerSquare(const VECTOR2I &position, int radius)
Plot a square centered on the position.
virtual int GetCurrentLineWidth() const
double GetDashMarkLenIU(int aLineWidth) const
virtual void SetColor(const COLOR4D &color)=0
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
static constexpr EDA_ANGLE & ANGLE_180
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_90
static constexpr EDA_ANGLE & ANGLE_0
int GetPenSizeForBold(int aTextSize)
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
double EuclideanNorm(const VECTOR2I &vector)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2< double > VECTOR2D