KiCad PCB EDA Suite
DXF_PLOTTER Class Reference

#include <plot_common.h>

Inheritance diagram for DXF_PLOTTER:
PLOTTER

Public Member Functions

 DXF_PLOTTER ()
 
virtual PlotFormat GetPlotterType () const override
 Returns the effective plot engine in use. More...
 
virtual void SetTextMode (PlotTextMode mode) override
 DXF handles NATIVE text emitting TEXT entities. More...
 
virtual bool StartPlot () override
 Opens the DXF plot with a skeleton header. More...
 
virtual bool EndPlot () override
 
virtual void SetCurrentLineWidth (int width, void *aData=NULL) override
 Set the line width for the next drawing. More...
 
virtual void SetDefaultLineWidth (int width) override
 Set the default line width. More...
 
virtual void SetDash (bool dashed) override
 Dashed lines are not (yet) supported by DXF_PLOTTER. More...
 
virtual void SetColor (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 The DXF engine doesn't support line widths and mirroring. 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=NULL) 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, EDA_DRAW_MODE_T 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, EDA_DRAW_MODE_T 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, EDA_DRAW_MODE_T 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, EDA_DRAW_MODE_T trace_mode, void *aData) override
 DXF rectangular pad: alwayd done in sketch mode. More...
 
virtual void FlashPadRoundRect (const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
 virtual function FlashPadRoundRect More...
 
virtual void FlashPadCustom (const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
 virtual function FlashPadCustom More...
 
virtual void FlashPadTrapez (const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
 DXF trapezoidal pad: only sketch mode is supported. 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=NULL) override
 Draws text with the plotter. More...
 
virtual void SetNegative (bool _negative)
 
virtual void SetColorMode (bool _color_mode)
 
bool GetColorMode () const
 
virtual void SetPageSettings (const PAGE_INFO &aPageSettings)
 
virtual int GetCurrentLineWidth () const
 
virtual void SetCreator (const wxString &aCreator)
 
virtual void SetTitle (const wxString &aTitle)
 
void AddLineToHeader (const wxString &aExtraString)
 Function AddLineToHeader Add a line to the list of free lines to print at the beginning of the file. More...
 
void ClearHeaderLinesList ()
 Function 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...
 
void MoveTo (const wxPoint &pos)
 
void LineTo (const wxPoint &pos)
 
void FinishTo (const wxPoint &pos)
 
void PenFinish ()
 
virtual void PlotImage (const wxImage &aImage, const wxPoint &aPos, double aScaleFactor)
 Function PlotImage Only Postscript plotters can plot bitmaps for plotters that cannot plot a bitmap, a rectangle is plotted. More...
 
virtual void ThickArc (const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, EDA_DRAW_MODE_T tracemode, void *aData)
 
virtual void ThickRect (const wxPoint &p1, const wxPoint &p2, int width, EDA_DRAW_MODE_T tracemode, void *aData)
 
virtual void ThickCircle (const wxPoint &pos, int diametre, int width, EDA_DRAW_MODE_T 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)
 Function SetLayerPolarity sets 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 StartBlock (void *aData)
 calling this function allows 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 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, EDA_DRAW_MODE_T tracemode)
 Cdonvert 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)
 Modifies coordinates according to the orientation, scale factor, and offsets trace. More...
 
virtual DPOINT userToDeviceSize (const wxSize &size)
 Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) More...
 
virtual double userToDeviceSize (double size) const
 Modifies size according to the plotter scale factors (simple double version) More...
 
double GetDashMarkLenIU () const
 
double GetDashGapLenIU () const
 

Protected Attributes

bool textAsLines
 
COLOR4D m_currentColor
 
double plotScale
 Plot scale - chosen by the user (even implicitly with 'fit in a4') More...
 
double m_IUsPerDecimil
 
double iuPerDeviceUnit
 Device scale (from IUs to plotter device units - usually decimils) More...
 
wxPoint plotOffset
 Plot offset (in IUs) More...
 
bool m_plotMirror
 X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG) More...
 
bool m_mirrorIsHorizontal
 
bool m_yaxisReversed
 true to mirror horizontally (else vertically) More...
 
FILE * outputFile
 true if the Y axis is top to bottom (SVG) More...
 
bool colorMode
 
bool negativeMode
 true to plot in color, false to plot in black and white More...
 
int defaultPenWidth
 true to generate a negative image (PS mode mainly) More...
 
int currentPenWidth
 
char penState
 Current pen state: 'U', 'D' or 'Z' (see PenTo) More...
 
wxPoint penLastpos
 Last pen positions; set to -1,-1 when the pen is at rest. More...
 
wxString creator
 
wxString filename
 
wxString title
 
PAGE_INFO pageInfo
 
wxSize paperSize
 Paper size in IU - not in mils. More...
 
wxArrayString m_headerExtraLines
 

Detailed Description

Definition at line 1206 of file plot_common.h.

Constructor & Destructor Documentation

DXF_PLOTTER::DXF_PLOTTER ( )
inline

Definition at line 1209 of file plot_common.h.

References BLACK, m_currentColor, and textAsLines.

1209  : textAsLines( false )
1210  {
1211  textAsLines = true;
1213  }
bool textAsLines
Definition: plot_common.h:1296
COLOR4D m_currentColor
Definition: plot_common.h:1297
Definition: colors.h:45

Member Function Documentation

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

Function AddLineToHeader 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 166 of file plot_common.h.

References PLOTTER::m_headerExtraLines.

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

167  {
168  m_headerExtraLines.Add( aExtraString );
169  }
wxArrayString m_headerExtraLines
Definition: plot_common.h:549
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 515 of file common_plotDXF_functions.cpp.

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

517 {
518  wxASSERT( outputFile );
519 
520  if( radius <= 0 )
521  return;
522 
523  // In DXF, arcs are drawn CCW.
524  // In Kicad, arcs are CW or CCW
525  // If StAngle > EndAngle, it is CW. So transform it to CCW
526  if( StAngle > EndAngle )
527  {
528  std::swap( StAngle, EndAngle );
529  }
530 
531  DPOINT centre_dev = userToDeviceCoordinates( centre );
532  double radius_dev = userToDeviceSize( radius );
533 
534  // Emit a DXF ARC entity
535  wxString cname = getDXFColorName( m_currentColor );
536  fprintf( outputFile,
537  "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
538  TO_UTF8( cname ),
539  centre_dev.x, centre_dev.y, radius_dev,
540  StAngle / 10.0, EndAngle / 10.0 );
541 }
static wxString getDXFColorName(COLOR4D aColor)
COLOR4D m_currentColor
Definition: plot_common.h:1297
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void DXF_PLOTTER::Circle ( const wxPoint centre,
int  diameter,
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 331 of file common_plotDXF_functions.cpp.

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

Referenced by FlashPadCircle().

332 {
333  wxASSERT( outputFile );
334  double radius = userToDeviceSize( diameter / 2 );
335  DPOINT centre_dev = userToDeviceCoordinates( centre );
336  if( radius > 0 )
337  {
338  wxString cname = getDXFColorName( m_currentColor );
339 
340  if( !fill )
341  {
342  fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
343  TO_UTF8( cname ),
344  centre_dev.x, centre_dev.y, radius );
345  }
346 
347  if( fill == FILLED_SHAPE )
348  {
349  double r = radius*0.5;
350  fprintf( outputFile, "0\nPOLYLINE\n");
351  fprintf( outputFile, "8\n%s\n66\n1\n70\n1\n", TO_UTF8( cname ));
352  fprintf( outputFile, "40\n%g\n41\n%g\n", radius, radius);
353  fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
354  fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n",
355  centre_dev.x-r, centre_dev.y );
356  fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
357  fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n",
358  centre_dev.x+r, centre_dev.y );
359  fprintf( outputFile, "0\nSEQEND\n");
360  }
361  }
362 }
static wxString getDXFColorName(COLOR4D aColor)
COLOR4D m_currentColor
Definition: plot_common.h:1297
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void PLOTTER::ClearHeaderLinesList ( )
inlineinherited

Function ClearHeaderLinesList remove all lines from the list of free lines to print at the beginning of the file.

Definition at line 175 of file plot_common.h.

References PLOTTER::m_headerExtraLines.

Referenced by StartPlotBoard().

