KiCad PCB EDA Suite
No Matches
Go to the documentation of this file.
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016-2022 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
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 <>.
18 */
26#pragma once
28#include "plotter.h"
31class DXF_PLOTTER : public PLOTTER
35 {
36 m_textAsLines = true;
37 m_currentColor = COLOR4D::BLACK;
38 m_currentLineType = PLOT_DASH_TYPE::SOLID;
39 SetUnits( DXF_UNITS::INCHES );
40 }
42 virtual PLOT_FORMAT GetPlotterType() const override
43 {
44 return PLOT_FORMAT::DXF;
45 }
47 static wxString GetDefaultFileExtension()
48 {
49 return wxString( wxT( "dxf" ) );
50 }
55 virtual void SetTextMode( PLOT_TEXT_MODE mode ) override
56 {
57 if( mode != PLOT_TEXT_MODE::DEFAULT )
58 m_textAsLines = ( mode != PLOT_TEXT_MODE::NATIVE );
59 }
64 virtual bool StartPlot( const wxString& aPageNumber ) override;
65 virtual bool EndPlot() override;
67 // For now we don't use 'thick' primitives, so no line width
68 virtual void SetCurrentLineWidth( int width, void* aData = nullptr ) override
69 {
71 }
73 virtual void SetDash( int aLineWidth, PLOT_DASH_TYPE aLineStyle ) override;
78 virtual void SetColor( const COLOR4D& color ) override;
86 virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
87 double aScale, bool aMirror ) override;
92 virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill,
93 int width = USE_DEFAULT_LINE_WIDTH ) override;
101 virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill,
102 int width = USE_DEFAULT_LINE_WIDTH ) override;
111 virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
112 int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
113 virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
114 OUTLINE_MODE tracemode, void* aData ) override;
116 virtual void PenTo( const VECTOR2I& pos, char plume ) override;
122 virtual void FlashPadCircle( const VECTOR2I& pos, int diametre,
123 OUTLINE_MODE trace_mode, void* aData ) override;
128 virtual void FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
129 const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
130 void* aData ) override;
135 virtual void FlashPadRect( const VECTOR2I& aPos, const VECTOR2I& aSize,
136 const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
137 void* aData ) override;
138 virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
139 int aCornerRadius, const EDA_ANGLE& aOrient,
140 OUTLINE_MODE aTraceMode, void* aData ) override;
141 virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
142 const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
143 OUTLINE_MODE aTraceMode, void* aData ) override;
148 virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
149 const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
150 void* aData ) override;
151 virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
152 const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
153 void* aData ) override;
155 virtual void Text( const VECTOR2I& aPos,
156 const COLOR4D& aColor,
157 const wxString& aText,
158 const EDA_ANGLE& aOrient,
159 const VECTOR2I& aSize,
160 enum GR_TEXT_H_ALIGN_T aH_justify,
161 enum GR_TEXT_V_ALIGN_T aV_justify,
162 int aWidth,
163 bool aItalic,
164 bool aBold,
165 bool aMultilineAllowed = false,
166 KIFONT::FONT* aFont = nullptr,
167 void* aData = nullptr ) override;
169 virtual void PlotText( const VECTOR2I& aPos,
170 const COLOR4D& aColor,
171 const wxString& aText,
172 const TEXT_ATTRIBUTES& aAttributes,
173 KIFONT::FONT* aFont,
174 void* aData = nullptr ) override;
180 void SetUnits( DXF_UNITS aUnit );
188 {
189 return m_plotUnits;
190 }
198 double GetUnitScaling() const
199 {
200 return m_unitScalingFactor;
201 }
208 unsigned int GetMeasurementDirective() const
209 {
211 }
214 virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
215 const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill,
216 int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
218 void plotOneLineOfText( const VECTOR2I& aPos, const COLOR4D& aColor,
219 const wxString& aText,
220 const TEXT_ATTRIBUTES& aAttributes );
int color
Definition: DXF_plotter.cpp:57
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
DXF_UNITS m_plotUnits
Definition: plotter_dxf.h:226
virtual void FlashPadCircle(const VECTOR2I &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...
bool m_textAsLines
Definition: plotter_dxf.h:222
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:47
virtual void FlashPadRect(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
DXF rectangular pad: always done in sketch mode.
virtual void Arc(const VECTOR2I &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, int aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
DXF trapezoidal pad: only sketch mode is supported.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot.
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:198
virtual void FlashRegularPolygon(const VECTOR2I &aShapePos, int aDiameter, int aCornerCount, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a regular polygon.
virtual void FlashPadOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
DXF oval pad: always done in sketch mode.
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
PLOT_DASH_TYPE m_currentLineType
Definition: plotter_dxf.h:224
virtual void SetDash(int aLineWidth, PLOT_DASH_TYPE aLineStyle) override
virtual bool StartPlot(const wxString &aPageNumber) override
Open the DXF plot with a skeleton header.
unsigned int GetMeasurementDirective() const
Get the correct value for the $MEASUREMENT field given the current units.
Definition: plotter_dxf.h:208
virtual void Circle(const VECTOR2I &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...
virtual void PlotPoly(const std::vector< VECTOR2I > &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.
virtual void SetTextMode(PLOT_TEXT_MODE mode) override
DXF handles NATIVE text emitting TEXT entities.
Definition: plotter_dxf.h:55
unsigned int m_measurementDirective
Definition: plotter_dxf.h:228
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Set the line width for the next drawing.
Definition: plotter_dxf.h:68
virtual bool EndPlot() override
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr) override
virtual void SetColor(const COLOR4D &color) override
The DXF exporter handles 'colors' as layers...
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, KIFONT::FONT *aFont=nullptr, void *aData=nullptr) override
Draw text with the plotter.
void plotOneLineOfText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes)
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF rectangle: fill not supported.
virtual PLOT_FORMAT GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plotter_dxf.h:42
DXF_UNITS GetUnits() const
The units currently enabled for plotting.
Definition: plotter_dxf.h:187
double m_unitScalingFactor
Definition: plotter_dxf.h:227
COLOR4D m_currentColor
Definition: plotter_dxf.h:223
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
Base plotter engine class.
Definition: plotter.h:110
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:114
int m_currentPenWidth
Definition: plotter.h:658
Represent a set of closed polygons.
Definition: eda_shape.h:54
Definition: outline_mode.h:25
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
Definition: plotter.h:58
Which kind of text to output with the PSLIKE plotters.
Definition: plotter.h:96
The set of supported output plot formats.
Definition: plotter.h:70
Dashed line types.
Definition: stroke_params.h:48