KiCad PCB EDA Suite
PDF_PLOTTER Class Reference

#include <plotters_pslike.h>

Inheritance diagram for PDF_PLOTTER:
PSLIKE_PLOTTER PLOTTER

Classes

struct  OUTLINE_NODE
 

Public Member Functions

 PDF_PLOTTER ()
 
virtual PLOT_FORMAT GetPlotterType () const override
 Returns the effective plot engine in use. More...
 
virtual bool OpenFile (const wxString &aFullFilename) override
 Open or create the plot file aFullFilename. More...
 
virtual bool StartPlot (const wxString &aPageNumber) override
 The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be closed and reopened. More...
 
virtual bool StartPlot (const wxString &aPageNumber, const wxString &aPageName=wxEmptyString)
 
virtual bool EndPlot () override
 
virtual void StartPage (const wxString &aPageNumber, const wxString &aPageName=wxEmptyString)
 Start a new page in the PDF document. More...
 
virtual void ClosePage ()
 Close the current page in the PDF document (and emit its compressed stream). More...
 
virtual void SetCurrentLineWidth (int width, void *aData=nullptr) override
 Pen width setting for PDF. More...
 
virtual void SetDash (int aLineWidth, PLOT_DASH_TYPE aLineStyle) override
 PDF supports dashed lines. More...
 
