127#define IU_PER_MILS ( m_IUsPerDecimil * 10 )
153 EDA_ANGLE startAngle( aStart - aCenter );
157 double det = ( aEnd - aStart ).Cross( aMid - aStart );
167 double radius = ( aStart - aCenter ).EuclideanNorm();
168 Arc( aCenter, startAngle, angle,
radius, aFill, aWidth );
173 double aRadius,
FILL_T aFill,
int aWidth )
175 polyArc( aCenter, aStartAngle, aAngle, aRadius, aFill, aWidth );
183 EDA_ANGLE endAngle = startAngle + aAngle;
189 std::swap( startAngle, endAngle );
193 start.
x =
KiROUND( aCenter.
x + aRadius * startAngle.
Cos() );
230 int aTolerance,
int aLineThickness )
233 std::vector<VECTOR2I> ctrlPoints;
234 ctrlPoints.reserve( 4 );
236 ctrlPoints.push_back( aStart );
237 ctrlPoints.push_back( aControl1 );
238 ctrlPoints.push_back( aControl2 );
239 ctrlPoints.push_back( aEnd );
243 std::vector<VECTOR2I> approxPoints;
244 bezier_converter.
GetPoly( approxPoints, aTolerance );
249 for(
unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
250 LineTo( approxPoints[ii] );
258 VECTOR2I size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
261 start.
x -= size.
x / 2;
262 start.
y -= size.
y / 2;
275 std::vector<VECTOR2I> corner_list;
278 corner_list.reserve( 4 );
280 corner.
x = position.
x + r;
281 corner.
y = position.
y + r;
282 corner_list.push_back( corner );
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 );
308 std::vector<VECTOR2I> corner_list;
311 corner_list.reserve( 4 );
313 corner.
x = position.
x;
315 corner_list.push_back( corner );
317 corner.
y = position.
y,
318 corner_list.push_back( corner );
319 corner.
x = position.
x;
321 corner_list.push_back( corner );
323 corner.
y = position.
y;
324 corner_list.push_back( corner );
325 corner.
x = position.
x;
327 corner_list.push_back( corner );
363 int radius = diametre / 2;
373 static const unsigned char marker_patterns[
MARKER_COUNT] = {
457 unsigned char pat = marker_patterns[aShapeId];
484 int aWidth,
void* aData )
491 if( size.
x > size.
y )
493 std::swap( size.
x, size.
y );
497 int deltaxy = size.
y - size.
x;
502 std::vector<VECTOR2I> corners;
503 corners.reserve( 6 );
508 int half_height = deltaxy / 2;
509 corners.emplace_back( -
radius, -half_height );
510 corners.emplace_back( -
radius, half_height );
511 corners.emplace_back( 0, half_height );
512 corners.emplace_back(
radius, half_height );
513 corners.emplace_back(
radius, -half_height );
514 corners.emplace_back( 0, -half_height );
545 int diameter = width;
557 wxCHECK2_MSG( diameter >= 0,
return,
558 wxT(
"Plotter called with unresolved line width sentinel" ) );
572 const EDA_ANGLE& aAngle,
double aRadius,
int aWidth,
void* aData )
590 double det = (
end - start ).Cross( mid - start );
629 std::vector<VECTOR2I> cornerList;
630 cornerList.reserve( aLineChain.
PointCount() );
632 for(
int ii = 0; ii < aLineChain.
PointCount(); ii++ )
633 cornerList.emplace_back( aLineChain.
CPoint( ii ) );
635 if( aLineChain.
IsClosed() && cornerList.front() != cornerList.back() )
636 cornerList.emplace_back( aLineChain.
CPoint( 0 ) );
638 PlotPoly( cornerList, aFill, aWidth, aData );
644 const wxString& aText,
652 bool aMultilineAllowed,
658 wxString
text( aText );
660 if(
text.Contains( wxS(
"@{" ) ) )
668 if( aPenWidth == 0 && aBold )
672 aPenWidth = -aPenWidth;
691 attributes.m_StrokeWidth = aPenWidth;
692 attributes.m_Italic = aItalic;
693 attributes.m_Bold = aBold;
694 attributes.m_Halign = aH_justify;
695 attributes.m_Valign = aV_justify;
696 attributes.m_Size = aSize;
699 if( attributes.m_Size.x < 0 )
701 attributes.m_Size.x = -attributes.m_Size.x;
702 attributes.m_Mirrored =
true;
708 aFont->
Draw( &callback_gal,
text, aPos, attributes, aFontMetrics );
714 const wxString& aText,
721 wxString
text( aText );
723 if(
text.Contains( wxS(
"@{" ) ) )
735 if( penWidth == 0 && attributes.
m_Bold )
739 penWidth = -penWidth;
760 aFont->
Draw( &callback_gal,
text, 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
High-level wrapper for evaluating mathematical and string expressions in wxString format.
wxString Evaluate(const wxString &aInput)
Main evaluation function - processes input string and evaluates all} expressions.
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, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr) const
Draw a string.
A color representation with 4 components: red, green, blue, alpha.
double GetDotMarkLenIU(int aLineWidth) const
virtual void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor)
Only PostScript plotters can plot bitmaps.
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map).
double GetDashGapLenIU(int aLineWidth) const
const PROJECT * m_project
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
bool m_mirrorIsHorizontal
virtual void ThickPoly(const SHAPE_POLY_SET &aPoly, int aWidth, void *aData)
static const int USE_DEFAULT_LINE_WIDTH
virtual void FilledCircle(const VECTOR2I &pos, int diametre, void *aData)
void MoveTo(const VECTOR2I &pos)
virtual void ThickOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, int aWidth, void *aData)
void markerSlash(const VECTOR2I &pos, int radius)
Plot a / bar centered on the position.
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 VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
virtual void ThickArc(const EDA_SHAPE &aArcShape, void *aData, int aWidth)
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0)=0
void Marker(const VECTOR2I &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness)
Generic fallback: Cubic Bezier curve rendered as a polyline.
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)
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)
void markerLozenge(const VECTOR2I &position, int radius)
Plot a lozenge centered on the position.
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData)=0
Draw a polygon ( filled or not ).
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.
void markerBackSlash(const VECTOR2I &pos, int radius)
Plot a \ bar centered on the position.
void markerVBar(const VECTOR2I &pos, int radius)
Plot a | bar centered on the position.
void markerSquare(const VECTOR2I &position, int radius)
Plot a square centered on the position.
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, void *aData)
virtual int GetCurrentLineWidth() const
double GetDashMarkLenIU(int aLineWidth) const
virtual void SetColor(const COLOR4D &color)=0
virtual void Arc(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd, FILL_T aFill, int aWidth)
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.
Represent a set of closed polygons.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
@ FILLED_SHAPE
Fill with object color.
int GetPenSizeForBold(int aTextSize)
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.
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