129#define IU_PER_MILS ( m_IUsPerDecimil * 10 )
155 EDA_ANGLE startAngle( aStart - aCenter );
159 double det = ( aEnd - aStart ).Cross( aMid - aStart );
169 double radius = ( aStart - aCenter ).EuclideanNorm();
170 Arc( aCenter, startAngle, angle, radius, aFill, aWidth );
175 double aRadius,
FILL_T aFill,
int aWidth )
177 polyArc( aCenter, aStartAngle, aAngle, aRadius, aFill, aWidth );
185 EDA_ANGLE endAngle = startAngle + aAngle;
191 std::swap( startAngle, endAngle );
195 start.
x =
KiROUND( aCenter.
x + aRadius * startAngle.
Cos() );
198 if( aFill != FILL_T::NO_FILL )
210 end.
x =
KiROUND( aCenter.
x + aRadius * ii.Cos() );
215 end.
x =
KiROUND( aCenter.
x + aRadius * endAngle.
Cos() );
218 if( aFill != FILL_T::NO_FILL )
232 int aTolerance,
int aLineThickness )
236 std::vector<VECTOR2I> ctrlPoints;
237 ctrlPoints.reserve( 4 );
239 ctrlPoints.push_back( aStart );
240 ctrlPoints.push_back( aControl1 );
241 ctrlPoints.push_back( aControl2 );
242 ctrlPoints.push_back( aEnd );
246 std::vector<VECTOR2I> approxPoints;
247 bezier_converter.
GetPoly( approxPoints, aTolerance );
252 for(
unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
253 LineTo( approxPoints[ii] );
261 VECTOR2I size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
264 start.
x -= size.
x / 2;
265 start.
y -= size.
y / 2;
271 Rect( start, end, FILL_T::NO_FILL );
277 double r =
KiROUND( radius / 1.4142 );
278 std::vector<VECTOR2I> corner_list;
281 corner_list.reserve( 4 );
283 corner.
x = position.
x + r;
284 corner.
y = position.
y + r;
285 corner_list.push_back( corner );
286 corner.
x = position.
x + r;
287 corner.
y = position.
y - r;
288 corner_list.push_back( corner );
289 corner.
x = position.
x - r;
290 corner.
y = position.
y - r;
291 corner_list.push_back( corner );
292 corner.
x = position.
x - r;
293 corner.
y = position.
y + r;
294 corner_list.push_back( corner );
295 corner.
x = position.
x + r;
296 corner.
y = position.
y + r;
297 corner_list.push_back( corner );
311 std::vector<VECTOR2I> corner_list;
314 corner_list.reserve( 4 );
316 corner.
x = position.
x;
317 corner.
y = position.
y + radius;
318 corner_list.push_back( corner );
319 corner.
x = position.
x + radius;
320 corner.
y = position.
y,
321 corner_list.push_back( corner );
322 corner.
x = position.
x;
323 corner.
y = position.
y - radius;
324 corner_list.push_back( corner );
325 corner.
x = position.
x - radius;
326 corner.
y = position.
y;
327 corner_list.push_back( corner );
328 corner.
x = position.
x;
329 corner.
y = position.
y + radius;
330 corner_list.push_back( corner );
366 int radius = diametre / 2;
376 static const unsigned char marker_patterns[
MARKER_COUNT] = {
460 unsigned char pat = marker_patterns[aShapeId];
489 VECTOR2I center( ( start.
x + end.
x ) / 2, ( start.
y + end.
y ) / 2 );
497 FlashPadOval( center, size, orient, aTraceMode,
nullptr );
509 if( size.
x > size.
y )
511 std::swap( size.
x, size.
y );
515 int deltaxy = size.
y - size.
x;
516 int radius = size.
x / 2;
520 std::vector<VECTOR2I> corners;
521 corners.reserve( 6 );
526 int half_height = deltaxy / 2;
527 corners.emplace_back( -radius, -half_height );
528 corners.emplace_back( -radius, half_height );
529 corners.emplace_back( 0, half_height );
530 corners.emplace_back( radius, half_height );
531 corners.emplace_back( radius, -half_height );
532 corners.emplace_back( 0, -half_height );
535 for(
size_t ii = 0; ii < corners.size(); ii++ )
545 Arc( corners[2], -orient,
ANGLE_180, radius, FILL_T::NO_FILL );
550 Arc( corners[5], -orient, -
ANGLE_180, radius, FILL_T::NO_FILL );
561 Circle( start, width, FILL_T::FILLED_SHAPE, 0 );
579 const EDA_ANGLE& aAngle,
double aRadius,
int aWidth,
582 if( aTraceMode ==
FILLED )
584 Arc( centre, aStartAngle, aAngle, aRadius, FILL_T::NO_FILL, aWidth );
590 FILL_T::NO_FILL, -1 );
592 FILL_T::NO_FILL, -1 );
610 double det = ( end - start ).Cross( mid - start );
617 double radius = ( start - center ).EuclideanNorm();
619 ThickArc( center, startAngle, angle, radius, aWidth, aTraceMode, aData );
628 Rect( p1, p2, FILL_T::NO_FILL, width );
637 Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
642 Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
652 Circle( pos, diametre, FILL_T::NO_FILL, width );
667 Circle( pos, diametre, FILL_T::FILLED_SHAPE, 0 );
672 Circle( pos, diametre, FILL_T::NO_FILL, -1 );
679 std::vector<VECTOR2I> cornerList;
680 cornerList.reserve( aCornerList.
PointCount() );
682 for(
int ii = 0; ii < aCornerList.
PointCount(); ii++ )
683 cornerList.emplace_back( aCornerList.
CPoint( ii ) );
685 if( aCornerList.
IsClosed() && cornerList.front() != cornerList.back() )
686 cornerList.emplace_back( aCornerList.
CPoint( 0 ) );
688 PlotPoly( cornerList, aFill, aWidth, aData );
694 const wxString& aText,
702 bool aMultilineAllowed,
711 if( aPenWidth == 0 && aBold )
715 aPenWidth = -aPenWidth;
729 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
734 attributes.m_StrokeWidth = aPenWidth;
735 attributes.m_Italic = aItalic;
736 attributes.m_Bold = aBold;
737 attributes.m_Halign = aH_justify;
738 attributes.m_Valign = aV_justify;
739 attributes.m_Size = aSize;
742 if( attributes.m_Size.x < 0 )
744 attributes.m_Size.
x = -attributes.m_Size.x;
745 attributes.m_Mirrored =
true;
751 aFont->
Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
756 const wxString& aText,
770 if( penWidth == 0 && attributes.
m_Bold )
774 penWidth = -penWidth;
789 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
795 aFont->
Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMaxError=10)
Convert a Bezier curve to a polygon.
EDA_ANGLE NormalizeNegative()
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.
VECTOR2I GetArcMid() const
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, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) 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 ThickArc(const EDA_SHAPE &aArcShape, OUTLINE_MODE aTraceMode, void *aData, int aWidth)
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 Arc(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH)
virtual void FilledCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
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 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 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)
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.
PLOTTER(const PROJECT *aProject=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 ).
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)
void markerLozenge(const VECTOR2I &position, int radius)
Plot a lozenge centered on the position.
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 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
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
Container for project specific data.
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.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
int GetPenSizeForBold(int aTextSize)
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.
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D