KiCad PCB EDA Suite
HPGL_PLOTTER Class Reference

#include <plotter_hpgl.h>

Inheritance diagram for HPGL_PLOTTER:
PLOTTER

Classes

struct  HPGL_ITEM
 

Public Member Functions

 HPGL_PLOTTER ()
 
virtual PLOT_FORMAT GetPlotterType () const override
 Returns the effective plot engine in use. More...
 
void SetTargetChordLength (double chord_len)
 Set the target length of chords used to draw approximated circles and arcs. More...
 
void SetUserCoords (bool user_coords)
 Switch to the user coordinate system. More...
 
void SetUserCoordsFit (bool user_coords_fit)
 Set whether the user coordinate system is fit to content. More...
 
virtual bool StartPlot (const wxString &aPageNumber) override
 At the start of the HPGL plot pen speed and number are requested. More...
 
virtual bool EndPlot () override
 HPGL end of plot: sort and emit graphics, pen return and release. More...
 
virtual void SetCurrentLineWidth (int width, void *aData=nullptr) override
 HPGL doesn't handle line thickness or color. More...
 
virtual void SetDash (int aLineWidth, PLOT_DASH_TYPE aLineStyle) override
 HPGL supports dashed lines. More...
 
virtual void SetColor (const COLOR4D &color) override
 
virtual void SetPenSpeed (int speed)
 
virtual void SetPenNumber (int number)
 
virtual void SetPenDiameter (double diameter)
 
