KiCad PCB EDA Suite
DXF_PLOTTER Class Reference

#include <plotter_dxf.h>

Inheritance diagram for DXF_PLOTTER:
PLOTTER

Public Member Functions

 DXF_PLOTTER ()
 
virtual PLOT_FORMAT GetPlotterType () const override
 Returns the effective plot engine in use. More...
 
virtual void SetTextMode (PLOT_TEXT_MODE mode) override
 DXF handles NATIVE text emitting TEXT entities. More...
 
virtual bool StartPlot () override
 Open the DXF plot with a skeleton header. More...
 
virtual bool EndPlot () override
 
virtual void SetCurrentLineWidth (int width, void *aData=nullptr) override
 Set the line width for the next drawing. More...
 
virtual void SetDash (PLOT_DASH_TYPE dashed) override
 
virtual void SetColor (const COLOR4D &color) override
 The DXF exporter handles 'colors' as layers... More...
 
virtual void SetViewport (const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
 Set the scale/position for the DXF plot. More...
 
virtual void Rect (const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
 DXF rectangle: fill not supported. More...
 
virtual void Circle (const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
 DXF circle: full functionality; it even does 'fills' drawing a circle with a dual-arc polyline wide as the radius. More...
 
virtual void PlotPoly (const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
 DXF polygon: doesn't fill it but at least it close the filled ones DXF does not know thick outline. More...
 
virtual void ThickSegment (const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData) override
 
virtual void Arc (const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
 Generic fallback: arc rendered as a polyline. More...
 
virtual void PenTo (const wxPoint &pos, char plume) override
 Moveto/lineto primitive, moves the 'pen' to the specified direction. More...
 
virtual void FlashPadCircle (const wxPoint &pos, int diametre, OUTLINE_MODE trace_mode, void *aData) override
 DXF round pad: always done in sketch mode; it could be filled but it isn't pretty if other kinds of pad aren't... More...
 
virtual void FlashPadOval (const wxPoint &pos, const wxSize &size, double orient, OUTLINE_MODE trace_mode, void *aData) override
 DXF oval pad: always done in sketch mode. More...
 
virtual void FlashPadRect (const wxPoint &pos, const wxSize &size, double orient, OUTLINE_MODE trace_mode, void *aData) override
 DXF rectangular pad: always done in sketch mode. More...
 
virtual void FlashPadRoundRect (const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadCustom (const wxPoint &aPadPos, const wxSize &aSize, double aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadTrapez (const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
 DXF trapezoidal pad: only sketch mode is supported. More...
 
virtual void FlashRegularPolygon (const wxPoint &aShapePos, int aDiameter, int aCornerCount, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
 Flash a regular polygon. More...
 
virtual void Text (const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=nullptr) override
 Draw text with the plotter. More...
 
void SetUnits (DXF_UNITS aUnit)
 Set the units to use for plotting the DXF file. More...
 
DXF_UNITS GetUnits () const
 The units currently enabled for plotting. More...
 
double GetUnitScaling () const
 Get the scale factor to apply to convert the device units to be in the currently set units. More...
 
unsigned int GetMeasurementDirective () const
 Get the correct value for the $MEASUREMENT field given the current units. 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 Arc (const SHAPE_ARC &aArc)
 
virtual void BezierCurve (const wxPoint &aStart, const wxPoint &aControl1, const wxPoint &aControl2, const wxPoint &aEnd, int aTolerance, int aLineThickness=USE_DEFAULT_LINE_WIDTH)
 Generic fallback: Cubic Bezier curve rendered as a polyline In KiCad the bezier curves have 4 control points: start ctrl1 ctrl2 end. More...
 
void MoveTo (const wxPoint &pos)
 
void LineTo (const wxPoint &pos)
 
void FinishTo (const wxPoint &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 wxPoint &aPos, double aScaleFactor)
 Only PostScript plotters can plot bitmaps. More...
 
virtual void ThickArc (const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, OUTLINE_MODE tracemode, void *aData)
 
virtual void ThickRect (const wxPoint &p1, const wxPoint &p2, int width, OUTLINE_MODE tracemode, void *aData)
 
virtual void ThickCircle (const wxPoint &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData)
 
virtual void FilledCircle (const wxPoint &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
 
void Marker (const wxPoint &position, int diametre, unsigned aShapeId)
 Draw a pattern shape number aShapeId, to coord position. More...
 
virtual void SetLayerPolarity (bool aPositive)
 Set the current Gerber layer polarity to positive or negative by writing %LPD*% or %LPC*% to the Gerber file, respectively. More...
 
virtual void SetGerberCoordinatesFormat (int aResolution, bool aUseInches=false)
 
virtual void SetSvgCoordinatesFormat (unsigned aResolution, bool aUseInches=false)
 
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

void markerCircle (const wxPoint &pos, int radius)
 Plot a circle centered on the position. More...
 
void markerHBar (const wxPoint &pos, int radius)
 Plot a - bar centered on the position. More...
 
void markerSlash (const wxPoint &pos, int radius)
 Plot a / bar centered on the position. More...
 
void markerBackSlash (const wxPoint &pos, int radius)
 Plot a \ bar centered on the position. More...
 
void markerVBar (const wxPoint &pos, int radius)
 Plot a | bar centered on the position. More...
 
void markerSquare (const wxPoint &position, int radius)
 Plot a square centered on the position. More...
 
void markerLozenge (const wxPoint &position, int radius)
 Plot a lozenge centered on the position. More...
 
void segmentAsOval (const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode)
 Convert a thick segment and plot it as an oval. More...
 
void sketchOval (const wxPoint &pos, const wxSize &size, double orient, int width)
 
virtual DPOINT userToDeviceCoordinates (const wxPoint &aCoordinate)
 Modify coordinates according to the orientation, scale factor, and offsets trace. More...
 
virtual DPOINT userToDeviceSize (const wxSize &size)
 Modify size according to the plotter scale factors (wxSize version, returns a DPOINT). More...
 
virtual double userToDeviceSize (double size) const
 Modify size according to the plotter scale factors (simple double version). More...
 
double GetDotMarkLenIU () const
 
double GetDashMarkLenIU () const
 
double GetDashGapLenIU () const
 

Protected Attributes

bool m_textAsLines
 
COLOR4D m_currentColor
 
PLOT_DASH_TYPE m_currentLineType
 
DXF_UNITS m_plotUnits
 
double m_unitScalingFactor
 
unsigned int m_measurementDirective
 
double m_plotScale
 Plot scale - chosen by the user (even implicitly with 'fit in a4') More...
 
double m_IUsPerDecimil
 
double m_iuPerDeviceUnit
 
wxPoint 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
 
wxPoint m_penLastpos
 
wxString m_creator
 
wxString m_filename
 
wxString m_title
 
PAGE_INFO m_pageInfo
 
wxSize m_paperSize
 
wxArrayString m_headerExtraLines
 
RENDER_SETTINGSm_renderSettings
 

Detailed Description

Definition at line 31 of file plotter_dxf.h.

Constructor & Destructor Documentation

◆ DXF_PLOTTER()

DXF_PLOTTER::DXF_PLOTTER ( )
inline

Definition at line 34 of file plotter_dxf.h.

34  : m_textAsLines( false )
35  {
36  m_textAsLines = true;
40  }
bool m_textAsLines
Definition: plotter_dxf.h:205
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
Definition: color4d.h:44
COLOR4D m_currentColor
Definition: plotter_dxf.h:206
PLOT_DASH_TYPE m_currentLineType
Definition: plotter_dxf.h:207

References BLACK, INCHES, m_currentColor, m_currentLineType, m_textAsLines, SetUnits(), 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 183 of file plotter.h.

184  {
185  m_headerExtraLines.Add( aExtraString );
186  }
wxArrayString m_headerExtraLines
Definition: plotter.h:605

References PLOTTER::m_headerExtraLines.

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

◆ Arc() [1/2]

void DXF_PLOTTER::Arc ( const wxPoint &  centre,
double  StAngle,
double  EndAngle,
int  rayon,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Generic fallback: arc rendered as a polyline.

Reimplemented from PLOTTER.

Definition at line 622 of file DXF_plotter.cpp.

624 {
625  wxASSERT( m_outputFile );
626 
627  if( radius <= 0 )
628  return;
629 
630  // In DXF, arcs are drawn CCW.
631  // In Kicad, arcs are CW or CCW
632  // If StAngle > EndAngle, it is CW. So transform it to CCW
633  if( StAngle > EndAngle )
634  {
635  std::swap( StAngle, EndAngle );
636  }
637 
638  DPOINT centre_dev = userToDeviceCoordinates( centre );
639  double radius_dev = userToDeviceSize( radius );
640 
641  // Emit a DXF ARC entity
642  wxString cname = getDXFColorName( m_currentColor );
643  fprintf( m_outputFile,
644  "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
645  TO_UTF8( cname ),
646  centre_dev.x, centre_dev.y, radius_dev,
647  StAngle / 10.0, EndAngle / 10.0 );
648 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
static wxString getDXFColorName(const COLOR4D &aColor)
COLOR4D m_currentColor
Definition: plotter_dxf.h:206
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify size according to the plotter scale factors (wxSize version, returns a DPOINT).
Definition: plotter.cpp:123
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:92

References getDXFColorName(), m_currentColor, PLOTTER::m_outputFile, TO_UTF8, PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Arc() [2/2]

void PLOTTER::Arc ( const SHAPE_ARC aArc)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 157 of file plotter.cpp.

158 {
159  Arc( wxPoint( aArc.GetCenter() ), aArc.GetStartAngle(), aArc.GetEndAngle(), aArc.GetRadius(),
160  FILL_T::NO_FILL, aArc.GetWidth() );
161 }
double GetRadius() const
Definition: shape_arc.cpp:492
double GetStartAngle() const
Definition: shape_arc.cpp:444
double GetEndAngle() const
Definition: shape_arc.cpp:454
int GetWidth() const
Definition: shape_arc.h:156
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:164
VECTOR2I GetCenter() const
Definition: shape_arc.cpp:464

References PLOTTER::Arc(), SHAPE_ARC::GetCenter(), SHAPE_ARC::GetEndAngle(), SHAPE_ARC::GetRadius(), SHAPE_ARC::GetStartAngle(), SHAPE_ARC::GetWidth(), and NO_FILL.

◆ BezierCurve()

void PLOTTER::BezierCurve ( const wxPoint &  aStart,
const wxPoint &  aControl1,
const wxPoint &  aControl2,
const wxPoint &  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 211 of file plotter.cpp.

214 {
215  // Generic fallback: Quadratic Bezier curve plotted as a polyline
216  int minSegLen = aLineThickness; // The segment min length to approximate a bezier curve
217 
218  std::vector<wxPoint> ctrlPoints;
219  ctrlPoints.push_back( aStart );
220  ctrlPoints.push_back( aControl1 );
221  ctrlPoints.push_back( aControl2 );
222  ctrlPoints.push_back( aEnd );
223 
224  BEZIER_POLY bezier_converter( ctrlPoints );
225 
226  std::vector<wxPoint> approxPoints;
227  bezier_converter.GetPoly( approxPoints, minSegLen );
228 
229  SetCurrentLineWidth( aLineThickness );
230  MoveTo( aStart );
231 
232  for( unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
233  LineTo( approxPoints[ii] );
234 
235  FinishTo( aEnd );
236 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
void LineTo(const wxPoint &pos)
Definition: plotter.h:268
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.

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

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

◆ Circle()

void DXF_PLOTTER::Circle ( const wxPoint &  pos,
int  diametre,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

DXF circle: full functionality; it even does 'fills' drawing a circle with a dual-arc polyline wide as the radius.

I could use this trick to do other filled primitives.

Implements PLOTTER.

Definition at line 423 of file DXF_plotter.cpp.

424 {
425  wxASSERT( m_outputFile );
426  double radius = userToDeviceSize( diameter / 2 );
427  DPOINT centre_dev = userToDeviceCoordinates( centre );
428 
429  if( radius > 0 )
430  {
431  wxString cname = getDXFColorName( m_currentColor );
432 
433  if( fill == FILL_T::NO_FILL )
434  {
435  fprintf( m_outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
436  TO_UTF8( cname ),
437  centre_dev.x, centre_dev.y, radius );
438  }
439  else if( fill == FILL_T::FILLED_SHAPE )
440  {
441  double r = radius*0.5;
442  fprintf( m_outputFile, "0\nPOLYLINE\n" );
443  fprintf( m_outputFile, "8\n%s\n66\n1\n70\n1\n", TO_UTF8( cname ) );
444  fprintf( m_outputFile, "40\n%g\n41\n%g\n", radius, radius);
445  fprintf( m_outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ) );
446  fprintf( m_outputFile, "10\n%g\n 20\n%g\n42\n1.0\n",
447  centre_dev.x-r, centre_dev.y );
448  fprintf( m_outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ) );
449  fprintf( m_outputFile, "10\n%g\n 20\n%g\n42\n1.0\n",
450  centre_dev.x+r, centre_dev.y );
451  fprintf( m_outputFile, "0\nSEQEND\n");
452  }
453  }
454 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
static wxString getDXFColorName(const COLOR4D &aColor)
COLOR4D m_currentColor
Definition: plotter_dxf.h:206
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify size according to the plotter scale factors (wxSize version, returns a DPOINT).
Definition: plotter.cpp:123
E_SERIE r
Definition: eserie.cpp:41
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:92

References FILLED_SHAPE, getDXFColorName(), m_currentColor, PLOTTER::m_outputFile, NO_FILL, r, TO_UTF8, PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by FlashPadCircle().

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

192  {
193  m_headerExtraLines.Clear();
194  }
wxArrayString m_headerExtraLines
Definition: plotter.h:605

References PLOTTER::m_headerExtraLines.

Referenced by 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 SVG_PLOTTER, and GERBER_PLOTTER.

Definition at line 496 of file plotter.h.

496 {}

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

◆ EndPlot()

bool DXF_PLOTTER::EndPlot ( )
overridevirtual

Implements PLOTTER.

Definition at line 381 of file DXF_plotter.cpp.

382 {
383  wxASSERT( m_outputFile );
384 
385  // DXF FOOTER
386  fputs( " 0\n"
387  "ENDSEC\n"
388  " 0\n"
389  "EOF\n", m_outputFile );
390  fclose( m_outputFile );
391  m_outputFile = nullptr;
392 
393  return true;
394 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590

References PLOTTER::m_outputFile.

Referenced by DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF().

◆ FilledCircle()

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

Reimplemented in GERBER_PLOTTER.

Definition at line 607 of file plotter.cpp.

608 {
609  if( tracemode == FILLED )
610  {
611  Circle( pos, diametre, FILL_T::FILLED_SHAPE, 0 );
612  }
613  else
614  {
615  SetCurrentLineWidth( -1 );
616  Circle( pos, diametre, FILL_T::NO_FILL, -1 );
617  }
618 }
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0

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

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

◆ FinishTo()

void PLOTTER::FinishTo ( const wxPoint &  pos)
inlineinherited

◆ FlashPadCircle()

void DXF_PLOTTER::FlashPadCircle ( const wxPoint &  pos,
int  diametre,
OUTLINE_MODE  trace_mode,
void *  aData 
)
overridevirtual

DXF round pad: always done in sketch mode; it could be filled but it isn't pretty if other kinds of pad aren't...

Implements PLOTTER.

Definition at line 669 of file DXF_plotter.cpp.

671 {
672  wxASSERT( m_outputFile );
673  Circle( pos, diametre, FILL_T::NO_FILL );
674 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF circle: full functionality; it even does 'fills' drawing a circle with a dual-arc polyline wide a...

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

◆ FlashPadCustom()

void DXF_PLOTTER::FlashPadCustom ( const wxPoint &  aPadPos,
const wxSize &  aSize,
double  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 763 of file DXF_plotter.cpp.

766 {
767  for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
768  {
769  SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
770 
771  MoveTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
772 
773  for( int ii = 1; ii < poly.PointCount(); ++ii )
774  LineTo( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
775 
776  FinishTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
777  }
778 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
int OutlineCount() const
Return the number of vertices in a given outline/hole.
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.
void LineTo(const wxPoint &pos)
Definition: plotter.h:268
SHAPE_LINE_CHAIN & Outline(int aIndex)
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
Represent a polyline (an zero-thickness chain of connected line segments).

References SHAPE_LINE_CHAIN::CPoint(), PLOTTER::FinishTo(), PLOTTER::LineTo(), PLOTTER::MoveTo(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadOval()

void DXF_PLOTTER::FlashPadOval ( const wxPoint &  pos,
const wxSize &  size,
double  orient,
OUTLINE_MODE  trace_mode,
void *  aData 
)
overridevirtual

DXF oval pad: always done in sketch mode.

Implements PLOTTER.

Definition at line 651 of file DXF_plotter.cpp.

653 {
654  wxASSERT( m_outputFile );
655  wxSize size( aSize );
656 
657  /* The chip is reduced to an oval tablet with size.y > size.x
658  * (Oval vertical orientation 0) */
659  if( size.x > size.y )
660  {
661  std::swap( size.x, size.y );
662  orient = AddAngles( orient, 900 );
663  }
664 
665  sketchOval( pos, size, orient, -1 );
666 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:341
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
Definition: plotter.cpp:481

References AddAngles(), PLOTTER::m_outputFile, and PLOTTER::sketchOval().

◆ FlashPadRect()

void DXF_PLOTTER::FlashPadRect ( const wxPoint &  pos,
const wxSize &  size,
double  orient,
OUTLINE_MODE  trace_mode,
void *  aData 
)
overridevirtual

DXF rectangular pad: always done in sketch mode.

Implements PLOTTER.

Definition at line 677 of file DXF_plotter.cpp.

679 {
680  wxASSERT( m_outputFile );
681  wxSize size;
682  int ox, oy, fx, fy;
683 
684  size.x = padsize.x / 2;
685  size.y = padsize.y / 2;
686 
687  if( size.x < 0 )
688  size.x = 0;
689 
690  if( size.y < 0 )
691  size.y = 0;
692 
693  // If a dimension is zero, the trace is reduced to 1 line
694  if( size.x == 0 )
695  {
696  ox = pos.x;
697  oy = pos.y - size.y;
698  RotatePoint( &ox, &oy, pos.x, pos.y, orient );
699  fx = pos.x;
700  fy = pos.y + size.y;
701  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
702  MoveTo( wxPoint( ox, oy ) );
703  FinishTo( wxPoint( fx, fy ) );
704  return;
705  }
706 
707  if( size.y == 0 )
708  {
709  ox = pos.x - size.x;
710  oy = pos.y;
711  RotatePoint( &ox, &oy, pos.x, pos.y, orient );
712  fx = pos.x + size.x;
713  fy = pos.y;
714  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
715  MoveTo( wxPoint( ox, oy ) );
716  FinishTo( wxPoint( fx, fy ) );
717  return;
718  }
719 
720  ox = pos.x - size.x;
721  oy = pos.y - size.y;
722  RotatePoint( &ox, &oy, pos.x, pos.y, orient );
723  MoveTo( wxPoint( ox, oy ) );
724 
725  fx = pos.x - size.x;
726  fy = pos.y + size.y;
727  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
728  LineTo( wxPoint( fx, fy ) );
729 
730  fx = pos.x + size.x;
731  fy = pos.y + size.y;
732  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
733  LineTo( wxPoint( fx, fy ) );
734 
735  fx = pos.x + size.x;
736  fy = pos.y - size.y;
737  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
738  LineTo( wxPoint( fx, fy ) );
739 
740  FinishTo( wxPoint( ox, oy ) );
741 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void LineTo(const wxPoint &pos)
Definition: plotter.h:268
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263

References PLOTTER::FinishTo(), PLOTTER::LineTo(), PLOTTER::m_outputFile, PLOTTER::MoveTo(), and RotatePoint().

◆ FlashPadRoundRect()

void DXF_PLOTTER::FlashPadRoundRect ( const wxPoint &  aPadPos,
const wxSize &  aSize,
int  aCornerRadius,
double  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 744 of file DXF_plotter.cpp.

747 {
748  SHAPE_POLY_SET outline;
749  TransformRoundChamferedRectToPolygon( outline, aPadPos, aSize, aOrient, aCornerRadius,
750  0.0, 0, 0, GetPlotterArcHighDef(), ERROR_INSIDE );
751 
752  // TransformRoundRectToPolygon creates only one convex polygon
753  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
754 
755  MoveTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
756 
757  for( int ii = 1; ii < poly.PointCount(); ++ii )
758  LineTo( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
759 
760  FinishTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
761 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
int PointCount() const
Return the number of points (vertices) in this line chain.
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double 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.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
void LineTo(const wxPoint &pos)
Definition: plotter.h:268
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
Represent a polyline (an zero-thickness chain of connected line segments).
int GetPlotterArcHighDef() const
Definition: plotter.h:228

References SHAPE_LINE_CHAIN::CPoint(), ERROR_INSIDE, PLOTTER::FinishTo(), PLOTTER::GetPlotterArcHighDef(), PLOTTER::LineTo(), PLOTTER::MoveTo(), SHAPE_POLY_SET::Outline(), SHAPE_LINE_CHAIN::PointCount(), TransformRoundChamferedRectToPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadTrapez()

void DXF_PLOTTER::FlashPadTrapez ( const wxPoint &  aPadPos,
const wxPoint *  aCorners,
double  aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual

DXF trapezoidal pad: only sketch mode is supported.

Implements PLOTTER.

Definition at line 781 of file DXF_plotter.cpp.

783 {
784  wxASSERT( m_outputFile );
785  wxPoint coord[4]; /* coord actual corners of a trapezoidal trace */
786 
787  for( int ii = 0; ii < 4; ii++ )
788  {
789  coord[ii] = aCorners[ii];
790  RotatePoint( &coord[ii], aPadOrient );
791  coord[ii] += aPadPos;
792  }
793 
794  // Plot edge:
795  MoveTo( coord[0] );
796  LineTo( coord[1] );
797  LineTo( coord[2] );
798  LineTo( coord[3] );
799  FinishTo( coord[0] );
800 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void LineTo(const wxPoint &pos)
Definition: plotter.h:268
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263

References PLOTTER::FinishTo(), PLOTTER::LineTo(), PLOTTER::m_outputFile, PLOTTER::MoveTo(), and RotatePoint().

◆ FlashRegularPolygon()

void DXF_PLOTTER::FlashRegularPolygon ( const wxPoint &  aShapePos,
int  aDiameter,
int  aCornerCount,
double  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 in degrees.
aDatais a auxiliary parameter used (if needed) to handle extra info specific to the plotter.

Implements PLOTTER.

Definition at line 803 of file DXF_plotter.cpp.

805 {
806  // Do nothing
807  wxASSERT( 0 );
808 }

◆ GetColorMode()

◆ GetCurrentLineWidth()

◆ GetDashGapLenIU()

double PLOTTER::GetDashGapLenIU ( ) const
protectedinherited

Definition at line 151 of file plotter.cpp.

152 {
154 }
virtual int GetCurrentLineWidth() const
Definition: plotter.h:168
constexpr double dash_gap_len(double aLineWidth)
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify size according to the plotter scale factors (wxSize version, returns a DPOINT).
Definition: plotter.cpp:123

References dash_gap_len(), PLOTTER::GetCurrentLineWidth(), and PLOTTER::userToDeviceSize().

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

◆ GetDashMarkLenIU()

double PLOTTER::GetDashMarkLenIU ( ) const
protectedinherited

Definition at line 145 of file plotter.cpp.

146 {
148 }
virtual int GetCurrentLineWidth() const
Definition: plotter.h:168
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify size according to the plotter scale factors (wxSize version, returns a DPOINT).
Definition: plotter.cpp:123
constexpr double dash_mark_len(double aLineWidth)

References dash_mark_len(), PLOTTER::GetCurrentLineWidth(), and PLOTTER::userToDeviceSize().

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

◆ GetDefaultFileExtension()

static wxString DXF_PLOTTER::GetDefaultFileExtension ( )
inlinestatic

Definition at line 47 of file plotter_dxf.h.

48  {
49  return wxString( wxT( "dxf" ) );
50  }

Referenced by DIALOG_PLOT_SCHEMATIC::createDXFFiles(), and GetDefaultPlotExtension().

◆ GetDotMarkLenIU()

double PLOTTER::GetDotMarkLenIU ( ) const
protectedinherited

Definition at line 139 of file plotter.cpp.

140 {
142 }
virtual int GetCurrentLineWidth() const
Definition: plotter.h:168
constexpr double dot_mark_len(double aLineWidth)
Dashed and dotted line patterns.
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify size according to the plotter scale factors (wxSize version, returns a DPOINT).
Definition: plotter.cpp:123

References dot_mark_len(), PLOTTER::GetCurrentLineWidth(), and PLOTTER::userToDeviceSize().

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

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

225 { return m_IUsPerDecimil; }
double m_IUsPerDecimil
Definition: plotter.h:579

References PLOTTER::m_IUsPerDecimil.

Referenced by PlotDrawingSheet().

◆ GetMeasurementDirective()

unsigned int DXF_PLOTTER::GetMeasurementDirective ( ) const
inline

Get the correct value for the $MEASUREMENT field given the current units.

Returns
the $MEASUREMENT directive field value

Definition at line 199 of file plotter_dxf.h.

200  {
201  return m_measurementDirective;
202  }
unsigned int m_measurementDirective
Definition: plotter_dxf.h:211

References m_measurementDirective.

Referenced by StartPlot().

◆ GetPlotterArcHighDef()

int PLOTTER::GetPlotterArcHighDef ( ) const
inlineinherited

◆ GetPlotterArcLowDef()

int PLOTTER::GetPlotterArcLowDef ( ) const
inlineinherited

Definition at line 227 of file plotter.h.

227 { return m_IUsPerDecimil * 8; }
double m_IUsPerDecimil
Definition: plotter.h:579

References PLOTTER::m_IUsPerDecimil.

◆ GetPlotterType()

virtual PLOT_FORMAT DXF_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 42 of file plotter_dxf.h.

43  {
44  return PLOT_FORMAT::DXF;
45  }

References DXF.

◆ GetUnits()

DXF_UNITS DXF_PLOTTER::GetUnits ( ) const
inline

The units currently enabled for plotting.

Returns
The currently configured units

Definition at line 178 of file plotter_dxf.h.

179  {
180  return m_plotUnits;
181  }
DXF_UNITS m_plotUnits
Definition: plotter_dxf.h:209

References m_plotUnits.

◆ GetUnitScaling()

double DXF_PLOTTER::GetUnitScaling ( ) const
inline

Get the scale factor to apply to convert the device units to be in the currently set units.

Returns
Scaling factor to apply for unit conversion

Definition at line 189 of file plotter_dxf.h.

190  {
191  return m_unitScalingFactor;
192  }
double m_unitScalingFactor
Definition: plotter_dxf.h:210

References m_unitScalingFactor.

Referenced by SetViewport().

◆ LineTo()

void PLOTTER::LineTo ( const wxPoint &  pos)
inlineinherited

Definition at line 268 of file plotter.h.

269  {
270  PenTo( pos, 'D' );
271  }
virtual void PenTo(const wxPoint &pos, char plume)=0
Moveto/lineto primitive, moves the 'pen' to the specified direction.

References PLOTTER::PenTo().

Referenced by PLOTTER::Arc(), PLOTTER::BezierCurve(), FlashPadCustom(), FlashPadRect(), FlashPadRoundRect(), FlashPadTrapez(), GERBER_PLOTTER::plotArc(), GERBER_PLOTTER::PlotPoly(), HPGL_PLOTTER::PlotPoly(), PlotPoly(), GERBER_PLOTTER::plotRoundRectAsRegion(), LIB_PIN::PlotSymbol(), and Rect().

◆ Marker()

void PLOTTER::Marker ( const wxPoint &  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 338 of file plotter.cpp.

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

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 wxPoint &  pos,
int  radius 
)
protectedinherited

Plot a \ bar centered on the position.

Building block for markers

Definition at line 324 of file plotter.cpp.

325 {
326  MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
327  FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
328 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

Referenced by PLOTTER::Marker().

◆ markerCircle()

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

Plot a circle centered on the position.

Building block for markers

Definition at line 280 of file plotter.cpp.

281 {
282  Circle( position, radius * 2, FILL_T::NO_FILL, GetCurrentLineWidth() );
283 }
virtual int GetCurrentLineWidth() const
Definition: plotter.h:168
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0

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

Referenced by PLOTTER::Marker().

◆ markerHBar()

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

Plot a - bar centered on the position.

Building block for markers

Definition at line 310 of file plotter.cpp.

311 {
312  MoveTo( wxPoint( pos.x - radius, pos.y ) );
313  FinishTo( wxPoint( pos.x + radius, pos.y ) );
314 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

Referenced by PLOTTER::Marker().

◆ markerLozenge()

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

Plot a lozenge centered on the position.

Building block for markers

Definition at line 286 of file plotter.cpp.

287 {
288  std::vector< wxPoint > corner_list;
289  wxPoint corner;
290  corner.x = position.x;
291  corner.y = position.y + radius;
292  corner_list.push_back( corner );
293  corner.x = position.x + radius;
294  corner.y = position.y,
295  corner_list.push_back( corner );
296  corner.x = position.x;
297  corner.y = position.y - radius;
298  corner_list.push_back( corner );
299  corner.x = position.x - radius;
300  corner.y = position.y;
301  corner_list.push_back( corner );
302  corner.x = position.x;
303  corner.y = position.y + radius;
304  corner_list.push_back( corner );
305 
306  PlotPoly( corner_list, FILL_T::NO_FILL, GetCurrentLineWidth() );
307 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual int GetCurrentLineWidth() const
Definition: plotter.h:168

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

Referenced by PLOTTER::Marker().

◆ markerSlash()

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

Plot a / bar centered on the position.

Building block for markers

Definition at line 317 of file plotter.cpp.

318 {
319  MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
320  FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
321 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

Referenced by PLOTTER::Marker().

◆ markerSquare()

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

Plot a square centered on the position.

Building block for markers

Definition at line 255 of file plotter.cpp.

256 {
257  double r = KiROUND( radius / 1.4142 );
258  std::vector< wxPoint > corner_list;
259  wxPoint corner;
260  corner.x = position.x + r;
261  corner.y = position.y + r;
262  corner_list.push_back( corner );
263  corner.x = position.x + r;
264  corner.y = position.y - r;
265  corner_list.push_back( corner );
266  corner.x = position.x - r;
267  corner.y = position.y - r;
268  corner_list.push_back( corner );
269  corner.x = position.x - r;
270  corner.y = position.y + r;
271  corner_list.push_back( corner );
272  corner.x = position.x + r;
273  corner.y = position.y + r;
274  corner_list.push_back( corner );
275 
276  PlotPoly( corner_list, FILL_T::NO_FILL, GetCurrentLineWidth() );
277 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual int GetCurrentLineWidth() const
Definition: plotter.h:168
E_SERIE r
Definition: eserie.cpp:41
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:73

References PLOTTER::GetCurrentLineWidth(), KiROUND(), NO_FILL, PLOTTER::PlotPoly(), and r.

Referenced by PLOTTER::Marker().

◆ markerVBar()

void PLOTTER::markerVBar ( const wxPoint &  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( wxPoint( pos.x, pos.y - radius ) );
334  FinishTo( wxPoint( pos.x, pos.y + radius ) );
335 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

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 76 of file plotter.cpp.

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

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

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

◆ PageSettings()

PAGE_INFO& PLOTTER::PageSettings ( )
inlineinherited

◆ PenFinish()

void PLOTTER::PenFinish ( )
inlineinherited

Definition at line 279 of file plotter.h.

280  {
281  // The point is not important with Z motion
282  PenTo( wxPoint( 0, 0 ), 'Z' );
283  }
virtual void PenTo(const wxPoint &pos, char plume)=0
Moveto/lineto primitive, moves the 'pen' to the specified direction.

References PLOTTER::PenTo().

Referenced by HPGL_PLOTTER::Circle(), HPGL_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::PlotPoly(), HPGL_PLOTTER::PlotPoly(), PlotPoly(), and HPGL_PLOTTER::Rect().

◆ PenTo()

void DXF_PLOTTER::PenTo ( const wxPoint &  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 557 of file DXF_plotter.cpp.

558 {
559  wxASSERT( m_outputFile );
560 
561  if( plume == 'Z' )
562  {
563  return;
564  }
565 
566  DPOINT pos_dev = userToDeviceCoordinates( pos );
567  DPOINT pen_lastpos_dev = userToDeviceCoordinates( m_penLastpos );
568 
569  if( m_penLastpos != pos && plume == 'D' )
570  {
573  // DXF LINE
574  wxString cname = getDXFColorName( m_currentColor );
575  const char* lname = getDXFLineType( static_cast<PLOT_DASH_TYPE>( m_currentLineType ) );
576  fprintf( m_outputFile, "0\nLINE\n8\n%s\n6\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
577  TO_UTF8( cname ), lname,
578  pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
579  }
580 
581  m_penLastpos = pos;
582 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
static wxString getDXFColorName(const COLOR4D &aColor)
COLOR4D m_currentColor
Definition: plotter_dxf.h:206
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
wxPoint m_penLastpos
Definition: plotter.h:597
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:92
static const char * getDXFLineType(PLOT_DASH_TYPE aType)
Definition: DXF_plotter.cpp:93
PLOT_DASH_TYPE m_currentLineType
Definition: plotter_dxf.h:207

References FIRST_TYPE, getDXFColorName(), getDXFLineType(), LAST_TYPE, m_currentColor, m_currentLineType, PLOTTER::m_outputFile, PLOTTER::m_penLastpos, TO_UTF8, PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ PlotImage()

void PLOTTER::PlotImage ( const wxImage &  aImage,
const wxPoint &  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 SVG_PLOTTER, PDF_PLOTTER, and PS_PLOTTER.

Definition at line 239 of file plotter.cpp.

240 {
241  wxSize size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
242 
243  wxPoint start = aPos;
244  start.x -= size.x / 2;
245  start.y -= size.y / 2;
246 
247  wxPoint end = start;
248  end.x += size.x;
249  end.y += size.y;
250 
251  Rect( start, end, FILL_T::NO_FILL );
252 }
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0

References NO_FILL, and PLOTTER::Rect().

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

◆ PlotPoly() [1/2]

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

DXF polygon: doesn't fill it but at least it close the filled ones DXF does not know thick outline.

It does not know thick segments, therefore filled polygons with thick outline are converted to inflated polygon by aWidth/2.

Implements PLOTTER.

Definition at line 457 of file DXF_plotter.cpp.

459 {
460  if( aCornerList.size() <= 1 )
461  return;
462 
463  unsigned last = aCornerList.size() - 1;
464 
465  // Plot outlines with lines (thickness = 0) to define the polygon
466  if( aWidth <= 0 )
467  {
468  MoveTo( aCornerList[0] );
469 
470  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
471  LineTo( aCornerList[ii] );
472 
473  // Close polygon if 'fill' requested
474  if( aFill != FILL_T::NO_FILL )
475  {
476  if( aCornerList[last] != aCornerList[0] )
477  LineTo( aCornerList[0] );
478  }
479 
480  PenFinish();
481 
482  return;
483  }
484 
485  // if the polygon outline has thickness, and is not filled
486  // (i.e. is a polyline) plot outlines with thick segments
487  if( aWidth > 0 && aFill == FILL_T::NO_FILL )
488  {
489  MoveTo( aCornerList[0] );
490 
491  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
492  ThickSegment( aCornerList[ii-1], aCornerList[ii], aWidth, FILLED, nullptr );
493 
494  return;
495  }
496 
497  // The polygon outline has thickness, and is filled
498  // Build and plot the polygon which contains the initial
499  // polygon and its thick outline
500  SHAPE_POLY_SET bufferOutline;
501  SHAPE_POLY_SET bufferPolybase;
502 
503  bufferPolybase.NewOutline();
504 
505  // enter outline as polygon:
506  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
507  {
508  TransformOvalToPolygon( bufferOutline, aCornerList[ ii - 1 ], aCornerList[ ii ],
509  aWidth, GetPlotterArcHighDef(), ERROR_INSIDE );
510  }
511 
512  // enter the initial polygon:
513  for( unsigned ii = 0; ii < aCornerList.size(); ii++ )
514  {
515  bufferPolybase.Append( aCornerList[ii] );
516  }
517 
518  // Merge polygons to build the polygon which contains the initial
519  // polygon and its thick outline
520 
521  // create the outline which contains thick outline:
522  bufferPolybase.BooleanAdd( bufferOutline, SHAPE_POLY_SET::PM_FAST );
523  bufferPolybase.Fracture( SHAPE_POLY_SET::PM_FAST );
524 
525  if( bufferPolybase.OutlineCount() < 1 ) // should not happen
526  return;
527 
528  const SHAPE_LINE_CHAIN& path = bufferPolybase.COutline( 0 );
529 
530  if( path.PointCount() < 2 ) // should not happen
531  return;
532 
533  // Now, output the final polygon to DXF file:
534  last = path.PointCount() - 1;
535  VECTOR2I point = path.CPoint( 0 );
536 
537  wxPoint startPoint( point.x, point.y );
538  MoveTo( startPoint );
539 
540  for( int ii = 1; ii < path.PointCount(); ii++ )
541  {
542  point = path.CPoint( ii );
543  LineTo( wxPoint( point.x, point.y ) );
544  }
545 
546  // Close polygon, if needed
547  point = path.CPoint( last );
548  wxPoint endPoint( point.x, point.y );
549 
550  if( endPoint != startPoint )
551  LineTo( startPoint );
552 
553  PenFinish();
554 }
void PenFinish()
Definition: plotter.h:279
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void LineTo(const wxPoint &pos)
Definition: plotter.h:268
Represent a set of closed polygons.
int NewOutline()
Creates a new hole in a given outline.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
Represent a polyline (an zero-thickness chain of connected line segments).
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
int GetPlotterArcHighDef() const
Definition: plotter.h:228
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData) override
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BooleanAdd(), SHAPE_POLY_SET::COutline(), ERROR_INSIDE, FILLED, SHAPE_POLY_SET::Fracture(), PLOTTER::GetPlotterArcHighDef(), PLOTTER::LineTo(), PLOTTER::MoveTo(), SHAPE_POLY_SET::NewOutline(), NO_FILL, SHAPE_POLY_SET::OutlineCount(), path, PLOTTER::PenFinish(), SHAPE_POLY_SET::PM_FAST, ThickSegment(), TransformOvalToPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by ThickSegment().

◆ PlotPoly() [2/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 621 of file plotter.cpp.

622 {
623  std::vector<wxPoint> cornerList;
624  cornerList.reserve( aCornerList.PointCount() );
625 
626  for( int ii = 0; ii < aCornerList.PointCount(); ii++ )
627  cornerList.emplace_back( aCornerList.CPoint( ii ) );
628 
629  if( aCornerList.IsClosed() && cornerList.front() != cornerList.back() )
630  cornerList.emplace_back( aCornerList.CPoint( 0 ) );
631 
632  PlotPoly( cornerList, aFill, aWidth, aData );
633 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
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.
bool IsClosed() const override

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

◆ Rect()

void DXF_PLOTTER::Rect ( const wxPoint &  p1,
const wxPoint &  p2,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

DXF rectangle: fill not supported.

Implements PLOTTER.

Definition at line 412 of file DXF_plotter.cpp.

413 {
414  wxASSERT( m_outputFile );
415  MoveTo( p1 );
416  LineTo( wxPoint( p1.x, p2.y ) );
417  LineTo( wxPoint( p2.x, p2.y ) );
418  LineTo( wxPoint( p2.x, p1.y ) );
419  FinishTo( wxPoint( p1.x, p1.y ) );
420 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void LineTo(const wxPoint &pos)
Definition: plotter.h:268
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263

References PLOTTER::FinishTo(), PLOTTER::LineTo(), PLOTTER::m_outputFile, and PLOTTER::MoveTo().

◆ RenderSettings()

◆ segmentAsOval()

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

Convert a thick segment and plot it as an oval.

Definition at line 460 of file plotter.cpp.

462 {
463  wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
464  wxSize size( end.x - start.x, end.y - start.y );
465  double orient;
466 
467  if( size.y == 0 )
468  orient = 0;
469  else if( size.x == 0 )
470  orient = 900;
471  else
472  orient = -ArcTangente( size.y, size.x );
473 
474  size.x = KiROUND( EuclideanNorm( size ) ) + width;
475  size.y = width;
476 
477  FlashPadOval( center, size, orient, tracemode, nullptr );
478 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
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:73
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References ArcTangente(), EuclideanNorm(), PLOTTER::FlashPadOval(), and KiROUND().

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

◆ SetColor()

void DXF_PLOTTER::SetColor ( const COLOR4D color)
overridevirtual

The DXF exporter handles 'colors' as layers...

Implements PLOTTER.

Definition at line 397 of file DXF_plotter.cpp.

398 {
399  if( ( m_colorMode )
400  || ( color == COLOR4D::BLACK )
401  || ( color == COLOR4D::WHITE ) )
402  {
404  }
405  else
406  {
408  }
409 }
int color
Definition: DXF_plotter.cpp:57
Definition: color4d.h:44
COLOR4D m_currentColor
Definition: plotter_dxf.h:206
bool m_colorMode
Definition: plotter.h:593
Definition: color4d.h:48

References BLACK, color, PLOTTER::m_colorMode, m_currentColor, and WHITE.

Referenced by Text().

◆ SetColorMode()

virtual void PLOTTER::SetColorMode ( bool  aColorMode)
inlinevirtualinherited

◆ SetCreator()

◆ SetCurrentLineWidth()

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

Set the line width for the next drawing.

Parameters
widthis specified in IUs.
aDatais an auxiliary parameter, mainly used in gerber plotter.

Implements PLOTTER.

Definition at line 68 of file plotter_dxf.h.

69  {
71  }
int m_currentPenWidth
Definition: plotter.h:595

References PLOTTER::m_currentPenWidth.

◆ SetDash()

void DXF_PLOTTER::SetDash ( PLOT_DASH_TYPE  dashed)
overridevirtual

Implements PLOTTER.

Definition at line 585 of file DXF_plotter.cpp.

586 {
587  wxASSERT( aDashed >= PLOT_DASH_TYPE::FIRST_TYPE && aDashed <= PLOT_DASH_TYPE::LAST_TYPE );
588  m_currentLineType = aDashed;
589 }
PLOT_DASH_TYPE m_currentLineType
Definition: plotter_dxf.h:207

References FIRST_TYPE, LAST_TYPE, and m_currentLineType.

◆ SetGerberCoordinatesFormat()

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

Reimplemented in GERBER_PLOTTER.

Definition at line 470 of file plotter.h.

471  {
472  // NOP for most plotters. Only for Gerber plotter
473  }

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

457  {
458  // NOP for most plotters
459  }

Referenced by PlotOneBoardLayer().

◆ SetNegative()

virtual void PLOTTER::SetNegative ( bool  aNegative)
inlinevirtualinherited

Definition at line 142 of file plotter.h.

143  {
144  m_negativeMode = aNegative;
145  }
bool m_negativeMode
Definition: plotter.h:594

References PLOTTER::m_negativeMode.

Referenced by FillNegativeKnockout().

◆ SetPageSettings()

◆ SetRenderSettings()

◆ SetSvgCoordinatesFormat()

virtual void PLOTTER::SetSvgCoordinatesFormat ( unsigned  aResolution,
bool  aUseInches = false 
)
inlinevirtualinherited

Reimplemented in SVG_PLOTTER.

Definition at line 475 of file plotter.h.

476  {
477  // NOP for most plotters. Only for SVG plotter
478  }

Referenced by initializePlotter().

◆ SetTextMode()

virtual void DXF_PLOTTER::SetTextMode ( PLOT_TEXT_MODE  mode)
inlineoverridevirtual

DXF handles NATIVE text emitting TEXT entities.

Reimplemented from PLOTTER.

Definition at line 55 of file plotter_dxf.h.

References DEFAULT, m_textAsLines, and NATIVE.

◆ SetTitle()

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

Definition at line 176 of file plotter.h.

176 { m_title = aTitle; }
wxString m_title
Definition: plotter.h:601

References PLOTTER::m_title.

Referenced by DIALOG_PLOT_SCHEMATIC::createPDFFile().

◆ SetUnits()

void DXF_PLOTTER::SetUnits ( DXF_UNITS  aUnit)

Set the units to use for plotting the DXF file.

Parameters
aUnit- The units to use

Definition at line 125 of file DXF_plotter.cpp.

126 {
127  m_plotUnits = aUnit;
128 
129  switch( aUnit )
130  {
132  m_unitScalingFactor = 0.00254;
134  break;
135 
136  case DXF_UNITS::INCHES:
137  default:
138  m_unitScalingFactor = 0.0001;
140  }
141 }
double m_unitScalingFactor
Definition: plotter_dxf.h:210
unsigned int m_measurementDirective
Definition: plotter_dxf.h:211
DXF_UNITS m_plotUnits
Definition: plotter_dxf.h:209

References INCHES, m_measurementDirective, m_plotUnits, m_unitScalingFactor, and MILLIMETERS.

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

◆ SetViewport()

void DXF_PLOTTER::SetViewport ( const wxPoint &  aOffset,
double  aIusPerDecimil,
double  aScale,
bool  aMirror 
)
overridevirtual

Set the scale/position for the DXF plot.

The DXF engine doesn't support line widths and mirroring. The output coordinate system is in the first quadrant (in mm).

Implements PLOTTER.

Definition at line 144 of file DXF_plotter.cpp.

146 {
147  m_plotOffset = aOffset;
148  m_plotScale = aScale;
149 
150  /* DXF paper is 'virtual' so there is no need of a paper size.
151  Also this way we can handle the aux origin which can be useful
152  (for example when aligning to a mechanical drawing) */
153  m_paperSize.x = 0;
154  m_paperSize.y = 0;
155 
156  /* Like paper size DXF units are abstract too. Anyway there is a
157  * system variable (MEASUREMENT) which will be set to 0 to indicate
158  * english units */
159  m_IUsPerDecimil = aIusPerDecimil;
160  m_iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils
161  m_iuPerDeviceUnit *= GetUnitScaling(); // Get the scaling factor for the current units
162 
163  m_plotMirror = false; // No mirroring on DXF
165 }
double m_iuPerDeviceUnit
Definition: plotter.h:581
Definition: color4d.h:44
COLOR4D m_currentColor
Definition: plotter_dxf.h:206
double m_IUsPerDecimil
Definition: plotter.h:579
double GetUnitScaling() const
Get the scale factor to apply to convert the device units to be in the currently set units.
Definition: plotter_dxf.h:189
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:573
bool m_plotMirror
Definition: plotter.h:584
wxPoint m_plotOffset
Definition: plotter.h:583
wxSize m_paperSize
Definition: plotter.h:603

References BLACK, GetUnitScaling(), m_currentColor, PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_IUsPerDecimil, PLOTTER::m_paperSize, PLOTTER::m_plotMirror, PLOTTER::m_plotOffset, and PLOTTER::m_plotScale.

Referenced by DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF().

◆ sketchOval()

void PLOTTER::sketchOval ( const wxPoint &  pos,
const wxSize &  size,
double  orient,
int  width 
)
protectedinherited

Definition at line 481 of file plotter.cpp.

482 {
483  SetCurrentLineWidth( width );
484  width = m_currentPenWidth;
485  int radius, deltaxy, cx, cy;
486  wxSize size( aSize );
487 
488  if( size.x > size.y )
489  {
490  std::swap( size.x, size.y );
491  orient = AddAngles( orient, 900 );
492  }
493 
494  deltaxy = size.y - size.x; /* distance between centers of the oval */
495  radius = ( size.x - width ) / 2;
496  cx = -radius;
497  cy = -deltaxy / 2;
498  RotatePoint( &cx, &cy, orient );
499  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
500  cx = -radius;
501  cy = deltaxy / 2;
502  RotatePoint( &cx, &cy, orient );
503  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
504 
505  cx = radius;
506  cy = -deltaxy / 2;
507  RotatePoint( &cx, &cy, orient );
508  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
509  cx = radius;
510  cy = deltaxy / 2;
511  RotatePoint( &cx, &cy, orient );
512  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
513 
514  cx = 0;
515  cy = deltaxy / 2;
516  RotatePoint( &cx, &cy, orient );
517  Arc( wxPoint( cx + pos.x, cy + pos.y ), orient + 1800, orient + 3600, radius, FILL_T::NO_FILL );
518  cx = 0;
519  cy = -deltaxy / 2;
520  RotatePoint( &cx, &cy, orient );
521  Arc( wxPoint( cx + pos.x, cy + pos.y ), orient, orient + 1800, radius, FILL_T::NO_FILL );
522 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int m_currentPenWidth
Definition: plotter.h:595
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:341
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:164
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.

References AddAngles(), PLOTTER::Arc(), PLOTTER::FinishTo(), PLOTTER::m_currentPenWidth, PLOTTER::MoveTo(), NO_FILL, RotatePoint(), and PLOTTER::SetCurrentLineWidth().

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

◆ StartBlock()

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

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

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

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

Reimplemented in SVG_PLOTTER, and GERBER_PLOTTER.

Definition at line 487 of file plotter.h.

487 {}

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

◆ StartPlot()

bool DXF_PLOTTER::StartPlot ( )
overridevirtual

Open the DXF plot with a skeleton header.

Implements PLOTTER.

Definition at line 168 of file DXF_plotter.cpp.

169 {
170  wxASSERT( m_outputFile );
171 
172  // DXF HEADER - Boilerplate
173  // Defines the minimum for drawing i.e. the angle system and the
174  // 4 linetypes (CONTINUOUS, DOTDASH, DASHED and DOTTED)
175  fprintf( m_outputFile,
176  " 0\n"
177  "SECTION\n"
178  " 2\n"
179  "HEADER\n"
180  " 9\n"
181  "$ANGBASE\n"
182  " 50\n"
183  "0.0\n"
184  " 9\n"
185  "$ANGDIR\n"
186  " 70\n"
187  "1\n"
188  " 9\n"
189  "$MEASUREMENT\n"
190  " 70\n"
191  "%u\n"
192  " 0\n"
193  "ENDSEC\n"
194  " 0\n"
195  "SECTION\n"
196  " 2\n"
197  "TABLES\n"
198  " 0\n"
199  "TABLE\n"
200  " 2\n"
201  "LTYPE\n"
202  " 70\n"
203  "4\n"
204  " 0\n"
205  "LTYPE\n"
206  " 5\n"
207  "40F\n"
208  " 2\n"
209  "CONTINUOUS\n"
210  " 70\n"
211  "0\n"
212  " 3\n"
213  "Solid line\n"
214  " 72\n"
215  "65\n"
216  " 73\n"
217  "0\n"
218  " 40\n"
219  "0.0\n"
220  " 0\n"
221  "LTYPE\n"
222  " 5\n"
223  "410\n"
224  " 2\n"
225  "DASHDOT\n"
226  " 70\n"
227  "0\n"
228  " 3\n"
229  "Dash Dot ____ _ ____ _\n"
230  " 72\n"
231  "65\n"
232  " 73\n"
233  "4\n"
234  " 40\n"
235  "2.0\n"
236  " 49\n"
237  "1.25\n"
238  " 49\n"
239  "-0.25\n"
240  " 49\n"
241  "0.25\n"
242  " 49\n"
243  "-0.25\n"
244  " 0\n"
245  "LTYPE\n"
246  " 5\n"
247  "411\n"
248  " 2\n"
249  "DASHED\n"
250  " 70\n"
251  "0\n"
252  " 3\n"
253  "Dashed __ __ __ __ __\n"
254  " 72\n"
255  "65\n"
256  " 73\n"
257  "2\n"
258  " 40\n"
259  "0.75\n"
260  " 49\n"
261  "0.5\n"
262  " 49\n"
263  "-0.25\n"
264  " 0\n"
265  "LTYPE\n"
266  " 5\n"
267  "43B\n"
268  " 2\n"
269  "DOTTED\n"
270  " 70\n"
271  "0\n"
272  " 3\n"
273  "Dotted . . . .\n"
274  " 72\n"
275  "65\n"
276  " 73\n"
277  "2\n"
278  " 40\n"
279  "0.2\n"
280  " 49\n"
281  "0.0\n"
282  " 49\n"
283  "-0.2\n"
284  " 0\n"
285  "ENDTAB\n",
287 
288  // Text styles table
289  // Defines 4 text styles, one for each bold/italic combination
290  fputs( " 0\n"
291  "TABLE\n"
292  " 2\n"
293  "STYLE\n"
294  " 70\n"
295  "4\n", m_outputFile );
296 
297  static const char *style_name[4] = {"KICAD", "KICADB", "KICADI", "KICADBI"};
298  for(int i = 0; i < 4; i++ )
299  {
300  fprintf( m_outputFile,
301  " 0\n"
302  "STYLE\n"
303  " 2\n"
304  "%s\n" // Style name
305  " 70\n"
306  "0\n" // Standard flags
307  " 40\n"
308  "0\n" // Non-fixed height text
309  " 41\n"
310  "1\n" // Width factor (base)
311  " 42\n"
312  "1\n" // Last height (mandatory)
313  " 50\n"
314  "%g\n" // Oblique angle
315  " 71\n"
316  "0\n" // Generation flags (default)
317  " 3\n"
318  // The standard ISO font (when kicad is build with it
319  // the dxf text in acad matches *perfectly*)
320  "isocp.shx\n", // Font name (when not bigfont)
321  // Apply a 15 degree angle to italic text
322  style_name[i], i < 2 ? 0 : DXF_OBLIQUE_ANGLE );
323  }
324 
325  EDA_COLOR_T numLayers = NBCOLORS;
326 
327  // If printing in monochrome, only output the black layer
328  if( !GetColorMode() )
329  numLayers = static_cast<EDA_COLOR_T>( 1 );
330 
331  // Layer table - one layer per color
332  fprintf( m_outputFile,
333  " 0\n"
334  "ENDTAB\n"
335  " 0\n"
336  "TABLE\n"
337  " 2\n"
338  "LAYER\n"
339  " 70\n"
340  "%d\n", numLayers );
341 
342  /* The layer/colors palette. The acad/DXF palette is divided in 3 zones:
343 
344  - The primary colors (1 - 9)
345  - An HSV zone (10-250, 5 values x 2 saturations x 10 hues
346  - Greys (251 - 255)
347  */
348 
349  wxASSERT( numLayers <= NBCOLORS );
350 
351  for( EDA_COLOR_T i = BLACK; i < numLayers; i = static_cast<EDA_COLOR_T>( int( i ) + 1 ) )
352  {
353  fprintf( m_outputFile,
354  " 0\n"
355  "LAYER\n"
356  " 2\n"
357  "%s\n" // Layer name
358  " 70\n"
359  "0\n" // Standard flags
360  " 62\n"
361  "%d\n" // Color number
362  " 6\n"
363  "CONTINUOUS\n",// Linetype name
364  dxf_layer[i].name, dxf_layer[i].color );
365  }
366 
367  // End of layer table, begin entities
368  fputs( " 0\n"
369  "ENDTAB\n"
370  " 0\n"
371  "ENDSEC\n"
372  " 0\n"
373  "SECTION\n"
374  " 2\n"
375  "ENTITIES\n", m_outputFile );
376 
377  return true;
378 }
int color
Definition: DXF_plotter.cpp:57
FILE * m_outputFile
Output file.
Definition: plotter.h:590
Definition: color4d.h:44
Number of colors.
Definition: color4d.h:79
static const double DXF_OBLIQUE_ANGLE
Oblique angle for DXF native text (I don't remember if 15 degrees is the ISO value....
Definition: DXF_plotter.cpp:38
static const struct @8 dxf_layer[NBCOLORS]
EDA_COLOR_T
Legacy color enumeration.
Definition: color4d.h:41
unsigned int GetMeasurementDirective() const
Get the correct value for the $MEASUREMENT field given the current units.
Definition: plotter_dxf.h:199
const char * name
Definition: DXF_plotter.cpp:56
bool GetColorMode() const
Definition: plotter.h:153

References BLACK, color, dxf_layer, DXF_OBLIQUE_ANGLE, PLOTTER::GetColorMode(), GetMeasurementDirective(), PLOTTER::m_outputFile, name, and NBCOLORS.

Referenced by DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF().

◆ Text()

void DXF_PLOTTER::Text ( const wxPoint &  aPos,
const COLOR4D aColor,
const wxString &  aText,
double  aOrient,
const wxSize &  aSize,
enum EDA_TEXT_HJUSTIFY_T  aH_justify,
enum EDA_TEXT_VJUSTIFY_T  aV_justify,
int  aPenWidth,
bool  aItalic,
bool  aBold,
bool  aMultilineAllowed = false,
void *  aData = nullptr 
)
overridevirtual

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 in 0.1 degree.
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 (aWidth = 0).
aMultilineAlloweduse true to plot text as multiline, otherwise single line.
aDatais a parameter used by some plotters in SetCurrentLineWidth(), not directly used here.

Reimplemented from PLOTTER.

Definition at line 833 of file DXF_plotter.cpp.

845 {
846  // Fix me: see how to use DXF text mode for multiline texts
847  if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) )
848  aMultilineAllowed = false; // the text has only one line.
849 
850  bool processSuperSub = aText.Contains( wxT( "^{" ) ) || aText.Contains( wxT( "_{" ) );
851 
852  if( m_textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed || processSuperSub )
853  {
854  // output text as graphics.
855  // Perhaps multiline texts could be handled as DXF text entity
856  // but I do not want spend time about this (JPC)
857  PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
858  aWidth, aItalic, aBold, aMultilineAllowed );
859  }
860  else
861  {
862  /* Emit text as a text entity. This loses formatting and shape but it's
863  more useful as a CAD object */
864  DPOINT origin_dev = userToDeviceCoordinates( aPos );
865  SetColor( aColor );
866  wxString cname = getDXFColorName( m_currentColor );
867  DPOINT size_dev = userToDeviceSize( aSize );
868  int h_code = 0, v_code = 0;
869 
870  switch( aH_justify )
871  {
873  h_code = 0;
874  break;
876  h_code = 1;
877  break;
879  h_code = 2;
880  break;
881  }
882 
883  switch( aV_justify )
884  {
886  v_code = 3;
887  break;
889  v_code = 2;
890  break;
892  v_code = 1;
893  break;
894  }
895 
896  // Position, size, rotation and alignment
897  // The two alignment point usages is somewhat idiot (see the DXF ref)
898  // Anyway since we don't use the fit/aligned options, they're the same
899  fprintf( m_outputFile,
900  " 0\n"
901  "TEXT\n"
902  " 7\n"
903  "%s\n" // Text style
904  " 8\n"
905  "%s\n" // Layer name
906  " 10\n"
907  "%g\n" // First point X
908  " 11\n"
909  "%g\n" // Second point X
910  " 20\n"
911  "%g\n" // First point Y
912  " 21\n"
913  "%g\n" // Second point Y
914  " 40\n"
915  "%g\n" // Text height
916  " 41\n"
917  "%g\n" // Width factor
918  " 50\n"
919  "%g\n" // Rotation
920  " 51\n"
921  "%g\n" // Oblique angle
922  " 71\n"
923  "%d\n" // Mirror flags
924  " 72\n"
925  "%d\n" // H alignment
926  " 73\n"
927  "%d\n", // V alignment
928  aBold ? (aItalic ? "KICADBI" : "KICADB")
929  : (aItalic ? "KICADI" : "KICAD"),
930  TO_UTF8( cname ),
931  origin_dev.x, origin_dev.x,
932  origin_dev.y, origin_dev.y,
933  size_dev.y, fabs( size_dev.x / size_dev.y ),
934  aOrient / 10.0,
935  aItalic ? DXF_OBLIQUE_ANGLE : 0,
936  size_dev.x < 0 ? 2 : 0, // X mirror flag
937  h_code, v_code );
938 
939  /* There are two issue in emitting the text:
940  - Our overline character (~) must be converted to the appropriate
941  control sequence %%O or %%o
942  - Text encoding in DXF is more or less unspecified since depends on
943  the DXF declared version, the acad version reading it *and* some
944  system variables to be put in the header handled only by newer acads
945  Also before R15 unicode simply is not supported (you need to use
946  bigfonts which are a massive PITA). Common denominator solution:
947  use Latin1 (and however someone could choke on it, anyway). Sorry
948  for the extended latin people. If somewant want to try fixing this
949  recent version seems to use UTF-8 (and not UCS2 like the rest of
950  Windows)
951 
952  XXX Actually there is a *third* issue: older DXF formats are limited
953  to 255 bytes records (it was later raised to 2048); since I'm lazy
954  and text so long is not probable I just don't implement this rule.
955  If someone is interested in fixing this, you have to emit the first
956  partial lines with group code 3 (max 250 bytes each) and then finish
957  with a group code 1 (less than 250 bytes). The DXF refs explains it
958  in no more details...
959  */
960 
961  int braceNesting = 0;
962  int overbarDepth = -1;
963 
964  fputs( " 1\n", m_outputFile );
965 
966  for( unsigned int i = 0; i < aText.length(); i++ )
967  {
968  /* Here I do a bad thing: writing the output one byte at a time!
969  but today I'm lazy and I have no idea on how to coerce a Unicode
970  wxString to spit out latin1 encoded text ...
971 
972  At least stdio is *supposed* to do output buffering, so there is
973  hope is not too slow */
974  wchar_t ch = aText[i];
975 
976  if( ch > 255 )
977  {
978  // I can't encode this...
979  putc( '?', m_outputFile );
980  }
981  else
982  {
983  if( aText[i] == '~' && i+1 < aText.length() && aText[i+1] == '{' )
984  {
985  fputs( "%%o", m_outputFile );
986  overbarDepth = braceNesting;
987 
988  // Skip the '{'
989  i++;
990  continue;
991  }
992  else if( aText[i] == '{' )
993  {
994  braceNesting++;
995  }
996  else if( aText[i] == '}' )
997  {
998  if( braceNesting > 0 )
999  braceNesting--;
1000 
1001  if( braceNesting == overbarDepth )
1002  {
1003  fputs( "%%O", m_outputFile );
1004  overbarDepth = -1;
1005  continue;
1006  }
1007  }
1008 
1009  putc( ch, m_outputFile );
1010  }
1011  }
1012 
1013  putc( '\n', m_outputFile );
1014  }
1015 }
bool containsNonAsciiChars(const wxString &string)
Check if a given string contains non-ASCII characters.
bool m_textAsLines
Definition: plotter_dxf.h:205
FILE * m_outputFile
Output file.
Definition: plotter.h:590
static wxString getDXFColorName(const COLOR4D &aColor)
COLOR4D m_currentColor
Definition: plotter_dxf.h:206
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static const double DXF_OBLIQUE_ANGLE
Oblique angle for DXF native text (I don't remember if 15 degrees is the ISO value....
Definition: DXF_plotter.cpp:38
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify size according to the plotter scale factors (wxSize version, returns a DPOINT).
Definition: plotter.cpp:123
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:92
virtual void Text(const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=nullptr)
Draw text with the plotter.
Definition: gr_text.cpp:219
virtual void SetColor(const COLOR4D &color) override
The DXF exporter handles 'colors' as layers...

References containsNonAsciiChars(), DXF_OBLIQUE_ANGLE, getDXFColorName(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, m_currentColor, PLOTTER::m_outputFile, m_textAsLines, SetColor(), PLOTTER::Text(), TO_UTF8, PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ ThickArc()

void PLOTTER::ThickArc ( const wxPoint &  centre,
double  StAngle,
double  EndAngle,
int  rayon,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 549 of file plotter.cpp.

551 {
552  if( tracemode == FILLED )
553  {
554  Arc( centre, StAngle, EndAngle, radius, FILL_T::NO_FILL, width );
555  }
556  else
557  {
558  SetCurrentLineWidth( -1 );
559  Arc( centre, StAngle, EndAngle, radius - ( width - m_currentPenWidth ) / 2,
560  FILL_T::NO_FILL, -1 );
561  Arc( centre, StAngle, EndAngle, radius + ( width - m_currentPenWidth ) / 2,
562  FILL_T::NO_FILL, -1 );
563  }
564 }
int m_currentPenWidth
Definition: plotter.h:595
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:164
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.

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

Referenced by BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), and PlotStandardLayer().

◆ ThickCircle()

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

Reimplemented in GERBER_PLOTTER.

Definition at line 591 of file plotter.cpp.

593 {
594  if( tracemode == FILLED )
595  {
596  Circle( pos, diametre, FILL_T::NO_FILL, width );
597  }
598  else
599  {
600  SetCurrentLineWidth( -1 );
601  Circle( pos, diametre - width + m_currentPenWidth, FILL_T::NO_FILL, -1 );
602  Circle( pos, diametre + width - m_currentPenWidth, FILL_T::NO_FILL, -1 );
603  }
604 }
int m_currentPenWidth
Definition: plotter.h:595
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0

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

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

◆ ThickRect()

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

Reimplemented in GERBER_PLOTTER.

Definition at line 567 of file plotter.cpp.

569 {
570  if( tracemode == FILLED )
571  {
572  Rect( p1, p2, FILL_T::NO_FILL, width );
573  }
574  else
575  {
576  SetCurrentLineWidth( -1 );
577  wxPoint offsetp1( p1.x - (width - m_currentPenWidth) / 2,
578  p1.y - (width - m_currentPenWidth) / 2 );
579  wxPoint offsetp2( p2.x + (width - m_currentPenWidth) / 2,
580  p2.y + (width - m_currentPenWidth) / 2 );
581  Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
582  offsetp1.x += ( width - m_currentPenWidth );
583  offsetp1.y += ( width - m_currentPenWidth );
584  offsetp2.x -= ( width - m_currentPenWidth );
585  offsetp2.y -= ( width - m_currentPenWidth );
586  Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
587  }
588 }
int m_currentPenWidth
Definition: plotter.h:595
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.

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

◆ ThickSegment()

void DXF_PLOTTER::ThickSegment ( const wxPoint &  start,
const wxPoint &  end,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 592 of file DXF_plotter.cpp.

594 {
595  if( aPlotMode == SKETCH )
596  {
597  std::vector<wxPoint> cornerList;
598  SHAPE_POLY_SET outlineBuffer;
599  TransformOvalToPolygon( outlineBuffer, aStart, aEnd, aWidth, GetPlotterArcHighDef(),
600  ERROR_INSIDE );
601  const SHAPE_LINE_CHAIN& path = outlineBuffer.COutline( 0 );
602 
603  cornerList.reserve( path.PointCount() );
604 
605  for( int jj = 0; jj < path.PointCount(); jj++ )
606  cornerList.emplace_back( path.CPoint( jj ).x, path.CPoint( jj ).y );
607 
608  // Ensure the polygon is closed
609  if( cornerList[0] != cornerList[cornerList.size() - 1] )
610  cornerList.push_back( cornerList[0] );
611 
612  PlotPoly( cornerList, FILL_T::NO_FILL );
613  }
614  else
615  {
616  MoveTo( aStart );
617  FinishTo( aEnd );
618  }
619 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
DXF polygon: doesn't fill it but at least it close the filled ones DXF does not know thick outline.
Represent a set of closed polygons.
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
Represent a polyline (an zero-thickness chain of connected line segments).
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
int GetPlotterArcHighDef() const
Definition: plotter.h:228

References SHAPE_POLY_SET::COutline(), ERROR_INSIDE, PLOTTER::FinishTo(), PLOTTER::GetPlotterArcHighDef(), PLOTTER::MoveTo(), NO_FILL, path, PlotPoly(), SKETCH, and TransformOvalToPolygon().

Referenced by PlotPoly().

◆ userToDeviceCoordinates()

DPOINT PLOTTER::userToDeviceCoordinates ( const wxPoint &  aCoordinate)
protectedvirtualinherited

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

Also convert from a wxPoint to DPOINT, since some output engines needs floating point coordinates.

Definition at line 92 of file plotter.cpp.

93 {
94  wxPoint pos = aCoordinate - m_plotOffset;
95 
96  // Don't allow overflows; they can cause rendering failures in some file viewers
97  // (such as Acrobat)
98  int clampSize = MAX_PAGE_SIZE_MILS * m_IUsPerDecimil * 10 / 2;
99  pos.x = std::max( -clampSize, std::min( pos.x, clampSize ) );
100  pos.y = std::max( -clampSize, std::min( pos.y, clampSize ) );
101 
102  double x = pos.x * m_plotScale;
103  double y = ( m_paperSize.y - pos.y * m_plotScale );
104 
105  if( m_plotMirror )
106  {
108  x = ( m_paperSize.x - pos.x * m_plotScale );
109  else
110  y = pos.y * m_plotScale;
111  }
112 
113  if( m_yaxisReversed )
114  y = m_paperSize.y - y;
115 
116  x *= m_iuPerDeviceUnit;
117  y *= m_iuPerDeviceUnit;
118 
119  return DPOINT( x, y );
120 }
double m_iuPerDeviceUnit
Definition: plotter.h:581
double m_IUsPerDecimil
Definition: plotter.h:579
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:573
bool m_yaxisReversed
Definition: plotter.h:587
bool m_plotMirror
Definition: plotter.h:584
wxPoint m_plotOffset
Definition: plotter.h:583
#define MAX_PAGE_SIZE_MILS
Definition: page_info.h:41
VECTOR2< double > DPOINT
Definition: vector2d.h:628
wxSize m_paperSize
Definition: plotter.h:603
bool m_mirrorIsHorizontal
Definition: plotter.h:586

References PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_IUsPerDecimil, PLOTTER::m_mirrorIsHorizontal, PLOTTER::m_paperSize, PLOTTER::m_plotMirror, PLOTTER::m_plotOffset, PLOTTER::m_plotScale, PLOTTER::m_yaxisReversed, and MAX_PAGE_SIZE_MILS.

Referenced by Arc(), HPGL_PLOTTER::Arc(), PS_PLOTTER::Arc(), PDF_PLOTTER::Arc(), SVG_PLOTTER::Arc(), SVG_PLOTTER::BezierCurve(), HPGL_PLOTTER::Circle(), Circle(), PS_PLOTTER::Circle(), PDF_PLOTTER::Circle(), SVG_PLOTTER::Circle(), PSLIKE_PLOTTER::computeTextParameters(), GERBER_PLOTTER::FlashPadChamferRoundRect(), GERBER_PLOTTER::FlashPadCircle(), HPGL_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadCustom(), GERBER_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadRect(), GERBER_PLOTTER::FlashPadRoundRect(), GERBER_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::FlashRegularPolygon(), GERBER_PLOTTER::PenTo(), PenTo(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::plotArc(), PS_PLOTTER::PlotImage(), PDF_PLOTTER::PlotImage(), HPGL_PLOTTER::PlotPoly(), PS_PLOTTER::PlotPoly(), PDF_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), HPGL_PLOTTER::Rect(), PS_PLOTTER::Rect(), PDF_PLOTTER::Rect(), SVG_PLOTTER::Rect(), 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 130 of file plotter.cpp.

131 {
132  return size * m_plotScale * m_iuPerDeviceUnit;
133 }
double m_iuPerDeviceUnit
Definition: plotter.h:581
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:573

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

Member Data Documentation

◆ DO_NOT_SET_LINE_WIDTH

◆ m_colorMode

bool PLOTTER::m_colorMode
protectedinherited

◆ m_creator

wxString PLOTTER::m_creator
protectedinherited

◆ m_currentColor

COLOR4D DXF_PLOTTER::m_currentColor
protected

Definition at line 206 of file plotter_dxf.h.

Referenced by Arc(), Circle(), DXF_PLOTTER(), PenTo(), SetColor(), SetViewport(), and Text().

◆ m_currentLineType

PLOT_DASH_TYPE DXF_PLOTTER::m_currentLineType
protected

Definition at line 207 of file plotter_dxf.h.

Referenced by DXF_PLOTTER(), PenTo(), and SetDash().

◆ m_currentPenWidth

◆ m_filename

wxString PLOTTER::m_filename
protectedinherited

◆ m_headerExtraLines

wxArrayString PLOTTER::m_headerExtraLines
protectedinherited

◆ m_iuPerDeviceUnit

◆ m_IUsPerDecimil

◆ m_measurementDirective

unsigned int DXF_PLOTTER::m_measurementDirective
protected

Definition at line 211 of file plotter_dxf.h.

Referenced by GetMeasurementDirective(), and SetUnits().

◆ m_mirrorIsHorizontal

bool PLOTTER::m_mirrorIsHorizontal
protectedinherited

◆ m_negativeMode

bool PLOTTER::m_negativeMode
protectedinherited

Definition at line 594 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 590 of file plotter.h.

Referenced by Arc(), HPGL_PLOTTER::Arc(), PS_PLOTTER::Arc(), SVG_PLOTTER::Arc(), SVG_PLOTTER::BezierCurve(), HPGL_PLOTTER::Circle(), 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(), PS_PLOTTER::emitSetRGBColor(), SVG_PLOTTER::EndBlock(), GERBER_PLOTTER::EndPlot(), EndPlot(), HPGL_PLOTTER::EndPlot(), PS_PLOTTER::EndPlot(), PDF_PLOTTER::EndPlot(), SVG_PLOTTER::EndPlot(), FlashPadCircle(), HPGL_PLOTTER::FlashPadCircle(), PSLIKE_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadOval(), FlashPadOval(), GERBER_PLOTTER::FlashPadRect(), FlashPadRect(), GERBER_PLOTTER::FlashPadRoundRect(), FlashPadTrapez(), GERBER_PLOTTER::formatNetAttribute(), PLOTTER::OpenFile(), PDF_PLOTTER::OpenFile(), GERBER_PLOTTER::PenTo(), PenTo(), HPGL_PLOTTER::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(), HPGL_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(), GERBER_PLOTTER::StartPlot(), HPGL_PLOTTER::StartPlot(), StartPlot(), PS_PLOTTER::StartPlot(), PDF_PLOTTER::StartPlot(), SVG_PLOTTER::StartPlot(), Text(), PS_PLOTTER::Text(), SVG_PLOTTER::Text(), HPGL_PLOTTER::ThickSegment(), GERBER_PLOTTER::writeApertureList(), and PLOTTER::~PLOTTER().

◆ m_pageInfo

◆ m_paperSize

◆ m_penLastpos

wxPoint PLOTTER::m_penLastpos
protectedinherited

◆ m_penState

char PLOTTER::m_penState
protectedinherited

◆ m_plotMirror

◆ m_plotOffset

◆ m_plotScale

◆ m_plotUnits

DXF_UNITS DXF_PLOTTER::m_plotUnits
protected

Definition at line 209 of file plotter_dxf.h.

Referenced by GetUnits(), and SetUnits().

◆ m_renderSettings

◆ m_textAsLines

bool DXF_PLOTTER::m_textAsLines
protected

Definition at line 205 of file plotter_dxf.h.

Referenced by DXF_PLOTTER(), SetTextMode(), and Text().

◆ m_title

wxString PLOTTER::m_title
protectedinherited

Definition at line 601 of file plotter.h.

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

◆ m_unitScalingFactor

double DXF_PLOTTER::m_unitScalingFactor
protected

Definition at line 210 of file plotter_dxf.h.

Referenced by GetUnitScaling(), and SetUnits().

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

Referenced by PLOTTER::Marker().

◆ USE_DEFAULT_LINE_WIDTH


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