KiCad PCB EDA Suite
plotter_dxf.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 #pragma once
27 
28 #include <vector>
29 #include <math/box2.h>
30 #include <eda_item.h> // FILL_TYPE
31 #include <plotter.h>
32 
33 
34 class DXF_PLOTTER : public PLOTTER
35 {
36 public:
38  {
39  m_textAsLines = true;
43  }
44 
45  virtual PLOT_FORMAT GetPlotterType() const override
46  {
47  return PLOT_FORMAT::DXF;
48  }
49 
50  static wxString GetDefaultFileExtension()
51  {
52  return wxString( wxT( "dxf" ) );
53  }
54 
58  virtual void SetTextMode( PLOT_TEXT_MODE mode ) override
59  {
60  if( mode != PLOT_TEXT_MODE::DEFAULT )
62  }
63 
64  virtual bool StartPlot() override;
65  virtual bool EndPlot() override;
66 
67  // For now we don't use 'thick' primitives, so no line width
68  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
69  {
71  }
72 
73  virtual void SetDash( PLOT_DASH_TYPE dashed ) override;
74 
75  virtual void SetColor( COLOR4D color ) override;
76 
77  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
78  double aScale, bool aMirror ) override;
79  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill,
80  int width = USE_DEFAULT_LINE_WIDTH ) override;
81  virtual void Circle( const wxPoint& pos, int diametre, FILL_TYPE fill,
82  int width = USE_DEFAULT_LINE_WIDTH ) override;
83  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
84  FILL_TYPE aFill, int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) override;
85  virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
86  OUTLINE_MODE tracemode, void* aData ) override;
87  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
88  int rayon, FILL_TYPE fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
89  virtual void PenTo( const wxPoint& pos, char plume ) override;
90 
91  virtual void FlashPadCircle( const wxPoint& pos, int diametre,
92  OUTLINE_MODE trace_mode, void* aData ) override;
93  virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, double orient,
94  OUTLINE_MODE trace_mode, void* aData ) override;
95  virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
96  double orient, OUTLINE_MODE trace_mode, void* aData ) override;
97  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
98  int aCornerRadius, double aOrient,
99  OUTLINE_MODE aTraceMode, void* aData ) override;
100  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize, double aOrient,
101  SHAPE_POLY_SET* aPolygons,
102  OUTLINE_MODE aTraceMode, void* aData ) override;
103  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
104  double aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
105  virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount,
106  double aOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
107 
108  virtual void Text( const wxPoint& aPos,
109  const COLOR4D aColor,
110  const wxString& aText,
111  double aOrient,
112  const wxSize& aSize,
113  enum EDA_TEXT_HJUSTIFY_T aH_justify,
114  enum EDA_TEXT_VJUSTIFY_T aV_justify,
115  int aWidth,
116  bool aItalic,
117  bool aBold,
118  bool aMultilineAllowed = false,
119  void* aData = NULL ) override;
120 
121 
127  void SetUnits( DXF_UNITS aUnit );
128 
135  {
136  return m_plotUnits;
137  }
138 
145  double GetUnitScaling() const
146  {
147  return m_unitScalingFactor;
148  }
149 
155  unsigned int GetMeasurementDirective() const
156  {
157  return m_measurementDirective;
158  }
159 
160 protected:
164 
168 };
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE 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.
OUTLINE_MODE
Definition: outline_mode.h:24
double m_unitScalingFactor
Definition: plotter_dxf.h:166
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:61
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Definition: plotter_dxf.h:68
virtual void FlashPadRect(const wxPoint &pos, const wxSize &size, double orient, OUTLINE_MODE trace_mode, void *aData) override
DXF rectangular pad: alwayd done in sketch mode.
FILL_TYPE
The set of fill types used in plotting or drawing enclosed areas.
Definition: fill_type.h:28
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.
unsigned int m_measurementDirective
Definition: plotter_dxf.h:167
virtual void SetDash(PLOT_DASH_TYPE dashed) override
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.
DXF_UNITS m_plotUnits
Definition: plotter_dxf.h:165
int color
Definition: DXF_plotter.cpp:60
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 p...
virtual void FlashRegularPolygon(const wxPoint &aShapePos, int aDiameter, int aCornerCount, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a regular polygon.
bool m_textAsLines
Definition: plotter_dxf.h:161
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
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:162
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
virtual void SetTextMode(PLOT_TEXT_MODE mode) override
DXF handles NATIVE text emitting TEXT entities.
Definition: plotter_dxf.h:58
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.
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:145
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:50
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, double aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:126
virtual bool StartPlot() override
Opens the DXF plot with a skeleton header.
int m_currentPenWidth
Definition: plotter.h:585
#define NULL
Represent a set of closed polygons.
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:67
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.
virtual bool EndPlot() override
PLOT_DASH_TYPE
Dashed line types.
Definition: plotter.h:104
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:68
virtual PLOT_FORMAT GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plotter_dxf.h:45
Base plotter engine class.
Definition: plotter.h:121
unsigned int GetMeasurementDirective() const
Get the correct value for the $MEASUREMENT field given the current units.
Definition: plotter_dxf.h:155
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE 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...
PLOT_DASH_TYPE m_currentLineType
Definition: plotter_dxf.h:163
virtual void SetColor(COLOR4D color) override
The DXF exporter handles 'colors' as layers...
DXF_UNITS
Definition: plotter.h:55
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData) override
PLOT_TEXT_MODE
Which kind of text to output with the PSLIKE plotters.
Definition: plotter.h:93
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
DXF_UNITS GetUnits() const
The units currently enabled for plotting.
Definition: plotter_dxf.h:134
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF rectangle: fill not supported.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98