virtual void SetViewport (const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
 Set the plot offset and scaling for the current plot. More...
 
virtual void Rect (const VECTOR2I &p1, const VECTOR2I &p2, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
 
virtual void Circle (const VECTOR2I &aCenter, int aDiameter, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
 
virtual void PlotPoly (const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
 Draw a polygon ( filled or not ). More...
 
virtual void ThickSegment (const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
 
virtual void Arc (const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aEnd, FILL_T aFill, int aWidth, int aMaxError) override
 Generic fallback: arc rendered as a polyline. More...
 
virtual void PenTo (const VECTOR2I &pos, char plume) override
 Moveto/lineto primitive, moves the 'pen' to the specified direction. 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 &aOrient, 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 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...
 
virtual bool OpenFile (const wxString &aFullFilename)
 Open or create the plot file aFullFilename. 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 PlotImage (const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor)
 Only PostScript plotters can plot bitmaps. More...
 
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)
 
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. More...
 
virtual void HyperlinkBox (const BOX2I &aBox, const wxString &aDestinationURL)
 Create a clickable hyperlink with a rectangular click area. More...
 
virtual void HyperlinkMenu (const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
 Create a clickable hyperlink menu with a rectangular click area. More...
 
virtual void Bookmark (const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
 Create a bookmark to a symbol. More...
 
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 SetTextMode (PLOT_TEXT_MODE mode)
 Change the current text mode. 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

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
 Plot an arc. More...
 
bool startItem (const VECTOR2D &location)
 Start a new HPGL_ITEM if necessary, keeping the current one if it exists. More...
 
void flushItem ()
 Flush the current HPGL_ITEM and clear out the current item pointer. More...
 
bool startOrAppendItem (const VECTOR2D &location, const wxString &content)
 Start a new HPGL_ITEM with the given string if necessary, or append the string to the current item. 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
 

Static Protected Member Functions

static void sortItems (std::list< HPGL_ITEM > &items)
 Sort a list of HPGL items to improve plotting speed on mechanical plotters. More...
 
static const char * lineStyleCommand (PLOT_DASH_TYPE aLineStyle)
 Return the plot command corresponding to a line type. More...
 

Protected Attributes

int m_penSpeed
 
int m_penNumber
 
double m_penDiameter
 
double m_arcTargetChordLength
 
EDA_ANGLE m_arcMinChordDegrees
 
PLOT_DASH_TYPE m_lineStyle
 
bool m_useUserCoords
 
bool m_fitUserCoords
 
std::list< HPGL_ITEMm_items
 
HPGL_ITEMm_current_item
 
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
 

Detailed Description

Definition at line 33 of file plotter_hpgl.h.

Constructor & Destructor Documentation

◆ HPGL_PLOTTER()

HPGL_PLOTTER::HPGL_PLOTTER ( )

Definition at line 222 of file HPGL_plotter.cpp.

222 :
226 m_useUserCoords( false ),
227 m_fitUserCoords( false ),
228 m_current_item( nullptr )
229{
230 SetPenSpeed( 40 ); // Default pen speed = 40 cm/s; Pen speed is *always* in cm
231 SetPenNumber( 1 ); // Default pen num = 1
232 SetPenDiameter( 0.0 );
233}
HPGL_ITEM * m_current_item
Definition: plotter_hpgl.h:228
virtual void SetPenSpeed(int speed)
Definition: plotter_hpgl.h:85
double m_arcTargetChordLength
Definition: plotter_hpgl.h:221
virtual void SetPenNumber(int number)
Definition: plotter_hpgl.h:90
EDA_ANGLE m_arcMinChordDegrees
Definition: plotter_hpgl.h:222
bool m_useUserCoords
Definition: plotter_hpgl.h:224
virtual void SetPenDiameter(double diameter)
bool m_fitUserCoords
Definition: plotter_hpgl.h:225
PLOT_DASH_TYPE m_lineStyle
Definition: plotter_hpgl.h:223
@ DEGREES_T
Definition: eda_angle.h:31

References SetPenDiameter(), SetPenNumber(), SetPenSpeed(), and SOLID.

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:648

References PLOTTER::m_headerExtraLines.

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

◆ Arc() [1/2]

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

Plot an arc.

Command PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, NbSegm; PU; Or PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, PU;

center is the center of the arc. StAngled is the start angle of the arc. aEndAngle is end angle the arc. Radius is the radius of the arc.

Reimplemented from PLOTTER.

Definition at line 570 of file HPGL_plotter.cpp.

572{
573 if( aRadius <= 0 )
574 return;
575
576 double const radius_device = userToDeviceSize( aRadius );
577 double const circumf_device = 2.0 * M_PI * radius_device;
578 double const target_chord_length = m_arcTargetChordLength;
579 EDA_ANGLE chord_angle = ANGLE_360 * target_chord_length / circumf_device;
580
581 chord_angle = std::max( m_arcMinChordDegrees, std::min( chord_angle, ANGLE_45 ) );
582
583 VECTOR2D centre_device = userToDeviceCoordinates( aCenter );
585
586 if( m_plotMirror )
587 angle = aStartAngle - aEndAngle;
588 else
589 angle = aEndAngle - aStartAngle;
590
591 angle.Normalize180();
592
593 // Calculate arc start point:
594 VECTOR2I cmap( aCenter.x + KiROUND( aRadius * aStartAngle.Cos() ),
595 aCenter.y - KiROUND( aRadius * aStartAngle.Sin() ) );
596 VECTOR2D cmap_dev = userToDeviceCoordinates( cmap );
597
598 startOrAppendItem( cmap_dev, wxString::Format( "AA %.0f,%.0f,%.0f,%g",
599 centre_device.x,
600 centre_device.y,
601 angle.AsDegrees(),
602 chord_angle.AsDegrees() ) );
603
604 // TODO We could compute the final position and full bounding box instead...
605 m_current_item->bbox.Merge( BOX2D( centre_device - radius_device,
606 VECTOR2D( radius_device * 2, radius_device * 2 ) ) );
608 flushItem();
609}
BOX2< VECTOR2D > BOX2D
Definition: box2.h:848
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
double AsDegrees() const
Definition: eda_angle.h:149
void flushItem()
Flush the current HPGL_ITEM and clear out the current item pointer.
bool startOrAppendItem(const VECTOR2D &location, const wxString &content)
Start a new HPGL_ITEM with the given string if necessary, or append the string to the current item.
bool m_plotMirror
Definition: plotter.h:627
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:90
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
Definition: plotter.cpp:115
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:429
static constexpr EDA_ANGLE & ANGLE_45
Definition: eda_angle.h:424
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
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
BOX2D bbox
Bounding box of this item.
Definition: plotter_hpgl.h:190
bool lift_after
Whether the pen must be lifted after the command.
Definition: plotter_hpgl.h:198
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
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617

References PNS::angle(), ANGLE_360, ANGLE_45, EDA_ANGLE::AsDegrees(), HPGL_PLOTTER::HPGL_ITEM::bbox, EDA_ANGLE::Cos(), flushItem(), Format(), KiROUND(), HPGL_PLOTTER::HPGL_ITEM::lift_after, m_arcMinChordDegrees, m_arcTargetChordLength, m_current_item, PLOTTER::m_plotMirror, BOX2< Vec >::Merge(), EDA_ANGLE::Sin(), startOrAppendItem(), PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Arc() [2/2]

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

Generic fallback: arc rendered as a polyline.

Reimplemented from PLOTTER.

Definition at line 612 of file HPGL_plotter.cpp.

615{
616 EDA_ANGLE startAngle( aStart - aCenter );
617 EDA_ANGLE endAngle( aEnd - aCenter );
618 int radius = ( aStart - aCenter ).EuclideanNorm();
619
620 Arc( aCenter, -endAngle, -startAngle, radius, aFill, aWidth );
621}
virtual void Arc(const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aEnd, FILL_T aFill, int aWidth, int aMaxError) override
Generic fallback: arc rendered as a polyline.
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129

References Arc(), and EuclideanNorm().

Referenced by Arc().

◆ 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()

virtual void PLOTTER::Bookmark ( const BOX2I aBox,
const wxString &  aName,
const wxString &  aGroupName = wxEmptyString 
)
inlinevirtualinherited

Create a bookmark to a symbol.

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

Reimplemented in PDF_PLOTTER.

Definition at line 457 of file plotter.h.

459 {
460 // NOP for most plotters.
461 }

Referenced by SCH_LABEL_BASE::Plot(), SCH_SYMBOL::Plot(), and PlotStandardLayer().

◆ Circle()

void HPGL_PLOTTER::Circle ( const VECTOR2I aCenter,
int  aDiameter,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Implements PLOTTER.

Definition at line 416 of file HPGL_plotter.cpp.

417{
418 wxASSERT( m_outputFile );
419 double radius = userToDeviceSize( aDiameter / 2 );
420 VECTOR2D center_dev = userToDeviceCoordinates( aCenter );
421 SetCurrentLineWidth( aWidth );
422
423 double const circumf = 2.0 * M_PI * radius;
424 double const target_chord_length = m_arcTargetChordLength;
425 EDA_ANGLE chord_angle = ANGLE_360 * target_chord_length / circumf;
426
427 chord_angle = std::max( m_arcMinChordDegrees, std::min( chord_angle, ANGLE_45 ) );
428
429 if( aFill == FILL_T::FILLED_SHAPE )
430 {
431 // Draw the filled area
432 MoveTo( aCenter );
433 startOrAppendItem( center_dev, wxString::Format( "PM 0;CI %g,%g;%s",
434 radius,
435 chord_angle.AsDegrees(),
439 m_current_item->bbox.Merge( BOX2D( center_dev - radius,
440 VECTOR2D( 2 * radius, 2 * radius ) ) );
441 PenFinish();
442 }
443
444 if( radius > 0 )
445 {
446 MoveTo( aCenter );
447 startOrAppendItem( center_dev, wxString::Format( "CI %g,%g;",
448 radius,
449 chord_angle.AsDegrees() ) );
452 m_current_item->bbox.Merge( BOX2D( center_dev - radius,
453 VECTOR2D( 2 * radius, 2 * radius ) ) );
454 PenFinish();
455 }
456}
static const char hpgl_end_polygon_cmd[]
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
HPGL doesn't handle line thickness or color.
Definition: plotter_hpgl.h:72
FILE * m_outputFile
Output file.
Definition: plotter.h:633
void PenFinish()
Definition: plotter.h:263
@ FILLED_SHAPE
bool pen_returns
Whether the pen returns to its original state after the command.
Definition: plotter_hpgl.h:202
bool lift_before
Whether the command should be executed with the pen lifted.
Definition: plotter_hpgl.h:193

References ANGLE_360, ANGLE_45, EDA_ANGLE::AsDegrees(), HPGL_PLOTTER::HPGL_ITEM::bbox, FILLED_SHAPE, Format(), hpgl_end_polygon_cmd, HPGL_PLOTTER::HPGL_ITEM::lift_before, m_arcMinChordDegrees, m_arcTargetChordLength, m_current_item, PLOTTER::m_outputFile, BOX2< Vec >::Merge(), PLOTTER::MoveTo(), HPGL_PLOTTER::HPGL_ITEM::pen_returns, PLOTTER::PenFinish(), SetCurrentLineWidth(), startOrAppendItem(), PLOTTER::userToDeviceCoordinates(), and PLOTTER::userToDeviceSize().

◆ 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().

◆ 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 527 of file plotter.h.

527{}

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

◆ EndPlot()

bool HPGL_PLOTTER::EndPlot ( )
overridevirtual

HPGL end of plot: sort and emit graphics, pen return and release.

Implements PLOTTER.

Definition at line 271 of file HPGL_plotter.cpp.

272{
273 wxASSERT( m_outputFile );
274
275 fputs( "PU;\n", m_outputFile );
276
277 flushItem();
279
280 if( m_items.size() > 0 )
281 {
282 if( m_useUserCoords )
283 {
284 if( m_fitUserCoords )
285 {
286 BOX2D bbox = m_items.front().bbox;
287
288 for( HPGL_ITEM const& item : m_items )
289 bbox.Merge( item.bbox );
290
291 fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n",
292 bbox.GetX(),
293 bbox.GetX() + bbox.GetWidth(),
294 bbox.GetY(),
295 bbox.GetY() + bbox.GetHeight() );
296 }
297 else
298 {
299 VECTOR2D pagesize_device( m_paperSize * m_iuPerDeviceUnit );
300 fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n",
301 0.0,
302 pagesize_device.x,
303 0.0,
304 pagesize_device.y );
305 }
306 }
307
308 VECTOR2I loc = m_items.begin()->loc_start;
309 bool pen_up = true;
311 int current_pen = m_penNumber;
312
313 for( HPGL_ITEM const& item : m_items )
314 {
315 if( item.loc_start != loc || pen_up )
316 {
317 if( !pen_up )
318 {
319 fputs( "PU;", m_outputFile );
320 pen_up = true;
321 }
322
323 fprintf( m_outputFile, "PA %.0f,%.0f;", item.loc_start.x, item.loc_start.y );
324 }
325
326 if( item.dashType != current_dash )
327 {
328 current_dash = item.dashType;
329 fputs( lineStyleCommand( item.dashType ), m_outputFile );
330 }
331
332 if( item.pen != current_pen )
333 {
334 if( !pen_up )
335 {
336 fputs( "PU;", m_outputFile );
337 pen_up = true;
338 }
339
340 fprintf( m_outputFile, "SP%d;", item.pen );
341 current_pen = item.pen;
342 }
343
344 if( pen_up && !item.lift_before )
345 {
346 fputs( "PD;", m_outputFile );
347 pen_up = false;
348 }
349 else if( !pen_up && item.lift_before )
350 {
351 fputs( "PU;", m_outputFile );
352 pen_up = true;
353 }
354
355 fputs( static_cast<const char*>( item.content.utf8_str() ), m_outputFile );
356
357 if( !item.pen_returns )
358 {
359 // Assume commands drop the pen
360 pen_up = false;
361 }
362
363 if( item.lift_after )
364 {
365 fputs( "PU;", m_outputFile );
366 pen_up = true;
367 }
368 else
369 {
370 loc = item.loc_end;
371 }
372
373 fputs( "\n", m_outputFile );
374 }
375 }
376
377 fputs( "PU;PA;SP0;\n", m_outputFile );
378 fclose( m_outputFile );
379 m_outputFile = nullptr;
380 return true;
381}
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetY() const
Definition: box2.h:181
coord_type GetWidth() const
Definition: box2.h:187
coord_type GetX() const
Definition: box2.h:180
static const char * lineStyleCommand(PLOT_DASH_TYPE aLineStyle)
Return the plot command corresponding to a line type.
static void sortItems(std::list< HPGL_ITEM > &items)
Sort a list of HPGL items to improve plotting speed on mechanical plotters.
std::list< HPGL_ITEM > m_items
Definition: plotter_hpgl.h:227
double m_iuPerDeviceUnit
Definition: plotter.h:624
VECTOR2I m_paperSize
Definition: plotter.h:646
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48

References flushItem(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), lineStyleCommand(), m_fitUserCoords, m_items, PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_outputFile, PLOTTER::m_paperSize, m_penNumber, m_useUserCoords, BOX2< Vec >::Merge(), SOLID, sortItems(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_PLOTTER::plotOneSheetHpgl().

◆ 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 HPGL_PLOTTER::FlashPadCircle ( const VECTOR2I aPadPos,
int  aDiameter,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
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 661 of file HPGL_plotter.cpp.

663{
664 wxASSERT( m_outputFile );
665 VECTOR2D pos_dev = userToDeviceCoordinates( pos );
666 int radius = diametre / 2;
667
668 if( trace_mode == FILLED )
669 {
670 // if filled mode, the pen diameter is removed from diameter
671 // to keep the pad size
672 radius -= KiROUND( m_penDiameter ) / 2;
673
674 if( radius < 0 )
675 radius = 0;
676 }
677
678 double rsize = userToDeviceSize( radius );
679
680 if( trace_mode == FILLED ) // Plot in filled mode.
681 {
682 // A filled polygon uses always the current point to start the polygon.
683 // Gives a correct current starting point for the circle
684 MoveTo( VECTOR2I( pos.x + radius, pos.y ) );
685
686 // Plot filled area and its outline
687 startOrAppendItem( userToDeviceCoordinates( VECTOR2I( pos.x + radius, pos.y ) ),
688 wxString::Format( "PM 0; PA %.0f,%.0f;CI %.0f;%s",
689 pos_dev.x, pos_dev.y, rsize, hpgl_end_polygon_cmd ) );
692 }
693 else
694 {
695 // Draw outline only:
696 startOrAppendItem( pos_dev, wxString::Format( "CI %.0f;", rsize ) );
699 }
700
701 PenFinish();
702}
double m_penDiameter
Definition: plotter_hpgl.h:220
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References FILLED, Format(), hpgl_end_polygon_cmd, KiROUND(), HPGL_PLOTTER::HPGL_ITEM::lift_before, m_current_item, PLOTTER::m_outputFile, m_penDiameter, PLOTTER::MoveTo(), HPGL_PLOTTER::HPGL_ITEM::pen_returns, PLOTTER::PenFinish(), startOrAppendItem(), PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by FlashPadOval().

◆ FlashPadCustom()

void HPGL_PLOTTER::FlashPadCustom ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
const EDA_ANGLE aPadOrient,
SHAPE_POLY_SET aPolygons,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
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 781 of file HPGL_plotter.cpp.

784{
785 std::vector<VECTOR2I> cornerList;
786
787 for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
788 {
789 SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
790
791 cornerList.clear();
792 cornerList.reserve( poly.PointCount() );
793
794 for( int ii = 0; ii < poly.PointCount(); ++ii )
795 cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
796
797 if( cornerList.back() != cornerList.front() )
798 cornerList.push_back( cornerList.front() );
799
800 PlotPoly( cornerList, aTraceMode == FILLED ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL );
801 }
802}
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
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, NO_FILL, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadOval()

void HPGL_PLOTTER::FlashPadOval ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
const EDA_ANGLE aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
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 624 of file HPGL_plotter.cpp.

626{
627 wxASSERT( m_outputFile );
628
629 VECTOR2I size( aSize );
630 EDA_ANGLE orient( aOrient );
631
632 // The pad will be drawn as an oblong shape with size.y > size.x (Oval vertical orientation 0).
633 if( size.x > size.y )
634 {
635 std::swap( size.x, size.y );
636 orient += ANGLE_90;
637 }
638
639 if( aTraceMode == FILLED )
640 {
641 int deltaxy = size.y - size.x; // distance between centers of the oval
642
643 FlashPadRect( aPos, VECTOR2I( size.x, deltaxy + KiROUND( m_penDiameter ) ), orient,
644 aTraceMode, aData );
645
646 VECTOR2I pt( 0, deltaxy / 2 );
647 RotatePoint( pt, orient );
648 FlashPadCircle( pt + aPos, size.x, aTraceMode, aData );
649
650 pt = VECTOR2I( 0, -deltaxy / 2 );
651 RotatePoint( pt, orient );
652 FlashPadCircle( pt + aPos, size.x, aTraceMode, aData );
653 }
654 else // Plot in outline mode.
655 {
656 sketchOval( aPos, size, orient, KiROUND( m_penDiameter ) );
657 }
658}
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData) override
virtual void FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
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:425
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References ANGLE_90, FILLED, FlashPadCircle(), FlashPadRect(), KiROUND(), PLOTTER::m_outputFile, m_penDiameter, RotatePoint(), PLOTTER::sketchOval(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadRect()

void HPGL_PLOTTER::FlashPadRect ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
const EDA_ANGLE aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
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 705 of file HPGL_plotter.cpp.

707{
708 // Build rect polygon:
709 std::vector<VECTOR2I> corners;
710
711 int dx = aPadSize.x / 2;
712 int dy = aPadSize.y / 2;
713
714 if( aTraceMode == FILLED )
715 {
716 // in filled mode, the pen diameter is removed from size
717 // to compensate the extra size due to this pen size
718 dx -= KiROUND( m_penDiameter ) / 2;
719 dx = std::max( dx, 0);
720 dy -= KiROUND( m_penDiameter ) / 2;
721 dy = std::max( dy, 0);
722 }
723
724
725 corners.emplace_back( - dx, - dy );
726 corners.emplace_back( - dx, + dy );
727 corners.emplace_back( + dx, + dy );
728 corners.emplace_back( + dx, - dy );
729
730 // Close polygon
731 corners.emplace_back( - dx, - dy );
732
733 for( unsigned ii = 0; ii < corners.size(); ii++ )
734 {
735 RotatePoint( corners[ii], aOrient );
736 corners[ii] += aPos;
737 }
738
739 PlotPoly( corners, aTraceMode == FILLED ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL );
740}

References FILLED, FILLED_SHAPE, KiROUND(), m_penDiameter, NO_FILL, PlotPoly(), RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by FlashPadOval().

◆ FlashPadRoundRect()

void HPGL_PLOTTER::FlashPadRoundRect ( const VECTOR2I aPadPos,
const VECTOR2I aSize,
int  aCornerRadius,
const EDA_ANGLE aOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
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 743 of file HPGL_plotter.cpp.

746{
747 SHAPE_POLY_SET outline;
748
749 VECTOR2I size = aSize;
750
751 if( aTraceMode == FILLED )
752 {
753 // In filled mode, the pen diameter is removed from size to keep the pad size.
754 size.x -= KiROUND( m_penDiameter ) / 2;
755 size.x = std::max( size.x, 0);
756 size.y -= KiROUND( m_penDiameter ) / 2;
757 size.y = std::max( size.y, 0);
758
759 // keep aCornerRadius to a value < min size x,y < 2:
760 aCornerRadius = std::min( aCornerRadius, std::min( size.x, size.y ) /2 );
761 }
762
763 TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient, aCornerRadius, 0.0, 0,
765
766 // TransformRoundRectToPolygon creates only one convex polygon
767 std::vector<VECTOR2I> cornerList;
768 SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
769 cornerList.reserve( poly.PointCount() );
770
771 for( int ii = 0; ii < poly.PointCount(); ++ii )
772 cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
773
774 if( cornerList.back() != cornerList.front() )
775 cornerList.push_back( cornerList.front() );
776
777 PlotPoly( cornerList, aTraceMode == FILLED ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL );
778}
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::GetPlotterArcHighDef(), KiROUND(), m_penDiameter, NO_FILL, SHAPE_POLY_SET::Outline(), PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), TransformRoundChamferedRectToPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadTrapez()

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

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 805 of file HPGL_plotter.cpp.

808{
809 std::vector<VECTOR2I> cornerList;
810 cornerList.reserve( 5 );
811
812 for( int ii = 0; ii < 4; ii++ )
813 {
814 VECTOR2I coord( aCorners[ii] );
815 RotatePoint( coord, aPadOrient );
816 coord += aPadPos;
817 cornerList.push_back( coord );
818 }
819
820 // Close polygon
821 cornerList.push_back( cornerList.front() );
822
823 PlotPoly( cornerList, aTraceMode == FILLED ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL );
824}

References FILLED, FILLED_SHAPE, NO_FILL, PlotPoly(), and RotatePoint().

◆ FlashRegularPolygon()

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

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 827 of file HPGL_plotter.cpp.

830{
831 // Do nothing
832 wxASSERT( 0 );
833}

◆ flushItem()

void HPGL_PLOTTER::flushItem ( )
protected

Flush the current HPGL_ITEM and clear out the current item pointer.

Definition at line 842 of file HPGL_plotter.cpp.

843{
844 m_current_item = nullptr;
845}

References m_current_item.

Referenced by Arc(), EndPlot(), PenTo(), and SetDash().

◆ 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:650

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

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

◆ GetDashMarkLenIU()

double PLOTTER::GetDashMarkLenIU ( int  aLineWidth) const
protectedinherited

◆ GetDefaultFileExtension()

static wxString HPGL_PLOTTER::GetDefaultFileExtension ( )
inlinestatic

Definition at line 43 of file plotter_hpgl.h.

44 {
45 return wxString( wxT( "plt" ) );
46 }

Referenced by SCH_PLOTTER::createHPGLFiles(), 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; }
double m_IUsPerDecimil
Definition: plotter.h:622

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 HPGL_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 38 of file plotter_hpgl.h.

39 {
40 return PLOT_FORMAT::HPGL;
41 }

References HPGL.

◆ HyperlinkBox()

virtual void PLOTTER::HyperlinkBox ( const BOX2I aBox,
const wxString &  aDestinationURL 
)
inlinevirtualinherited

Create a clickable hyperlink with a rectangular click area.

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

Reimplemented in PDF_PLOTTER.

Definition at line 435 of file plotter.h.

436 {
437 // NOP for most plotters.
438 }

Referenced by SCH_TEXT::Plot(), and SCH_TEXTBOX::Plot().

◆ HyperlinkMenu()

virtual void PLOTTER::HyperlinkMenu ( const BOX2I aBox,
const std::vector< wxString > &  aDestURLs 
)
inlinevirtualinherited

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 in PDF_PLOTTER.

Definition at line 446 of file plotter.h.

447 {
448 // NOP for most plotters.
449 }

Referenced by SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_LINE::Plot(), SCH_SHEET::Plot(), SCH_SYMBOL::Plot(), and PlotInteractiveLayer().

◆ lineStyleCommand()

const char * HPGL_PLOTTER::lineStyleCommand ( PLOT_DASH_TYPE  aLineStyle)
staticprotected

Return the plot command corresponding to a line type.

Definition at line 934 of file HPGL_plotter.cpp.

935{
936 switch( aLineStyle )
937 {
938 case PLOT_DASH_TYPE::DASH: return "LT 2 4 1;";
939 case PLOT_DASH_TYPE::DOT: return "LT 1 1 1;";
940 case PLOT_DASH_TYPE::DASHDOT: return "LT 4 6 1;";
941 case PLOT_DASH_TYPE::DASHDOTDOT: return "LT 7 8 1;";
942 default: return "LT;";
943 }
944}

References DASH, DASHDOT, DASHDOTDOT, and DOT.

Referenced by EndPlot().

◆ 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:466
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}

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}
virtual int GetCurrentLineWidth() const
Definition: plotter.h:153

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}
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 ).

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 PLOTTER::OpenFile ( const wxString &  aFullFilename)
virtualinherited

Open or create the plot file aFullFilename.

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

Virtual because some plotters use ascii files, some others binary files (PDF) The base class open the file in text mode

Reimplemented in PDF_PLOTTER.

Definition at line 74 of file plotter.cpp.

75{
76 m_filename = aFullFilename;
77
78 wxASSERT( !m_outputFile );
79
80 // Open the file in text mode (not suitable for all plotters but only for most of them.
81 m_outputFile = wxFopen( m_filename, wxT( "wt" ) );
82
83 if( m_outputFile == nullptr )
84 return false ;
85
86 return true;
87}
wxString m_filename
Definition: plotter.h:643

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

Referenced by GERBER_WRITER::createDrillFile(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), EESCHEMA_JOBS_HANDLER::doSymExportSvg(), GENDRILL_WRITER_BASE::genDrillMapFile(), SCH_PLOTTER::plotOneSheetDXF(), SCH_PLOTTER::plotOneSheetHpgl(), SCH_PLOTTER::plotOneSheetPS(), SCH_PLOTTER::plotOneSheetSVG(), StartPlotBoard(), and SYMBOL_EDIT_FRAME::SVGPlotSymbol().

◆ PageSettings()

PAGE_INFO & PLOTTER::PageSettings ( )
inlineinherited

Definition at line 144 of file plotter.h.

144{ return m_pageInfo; }
PAGE_INFO m_pageInfo
Definition: plotter.h:645

References PLOTTER::m_pageInfo.

Referenced by SCH_PLOTTER::plotOneSheetPDF(), SCH_PLOTTER::plotOneSheetPS(), and SCH_PLOTTER::plotOneSheetSVG().

◆ 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 Circle(), FlashPadCircle(), GERBER_PLOTTER::PlotPoly(), DXF_PLOTTER::PlotPoly(), PlotPoly(), Rect(), and PLOTTER::Text().

◆ PenTo()

void HPGL_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 514 of file HPGL_plotter.cpp.

515{
516 wxASSERT( m_outputFile );
517
518 if( plume == 'Z' )
519 {
520 m_penState = 'Z';
521 flushItem();
522 return;
523 }
524
525 VECTOR2D pos_dev = userToDeviceCoordinates( pos );
527
528 if( plume == 'U' )
529 {
530 m_penState = 'U';
531 flushItem();
532 }
533 else if( plume == 'D' )
534 {
535 m_penState = 'D';
536 startOrAppendItem( lastpos_dev, wxString::Format( "PA %.0f,%.0f;", pos_dev.x, pos_dev.y ) );
537 m_current_item->loc_end = pos_dev;
538 m_current_item->bbox.Merge( pos_dev );
539 }
540
541 m_penLastpos = pos;
542}
VECTOR2I m_penLastpos
Definition: plotter.h:640
char m_penState
Definition: plotter.h:639
VECTOR2D loc_end
Location the pen will be at when it finishes.
Definition: plotter_hpgl.h:187

References HPGL_PLOTTER::HPGL_ITEM::bbox, flushItem(), Format(), HPGL_PLOTTER::HPGL_ITEM::loc_end, m_current_item, PLOTTER::m_outputFile, PLOTTER::m_penLastpos, PLOTTER::m_penState, BOX2< Vec >::Merge(), startOrAppendItem(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ PlotImage()

void PLOTTER::PlotImage ( const wxImage &  aImage,
const VECTOR2I aPos,
double  aScaleFactor 
)
virtualinherited

Only PostScript plotters can plot bitmaps.

A rectangle is plotted for plotters that cannot plot a bitmap.

Parameters
aImageis the bitmap.
aPosis position of the center of the bitmap.
aScaleFactoris the scale factor to apply to the bitmap size (this is not the plot scale factor).

Reimplemented in PS_PLOTTER, PDF_PLOTTER, and SVG_PLOTTER.

Definition at line 254 of file plotter.cpp.

255{
256 VECTOR2I size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
257
258 VECTOR2I start = aPos;
259 start.x -= size.x / 2;
260 start.y -= size.y / 2;
261
262 VECTOR2I end = start;
263 end.x += size.x;
264 end.y += size.y;
265
266 Rect( start, end, FILL_T::NO_FILL );
267}
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0

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

Referenced by SVG_PLOTTER::PlotImage(), and BITMAP_BASE::PlotImage().

◆ 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 HPGL_PLOTTER::PlotPoly ( const std::vector< VECTOR2I > &  aCornerList,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH,
void *  aData = nullptr 
)
overridevirtual

Draw a polygon ( filled or not ).

Parameters
aCornerListis the corners list (a std::vector< VECTOR2I >).
aFillis the type of fill.
aWidthis the line width.
aDatais an auxiliary info (mainly for gerber format).

Implements PLOTTER.

Definition at line 459 of file HPGL_plotter.cpp.

461{
462 if( aCornerList.size() <= 1 )
463 return;
464
465 // Width less than zero is occasionally used to create background-only
466 // polygons. Don't set that as the plotter line width, that'll cause
467 // trouble. Also, later, skip plotting the outline if this is the case.
468 if( aWidth > 0 )
469 {
470 SetCurrentLineWidth( aWidth );
471 }
472
473 MoveTo( aCornerList[0] );
474 startItem( userToDeviceCoordinates( aCornerList[0] ) );
475
476 if( aFill == FILL_T::FILLED_SHAPE )
477 {
478 // Draw the filled area
480
481 m_current_item->content << wxString( "PM 0;\n" ); // Start polygon
482
483 for( unsigned ii = 1; ii < aCornerList.size(); ++ii )
484 LineTo( aCornerList[ii] );
485
486 int ii = aCornerList.size() - 1;
487
488 if( aCornerList[ii] != aCornerList[0] )
489 LineTo( aCornerList[0] );
490
491 m_current_item->content << hpgl_end_polygon_cmd; // Close, fill polygon and draw outlines
493 }
494 else if( aWidth != 0 )
495 {
496 // Plot only the polygon outline.
497 for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
498 LineTo( aCornerList[ii] );
499
500 // Always close polygon if filled.
501 if( aFill != FILL_T::NO_FILL )
502 {
503 int ii = aCornerList.size() - 1;
504
505 if( aCornerList[ii] != aCornerList[0] )
506 LineTo( aCornerList[0] );
507 }
508 }
509
510 PenFinish();
511}
bool startItem(const VECTOR2D &location)
Start a new HPGL_ITEM if necessary, keeping the current one if it exists.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:114
wxString content
Line style for this command.
Definition: plotter_hpgl.h:206

References HPGL_PLOTTER::HPGL_ITEM::content, FILLED_SHAPE, hpgl_end_polygon_cmd, PLOTTER::LineTo(), m_current_item, PLOTTER::MoveTo(), NO_FILL, HPGL_PLOTTER::HPGL_ITEM::pen_returns, PLOTTER::PenFinish(), SetCurrentLineWidth(), startItem(), PLOTTER::USE_DEFAULT_LINE_WIDTH, and PLOTTER::userToDeviceCoordinates().

Referenced by FlashPadCustom(), FlashPadRect(), FlashPadRoundRect(), and FlashPadTrapez().

◆ Rect()

void HPGL_PLOTTER::Rect ( const VECTOR2I p1,
const VECTOR2I p2,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Implements PLOTTER.

Definition at line 390 of file HPGL_plotter.cpp.

391{
392 wxASSERT( m_outputFile );
393
394 VECTOR2D p1_device = userToDeviceCoordinates( p1 );
395 VECTOR2D p2_device = userToDeviceCoordinates( p2 );
396
397 MoveTo( p1 );
398
399 if( aFill == FILL_T::FILLED_SHAPE )
400 {
401 startOrAppendItem( p1_device, wxString::Format( "RA %.0f,%.0f;",
402 p2_device.x,
403 p2_device.y ) );
404 }
405
406 startOrAppendItem( p1_device, wxString::Format( "EA %.0f,%.0f;",
407 p2_device.x,
408 p2_device.y ) );
409
411 m_current_item->bbox.Merge( p2_device );
412 PenFinish();
413}
VECTOR2D loc_start
Location the pen should start at.
Definition: plotter_hpgl.h:183

References HPGL_PLOTTER::HPGL_ITEM::bbox, FILLED_SHAPE, Format(), HPGL_PLOTTER::HPGL_ITEM::loc_end, HPGL_PLOTTER::HPGL_ITEM::loc_start, m_current_item, PLOTTER::m_outputFile, BOX2< Vec >::Merge(), PLOTTER::MoveTo(), PLOTTER::PenFinish(), startOrAppendItem(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ RenderSettings()

◆ 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 ThickSegment().

◆ SetColor()

virtual void HPGL_PLOTTER::SetColor ( const COLOR4D color)
inlineoverridevirtual

Implements PLOTTER.

Definition at line 83 of file plotter_hpgl.h.

83{}

◆ SetColorMode()

virtual void PLOTTER::SetColorMode ( bool  aColorMode)
inlinevirtualinherited

◆ SetCreator()

◆ SetCurrentLineWidth()

virtual void HPGL_PLOTTER::SetCurrentLineWidth ( int  width,
void *  aData = nullptr 
)
inlineoverridevirtual

HPGL doesn't handle line thickness or color.

Implements PLOTTER.

Definition at line 72 of file plotter_hpgl.h.

73 {
74 // This is the truth
76 }

References PLOTTER::m_currentPenWidth, m_penDiameter, and PLOTTER::userToDeviceSize().

Referenced by Circle(), and PlotPoly().

◆ SetDash()

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

HPGL supports dashed lines.

Implements PLOTTER.

Definition at line 545 of file HPGL_plotter.cpp.

546{
547 m_lineStyle = aLineStyle;
548 flushItem();
549}

References flushItem(), and m_lineStyle.

◆ SetGerberCoordinatesFormat()

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

Reimplemented in GERBER_PLOTTER.

Definition at line 500 of file plotter.h.

501 {
502 // NOP for most plotters. Only for Gerber plotter
503 }

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 486 of file plotter.h.

487 {
488 // NOP for most plotters
489 }

Referenced by PlotOneBoardLayer().

◆ SetNegative()

virtual void PLOTTER::SetNegative ( bool  aNegative)
inlinevirtualinherited

Definition at line 130 of file plotter.h.

130{ m_negativeMode = aNegative; }
bool m_negativeMode
Definition: plotter.h:637

References PLOTTER::m_negativeMode.

Referenced by FillNegativeKnockout().

◆ SetPageSettings()

◆ SetPenDiameter()

void HPGL_PLOTTER::SetPenDiameter ( double  diameter)
virtual

Definition at line 384 of file HPGL_plotter.cpp.

385{
386 m_penDiameter = diameter;
387}

References m_penDiameter.

Referenced by ConfigureHPGLPenSizes(), HPGL_PLOTTER(), and SCH_PLOTTER::plotOneSheetHpgl().

◆ SetPenNumber()

virtual void HPGL_PLOTTER::SetPenNumber ( int  number)
inlinevirtual

Definition at line 90 of file plotter_hpgl.h.

91 {
92 m_penNumber = number;
93 }

References m_penNumber.

Referenced by ConfigureHPGLPenSizes(), and HPGL_PLOTTER().

◆ SetPenSpeed()

virtual void HPGL_PLOTTER::SetPenSpeed ( int  speed)
inlinevirtual

Definition at line 85 of file plotter_hpgl.h.

86 {
87 m_penSpeed = speed;
88 }

References m_penSpeed.

Referenced by ConfigureHPGLPenSizes(), and HPGL_PLOTTER().

◆ SetRenderSettings()

◆ 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 506 of file plotter.h.

507 {
508 // NOP for most plotters. Only for SVG plotter
509 }

Referenced by initializePlotter().

◆ SetTargetChordLength()

void HPGL_PLOTTER::SetTargetChordLength ( double  chord_len)

Set the target length of chords used to draw approximated circles and arcs.

Parameters
chord_lenthe chord length in IUs.

Definition at line 252 of file HPGL_plotter.cpp.

253{
255}

References m_arcTargetChordLength, and PLOTTER::userToDeviceSize().

Referenced by SCH_PLOTTER::plotOneSheetHpgl().

◆ SetTextMode()

virtual void PLOTTER::SetTextMode ( PLOT_TEXT_MODE  mode)
inlinevirtualinherited

Change the current text mode.

See the PlotTextMode explanation at the beginning of the file.

Reimplemented in DXF_PLOTTER, and PSLIKE_PLOTTER.

Definition at line 495 of file plotter.h.

496 {
497 // NOP for most plotters.
498 }

Referenced by initializePlotter(), and PlotOneBoardLayer().

◆ SetTitle()

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

Definition at line 161 of file plotter.h.

161{ m_title = aTitle; }
wxString m_title
Definition: plotter.h:644

References PLOTTER::m_title.

Referenced by SCH_PLOTTER::createPDFFile().

◆ SetUserCoords()

void HPGL_PLOTTER::SetUserCoords ( bool  user_coords)
inline

Switch to the user coordinate system.

Definition at line 56 of file plotter_hpgl.h.

56{ m_useUserCoords = user_coords; }

References m_useUserCoords.

Referenced by SCH_PLOTTER::plotOneSheetHpgl().

◆ SetUserCoordsFit()

void HPGL_PLOTTER::SetUserCoordsFit ( bool  user_coords_fit)
inline

Set whether the user coordinate system is fit to content.

Definition at line 59 of file plotter_hpgl.h.

59{ m_fitUserCoords = user_coords_fit; }

References m_fitUserCoords.

Referenced by SCH_PLOTTER::plotOneSheetHpgl().

◆ SetViewport()

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

Set the plot offset and scaling for the current plot.

Parameters
aOffsetis the plot offset.
aIusPerDecimilgives the scaling factor from IUs to device units
aScaleis the user set plot scaling factor (either explicitly or using 'fit to A4').
aMirrorflips the plot in the Y direction (useful for toner transfers or some kind of film).

Implements PLOTTER.

Definition at line 236 of file HPGL_plotter.cpp.

238{
239 m_plotOffset = aOffset;
240 m_plotScale = aScale;
241 m_IUsPerDecimil = aIusPerDecimil;
242 m_iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
243
244 // Compute the paper size in IUs.
246 m_paperSize.x *= 10.0 * aIusPerDecimil;
247 m_paperSize.y *= 10.0 * aIusPerDecimil;
248 m_plotMirror = aMirror;
249}
static const double PLUsPERDECIMIL
const VECTOR2I & GetSizeMils() const
Definition: page_info.h:135
VECTOR2I m_plotOffset
Definition: plotter.h:626
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:616

References PAGE_INFO::GetSizeMils(), PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_IUsPerDecimil, PLOTTER::m_pageInfo, PLOTTER::m_paperSize, PLOTTER::m_plotMirror, PLOTTER::m_plotOffset, PLOTTER::m_plotScale, PLUsPERDECIMIL, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_PLOTTER::plotOneSheetHpgl().

◆ 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:427

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(), FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), and DXF_PLOTTER::FlashPadOval().

◆ sortItems()

void HPGL_PLOTTER::sortItems ( std::list< HPGL_ITEM > &  items)
staticprotected

Sort a list of HPGL items to improve plotting speed on mechanical plotters.

Parameters
items- items to sort

Definition at line 871 of file HPGL_plotter.cpp.

872{
873 if( items.size() < 2 )
874 return;
875
876 std::list<HPGL_ITEM> target;
877
878 // Plot items are sorted to improve print time on mechanical plotters. This
879 // means
880 // 1) Avoid excess pen-switching - once a pen is selected, keep printing
881 // with it until no more items using that pen remain.
882 // 2) Within the items for one pen, avoid bouncing back and forth around
883 // the page; items should be sequenced with nearby items.
884 //
885 // This is essentially a variant of the Traveling Salesman Problem where
886 // the cities are themselves edges that must be traversed. This is of course
887 // a famously NP-Hard problem and this particular variant has a monstrous
888 // number of "cities". For now, we're using a naive nearest-neighbor search,
889 // which is less than optimal but (usually!) better than nothing, very
890 // simple to implement, and fast enough.
891 //
892 // Items are moved one at a time from `items` into `target`, searching
893 // each time for the first one matching the above criteria. Then, all of
894 // `target` is moved back into `items`.
895
896 // Get the first one started
897 HPGL_ITEM last_item = items.front();
898 items.pop_front();
899 target.emplace_back( last_item );
900
901 while( !items.empty() )
902 {
903 auto best_it = items.begin();
904 double best_dist = dpoint_dist( last_item.loc_end, best_it->loc_start );
905
906 for( auto search_it = best_it; search_it != items.end(); search_it++ )
907 {
908 // Immediately forget an item as "best" if another one is a better pen match
909 if( best_it->pen != last_item.pen && search_it->pen == last_item.pen )
910 {
911 best_it = search_it;
912 continue;
913 }
914
915 double const dist = dpoint_dist( last_item.loc_end, search_it->loc_start );
916
917 if( dist < best_dist )
918 {
919 best_it = search_it;
920 best_dist = dist;
921 continue;
922 }
923 }
924
925 target.emplace_back( *best_it );
926 last_item = *best_it;
927 items.erase( best_it );
928 }
929
930 items.splice( items.begin(), target );
931}
static double dpoint_dist(const VECTOR2D &a, const VECTOR2D &b)
Compute the distance between two VECTOR2D points.

References dpoint_dist(), HPGL_PLOTTER::HPGL_ITEM::loc_end, and HPGL_PLOTTER::HPGL_ITEM::pen.

Referenced by EndPlot().

◆ 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 518 of file plotter.h.

518{}

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

◆ startItem()

bool HPGL_PLOTTER::startItem ( const VECTOR2D location)
protected

Start a new HPGL_ITEM if necessary, keeping the current one if it exists.

Parameters
locationis the location of the item.
Returns
whether a new item was made.

Definition at line 836 of file HPGL_plotter.cpp.

837{
838 return startOrAppendItem( location, wxEmptyString );
839}

References startOrAppendItem().

Referenced by PlotPoly().

◆ startOrAppendItem()

bool HPGL_PLOTTER::startOrAppendItem ( const VECTOR2D location,
const wxString &  content 
)
protected

Start a new HPGL_ITEM with the given string if necessary, or append the string to the current item.

Parameters
locationis the location of the item, if a new one is made.
contentis the content substring.
Returns
whether a new item was made.

Definition at line 848 of file HPGL_plotter.cpp.

849{
850 if( m_current_item == nullptr )
851 {
852 HPGL_ITEM item;
853 item.loc_start = location;
854 item.loc_end = location;
855 item.bbox = BOX2D( location );
856 item.pen = m_penNumber;
857 item.dashType = m_lineStyle;
858 item.content = content;
859 m_items.push_back( item );
860 m_current_item = &m_items.back();
861 return true;
862 }
863 else
864 {
865 m_current_item->content << content;
866 return false;
867 }
868}

References HPGL_PLOTTER::HPGL_ITEM::bbox, HPGL_PLOTTER::HPGL_ITEM::content, HPGL_PLOTTER::HPGL_ITEM::dashType, HPGL_PLOTTER::HPGL_ITEM::loc_end, HPGL_PLOTTER::HPGL_ITEM::loc_start, m_current_item, m_items, m_lineStyle, m_penNumber, and HPGL_PLOTTER::HPGL_ITEM::pen.

Referenced by Arc(), Circle(), FlashPadCircle(), PenTo(), Rect(), and startItem().

◆ StartPlot()

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

At the start of the HPGL plot pen speed and number are requested.

Implements PLOTTER.

Definition at line 258 of file HPGL_plotter.cpp.

259{
260 wxASSERT( m_outputFile );
261 fprintf( m_outputFile, "IN;VS%d;PU;PA;SP%d;\n", m_penSpeed, m_penNumber );
262
263 // Set HPGL Pen Thickness (in mm) (useful in polygon fill command)
264 double penThicknessMM = userToDeviceSize( m_penDiameter ) / 40;
265 fprintf( m_outputFile, "PT %.1f;\n", penThicknessMM );
266
267 return true;
268}

References PLOTTER::m_outputFile, m_penDiameter, m_penNumber, m_penSpeed, and PLOTTER::userToDeviceSize().

Referenced by SCH_PLOTTER::plotOneSheetHpgl().

◆ Text()

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

Draw text with the plotter.

Same as GRText, but plot graphic text instead of draw it.

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

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 in DXF_PLOTTER, GERBER_PLOTTER, PS_PLOTTER, PDF_PLOTTER, and SVG_PLOTTER.

Definition at line 714 of file plotter.cpp.

727{
729
730 SetColor( aColor );
731 SetCurrentLineWidth( aPenWidth, aData );
732
733 if( aPenWidth == 0 && aBold ) // Use default values if aPenWidth == 0
734 aPenWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
735
736 if( aPenWidth < 0 )
737 aPenWidth = -aPenWidth;
738
739 CALLBACK_GAL callback_gal( empty_opts,
740 // Stroke callback
741 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
742 {
743 MoveTo( (wxPoint) aPt1 );
744 LineTo( (wxPoint) aPt2 );
745 PenFinish();
746 },
747 // Polygon callback
748 [&]( const SHAPE_LINE_CHAIN& aPoly )
749 {
750 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
751 } );
752
753 TEXT_ATTRIBUTES attributes;
754 attributes.m_Angle = aOrient;
755 attributes.m_StrokeWidth = aPenWidth;
756 attributes.m_Italic = aItalic;
757 attributes.m_Bold = aBold;
758 attributes.m_Halign = aH_justify;
759 attributes.m_Valign = aV_justify;
760 attributes.m_Size = aSize;
761
762 if( !aFont )
763 aFont = KIFONT::FONT::GetFont();
764
765 aFont->Draw( &callback_gal, aText, aPos, attributes );
766}
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:159
virtual void SetColor(const COLOR4D &color)=0
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:40

References KIFONT::FONT::Draw(), FILLED_SHAPE, KIFONT::FONT::GetFont(), GetPenSizeForBold(), PLOTTER::LineTo(), TEXT_ATTRIBUTES::m_Angle, PLOTTER::MoveTo(), PLOTTER::PenFinish(), PLOTTER::PlotPoly(), PLOTTER::SetColor(), PLOTTER::SetCurrentLineWidth(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), LIB_TEXTBOX::Plot(), PlotDrawingSheet(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), LIB_PIN::PlotPinTexts(), DXF_PLOTTER::Text(), GERBER_PLOTTER::Text(), PS_PLOTTER::Text(), PDF_PLOTTER::Text(), and SVG_PLOTTER::Text().

◆ 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}

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

◆ ThickSegment()

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

Reimplemented from PLOTTER.

Definition at line 552 of file HPGL_plotter.cpp.

554{
555 wxASSERT( m_outputFile );
556
557 // Suppress overlap if pen is too big
558 if( m_penDiameter >= width )
559 {
560 MoveTo( start );
561 FinishTo( end );
562 }
563 else
564 {
565 segmentAsOval( start, end, width, tracemode );
566 }
567}
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::FinishTo(), PLOTTER::m_outputFile, m_penDiameter, PLOTTER::MoveTo(), and PLOTTER::segmentAsOval().

◆ 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:629
bool m_yaxisReversed
Definition: plotter.h:630

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(), Arc(), SVG_PLOTTER::Arc(), PS_PLOTTER::Arc(), PDF_PLOTTER::Arc(), SVG_PLOTTER::BezierCurve(), Circle(), DXF_PLOTTER::Circle(), PS_PLOTTER::Circle(), PDF_PLOTTER::Circle(), SVG_PLOTTER::Circle(), PSLIKE_PLOTTER::computeTextParameters(), GERBER_PLOTTER::FlashPadChamferRoundRect(), 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(), PenTo(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::plotArc(), PS_PLOTTER::PlotImage(), PDF_PLOTTER::PlotImage(), PlotPoly(), PS_PLOTTER::PlotPoly(), PDF_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), Rect(), PS_PLOTTER::Rect(), PDF_PLOTTER::Rect(), SVG_PLOTTER::Rect(), DXF_PLOTTER::Text(), 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_arcMinChordDegrees

EDA_ANGLE HPGL_PLOTTER::m_arcMinChordDegrees
protected

Definition at line 222 of file plotter_hpgl.h.

Referenced by Arc(), and Circle().

◆ m_arcTargetChordLength

double HPGL_PLOTTER::m_arcTargetChordLength
protected

Definition at line 221 of file plotter_hpgl.h.

Referenced by Arc(), Circle(), and SetTargetChordLength().

◆ m_colorMode

◆ m_creator

wxString PLOTTER::m_creator
protectedinherited

◆ m_current_item

HPGL_ITEM* HPGL_PLOTTER::m_current_item
protected

◆ m_currentPenWidth

◆ m_filename

wxString PLOTTER::m_filename
protectedinherited

◆ m_fitUserCoords

bool HPGL_PLOTTER::m_fitUserCoords
protected

Definition at line 225 of file plotter_hpgl.h.

Referenced by EndPlot(), and SetUserCoordsFit().

◆ m_headerExtraLines

wxArrayString PLOTTER::m_headerExtraLines
protectedinherited

◆ m_items

std::list<HPGL_ITEM> HPGL_PLOTTER::m_items
protected

Definition at line 227 of file plotter_hpgl.h.

Referenced by EndPlot(), and startOrAppendItem().

◆ m_iuPerDeviceUnit

◆ m_IUsPerDecimil

◆ m_lineStyle

PLOT_DASH_TYPE HPGL_PLOTTER::m_lineStyle
protected

Definition at line 223 of file plotter_hpgl.h.

Referenced by SetDash(), and startOrAppendItem().

◆ m_mirrorIsHorizontal

bool PLOTTER::m_mirrorIsHorizontal
protectedinherited

Definition at line 629 of file plotter.h.

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

◆ m_negativeMode

bool PLOTTER::m_negativeMode
protectedinherited

Definition at line 637 of file plotter.h.

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

◆ m_outputFile

FILE* PLOTTER::m_outputFile
protectedinherited

Output file.

Definition at line 633 of file plotter.h.

Referenced by DXF_PLOTTER::Arc(), SVG_PLOTTER::Arc(), PS_PLOTTER::Arc(), SVG_PLOTTER::BezierCurve(), Circle(), DXF_PLOTTER::Circle(), PS_PLOTTER::Circle(), SVG_PLOTTER::Circle(), GERBER_PLOTTER::ClearAllAttributes(), GERBER_PLOTTER::clearNetAttribute(), PDF_PLOTTER::ClosePage(), PDF_PLOTTER::closePdfObject(), PDF_PLOTTER::closePdfStream(), GERBER_PLOTTER::emitDcode(), PDF_PLOTTER::emitGoToAction(), PDF_PLOTTER::emitOutline(), PDF_PLOTTER::emitOutlineNode(), PS_PLOTTER::emitSetRGBColor(), SVG_PLOTTER::EndBlock(), DXF_PLOTTER::EndPlot(), GERBER_PLOTTER::EndPlot(), EndPlot(), PS_PLOTTER::EndPlot(), PDF_PLOTTER::EndPlot(), SVG_PLOTTER::EndPlot(), FlashPadCircle(), DXF_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadOval(), FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), DXF_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadRect(), DXF_PLOTTER::FlashPadRect(), GERBER_PLOTTER::FlashPadRoundRect(), DXF_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::formatNetAttribute(), PLOTTER::OpenFile(), PDF_PLOTTER::OpenFile(), DXF_PLOTTER::PenTo(), GERBER_PLOTTER::PenTo(), PenTo(), PS_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::plotArc(), GERBER_PLOTTER::PlotGerberRegion(), PS_PLOTTER::PlotImage(), SVG_PLOTTER::PlotImage(), GERBER_PLOTTER::PlotPoly(), PS_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), GERBER_PLOTTER::plotRoundRectAsRegion(), PLOTTER::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(), PDF_PLOTTER::StartPage(), PDF_PLOTTER::startPdfObject(), PDF_PLOTTER::startPdfStream(), DXF_PLOTTER::StartPlot(), StartPlot(), PS_PLOTTER::StartPlot(), SVG_PLOTTER::StartPlot(), PDF_PLOTTER::StartPlot(), GERBER_PLOTTER::StartPlot(), DXF_PLOTTER::Text(), PS_PLOTTER::Text(), SVG_PLOTTER::Text(), ThickSegment(), GERBER_PLOTTER::writeApertureList(), and PLOTTER::~PLOTTER().

◆ m_pageInfo

◆ m_paperSize

◆ m_penDiameter

double HPGL_PLOTTER::m_penDiameter
protected

◆ m_penLastpos

VECTOR2I PLOTTER::m_penLastpos
protectedinherited

◆ m_penNumber

int HPGL_PLOTTER::m_penNumber
protected

Definition at line 219 of file plotter_hpgl.h.

Referenced by EndPlot(), SetPenNumber(), startOrAppendItem(), and StartPlot().

◆ m_penSpeed

int HPGL_PLOTTER::m_penSpeed
protected

Definition at line 218 of file plotter_hpgl.h.

Referenced by SetPenSpeed(), and StartPlot().

◆ m_penState

char PLOTTER::m_penState
protectedinherited

◆ m_plotMirror

◆ m_plotOffset

◆ m_plotScale

◆ m_renderSettings

◆ m_title

wxString PLOTTER::m_title
protectedinherited

Definition at line 644 of file plotter.h.

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

◆ m_useUserCoords

bool HPGL_PLOTTER::m_useUserCoords
protected

Definition at line 224 of file plotter_hpgl.h.

Referenced by EndPlot(), and SetUserCoords().

◆ 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 466 of file plotter.h.

Referenced by PLOTTER::Marker().

◆ USE_DEFAULT_LINE_WIDTH


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