KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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
20#pragma once
21
22#include "plotter.h"
23
24
25class DXF_PLOTTER : public PLOTTER
26{
27public:
29 m_textAsLines( false )
30 {
31 m_textAsLines = true;
32 m_currentColor = COLOR4D::BLACK;
33 m_currentLineType = LINE_STYLE::SOLID;
34 SetUnits( DXF_UNITS::INCH );
35 }
36
37 virtual PLOT_FORMAT GetPlotterType() const override
38 {
39 return PLOT_FORMAT::DXF;
40 }
41
42 static wxString GetDefaultFileExtension()
43 {
44 return wxString( wxT( "dxf" ) );
45 }
46
50 virtual void SetTextMode( PLOT_TEXT_MODE mode ) override
51 {
52 if( mode != PLOT_TEXT_MODE::DEFAULT )
53 m_textAsLines = ( mode != PLOT_TEXT_MODE::NATIVE );
54 }
55
59 virtual bool StartPlot( const wxString& aPageNumber ) override;
60 virtual bool EndPlot() override;
61
62 // For now we don't use 'thick' primitives, so no line width
63 virtual void SetCurrentLineWidth( int width, void* aData = nullptr ) override
64 {
66 }
67
68 virtual void SetDash( int aLineWidth, LINE_STYLE aLineStyle ) override;
69
73 virtual void SetColor( const COLOR4D& color ) override;
74
81 virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
82 double aScale, bool aMirror ) override;
83
87 virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int width ) override;
88
95 virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width ) override;
96
97 virtual void Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
98 const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill, int aWidth ) override;
99
107 virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
108 int aWidth, void* aData = nullptr ) override;
109
110 virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
111 void* aData ) override;
112
113 virtual void ThickArc( const VECTOR2D& aCentre, const EDA_ANGLE& aStAngle,
114 const EDA_ANGLE& aAngle, double aRadius, int aWidth,
115 void* aData ) override;
116
117 virtual void ThickRect( const VECTOR2I& p1, const VECTOR2I& p2, int width,
118 void* aData ) override;
119
120 virtual void ThickCircle( const VECTOR2I& pos, int diametre, int width, void* aData ) override;
121
122 virtual void FilledCircle( const VECTOR2I& pos, int diametre, void* aData ) override;
123
124 virtual void ThickPoly( const SHAPE_POLY_SET& aPoly, int aWidth, void* aData ) override;
125
126 virtual void PenTo( const VECTOR2I& pos, char plume ) override;
127
132 virtual void FlashPadCircle( const VECTOR2I& pos, int diametre, void* aData ) override;
133
137 virtual void FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
138 const EDA_ANGLE& aOrient, void* aData ) override;
139
143 virtual void FlashPadRect( const VECTOR2I& aPos, const VECTOR2I& aSize,
144 const EDA_ANGLE& aOrient, void* aData ) override;
145 virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
146 int aCornerRadius, const EDA_ANGLE& aOrient,
147 void* aData ) override;
148 virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
149 const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
150 void* aData ) override;
151
155 virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
156 const EDA_ANGLE& aPadOrient, void* aData ) override;
157 virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
158 const EDA_ANGLE& aOrient, void* aData ) override;
159
160 virtual void Text( const VECTOR2I& aPos,
161 const COLOR4D& aColor,
162 const wxString& aText,
163 const EDA_ANGLE& aOrient,
164 const VECTOR2I& aSize,
165 enum GR_TEXT_H_ALIGN_T aH_justify,
166 enum GR_TEXT_V_ALIGN_T aV_justify,
167 int aWidth,
168 bool aItalic,
169 bool aBold,
170 bool aMultilineAllowed,
171 KIFONT::FONT* aFont,
172 const KIFONT::METRICS& aFontMetrics,
173 void* aData = nullptr ) override;
174
175 virtual void PlotText( const VECTOR2I& aPos,
176 const COLOR4D& aColor,
177 const wxString& aText,
178 const TEXT_ATTRIBUTES& aAttributes,
179 KIFONT::FONT* aFont,
180 const KIFONT::METRICS& aFontMetrics,
181 void* aData = nullptr ) override;
182
188 void SetUnits( DXF_UNITS aUnit );
189
196 {
197 return m_plotUnits;
198 }
199
206 double GetUnitScaling() const
207 {
208 return m_unitScalingFactor;
209 }
210
216 unsigned int GetMeasurementDirective() const
217 {
219 }
220
221protected:
222 void plotOneLineOfText( const VECTOR2I& aPos, const COLOR4D& aColor, const wxString& aText,
223 const TEXT_ATTRIBUTES& aAttrs );
224
228
232};
int color
Definition: DXF_plotter.cpp:63
void plotOneLineOfText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttrs)
DXF_UNITS m_plotUnits
Definition: plotter_dxf.h:229
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
bool m_textAsLines
Definition: plotter_dxf.h:225
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, SHAPE_POLY_SET *aPolygons, void *aData) override
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, void *aData) override
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:42
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot.
virtual void ThickArc(const VECTOR2D &aCentre, const EDA_ANGLE &aStAngle, const EDA_ANGLE &aAngle, double aRadius, int aWidth, void *aData) override
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth) override
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:206
virtual void FlashPadOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, void *aData) override
DXF oval pad: always done in sketch mode.
virtual void FlashPadRect(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, void *aData) override
DXF rectangular pad: always done in sketch mode.
virtual void ThickRect(const VECTOR2I &p1, const VECTOR2I &p2, int width, void *aData) override
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, void *aData) override
virtual void ThickPoly(const SHAPE_POLY_SET &aPoly, int aWidth, void *aData) 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:216
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, void *aData) override
DXF trapezoidal pad: only sketch mode is supported.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width) override
DXF circle: full functionality; it even does 'fills' drawing a circle with a dual-arc polyline wide a...
virtual void FlashPadCircle(const VECTOR2I &pos, int diametre, 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 FilledCircle(const VECTOR2I &pos, int diametre, void *aData) override
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, 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:50
unsigned int m_measurementDirective
Definition: plotter_dxf.h:231
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Set the line width for the next drawing.
Definition: plotter_dxf.h:63
virtual bool EndPlot() override
virtual void FlashRegularPolygon(const VECTOR2I &aShapePos, int aDiameter, int aCornerCount, const EDA_ANGLE &aOrient, void *aData) override
Flash a regular polygon.
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width) override
DXF rectangle: fill not supported.
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, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData) override
virtual PLOT_FORMAT GetPlotterType() const override
Return the effective plot engine in use.
Definition: plotter_dxf.h:37
DXF_UNITS GetUnits() const
The units currently enabled for plotting.
Definition: plotter_dxf.h:195
double m_unitScalingFactor
Definition: plotter_dxf.h:230
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
COLOR4D m_currentColor
Definition: plotter_dxf.h:226
LINE_STYLE m_currentLineType
Definition: plotter_dxf.h:227
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Base plotter engine class.
Definition: plotter.h:121
int m_currentPenWidth
Definition: plotter.h:665
Represent a set of closed polygons.
FILL_T
Definition: eda_shape.h:56
DXF_UNITS
Definition: plotter.h:52
PLOT_TEXT_MODE
Which kind of text to output with the PSLIKE plotters.
Definition: plotter.h:99
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:64
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
VECTOR2I end
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.