virtual void SetViewport (const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
 PDF can have multiple pages, so SetPageSettings can be called with the outputFile open (but not inside a page stream!) More...
 
virtual void Rect (const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
 Rectangles in PDF. More...
 
virtual void Circle (const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
 Circle drawing for PDF. More...
 
virtual void Arc (const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aEnd, FILL_T aFill, int aWidth, int aMaxError) override
 The PDF engine can't directly plot arcs so we use polygonization. More...
 
virtual void PlotPoly (const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
 Polygon plotting for PDF. More...
 
virtual void PenTo (const VECTOR2I &pos, char plume) override
 Moveto/lineto primitive, moves the 'pen' to the specified direction. More...
 
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=false, KIFONT::FONT *aFont=nullptr, void *aData=nullptr) override
 Draw text with the plotter. More...
 
virtual void PlotText (const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr) override
 
void HyperlinkBox (const BOX2I &aBox, const wxString &aDestinationURL) override
 Create a clickable hyperlink with a rectangular click area. More...
 
void HyperlinkMenu (const BOX2I &aBox, const std::vector< wxString > &aDestURLs) override
 Create a clickable hyperlink menu with a rectangular click area. More...
 
void Bookmark (const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString) override
 Create a bookmark to a symbol. More...
 
void PlotImage (const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor) override
 PDF images are handles as inline, not XObject streams... More...
 
virtual void SetTextMode (PLOT_TEXT_MODE mode) override
 PS and PDF fully implement native text (for the Latin-1 subset) More...
 
void SetScaleAdjust (double scaleX, double scaleY)
 Set the 'fine' scaling for the postscript engine. More...
 
virtual void FlashPadCircle (const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadOval (const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadRect (const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadRoundRect (const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadCustom (const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadTrapez (const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
 Flash a trapezoidal pad. More...
 
virtual void FlashRegularPolygon (const VECTOR2I &aShapePos, int aDiameter, int aCornerCount, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
 Flash a regular polygon. More...
 
virtual void SetColor (const COLOR4D &color) override
 The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values, the subclass emits the operator to actually do it. More...
 
virtual void SetNegative (bool aNegative)
 
virtual void SetColorMode (bool aColorMode)
 Plot in B/W or color. More...
 
bool GetColorMode () const
 
void SetRenderSettings (RENDER_SETTINGS *aSettings)
 
RENDER_SETTINGSRenderSettings ()
 
virtual void SetPageSettings (const PAGE_INFO &aPageSettings)
 
PAGE_INFOPageSettings ()
 
virtual int GetCurrentLineWidth () const
 
virtual void SetCreator (const wxString &aCreator)
 
virtual void SetTitle (const wxString &aTitle)
 
void AddLineToHeader (const wxString &aExtraString)
 Add a line to the list of free lines to print at the beginning of the file. More...
 
void ClearHeaderLinesList ()
 Remove all lines from the list of free lines to print at the beginning of the file. More...
 
double GetIUsPerDecimil () const
 The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establishing the viewport. More...
 
int GetPlotterArcLowDef () const
 
int GetPlotterArcHighDef () const
 
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 points: start ctrl1 ctrl2 end. More...
 
void MoveTo (const VECTOR2I &pos)
 
void LineTo (const VECTOR2I &pos)
 
void FinishTo (const VECTOR2I &pos)
 
void PenFinish ()
 
virtual void PlotPoly (const SHAPE_LINE_CHAIN &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)
 Draw a polygon ( filled or not ). More...
 
virtual void ThickSegment (const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
 
virtual void ThickArc (const VECTOR2I &aCentre, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, OUTLINE_MODE aTraceMode, void *aData)
 
virtual void ThickArc (const EDA_SHAPE &aArcShape, OUTLINE_MODE aTraceMode, void *aData)
 
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)
 
virtual void FilledCircle (const VECTOR2I &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
 
void Marker (const VECTOR2I &position, int diametre, unsigned aShapeId)
 Draw a pattern shape number aShapeId, to coord position. More...
 
virtual void SetLayerPolarity (bool aPositive)
 Set the current Gerber layer polarity to positive or negative by writing %LPD*% or %LPC*% to the Gerber file, respectively. More...
 
virtual void SetGerberCoordinatesFormat (int aResolution, bool aUseInches=false)
 
virtual void SetSvgCoordinatesFormat (unsigned aPrecision)
 Set the number of digits for mantissa in coordinates in mm for SVG plotter. More...
 
virtual void StartBlock (void *aData)
 calling this function allows one to define the beginning of a group of drawing items, for instance in SVG or Gerber format. More...
 
virtual void EndBlock (void *aData)
 calling this function allows one to define the end of a group of drawing items for instance in SVG or Gerber format. More...
 

Static Public Member Functions

static wxString GetDefaultFileExtension ()
 

Static Public Attributes

static const int DO_NOT_SET_LINE_WIDTH = -2
 
static const int USE_DEFAULT_LINE_WIDTH = -1
 
static const unsigned MARKER_COUNT = 58
 Draw a marker (used for the drill map). More...
 

Protected Member Functions

OUTLINE_NODEaddOutlineNode (OUTLINE_NODE *aParent, int aActionHandle, const wxString &aTitle)
 Adds a new outline node entry. More...
 
virtual void Arc (const VECTOR2I &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, int aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
 Generic fallback: arc rendered as a polyline. More...
 
std::string encodeStringForPlotter (const wxString &aUnicode) override
 convert a wxString unicode string to a char string compatible with the accepted string PDF format (convert special chars and non ascii7 chars) More...
 
virtual void emitSetRGBColor (double r, double g, double b, double a) override
 PDF supports colors fully. More...
 
int allocPdfObject ()
 Allocate a new handle in the table of the PDF object. More...
 
int startPdfObject (int handle=-1)
 Open a new PDF object and returns the handle if the parameter is -1. More...
 
void closePdfObject ()
 Close the current PDF object. More...
 
int startPdfStream (int handle=-1)
 Starts a PDF stream (for the page). More...
 
void closePdfStream ()
 Finish the current PDF stream (writes the deferred length, too) More...
 
int emitOutline ()
 Starts emitting the outline object. More...
 
void emitOutlineNode (OUTLINE_NODE *aNode, int aParentHandle, int aNextNode, int aPrevNode)
 Emits a outline item object and recurses into any children. More...
 
int emitGoToAction (int aPageHandle, const VECTOR2I &aBottomLeft, const VECTOR2I &aTopRight)
 Emits an action object that instructs a goto coordinates on a page. More...
 
int emitGoToAction (int aPageHandle)
 
void computeTextParameters (const VECTOR2I &aPos, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, bool aMirror, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, double *wideningFactor, double *ctm_a, double *ctm_b, double *ctm_c, double *ctm_d, double *ctm_e, double *ctm_f, double *heightFactor)
 This is the core for postscript/PDF text alignment. More...
 
void postscriptOverlinePositions (const wxString &aText, int aXSize, bool aItalic, bool aBold, std::vector< int > *pos_pairs)
 Computes the x coordinates for the overlining in a string of text. More...
 
int returnPostscriptTextWidth (const wxString &aText, int aXSize, bool aItalic, bool aBold)
 Sister function for the GraphicTextWidth in drawtxt.cpp Does the same processing (i.e. More...
 
virtual void ThickArc (const VECTOR2I &aCentre, const EDA_ANGLE &StAngle, const EDA_ANGLE &EndAngle, int aRadius, int aWidth, OUTLINE_MODE aTraceMode, void *aData)
 
void markerCircle (const VECTOR2I &pos, int radius)
 Plot a circle centered on the position. More...
 
void markerHBar (const VECTOR2I &pos, int radius)
 Plot a - bar centered on the position. More...
 
void markerSlash (const VECTOR2I &pos, int radius)
 Plot a / bar centered on the position. More...
 
void markerBackSlash (const VECTOR2I &pos, int radius)
 Plot a \ bar centered on the position. More...
 
void markerVBar (const VECTOR2I &pos, int radius)
 Plot a | bar centered on the position. More...
 
void markerSquare (const VECTOR2I &position, int radius)
 Plot a square centered on the position. More...
 
void markerLozenge (const VECTOR2I &position, int radius)
 Plot a lozenge centered on the position. More...
 
void segmentAsOval (const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode)
 Convert a thick segment and plot it as an oval. More...
 
void sketchOval (const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, int aWidth)
 
virtual VECTOR2D userToDeviceCoordinates (const VECTOR2I &aCoordinate)
 Modify coordinates according to the orientation, scale factor, and offsets trace. More...
 
virtual VECTOR2D userToDeviceSize (const VECTOR2I &size)
 Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D). More...
 
virtual double userToDeviceSize (double size) const
 Modify size according to the plotter scale factors (simple double version). More...
 
double GetDotMarkLenIU (int aLineWidth) const
 
double GetDashMarkLenIU (int aLineWidth) const
 
double GetDashGapLenIU (int aLineWidth) const
 

Protected Attributes

int m_pageTreeHandle
 Handle to the root of the page tree object. More...
 
int m_fontResDictHandle
 Font resource dictionary. More...
 
std::vector< int > m_pageHandles
 Handles to the page objects. More...
 
int m_pageStreamHandle
 Handle of the page content object. More...
 
int m_streamLengthHandle
 Handle to the deferred stream length. More...
 
wxString m_workFilename
 
wxString m_pageName
 
FILE * m_workFile
 Temporary file to construct the stream before zipping. More...
 
std::vector< long > m_xrefTable
 The PDF xref offset table. More...
 
std::vector< wxString > m_pageNumbers
 List of loaded hyperlinks in current page. More...
 
std::vector< std::pair< BOX2I, wxString > > m_hyperlinksInPage
 
std::vector< std::pair< BOX2I, std::vector< wxString > > > m_hyperlinkMenusInPage
 Handles for all the hyperlink objects that will be deferred. More...
 
std::map< int, std::pair< BOX2D, wxString > > m_hyperlinkHandles
 
std::map< int, std::pair< BOX2D, std::vector< wxString > > > m_hyperlinkMenuHandles
 
std::map< wxString, std::vector< std::pair< BOX2I, wxString > > > m_bookmarksInPage
 
std::unique_ptr< OUTLINE_NODEm_outlineRoot
 Root outline node. More...
 
int m_totalOutlineNodes
 Total number of outline nodes. More...
 
double plotScaleAdjX
 Fine user scale adjust ( = 1.0 if no correction) More...
 
double plotScaleAdjY
 
PLOT_TEXT_MODE m_textMode
 How to draw text. More...
 
double m_plotScale
 Plot scale - chosen by the user (even implicitly with 'fit in a4') More...
 
double m_IUsPerDecimil
 
double m_iuPerDeviceUnit
 
VECTOR2I m_plotOffset
 
bool m_plotMirror
 
bool m_mirrorIsHorizontal
 
bool m_yaxisReversed
 
FILE * m_outputFile
 Output file. More...
 
bool m_colorMode
 
bool m_negativeMode
 
int m_currentPenWidth
 
char m_penState
 
VECTOR2I m_penLastpos
 
wxString m_creator
 
wxString m_filename
 
wxString m_title
 
PAGE_INFO m_pageInfo
 
VECTOR2I m_paperSize
 
wxArrayString m_headerExtraLines
 
RENDER_SETTINGSm_renderSettings
 

Static Protected Attributes

static const double postscriptTextAscent = 0.718
 Height of the postscript font (from the AFM) More...
 

Detailed Description

Definition at line 247 of file plotters_pslike.h.

Constructor & Destructor Documentation

◆ PDF_PLOTTER()

PDF_PLOTTER::PDF_PLOTTER ( )
inline

Definition at line 250 of file plotters_pslike.h.

250 :
251 m_pageTreeHandle( 0 ),
255 m_workFile( nullptr ),
257 {
258 }
FILE * m_workFile
Temporary file to construct the stream before zipping.
int m_streamLengthHandle
Handle to the deferred stream length.
int m_fontResDictHandle
Font resource dictionary.
int m_pageTreeHandle
Handle to the root of the page tree object.
int m_pageStreamHandle
Handle of the page content object.
int m_totalOutlineNodes
Total number of outline nodes.

Member Function Documentation

◆ AddLineToHeader()

void PLOTTER::AddLineToHeader ( const wxString &  aExtraString)
inlineinherited

Add a line to the list of free lines to print at the beginning of the file.

Parameters
aExtraStringis the string to print

Definition at line 168 of file plotter.h.

169 {
170 m_headerExtraLines.Add( aExtraString );
171 }
wxArrayString m_headerExtraLines
Definition: plotter.h:668

References PLOTTER::m_headerExtraLines.

Referenced by AddGerberX2Attribute(), AddGerberX2Header(), GERBER_WRITER::createDrillFile(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), and GENDRILL_WRITER_BASE::genDrillMapFile().

◆ addOutlineNode()

PDF_PLOTTER::OUTLINE_NODE * PDF_PLOTTER::addOutlineNode ( OUTLINE_NODE aParent,
int  aActionHandle,
const wxString &  aTitle 
)
protected

Adds a new outline node entry.

The PDF object handle is automacially allocated

Parameters
aParentParent node to append the new node to
aActionHandleThe handle of an action that may be performed on click, set to -1 for no action
aTitleTitle of node to display

Definition at line 1009 of file PDF_plotter.cpp.

1011{
1012 OUTLINE_NODE *node = aParent->AddChild( aActionHandle, aTitle, allocPdfObject() );
1014
1015 return node;
1016}
int allocPdfObject()
Allocate a new handle in the table of the PDF object.

References PDF_PLOTTER::OUTLINE_NODE::AddChild(), allocPdfObject(), and m_totalOutlineNodes.

Referenced by ClosePage().

◆ allocPdfObject()

int PDF_PLOTTER::allocPdfObject ( )
protected

Allocate a new handle in the table of the PDF object.

The handle must be completed using startPdfObject. It's an in-RAM operation only, no output is done.

Definition at line 554 of file PDF_plotter.cpp.

555{
556 m_xrefTable.push_back( 0 );
557 return m_xrefTable.size() - 1;
558}
std::vector< long > m_xrefTable
The PDF xref offset table.

References m_xrefTable.

Referenced by addOutlineNode(), ClosePage(), emitGoToAction(), emitOutline(), startPdfObject(), startPdfStream(), and StartPlot().

◆ Arc() [1/2]

void PDF_PLOTTER::Arc ( const VECTOR2I aCentre,
const EDA_ANGLE aStartAngle,
const EDA_ANGLE aEndAngle,
int  aRadius,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH 
)
overrideprotectedvirtual

Generic fallback: arc rendered as a polyline.

Reimplemented from PLOTTER.

Definition at line 339 of file PDF_plotter.cpp.

341{
342 wxASSERT( m_workFile );
343
344 if( aRadius <= 0 )
345 {
346 Circle( aCenter, aWidth, FILL_T::FILLED_SHAPE, 0 );
347 return;
348 }
349
350 /*
351 * Arcs are not so easily approximated by beziers (in the general case), so we approximate
352 * them in the old way
353 */
354 EDA_ANGLE startAngle( aStartAngle );
355 EDA_ANGLE endAngle( aEndAngle );
356 VECTOR2I start;
357 VECTOR2I end;
358 const EDA_ANGLE delta( 5, DEGREES_T ); // increment to draw circles
359
360 if( startAngle > endAngle )
361 {
362 std::swap( startAngle, endAngle );
363 std::swap( start, end );
364 }
365
366 SetCurrentLineWidth( aWidth );
367
368 // Usual trig arc plotting routine...
369 start.x = aCenter.x + KiROUND( aRadius * (-startAngle).Cos() );
370 start.y = aCenter.y + KiROUND( aRadius * (-startAngle).Sin() );
371 VECTOR2D pos_dev = userToDeviceCoordinates( start );
372 fprintf( m_workFile, "%g %g m ", pos_dev.x, pos_dev.y );
373
374 for( EDA_ANGLE ii = startAngle + delta; ii < endAngle; ii += delta )
375 {
376 end.x = aCenter.x + KiROUND( aRadius * (-ii).Cos() );
377 end.y = aCenter.y + KiROUND( aRadius * (-ii).Sin() );
378 pos_dev = userToDeviceCoordinates( end );
379 fprintf( m_workFile, "%g %g l ", pos_dev.x, pos_dev.y );
380 }
381
382 end.x = aCenter.x + KiROUND( aRadius * (-endAngle).Cos() );
383 end.y = aCenter.y + KiROUND( aRadius * (-endAngle).Sin() );
384 pos_dev = userToDeviceCoordinates( end );
385 fprintf( m_workFile, "%g %g l ", pos_dev.x, pos_dev.y );
386
387 // The arc is drawn... if not filled we stroke it, otherwise we finish
388 // closing the pie at the center
389 if( aFill == FILL_T::NO_FILL )
390 {
391 fputs( "S\n", m_workFile );
392 }
393 else
394 {
395 pos_dev = userToDeviceCoordinates( aCenter );
396 fprintf( m_workFile, "%g %g l b\n", pos_dev.x, pos_dev.y );
397 }
398}
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Pen width setting for PDF.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Circle drawing for PDF.
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:90
@ DEGREES_T
Definition: eda_angle.h:31
@ FILLED_SHAPE
constexpr int delta
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References Circle(), DEGREES_T, delta, FILLED_SHAPE, KiROUND(), m_workFile, NO_FILL, SetCurrentLineWidth(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Arc() [2/2]

void PDF_PLOTTER::Arc ( const VECTOR2I aCenter,
const VECTOR2I aStart,
const VECTOR2I aEnd,
FILL_T  aFill,
int  aWidth,
int  aMaxError 
)
overridevirtual

The PDF engine can't directly plot arcs so we use polygonization.

Reimplemented from PLOTTER.

Definition at line 283 of file PDF_plotter.cpp.

285{
286 wxASSERT( m_workFile );
287
288 /*
289 * Arcs are not so easily approximated by beziers (in the general case), so we approximate
290 * them in the old way
291 */
292 EDA_ANGLE startAngle( aStart - aCenter );
293 EDA_ANGLE endAngle( aEnd - aCenter );
294 int radius = ( aStart - aCenter ).EuclideanNorm();
295 int numSegs = GetArcToSegmentCount( radius, aMaxError, FULL_CIRCLE );
296 EDA_ANGLE delta = ANGLE_360 / std::max( 8, numSegs );
297 VECTOR2I start( aStart );
298 VECTOR2I end( aEnd );
299 VECTOR2I pt;
300
301 if( startAngle > endAngle )
302 {
303 if( endAngle < ANGLE_0 )
304 endAngle.Normalize();
305 else
306 startAngle = startAngle.Normalize() - ANGLE_360;
307 }
308
309 SetCurrentLineWidth( aWidth );
310 VECTOR2D pos_dev = userToDeviceCoordinates( start );
311 fprintf( m_workFile, "%g %g m ", pos_dev.x, pos_dev.y );
312
313 for( EDA_ANGLE ii = delta; startAngle + ii < endAngle; ii += delta )
314 {
315 pt = start;
316 RotatePoint( pt, aCenter, -ii );
317
318 pos_dev = userToDeviceCoordinates( pt );
319 fprintf( m_workFile, "%g %g l ", pos_dev.x, pos_dev.y );
320 }
321
322 pos_dev = userToDeviceCoordinates( end );
323 fprintf( m_workFile, "%g %g l ", pos_dev.x, pos_dev.y );
324
325 // The arc is drawn... if not filled we stroke it, otherwise we finish
326 // closing the pie at the center
327 if( aFill == FILL_T::NO_FILL )
328 {
329 fputs( "S\n", m_workFile );
330 }
331 else
332 {
333 pos_dev = userToDeviceCoordinates( aCenter );
334 fprintf( m_workFile, "%g %g l b\n", pos_dev.x, pos_dev.y );
335 }
336}
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:435
static constexpr EDA_ANGLE & FULL_CIRCLE
Definition: eda_angle.h:427
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:429
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129

References ANGLE_0, ANGLE_360, delta, EuclideanNorm(), FULL_CIRCLE, GetArcToSegmentCount(), m_workFile, NO_FILL, EDA_ANGLE::Normalize(), RotatePoint(), SetCurrentLineWidth(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BezierCurve()

void PLOTTER::BezierCurve ( const VECTOR2I aStart,
const VECTOR2I aControl1,
const VECTOR2I aControl2,
const VECTOR2I aEnd,
int  aTolerance,
int  aLineThickness = USE_DEFAULT_LINE_WIDTH 
)
virtualinherited

Generic fallback: Cubic Bezier curve rendered as a polyline In KiCad the bezier curves have 4 control points: start ctrl1 ctrl2 end.

Reimplemented in SVG_PLOTTER.

Definition at line 224 of file plotter.cpp.

227{
228 // Generic fallback: Quadratic Bezier curve plotted as a polyline
229 int minSegLen = aLineThickness; // The segment min length to approximate a bezier curve
230
231 std::vector<VECTOR2I> ctrlPoints;
232 ctrlPoints.reserve( 4 );
233
234 ctrlPoints.push_back( aStart );
235 ctrlPoints.push_back( aControl1 );
236 ctrlPoints.push_back( aControl2 );
237 ctrlPoints.push_back( aEnd );
238
239 BEZIER_POLY bezier_converter( ctrlPoints );
240
241 std::vector<VECTOR2I> approxPoints;
242 bezier_converter.GetPoly( approxPoints, minSegLen );
243
244 SetCurrentLineWidth( aLineThickness );
245 MoveTo( aStart );
246
247 for( unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
248 LineTo( approxPoints[ii] );
249
250 FinishTo( aEnd );
251}
Bezier curves to polygon converter.
Definition: bezier_curves.h:38
void MoveTo(const VECTOR2I &pos)
Definition: plotter.h:247
void FinishTo(const VECTOR2I &pos)
Definition: plotter.h:257
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void LineTo(const VECTOR2I &pos)
Definition: plotter.h:252

References PLOTTER::FinishTo(), BEZIER_POLY::GetPoly(), PLOTTER::LineTo(), PLOTTER::MoveTo(), and PLOTTER::SetCurrentLineWidth().

Referenced by SVG_PLOTTER::BezierCurve(), BRDITEMS_PLOTTER::PlotFootprintShape(), and BRDITEMS_PLOTTER::PlotPcbShape().

◆ Bookmark()

void PDF_PLOTTER::Bookmark ( const BOX2I aBox,
const wxString &  aName,
const wxString &  aGroupName = wxEmptyString 
)
overridevirtual

Create a bookmark to a symbol.

@aBox is the bounding box of the symbol @aSymbolReference is the symbol schematic ref

Reimplemented from PLOTTER.

Definition at line 1485 of file PDF_plotter.cpp.

1487{
1488
1489 m_bookmarksInPage[aGroupName].push_back( std::make_pair( aLocation, aSymbolReference ) );
1490}
std::map< wxString, std::vector< std::pair< BOX2I, wxString > > > m_bookmarksInPage

References m_bookmarksInPage.

◆ Circle()

void PDF_PLOTTER::Circle ( const VECTOR2I pos,
int  diametre,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Circle drawing for PDF.

They're approximated by curves, but fill is supported

Implements PLOTTER.

Definition at line 229 of file PDF_plotter.cpp.

230{
231 wxASSERT( m_workFile );
232 VECTOR2D pos_dev = userToDeviceCoordinates( pos );
233 double radius = userToDeviceSize( diametre / 2.0 );
234
235 /* OK. Here's a trick. PDF doesn't support circles or circular angles, that's
236 a fact. You'll have to do with cubic beziers. These *can't* represent
237 circular arcs (NURBS can, beziers don't). But there is a widely known
238 approximation which is really good
239 */
240
241 SetCurrentLineWidth( width );
242
243 // If diameter is less than width, switch to filled mode
244 if( aFill == FILL_T::NO_FILL && diametre < width )
245 {
246 aFill = FILL_T::FILLED_SHAPE;
248
249 radius = userToDeviceSize( ( diametre / 2.0 ) + ( width / 2.0 ) );
250 }
251
252 double magic = radius * 0.551784; // You don't want to know where this come from
253
254 // This is the convex hull for the bezier approximated circle
255 fprintf( m_workFile,
256 "%g %g m "
257 "%g %g %g %g %g %g c "
258 "%g %g %g %g %g %g c "
259 "%g %g %g %g %g %g c "
260 "%g %g %g %g %g %g c %c\n",
261 pos_dev.x - radius, pos_dev.y,
262
263 pos_dev.x - radius, pos_dev.y + magic,
264 pos_dev.x - magic, pos_dev.y + radius,
265 pos_dev.x, pos_dev.y + radius,
266
267 pos_dev.x + magic, pos_dev.y + radius,
268 pos_dev.x + radius, pos_dev.y + magic,
269 pos_dev.x + radius, pos_dev.y,
270
271 pos_dev.x + radius, pos_dev.y - magic,
272 pos_dev.x + magic, pos_dev.y - radius,
273 pos_dev.x, pos_dev.y - radius,
274
275 pos_dev.x - magic, pos_dev.y - radius,
276 pos_dev.x - radius, pos_dev.y - magic,
277 pos_dev.x - radius, pos_dev.y,
278
279 aFill == FILL_T::NO_FILL ? 's' : 'b' );
280}
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
Definition: plotter.cpp:115

References FILLED_SHAPE, m_workFile, NO_FILL, SetCurrentLineWidth(), PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Arc().

◆ ClearHeaderLinesList()

void PLOTTER::ClearHeaderLinesList ( )
inlineinherited

Remove all lines from the list of free lines to print at the beginning of the file.

Definition at line 176 of file plotter.h.

177 {
178 m_headerExtraLines.Clear();
179 }

References PLOTTER::m_headerExtraLines.

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile(), and StartPlotBoard().

◆ ClosePage()

void PDF_PLOTTER::ClosePage ( )
virtual

Close the current page in the PDF document (and emit its compressed stream).

Definition at line 708 of file PDF_plotter.cpp.

709{
710 wxASSERT( m_workFile );
711
712 // Close the page stream (and compress it)
714
715 // Page size is in 1/72 of inch (default user space units). Works like the bbox in postscript
716 // but there is no need for swapping the sizes, since PDF doesn't require a portrait page.
717 // We use the MediaBox but PDF has lots of other less-used boxes that could be used.
718 const double PTsPERMIL = 0.072;
719 VECTOR2D psPaperSize = VECTOR2D( m_pageInfo.GetSizeMils() ) * PTsPERMIL;
720
721 auto iuToPdfUserSpace =
722 [&]( const VECTOR2I& aCoord ) -> VECTOR2D
723 {
724 VECTOR2D retval = VECTOR2D( aCoord ) * PTsPERMIL / ( m_IUsPerDecimil * 10 );
725 // PDF y=0 is at bottom of page, invert coordinate
726 retval.y = psPaperSize.y - retval.y;
727 return retval;
728 };
729
730 // Handle annotations (at the moment only "link" type objects)
731 std::vector<int> hyperlinkHandles;
732
733 // Allocate all hyperlink objects for the page and calculate their position in user space
734 // coordinates
735 for( const std::pair<BOX2I, wxString>& linkPair : m_hyperlinksInPage )
736 {
737 const BOX2I& box = linkPair.first;
738 const wxString& url = linkPair.second;
739
740 VECTOR2D bottomLeft = iuToPdfUserSpace( box.GetPosition() );
741 VECTOR2D topRight = iuToPdfUserSpace( box.GetEnd() );
742
743 BOX2D userSpaceBox;
744 userSpaceBox.SetOrigin( bottomLeft );
745 userSpaceBox.SetEnd( topRight );
746
747 hyperlinkHandles.push_back( allocPdfObject() );
748
749 m_hyperlinkHandles.insert( { hyperlinkHandles.back(), { userSpaceBox, url } } );
750 }
751
752 for( const std::pair<BOX2I, std::vector<wxString>>& menuPair : m_hyperlinkMenusInPage )
753 {
754 const BOX2I& box = menuPair.first;
755 const std::vector<wxString>& urls = menuPair.second;
756
757 VECTOR2D bottomLeft = iuToPdfUserSpace( box.GetPosition() );
758 VECTOR2D topRight = iuToPdfUserSpace( box.GetEnd() );
759
760 BOX2D userSpaceBox;
761 userSpaceBox.SetOrigin( bottomLeft );
762 userSpaceBox.SetEnd( topRight );
763
764 hyperlinkHandles.push_back( allocPdfObject() );
765
766 m_hyperlinkMenuHandles.insert( { hyperlinkHandles.back(), { userSpaceBox, urls } } );
767 }
768
769 int hyperLinkArrayHandle = -1;
770
771 // If we have added any annotation links, create an array containing all the objects
772 if( hyperlinkHandles.size() > 0 )
773 {
774 hyperLinkArrayHandle = startPdfObject();
775 bool isFirst = true;
776
777 fputs( "[", m_outputFile );
778
779 for( int handle : hyperlinkHandles )
780 {
781 if( isFirst )
782 isFirst = false;
783 else
784 fprintf( m_outputFile, " " );
785
786 fprintf( m_outputFile, "%d 0 R", handle );
787 }
788
789 fputs( "]\n", m_outputFile );
791 }
792
793 // Emit the page object and put it in the page list for later
794 int pageHandle = startPdfObject();
795 m_pageHandles.push_back( pageHandle );
796
797 fprintf( m_outputFile,
798 "<<\n"
799 "/Type /Page\n"
800 "/Parent %d 0 R\n"
801 "/Resources <<\n"
802 " /ProcSet [/PDF /Text /ImageC /ImageB]\n"
803 " /Font %d 0 R >>\n"
804 "/MediaBox [0 0 %g %g]\n"
805 "/Contents %d 0 R\n",
808 psPaperSize.x,
809 psPaperSize.y,
811
812 if( hyperlinkHandles.size() > 0 )
813 fprintf( m_outputFile, "/Annots %d 0 R", hyperLinkArrayHandle );
814
815 fputs( ">>\n", m_outputFile );
816
818
819 // Mark the page stream as idle
821
822 wxString pageOutlineName = wxEmptyString;
823
824 if( m_pageName.IsEmpty() )
825 {
826 pageOutlineName = wxString::Format( _( "Page %s" ), m_pageNumbers.back() );
827 }
828 else
829 {
830 pageOutlineName = wxString::Format( _( "%s (Page %s)" ), m_pageName, m_pageNumbers.back() );
831 }
832
833
834 int actionHandle = emitGoToAction( pageHandle );
835 OUTLINE_NODE* pageOutlineNode =
836 addOutlineNode( m_outlineRoot.get(), actionHandle, pageOutlineName );
837
838 // let's reorg the symbol bookmarks under a page handle
839 // let's reorg the symbol bookmarks under a page handle
840 for( const auto& [groupName, groupVector] : m_bookmarksInPage )
841 {
842 OUTLINE_NODE* groupOutlineNode = addOutlineNode( pageOutlineNode, actionHandle, groupName );
843
844 for( const std::pair<BOX2I, wxString>& bookmarkPair : groupVector )
845 {
846 const BOX2I& box = bookmarkPair.first;
847 const wxString& ref = bookmarkPair.second;
848
849 VECTOR2I bottomLeft = iuToPdfUserSpace( box.GetPosition() );
850 VECTOR2I topRight = iuToPdfUserSpace( box.GetEnd() );
851
852 actionHandle = emitGoToAction( pageHandle, bottomLeft, topRight );
853
854 addOutlineNode( groupOutlineNode, actionHandle, ref );
855 }
856
857 std::sort( groupOutlineNode->children.begin(), groupOutlineNode->children.end(),
858 []( const OUTLINE_NODE* a, const OUTLINE_NODE* b ) -> bool
859 {
860 return a->title < b->title;
861 } );
862 }
863
864 // Clean up
865 m_hyperlinksInPage.clear();
867 m_bookmarksInPage.clear();
868}
void SetOrigin(const Vec &pos)
Definition: box2.h:202
const Vec & GetPosition() const
Definition: box2.h:184
const Vec GetEnd() const
Definition: box2.h:185
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
const VECTOR2I & GetSizeMils() const
Definition: page_info.h:135
std::vector< int > m_pageHandles
Handles to the page objects.
wxString m_pageName
std::map< int, std::pair< BOX2D, wxString > > m_hyperlinkHandles
int emitGoToAction(int aPageHandle, const VECTOR2I &aBottomLeft, const VECTOR2I &aTopRight)
Emits an action object that instructs a goto coordinates on a page.
void closePdfStream()
Finish the current PDF stream (writes the deferred length, too)
int startPdfObject(int handle=-1)
Open a new PDF object and returns the handle if the parameter is -1.
OUTLINE_NODE * addOutlineNode(OUTLINE_NODE *aParent, int aActionHandle, const wxString &aTitle)
Adds a new outline node entry.
std::vector< wxString > m_pageNumbers
List of loaded hyperlinks in current page.
std::map< int, std::pair< BOX2D, std::vector< wxString > > > m_hyperlinkMenuHandles
std::vector< std::pair< BOX2I, wxString > > m_hyperlinksInPage
std::unique_ptr< OUTLINE_NODE > m_outlineRoot
Root outline node.
std::vector< std::pair< BOX2I, std::vector< wxString > > > m_hyperlinkMenusInPage
Handles for all the hyperlink objects that will be deferred.
void closePdfObject()
Close the current PDF object.
PAGE_INFO m_pageInfo
Definition: plotter.h:665
FILE * m_outputFile
Output file.
Definition: plotter.h:653
double m_IUsPerDecimil
Definition: plotter.h:642
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589

References _, addOutlineNode(), allocPdfObject(), PDF_PLOTTER::OUTLINE_NODE::children, closePdfObject(), closePdfStream(), emitGoToAction(), Format(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetPosition(), PAGE_INFO::GetSizeMils(), m_bookmarksInPage, m_fontResDictHandle, m_hyperlinkHandles, m_hyperlinkMenuHandles, m_hyperlinkMenusInPage, m_hyperlinksInPage, PLOTTER::m_IUsPerDecimil, m_outlineRoot, PLOTTER::m_outputFile, m_pageHandles, PLOTTER::m_pageInfo, m_pageName, m_pageNumbers, m_pageStreamHandle, m_pageTreeHandle, m_workFile, BOX2< Vec >::SetEnd(), BOX2< Vec >::SetOrigin(), startPdfObject(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_PLOTTER::createPDFFile(), and EndPlot().

◆ closePdfObject()

void PDF_PLOTTER::closePdfObject ( )
protected

Close the current PDF object.

Definition at line 575 of file PDF_plotter.cpp.

576{
577 wxASSERT( m_outputFile );
578 wxASSERT( !m_workFile );
579 fputs( "endobj\n", m_outputFile );
580}

References PLOTTER::m_outputFile, and m_workFile.

Referenced by ClosePage(), closePdfStream(), emitGoToAction(), emitOutline(), emitOutlineNode(), and EndPlot().

◆ closePdfStream()

void PDF_PLOTTER::closePdfStream ( )
protected

Finish the current PDF stream (writes the deferred length, too)

Definition at line 614 of file PDF_plotter.cpp.

615{
616 wxASSERT( m_workFile );
617
618 long stream_len = ftell( m_workFile );
619
620 if( stream_len < 0 )
621 {
622 wxASSERT( false );
623 return;
624 }
625
626 // Rewind the file, read in the page stream and DEFLATE it
627 fseek( m_workFile, 0, SEEK_SET );
628 unsigned char *inbuf = new unsigned char[stream_len];
629
630 int rc = fread( inbuf, 1, stream_len, m_workFile );
631 wxASSERT( rc == stream_len );
632 ignore_unused( rc );
633
634 // We are done with the temporary file, junk it
635 fclose( m_workFile );
636 m_workFile = nullptr;
637 ::wxRemoveFile( m_workFilename );
638
639 unsigned out_count;
640
641 if( ADVANCED_CFG::GetCfg().m_DebugPDFWriter )
642 {
643 out_count = stream_len;
644 fwrite( inbuf, out_count, 1, m_outputFile );
645 }
646 else
647 {
648 // NULL means memos owns the memory, but provide a hint on optimum size needed.
649 wxMemoryOutputStream memos( nullptr, std::max( 2000l, stream_len ) ) ;
650
651 {
652 /* Somewhat standard parameters to compress in DEFLATE. The PDF spec is
653 * misleading, it says it wants a DEFLATE stream but it really want a ZLIB
654 * stream! (a DEFLATE stream would be generated with -15 instead of 15)
655 * rc = deflateInit2( &zstrm, Z_BEST_COMPRESSION, Z_DEFLATED, 15,
656 * 8, Z_DEFAULT_STRATEGY );
657 */
658
659 wxZlibOutputStream zos( memos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
660
661 zos.Write( inbuf, stream_len );
662 } // flush the zip stream using zos destructor
663
664 wxStreamBuffer* sb = memos.GetOutputStreamBuffer();
665
666 out_count = sb->Tell();
667 fwrite( sb->GetBufferStart(), 1, out_count, m_outputFile );
668 }
669
670 delete[] inbuf;
671 fputs( "\nendstream\n", m_outputFile );
673
674 // Writing the deferred length as an indirect object
676 fprintf( m_outputFile, "%u\n", out_count );
678}
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString m_workFilename
void ignore_unused(const T &)
Definition: ignore.h:24

References closePdfObject(), ADVANCED_CFG::GetCfg(), ignore_unused(), PLOTTER::m_outputFile, m_streamLengthHandle, m_workFile, m_workFilename, and startPdfObject().

Referenced by ClosePage().

◆ computeTextParameters()

void PSLIKE_PLOTTER::computeTextParameters ( const VECTOR2I aPos,
const wxString &  aText,
const EDA_ANGLE aOrient,
const VECTOR2I aSize,
bool  aMirror,
enum GR_TEXT_H_ALIGN_T  aH_justify,
enum GR_TEXT_V_ALIGN_T  aV_justify,
int  aWidth,
bool  aItalic,
bool  aBold,
double *  wideningFactor,
double *  ctm_a,
double *  ctm_b,
double *  ctm_c,
double *  ctm_d,
double *  ctm_e,
double *  ctm_f,
double *  heightFactor 
)
protectedinherited

This is the core for postscript/PDF text alignment.

It computes the transformation matrix to generate a user space system aligned with the text. Even the PS uses the concat operator to simplify PDF generation (concat is everything PDF has to modify the CTM. Lots of parameters, both in and out.

Definition at line 401 of file PS_plotter.cpp.

419{
420 // Compute the starting position (compensated for alignment)
421 VECTOR2I start_pos = aPos;
422
423 // This is an approximation of the text bounds (in IUs)
424 int tw = returnPostscriptTextWidth( aText, aSize.x, aItalic, aWidth );
425 int th = aSize.y;
426 int dx, dy;
427
428 switch( aH_justify )
429 {
430 case GR_TEXT_H_ALIGN_CENTER: dx = -tw / 2; break;
431 case GR_TEXT_H_ALIGN_RIGHT: dx = -tw; break;
432 case GR_TEXT_H_ALIGN_LEFT: dx = 0; break;
433 }
434
435 switch( aV_justify )
436 {
437 case GR_TEXT_V_ALIGN_CENTER: dy = th / 2; break;
438 case GR_TEXT_V_ALIGN_TOP: dy = th; break;
439 case GR_TEXT_V_ALIGN_BOTTOM: dy = 0; break;
440 }
441
442 RotatePoint( &dx, &dy, aOrient );
443 RotatePoint( &tw, &th, aOrient );
444 start_pos.x += dx;
445 start_pos.y += dy;
446 VECTOR2D pos_dev = userToDeviceCoordinates( start_pos );
447 VECTOR2D sz_dev = userToDeviceSize( aSize );
448
449 // Now returns the final values... the widening factor
450 *wideningFactor = sz_dev.x / sz_dev.y;
451
452 // Mirrored texts must be plotted as mirrored!
453 if( m_plotMirror )
454 *wideningFactor = -*wideningFactor;
455
456 // The CTM transformation matrix
457 double alpha = m_plotMirror ? aOrient.Invert().AsRadians() : aOrient.AsRadians();
458 double sinalpha = sin( alpha );
459 double cosalpha = cos( alpha );
460
461 *ctm_a = cosalpha;
462 *ctm_b = sinalpha;
463 *ctm_c = -sinalpha;
464 *ctm_d = cosalpha;
465 *ctm_e = pos_dev.x;
466 *ctm_f = pos_dev.y;
467
468 // This is because the letters are less than 1 unit high
469 *heightFactor = sz_dev.y / postscriptTextAscent;
470}
EDA_ANGLE Invert() const
Definition: eda_angle.h:201
double AsRadians() const
Definition: eda_angle.h:153
bool m_plotMirror
Definition: plotter.h:647
static const double postscriptTextAscent
Height of the postscript font (from the AFM)
int returnPostscriptTextWidth(const wxString &aText, int aXSize, bool aItalic, bool aBold)
Sister function for the GraphicTextWidth in drawtxt.cpp Does the same processing (i....
Definition: PS_plotter.cpp:329
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP

References EDA_ANGLE::AsRadians(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_ANGLE::Invert(), PLOTTER::m_plotMirror, PSLIKE_PLOTTER::postscriptTextAscent, PSLIKE_PLOTTER::returnPostscriptTextWidth(), RotatePoint(), PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Text().

◆ emitGoToAction() [1/2]

int PDF_PLOTTER::emitGoToAction ( int  aPageHandle)
protected

Definition at line 930 of file PDF_plotter.cpp.

931{
932 int actionHandle = allocPdfObject();
933 startPdfObject( actionHandle );
934
935 fprintf( m_outputFile,
936 "<</S /GoTo /D [%d 0 R /Fit]\n"
937 ">>\n",
938 aPageHandle );
939
941
942 return actionHandle;
943}

References allocPdfObject(), closePdfObject(), PLOTTER::m_outputFile, and startPdfObject().

◆ emitGoToAction() [2/2]

int PDF_PLOTTER::emitGoToAction ( int  aPageHandle,
const VECTOR2I aBottomLeft,
const VECTOR2I aTopRight 
)
protected

Emits an action object that instructs a goto coordinates on a page.

Returns
Generated action handle

Definition at line 913 of file PDF_plotter.cpp.

915{
916 int actionHandle = allocPdfObject();
917 startPdfObject( actionHandle );
918
919 fprintf( m_outputFile,
920 "<</S /GoTo /D [%d 0 R /FitR %d %d %d %d]\n"
921 ">>\n",
922 aPageHandle, aBottomLeft.x, aBottomLeft.y, aTopRight.x, aTopRight.y );
923
925
926 return actionHandle;
927}

References allocPdfObject(), closePdfObject(), PLOTTER::m_outputFile, startPdfObject(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by ClosePage().

◆ emitOutline()

int PDF_PLOTTER::emitOutline ( )
protected

Starts emitting the outline object.

Definition at line 1019 of file PDF_plotter.cpp.

1020{
1021 if( m_outlineRoot->children.size() > 0 )
1022 {
1023 // declare the outline object
1024 m_outlineRoot->entryHandle = allocPdfObject();
1025
1026 emitOutlineNode( m_outlineRoot.get(), -1, -1, -1 );
1027
1028 startPdfObject( m_outlineRoot->entryHandle );
1029
1030 fprintf( m_outputFile,
1031 "<< /Type /Outlines\n"
1032 " /Count %d\n"
1033 " /First %d 0 R\n"
1034 " /Last %d 0 R\n"
1035 ">>\n",
1037 m_outlineRoot->children.front()->entryHandle,
1038 m_outlineRoot->children.back()->entryHandle
1039 );
1040
1042
1043 return m_outlineRoot->entryHandle;
1044 }
1045
1046 return -1;
1047}
void emitOutlineNode(OUTLINE_NODE *aNode, int aParentHandle, int aNextNode, int aPrevNode)
Emits a outline item object and recurses into any children.

References allocPdfObject(), closePdfObject(), emitOutlineNode(), m_outlineRoot, PLOTTER::m_outputFile, m_totalOutlineNodes, and startPdfObject().

Referenced by EndPlot().

◆ emitOutlineNode()

void PDF_PLOTTER::emitOutlineNode ( OUTLINE_NODE aNode,
int  aParentHandle,
int  aNextNode,
int  aPrevNode 
)
protected

Emits a outline item object and recurses into any children.

Definition at line 946 of file PDF_plotter.cpp.

948{
949 int nodeHandle = node->entryHandle;
950 int prevHandle = -1;
951 int nextHandle = -1;
952
953 for( std::vector<OUTLINE_NODE*>::iterator it = node->children.begin();
954 it != node->children.end(); it++ )
955 {
956 if( it >= node->children.end() - 1 )
957 {
958 nextHandle = -1;
959 }
960 else
961 {
962 nextHandle = ( *( it + 1 ) )->entryHandle;
963 }
964
965 emitOutlineNode( *it, nodeHandle, nextHandle, prevHandle );
966
967 prevHandle = ( *it )->entryHandle;
968 }
969
970 // -1 for parentHandle is the outline root itself which is handed elsewhere.
971 if( parentHandle != -1 )
972 {
973 startPdfObject( nodeHandle );
974
975 fprintf( m_outputFile,
976 "<< /Title %s\n"
977 " /Parent %d 0 R\n",
978 encodeStringForPlotter(node->title ).c_str(),
979 parentHandle);
980
981 if( nextNode > 0 )
982 {
983 fprintf( m_outputFile, " /Next %d 0 R\n", nextNode );
984 }
985
986 if( prevNode > 0 )
987 {
988 fprintf( m_outputFile, " /Prev %d 0 R\n", prevNode );
989 }
990
991 if( node->children.size() > 0 )
992 {
993 fprintf( m_outputFile, " /Count %zd\n", -1 * node->children.size() );
994 fprintf( m_outputFile, " /First %d 0 R\n", node->children.front()->entryHandle );
995 fprintf( m_outputFile, " /Last %d 0 R\n", node->children.back()->entryHandle );
996 }
997
998 if( node->actionHandle != -1 )
999 {
1000 fprintf( m_outputFile, " /A %d 0 R\n", node->actionHandle );
1001 }
1002
1003 fputs( ">>\n", m_outputFile );
1005 }
1006}
std::string encodeStringForPlotter(const wxString &aUnicode) override
convert a wxString unicode string to a char string compatible with the accepted string PDF format (co...
Definition: PDF_plotter.cpp:47

References PDF_PLOTTER::OUTLINE_NODE::actionHandle, PDF_PLOTTER::OUTLINE_NODE::children, closePdfObject(), emitOutlineNode(), encodeStringForPlotter(), PDF_PLOTTER::OUTLINE_NODE::entryHandle, PLOTTER::m_outputFile, startPdfObject(), and PDF_PLOTTER::OUTLINE_NODE::title.

Referenced by emitOutline(), and emitOutlineNode().

◆ emitSetRGBColor()

void PDF_PLOTTER::emitSetRGBColor ( double  r,
double  g,
double  b,
double  a 
)
overrideprotectedvirtual

PDF supports colors fully.

It actually has distinct fill and pen colors, but we set both at the same time.

XXX Keeping them divided could result in a minor optimization in Eeschema filled shapes, but would propagate to all the other plot engines. Also arcs are filled as pies but only the arc is stroked so it would be difficult to handle anyway.

Implements PSLIKE_PLOTTER.

Definition at line 165 of file PDF_plotter.cpp.

166{
167 wxASSERT( m_workFile );
168
169 // PDF treats all colors as opaque, so the best we can do with alpha is generate an
170 // appropriate blended color assuming white paper.
171 if( a < 1.0 )
172 {
173 r = ( r * a ) + ( 1 - a );
174 g = ( g * a ) + ( 1 - a );
175 b = ( b * a ) + ( 1 - a );
176 }
177
178 fprintf( m_workFile, "%g %g %g rg %g %g %g RG\n", r, g, b, r, g, b );
179}

References m_workFile.

◆ encodeStringForPlotter()

std::string PDF_PLOTTER::encodeStringForPlotter ( const wxString &  aUnicode)
overrideprotectedvirtual

convert a wxString unicode string to a char string compatible with the accepted string PDF format (convert special chars and non ascii7 chars)

Reimplemented from PSLIKE_PLOTTER.

Definition at line 47 of file PDF_plotter.cpp.

48{
49 // returns a string compatible with PDF string convention from a unicode string.
50 // if the initial text is only ASCII7, return the text between ( and ) for a good readability
51 // if the initial text is no ASCII7, return the text between < and >
52 // and encoded using 16 bits hexa (4 digits) by wide char (unicode 16)
53 std::string result;
54
55 // Is aText only ASCII7 ?
56 bool is_ascii7 = true;
57
58 for( size_t ii = 0; ii < aText.Len(); ii++ )
59 {
60 if( aText[ii] >= 0x7F )
61 {
62 is_ascii7 = false;
63 break;
64 }
65 }
66
67 if( is_ascii7 )
68 {
69 result = '(';
70
71 for( unsigned ii = 0; ii < aText.Len(); ii++ )
72 {
73 unsigned int code = aText[ii];
74
75 // These characters must be escaped
76 switch( code )
77 {
78 case '(':
79 case ')':
80 case '\\':
81 result += '\\';
83
84 default:
85 result += code;
86 break;
87 }
88 }
89
90 result += ')';
91 }
92 else
93 {
94 result = "<FEFF";
95
96 for( size_t ii = 0; ii < aText.Len(); ii++ )
97 {
98 unsigned int code = aText[ii];
99 char buffer[16];
100 sprintf( buffer, "%4.4X", code );
101 result += buffer;
102
103 }
104
105 result += '>';
106 }
107
108 return result;
109}
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83

References KI_FALLTHROUGH.

Referenced by emitOutlineNode(), EndPlot(), and Text().

◆ EndBlock()

virtual void PLOTTER::EndBlock ( void *  aData)
inlinevirtualinherited

calling this function allows one to define the end of a group of drawing items for instance in SVG or Gerber format.

the group is started by StartBlock()

Parameters
aDatacan define any parameter for most of plotters: do nothing

Reimplemented in GERBER_PLOTTER, and SVG_PLOTTER.

Definition at line 547 of file plotter.h.

547{}

Referenced by SCH_SYMBOL::Plot(), BRDITEMS_PLOTTER::PlotFilledAreas(), and PlotStandardLayer().

◆ EndPlot()

bool PDF_PLOTTER::EndPlot ( )
overridevirtual

Implements PLOTTER.

Definition at line 1050 of file PDF_plotter.cpp.

1051{
1052 wxASSERT( m_outputFile );
1053
1054 // Close the current page (often the only one)
1055 ClosePage();
1056
1057 /* We need to declare the resources we're using (fonts in particular)
1058 The useful standard one is the Helvetica family. Adding external fonts
1059 is *very* involved! */
1060 struct {
1061 const char *psname;
1062 const char *rsname;
1063 int font_handle;
1064 } fontdefs[4] = {
1065 { "/Helvetica", "/KicadFont", 0 },
1066 { "/Helvetica-Oblique", "/KicadFontI", 0 },
1067 { "/Helvetica-Bold", "/KicadFontB", 0 },
1068 { "/Helvetica-BoldOblique", "/KicadFontBI", 0 }
1069 };
1070
1071 /* Declare the font resources. Since they're builtin fonts, no descriptors (yay!)
1072 We'll need metrics anyway to do any alignment (these are in the shared with
1073 the postscript engine) */
1074 for( int i = 0; i < 4; i++ )
1075 {
1076 fontdefs[i].font_handle = startPdfObject();
1077 fprintf( m_outputFile,
1078 "<< /BaseFont %s\n"
1079 " /Type /Font\n"
1080 " /Subtype /Type1\n"
1081 /* Adobe is so Mac-based that the nearest thing to Latin1 is
1082 the Windows ANSI encoding! */
1083 " /Encoding /WinAnsiEncoding\n"
1084 ">>\n",
1085 fontdefs[i].psname );
1087 }
1088
1089 // Named font dictionary (was allocated, now we emit it)
1091 fputs( "<<\n", m_outputFile );
1092
1093 for( int i = 0; i < 4; i++ )
1094 {
1095 fprintf( m_outputFile, " %s %d 0 R\n",
1096 fontdefs[i].rsname, fontdefs[i].font_handle );
1097 }
1098
1099 fputs( ">>\n", m_outputFile );
1101
1102 for( const auto& [ linkHandle, linkPair ] : m_hyperlinkHandles )
1103 {
1104 const BOX2D& box = linkPair.first;
1105 const wxString& url = linkPair.second;
1106
1107 startPdfObject( linkHandle );
1108
1109 fprintf( m_outputFile,
1110 "<< /Type /Annot\n"
1111 " /Subtype /Link\n"
1112 " /Rect [%g %g %g %g]\n"
1113 " /Border [16 16 0]\n",
1114 box.GetLeft(), box.GetBottom(), box.GetRight(), box.GetTop() );
1115
1116 wxString pageNumber;
1117 bool pageFound = false;
1118
1119 if( EDA_TEXT::IsGotoPageHref( url, &pageNumber ) )
1120 {
1121 for( size_t ii = 0; ii < m_pageNumbers.size(); ++ii )
1122 {
1123 if( m_pageNumbers[ii] == pageNumber )
1124 {
1125 fprintf( m_outputFile,
1126 " /Dest [%d 0 R /FitB]\n"
1127 ">>\n",
1128 m_pageHandles[ii] );
1129
1130 pageFound = true;
1131 break;
1132 }
1133 }
1134
1135 if( !pageFound )
1136 {
1137 // destination page is not being plotted, assign the NOP action to the link
1138 fprintf( m_outputFile,
1139 " /A << /Type /Action /S /NOP >>\n"
1140 ">>\n" );
1141 }
1142 }
1143 else
1144 {
1145 fprintf( m_outputFile,
1146 " /A << /Type /Action /S /URI /URI %s >>\n"
1147 ">>\n",
1148 encodeStringForPlotter( url ).c_str() );
1149 }
1150
1152 }
1153
1154 for( const auto& [ menuHandle, menuPair ] : m_hyperlinkMenuHandles )
1155 {
1156 const BOX2D& box = menuPair.first;
1157 const std::vector<wxString>& urls = menuPair.second;
1158 wxString js = wxT( "var aParams = [ " );
1159
1160 for( const wxString& url : urls )
1161 {
1162 if( url.StartsWith( "!" ) )
1163 {
1164 wxString property = url.AfterFirst( '!' );
1165
1166 if( property.Find( "http:" ) >= 0 )
1167 {
1168 wxString href = property.substr( property.Find( "http:" ) );
1169
1170 js += wxString::Format( wxT( "{ cName: '%s', cReturn: '%s' }, " ),
1171 EscapeString( property, CTX_JS_STR ),
1172 EscapeString( href, CTX_JS_STR ) );
1173 }
1174 else if( property.Find( "https:" ) >= 0 )
1175 {
1176 wxString href = property.substr( property.Find( "https:" ) );
1177
1178 js += wxString::Format( wxT( "{ cName: '%s', cReturn: '%s' }, " ),
1179 EscapeString( property, CTX_JS_STR ),
1180 EscapeString( href, CTX_JS_STR ) );
1181 }
1182 else
1183 {
1184 js += wxString::Format( wxT( "{ cName: '%s', cReturn: null }, " ),
1185 EscapeString( property, CTX_JS_STR ) );
1186 }
1187 }
1188 else if( url.StartsWith( "#" ) )
1189 {
1190 wxString pageNumber = url.AfterFirst( '#' );
1191
1192 for( size_t ii = 0; ii < m_pageNumbers.size(); ++ii )
1193 {
1194 if( m_pageNumbers[ii] == pageNumber )
1195 {
1196 wxString menuText = wxString::Format( _( "Show Page %s" ), pageNumber );
1197
1198 js += wxString::Format( wxT( "{ cName: '%s', cReturn: '#%d' }, " ),
1199 EscapeString( menuText, CTX_JS_STR ),
1200 static_cast<int>( ii ) );
1201 break;
1202 }
1203 }
1204 }
1205 else if( url.StartsWith( "http:" ) || url.StartsWith( "https:" ) )
1206 {
1207 wxString menuText = wxString::Format( _( "Open %s" ), url );
1208
1209 js += wxString::Format( wxT( "{ cName: '%s', cReturn: '%s' }, " ),
1210 EscapeString( menuText, CTX_JS_STR ),
1211 EscapeString( url, CTX_JS_STR ) );
1212 }
1213 }
1214
1215 js += wxT( "]; " );
1216
1217 js += wxT( "var cChoice = app.popUpMenuEx.apply\\( app, aParams \\); " );
1218 js += wxT( "if\\( cChoice != null && cChoice.substring\\( 0, 1 \\) == '#' \\)"
1219 " this.pageNum = cChoice.slice\\( 1 \\); " );
1220 js += wxT( "else if\\( cChoice != null && cChoice.substring\\( 0, 4 \\) == 'http' \\)"
1221 " app.launchURL\\( cChoice \\);" );
1222
1223 startPdfObject( menuHandle );
1224
1225 fprintf( m_outputFile,
1226 "<< /Type /Annot\n"
1227 " /Subtype /Link\n"
1228 " /Rect [%g %g %g %g]\n"
1229 " /Border [16 16 0]\n",
1230 box.GetLeft(), box.GetBottom(), box.GetRight(), box.GetTop() );
1231
1232 fprintf( m_outputFile,
1233 " /A << /Type /Action /S /JavaScript /JS (%s) >>\n"
1234 ">>\n",
1235 js.ToStdString().c_str() );
1236
1238 }
1239
1240 /* The page tree: it's a B-tree but luckily we only have few pages!
1241 So we use just an array... The handle was allocated at the beginning,
1242 now we instantiate the corresponding object */
1244 fputs( "<<\n"
1245 "/Type /Pages\n"
1246 "/Kids [\n", m_outputFile );
1247
1248 for( unsigned i = 0; i < m_pageHandles.size(); i++ )
1249 fprintf( m_outputFile, "%d 0 R\n", m_pageHandles[i] );
1250
1251 fprintf( m_outputFile,
1252 "]\n"
1253 "/Count %ld\n"
1254 ">>\n", (long) m_pageHandles.size() );
1256
1257
1258 // The info dictionary
1259 int infoDictHandle = startPdfObject();
1260 char date_buf[250];
1261 time_t ltime = time( nullptr );
1262 strftime( date_buf, 250, "D:%Y%m%d%H%M%S", localtime( &ltime ) );
1263
1264 if( m_title.IsEmpty() )
1265 {
1266 // Windows uses '\' and other platforms use '/' as separator
1267 m_title = m_filename.AfterLast( '\\' );
1268 m_title = m_title.AfterLast( '/' );
1269 }
1270
1271 fprintf( m_outputFile,
1272 "<<\n"
1273 "/Producer (KiCad PDF)\n"
1274 "/CreationDate (%s)\n"
1275 "/Creator %s\n"
1276 "/Title %s\n",
1277 date_buf,
1279 encodeStringForPlotter( m_title ).c_str() );
1280
1281 fputs( ">>\n", m_outputFile );
1283
1284 // Let's dump in the outline
1285 int outlineHandle = emitOutline();
1286
1287 // The catalog, at last
1288 int catalogHandle = startPdfObject();
1289
1290 if( outlineHandle > 0 )
1291 {
1292 fprintf( m_outputFile,
1293 "<<\n"
1294 "/Type /Catalog\n"
1295 "/Pages %d 0 R\n"
1296 "/Version /1.5\n"
1297 "/PageMode /UseOutlines\n"
1298 "/Outlines %d 0 R\n"
1299 "/PageLayout /SinglePage\n"
1300 ">>\n",
1302 outlineHandle );
1303 }
1304 else
1305 {
1306 fprintf( m_outputFile,
1307 "<<\n"
1308 "/Type /Catalog\n"
1309 "/Pages %d 0 R\n"
1310 "/Version /1.5\n"
1311 "/PageMode /UseNone\n"
1312 "/PageLayout /SinglePage\n"
1313 ">>\n",
1315 }
1316
1318
1319 /* Emit the xref table (format is crucial to the byte, each entry must
1320 be 20 bytes long, and object zero must be done in that way). Also
1321 the offset must be kept along for the trailer */
1322 long xref_start = ftell( m_outputFile );
1323 fprintf( m_outputFile,
1324 "xref\n"
1325 "0 %ld\n"
1326 "0000000000 65535 f \n", (long) m_xrefTable.size() );
1327
1328 for( unsigned i = 1; i < m_xrefTable.size(); i++ )
1329 {
1330 fprintf( m_outputFile, "%010ld 00000 n \n", m_xrefTable[i] );
1331 }
1332
1333 // Done the xref, go for the trailer
1334 fprintf( m_outputFile,
1335 "trailer\n"
1336 "<< /Size %lu /Root %d 0 R /Info %d 0 R >>\n"
1337 "startxref\n"
1338 "%ld\n" // The offset we saved before
1339 "%%%%EOF\n",
1340 (unsigned long) m_xrefTable.size(), catalogHandle, infoDictHandle, xref_start );
1341
1342 fclose( m_outputFile );
1343 m_outputFile = nullptr;
1344
1345 return true;
1346}
coord_type GetTop() const
Definition: box2.h:194
coord_type GetRight() const
Definition: box2.h:189
coord_type GetLeft() const
Definition: box2.h:193
coord_type GetBottom() const
Definition: box2.h:190
static bool IsGotoPageHref(const wxString &aHref, wxString *aDestination=nullptr)
Check if aHref is a valid internal hyperlink.
Definition: eda_text.cpp:1000
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
int emitOutline()
Starts emitting the outline object.
wxString m_creator
Definition: plotter.h:662
wxString m_title
Definition: plotter.h:664
wxString m_filename
Definition: plotter.h:663
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_JS_STR
Definition: string_utils.h:58

References _, ClosePage(), closePdfObject(), CTX_JS_STR, emitOutline(), encodeStringForPlotter(), EscapeString(), Format(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), EDA_TEXT::IsGotoPageHref(), PLOTTER::m_creator, PLOTTER::m_filename, m_fontResDictHandle, m_hyperlinkHandles, m_hyperlinkMenuHandles, PLOTTER::m_outputFile, m_pageHandles, m_pageNumbers, m_pageTreeHandle, PLOTTER::m_title, m_xrefTable, and startPdfObject().

Referenced by PCBNEW_JOBS_HANDLER::JobExportPdf(), and SCH_PLOTTER::restoreEnvironment().

◆ FilledCircle()

void PLOTTER::FilledCircle ( const VECTOR2I pos,
int  diametre,
OUTLINE_MODE  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 668 of file plotter.cpp.

669{
670 if( tracemode == FILLED )
671 {
672 Circle( pos, diametre, FILL_T::FILLED_SHAPE, 0 );
673 }
674 else
675 {
677 Circle( pos, diametre, FILL_T::NO_FILL, -1 );
678 }
679}
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
@ FILLED
Definition: outline_mode.h:27

References PLOTTER::Circle(), FILLED, FILLED_SHAPE, NO_FILL, and PLOTTER::SetCurrentLineWidth().

Referenced by BRDITEMS_PLOTTER::PlotFootprintShape(), and BRDITEMS_PLOTTER::PlotPcbShape().

◆ FinishTo()

◆ FlashPadCircle()

void PSLIKE_PLOTTER::FlashPadCircle ( const VECTOR2I aPadPos,
int  aDiameter,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtualinherited
Parameters
aPadPosPosition of the shape (center of the rectangle.
aDiameteris the diameter of round pad.
aTraceModeis the drawing mode, FILLED or SKETCH.
aDatais an auxiliary info (mainly for gerber format attributes).

Implements PLOTTER.

Definition at line 120 of file PS_plotter.cpp.

122{
123 if( aTraceMode == FILLED )
124 {
125 Circle( aPadPos, aDiameter, FILL_T::FILLED_SHAPE, 0 );
126 }
127 else // Plot a ring:
128 {
130 Circle( aPadPos, aDiameter, FILL_T::NO_FILL, GetCurrentLineWidth() );
131 }
132
134}
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:114
virtual int GetCurrentLineWidth() const
Definition: plotter.h:153

References PLOTTER::Circle(), FILLED, FILLED_SHAPE, PLOTTER::GetCurrentLineWidth(), NO_FILL, PLOTTER::SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

◆ FlashPadCustom()

void PSLIKE_PLOTTER::FlashPadCustom ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
const EDA_ANGLE aPadOrient,
SHAPE_POLY_SET aPolygons,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtualinherited
Parameters
aPadPosPosition of the shape.
aSizeis the size of round reference pad.
aPadOrientis the pad rotation, used only with aperture macros (Gerber plotter).
aPolygonsthe shape as polygon set.
aTraceModeis the drawing mode, FILLED or SKETCH.
aDataan auxiliary info (mainly for gerber format attributes).

Implements PLOTTER.

Definition at line 214 of file PS_plotter.cpp.

217{
218 VECTOR2I size( aSize );
219
220 if( aTraceMode == FILLED )
221 {
223 }
224 else
225 {
227 }
228
229
230 std::vector<VECTOR2I> cornerList;
231
232 for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
233 {
234 SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
235 cornerList.clear();
236
237 for( int ii = 0; ii < poly.PointCount(); ++ii )
238 cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
239
240 // Close polygon
241 cornerList.push_back( cornerList[0] );
242
243 PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL,
245 }
246}
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 ).
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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.
SHAPE_LINE_CHAIN & Outline(int aIndex)
int OutlineCount() const
Return the number of vertices in a given outline/hole.

References SHAPE_LINE_CHAIN::CPoint(), FILLED, FILLED_SHAPE, PLOTTER::GetCurrentLineWidth(), NO_FILL, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PLOTTER::PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), PLOTTER::SetCurrentLineWidth(), PLOTTER::USE_DEFAULT_LINE_WIDTH, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadOval()

void PSLIKE_PLOTTER::FlashPadOval ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
const EDA_ANGLE aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtualinherited
Parameters
aPadPosPosition of the shape (center of the rectangle.
aSizeis the size of oblong shape.
aPadOrientThe rotation of the shape.
aTraceModeis the drawing mode, FILLED or SKETCH.
aDataan auxiliary info (mainly for gerber format attributes).

Implements PLOTTER.

Definition at line 90 of file PS_plotter.cpp.

93{
94 wxASSERT( m_outputFile );
95
96 VECTOR2I size( aSize );
97 EDA_ANGLE orient( aPadOrient );
98
99 // The pad is reduced to an oval by dy > dx
100 if( size.x > size.y )
101 {
102 std::swap( size.x, size.y );
103 orient += ANGLE_90;
104 }
105
106 int delta = size.y - size.x;
107 VECTOR2I a( 0, -delta / 2 );
108 VECTOR2I b( 0, delta / 2 );
109
110 RotatePoint( a, orient );
111 RotatePoint( b, orient );
112
113 if( aTraceMode == FILLED )
114 ThickSegment( a + aPadPos, b + aPadPos, size.x, aTraceMode, nullptr );
115 else
116 sketchOval( aPadPos, size, orient, -1 );
117}
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:549
void sketchOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, int aWidth)
Definition: plotter.cpp:496
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431

References ANGLE_90, delta, FILLED, PLOTTER::m_outputFile, RotatePoint(), PLOTTER::sketchOval(), PLOTTER::ThickSegment(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadRect()

void PSLIKE_PLOTTER::FlashPadRect ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
const EDA_ANGLE aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtualinherited
Parameters
aPadPosPosition of the shape (center of the rectangle).
aSizeis the size of rounded rect.
aPadOrientThe rotation of the shape.
aTraceModeis the drawing mode, FILLED or SKETCH.
aDataan auxiliary info (mainly for gerber format attributes).

Implements PLOTTER.

Definition at line 137 of file PS_plotter.cpp.

140{
141 std::vector<VECTOR2I> cornerList;
142 VECTOR2I size( aSize );
143 cornerList.reserve( 4 );
144
145 if( aTraceMode == FILLED )
147 else
149
150 int dx = size.x / 2;
151 int dy = size.y / 2;
152
153 VECTOR2I corner;
154 corner.x = aPadPos.x - dx;
155 corner.y = aPadPos.y + dy;
156 cornerList.push_back( corner );
157 corner.x = aPadPos.x - dx;
158 corner.y = aPadPos.y - dy;
159 cornerList.push_back( corner );
160 corner.x = aPadPos.x + dx;
161 corner.y = aPadPos.y - dy;
162 cornerList.push_back( corner );
163 corner.x = aPadPos.x + dx;
164 corner.y = aPadPos.y + dy,
165 cornerList.push_back( corner );
166
167 for( unsigned ii = 0; ii < cornerList.size(); ii++ )
168 RotatePoint( cornerList[ii], aPadPos, aPadOrient );
169
170 cornerList.push_back( cornerList[0] );
171
172 PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL,
174}

References FILLED, FILLED_SHAPE, PLOTTER::GetCurrentLineWidth(), NO_FILL, PLOTTER::PlotPoly(), RotatePoint(), PLOTTER::SetCurrentLineWidth(), PLOTTER::USE_DEFAULT_LINE_WIDTH, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadRoundRect()

void PSLIKE_PLOTTER::FlashPadRoundRect ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
int  aCornerRadius,
const EDA_ANGLE aOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtualinherited
Parameters
aPadPosPosition of the shape (center of the rectangle.
aSizeis the size of rounded rect.
aCornerRadiusRadius of the rounded corners.
aOrientThe rotation of the shape.
aTraceModeis the drawing mode, FILLED or SKETCH.
aDataan auxiliary info (mainly for gerber format attributes).

Implements PLOTTER.

Definition at line 177 of file PS_plotter.cpp.

180{
181 VECTOR2I size( aSize );
182
183 if( aTraceMode == FILLED )
184 {
186 }
187 else
188 {
190 }
191
192
193 SHAPE_POLY_SET outline;
194 TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient, aCornerRadius, 0.0, 0,
196
197 std::vector<VECTOR2I> cornerList;
198
199 // TransformRoundRectToPolygon creates only one convex polygon
200 SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
201 cornerList.reserve( poly.PointCount() );
202
203 for( int ii = 0; ii < poly.PointCount(); ++ii )
204 cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
205
206 // Close polygon
207 cornerList.push_back( cornerList[0] );
208
209 PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL,
211}
int GetPlotterArcHighDef() const
Definition: plotter.h:213
Represent a set of closed polygons.
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.
@ ERROR_INSIDE

References SHAPE_LINE_CHAIN::CPoint(), ERROR_INSIDE, FILLED, FILLED_SHAPE, PLOTTER::GetCurrentLineWidth(), PLOTTER::GetPlotterArcHighDef(), NO_FILL, SHAPE_POLY_SET::Outline(), PLOTTER::PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), PLOTTER::SetCurrentLineWidth(), TransformRoundChamferedRectToPolygon(), PLOTTER::USE_DEFAULT_LINE_WIDTH, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadTrapez()

void PSLIKE_PLOTTER::FlashPadTrapez ( const VECTOR2I aPadPos,
const VECTOR2I aCorners,
const EDA_ANGLE aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtualinherited

Flash a trapezoidal pad.

Parameters
aPadPosis the the position of the shape.
aCornersis the list of 4 corners positions, relative to the shape position, pad orientation 0.
aPadOrientis the rotation of the shape.
aTraceModeis the drawing mode, FILLED or SKETCH.
aDataan auxiliary info (mainly for gerber format attributes).

Implements PLOTTER.

Definition at line 249 of file PS_plotter.cpp.

252{
253 static std::vector<VECTOR2I> cornerList;
254 cornerList.clear();
255
256 for( int ii = 0; ii < 4; ii++ )
257 cornerList.push_back( aCorners[ii] );
258
259 if( aTraceMode == FILLED )
260 {
262 }
263 else
264 {
266 }
267
268 for( int ii = 0; ii < 4; ii++ )
269 {
270 RotatePoint( cornerList[ii], aPadOrient );
271 cornerList[ii] += aPadPos;
272 }
273
274 cornerList.push_back( cornerList[0] );
275 PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL,
277}

References FILLED, FILLED_SHAPE, PLOTTER::GetCurrentLineWidth(), NO_FILL, PLOTTER::PlotPoly(), RotatePoint(), PLOTTER::SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

◆ FlashRegularPolygon()

void PSLIKE_PLOTTER::FlashRegularPolygon ( const VECTOR2I aShapePos,
int  aDiameter,
int  aCornerCount,
const EDA_ANGLE aOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtualinherited

Flash a regular polygon.

Useful only in Gerber files to flash a regular polygon.

Parameters
aShapePosis the center of the circle containing the polygon.
aRadiusis the radius of the circle containing the polygon.
aCornerCountis the number of vertices.
aOrientis the polygon rotation.
aDatais a auxiliary parameter used (if needed) to handle extra info specific to the plotter.

Implements PLOTTER.

Definition at line 280 of file PS_plotter.cpp.

283{
284 // Do nothing
285 wxASSERT( 0 );
286}

◆ GetColorMode()

◆ GetCurrentLineWidth()

◆ GetDashGapLenIU()

double PLOTTER::GetDashGapLenIU ( int  aLineWidth) const
protectedinherited

Definition at line 143 of file plotter.cpp.

144{
145 return userToDeviceSize( m_renderSettings->GetGapLength( aLineWidth ) );
146}
double GetGapLength(int aLineWidth) const
RENDER_SETTINGS * m_renderSettings
Definition: plotter.h:670

References KIGFX::RENDER_SETTINGS::GetGapLength(), PLOTTER::m_renderSettings, and PLOTTER::userToDeviceSize().

Referenced by PS_PLOTTER::SetDash(), SetDash(), and SVG_PLOTTER::setSVGPlotStyle().

◆ GetDashMarkLenIU()

double PLOTTER::GetDashMarkLenIU ( int  aLineWidth) const
protectedinherited

◆ GetDefaultFileExtension()

static wxString PDF_PLOTTER::GetDefaultFileExtension ( )
inlinestatic

Definition at line 265 of file plotters_pslike.h.

266 {
267 return wxString( wxT( "pdf" ) );
268 }

Referenced by SCH_PLOTTER::createPDFFile(), and GetDefaultPlotExtension().

◆ GetDotMarkLenIU()

double PLOTTER::GetDotMarkLenIU ( int  aLineWidth) const
protectedinherited

◆ GetIUsPerDecimil()

double PLOTTER::GetIUsPerDecimil ( ) const
inlineinherited

The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establishing the viewport.

Here they can be get back again

Definition at line 210 of file plotter.h.

210{ return m_IUsPerDecimil; }

References PLOTTER::m_IUsPerDecimil.

Referenced by PlotDrawingSheet().

◆ GetPlotterArcHighDef()

◆ GetPlotterArcLowDef()

int PLOTTER::GetPlotterArcLowDef ( ) const
inlineinherited

Definition at line 212 of file plotter.h.

212{ return m_IUsPerDecimil * 8; }

References PLOTTER::m_IUsPerDecimil.

◆ GetPlotterType()

virtual PLOT_FORMAT PDF_PLOTTER::GetPlotterType ( ) const
inlineoverridevirtual

Returns the effective plot engine in use.

It's not very OO but for now is required since some things are only done with some output devices (like drill marks, emitted only for postscript

Implements PLOTTER.

Definition at line 260 of file plotters_pslike.h.

261 {
262 return PLOT_FORMAT::PDF;
263 }

References PDF.

◆ HyperlinkBox()

void PDF_PLOTTER::HyperlinkBox ( const BOX2I aBox,
const wxString &  aDestinationURL 
)
overridevirtual

Create a clickable hyperlink with a rectangular click area.

@aBox is the rectangular click target @aDestinationURL is the target URL

Reimplemented from PLOTTER.

Definition at line 1473 of file PDF_plotter.cpp.

1474{
1475 m_hyperlinksInPage.push_back( std::make_pair( aBox, aDestinationURL ) );
1476}

References m_hyperlinksInPage.

◆ HyperlinkMenu()

void PDF_PLOTTER::HyperlinkMenu ( const BOX2I aBox,
const std::vector< wxString > &  aDestURLs 
)
overridevirtual

Create a clickable hyperlink menu with a rectangular click area.

@aBox is the rectangular click target @aDestURLs is the list of target URLs for the menu

Reimplemented from PLOTTER.

Definition at line 1479 of file PDF_plotter.cpp.

1480{
1481 m_hyperlinkMenusInPage.push_back( std::make_pair( aBox, aDestURLs ) );
1482}

References m_hyperlinkMenusInPage.

◆ LineTo()

◆ Marker()

void PLOTTER::Marker ( const VECTOR2I position,
int  diametre,
unsigned  aShapeId 
)
inherited

Draw a pattern shape number aShapeId, to coord position.

Parameters
aPositionis the position of the marker.
aDiameteris the diameter of the marker.
aShapeIdis the index (used to generate forms characters).

Definition at line 359 of file plotter.cpp.

360{
361 int radius = diametre / 2;
362
363 /* Marker are composed by a series of 'parts' superimposed; not every
364 combination make sense, obviously. Since they are used in order I
365 tried to keep the uglier/more complex constructions at the end.
366 Also I avoided the |/ |\ -/ -\ construction because they're *very*
367 ugly... if needed they could be added anyway... I'd like to see
368 a board with more than 58 drilling/slotting tools!
369 If Visual C++ supported the 0b literals they would be optimally
370 and easily encoded as an integer array. We have to do with octal */
371 static const unsigned char marker_patterns[MARKER_COUNT] = {
372
373 // Bit order: O Square Lozenge - | \ /
374 // First choice: simple shapes
375 0003, // X
376 0100, // O
377 0014, // +
378 0040, // Sq
379 0020, // Lz
380
381 // Two simple shapes
382 0103, // X O
383 0017, // X +
384 0043, // X Sq
385 0023, // X Lz
386 0114, // O +
387 0140, // O Sq
388 0120, // O Lz
389 0054, // + Sq
390 0034, // + Lz
391 0060, // Sq Lz
392
393 // Three simple shapes
394 0117, // X O +
395 0143, // X O Sq
396 0123, // X O Lz
397 0057, // X + Sq
398 0037, // X + Lz
399 0063, // X Sq Lz
400 0154, // O + Sq
401 0134, // O + Lz
402 0074, // + Sq Lz
403
404 // Four simple shapes
405 0174, // O Sq Lz +
406 0163, // X O Sq Lz
407 0157, // X O Sq +
408 0137, // X O Lz +
409 0077, // X Sq Lz +
410
411 // This draws *everything *
412 0177, // X O Sq Lz +
413
414 // Here we use the single bars... so the cross is forbidden
415 0110, // O -
416 0104, // O |
417 0101, // O /
418 0050, // Sq -
419 0044, // Sq |
420 0041, // Sq /
421 0030, // Lz -
422 0024, // Lz |
423 0021, // Lz /
424 0150, // O Sq -
425 0144, // O Sq |
426 0141, // O Sq /
427 0130, // O Lz -
428 0124, // O Lz |
429 0121, // O Lz /
430 0070, // Sq Lz -
431 0064, // Sq Lz |
432 0061, // Sq Lz /
433 0170, // O Sq Lz -
434 0164, // O Sq Lz |
435 0161, // O Sq Lz /
436
437 // Last resort: the backlash component (easy to confound)
438 0102, // \ O
439 0042, // \ Sq
440 0022, // \ Lz
441 0142, // \ O Sq
442 0122, // \ O Lz
443 0062, // \ Sq Lz
444 0162 // \ O Sq Lz
445 };
446
447 if( aShapeId >= MARKER_COUNT )
448 {
449 // Fallback shape
450 markerCircle( position, radius );
451 }
452 else
453 {
454 // Decode the pattern and draw the corresponding parts
455 unsigned char pat = marker_patterns[aShapeId];
456
457 if( pat & 0001 )
458 markerSlash( position, radius );
459
460 if( pat & 0002 )
461 markerBackSlash( position, radius );
462
463 if( pat & 0004 )
464 markerVBar( position, radius );
465
466 if( pat & 0010 )
467 markerHBar( position, radius );
468
469 if( pat & 0020 )
470 markerLozenge( position, radius );
471
472 if( pat & 0040 )
473 markerSquare( position, radius );
474
475 if( pat & 0100 )
476 markerCircle( position, radius );
477 }
478}
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map).
Definition: plotter.h:486
void markerSlash(const VECTOR2I &pos, int radius)
Plot a / bar centered on the position.
Definition: plotter.cpp:338
void markerHBar(const VECTOR2I &pos, int radius)
Plot a - bar centered on the position.
Definition: plotter.cpp:331
void markerCircle(const VECTOR2I &pos, int radius)
Plot a circle centered on the position.
Definition: plotter.cpp:298
void markerLozenge(const VECTOR2I &position, int radius)
Plot a lozenge centered on the position.
Definition: plotter.cpp:304
void markerBackSlash(const VECTOR2I &pos, int radius)
Plot a \ bar centered on the position.
Definition: plotter.cpp:345
void markerVBar(const VECTOR2I &pos, int radius)
Plot a | bar centered on the position.
Definition: plotter.cpp:352
void markerSquare(const VECTOR2I &position, int radius)
Plot a square centered on the position.
Definition: plotter.cpp:270

References PLOTTER::MARKER_COUNT, PLOTTER::markerBackSlash(), PLOTTER::markerCircle(), PLOTTER::markerHBar(), PLOTTER::markerLozenge(), PLOTTER::markerSlash(), PLOTTER::markerSquare(), and PLOTTER::markerVBar().

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile(), and GENDRILL_WRITER_BASE::plotDrillMarks().

◆ markerBackSlash()

void PLOTTER::markerBackSlash ( const VECTOR2I pos,
int  radius 
)
protectedinherited

Plot a \ bar centered on the position.

Building block for markers

Definition at line 345 of file plotter.cpp.

346{
347 MoveTo( VECTOR2I( pos.x + radius, pos.y - radius ) );
348 FinishTo( VECTOR2I( pos.x - radius, pos.y + radius ) );
349}
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PLOTTER::Marker().

◆ markerCircle()

void PLOTTER::markerCircle ( const VECTOR2I pos,
int  radius 
)
protectedinherited

Plot a circle centered on the position.

Building block for markers

Definition at line 298 of file plotter.cpp.

299{
300 Circle( position, radius * 2, FILL_T::NO_FILL, GetCurrentLineWidth() );
301}

References PLOTTER::Circle(), PLOTTER::GetCurrentLineWidth(), and NO_FILL.

Referenced by PLOTTER::Marker().

◆ markerHBar()

void PLOTTER::markerHBar ( const VECTOR2I pos,
int  radius 
)
protectedinherited

Plot a - bar centered on the position.

Building block for markers

Definition at line 331 of file plotter.cpp.

332{
333 MoveTo( VECTOR2I( pos.x - radius, pos.y ) );
334 FinishTo( VECTOR2I( pos.x + radius, pos.y ) );
335}

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PLOTTER::Marker().

◆ markerLozenge()

void PLOTTER::markerLozenge ( const VECTOR2I position,
int  radius 
)
protectedinherited

Plot a lozenge centered on the position.

Building block for markers

Definition at line 304 of file plotter.cpp.

305{
306 std::vector<VECTOR2I> corner_list;
307 VECTOR2I corner;
308
309 corner_list.reserve( 4 );
310
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 );
326
328}

References PLOTTER::GetCurrentLineWidth(), NO_FILL, PLOTTER::PlotPoly(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PLOTTER::Marker().

◆ markerSlash()

void PLOTTER::markerSlash ( const VECTOR2I pos,
int  radius 
)
protectedinherited

Plot a / bar centered on the position.

Building block for markers

Definition at line 338 of file plotter.cpp.

339{
340 MoveTo( VECTOR2I( pos.x - radius, pos.y - radius ) );
341 FinishTo( VECTOR2I( pos.x + radius, pos.y + radius ) );
342}

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PLOTTER::Marker().

◆ markerSquare()

void PLOTTER::markerSquare ( const VECTOR2I position,
int  radius 
)
protectedinherited

Plot a square centered on the position.

Building block for markers

Definition at line 270 of file plotter.cpp.

271{
272 double r = KiROUND( radius / 1.4142 );
273 std::vector<VECTOR2I> corner_list;
274 VECTOR2I corner;
275
276 corner_list.reserve( 4 );
277
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 );
293
295}

References PLOTTER::GetCurrentLineWidth(), KiROUND(), NO_FILL, PLOTTER::PlotPoly(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PLOTTER::Marker().

◆ markerVBar()

void PLOTTER::markerVBar ( const VECTOR2I pos,
int  radius 
)
protectedinherited

Plot a | bar centered on the position.

Building block for markers

Definition at line 352 of file plotter.cpp.

353{
354 MoveTo( VECTOR2I( pos.x, pos.y - radius ) );
355 FinishTo( VECTOR2I( pos.x, pos.y + radius ) );
356}

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PLOTTER::Marker().

◆ MoveTo()

◆ OpenFile()

bool PDF_PLOTTER::OpenFile ( const wxString &  aFullFilename)
overridevirtual

Open or create the plot file aFullFilename.

The base class open the file in text mode, so we should have this function overlaid for PDF files, which are binary files.

Parameters
aFullFilenameis the full file name of the file to create.
Returns
true if success, false if the file cannot be created/opened.

Reimplemented from PLOTTER.

Definition at line 112 of file PDF_plotter.cpp.

113{
114 m_filename = aFullFilename;
115
116 wxASSERT( !m_outputFile );
117
118 // Open the PDF file in binary mode
119 m_outputFile = wxFopen( m_filename, wxT( "wb" ) );
120
121 if( m_outputFile == nullptr )
122 return false ;
123
124 return true;
125}

References PLOTTER::m_filename, and PLOTTER::m_outputFile.

Referenced by SCH_PLOTTER::createPDFFile().

◆ PageSettings()

PAGE_INFO & PLOTTER::PageSettings ( )
inlineinherited

◆ PenFinish()

void PLOTTER::PenFinish ( )
inlineinherited

Definition at line 263 of file plotter.h.

264 {
265 // The point is not important with Z motion
266 PenTo( VECTOR2I( 0, 0 ), 'Z' );
267 }

References PLOTTER::PenTo().

Referenced by HPGL_PLOTTER::Circle(), HPGL_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::PlotPoly(), DXF_PLOTTER::PlotPoly(), HPGL_PLOTTER::PlotPoly(), PLOTTER::PlotText(), HPGL_PLOTTER::Rect(), and PLOTTER::Text().

◆ PenTo()

void PDF_PLOTTER::PenTo ( const VECTOR2I pos,
char  plume 
)
overridevirtual

Moveto/lineto primitive, moves the 'pen' to the specified direction.

Parameters
posis the target position.
plumespecifies the kind of motion: 'U' only moves the pen, 'D' draw a line from the current position and 'Z' finish the drawing and returns the 'pen' to rest (flushes the trace).

Implements PLOTTER.

Definition at line 430 of file PDF_plotter.cpp.

431{
432 wxASSERT( m_workFile );
433
434 if( plume == 'Z' )
435 {
436 if( m_penState != 'Z' )
437 {
438 fputs( "S\n", m_workFile );
439 m_penState = 'Z';
440 m_penLastpos.x = -1;
441 m_penLastpos.y = -1;
442 }
443
444 return;
445 }
446
447 if( m_penState != plume || pos != m_penLastpos )
448 {
449 VECTOR2D pos_dev = userToDeviceCoordinates( pos );
450 fprintf( m_workFile, "%g %g %c\n",
451 pos_dev.x, pos_dev.y,
452 ( plume=='D' ) ? 'l' : 'm' );
453 }
454
455 m_penState = plume;
456 m_penLastpos = pos;
457}
VECTOR2I m_penLastpos
Definition: plotter.h:660
char m_penState
Definition: plotter.h:659

References PLOTTER::m_penLastpos, PLOTTER::m_penState, m_workFile, PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ PlotImage()

void PDF_PLOTTER::PlotImage ( const wxImage &  aImage,
const VECTOR2I aPos,
double  aScaleFactor 
)
overridevirtual

PDF images are handles as inline, not XObject streams...

Reimplemented from PLOTTER.

Definition at line 460 of file PDF_plotter.cpp.

461{
462 wxASSERT( m_workFile );
463 VECTOR2I pix_size( aImage.GetWidth(), aImage.GetHeight() );
464
465 // Requested size (in IUs)
466 VECTOR2D drawsize( aScaleFactor * pix_size.x, aScaleFactor * pix_size.y );
467
468 // calculate the bitmap start position
469 VECTOR2I start( aPos.x - drawsize.x / 2, aPos.y + drawsize.y / 2 );
470 VECTOR2D dev_start = userToDeviceCoordinates( start );
471
472 /* PDF has an uhm... simplified coordinate system handling. There is
473 *one* operator to do everything (the PS concat equivalent). At least
474 they kept the matrix stack to save restore environments. Also images
475 are always emitted at the origin with a size of 1x1 user units.
476 What we need to do is:
477 1) save the CTM end establish the new one
478 2) plot the image
479 3) restore the CTM
480 4) profit
481 */
482 fprintf( m_workFile, "q %g 0 0 %g %g %g cm\n", // Step 1
483 userToDeviceSize( drawsize.x ),
484 userToDeviceSize( drawsize.y ),
485 dev_start.x, dev_start.y );
486
487 /* An inline image is a cross between a dictionary and a stream.
488 A real ugly construct (compared with the elegance of the PDF
489 format). Also it accepts some 'abbreviations', which is stupid
490 since the content stream is usually compressed anyway... */
491 fprintf( m_workFile,
492 "BI\n"
493 " /BPC 8\n"
494 " /CS %s\n"
495 " /W %d\n"
496 " /H %d\n"
497 "ID\n", m_colorMode ? "/RGB" : "/G", pix_size.x, pix_size.y );
498
499 /* Here comes the stream (in binary!). I *could* have hex or ascii84
500 encoded it, but who cares? I'll go through zlib anyway */
501 for( int y = 0; y < pix_size.y; y++ )
502 {
503 for( int x = 0; x < pix_size.x; x++ )
504 {
505 unsigned char r = aImage.GetRed( x, y ) & 0xFF;
506 unsigned char g = aImage.GetGreen( x, y ) & 0xFF;
507 unsigned char b = aImage.GetBlue( x, y ) & 0xFF;
508
509 // PDF inline images don't support alpha, so premultiply against white background
510 if( aImage.HasAlpha() )
511 {
512 unsigned char alpha = aImage.GetAlpha( x, y ) & 0xFF;
513
514 if( alpha < 0xFF )
515 {
516 float a = 1.0 - ( (float) alpha / 255.0 );
517 r = ( int )( r + ( a * 0xFF ) ) & 0xFF;
518 g = ( int )( g + ( a * 0xFF ) ) & 0xFF;
519 b = ( int )( b + ( a * 0xFF ) ) & 0xFF;
520 }
521 }
522
523 if( aImage.HasMask() )
524 {
525 if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen()
526 && b == aImage.GetMaskBlue() )
527 {
528 r = 0xFF;
529 g = 0xFF;
530 b = 0xFF;
531 }
532 }
533
534 // As usual these days, stdio buffering has to suffeeeeerrrr
535 if( m_colorMode )
536 {
537 putc( r, m_workFile );
538 putc( g, m_workFile );
539 putc( b, m_workFile );
540 }
541 else
542 {
543 // Greyscale conversion (CIE 1931)
544 unsigned char grey = KiROUND( r * 0.2126 + g * 0.7152 + b * 0.0722 );
545 putc( grey, m_workFile );
546 }
547 }
548 }
549
550 fputs( "EI Q\n", m_workFile ); // Finish step 2 and do step 3
551}

References KiROUND(), PLOTTER::m_colorMode, m_workFile, PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ PlotPoly() [1/2]

void PLOTTER::PlotPoly ( const SHAPE_LINE_CHAIN aCornerList,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH,
void *  aData = nullptr 
)
virtualinherited

Draw a polygon ( filled or not ).

Parameters
aCornerListis the corners list (a SHAPE_LINE_CHAIN). must be closed (IsClosed() == true) for a polygon. Otherwise this is a polyline.
aFillis the type of fill.
aWidthis the line width.
aDatais an auxiliary info (mainly for gerber format).

Reimplemented in GERBER_PLOTTER.

Definition at line 682 of file plotter.cpp.

683{
684 std::vector<VECTOR2I> cornerList;
685 cornerList.reserve( aCornerList.PointCount() );
686
687 for( int ii = 0; ii < aCornerList.PointCount(); ii++ )
688 cornerList.emplace_back( aCornerList.CPoint( ii ) );
689
690 if( aCornerList.IsClosed() && cornerList.front() != cornerList.back() )
691 cornerList.emplace_back( aCornerList.CPoint( 0 ) );
692
693 PlotPoly( cornerList, aFill, aWidth, aData );
694}
bool IsClosed() const override

References SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::IsClosed(), PLOTTER::PlotPoly(), and SHAPE_LINE_CHAIN::PointCount().

◆ PlotPoly() [2/2]

void PDF_PLOTTER::PlotPoly ( const std::vector< VECTOR2I > &  aCornerList,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH,
void *  aData = nullptr 
)
overridevirtual

Polygon plotting for PDF.

Everything is supported

Implements PLOTTER.

Definition at line 401 of file PDF_plotter.cpp.

403{
404 wxASSERT( m_workFile );
405
406 if( aCornerList.size() <= 1 )
407 return;
408
409 SetCurrentLineWidth( aWidth );
410
411 VECTOR2D pos = userToDeviceCoordinates( aCornerList[0] );
412 fprintf( m_workFile, "%g %g m\n", pos.x, pos.y );
413
414 for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
415 {
416 pos = userToDeviceCoordinates( aCornerList[ii] );
417 fprintf( m_workFile, "%g %g l\n", pos.x, pos.y );
418 }
419
420 // Close path and stroke and/or fill
421 if( aFill == FILL_T::NO_FILL )
422 fputs( "S\n", m_workFile );
423 else if( aWidth == 0 )
424 fputs( "f\n", m_workFile );
425 else
426 fputs( "b\n", m_workFile );
427}

References m_workFile, NO_FILL, SetCurrentLineWidth(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ PlotText()

void PDF_PLOTTER::PlotText ( const VECTOR2I aPos,
const COLOR4D aColor,
const wxString &  aText,
const TEXT_ATTRIBUTES aAttributes,
KIFONT::FONT aFont,
void *  aData = nullptr 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 1449 of file PDF_plotter.cpp.

1454{
1455 VECTOR2I size = aAttributes.m_Size;
1456
1457 // PDF files do not like 0 sized texts which create broken files.
1458 if( size.x == 0 || size.y == 0 )
1459 return;
1460
1461 if( aAttributes.m_Mirrored )
1462 size.x = -size.x;
1463
1464 PDF_PLOTTER::Text( aPos, aColor, aText, aAttributes.m_Angle, size,
1465 aAttributes.m_Halign, aAttributes.m_Valign,
1466 aAttributes.m_StrokeWidth,
1467 aAttributes.m_Italic, aAttributes.m_Bold,
1468 aAttributes.m_Multiline,
1469 aFont, aData );
1470}
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=false, KIFONT::FONT *aFont=nullptr, void *aData=nullptr) override
Draw text with the plotter.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign

References TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Bold, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_Mirrored, TEXT_ATTRIBUTES::m_Multiline, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, Text(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ postscriptOverlinePositions()

void PSLIKE_PLOTTER::postscriptOverlinePositions ( const wxString &  aText,
int  aXSize,
bool  aItalic,
bool  aBold,
std::vector< int > *  pos_pairs 
)
protectedinherited

Computes the x coordinates for the overlining in a string of text.

Fills the passed vector with couples of (start, stop) values to be used in the text coordinate system (use computeTextParameters to obtain the parameters to establish such a system)

Definition at line 352 of file PS_plotter.cpp.

355{
356 /* XXX This function is *too* similar to returnPostscriptTextWidth.
357 Consider merging them... */
358 const double *width_table = aBold ? ( aItalic ? hvbo_widths : hvb_widths )
359 : ( aItalic ? hvo_widths : hv_widths );
360 double tally = 0;
361
362 for( unsigned i = 0; i < aText.length(); i++ )
363 {
364 wchar_t AsciiCode = aText[i];
365
366 // Skip the negation marks and untabled points
367 if( AsciiCode != '~' && AsciiCode < 256 )
368 {
369 tally += width_table[AsciiCode];
370 }
371 else
372 {
373 if( AsciiCode == '~' )
374 pos_pairs->push_back( KiROUND( aXSize * tally / postscriptTextAscent ) );
375 }
376 }
377
378 // Special rule: we have to complete the last bar if the ~ aren't matched
379 if( pos_pairs->size() % 2 == 1 )
380 pos_pairs->push_back( KiROUND( aXSize * tally / postscriptTextAscent ) );
381}
const double hvbo_widths[256]
Character widths for Helvetica-BoldOblique.
const double hvb_widths[256]
Character widths for Helvetica-Bold.
const double hv_widths[256]
Character widths for Helvetica.
Definition: PS_plotter.cpp:995
const double hvo_widths[256]
Character widths for Helvetica-Oblique.

References hv_widths, hvb_widths, hvbo_widths, hvo_widths, KiROUND(), and PSLIKE_PLOTTER::postscriptTextAscent.

◆ Rect()

void PDF_PLOTTER::Rect ( const VECTOR2I p1,
const VECTOR2I p2,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Rectangles in PDF.

Supported by the native operator.

Implements PLOTTER.

Definition at line 217 of file PDF_plotter.cpp.

218{
219 wxASSERT( m_workFile );
220 VECTOR2D p1_dev = userToDeviceCoordinates( p1 );
221 VECTOR2D p2_dev = userToDeviceCoordinates( p2 );
222
223 SetCurrentLineWidth( width );
224 fprintf( m_workFile, "%g %g %g %g re %c\n", p1_dev.x, p1_dev.y,
225 p2_dev.x - p1_dev.x, p2_dev.y - p1_dev.y, fill == FILL_T::NO_FILL ? 'S' : 'B' );
226}

References m_workFile, NO_FILL, SetCurrentLineWidth(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ RenderSettings()

◆ returnPostscriptTextWidth()

int PSLIKE_PLOTTER::returnPostscriptTextWidth ( const wxString &  aText,
int  aXSize,
bool  aItalic,
bool  aBold 
)
protectedinherited

Sister function for the GraphicTextWidth in drawtxt.cpp Does the same processing (i.e.

calculates a text string width) but using postscript metrics for the Helvetica font (optionally used for PS and PDF plotting

Definition at line 329 of file PS_plotter.cpp.

331{
332 const double *width_table = aBold ? ( aItalic ? hvbo_widths : hvb_widths )
333 : ( aItalic ? hvo_widths : hv_widths );
334 double tally = 0;
335
336 for( unsigned i = 0; i < aText.length(); i++ )
337 {
338 wchar_t AsciiCode = aText[i];
339
340 // Skip the negation marks and untabled points.
341 if( AsciiCode != '~' && AsciiCode < 256 )
342 {
343 tally += width_table[AsciiCode];
344 }
345 }
346
347 // Widths are proportional to height, but height is enlarged by a scaling factor.
348 return KiROUND( aXSize * tally / postscriptTextAscent );
349}

References hv_widths, hvb_widths, hvbo_widths, hvo_widths, KiROUND(), and PSLIKE_PLOTTER::postscriptTextAscent.

Referenced by PSLIKE_PLOTTER::computeTextParameters().

◆ segmentAsOval()

void PLOTTER::segmentAsOval ( const VECTOR2I start,
const VECTOR2I end,
int  width,
OUTLINE_MODE  tracemode 
)
protectedinherited

Convert a thick segment and plot it as an oval.

Definition at line 481 of file plotter.cpp.

483{
484 VECTOR2I center( ( start.x + end.x ) / 2, ( start.y + end.y ) / 2 );
485 VECTOR2I size( end.x - start.x, end.y - start.y );
486 EDA_ANGLE orient( size );
487 orient = -orient; // this is due to our Y axis orientation
488
489 size.x = KiROUND( EuclideanNorm( size ) ) + aWidth;
490 size.y = aWidth;
491
492 FlashPadOval( center, size, orient, aTraceMode, nullptr );
493}
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0

References EuclideanNorm(), PLOTTER::FlashPadOval(), KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PLOTTER::ThickSegment(), GERBER_PLOTTER::ThickSegment(), and HPGL_PLOTTER::ThickSegment().

◆ SetColor()

void PSLIKE_PLOTTER::SetColor ( const COLOR4D color)
overridevirtualinherited

The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values, the subclass emits the operator to actually do it.

Implements PLOTTER.

Reimplemented in SVG_PLOTTER.

Definition at line 62 of file PS_plotter.cpp.

63{
64 if( m_colorMode )
65 {
66 if( m_negativeMode )
67 emitSetRGBColor( 1 - color.r, 1 - color.g, 1 - color.b, color.a );
68 else
70 }
71 else
72 {
73 /* B/W Mode - Use BLACK or WHITE for all items
74 * note the 2 colors are used in B&W mode, mainly by Pcbnew to draw
75 * holes in white on pads in black
76 */
77 double k = 1; // White
78
79 if( color != COLOR4D::WHITE )
80 k = 0;
81
82 if( m_negativeMode )
83 emitSetRGBColor( 1 - k, 1 - k, 1 - k, 1.0 );
84 else
85 emitSetRGBColor( k, k, k, 1.0 );
86 }
87}
int color
Definition: DXF_plotter.cpp:57
bool m_negativeMode
Definition: plotter.h:657
virtual void emitSetRGBColor(double r, double g, double b, double a)=0
Virtual primitive for emitting the setrgbcolor operator.
@ WHITE
Definition: color4d.h:46

References color, PSLIKE_PLOTTER::emitSetRGBColor(), PLOTTER::m_colorMode, PLOTTER::m_negativeMode, and WHITE.

Referenced by SCH_PLOTTER::plotOneSheetPS(), PS_PLOTTER::PlotText(), SVG_PLOTTER::SetColor(), PS_PLOTTER::Text(), and Text().

◆ SetColorMode()

virtual void PLOTTER::SetColorMode ( bool  aColorMode)
inlinevirtualinherited

◆ SetCreator()

◆ SetCurrentLineWidth()

void PDF_PLOTTER::SetCurrentLineWidth ( int  width,
void *  aData = nullptr 
)
overridevirtual

Pen width setting for PDF.

Since the specs explicitly says that a 0 width is a bad thing to use (since it results in 1 pixel traces), we convert such requests to the minimal width (like 1) Note pen width = 0 is used in plot polygons to plot filled polygons with no outline thickness. Use in this case pen width = 1 does not actually change the polygon.

Implements PLOTTER.

Definition at line 144 of file PDF_plotter.cpp.

145{
146 wxASSERT( m_workFile );
147
148 if( aWidth == DO_NOT_SET_LINE_WIDTH )
149 return;
150 else if( aWidth == USE_DEFAULT_LINE_WIDTH )
152
153 if( aWidth == 0 )
154 aWidth = 1;
155
156 wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" );
157
158 if( aWidth != m_currentPenWidth )
159 fprintf( m_workFile, "%g w\n", userToDeviceSize( aWidth ) );
160
161 m_currentPenWidth = aWidth;
162}
int GetDefaultPenWidth() const
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:113

References PLOTTER::DO_NOT_SET_LINE_WIDTH, KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), PLOTTER::m_currentPenWidth, PLOTTER::m_renderSettings, m_workFile, PLOTTER::USE_DEFAULT_LINE_WIDTH, and PLOTTER::userToDeviceSize().

Referenced by Arc(), Circle(), PlotPoly(), Rect(), and Text().

◆ SetDash()

void PDF_PLOTTER::SetDash ( int  aLineWidth,
PLOT_DASH_TYPE  aLineStyle 
)
overridevirtual

PDF supports dashed lines.

Implements PLOTTER.

Definition at line 182 of file PDF_plotter.cpp.

183{
184 wxASSERT( m_workFile );
185
186 switch( aLineStyle )
187 {
189 fprintf( m_workFile, "[%d %d] 0 d\n",
190 (int) GetDashMarkLenIU( aLineWidth ), (int) GetDashGapLenIU( aLineWidth ) );
191 break;
192
194 fprintf( m_workFile, "[%d %d] 0 d\n",
195 (int) GetDotMarkLenIU( aLineWidth ), (int) GetDashGapLenIU( aLineWidth ) );
196 break;
197
199 fprintf( m_workFile, "[%d %d %d %d] 0 d\n",
200 (int) GetDashMarkLenIU( aLineWidth ), (int) GetDashGapLenIU( aLineWidth ),
201 (int) GetDotMarkLenIU( aLineWidth ), (int) GetDashGapLenIU( aLineWidth ) );
202 break;
203
205 fprintf( m_workFile, "[%d %d %d %d %d %d] 0 d\n",
206 (int) GetDashMarkLenIU( aLineWidth ), (int) GetDashGapLenIU( aLineWidth ),
207 (int) GetDotMarkLenIU( aLineWidth ), (int) GetDashGapLenIU( aLineWidth ),
208 (int) GetDotMarkLenIU( aLineWidth ), (int) GetDashGapLenIU( aLineWidth ) );
209 break;
210
211 default:
212 fputs( "[] 0 d\n", m_workFile );
213 }
214}
double GetDotMarkLenIU(int aLineWidth) const
Definition: plotter.cpp:131
double GetDashGapLenIU(int aLineWidth) const
Definition: plotter.cpp:143
double GetDashMarkLenIU(int aLineWidth) const
Definition: plotter.cpp:137

References DASH, DASHDOT, DASHDOTDOT, DOT, PLOTTER::GetDashGapLenIU(), PLOTTER::GetDashMarkLenIU(), PLOTTER::GetDotMarkLenIU(), and m_workFile.

◆ SetGerberCoordinatesFormat()

virtual void PLOTTER::SetGerberCoordinatesFormat ( int  aResolution,
bool  aUseInches = false 
)
inlinevirtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 520 of file plotter.h.

521 {
522 // NOP for most plotters. Only for Gerber plotter
523 }

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile(), and initializePlotter().

◆ SetLayerPolarity()

virtual void PLOTTER::SetLayerPolarity ( bool  aPositive)
inlinevirtualinherited

Set the current Gerber layer polarity to positive or negative by writing %LPD*% or %LPC*% to the Gerber file, respectively.

(obviously starts a new Gerber layer, too)

Parameters
aPositiveis the layer polarity and true for positive. It's not useful with most other plotter since they can't 'scratch' the film like photoplotter imagers do

Reimplemented in GERBER_PLOTTER.

Definition at line 506 of file plotter.h.

507 {
508 // NOP for most plotters
509 }

Referenced by PlotOneBoardLayer().

◆ SetNegative()

virtual void PLOTTER::SetNegative ( bool  aNegative)
inlinevirtualinherited

Definition at line 130 of file plotter.h.

130{ m_negativeMode = aNegative; }

References PLOTTER::m_negativeMode.

Referenced by FillNegativeKnockout().

◆ SetPageSettings()

◆ SetRenderSettings()

◆ SetScaleAdjust()

void PSLIKE_PLOTTER::SetScaleAdjust ( double  scaleX,
double  scaleY 
)
inlineinherited

Set the 'fine' scaling for the postscript engine.

Definition at line 57 of file plotters_pslike.h.

58 {
59 plotScaleAdjX = scaleX;
60 plotScaleAdjY = scaleY;
61 }
double plotScaleAdjX
Fine user scale adjust ( = 1.0 if no correction)

References PSLIKE_PLOTTER::plotScaleAdjX, and PSLIKE_PLOTTER::plotScaleAdjY.

Referenced by StartPlotBoard().

◆ SetSvgCoordinatesFormat()

virtual void PLOTTER::SetSvgCoordinatesFormat ( unsigned  aPrecision)
inlinevirtualinherited

Set the number of digits for mantissa in coordinates in mm for SVG plotter.

Reimplemented in SVG_PLOTTER.

Definition at line 526 of file plotter.h.

527 {
528 // NOP for most plotters. Only for SVG plotter
529 }

Referenced by initializePlotter().

◆ SetTextMode()

virtual void PSLIKE_PLOTTER::SetTextMode ( PLOT_TEXT_MODE  mode)
inlineoverridevirtualinherited

PS and PDF fully implement native text (for the Latin-1 subset)

Reimplemented from PLOTTER.

Definition at line 48 of file plotters_pslike.h.

49 {
50 if( mode != PLOT_TEXT_MODE::DEFAULT )
51 m_textMode = mode;
52 }
PLOT_TEXT_MODE m_textMode
How to draw text.

References DEFAULT, and PSLIKE_PLOTTER::m_textMode.

Referenced by SVG_PLOTTER::SVG_PLOTTER().

◆ SetTitle()

virtual void PLOTTER::SetTitle ( const wxString &  aTitle)
inlinevirtualinherited

Definition at line 161 of file plotter.h.

161{ m_title = aTitle; }

References PLOTTER::m_title.

Referenced by SCH_PLOTTER::createPDFFile().

◆ SetViewport()

void PDF_PLOTTER::SetViewport ( const VECTOR2I aOffset,
double  aIusPerDecimil,
double  aScale,
bool  aMirror 
)
overridevirtual

PDF can have multiple pages, so SetPageSettings can be called with the outputFile open (but not inside a page stream!)

Implements PLOTTER.

Definition at line 128 of file PDF_plotter.cpp.

130{
131 m_plotMirror = aMirror;
132 m_plotOffset = aOffset;
133 m_plotScale = aScale;
134 m_IUsPerDecimil = aIusPerDecimil;
135
136 // The CTM is set to 1 user unit per decimal
137 m_iuPerDeviceUnit = 1.0 / aIusPerDecimil;
138
139 /* The paper size in this engine is handled page by page
140 Look in the StartPage function */
141}
double m_iuPerDeviceUnit
Definition: plotter.h:644
VECTOR2I m_plotOffset
Definition: plotter.h:646
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:636

References PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_IUsPerDecimil, PLOTTER::m_plotMirror, PLOTTER::m_plotOffset, and PLOTTER::m_plotScale.

◆ sketchOval()

void PLOTTER::sketchOval ( const VECTOR2I aPos,
const VECTOR2I aSize,
const EDA_ANGLE aOrient,
int  aWidth 
)
protectedinherited

Definition at line 496 of file plotter.cpp.

498{
499 SetCurrentLineWidth( aWidth );
500
501 EDA_ANGLE orient( aOrient );
502 VECTOR2I size( aSize );
503
504 if( size.x > size.y )
505 {
506 std::swap( size.x, size.y );
507 orient += ANGLE_90;
508 }
509
510 int deltaxy = size.y - size.x; /* distance between centers of the oval */
511 int radius = size.x / 2;
512
513 // Build a vertical oval shape giving the start and end points of arcs and edges,
514 // and the middle point of arcs
515 std::vector<VECTOR2I> corners;
516 corners.reserve( 6 );
517 // Shape is (x = corner and arc ends, c = arc centre)
518 // xcx
519 //
520 // xcx
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 );
528
529 // Rotate and move to the actual position
530 for( size_t ii = 0; ii < corners.size(); ii++ )
531 {
532 RotatePoint( corners[ii], orient );
533 corners[ii] += aPos;
534 }
535
536 // Gen shape:
537 MoveTo( corners[0] );
538 FinishTo( corners[1] );
539
540 Arc( corners[2], orient + ANGLE_180, orient + ANGLE_360, radius, FILL_T::NO_FILL );
541
542 MoveTo( corners[3] );
543 FinishTo( corners[4] );
544
545 Arc( corners[5], orient, orient + ANGLE_180, radius, FILL_T::NO_FILL );
546}
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.
Definition: plotter.cpp:149
static constexpr EDA_ANGLE & ANGLE_180
Definition: eda_angle.h:433

References ANGLE_180, ANGLE_360, ANGLE_90, PLOTTER::Arc(), PLOTTER::FinishTo(), PLOTTER::MoveTo(), NO_FILL, RotatePoint(), PLOTTER::SetCurrentLineWidth(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GERBER_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), and DXF_PLOTTER::FlashPadOval().

◆ StartBlock()

virtual void PLOTTER::StartBlock ( void *  aData)
inlinevirtualinherited

calling this function allows one to define the beginning of a group of drawing items, for instance in SVG or Gerber format.

(example: group all segments of a letter or a text)

Parameters
aDatacan define any parameter for most of plotters: do nothing

Reimplemented in GERBER_PLOTTER, and SVG_PLOTTER.

Definition at line 538 of file plotter.h.

538{}

Referenced by SCH_SYMBOL::Plot(), BRDITEMS_PLOTTER::PlotFilledAreas(), and PlotStandardLayer().

◆ StartPage()

void PDF_PLOTTER::StartPage ( const wxString &  aPageNumber,
const wxString &  aPageName = wxEmptyString 
)
virtual

Start a new page in the PDF document.

Definition at line 681 of file PDF_plotter.cpp.

682{
683 wxASSERT( m_outputFile );
684 wxASSERT( !m_workFile );
685
686 m_pageNumbers.push_back( aPageNumber );
687 m_pageName = aPageName;
688
689 // Compute the paper size in IUs
693
694 // Open the content stream; the page object will go later
696
697 /* Now, until ClosePage *everything* must be wrote in workFile, to be
698 compressed later in closePdfStream */
699
700 // Default graphic settings (coordinate system, default color and line style)
701 fprintf( m_workFile,
702 "%g 0 0 %g 0 0 cm 1 J 1 j 0 0 0 rg 0 0 0 RG %g w\n",
703 0.0072 * plotScaleAdjX, 0.0072 * plotScaleAdjY,
705}
int startPdfStream(int handle=-1)
Starts a PDF stream (for the page).
VECTOR2I m_paperSize
Definition: plotter.h:666

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), PAGE_INFO::GetSizeMils(), PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_outputFile, PLOTTER::m_pageInfo, m_pageName, m_pageNumbers, m_pageStreamHandle, PLOTTER::m_paperSize, PLOTTER::m_renderSettings, m_workFile, PSLIKE_PLOTTER::plotScaleAdjX, PSLIKE_PLOTTER::plotScaleAdjY, startPdfStream(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_PLOTTER::createPDFFile(), and StartPlot().

◆ startPdfObject()

int PDF_PLOTTER::startPdfObject ( int  handle = -1)
protected

Open a new PDF object and returns the handle if the parameter is -1.

Otherwise fill in the xref entry for the passed object

Definition at line 561 of file PDF_plotter.cpp.

562{
563 wxASSERT( m_outputFile );
564 wxASSERT( !m_workFile );
565
566 if( handle < 0)
567 handle = allocPdfObject();
568
569 m_xrefTable[handle] = ftell( m_outputFile );
570 fprintf( m_outputFile, "%d 0 obj\n", handle );
571 return handle;
572}

References allocPdfObject(), PLOTTER::m_outputFile, m_workFile, and m_xrefTable.

Referenced by ClosePage(), closePdfStream(), emitGoToAction(), emitOutline(), emitOutlineNode(), EndPlot(), and startPdfStream().

◆ startPdfStream()

int PDF_PLOTTER::startPdfStream ( int  handle = -1)
protected

Starts a PDF stream (for the page).

Returns the object handle opened Pass -1 (default) for a fresh object. Especially from PDF 1.5 streams can contain a lot of things, but for the moment we only handle page content.

Definition at line 583 of file PDF_plotter.cpp.

584{
585 wxASSERT( m_outputFile );
586 wxASSERT( !m_workFile );
587 handle = startPdfObject( handle );
588
589 // This is guaranteed to be handle+1 but needs to be allocated since
590 // you could allocate more object during stream preparation
592
593 if( ADVANCED_CFG::GetCfg().m_DebugPDFWriter )
594 {
595 fprintf( m_outputFile,
596 "<< /Length %d 0 R >>\n" // Length is deferred
597 "stream\n", handle + 1 );
598 }
599 else
600 {
601 fprintf( m_outputFile,
602 "<< /Length %d 0 R /Filter /FlateDecode >>\n" // Length is deferred
603 "stream\n", handle + 1 );
604 }
605
606 // Open a temporary file to accumulate the stream
607 m_workFilename = wxFileName::CreateTempFileName( "" );
608 m_workFile = wxFopen( m_workFilename, wxT( "w+b" ) );
609 wxASSERT( m_workFile );
610 return handle;
611}

References allocPdfObject(), ADVANCED_CFG::GetCfg(), PLOTTER::m_outputFile, m_streamLengthHandle, m_workFile, m_workFilename, and startPdfObject().

Referenced by StartPage().

◆ StartPlot() [1/2]

bool PDF_PLOTTER::StartPlot ( const wxString &  aPageNumber)
overridevirtual

The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be closed and reopened.

Between each page parameters can be set.

Implements PLOTTER.

Definition at line 871 of file PDF_plotter.cpp.

872{
873 return StartPlot( aPageNumber, wxEmptyString );
874}
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...

References StartPlot().

Referenced by SCH_PLOTTER::createPDFFile(), and StartPlot().

◆ StartPlot() [2/2]

bool PDF_PLOTTER::StartPlot ( const wxString &  aPageNumber,
const wxString &  aPageName = wxEmptyString 
)
virtual

Definition at line 877 of file PDF_plotter.cpp.

878{
879 wxASSERT( m_outputFile );
880
881 // First things first: the customary null object
882 m_xrefTable.clear();
883 m_xrefTable.push_back( 0 );
884 m_hyperlinksInPage.clear();
886 m_hyperlinkHandles.clear();
888 m_bookmarksInPage.clear();
890
891 m_outlineRoot = std::make_unique<OUTLINE_NODE>();
892
893 /* The header (that's easy!). The second line is binary junk required
894 to make the file binary from the beginning (the important thing is
895 that they must have the bit 7 set) */
896 fputs("%PDF-1.5\n%\200\201\202\203\n", m_outputFile);
897
898 /* Allocate an entry for the page tree root, it will go in every page parent entry */
900
901 /* In the same way, the font resource dictionary is used by every page
902 (it *could* be inherited via the Pages tree */
904
905 /* Now, the PDF is read from the end, (more or less)... so we start
906 with the page stream for page 1. Other more important stuff is written
907 at the end */
908 StartPage( aPageNumber, aPageName );
909 return true;
910}
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString)
Start a new page in the PDF document.

References allocPdfObject(), m_bookmarksInPage, m_fontResDictHandle, m_hyperlinkHandles, m_hyperlinkMenuHandles, m_hyperlinkMenusInPage, m_hyperlinksInPage, m_outlineRoot, PLOTTER::m_outputFile, m_pageTreeHandle, m_totalOutlineNodes, m_xrefTable, and StartPage().

◆ Text()

void PDF_PLOTTER::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 = false,
KIFONT::FONT aFont = nullptr,
void *  aData = nullptr 
)
overridevirtual

Draw text with the plotter.

For convenience it accept the color to use for specific plotters aData is used to pass extra parameters (GERBER).

Parameters
aPosis the text position (according to aH_justify, aV_justify).
aColoris the text color.
aTextis the text to draw.
aOrientis the angle.
aSizeis the text size (size.x or size.y can be < 0 for mirrored texts).
aH_justifyis the horizontal justification (Left, center, right).
aV_justifyis the vertical justification (bottom, center, top).
aPenWidthis the line width (if = 0, use plot default line width).
aItalicis the true to simulate an italic font.
aBolduse true to use a bold font Useful only with default width value (aPenWidth = 0).
aMultilineAlloweduse true to plot text as multiline, otherwise single line.
aDatais a parameter used by some plotters in SetCurrentLineWidth(), not directly used here.

Reimplemented from PLOTTER.

Definition at line 1349 of file PDF_plotter.cpp.

1362{
1363 // PDF files do not like 0 sized texts which create broken files.
1364 if( aSize.x == 0 || aSize.y == 0 )
1365 return;
1366
1367 // Render phantom text (which will be searchable) behind the stroke font. This won't
1368 // be pixel-accurate, but it doesn't matter for searching.
1369 int render_mode = 3; // invisible
1370
1371 VECTOR2I pos( aPos );
1372 const char *fontname = aItalic ? ( aBold ? "/KicadFontBI" : "/KicadFontI" )
1373 : ( aBold ? "/KicadFontB" : "/KicadFont" );
1374
1375 // Compute the copious transformation parameters of the Current Transform Matrix
1376 double ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f;
1377 double wideningFactor, heightFactor;
1378
1379 VECTOR2I t_size( std::abs( aSize.x ), std::abs( aSize.y ) );
1380
1381 computeTextParameters( aPos, aText, aOrient, t_size, m_plotMirror, aH_justify,
1382 aV_justify, aWidth, aItalic, aBold, &wideningFactor, &ctm_a,
1383 &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
1384
1385 SetColor( aColor );
1386 SetCurrentLineWidth( aWidth, aData );
1387
1388 wxStringTokenizer str_tok( aText, " ", wxTOKEN_RET_DELIMS );
1389
1390 // If aFont is not specilied (== nullptr), use the default kicad stroke font
1391 if( !aFont )
1392 aFont = KIFONT::FONT::GetFont();
1393
1394 VECTOR2I full_box( aFont->StringBoundaryLimits( aText, t_size, aWidth, aBold, aItalic ) );
1395 VECTOR2I box_x( full_box.x, 0 );
1396 VECTOR2I box_y( 0, full_box.y );
1397
1398 RotatePoint( box_x, aOrient );
1399 RotatePoint( box_y, aOrient );
1400
1401 if( aH_justify == GR_TEXT_H_ALIGN_CENTER )
1402 pos -= box_x / 2;
1403 else if( aH_justify == GR_TEXT_H_ALIGN_RIGHT )
1404 pos -= box_x;
1405
1406 if( aV_justify == GR_TEXT_V_ALIGN_CENTER )
1407 pos += box_y / 2;
1408 else if( aV_justify == GR_TEXT_V_ALIGN_TOP )
1409 pos += box_y;
1410
1411 while( str_tok.HasMoreTokens() )
1412 {
1413 wxString word = str_tok.GetNextToken();
1414
1415 computeTextParameters( pos, word, aOrient, t_size, m_plotMirror, GR_TEXT_H_ALIGN_LEFT,
1416 GR_TEXT_V_ALIGN_BOTTOM, aWidth, aItalic, aBold, &wideningFactor, &ctm_a,
1417 &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
1418
1419 // Extract the changed width and rotate by the orientation to get the offset for the
1420 // next word
1421 VECTOR2I bbox( aFont->StringBoundaryLimits( word, t_size, aWidth, aBold, aItalic ).x, 0 );
1422 RotatePoint( bbox, aOrient );
1423 pos += bbox;
1424
1425 // Don't try to output a blank string
1426 if( word.Trim( false ).Trim( true ).empty() )
1427 continue;
1428
1429 /* We use the full CTM instead of the text matrix because the same
1430 coordinate system will be used for the overlining. Also the %f
1431 for the trig part of the matrix to avoid %g going in exponential
1432 format (which is not supported) */
1433 fprintf( m_workFile, "q %f %f %f %f %g %g cm BT %s %g Tf %d Tr %g Tz ",
1434 ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f,
1435 fontname, heightFactor, render_mode, wideningFactor * 100 );
1436
1437 std::string txt_pdf = encodeStringForPlotter( word );
1438 fprintf( m_workFile, "%s Tj ET\n", txt_pdf.c_str() );
1439 // Restore the CTM
1440 fputs( "Q\n", m_workFile );
1441 }
1442
1443 // Plot the stroked text (if requested)
1444 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
1445 aBold, aMultilineAllowed, aFont );
1446}
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:138
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic) const
Compute the boundary limits of aText (the bounding box of all shapes).
Definition: font.cpp:357
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.
Definition: plotter.cpp:697
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values,...
Definition: PS_plotter.cpp:62
void computeTextParameters(const VECTOR2I &aPos, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, bool aMirror, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, double *wideningFactor, double *ctm_a, double *ctm_b, double *ctm_c, double *ctm_d, double *ctm_e, double *ctm_f, double *heightFactor)
This is the core for postscript/PDF text alignment.
Definition: PS_plotter.cpp:401
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418

References std::abs(), PSLIKE_PLOTTER::computeTextParameters(), encodeStringForPlotter(), KIFONT::FONT::GetFont(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, PLOTTER::m_plotMirror, m_workFile, render_mode, RotatePoint(), PSLIKE_PLOTTER::SetColor(), SetCurrentLineWidth(), KIFONT::FONT::StringBoundaryLimits(), PLOTTER::Text(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PlotText().

◆ ThickArc() [1/3]

void PLOTTER::ThickArc ( const EDA_SHAPE aArcShape,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 620 of file plotter.cpp.

622{
623 ThickArc( aArcShape.getCenter(),aArcShape.GetStart(), aArcShape.GetEnd(),
624 aArcShape.GetWidth(), aTraceMode, aData );
625}
VECTOR2I getCenter() const
Definition: eda_shape.cpp:444
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
int GetWidth() const
Definition: eda_shape.h:109
virtual void ThickArc(const VECTOR2I &aCentre, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, OUTLINE_MODE aTraceMode, void *aData)
Definition: plotter.cpp:592

References EDA_SHAPE::getCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), EDA_SHAPE::GetWidth(), and PLOTTER::ThickArc().

◆ ThickArc() [2/3]

void PLOTTER::ThickArc ( const VECTOR2I aCentre,
const EDA_ANGLE StAngle,
const EDA_ANGLE EndAngle,
int  aRadius,
int  aWidth,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
protectedvirtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 573 of file plotter.cpp.

576{
577 if( aTraceMode == FILLED )
578 {
579 Arc( centre, aStartAngle, aEndAngle, aRadius, FILL_T::NO_FILL, aWidth );
580 }
581 else
582 {
584 Arc( centre, aStartAngle, aEndAngle, aRadius - ( aWidth - m_currentPenWidth ) / 2,
585 FILL_T::NO_FILL, -1 );
586 Arc( centre, aStartAngle, aEndAngle, aRadius + ( aWidth - m_currentPenWidth ) / 2,
587 FILL_T::NO_FILL, -1 );
588 }
589}

References PLOTTER::Arc(), FILLED, PLOTTER::m_currentPenWidth, NO_FILL, and PLOTTER::SetCurrentLineWidth().

◆ ThickArc() [3/3]

void PLOTTER::ThickArc ( const VECTOR2I aCentre,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 592 of file plotter.cpp.

595{
596 if( aTraceMode == FILLED )
597 {
598 Arc( aCentre, aStart, aEnd, FILL_T::NO_FILL, aWidth, GetPlotterArcHighDef() );
599 }
600 else
601 {
603 int radius = ( aStart - aCentre ).EuclideanNorm();
604
605 int new_radius = radius - ( aWidth - m_currentPenWidth ) / 2;
606 VECTOR2I start = ( aStart - aCentre ).Resize( new_radius ) + aCentre;
607 VECTOR2I end = ( aEnd - aCentre ).Resize( new_radius ) + aCentre;
608
609 Arc( aCentre, start, end, FILL_T::NO_FILL, -1, GetPlotterArcHighDef() );
610
611 new_radius = radius + ( aWidth - m_currentPenWidth ) / 2;
612 start = ( aStart - aCentre ).Resize( new_radius ) + aCentre;
613 end = ( aEnd - aCentre ).Resize( new_radius ) + aCentre;
614
615 Arc( aCentre, start, end, FILL_T::NO_FILL, -1, GetPlotterArcHighDef() );
616 }
617}

References PLOTTER::Arc(), EuclideanNorm(), FILLED, PLOTTER::GetPlotterArcHighDef(), PLOTTER::m_currentPenWidth, NO_FILL, and PLOTTER::SetCurrentLineWidth().

Referenced by BRDITEMS_PLOTTER::PlotFootprintShape(), BRDITEMS_PLOTTER::PlotPcbShape(), PlotStandardLayer(), and PLOTTER::ThickArc().

◆ ThickCircle()

void PLOTTER::ThickCircle ( const VECTOR2I pos,
int  diametre,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 652 of file plotter.cpp.

654{
655 if( tracemode == FILLED )
656 {
657 Circle( pos, diametre, FILL_T::NO_FILL, width );
658 }
659 else
660 {
662 Circle( pos, diametre - width + m_currentPenWidth, FILL_T::NO_FILL, -1 );
663 Circle( pos, diametre + width - m_currentPenWidth, FILL_T::NO_FILL, -1 );
664 }
665}

References PLOTTER::Circle(), FILLED, PLOTTER::m_currentPenWidth, NO_FILL, and PLOTTER::SetCurrentLineWidth().

Referenced by BRDITEMS_PLOTTER::PlotFootprintShape(), and BRDITEMS_PLOTTER::PlotPcbShape().

◆ ThickRect()

void PLOTTER::ThickRect ( const VECTOR2I p1,
const VECTOR2I p2,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 628 of file plotter.cpp.

630{
631 if( tracemode == FILLED )
632 {
633 Rect( p1, p2, FILL_T::NO_FILL, width );
634 }
635 else
636 {
638 VECTOR2I offsetp1( p1.x - ( width - m_currentPenWidth ) / 2,
639 p1.y - (width - m_currentPenWidth) / 2 );
640 VECTOR2I offsetp2( p2.x + ( width - m_currentPenWidth ) / 2,
641 p2.y + (width - m_currentPenWidth) / 2 );
642 Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
643 offsetp1.x += ( width - m_currentPenWidth );
644 offsetp1.y += ( width - m_currentPenWidth );
645 offsetp2.x -= ( width - m_currentPenWidth );
646 offsetp2.y -= ( width - m_currentPenWidth );
647 Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
648 }
649}
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0

References FILLED, PLOTTER::m_currentPenWidth, NO_FILL, PLOTTER::Rect(), PLOTTER::SetCurrentLineWidth(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ ThickSegment()

void PLOTTER::ThickSegment ( const VECTOR2I start,
const VECTOR2I end,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in DXF_PLOTTER, GERBER_PLOTTER, and HPGL_PLOTTER.

Definition at line 549 of file plotter.cpp.

551{
552 if( tracemode == FILLED )
553 {
554 if( start == end )
555 {
556 Circle( start, width, FILL_T::FILLED_SHAPE, 0 );
557 }
558 else
559 {
560 SetCurrentLineWidth( width );
561 MoveTo( start );
562 FinishTo( end );
563 }
564 }
565 else
566 {
568 segmentAsOval( start, end, width, tracemode );
569 }
570}
void segmentAsOval(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode)
Convert a thick segment and plot it as an oval.
Definition: plotter.cpp:481

References PLOTTER::Circle(), FILLED, FILLED_SHAPE, PLOTTER::FinishTo(), PLOTTER::MoveTo(), PLOTTER::segmentAsOval(), and PLOTTER::SetCurrentLineWidth().

Referenced by PSLIKE_PLOTTER::FlashPadOval(), SCH_SYMBOL::PlotDNP(), BRDITEMS_PLOTTER::PlotFootprintShape(), PlotLayerOutlines(), BRDITEMS_PLOTTER::PlotPcbShape(), and PlotStandardLayer().

◆ userToDeviceCoordinates()

VECTOR2D PLOTTER::userToDeviceCoordinates ( const VECTOR2I aCoordinate)
protectedvirtualinherited

Modify coordinates according to the orientation, scale factor, and offsets trace.

Also convert from a VECTOR2I to VECTOR2D, since some output engines needs floating point coordinates.

Definition at line 90 of file plotter.cpp.

91{
92 VECTOR2I pos = aCoordinate - m_plotOffset;
93
94 double x = pos.x * m_plotScale;
95 double y = ( m_paperSize.y - pos.y * m_plotScale );
96
97 if( m_plotMirror )
98 {
100 x = ( m_paperSize.x - pos.x * m_plotScale );
101 else
102 y = pos.y * m_plotScale;
103 }
104
105 if( m_yaxisReversed )
106 y = m_paperSize.y - y;
107
110
111 return VECTOR2D( x, y );
112}
bool m_mirrorIsHorizontal
Definition: plotter.h:649
bool m_yaxisReversed
Definition: plotter.h:650

References PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_mirrorIsHorizontal, PLOTTER::m_paperSize, PLOTTER::m_plotMirror, PLOTTER::m_plotOffset, PLOTTER::m_plotScale, PLOTTER::m_yaxisReversed, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DXF_PLOTTER::Arc(), HPGL_PLOTTER::Arc(), SVG_PLOTTER::Arc(), PS_PLOTTER::Arc(), Arc(), SVG_PLOTTER::BezierCurve(), HPGL_PLOTTER::Circle(), DXF_PLOTTER::Circle(), PS_PLOTTER::Circle(), Circle(), SVG_PLOTTER::Circle(), PSLIKE_PLOTTER::computeTextParameters(), GERBER_PLOTTER::FlashPadChamferRoundRect(), HPGL_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadCustom(), GERBER_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadRect(), GERBER_PLOTTER::FlashPadRoundRect(), GERBER_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::FlashRegularPolygon(), DXF_PLOTTER::PenTo(), GERBER_PLOTTER::PenTo(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::plotArc(), PS_PLOTTER::PlotImage(), PlotImage(), DXF_PLOTTER::plotOneLineOfText(), HPGL_PLOTTER::PlotPoly(), PS_PLOTTER::PlotPoly(), PlotPoly(), SVG_PLOTTER::PlotPoly(), PS_PLOTTER::PlotText(), HPGL_PLOTTER::Rect(), PS_PLOTTER::Rect(), Rect(), SVG_PLOTTER::Rect(), PS_PLOTTER::Text(), and SVG_PLOTTER::Text().

◆ userToDeviceSize() [1/2]

◆ userToDeviceSize() [2/2]

double PLOTTER::userToDeviceSize ( double  size) const
protectedvirtualinherited

Modify size according to the plotter scale factors (simple double version).

Definition at line 122 of file plotter.cpp.

123{
124 return size * m_plotScale * m_iuPerDeviceUnit;
125}

References PLOTTER::m_iuPerDeviceUnit, and PLOTTER::m_plotScale.

Member Data Documentation

◆ DO_NOT_SET_LINE_WIDTH

◆ m_bookmarksInPage

std::map<wxString, std::vector<std::pair<BOX2I, wxString> > > PDF_PLOTTER::m_bookmarksInPage
protected

Definition at line 515 of file plotters_pslike.h.

Referenced by Bookmark(), ClosePage(), and StartPlot().

◆ m_colorMode

◆ m_creator

wxString PLOTTER::m_creator
protectedinherited

◆ m_currentPenWidth

◆ m_filename

wxString PLOTTER::m_filename
protectedinherited

Definition at line 663 of file plotter.h.

Referenced by EndPlot(), PLOTTER::OpenFile(), OpenFile(), and SVG_PLOTTER::StartPlot().

◆ m_fontResDictHandle

int PDF_PLOTTER::m_fontResDictHandle
protected

Font resource dictionary.

Definition at line 495 of file plotters_pslike.h.

Referenced by ClosePage(), EndPlot(), and StartPlot().

◆ m_headerExtraLines

wxArrayString PLOTTER::m_headerExtraLines
protectedinherited

◆ m_hyperlinkHandles

std::map<int, std::pair<BOX2D, wxString> > PDF_PLOTTER::m_hyperlinkHandles
protected

Definition at line 512 of file plotters_pslike.h.

Referenced by ClosePage(), EndPlot(), and StartPlot().

◆ m_hyperlinkMenuHandles

std::map<int, std::pair<BOX2D, std::vector<wxString> > > PDF_PLOTTER::m_hyperlinkMenuHandles
protected

Definition at line 513 of file plotters_pslike.h.

Referenced by ClosePage(), EndPlot(), and StartPlot().

◆ m_hyperlinkMenusInPage

std::vector<std::pair<BOX2I, std::vector<wxString> > > PDF_PLOTTER::m_hyperlinkMenusInPage
protected

Handles for all the hyperlink objects that will be deferred.

Definition at line 509 of file plotters_pslike.h.

Referenced by ClosePage(), HyperlinkMenu(), and StartPlot().

◆ m_hyperlinksInPage

std::vector<std::pair<BOX2I, wxString> > PDF_PLOTTER::m_hyperlinksInPage
protected

Definition at line 508 of file plotters_pslike.h.

Referenced by ClosePage(), HyperlinkBox(), and StartPlot().

◆ m_iuPerDeviceUnit

◆ m_IUsPerDecimil

◆ m_mirrorIsHorizontal

bool PLOTTER::m_mirrorIsHorizontal
protectedinherited

Definition at line 649 of file plotter.h.

Referenced by SVG_PLOTTER::Arc(), PLOTTER::PLOTTER(), and PLOTTER::userToDeviceCoordinates().

◆ m_negativeMode

bool PLOTTER::m_negativeMode
protectedinherited

Definition at line 657 of file plotter.h.

Referenced by PLOTTER::PLOTTER(), PSLIKE_PLOTTER::SetColor(), and PLOTTER::SetNegative().

◆ m_outlineRoot

std::unique_ptr<OUTLINE_NODE> PDF_PLOTTER::m_outlineRoot
protected

Root outline node.

Definition at line 517 of file plotters_pslike.h.

Referenced by ClosePage(), emitOutline(), and StartPlot().

◆ m_outputFile

FILE* PLOTTER::m_outputFile
protectedinherited

Output file.

Definition at line 653 of file plotter.h.

Referenced by DXF_PLOTTER::Arc(), SVG_PLOTTER::Arc(), PS_PLOTTER::Arc(), SVG_PLOTTER::BezierCurve(), HPGL_PLOTTER::Circle(), DXF_PLOTTER::Circle(), PS_PLOTTER::Circle(), SVG_PLOTTER::Circle(), GERBER_PLOTTER::ClearAllAttributes(), GERBER_PLOTTER::clearNetAttribute(), ClosePage(), closePdfObject(), closePdfStream(), GERBER_PLOTTER::emitDcode(), emitGoToAction(), emitOutline(), emitOutlineNode(), PS_PLOTTER::emitSetRGBColor(), SVG_PLOTTER::EndBlock(), DXF_PLOTTER::EndPlot(), GERBER_PLOTTER::EndPlot(), HPGL_PLOTTER::EndPlot(), PS_PLOTTER::EndPlot(), EndPlot(), SVG_PLOTTER::EndPlot(), HPGL_PLOTTER::FlashPadCircle(), DXF_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), DXF_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadRect(), DXF_PLOTTER::FlashPadRect(), GERBER_PLOTTER::FlashPadRoundRect(), DXF_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::formatNetAttribute(), PLOTTER::OpenFile(), OpenFile(), DXF_PLOTTER::PenTo(), GERBER_PLOTTER::PenTo(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::plotArc(), GERBER_PLOTTER::PlotGerberRegion(), PS_PLOTTER::PlotImage(), SVG_PLOTTER::PlotImage(), DXF_PLOTTER::plotOneLineOfText(), GERBER_PLOTTER::PlotPoly(), PS_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), GERBER_PLOTTER::plotRoundRectAsRegion(), PLOTTER::PLOTTER(), PS_PLOTTER::PlotText(), HPGL_PLOTTER::Rect(), DXF_PLOTTER::Rect(), PS_PLOTTER::Rect(), SVG_PLOTTER::Rect(), GERBER_PLOTTER::selectAperture(), PS_PLOTTER::SetCurrentLineWidth(), PS_PLOTTER::SetDash(), GERBER_PLOTTER::SetLayerPolarity(), SVG_PLOTTER::setSVGPlotStyle(), PS_PLOTTER::SetViewport(), SVG_PLOTTER::StartBlock(), StartPage(), startPdfObject(), startPdfStream(), DXF_PLOTTER::StartPlot(), HPGL_PLOTTER::StartPlot(), PS_PLOTTER::StartPlot(), SVG_PLOTTER::StartPlot(), StartPlot(), GERBER_PLOTTER::StartPlot(), PS_PLOTTER::Text(), SVG_PLOTTER::Text(), HPGL_PLOTTER::ThickSegment(), GERBER_PLOTTER::writeApertureList(), and PLOTTER::~PLOTTER().

◆ m_pageHandles

std::vector<int> PDF_PLOTTER::m_pageHandles
protected

Handles to the page objects.

Definition at line 496 of file plotters_pslike.h.

Referenced by ClosePage(), and EndPlot().

◆ m_pageInfo

◆ m_pageName

wxString PDF_PLOTTER::m_pageName
protected

Definition at line 500 of file plotters_pslike.h.

Referenced by ClosePage(), and StartPage().

◆ m_pageNumbers

std::vector<wxString> PDF_PLOTTER::m_pageNumbers
protected

List of loaded hyperlinks in current page.

Definition at line 505 of file plotters_pslike.h.

Referenced by ClosePage(), EndPlot(), and StartPage().

◆ m_pageStreamHandle

int PDF_PLOTTER::m_pageStreamHandle
protected

Handle of the page content object.

Definition at line 497 of file plotters_pslike.h.

Referenced by ClosePage(), and StartPage().

◆ m_pageTreeHandle

int PDF_PLOTTER::m_pageTreeHandle
protected

Handle to the root of the page tree object.

Definition at line 494 of file plotters_pslike.h.

Referenced by ClosePage(), EndPlot(), and StartPlot().

◆ m_paperSize

◆ m_penLastpos

VECTOR2I PLOTTER::m_penLastpos
protectedinherited

◆ m_penState

char PLOTTER::m_penState
protectedinherited

◆ m_plotMirror

◆ m_plotOffset

◆ m_plotScale

◆ m_renderSettings

◆ m_streamLengthHandle

int PDF_PLOTTER::m_streamLengthHandle
protected

Handle to the deferred stream length.

Definition at line 498 of file plotters_pslike.h.

Referenced by closePdfStream(), and startPdfStream().

◆ m_textMode

PLOT_TEXT_MODE PSLIKE_PLOTTER::m_textMode
protectedinherited

◆ m_title

wxString PLOTTER::m_title
protectedinherited

Definition at line 664 of file plotter.h.

Referenced by EndPlot(), PLOTTER::SetTitle(), and PS_PLOTTER::StartPlot().

◆ m_totalOutlineNodes

int PDF_PLOTTER::m_totalOutlineNodes
protected

Total number of outline nodes.

Definition at line 518 of file plotters_pslike.h.

Referenced by addOutlineNode(), emitOutline(), and StartPlot().

◆ m_workFile

FILE* PDF_PLOTTER::m_workFile
protected

◆ m_workFilename

wxString PDF_PLOTTER::m_workFilename
protected

Definition at line 499 of file plotters_pslike.h.

Referenced by closePdfStream(), and startPdfStream().

◆ m_xrefTable

std::vector<long> PDF_PLOTTER::m_xrefTable
protected

The PDF xref offset table.

List of user-space page numbers for resolving internal hyperlinks

Definition at line 502 of file plotters_pslike.h.

Referenced by allocPdfObject(), EndPlot(), startPdfObject(), and StartPlot().

◆ m_yaxisReversed

bool PLOTTER::m_yaxisReversed
protectedinherited

◆ MARKER_COUNT

const unsigned PLOTTER::MARKER_COUNT = 58
staticinherited

Draw a marker (used for the drill map).

Definition at line 486 of file plotter.h.

Referenced by PLOTTER::Marker().

◆ plotScaleAdjX

double PSLIKE_PLOTTER::plotScaleAdjX
protectedinherited

Fine user scale adjust ( = 1.0 if no correction)

Definition at line 148 of file plotters_pslike.h.

Referenced by PSLIKE_PLOTTER::SetScaleAdjust(), StartPage(), and PS_PLOTTER::StartPlot().

◆ plotScaleAdjY

double PSLIKE_PLOTTER::plotScaleAdjY
protectedinherited

◆ postscriptTextAscent

const double PSLIKE_PLOTTER::postscriptTextAscent = 0.718
staticprotectedinherited

Height of the postscript font (from the AFM)

Definition at line 137 of file plotters_pslike.h.

Referenced by PSLIKE_PLOTTER::computeTextParameters(), PSLIKE_PLOTTER::postscriptOverlinePositions(), and PSLIKE_PLOTTER::returnPostscriptTextWidth().

◆ USE_DEFAULT_LINE_WIDTH


The documentation for this class was generated from the following files: