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 SetCurrentLineWidth( int width, void* aData = nullptr ) override
73 {
74 // This is the truth
76 }
77
81 virtual void SetDash( int aLineWidth, LINE_STYLE aLineStyle ) override;
82
83 virtual void SetColor( const COLOR4D& color ) override {}
84
85 virtual void SetPenSpeed( int speed )
86 {
87 m_penSpeed = speed;
88 }
89
90 virtual void SetPenNumber( int number )
91 {
92 m_penNumber = number;
93 }
94
95 virtual void SetPenDiameter( double diameter );
96
97 virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
98 double aScale, bool aMirror ) override;
99 virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T aFill,
100 int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
101 virtual void Circle( const VECTOR2I& aCenter, int aDiameter, FILL_T aFill,
102 int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
103 virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
104 int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
105
106 virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
107 OUTLINE_MODE tracemode, void* aData ) override;
108
109 virtual void PenTo( const VECTOR2I& pos, char plume ) override;
110
111 virtual void FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter,
112 OUTLINE_MODE aTraceMode, void* aData ) override;
113 virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
114 const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
115 void* aData ) override;
116 virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
117 const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
118 void* aData ) override;
119 virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
120 int aCornerRadius, const EDA_ANGLE& aOrient,
121 OUTLINE_MODE aTraceMode, void* aData ) override;
122 virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
123 const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
124 OUTLINE_MODE aTraceMode, void* aData ) override;
125 virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
126 const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
127 void* aData ) override;
128 virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
129 const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
130 void* aData ) override;
131
132protected:
145 virtual void Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
146 const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill,
147 int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
148
155 bool startItem( const VECTOR2D& location );
156
158 void flushItem();
159
168 bool startOrAppendItem( const VECTOR2D& location, const wxString& content );
169
171 {
173 lift_before( false ),
174 lift_after( false ),
175 pen_returns( false ),
176 pen( 0 ),
178
181
185
188
191
196
200
201 int pen;
203 wxString content;
204 };
205
209 static void sortItems( std::list<HPGL_ITEM>& items );
210
212 static const char* lineStyleCommand( LINE_STYLE aLineStyle );
213
214protected:
223
224 std::list<HPGL_ITEM> m_items;
226};
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:225
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
HPGL supports dashed lines.
virtual void SetPenSpeed(int speed)
Definition: plotter_hpgl.h:85
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:218
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:90
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:220
EDA_ANGLE m_arcMinChordDegrees
Definition: plotter_hpgl.h:219
virtual void SetColor(const COLOR4D &color) override
Definition: plotter_hpgl.h:83
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
HPGL doesn't handle line thickness or color.
Definition: plotter_hpgl.h:72
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:221
std::list< HPGL_ITEM > m_items
Definition: plotter_hpgl.h:224
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:217
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:222
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
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:658
Represent a set of closed polygons.
FILL_T
Definition: eda_shape.h:54
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:203
bool pen_returns
Whether the pen returns to its original state after the command.
Definition: plotter_hpgl.h:199
BOX2D bbox
Bounding box of this item.
Definition: plotter_hpgl.h:187
LINE_STYLE dashType
Pen number for this command.
Definition: plotter_hpgl.h:202
bool lift_after
Whether the pen must be lifted after the command.
Definition: plotter_hpgl.h:195
bool lift_before
Whether the command should be executed with the pen lifted.
Definition: plotter_hpgl.h:190
VECTOR2D loc_start
Location the pen should start at.
Definition: plotter_hpgl.h:180
VECTOR2D loc_end
Location the pen will be at when it finishes.
Definition: plotter_hpgl.h:184