130 #define IU_PER_MILS ( m_IUsPerDecimil * 10 ) 158 void PLOTTER::Arc(
const wxPoint& centre,
double StAngle,
double EndAngle,
int radius,
162 const int delta = 50;
164 if( StAngle > EndAngle )
165 std::swap( StAngle, EndAngle );
183 for(
int ii = StAngle +
delta; ii < EndAngle; ii +=
delta )
206 const wxPoint& aControl2,
const wxPoint& aEnd,
207 int aTolerance,
int aLineThickness )
210 int minSegLen = aLineThickness;
212 std::vector<wxPoint> ctrlPoints;
213 ctrlPoints.push_back( aStart );
214 ctrlPoints.push_back( aControl1 );
215 ctrlPoints.push_back( aControl2 );
216 ctrlPoints.push_back( aEnd );
220 std::vector<wxPoint> approxPoints;
221 bezier_converter.
GetPoly( approxPoints, minSegLen );
226 for(
unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
227 LineTo( approxPoints[ii] );
235 wxSize size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
237 wxPoint start = aPos;
238 start.x -= size.x / 2;
239 start.y -= size.y / 2;
251 double r =
KiROUND( radius / 1.4142 );
252 std::vector< wxPoint > corner_list;
254 corner.x = position.x +
r;
255 corner.y = position.y +
r;
256 corner_list.push_back( corner );
257 corner.x = position.x +
r;
258 corner.y = position.y -
r;
259 corner_list.push_back( corner );
260 corner.x = position.x -
r;
261 corner.y = position.y -
r;
262 corner_list.push_back( corner );
263 corner.x = position.x -
r;
264 corner.y = position.y +
r;
265 corner_list.push_back( corner );
266 corner.x = position.x +
r;
267 corner.y = position.y +
r;
268 corner_list.push_back( corner );
282 std::vector< wxPoint > corner_list;
284 corner.x = position.x;
285 corner.y = position.y + radius;
286 corner_list.push_back( corner );
287 corner.x = position.x + radius;
288 corner.y = position.y,
289 corner_list.push_back( corner );
290 corner.x = position.x;
291 corner.y = position.y - radius;
292 corner_list.push_back( corner );
293 corner.x = position.x - radius;
294 corner.y = position.y;
295 corner_list.push_back( corner );
296 corner.x = position.x;
297 corner.y = position.y + radius;
298 corner_list.push_back( corner );
306 MoveTo( wxPoint( pos.x - radius, pos.y ) );
307 FinishTo( wxPoint( pos.x + radius, pos.y ) );
313 MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
314 FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
320 MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
321 FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
327 MoveTo( wxPoint( pos.x, pos.y - radius ) );
328 FinishTo( wxPoint( pos.x, pos.y + radius ) );
334 int radius = diametre / 2;
344 static const unsigned char marker_patterns[
MARKER_COUNT] = {
428 unsigned char pat = marker_patterns[aShapeId];
457 wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
458 wxSize size( end.x - start.x, end.y - start.y );
463 else if( size.x == 0 )
471 FlashPadOval( center, size, orient, tracemode,
nullptr );
479 int radius, deltaxy, cx, cy;
480 wxSize size( aSize );
482 if( size.x > size.y )
484 std::swap( size.x, size.y );
488 deltaxy = size.y - size.x;
493 MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
497 FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
502 MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
506 FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
511 Arc( wxPoint( cx + pos.x, cy + pos.y ), orient + 1800, orient + 3600, radius,
FILL_T::NO_FILL );
515 Arc( wxPoint( cx + pos.x, cy + pos.y ), orient, orient + 1800, radius,
FILL_T::NO_FILL );
544 int radius,
int width,
OUTLINE_MODE tracemode,
void* aData )
617 std::vector<wxPoint> cornerList;
618 cornerList.reserve( aCornerList.
PointCount() );
620 for(
int ii = 0; ii < aCornerList.
PointCount(); ii++ )
621 cornerList.emplace_back( aCornerList.
CPoint( ii ) );
623 if( aCornerList.
IsClosed() && cornerList.front() != cornerList.back() )
624 cornerList.emplace_back( aCornerList.
CPoint( 0 ) );
626 PlotPoly( cornerList, aFill, aWidth, aData );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
void segmentAsOval(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode)
Convert a thick segment and plot it as an oval.
void FinishTo(const wxPoint &pos)
double GetDotMarkLenIU() const
void markerHBar(const wxPoint &pos, int radius)
Plot a - bar centered on the position.
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
virtual void ThickCircle(const wxPoint &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData)
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Convert a Bezier curve to a polygon.
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map).
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
FILE * m_outputFile
Output file.
virtual void ThickRect(const wxPoint &p1, const wxPoint &p2, int width, OUTLINE_MODE tracemode, void *aData)
virtual void FilledCircle(const wxPoint &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
virtual void BezierCurve(const wxPoint &aStart, const wxPoint &aControl1, const wxPoint &aControl2, const wxPoint &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...
double GetStartAngle() const
void RotatePoint(int *pX, int *pY, double angle)
int PointCount() const
Return the number of points (vertices) in this line chain.
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData)
double GetDashGapLenIU() const
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
virtual int GetCurrentLineWidth() const
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
void LineTo(const wxPoint &pos)
bool IsClosed() const override
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
constexpr double dot_mark_len(double aLineWidth)
Dashed and dotted line patterns.
RENDER_SETTINGS * m_renderSettings
a few functions useful in geometry calculations.
constexpr double dash_gap_len(double aLineWidth)
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify size according to the plotter scale factors (wxSize version, returns a DPOINT).
double GetEndAngle() const
void markerSlash(const wxPoint &pos, int radius)
Plot a / bar centered on the position.
void Marker(const wxPoint &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
void MoveTo(const wxPoint &pos)
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Bezier curves to polygon converter.
virtual void PlotImage(const wxImage &aImage, const wxPoint &aPos, double aScaleFactor)
Only PostScript plotters can plot bitmaps.
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
double GetDashMarkLenIU() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void markerLozenge(const wxPoint &position, int radius)
Plot a lozenge centered on the position.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
void markerCircle(const wxPoint &pos, int radius)
Plot a circle centered on the position.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void ThickArc(const wxPoint ¢re, double StAngle, double EndAngle, int rayon, int width, OUTLINE_MODE tracemode, void *aData)
virtual void Arc(const wxPoint ¢re, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
double ArcTangente(int dy, int dx)
void markerVBar(const wxPoint &pos, int radius)
Plot a | bar centered on the position.
void markerSquare(const wxPoint &position, int radius)
Plot a square centered on the position.
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void markerBackSlash(const wxPoint &pos, int radius)
Plot a \ bar centered on the position.
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
VECTOR2I GetCenter() const
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
constexpr double dash_mark_len(double aLineWidth)
bool m_mirrorIsHorizontal