KiCad PCB EDA Suite
common_plotHPGL_functions.cpp
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 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2016 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
33 /* Some HPGL commands:
34  * Note: the HPGL unit is 25 micrometers
35  * All commands MUST be terminated by a semi-colon or a linefeed.
36  * Spaces can NOT be substituted for required commas in the syntax of a command.
37  *
38  *
39  * AA (Arc Absolute): Angle is a floating point # (requires non integer value)
40  * Draws an arc with the center at (X,Y).
41  * A positive angle creates a counter-clockwise arc.
42  * If the chord angle is specified,
43  * this will be the number of degrees used for stepping around the arc.
44  * If no value is given then a default value of five degrees is used.
45  * AA x, y, a {,b};
46  *
47  * AR (Arc Relative):
48  * AR Dx, Dy, a {, b};
49  *
50  * CA (Alternate Character Set):
51  * CA {n};
52  *
53  * CI (Circle):
54  * CI r {,b};
55  *
56  * CP (Character Plot):
57  * CP {h, v};
58  * h [-127.9999 .. 127.9999] Anzahl der Zeichen horizontal
59  * v [-127.9999 .. 127.9999] Anzahl der Zeichen vertikal
60  *
61  * CS (Standard Character Set):
62  * CS {n};
63  *
64  * DR (Relative Direction for Label Text):
65  * DR s, a;
66  *
67  * DI (Absolute Direction for Label Text):
68  * DI {s, a};
69  *
70  * DT (Define Terminator - this character becomes unavailable except to terminate a label string.
71  * Default is ^C control-C):
72  * DT t;
73  *
74  * EA (rEctangle Absolute - Unfilled, from current position to diagonal x,y):
75  * EA x, y;
76  *
77  * ER (rEctangle Relative - Unfilled, from current position to diagonal x,y):
78  * ER x,y;
79  *
80  * FT (Fill Type):
81  * FT {s {,l {a}}};
82  *
83  * IM (Input Mask):
84  * IM {f};
85  *
86  * IN (Initialize): This command instructs the controller to begin processing the HPGL plot file.
87  * Without this, the commands in the file are received but never executed.
88  * If multiple IN s are found during execution of the file,
89  * the controller performs a Pause/Cancel operation.
90  * All motion from the previous job, yet to be executed, is lost,
91  * and the new information is executed.
92  * IN;
93  *
94  * IP Input P1 and P2:
95  * IP {P1x, P1y {, P2x, P2y}};
96  *
97  * IW (Input Window):
98  * IW {XUL, YUL, XOR, YOR};
99  *
100  * LB (Label):
101  * LB c1 .. cn t;
102  *
103  * PA (Plot Absolute): Moves to an absolute HPGL position and sets absolute mode for
104  * future PU and PD commands. If no arguments follow the command,
105  * only absolute mode is set.
106  * PA {x1, y1 {{PU|PD|,} ..., ..., xn, yn}};
107  * P1x, P1y, P2x, P2y [Integer in ASCII]
108  *
109  * PD (Pen Down): Executes <current pen> pen then moves to the requested position
110  * if one is specified. This position is dependent on whether absolute
111  * or relative mode is set. This command performs no motion in 3-D mode,
112  * but the outputs and feedrates are affected.
113  * PD {x, y};
114  *
115  * PM Polygon mode
116  * associated commands:
117  * PM2 End polygon mode
118  * FP Fill polygon
119  * EP Draw polygon outline
120  *
121  * PR (Plot Relative): Moves to the relative position specified and sets relative mode
122  * for future PU and PD commands.
123  * If no arguments follow the command, only relative mode is set.
124  * PR {Dx1, Dy1 {{PU|PD|,} ..., ..., Dxn, Dyn}};
125  *
126  * PS (Paper Size):
127  * PS {n};
128  *
129  * PT (Pen Thickness): in mm
130  * PT {l};
131  *
132  * PU (Pen Up): Executes <current pen> pen then moves to the requested position
133  * if one is specified. This position is dependent on whether absolute
134  * or relative mode is set.
135  * This command performs no motion in 3-D mode, but the outputs
136  * and feedrates are affected.
137  * PU {x, y};
138  *
139  * RA (Rectangle Absolute - Filled, from current position to diagonal x,y):
140  * RA x, y;
141  *
142  * RO (Rotate Coordinate System):
143  * RO;
144  *
145  * RR (Rectangle Relative - Filled, from current position to diagonal x,y):
146  * RR x, y;
147  *
148  * SA (Select Alternate Set):
149  * SA;
150  *
151  * SC (Scale):
152  * SC {Xmin, Xmax, Ymin, Ymax};
153  *
154  * SI (Absolute Character Size):
155  * SI b, h;
156  * b [-127.9999 .. 127.9999, keine 0]
157  * h [-127.9999 .. 127.9999, keine 0]
158  *
159  * SL (Character Slant):
160  * SL {a};
161  * a [-3.5 .. -0.5, 0.5 .. 3.5]
162 *
163  * SP (Select Pen): Selects a new pen or tool for use.
164  * If no pen number or a value of zero is given,
165  * the controller performs an EOF (end of file command).
166  * Once an EOF is performed, no motion is executed,
167  * until a new IN command is received.
168  * SP n;
169  *
170  * SR (Relative Character Size):
171  * SR {b, h};
172  * b [-127.9999 .. 127.9999, keine 0]
173  * h [-127.9999 .. 127.9999, keine 0]
174  *
175  * SS (Select Standard Set):
176  * SS;
177  *
178  * TL (Tick Length):
179  * TL {tp {, tm}};
180  *
181  * UC (User Defined Character):
182  * UC {i,} x1, y1, {i,} x2, y2, ... {i,} xn, yn;
183  *
184  * VS (Velocity Select):
185  * VS {v {, n}};
186  * v [1 .. 40] in cm/s
187  * n [1 .. 8]
188  *
189  * XT (X Tick):
190  * XT;
191  *
192  * YT (Y Tick):
193  * YT;
194  */
195 
196 
197 #include <fctsys.h>
198 #include <gr_basic.h>
199 #include <trigo.h>
200 #include <wxstruct.h>
201 #include <base_struct.h>
202 #include <plot_common.h>
203 #include <macros.h>
204 #include <kicad_string.h>
206 
207 // The hpgl command to close a polygon def, fill it and plot outline:
208 // PM 2; ends the polygon definition and closes it if not closed
209 // FP; fills the polygon
210 // EP; draws the polygon outline. It usually gives a better look to the filled polygon
211 static const char hpgl_end_polygon_cmd[] = "PM 2; FP; EP;\n";
212 
213 // HPGL scale factor (1 PLU = 1/40mm = 25 micrometers)
214 static const double PLUsPERDECIMIL = 0.102041;
215 
217 {
218  SetPenSpeed( 40 ); // Default pen speed = 40 cm/s; Pen speed is *always* in cm
219  SetPenNumber( 1 ); // Default pen num = 1
220  SetPenDiameter( 0.0 );
221 }
222 
223 void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
224  double aScale, bool aMirror )
225 {
226  plotOffset = aOffset;
227  plotScale = aScale;
228  m_IUsPerDecimil = aIusPerDecimil;
229  iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
230  /* Compute the paper size in IUs */
232  paperSize.x *= 10.0 * aIusPerDecimil;
233  paperSize.y *= 10.0 * aIusPerDecimil;
234  SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead
235  m_plotMirror = aMirror;
236 }
237 
238 
243 {
244  wxASSERT( outputFile );
245  fprintf( outputFile, "IN;VS%d;PU;PA;SP%d;\n", penSpeed, penNumber );
246 
247  // Set HPGL Pen Thickness (in mm) (usefull in polygon fill command)
248  double penThicknessMM = userToDeviceSize( penDiameter )/40;
249  fprintf( outputFile, "PT %.1f;\n", penThicknessMM );
250 
251  return true;
252 }
253 
254 
259 {
260  wxASSERT( outputFile );
261  fputs( "PU;PA;SP0;\n", outputFile );
262  fclose( outputFile );
263  outputFile = NULL;
264  return true;
265 }
266 
267 
268 void HPGL_PLOTTER::SetPenDiameter( double diameter )
269 {
270  penDiameter = diameter;
271 }
272 
276 void HPGL_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
277 {
278  wxASSERT( outputFile );
279  DPOINT p2dev = userToDeviceCoordinates( p2 );
280  MoveTo( p1 );
281  fprintf( outputFile, "EA %.0f,%.0f;\n", p2dev.x, p2dev.y );
282  PenFinish();
283 }
284 
285 
286 // HPGL circle
287 void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill,
288  int width )
289 {
290  wxASSERT( outputFile );
291  double radius = userToDeviceSize( diameter / 2 );
292  SetCurrentLineWidth( width );
293 
294  if( fill == FILLED_SHAPE )
295  {
296  // Draw the filled area
297  MoveTo( centre );
298  fprintf( outputFile, "PM 0; CI %g;\n", radius );
299  fprintf( outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines
300  PenFinish();
301  }
302 
303  if( radius > 0 )
304  {
305  MoveTo( centre );
306  fprintf( outputFile, "CI %g;\n", radius );
307  PenFinish();
308  }
309 }
310 
311 
316 void HPGL_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
317  FILL_T aFill, int aWidth, void * aData )
318 {
319  if( aCornerList.size() <= 1 )
320  return;
321 
322  SetCurrentLineWidth( aWidth );
323  MoveTo( aCornerList[0] );
324 
325  if( aFill == FILLED_SHAPE )
326  {
327  // Draw the filled area
329  fprintf( outputFile, "PM 0;\n" ); // Start polygon
330 
331  for( unsigned ii = 1; ii < aCornerList.size(); ++ii )
332  LineTo( aCornerList[ii] );
333 
334  int ii = aCornerList.size() - 1;
335 
336  if( aCornerList[ii] != aCornerList[0] )
337  LineTo( aCornerList[0] );
338 
339  fprintf( outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines
340  }
341  else
342  {
343  // Plot only the polygon outline.
344  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
345  LineTo( aCornerList[ii] );
346 
347  // Always close polygon if filled.
348  if( aFill )
349  {
350  int ii = aCornerList.size() - 1;
351 
352  if( aCornerList[ii] != aCornerList[0] )
353  LineTo( aCornerList[0] );
354  }
355  }
356 
357  PenFinish();
358 }
359 
360 
364 void HPGL_PLOTTER::penControl( char plume )
365 {
366  wxASSERT( outputFile );
367 
368  switch( plume )
369  {
370  case 'U':
371 
372  if( penState != 'U' )
373  {
374  fputs( "PU;", outputFile );
375  penState = 'U';
376  }
377 
378  break;
379 
380  case 'D':
381 
382  if( penState != 'D' )
383  {
384  fputs( "PD;", outputFile );
385  penState = 'D';
386  }
387 
388  break;
389 
390  case 'Z':
391  fputs( "PU;", outputFile );
392  penState = 'U';
393  penLastpos.x = -1;
394  penLastpos.y = -1;
395  break;
396  }
397 }
398 
399 
400 void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
401 {
402  wxASSERT( outputFile );
403 
404  if( plume == 'Z' )
405  {
406  penControl( 'Z' );
407  return;
408  }
409 
410  penControl( plume );
411  DPOINT pos_dev = userToDeviceCoordinates( pos );
412 
413  if( penLastpos != pos )
414  fprintf( outputFile, "PA %.0f,%.0f;\n", pos_dev.x, pos_dev.y );
415 
416  penLastpos = pos;
417 }
418 
419 
423 void HPGL_PLOTTER::SetDash( bool dashed )
424 {
425  wxASSERT( outputFile );
426 
427  if( dashed )
428  fputs( "LI 2;\n", outputFile );
429  else
430  fputs( "LI;\n", outputFile );
431 }
432 
433 
434 void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end,
435  int width, EDA_DRAW_MODE_T tracemode, void* aData )
436 {
437  wxASSERT( outputFile );
438  wxPoint center;
439  wxSize size;
440 
441  // Suppress overlap if pen is too big
442  if( penDiameter >= width )
443  {
444  MoveTo( start );
445  FinishTo( end );
446  }
447  else
448  segmentAsOval( start, end, width, tracemode );
449 }
450 
451 
452 /* Plot an arc:
453  * Center = center coord
454  * Stangl, endAngle = angle of beginning and end
455  * Radius = radius of the arc
456  * Command
457  * PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, NbSegm; PU;
458  * Or PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, PU;
459  */
460 void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
461  FILL_T fill, int width )
462 {
463  wxASSERT( outputFile );
464  double angle;
465 
466  if( radius <= 0 )
467  return;
468 
469  DPOINT centre_dev = userToDeviceCoordinates( centre );
470 
471  if( m_plotMirror )
472  angle = StAngle - EndAngle;
473  else
474  angle = EndAngle - StAngle;
475 
476  NORMALIZE_ANGLE_180( angle );
477  angle /= 10;
478 
479  // Calculate arc start point:
480  wxPoint cmap;
481  cmap.x = centre.x + KiROUND( cosdecideg( radius, StAngle ) );
482  cmap.y = centre.y - KiROUND( sindecideg( radius, StAngle ) );
483  DPOINT cmap_dev = userToDeviceCoordinates( cmap );
484 
485  fprintf( outputFile,
486  "PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,",
487  cmap_dev.x, cmap_dev.y,
488  centre_dev.x, centre_dev.y );
489  fprintf( outputFile, "%.0f", angle );
490  fprintf( outputFile, ";PU;\n" );
491  PenFinish();
492 }
493 
494 
495 /* Plot oval pad.
496  */
497 void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient,
498  EDA_DRAW_MODE_T trace_mode, void* aData )
499 {
500  wxASSERT( outputFile );
501  int deltaxy, cx, cy;
502  wxSize size( aSize );
503 
504  /* The pad will be drawn as an oblong shape with size.y > size.x
505  * (Oval vertical orientation 0)
506  */
507  if( size.x > size.y )
508  {
509  std::swap( size.x, size.y );
510  orient = AddAngles( orient, 900 );
511  }
512 
513  deltaxy = size.y - size.x; // distance between centers of the oval
514 
515  if( trace_mode == FILLED )
516  {
517  FlashPadRect( pos, wxSize( size.x, deltaxy + KiROUND( penDiameter ) ),
518  orient, trace_mode, aData );
519  cx = 0; cy = deltaxy / 2;
520  RotatePoint( &cx, &cy, orient );
521  FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
522  cx = 0; cy = -deltaxy / 2;
523  RotatePoint( &cx, &cy, orient );
524  FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
525  }
526  else // Plot in outline mode.
527  {
528  sketchOval( pos, size, orient, KiROUND( penDiameter ) );
529  }
530 }
531 
532 
533 /* Plot round pad or via.
534  */
535 void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
536  EDA_DRAW_MODE_T trace_mode, void* aData )
537 {
538  wxASSERT( outputFile );
539  DPOINT pos_dev = userToDeviceCoordinates( pos );
540 
541  int radius = diametre / 2;
542 
543  if( trace_mode == FILLED )
544  {
545  // if filled mode, the pen diameter is removed from diameter
546  // to keep the pad size
547  radius -= KiROUND( penDiameter ) / 2;
548  }
549 
550  if( radius < 0 )
551  radius = 0;
552 
553  double rsize = userToDeviceSize( radius );
554 
555  if( trace_mode == FILLED ) // Plot in filled mode.
556  {
557  // A filled polygon uses always the current point to start the polygon.
558  // Gives a correct current starting point for the circle
559  MoveTo( wxPoint( pos.x+radius, pos.y ) );
560  // Plot filled area and its outline
561  fprintf( outputFile, "PM 0; PA %.0f,%.0f;CI %.0f;%s",
562  pos_dev.x, pos_dev.y, rsize, hpgl_end_polygon_cmd );
563  }
564  else
565  {
566  // Draw outline only:
567  fprintf( outputFile, "PA %.0f,%.0f;CI %.0f;\n",
568  pos_dev.x, pos_dev.y, rsize );
569  }
570 
571  PenFinish();
572 }
573 
574 
575 void HPGL_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize,
576  double orient, EDA_DRAW_MODE_T trace_mode, void* aData )
577 {
578  // Build rect polygon:
579  std::vector<wxPoint> corners;
580 
581  int dx = padsize.x / 2;
582  int dy = padsize.y / 2;
583 
584  if( trace_mode == FILLED )
585  {
586  // in filled mode, the pen diameter is removed from size
587  // to compensate the extra size due to this pen size
588  dx -= KiROUND( penDiameter ) / 2;
589  dx = std::max( dx, 0);
590  dy -= KiROUND( penDiameter ) / 2;
591  dy = std::max( dy, 0);
592  }
593 
594 
595  corners.push_back( wxPoint( - dx, - dy ) );
596  corners.push_back( wxPoint( - dx, + dy ) );
597  corners.push_back( wxPoint( + dx, + dy ) );
598  corners.push_back( wxPoint( + dx, - dy ) );
599 
600 
601  for( unsigned ii = 0; ii < corners.size(); ii++ )
602  {
603  RotatePoint( &corners[ii], orient );
604  corners[ii] += pos;
605  }
606 
607  PlotPoly( corners, trace_mode == FILLED ? FILLED_SHAPE : NO_FILL );
608 }
609 
610 
611 void HPGL_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
612  int aCornerRadius, double aOrient,
613  EDA_DRAW_MODE_T aTraceMode, void* aData )
614 {
615  SHAPE_POLY_SET outline;
616  const int segmentToCircleCount = 32;
617 
618  wxSize size = aSize;
619 
620  if( aTraceMode == FILLED )
621  {
622  // in filled mode, the pen diameter is removed from size
623  // to keep the pad size
624  size.x -= KiROUND( penDiameter ) / 2;
625  size.x = std::max( size.x, 0);
626  size.y -= KiROUND( penDiameter ) / 2;
627  size.y = std::max( size.y, 0);
628 
629  // keep aCornerRadius to a value < min size x,y < 2:
630  aCornerRadius = std::min( aCornerRadius, std::min( size.x, size.y ) /2 );
631  }
632 
633  TransformRoundRectToPolygon( outline, aPadPos, size, aOrient,
634  aCornerRadius, segmentToCircleCount );
635 
636  // TransformRoundRectToPolygon creates only one convex polygon
637  std::vector< wxPoint > cornerList;
638  cornerList.reserve( segmentToCircleCount + 4 );
639  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
640 
641  for( int ii = 0; ii < poly.PointCount(); ++ii )
642  cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
643 
644  PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL );
645 }
646 
647 void HPGL_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
648  SHAPE_POLY_SET* aPolygons,
649  EDA_DRAW_MODE_T aTraceMode, void* aData )
650 {
651  std::vector< wxPoint > cornerList;
652 
653  for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
654  {
655  SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
656 
657  cornerList.clear();
658  cornerList.reserve( poly.PointCount() );
659 
660  for( int ii = 1; ii < poly.PointCount(); ++ii )
661  cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
662 
663  PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL );
664  }
665 }
666 
667 
668 void HPGL_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCorners,
669  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData )
670 {
671  std::vector< wxPoint > cornerList;
672  cornerList.reserve( 4 );
673 
674  for( int ii = 0; ii < 4; ii++ )
675  {
676  wxPoint coord( aCorners[ii] );
677  RotatePoint( &coord, aPadOrient );
678  coord += aPadPos;
679  cornerList.push_back( coord );
680  }
681 
682  PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL );
683 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
virtual bool EndPlot() override
HPGL end of plot: pen return and release.
void PenFinish()
Definition: plot_common.h:247
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCircle
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
HPGL polygon:
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
int PointCount() const
Function PointCount()
void TransformRoundRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, int aCircleToSegmentsCount)
Function TransformRoundRectToPolygon convert a rectangle with rounded corners to a polygon Convert ar...
virtual void SetPenDiameter(double diameter)
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
char penState
Current pen state: 'U', 'D' or 'Z' (see PenTo)
Definition: plot_common.h:539
void NORMALIZE_ANGLE_180(T &Angle)
Definition: trigo.h:292
int OutlineCount() const
Returns the number of outlines in the set
double m_IUsPerDecimil
Definition: plot_common.h:516
virtual void SetDash(bool dashed) override
HPGL supports dashed lines.
virtual bool StartPlot() override
At the start of the HPGL plot pen speed and number are requested.
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
Definition: plot_common.h:578
wxPoint plotOffset
Plot offset (in IUs)
Definition: plot_common.h:522
wxPoint penLastpos
Last pen positions; set to -1,-1 when the pen is at rest.
Definition: plot_common.h:541
PAGE_INFO pageInfo
Definition: plot_common.h:545
static const double PLUsPERDECIMIL
This file contains miscellaneous commonly used macros and functions.
const wxSize & GetSizeMils() const
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
HPGL rectangle: fill not supported.
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRoundRect
static const char hpgl_end_polygon_cmd[]
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plot_common.h:526
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
HPGL doesn't handle line thickness or color.
Definition: plot_common.h:572
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:246
Class SHAPE_POLY_SET.
Base window classes and related definitions.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
EDA_DRAW_MODE_T
Definition: eda_text.h:62
virtual void SetPenSpeed(int speed)
Definition: plot_common.h:583
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:510
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadOval
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRect
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:311
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:302
#define max(a, b)
Definition: auxiliary.h:86
Class SHAPE_LINE_CHAIN.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double penDiameter
Definition: plot_common.h:631
virtual void SetPenNumber(int number)
Definition: plot_common.h:588
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:56
VECTOR2I & Point(int aIndex)
Function Point()
Basic classes for most KiCad items.
void penControl(char plume)
Pen control logic (remove redundant pen activations)
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCustom
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:519
void segmentAsOval(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode)
Cdonvert a thick segment and plot it as an oval.
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadTrapez flash a trapezoidal pad
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
wxSize paperSize
Paper size in IU - not in mils.
Definition: plot_common.h:547
#define min(a, b)
Definition: auxiliary.h:85
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.