176  {
177  m_headerExtraLines.Clear();
178  }
wxArrayString m_headerExtraLines
Definition: plot_common.h:549
virtual void PLOTTER::EndBlock ( void *  aData)
inlinevirtualinherited

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

the group is started by StartBlock()

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

Reimplemented in GERBER_PLOTTER.

Definition at line 433 of file plot_common.h.

Referenced by PlotSilkScreen(), and PlotStandardLayer().

433 {}
bool DXF_PLOTTER::EndPlot ( )
overridevirtual

Implements PLOTTER.

Definition at line 280 of file common_plotDXF_functions.cpp.

References PLOTTER::outputFile.

Referenced by DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF().

281 {
282  wxASSERT( outputFile );
283 
284  // DXF FOOTER
285  fputs( " 0\n"
286  "ENDSEC\n"
287  " 0\n"
288  "EOF\n", outputFile );
289  fclose( outputFile );
290  outputFile = NULL;
291 
292  return true;
293 }
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void PLOTTER::FinishTo ( const wxPoint pos)
inlineinherited
void DXF_PLOTTER::FlashPadCircle ( const wxPoint pos,
int  diametre,
EDA_DRAW_MODE_T  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 568 of file common_plotDXF_functions.cpp.

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

570 {
571  wxASSERT( outputFile );
572  Circle( pos, diametre, NO_FILL );
573 }
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...
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void DXF_PLOTTER::FlashPadCustom ( const wxPoint aPadPos,
const wxSize &  aSize,
SHAPE_POLY_SET aPolygons,
EDA_DRAW_MODE_T  aTraceMode,
void *  aData 
)
overridevirtual

virtual function FlashPadCustom

Parameters
aPadPosPosition of the shape (center of the rectangle
aSize= size of round reference pad
aPolygonsthe shape as polygon set
aTraceModeFILLED or SKETCH
aDataan auxiliary info (mainly for gerber format attributes)

Implements PLOTTER.

Definition at line 663 of file common_plotDXF_functions.cpp.

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

666 {
667  for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
668  {
669  SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
670 
671  MoveTo( wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
672 
673  for( int ii = 1; ii < poly.PointCount(); ++ii )
674  LineTo( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
675 
676  FinishTo(wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
677  }
678 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
int PointCount() const
Function PointCount()
int OutlineCount() const
Returns the number of outlines in the set
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
Class SHAPE_LINE_CHAIN.
VECTOR2I & Point(int aIndex)
Function Point()
void DXF_PLOTTER::FlashPadOval ( const wxPoint pos,
const wxSize &  size,
double  orient,
EDA_DRAW_MODE_T  trace_mode,
void *  aData 
)
overridevirtual

DXF oval pad: always done in sketch mode.

Implements PLOTTER.

Definition at line 546 of file common_plotDXF_functions.cpp.

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

548 {
549  wxASSERT( outputFile );
550  wxSize size( aSize );
551 
552  /* The chip is reduced to an oval tablet with size.y > size.x
553  * (Oval vertical orientation 0) */
554  if( size.x > size.y )
555  {
556  std::swap( size.x, size.y );
557  orient = AddAngles( orient, 900 );
558  }
559 
560  sketchOval( pos, size, orient, -1 );
561 }
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:246
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
void DXF_PLOTTER::FlashPadRect ( const wxPoint pos,
const wxSize &  size,
double  orient,
EDA_DRAW_MODE_T  trace_mode,
void *  aData 
)
overridevirtual

DXF rectangular pad: alwayd done in sketch mode.

Implements PLOTTER.

Definition at line 579 of file common_plotDXF_functions.cpp.

References PLOTTER::FinishTo(), PLOTTER::LineTo(), PLOTTER::MoveTo(), PLOTTER::outputFile, RotatePoint(), wxPoint::x, and wxPoint::y.

581 {
582  wxASSERT( outputFile );
583  wxSize size;
584  int ox, oy, fx, fy;
585 
586  size.x = padsize.x / 2;
587  size.y = padsize.y / 2;
588 
589  if( size.x < 0 )
590  size.x = 0;
591  if( size.y < 0 )
592  size.y = 0;
593 
594  // If a dimension is zero, the trace is reduced to 1 line
595  if( size.x == 0 )
596  {
597  ox = pos.x;
598  oy = pos.y - size.y;
599  RotatePoint( &ox, &oy, pos.x, pos.y, orient );
600  fx = pos.x;
601  fy = pos.y + size.y;
602  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
603  MoveTo( wxPoint( ox, oy ) );
604  FinishTo( wxPoint( fx, fy ) );
605  return;
606  }
607  if( size.y == 0 )
608  {
609  ox = pos.x - size.x;
610  oy = pos.y;
611  RotatePoint( &ox, &oy, pos.x, pos.y, orient );
612  fx = pos.x + size.x;
613  fy = pos.y;
614  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
615  MoveTo( wxPoint( ox, oy ) );
616  FinishTo( wxPoint( fx, fy ) );
617  return;
618  }
619 
620  ox = pos.x - size.x;
621  oy = pos.y - size.y;
622  RotatePoint( &ox, &oy, pos.x, pos.y, orient );
623  MoveTo( wxPoint( ox, oy ) );
624 
625  fx = pos.x - size.x;
626  fy = pos.y + size.y;
627  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
628  LineTo( wxPoint( fx, fy ) );
629 
630  fx = pos.x + size.x;
631  fy = pos.y + size.y;
632  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
633  LineTo( wxPoint( fx, fy ) );
634 
635  fx = pos.x + size.x;
636  fy = pos.y - size.y;
637  RotatePoint( &fx, &fy, pos.x, pos.y, orient );
638  LineTo( wxPoint( fx, fy ) );
639 
640  FinishTo( wxPoint( ox, oy ) );
641 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void DXF_PLOTTER::FlashPadRoundRect ( const wxPoint aPadPos,
const wxSize &  aSize,
int  aCornerRadius,
double  aOrient,
EDA_DRAW_MODE_T  aTraceMode,
void *  aData 
)
overridevirtual

virtual function FlashPadRoundRect

Parameters
aPadPosPosition of the shape (center of the rectangle
aSize= size of rounded rect
aCornerRadiusRadius of the rounded corners
aOrientThe rotation of the shape
aTraceModeFILLED or SKETCH
aDataan auxiliary info (mainly for gerber format attributes)

Implements PLOTTER.

Definition at line 643 of file common_plotDXF_functions.cpp.

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

646 {
647  SHAPE_POLY_SET outline;
648  const int segmentToCircleCount = 64;
649  TransformRoundRectToPolygon( outline, aPadPos, aSize, aOrient,
650  aCornerRadius, segmentToCircleCount );
651 
652  // TransformRoundRectToPolygon creates only one convex polygon
653  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
654 
655  MoveTo( wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
656 
657  for( int ii = 1; ii < poly.PointCount(); ++ii )
658  LineTo( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
659 
660  FinishTo( wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
661 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
int PointCount() const
Function PointCount()
void TransformRoundRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, int aCircleToSegmentsCount)
Function TransformRoundRectToPolygon convert a rectangle with rounded corners to a polygon Convert ar...
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
Class SHAPE_LINE_CHAIN.
VECTOR2I & Point(int aIndex)
Function Point()
void DXF_PLOTTER::FlashPadTrapez ( const wxPoint aPadPos,
const wxPoint aCorners,
double  aPadOrient,
EDA_DRAW_MODE_T  aTraceMode,
void *  aData 
)
overridevirtual

DXF trapezoidal pad: only sketch mode is supported.

Implements PLOTTER.

Definition at line 684 of file common_plotDXF_functions.cpp.

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

686 {
687  wxASSERT( outputFile );
688  wxPoint coord[4]; /* coord actual corners of a trapezoidal trace */
689 
690  for( int ii = 0; ii < 4; ii++ )
691  {
692  coord[ii] = aCorners[ii];
693  RotatePoint( &coord[ii], aPadOrient );
694  coord[ii] += aPadPos;
695  }
696 
697  // Plot edge:
698  MoveTo( coord[0] );
699  LineTo( coord[1] );
700  LineTo( coord[2] );
701  LineTo( coord[3] );
702  FinishTo( coord[0] );
703 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
bool PLOTTER::GetColorMode ( ) const
inlineinherited

Definition at line 121 of file plot_common.h.

References PLOTTER::colorMode.

Referenced by PLOT_CONTROLLER::GetColorMode(), LIB_TEXT::Plot(), LIB_PART::Plot(), LIB_PART::PlotLibFields(), and PlotWorkSheet().

122  {
123  return colorMode;
124  }
bool colorMode
Definition: plot_common.h:534
double PLOTTER::GetDashGapLenIU ( ) const
protectedinherited

Definition at line 141 of file class_plotter.cpp.

References PLOTTER::GetCurrentLineWidth(), PLOTTER::m_dashGapLength_mm, PLOTTER::m_IUsPerDecimil, and PLOTTER::userToDeviceSize().

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

142 {
144 }
double m_IUsPerDecimil
Definition: plot_common.h:516
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
double m_dashGapLength_mm
Dashed line parameter in mm: gap.
Definition: plot_common.h:90
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
double PLOTTER::GetDashMarkLenIU ( ) const
protectedinherited

Definition at line 134 of file class_plotter.cpp.

References PLOTTER::GetCurrentLineWidth(), PLOTTER::m_dashMarkLength_mm, PLOTTER::m_IUsPerDecimil, and PLOTTER::userToDeviceSize().

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

135 {
137  return ( mark < 0.0 ) ? 0.0 : mark;
138 }
double m_IUsPerDecimil
Definition: plot_common.h:516
double m_dashMarkLength_mm
Dashed line parameter in mm: segment.
Definition: plot_common.h:89
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
static wxString DXF_PLOTTER::GetDefaultFileExtension ( )
inlinestatic

Definition at line 1220 of file plot_common.h.

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

1221  {
1222  return wxString( wxT( "dxf" ) );
1223  }
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 207 of file plot_common.h.

References PLOTTER::m_IUsPerDecimil.

Referenced by PlotWorkSheet().

207 { return m_IUsPerDecimil; }
double m_IUsPerDecimil
Definition: plot_common.h:516
virtual PlotFormat 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 1215 of file plot_common.h.

References PLOT_FORMAT_DXF.

1216  {
1217  return PLOT_FORMAT_DXF;
1218  }
void PLOTTER::LineTo ( const wxPoint pos)
inlineinherited

Definition at line 236 of file plot_common.h.

References PLOTTER::PenTo().

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

237  {
238  PenTo( pos, 'D' );
239  }
virtual void PenTo(const wxPoint &pos, char plume)=0
moveto/lineto primitive, moves the 'pen' to the specified direction
void PLOTTER::Marker ( const wxPoint position,
int  diametre,
unsigned  aShapeId 
)
inherited

Draw a pattern shape number aShapeId, to coord position.

Diameter diameter = (coord table) hole AShapeId = index (used to generate forms characters)

Definition at line 273 of file class_plotter.cpp.

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

274 {
275  int radius = diametre / 2;
276  /* Marker are composed by a series of 'parts' superimposed; not every
277  combination make sense, obviously. Since they are used in order I
278  tried to keep the uglier/more complex constructions at the end.
279  Also I avoided the |/ |\ -/ -\ construction because they're *very*
280  ugly... if needed they could be added anyway... I'd like to see
281  a board with more than 58 drilling/slotting tools!
282  If Visual C++ supported the 0b literals they would be optimally
283  and easily encoded as an integer array. We have to do with octal */
284  static const unsigned char marker_patterns[MARKER_COUNT] = {
285  // Bit order: O Square Lozenge - | \ /
286  // First choice: simple shapes
287  0003, // X
288  0100, // O
289  0014, // +
290  0040, // Sq
291  0020, // Lz
292  // Two simple shapes
293  0103, // X O
294  0017, // X +
295  0043, // X Sq
296  0023, // X Lz
297  0114, // O +
298  0140, // O Sq
299  0120, // O Lz
300  0054, // + Sq
301  0034, // + Lz
302  0060, // Sq Lz
303  // Three simple shapes
304  0117, // X O +
305  0143, // X O Sq
306  0123, // X O Lz
307  0057, // X + Sq
308  0037, // X + Lz
309  0063, // X Sq Lz
310  0154, // O + Sq
311  0134, // O + Lz
312  0074, // + Sq Lz
313  // Four simple shapes
314  0174, // O Sq Lz +
315  0163, // X O Sq Lz
316  0157, // X O Sq +
317  0137, // X O Lz +
318  0077, // X Sq Lz +
319  // This draws *everything *
320  0177, // X O Sq Lz +
321  // Here we use the single bars... so the cross is forbidden
322  0110, // O -
323  0104, // O |
324  0101, // O /
325  0050, // Sq -
326  0044, // Sq |
327  0041, // Sq /
328  0030, // Lz -
329  0024, // Lz |
330  0021, // Lz /
331  0150, // O Sq -
332  0144, // O Sq |
333  0141, // O Sq /
334  0130, // O Lz -
335  0124, // O Lz |
336  0121, // O Lz /
337  0070, // Sq Lz -
338  0064, // Sq Lz |
339  0061, // Sq Lz /
340  0170, // O Sq Lz -
341  0164, // O Sq Lz |
342  0161, // O Sq Lz /
343  // Last resort: the backlash component (easy to confound)
344  0102, // \ O
345  0042, // \ Sq
346  0022, // \ Lz
347  0142, // \ O Sq
348  0122, // \ O Lz
349  0062, // \ Sq Lz
350  0162 // \ O Sq Lz
351  };
352  if( aShapeId >= MARKER_COUNT )
353  {
354  // Fallback shape
355  markerCircle( position, radius );
356  }
357  else
358  {
359  // Decode the pattern and draw the corresponding parts
360  unsigned char pat = marker_patterns[aShapeId];
361  if( pat & 0001 )
362  markerSlash( position, radius );
363  if( pat & 0002 )
364  markerBackSlash( position, radius );
365  if( pat & 0004 )
366  markerVBar( position, radius );
367  if( pat & 0010 )
368  markerHBar( position, radius );
369  if( pat & 0020 )
370  markerLozenge( position, radius );
371  if( pat & 0040 )
372  markerSquare( position, radius );
373  if( pat & 0100 )
374  markerCircle( position, radius );
375  }
376 }
void markerHBar(const wxPoint &pos, int radius)
Plot a - bar centered on the position.
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map)
Definition: plot_common.h:380
void markerSlash(const wxPoint &pos, int radius)
Plot a / bar centered on the position.
void markerLozenge(const wxPoint &position, int radius)
Plot a lozenge centered on the position.
void markerCircle(const wxPoint &pos, int radius)
Plot a circle centered on the position.
void markerVBar(const wxPoint &pos, int radius)
Plot a | bar centered on the position.
void markerSquare(const wxPoint &position, int radius)
Plot a square centered on the position.
void markerBackSlash(const wxPoint &pos, int radius)
Plot a \ bar centered on the position.
void PLOTTER::markerBackSlash ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a \ bar centered on the position.

Building block for markers

Definition at line 259 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

260 {
261  MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
262  FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
263 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
void PLOTTER::markerCircle ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a circle centered on the position.

Building block for markers

Definition at line 215 of file class_plotter.cpp.

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

Referenced by PLOTTER::Marker().

216 {
217  Circle( position, radius * 2, NO_FILL, GetCurrentLineWidth() );
218 }
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void PLOTTER::markerHBar ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a - bar centered on the position.

Building block for markers

Definition at line 245 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

246 {
247  MoveTo( wxPoint( pos.x - radius, pos.y ) );
248  FinishTo( wxPoint( pos.x + radius, pos.y ) );
249 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
void PLOTTER::markerLozenge ( const wxPoint position,
int  radius 
)
protectedinherited

Plot a lozenge centered on the position.

Building block for markers

Definition at line 221 of file class_plotter.cpp.

References PLOTTER::GetCurrentLineWidth(), NO_FILL, PLOTTER::PlotPoly(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

222 {
223  std::vector< wxPoint > corner_list;
224  wxPoint corner;
225  corner.x = position.x;
226  corner.y = position.y + radius;
227  corner_list.push_back( corner );
228  corner.x = position.x + radius;
229  corner.y = position.y,
230  corner_list.push_back( corner );
231  corner.x = position.x;
232  corner.y = position.y - radius;
233  corner_list.push_back( corner );
234  corner.x = position.x - radius;
235  corner.y = position.y;
236  corner_list.push_back( corner );
237  corner.x = position.x;
238  corner.y = position.y + radius;
239  corner_list.push_back( corner );
240 
241  PlotPoly( corner_list, NO_FILL, GetCurrentLineWidth() );
242 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
void PLOTTER::markerSlash ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a / bar centered on the position.

Building block for markers

Definition at line 252 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

253 {
254  MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
255  FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
256 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
void PLOTTER::markerSquare ( const wxPoint position,
int  radius 
)
protectedinherited

Plot a square centered on the position.

Building block for markers

Definition at line 190 of file class_plotter.cpp.

References PLOTTER::GetCurrentLineWidth(), KiROUND(), NO_FILL, PLOTTER::PlotPoly(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

191 {
192  double r = KiROUND( radius / 1.4142 );
193  std::vector< wxPoint > corner_list;
194  wxPoint corner;
195  corner.x = position.x + r;
196  corner.y = position.y + r;
197  corner_list.push_back( corner );
198  corner.x = position.x + r;
199  corner.y = position.y - r;
200  corner_list.push_back( corner );
201  corner.x = position.x - r;
202  corner.y = position.y - r;
203  corner_list.push_back( corner );
204  corner.x = position.x - r;
205  corner.y = position.y + r;
206  corner_list.push_back( corner );
207  corner.x = position.x + r;
208  corner.y = position.y + r;
209  corner_list.push_back( corner );
210 
211  PlotPoly( corner_list, NO_FILL, GetCurrentLineWidth() );
212 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
void PLOTTER::markerVBar ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a | bar centered on the position.

Building block for markers

Definition at line 266 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

267 {
268  MoveTo( wxPoint( pos.x, pos.y - radius ) );
269  FinishTo( wxPoint( pos.x, pos.y + radius ) );
270 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
bool PLOTTER::OpenFile ( const wxString &  aFullFilename)
virtualinherited

Open or create the plot file aFullFilename.

Parameters
aFullFilename= 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 79 of file class_plotter.cpp.

References PLOTTER::filename, and PLOTTER::outputFile.

Referenced by GERBER_WRITER::createDrillFile(), GENDRILL_WRITER_BASE::genDrillMapFile(), DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL(), DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPS(), DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG(), StartPlotBoard(), and LIB_EDIT_FRAME::SVG_PlotComponent().

80 {
81  filename = aFullFilename;
82 
83  wxASSERT( !outputFile );
84 
85  // Open the file in text mode (not suitable for all plotters
86  // but only for most of them
87  outputFile = wxFopen( filename, wxT( "wt" ) );
88 
89  if( outputFile == NULL )
90  return false ;
91 
92  return true;
93 }
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
wxString filename
Definition: plot_common.h:543
void PLOTTER::PenFinish ( )
inlineinherited

Definition at line 247 of file plot_common.h.

References PLOTTER::PenTo().

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

248  {
249  // The point is not important with Z motion
250  PenTo( wxPoint( 0, 0 ), 'Z' );
251  }
virtual void PenTo(const wxPoint &pos, char plume)=0
moveto/lineto primitive, moves the 'pen' to the specified direction
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 474 of file common_plotDXF_functions.cpp.

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

475 {
476  wxASSERT( outputFile );
477  if( plume == 'Z' )
478  {
479  return;
480  }
481  DPOINT pos_dev = userToDeviceCoordinates( pos );
482  DPOINT pen_lastpos_dev = userToDeviceCoordinates( penLastpos );
483 
484  if( penLastpos != pos && plume == 'D' )
485  {
486  // DXF LINE
487  wxString cname = getDXFColorName( m_currentColor );
488  fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
489  TO_UTF8( cname ),
490  pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
491  }
492  penLastpos = pos;
493 }
static wxString getDXFColorName(COLOR4D aColor)
COLOR4D m_currentColor
Definition: plot_common.h:1297
wxPoint penLastpos
Last pen positions; set to -1,-1 when the pen is at rest.
Definition: plot_common.h:541
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void PLOTTER::PlotImage ( const wxImage &  aImage,
const wxPoint aPos,
double  aScaleFactor 
)
virtualinherited

Function PlotImage Only Postscript plotters can plot bitmaps for plotters that cannot plot a bitmap, a rectangle is plotted.

Draw an image bitmap

Parameters
aImage= the bitmap
aPos= position of the center of the bitmap
aScaleFactor= 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 173 of file class_plotter.cpp.

References NO_FILL, PLOTTER::Rect(), wxPoint::x, and wxPoint::y.

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

174 {
175  wxSize size( aImage.GetWidth() * aScaleFactor,
176  aImage.GetHeight() * aScaleFactor );
177 
178  wxPoint start = aPos;
179  start.x -= size.x / 2;
180  start.y -= size.y / 2;
181 
182  wxPoint end = start;
183  end.x += size.x;
184  end.y += size.y;
185 
186  Rect( start, end, NO_FILL );
187 }
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void DXF_PLOTTER::PlotPoly ( const std::vector< wxPoint > &  aCornerList,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH,
void *  aData = NULL 
)
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 thhick segments, therefore filled polygons with thick outline are converted to inflated polygon by aWidth/2

Implements PLOTTER.

Definition at line 371 of file common_plotDXF_functions.cpp.

References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BooleanAdd(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), FILLED, SHAPE_POLY_SET::Fracture(), PLOTTER::LineTo(), PLOTTER::MoveTo(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), PLOTTER::PenFinish(), SHAPE_POLY_SET::PM_FAST, SHAPE_LINE_CHAIN::PointCount(), ThickSegment(), TransformRoundedEndsSegmentToPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

373 {
374  if( aCornerList.size() <= 1 )
375  return;
376 
377  unsigned last = aCornerList.size() - 1;
378 
379  // Plot outlines with lines (thickness = 0) to define the polygon
380  if( aWidth <= 0 )
381  {
382  MoveTo( aCornerList[0] );
383 
384  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
385  LineTo( aCornerList[ii] );
386 
387  // Close polygon if 'fill' requested
388  if( aFill )
389  {
390  if( aCornerList[last] != aCornerList[0] )
391  LineTo( aCornerList[0] );
392  }
393 
394  PenFinish();
395 
396  return;
397  }
398 
399 
400  // if the polygon outline has thickness, and is not filled
401  // (i.e. is a polyline) plot outlines with thick segments
402  if( aWidth > 0 && !aFill )
403  {
404  MoveTo( aCornerList[0] );
405 
406  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
407  ThickSegment( aCornerList[ii-1], aCornerList[ii],
408  aWidth, FILLED, NULL );
409 
410  return;
411  }
412 
413  // The polygon outline has thickness, and is filled
414  // Build and plot the polygon which contains the initial
415  // polygon and its thick outline
416  SHAPE_POLY_SET bufferOutline;
417  SHAPE_POLY_SET bufferPolybase;
418  const int circleToSegmentsCount = 16;
419 
420  bufferPolybase.NewOutline();
421 
422  // enter outline as polygon:
423  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
424  {
426  aCornerList[ii-1], aCornerList[ii], circleToSegmentsCount, aWidth );
427  }
428 
429  // enter the initial polygon:
430  for( unsigned ii = 0; ii < aCornerList.size(); ii++ )
431  {
432  bufferPolybase.Append( aCornerList[ii] );
433  }
434 
435  // Merge polygons to build the polygon which contains the initial
436  // polygon and its thick outline
437 
438  // create the outline which contains thick outline:
439  bufferPolybase.BooleanAdd( bufferOutline, SHAPE_POLY_SET::PM_FAST );
440  bufferPolybase.Fracture( SHAPE_POLY_SET::PM_FAST );
441 
442  if( bufferPolybase.OutlineCount() < 1 ) // should not happen
443  return;
444 
445  const SHAPE_LINE_CHAIN& path = bufferPolybase.COutline( 0 );
446 
447  if( path.PointCount() < 2 ) // should not happen
448  return;
449 
450  // Now, output the final polygon to DXF file:
451  last = path.PointCount() - 1;
452  VECTOR2I point = path.CPoint( 0 );
453 
454  wxPoint startPoint( point.x, point.y );
455  MoveTo( startPoint );
456 
457  for( int ii = 1; ii < path.PointCount(); ii++ )
458  {
459  point = path.CPoint( ii );
460  LineTo( wxPoint( point.x, point.y ) );
461  }
462 
463  // Close polygon, if needed
464  point = path.CPoint( last );
465  wxPoint endPoint( point.x, point.y );
466 
467  if( endPoint != startPoint )
468  LineTo( startPoint );
469 
470  PenFinish();
471 }
void TransformRoundedEndsSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aCircleToSegmentsCount, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
void PenFinish()
Definition: plot_common.h:247
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset union For aFastMode meaning, see function booleanOp
int PointCount() const
Function PointCount()
int OutlineCount() const
Returns the number of outlines in the set
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
Class SHAPE_POLY_SET.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
int NewOutline()
Creates a new empty polygon in the set and returns its index
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
Class SHAPE_LINE_CHAIN.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
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 314 of file common_plotDXF_functions.cpp.

References PLOTTER::FinishTo(), PLOTTER::LineTo(), PLOTTER::MoveTo(), PLOTTER::outputFile, wxPoint::x, and wxPoint::y.

315 {
316  wxASSERT( outputFile );
317  MoveTo( p1 );
318  LineTo( wxPoint( p1.x, p2.y ) );
319  LineTo( wxPoint( p2.x, p2.y ) );
320  LineTo( wxPoint( p2.x, p1.y ) );
321  FinishTo( wxPoint( p1.x, p1.y ) );
322 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
void PLOTTER::segmentAsOval ( const wxPoint start,
const wxPoint end,
int  width,
EDA_DRAW_MODE_T  tracemode 
)
protectedinherited

Cdonvert a thick segment and plot it as an oval.

Definition at line 379 of file class_plotter.cpp.

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

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

381 {
382  wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
383  wxSize size( end.x - start.x, end.y - start.y );
384  double orient;
385 
386  if( size.y == 0 )
387  orient = 0;
388  else if( size.x == 0 )
389  orient = 900;
390  else
391  orient = -ArcTangente( size.y, size.x );
392 
393  size.x = KiROUND( EuclideanNorm( size ) ) + width;
394  size.y = width;
395 
396  FlashPadOval( center, size, orient, tracemode, NULL );
397 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:104
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:271
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadOval
void DXF_PLOTTER::SetColor ( COLOR4D  color)
overridevirtual

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

Implements PLOTTER.

Definition at line 299 of file common_plotDXF_functions.cpp.

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

Referenced by Text().

300 {
301  if( ( colorMode )
302  || ( color == COLOR4D::BLACK )
303  || ( color == COLOR4D::WHITE ) )
304  {
306  }
307  else
309 }
bool colorMode
Definition: plot_common.h:534
COLOR4D m_currentColor
Definition: plot_common.h:1297
Definition: colors.h:49
Definition: colors.h:45
virtual void DXF_PLOTTER::SetCurrentLineWidth ( int  width,
void *  aData = NULL 
)
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 1238 of file plot_common.h.

References PLOTTER::currentPenWidth.

1239  {
1240  currentPenWidth = 0;
1241  }
int currentPenWidth
Definition: plot_common.h:537
void DXF_PLOTTER::SetDash ( bool  dashed)
overridevirtual

Dashed lines are not (yet) supported by DXF_PLOTTER.

Implements PLOTTER.

Definition at line 499 of file common_plotDXF_functions.cpp.

500 {
501  // NOP for now
502 }
virtual void DXF_PLOTTER::SetDefaultLineWidth ( int  width)
inlineoverridevirtual

Set the default line width.

Used at the beginning and when a width of -1 (USE_DEFAULT_LINE_WIDTH) is requested.

Parameters
widthis specified in IUs

Implements PLOTTER.

Definition at line 1243 of file plot_common.h.

References PLOTTER::defaultPenWidth.

Referenced by SetViewport().

1244  {
1245  // DXF lines are infinitesimal
1246  defaultPenWidth = 0;
1247  }
int defaultPenWidth
true to generate a negative image (PS mode mainly)
Definition: plot_common.h:536
virtual void PLOTTER::SetGerberCoordinatesFormat ( int  aResolution,
bool  aUseInches = false 
)
inlinevirtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 412 of file plot_common.h.

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

413  {
414  // NOP for most plotters. Only for Gerber plotter
415  }
virtual void PLOTTER::SetLayerPolarity ( bool  aPositive)
inlinevirtualinherited

Function SetLayerPolarity sets 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 398 of file plot_common.h.

Referenced by PlotOneBoardLayer().

399  {
400  // NOP for most plotters
401  }
virtual void PLOTTER::SetNegative ( bool  _negative)
inlinevirtualinherited

Definition at line 111 of file plot_common.h.

References PLOTTER::negativeMode.

Referenced by FillNegativeKnockout().

112  {
113  negativeMode = _negative;
114  }
bool negativeMode
true to plot in color, false to plot in black and white
Definition: plot_common.h:535
virtual void DXF_PLOTTER::SetTextMode ( PlotTextMode  mode)
inlineoverridevirtual

DXF handles NATIVE text emitting TEXT entities.

Reimplemented from PLOTTER.

Definition at line 1228 of file plot_common.h.

References PLOTTEXTMODE_DEFAULT, PLOTTEXTMODE_NATIVE, and textAsLines.

1229  {
1230  if( mode != PLOTTEXTMODE_DEFAULT )
1231  textAsLines = ( mode != PLOTTEXTMODE_NATIVE );
1232  }
bool textAsLines
Definition: plot_common.h:1296
virtual void PLOTTER::SetTitle ( const wxString &  aTitle)
inlinevirtualinherited

Definition at line 156 of file plot_common.h.

References PLOTTER::title.

Referenced by DIALOG_PLOT_SCHEMATIC::createPDFFile().

157  {
158  title = aTitle;
159  }
wxString title
Definition: plot_common.h:544
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 114 of file common_plotDXF_functions.cpp.

References BLACK, PLOTTER::iuPerDeviceUnit, m_currentColor, PLOTTER::m_IUsPerDecimil, PLOTTER::m_plotMirror, PLOTTER::paperSize, PLOTTER::plotOffset, PLOTTER::plotScale, and SetDefaultLineWidth().

Referenced by DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF().

116 {
117  plotOffset = aOffset;
118  plotScale = aScale;
119 
120  /* DXF paper is 'virtual' so there is no need of a paper size.
121  Also this way we can handle the aux origin which can be useful
122  (for example when aligning to a mechanical drawing) */
123  paperSize.x = 0;
124  paperSize.y = 0;
125 
126  /* Like paper size DXF units are abstract too. Anyway there is a
127  * system variable (MEASUREMENT) which will be set to 1 to indicate
128  * metric units */
129  m_IUsPerDecimil = aIusPerDecimil;
130  iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils
131  iuPerDeviceUnit *= 0.00254; // ... now in mm
132 
133  SetDefaultLineWidth( 0 ); // No line width on DXF
134  m_plotMirror = false; // No mirroring on DXF
136 }
COLOR4D m_currentColor
Definition: plot_common.h:1297
double m_IUsPerDecimil
Definition: plot_common.h:516
wxPoint plotOffset
Plot offset (in IUs)
Definition: plot_common.h:522
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plot_common.h:526
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:510
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
Definition: plot_common.h:1243
Definition: colors.h:45
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:519
wxSize paperSize
Paper size in IU - not in mils.
Definition: plot_common.h:547
void PLOTTER::sketchOval ( const wxPoint pos,
const wxSize &  size,
double  orient,
int  width 
)
protectedinherited

Definition at line 400 of file class_plotter.cpp.

References AddAngles(), PLOTTER::Arc(), PLOTTER::currentPenWidth, PLOTTER::FinishTo(), PLOTTER::MoveTo(), NO_FILL, RotatePoint(), PLOTTER::SetCurrentLineWidth(), wxPoint::x, and wxPoint::y.

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

401 {
402  SetCurrentLineWidth( width );
403  width = currentPenWidth;
404  int radius, deltaxy, cx, cy;
405  wxSize size( aSize );
406 
407  if( size.x > size.y )
408  {
409  std::swap( size.x, size.y );
410  orient = AddAngles( orient, 900 );
411  }
412 
413  deltaxy = size.y - size.x; /* distance between centers of the oval */
414  radius = ( size.x - width ) / 2;
415  cx = -radius;
416  cy = -deltaxy / 2;
417  RotatePoint( &cx, &cy, orient );
418  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
419  cx = -radius;
420  cy = deltaxy / 2;
421  RotatePoint( &cx, &cy, orient );
422  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
423 
424  cx = radius;
425  cy = -deltaxy / 2;
426  RotatePoint( &cx, &cy, orient );
427  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
428  cx = radius;
429  cy = deltaxy / 2;
430  RotatePoint( &cx, &cy, orient );
431  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
432 
433  cx = 0;
434  cy = deltaxy / 2;
435  RotatePoint( &cx, &cy, orient );
436  Arc( wxPoint( cx + pos.x, cy + pos.y ),
437  orient + 1800, orient + 3600,
438  radius, NO_FILL );
439  cx = 0;
440  cy = -deltaxy / 2;
441  RotatePoint( &cx, &cy, orient );
442  Arc( wxPoint( cx + pos.x, cy + pos.y ),
443  orient, orient + 1800,
444  radius, NO_FILL );
445 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:246
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
int currentPenWidth
Definition: plot_common.h:537
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.
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
virtual void PLOTTER::StartBlock ( void *  aData)
inlinevirtualinherited

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

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

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

Reimplemented in GERBER_PLOTTER.

Definition at line 424 of file plot_common.h.

Referenced by PlotSilkScreen(), and PlotStandardLayer().

424 {}
bool DXF_PLOTTER::StartPlot ( )
overridevirtual

Opens the DXF plot with a skeleton header.

Implements PLOTTER.

Definition at line 141 of file common_plotDXF_functions.cpp.

References BLACK, color, dxf_layer, DXF_OBLIQUE_ANGLE, name, NBCOLORS, NextColor(), and PLOTTER::outputFile.

Referenced by DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF().

142 {
143  wxASSERT( outputFile );
144 
145  // DXF HEADER - Boilerplate
146  // Defines the minimum for drawing i.e. the angle system and the
147  // continuous linetype
148  fputs( " 0\n"
149  "SECTION\n"
150  " 2\n"
151  "HEADER\n"
152  " 9\n"
153  "$ANGBASE\n"
154  " 50\n"
155  "0.0\n"
156  " 9\n"
157  "$ANGDIR\n"
158  " 70\n"
159  " 1\n"
160  " 9\n"
161  "$MEASUREMENT\n"
162  " 70\n"
163  "0\n"
164  " 0\n" // This means 'metric units'
165  "ENDSEC\n"
166  " 0\n"
167  "SECTION\n"
168  " 2\n"
169  "TABLES\n"
170  " 0\n"
171  "TABLE\n"
172  " 2\n"
173  "LTYPE\n"
174  " 70\n"
175  "1\n"
176  " 0\n"
177  "LTYPE\n"
178  " 2\n"
179  "CONTINUOUS\n"
180  " 70\n"
181  "0\n"
182  " 3\n"
183  "Solid line\n"
184  " 72\n"
185  "65\n"
186  " 73\n"
187  "0\n"
188  " 40\n"
189  "0.0\n"
190  " 0\n"
191  "ENDTAB\n",
192  outputFile );
193 
194  // Text styles table
195  // Defines 4 text styles, one for each bold/italic combination
196  fputs( " 0\n"
197  "TABLE\n"
198  " 2\n"
199  "STYLE\n"
200  " 70\n"
201  "4\n", outputFile );
202 
203  static const char *style_name[4] = {"KICAD", "KICADB", "KICADI", "KICADBI"};
204  for(int i = 0; i < 4; i++ )
205  {
206  fprintf( outputFile,
207  " 0\n"
208  "STYLE\n"
209  " 2\n"
210  "%s\n" // Style name
211  " 70\n"
212  "0\n" // Standard flags
213  " 40\n"
214  "0\n" // Non-fixed height text
215  " 41\n"
216  "1\n" // Width factor (base)
217  " 42\n"
218  "1\n" // Last height (mandatory)
219  " 50\n"
220  "%g\n" // Oblique angle
221  " 71\n"
222  "0\n" // Generation flags (default)
223  " 3\n"
224  // The standard ISO font (when kicad is build with it
225  // the dxf text in acad matches *perfectly*)
226  "isocp.shx\n", // Font name (when not bigfont)
227  // Apply a 15 degree angle to italic text
228  style_name[i], i < 2 ? 0 : DXF_OBLIQUE_ANGLE );
229  }
230 
231 
232  // Layer table - one layer per color
233  fprintf( outputFile,
234  " 0\n"
235  "ENDTAB\n"
236  " 0\n"
237  "TABLE\n"
238  " 2\n"
239  "LAYER\n"
240  " 70\n"
241  "%d\n", NBCOLORS );
242 
243  /* The layer/colors palette. The acad/DXF palette is divided in 3 zones:
244 
245  - The primary colors (1 - 9)
246  - An HSV zone (10-250, 5 values x 2 saturations x 10 hues
247  - Greys (251 - 255)
248  */
249 
250  for( EDA_COLOR_T i = BLACK; i < NBCOLORS; i = NextColor(i) )
251  {
252  fprintf( outputFile,
253  " 0\n"
254  "LAYER\n"
255  " 2\n"
256  "%s\n" // Layer name
257  " 70\n"
258  "0\n" // Standard flags
259  " 62\n"
260  "%d\n" // Color number
261  " 6\n"
262  "CONTINUOUS\n",// Linetype name
263  dxf_layer[i].name, dxf_layer[i].color );
264  }
265 
266  // End of layer table, begin entities
267  fputs( " 0\n"
268  "ENDTAB\n"
269  " 0\n"
270  "ENDSEC\n"
271  " 0\n"
272  "SECTION\n"
273  " 2\n"
274  "ENTITIES\n", outputFile );
275 
276  return true;
277 }
EDA_COLOR_T
NOTE: EDA_COLOR_T is deprecated and is kept around for compatibility with legacy canvas.
Definition: colors.h:42
static const double DXF_OBLIQUE_ANGLE
Oblique angle for DXF native text (I don't remember if 15 degrees is the ISO value...
static const struct @36 dxf_layer[NBCOLORS]
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
const char * name
Definition: colors.h:45
Number of colors.
Definition: colors.h:75
EDA_COLOR_T NextColor(EDA_COLOR_T &aColor)
Definition: colors.h:87
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  aWidth,
bool  aItalic,
bool  aBold,
bool  aMultilineAllowed = false,
void *  aData = NULL 
)
overridevirtual

Draws text with the plotter.

Function PLOTTER::Text same as DrawGraphicText, but plot graphic text insteed of draw it.

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

Parameters
aPos= text position (according to aH_justify, aV_justify)
aColor(COLOR4D) = text color
aText= text to draw
aOrient= angle in 0.1 degree
aSize= text size (size.x or size.y can be < 0 for mirrored texts)
aH_justify= horizontal justification (Left, center, right)
aV_justify= vertical justification (bottom, center, top)
aWidth= line width (pen width) (default = 0) if width < 0 : draw segments in sketch mode, width = abs(width) Use a value min(aSize.x, aSize.y) / 5 for a bold text
aItalic= true to simulate an italic font
aBold= true to use a bold font Useful only with default width value (aWidth = 0)
aMultilineAllowed= true to plot text as multiline, otherwise single line
aData= a parameter used by some plotters in SetCurrentLineWidth(), not directly used here.

Reimplemented from PLOTTER.

Definition at line 724 of file common_plotDXF_functions.cpp.

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::outputFile, SetColor(), PLOTTER::Text(), textAsLines, TO_UTF8, PLOTTER::userToDeviceCoordinates(), PLOTTER::userToDeviceSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

736 {
737  // Fix me: see how to use DXF text mode for multiline texts
738  if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) )
739  aMultilineAllowed = false; // the text has only one line.
740 
741  if( textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed )
742  {
743  // output text as graphics.
744  // Perhaps multiline texts could be handled as DXF text entity
745  // but I do not want spend time about this (JPC)
746  PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
747  aWidth, aItalic, aBold, aMultilineAllowed );
748  }
749  else
750  {
751  /* Emit text as a text entity. This loses formatting and shape but it's
752  more useful as a CAD object */
753  DPOINT origin_dev = userToDeviceCoordinates( aPos );
754  SetColor( aColor );
755  wxString cname = getDXFColorName( m_currentColor );
756  DPOINT size_dev = userToDeviceSize( aSize );
757  int h_code = 0, v_code = 0;
758  switch( aH_justify )
759  {
761  h_code = 0;
762  break;
764  h_code = 1;
765  break;
767  h_code = 2;
768  break;
769  }
770  switch( aV_justify )
771  {
773  v_code = 3;
774  break;
776  v_code = 2;
777  break;
779  v_code = 1;
780  break;
781  }
782 
783  // Position, size, rotation and alignment
784  // The two alignment point usages is somewhat idiot (see the DXF ref)
785  // Anyway since we don't use the fit/aligned options, they're the same
786  fprintf( outputFile,
787  " 0\n"
788  "TEXT\n"
789  " 7\n"
790  "%s\n" // Text style
791  " 8\n"
792  "%s\n" // Layer name
793  " 10\n"
794  "%g\n" // First point X
795  " 11\n"
796  "%g\n" // Second point X
797  " 20\n"
798  "%g\n" // First point Y
799  " 21\n"
800  "%g\n" // Second point Y
801  " 40\n"
802  "%g\n" // Text height
803  " 41\n"
804  "%g\n" // Width factor
805  " 50\n"
806  "%g\n" // Rotation
807  " 51\n"
808  "%g\n" // Oblique angle
809  " 71\n"
810  "%d\n" // Mirror flags
811  " 72\n"
812  "%d\n" // H alignment
813  " 73\n"
814  "%d\n", // V alignment
815  aBold ? (aItalic ? "KICADBI" : "KICADB")
816  : (aItalic ? "KICADI" : "KICAD"),
817  TO_UTF8( cname ),
818  origin_dev.x, origin_dev.x,
819  origin_dev.y, origin_dev.y,
820  size_dev.y, fabs( size_dev.x / size_dev.y ),
821  aOrient / 10.0,
822  aItalic ? DXF_OBLIQUE_ANGLE : 0,
823  size_dev.x < 0 ? 2 : 0, // X mirror flag
824  h_code, v_code );
825 
826  /* There are two issue in emitting the text:
827  - Our overline character (~) must be converted to the appropriate
828  control sequence %%O or %%o
829  - Text encoding in DXF is more or less unspecified since depends on
830  the DXF declared version, the acad version reading it *and* some
831  system variables to be put in the header handled only by newer acads
832  Also before R15 unicode simply is not supported (you need to use
833  bigfonts which are a massive PITA). Common denominator solution:
834  use Latin1 (and however someone could choke on it, anyway). Sorry
835  for the extended latin people. If somewant want to try fixing this
836  recent version seems to use UTF-8 (and not UCS2 like the rest of
837  Windows)
838 
839  XXX Actually there is a *third* issue: older DXF formats are limited
840  to 255 bytes records (it was later raised to 2048); since I'm lazy
841  and text so long is not probable I just don't implement this rule.
842  If someone is interested in fixing this, you have to emit the first
843  partial lines with group code 3 (max 250 bytes each) and then finish
844  with a group code 1 (less than 250 bytes). The DXF refs explains it
845  in no more details...
846  */
847 
848  bool overlining = false;
849  fputs( " 1\n", outputFile );
850  for( unsigned i = 0; i < aText.length(); i++ )
851  {
852  /* Here I do a bad thing: writing the output one byte at a time!
853  but today I'm lazy and I have no idea on how to coerce a Unicode
854  wxString to spit out latin1 encoded text ...
855 
856  Atleast stdio is *supposed* to do output buffering, so there is
857  hope is not too slow */
858  wchar_t ch = aText[i];
859  if( ch > 255 )
860  {
861  // I can't encode this...
862  putc( '?', outputFile );
863  }
864  else
865  {
866  if( ch == '~' )
867  {
868  // Handle the overline toggle
869  fputs( overlining ? "%%o" : "%%O", outputFile );
870  overlining = !overlining;
871  }
872  else
873  {
874  putc( ch, outputFile );
875  }
876  }
877  }
878  putc( '\n', outputFile );
879  }
880 }
bool textAsLines
Definition: plot_common.h:1296
static const double DXF_OBLIQUE_ANGLE
Oblique angle for DXF native text (I don't remember if 15 degrees is the ISO value...
static wxString getDXFColorName(COLOR4D aColor)
COLOR4D m_currentColor
Definition: plot_common.h:1297
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=NULL)
Draws text with the plotter.
Definition: drawtxt.cpp:229
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
bool containsNonAsciiChars(const wxString &string)
Checks if a given string contains non-ASCII characters.
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
virtual void SetColor(COLOR4D color) override
The DXF exporter handles 'colors' as layers...
void PLOTTER::ThickArc ( const wxPoint centre,
double  StAngle,
double  EndAngle,
int  rayon,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 465 of file class_plotter.cpp.

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

Referenced by BRDITEMS_PLOTTER::Plot_1_EdgeModule(), and BRDITEMS_PLOTTER::PlotDrawSegment().

467 {
468  if( tracemode == FILLED )
469  Arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
470  else
471  {
472  SetCurrentLineWidth( -1 );
473  Arc( centre, StAngle, EndAngle,
474  radius - ( width - currentPenWidth ) / 2, NO_FILL, -1 );
475  Arc( centre, StAngle, EndAngle,
476  radius + ( width - currentPenWidth ) / 2, NO_FILL, -1 );
477  }
478 }
int currentPenWidth
Definition: plot_common.h:537
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.
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
void PLOTTER::ThickCircle ( const wxPoint pos,
int  diametre,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 503 of file class_plotter.cpp.

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

Referenced by BRDITEMS_PLOTTER::Plot_1_EdgeModule(), and BRDITEMS_PLOTTER::PlotDrawSegment().

504 {
505  if( tracemode == FILLED )
506  Circle( pos, diametre, NO_FILL, width );
507  else
508  {
509  SetCurrentLineWidth( -1 );
510  Circle( pos, diametre - width + currentPenWidth, NO_FILL, -1 );
511  Circle( pos, diametre + width - currentPenWidth, NO_FILL, -1 );
512  }
513 }
int currentPenWidth
Definition: plot_common.h:537
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
void PLOTTER::ThickRect ( const wxPoint p1,
const wxPoint p2,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
virtualinherited

Reimplemented in GERBER_PLOTTER.

Definition at line 481 of file class_plotter.cpp.

References PLOTTER::currentPenWidth, FILLED, NO_FILL, PLOTTER::Rect(), PLOTTER::SetCurrentLineWidth(), wxPoint::x, and wxPoint::y.

483 {
484  if( tracemode == FILLED )
485  Rect( p1, p2, NO_FILL, width );
486  else
487  {
488  SetCurrentLineWidth( -1 );
489  wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2,
490  p1.y - (width - currentPenWidth) / 2 );
491  wxPoint offsetp2( p2.x + (width - currentPenWidth) / 2,
492  p2.y + (width - currentPenWidth) / 2 );
493  Rect( offsetp1, offsetp2, NO_FILL, -1 );
494  offsetp1.x += (width - currentPenWidth);
495  offsetp1.y += (width - currentPenWidth);
496  offsetp2.x -= (width - currentPenWidth);
497  offsetp2.y -= (width - currentPenWidth);
498  Rect( offsetp1, offsetp2, NO_FILL, -1 );
499  }
500 }
int currentPenWidth
Definition: plot_common.h:537
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=NULL)=0
Set the line width for the next drawing.
void DXF_PLOTTER::ThickSegment ( const wxPoint start,
const wxPoint end,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 505 of file common_plotDXF_functions.cpp.

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

Referenced by PlotPoly().

507 {
508  MoveTo( aStart );
509  FinishTo( aEnd );
510 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
DPOINT PLOTTER::userToDeviceCoordinates ( const wxPoint aCoordinate)
protectedvirtualinherited

Modifies 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 96 of file class_plotter.cpp.

References PLOTTER::iuPerDeviceUnit, PLOTTER::m_mirrorIsHorizontal, PLOTTER::m_plotMirror, PLOTTER::m_yaxisReversed, PLOTTER::paperSize, PLOTTER::plotOffset, PLOTTER::plotScale, wxPoint::x, and wxPoint::y.

Referenced by HPGL_PLOTTER::Arc(), PS_PLOTTER::Arc(), PDF_PLOTTER::Arc(), SVG_PLOTTER::Arc(), GERBER_PLOTTER::Arc(), Arc(), PS_PLOTTER::Circle(), PDF_PLOTTER::Circle(), SVG_PLOTTER::Circle(), Circle(), PSLIKE_PLOTTER::computeTextParameters(), HPGL_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadRect(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::PenTo(), PenTo(), PS_PLOTTER::PlotImage(), PDF_PLOTTER::PlotImage(), PS_PLOTTER::PlotPoly(), PDF_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), HPGL_PLOTTER::Rect(), PS_PLOTTER::Rect(), PDF_PLOTTER::Rect(), SVG_PLOTTER::Rect(), PS_PLOTTER::Text(), and Text().

97 {
98  wxPoint pos = aCoordinate - plotOffset;
99 
100  double x = pos.x * plotScale;
101  double y = ( paperSize.y - pos.y * plotScale );
102 
103  if( m_plotMirror )
104  {
106  x = ( paperSize.x - pos.x * plotScale );
107  else
108  y = pos.y * plotScale;
109  }
110 
111  if( m_yaxisReversed )
112  y = paperSize.y - y;
113 
114  x *= iuPerDeviceUnit;
115  y *= iuPerDeviceUnit;
116 
117  return DPOINT( x, y );
118 }
wxPoint plotOffset
Plot offset (in IUs)
Definition: plot_common.h:522
bool m_yaxisReversed
true to mirror horizontally (else vertically)
Definition: plot_common.h:528
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plot_common.h:526
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:510
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:519
VECTOR2< double > DPOINT
Definition: vector2d.h:595
wxSize paperSize
Paper size in IU - not in mils.
Definition: plot_common.h:547
bool m_mirrorIsHorizontal
Definition: plot_common.h:527
DPOINT PLOTTER::userToDeviceSize ( const wxSize &  size)
protectedvirtualinherited

Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT)

Definition at line 121 of file class_plotter.cpp.

References PLOTTER::iuPerDeviceUnit, and PLOTTER::plotScale.

Referenced by PS_PLOTTER::Arc(), SVG_PLOTTER::Arc(), Arc(), HPGL_PLOTTER::Circle(), PS_PLOTTER::Circle(), PDF_PLOTTER::Circle(), SVG_PLOTTER::Circle(), Circle(), PSLIKE_PLOTTER::computeTextParameters(), HPGL_PLOTTER::FlashPadCircle(), PLOTTER::GetDashGapLenIU(), PLOTTER::GetDashMarkLenIU(), PDF_PLOTTER::PlotImage(), HPGL_PLOTTER::SetCurrentLineWidth(), PS_PLOTTER::SetCurrentLineWidth(), PDF_PLOTTER::SetCurrentLineWidth(), SVG_PLOTTER::setSVGPlotStyle(), PDF_PLOTTER::StartPage(), HPGL_PLOTTER::StartPlot(), PS_PLOTTER::StartPlot(), PS_PLOTTER::Text(), PDF_PLOTTER::Text(), and Text().

122 {
123  return DPOINT( size.x * plotScale * iuPerDeviceUnit,
124  size.y * plotScale * iuPerDeviceUnit );
125 }
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:510
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:519
VECTOR2< double > DPOINT
Definition: vector2d.h:595
double PLOTTER::userToDeviceSize ( double  size) const
protectedvirtualinherited

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

Definition at line 128 of file class_plotter.cpp.

References PLOTTER::iuPerDeviceUnit, and PLOTTER::plotScale.

129 {
130  return size * plotScale * iuPerDeviceUnit;
131 }
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:510
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:519

Member Data Documentation

wxString PLOTTER::creator
protectedinherited
const int PLOTTER::DO_NOT_SET_LINE_WIDTH = -2
staticinherited
COLOR4D DXF_PLOTTER::m_currentColor
protected

Definition at line 1297 of file plot_common.h.

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

wxArrayString PLOTTER::m_headerExtraLines
protectedinherited
bool PLOTTER::m_mirrorIsHorizontal
protectedinherited
bool PLOTTER::m_yaxisReversed
protectedinherited

true to mirror horizontally (else vertically)

Definition at line 528 of file plot_common.h.

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

const unsigned PLOTTER::MARKER_COUNT = 58
staticinherited

Draw a marker (used for the drill map)

Definition at line 380 of file plot_common.h.

Referenced by PLOTTER::Marker().

bool PLOTTER::negativeMode
protectedinherited

true to plot in color, false to plot in black and white

Definition at line 535 of file plot_common.h.

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

FILE* PLOTTER::outputFile
protectedinherited

true if the Y axis is top to bottom (SVG)

Output file

Definition at line 531 of file plot_common.h.

Referenced by HPGL_PLOTTER::Arc(), PS_PLOTTER::Arc(), SVG_PLOTTER::Arc(), GERBER_PLOTTER::Arc(), Arc(), HPGL_PLOTTER::Circle(), PS_PLOTTER::Circle(), SVG_PLOTTER::Circle(), Circle(), GERBER_PLOTTER::clearNetAttribute(), PDF_PLOTTER::ClosePage(), PDF_PLOTTER::closePdfObject(), PDF_PLOTTER::closePdfStream(), GERBER_PLOTTER::emitDcode(), PS_PLOTTER::emitSetRGBColor(), HPGL_PLOTTER::EndPlot(), PS_PLOTTER::EndPlot(), PDF_PLOTTER::EndPlot(), SVG_PLOTTER::EndPlot(), GERBER_PLOTTER::EndPlot(), EndPlot(), HPGL_PLOTTER::FlashPadCircle(), FlashPadCircle(), HPGL_PLOTTER::FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadOval(), FlashPadOval(), GERBER_PLOTTER::FlashPadRect(), FlashPadRect(), FlashPadTrapez(), GERBER_PLOTTER::formatNetAttribute(), PLOTTER::OpenFile(), PDF_PLOTTER::OpenFile(), HPGL_PLOTTER::penControl(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::PenTo(), PenTo(), PS_PLOTTER::PlotImage(), HPGL_PLOTTER::PlotPoly(), PS_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), GERBER_PLOTTER::PlotPoly(), PLOTTER::PLOTTER(), HPGL_PLOTTER::Rect(), PS_PLOTTER::Rect(), SVG_PLOTTER::Rect(), Rect(), GERBER_PLOTTER::selectAperture(), PS_PLOTTER::SetCurrentLineWidth(), HPGL_PLOTTER::SetDash(), PS_PLOTTER::SetDash(), GERBER_PLOTTER::SetLayerPolarity(), SVG_PLOTTER::setSVGPlotStyle(), PS_PLOTTER::SetViewport(), PDF_PLOTTER::StartPage(), PDF_PLOTTER::startPdfObject(), PDF_PLOTTER::startPdfStream(), HPGL_PLOTTER::StartPlot(), PS_PLOTTER::StartPlot(), PDF_PLOTTER::StartPlot(), SVG_PLOTTER::StartPlot(), GERBER_PLOTTER::StartPlot(), StartPlot(), PS_PLOTTER::Text(), Text(), HPGL_PLOTTER::ThickSegment(), GERBER_PLOTTER::writeApertureList(), and PLOTTER::~PLOTTER().

wxPoint PLOTTER::penLastpos
protectedinherited

Last pen positions; set to -1,-1 when the pen is at rest.

Definition at line 541 of file plot_common.h.

Referenced by HPGL_PLOTTER::penControl(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), and PenTo().

char PLOTTER::penState
protectedinherited

Current pen state: 'U', 'D' or 'Z' (see PenTo)

Definition at line 539 of file plot_common.h.

Referenced by HPGL_PLOTTER::penControl(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), GERBER_PLOTTER::PenTo(), and PLOTTER::PLOTTER().

bool DXF_PLOTTER::textAsLines
protected

Definition at line 1296 of file plot_common.h.

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

wxString PLOTTER::title
protectedinherited

Definition at line 544 of file plot_common.h.

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


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