KiCad PCB EDA Suite
Loading...
Searching...
No Matches
plotter_hpgl.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-2023 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 <list>
29
30#include "plotter.h"
31
32
33class HPGL_PLOTTER : public PLOTTER
34{
35public:
37
38 virtual PLOT_FORMAT GetPlotterType() const override
39 {
40 return PLOT_FORMAT::HPGL;
41 }
42
43 static wxString GetDefaultFileExtension()
44 {
45 return wxString( wxT( "plt" ) );
46 }
47
53 void SetTargetChordLength( double chord_len );
54
56 void SetUserCoords( bool user_coords ) { m_useUserCoords = user_coords; }
57
59 void SetUserCoordsFit( bool user_coords_fit ) { m_fitUserCoords = user_coords_fit; }
60
64 virtual bool StartPlot( const wxString& aPageNumber ) override;
65
69 virtual bool EndPlot() override;
70
72 virtual void SetColorMode( bool aColorMode ) override {};
73
75 virtual void SetCurrentLineWidth( int width, void* aData = nullptr ) override
76 {
77 // This is the truth
79 }
80
84 virtual void SetDash( int aLineWidth, LINE_STYLE aLineStyle ) override;
85
86 virtual void SetColor( const COLOR4D& color ) override {}
87
88 virtual void SetPenSpeed( int speed )
89 {
90 m_penSpeed = speed;
91 }
92
93 virtual void SetPenNumber( int number )
94 {
95 m_penNumber = number;
96 }
97
98 virtual void SetPenDiameter( double diameter );
99
100 virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
101 double aScale, bool aMirror ) override;
102 virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T aFill,
103 int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
104 virtual void Circle( const VECTOR2I& aCenter, int aDiameter, FILL_T aFill,
105 int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
106 virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
107 int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
108
109 virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
110 OUTLINE_MODE tracemode, void* aData ) override;
111
112 virtual void PenTo( const VECTOR2I& pos, char plume ) override;
113
114 virtual void FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter,
115 OUTLINE_MODE aTraceMode, void* aData ) override;
116 virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
117 const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
118 void* aData ) override;
119 virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
120 const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
121 void* aData ) override;
122 virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
123 int aCornerRadius, const EDA_ANGLE& aOrient,
124 OUTLINE_MODE aTraceMode, void* aData ) override;
125 virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
126 const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
127 OUTLINE_MODE aTraceMode, void* aData ) override;
128 virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
129 const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
130 void* aData ) override;
131 virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
132 const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
133 void* aData ) override;
134
135protected:
148 virtual void Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
149 const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill,
150 int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
151
158 bool startItem( const VECTOR2D& location );
159
161 void flushItem();
162
171 bool startOrAppendItem( const VECTOR2D& location, const wxString& content );
172
174 {
176 lift_before( false ),
177 lift_after( false ),
178 pen_returns( false ),
179 pen( 0 ),
181
184
188
191
194
199
203
204 int pen;
206 wxString content;
207 };
208
212 static void sortItems( std::list<HPGL_ITEM>& items );
213
215 static const char* lineStyleCommand( LINE_STYLE aLineStyle );
216
217protected:
226
227 std::list<HPGL_ITEM> m_items;
229};
int color
Definition: DXF_plotter.cpp:58
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
void SetUserCoordsFit(bool user_coords_fit)
Set whether the user coordinate system is fit to content.
Definition: plotter_hpgl.h:59
HPGL_ITEM * m_current_item
Definition: plotter_hpgl.h:228
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
HPGL supports dashed lines.
virtual void SetPenSpeed(int speed)
Definition: plotter_hpgl.h:88
bool startItem(const VECTOR2D &location)
Start a new HPGL_ITEM if necessary, keeping the current one if it exists.
double m_arcTargetChordLength
Definition: plotter_hpgl.h:221
void flushItem()
Flush the current HPGL_ITEM and clear out the current item pointer.
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a trapezoidal pad.
virtual PLOT_FORMAT GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plotter_hpgl.h:38
void SetTargetChordLength(double chord_len)
Set the target length of chords used to draw approximated circles and arcs.
virtual void SetPenNumber(int number)
Definition: plotter_hpgl.h:93
static wxString GetDefaultFileExtension()
Definition: plotter_hpgl.h:43
void SetUserCoords(bool user_coords)
Switch to the user coordinate system.
Definition: plotter_hpgl.h:56
static void sortItems(std::list< HPGL_ITEM > &items)
Sort a list of HPGL items to improve plotting speed on mechanical plotters.
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData) override
virtual bool StartPlot(const wxString &aPageNumber) override
At the start of the HPGL plot pen speed and number are requested.
LINE_STYLE m_lineStyle
Definition: plotter_hpgl.h:223
EDA_ANGLE m_arcMinChordDegrees
Definition: plotter_hpgl.h:222
virtual void SetColor(const COLOR4D &color) override
Definition: plotter_hpgl.h:86
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
HPGL doesn't handle line thickness or color.
Definition: plotter_hpgl.h:75
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 PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Draw a polygon ( filled or not ).
static const char * lineStyleCommand(LINE_STYLE aLineStyle)
Return the plot command corresponding to a line type.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
bool m_useUserCoords
Definition: plotter_hpgl.h:224
std::list< HPGL_ITEM > m_items
Definition: plotter_hpgl.h:227
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
virtual void SetPenDiameter(double diameter)
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
double m_penDiameter
Definition: plotter_hpgl.h:220
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Plot an arc.
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
bool m_fitUserCoords
Definition: plotter_hpgl.h:225
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
virtual void SetColorMode(bool aColorMode) override
HPGL doesn't handle color.
Definition: plotter_hpgl.h:72
bool startOrAppendItem(const VECTOR2D &location, const wxString &content)
Start a new HPGL_ITEM with the given string if necessary, or append the string to the current item.
virtual void Circle(const VECTOR2I &aCenter, int aDiameter, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
virtual bool EndPlot() override
HPGL end of plot: sort and emit graphics, pen return and release.
virtual void FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Base plotter engine class.
Definition: plotter.h:104
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:108
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
Definition: plotter.cpp:115
int m_currentPenWidth
Definition: plotter.h:666
Represent a set of closed polygons.
FILL_T
Definition: eda_shape.h:55
OUTLINE_MODE
Definition: outline_mode.h:25
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:64
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
wxString content
Line style for this command.
Definition: plotter_hpgl.h:206
bool pen_returns
Whether the pen returns to its original state after the command.
Definition: plotter_hpgl.h:202
BOX2D bbox
Bounding box of this item.
Definition: plotter_hpgl.h:190
LINE_STYLE dashType
Pen number for this command.
Definition: plotter_hpgl.h:205
bool lift_after
Whether the pen must be lifted after the command.
Definition: plotter_hpgl.h:198
bool lift_before
Whether the command should be executed with the pen lifted.
Definition: plotter_hpgl.h:193
VECTOR2D loc_start
Location the pen should start at.
Definition: plotter_hpgl.h:183
VECTOR2D loc_end
Location the pen will be at when it finishes.
Definition: plotter_hpgl.h:187