KiCad PCB EDA Suite
HPGL_plotter.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2017 KiCad Developers, see AUTHORS.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 <eda_base_frame.h>
201 #include <base_struct.h>
202 #include <plotter.h>
203 #include <macros.h>
204 #include <kicad_string.h>
206 #include <math/util.h> // for KiROUND
207 
208 
209 // The hpgl command to close a polygon def, fill it and plot outline:
210 // PM 2; ends the polygon definition and closes it if not closed
211 // FP; fills the polygon
212 // EP; draws the polygon outline. It usually gives a better look to the filled polygon
213 static const char hpgl_end_polygon_cmd[] = "PM 2; FP; EP;\n";
214 
215 // HPGL scale factor (1 Plotter Logical Unit = 1/40mm = 25 micrometers)
216 // PLUsPERDECIMIL = (25.4 / 10000) / 0.025
217 static const double PLUsPERDECIMIL = 0.1016;
218 
220 {
221  SetPenSpeed( 40 ); // Default pen speed = 40 cm/s; Pen speed is *always* in cm
222  SetPenNumber( 1 ); // Default pen num = 1
223  SetPenDiameter( 0.0 );
224 }
225 
226 void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
227  double aScale, bool aMirror )
228 {
229  plotOffset = aOffset;
230  plotScale = aScale;
231  m_IUsPerDecimil = aIusPerDecimil;
232  iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
233  /* Compute the paper size in IUs */
235  paperSize.x *= 10.0 * aIusPerDecimil;
236  paperSize.y *= 10.0 * aIusPerDecimil;
237  m_plotMirror = aMirror;
238 }
239 
240 
245 {
246  wxASSERT( outputFile );
247  fprintf( outputFile, "IN;VS%d;PU;PA;SP%d;\n", penSpeed, penNumber );
248 
249  // Set HPGL Pen Thickness (in mm) (usefull in polygon fill command)
250  double penThicknessMM = userToDeviceSize( penDiameter )/40;
251  fprintf( outputFile, "PT %.1f;\n", penThicknessMM );
252 
253  return true;
254 }
255 
256 
261 {
262  wxASSERT( outputFile );
263  fputs( "PU;PA;SP0;\n", outputFile );
264  fclose( outputFile );
265  outputFile = NULL;
266  return true;
267 }
268 
269 
270 void HPGL_PLOTTER::SetPenDiameter( double diameter )
271 {
272  penDiameter = diameter;
273 }
274 
278 void HPGL_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
279 {
280  wxASSERT( outputFile );
281  DPOINT p2dev = userToDeviceCoordinates( p2 );
282  MoveTo( p1 );
283  fprintf( outputFile, "EA %.0f,%.0f;\n", p2dev.x, p2dev.y );
284  PenFinish();
285 }
286 
287 
288 // HPGL circle
289 void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill,
290  int width )
291 {
292  wxASSERT( outputFile );
293  double radius = userToDeviceSize( diameter / 2 );
294  SetCurrentLineWidth( width );
295 
296  if( fill == FILLED_SHAPE )
297  {
298  // Draw the filled area
299  MoveTo( centre );
300  fprintf( outputFile, "PM 0; CI %g;\n", radius );
301  fprintf( outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines
302  PenFinish();
303  }
304 
305  if( radius > 0 )
306  {
307  MoveTo( centre );
308  fprintf( outputFile, "CI %g;\n", radius );
309  PenFinish();
310  }
311 }
312 
313 
318 void HPGL_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
319  FILL_T aFill, int aWidth, void * aData )
320 {
321  if( aCornerList.size() <= 1 )
322  return;
323 
324  SetCurrentLineWidth( aWidth );
325  MoveTo( aCornerList[0] );
326 
327  if( aFill == FILLED_SHAPE )
328  {
329  // Draw the filled area
331  fprintf( outputFile, "PM 0;\n" ); // Start polygon
332 
333  for( unsigned ii = 1; ii < aCornerList.size(); ++ii )
334  LineTo( aCornerList[ii] );
335 
336  int ii = aCornerList.size() - 1;
337 
338  if( aCornerList[ii] != aCornerList[0] )
339  LineTo( aCornerList[0] );
340 
341  fprintf( outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines
342  }
343  else
344  {
345  // Plot only the polygon outline.
346  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
347  LineTo( aCornerList[ii] );
348 
349  // Always close polygon if filled.
350  if( aFill )
351  {
352  int ii = aCornerList.size() - 1;
353 
354  if( aCornerList[ii] != aCornerList[0] )
355  LineTo( aCornerList[0] );
356  }
357  }
358 
359  PenFinish();
360 }
361 
362 
366 void HPGL_PLOTTER::penControl( char plume )
367 {
368  wxASSERT( outputFile );
369 
370  switch( plume )
371  {
372  case 'U':
373 
374  if( penState != 'U' )
375  {
376  fputs( "PU;", outputFile );
377  penState = 'U';
378  }
379 
380  break;
381 
382  case 'D':
383 
384  if( penState != 'D' )
385  {
386  fputs( "PD;", outputFile );
387  penState = 'D';
388  }
389 
390  break;
391 
392  case 'Z':
393  fputs( "PU;", outputFile );
394  penState = 'U';
395  penLastpos.x = -1;
396  penLastpos.y = -1;
397  break;
398  }
399 }
400 
401 
402 void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
403 {
404  wxASSERT( outputFile );
405 
406  if( plume == 'Z' )
407  {
408  penControl( 'Z' );
409  return;
410  }
411 
412  penControl( plume );
413  DPOINT pos_dev = userToDeviceCoordinates( pos );
414 
415  if( penLastpos != pos )
416  fprintf( outputFile, "PA %.0f,%.0f;\n", pos_dev.x, pos_dev.y );
417 
418  penLastpos = pos;
419 }
420 
421 
426 {
427  wxASSERT( outputFile );
428 
429  switch( dashed )
430  {
432  fprintf( outputFile, "LT -2 4 1;\n" );
433  break;
434  case PLOT_DASH_TYPE::DOT:
435  fprintf( outputFile, "LT -1 2 1;\n" );
436  break;
438  fprintf( outputFile, "LT -4 6 1;\n" );
439  break;
440  default:
441  fputs( "LT;\n", outputFile );
442  }
443 }
444 
445 
446 void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end,
447  int width, EDA_DRAW_MODE_T tracemode, void* aData )
448 {
449  wxASSERT( outputFile );
450  wxPoint center;
451  wxSize size;
452 
453  // Suppress overlap if pen is too big
454  if( penDiameter >= width )
455  {
456  MoveTo( start );
457  FinishTo( end );
458  }
459  else
460  segmentAsOval( start, end, width, tracemode );
461 }
462 
463 
464 /* Plot an arc:
465  * Center = center coord
466  * Stangl, endAngle = angle of beginning and end
467  * Radius = radius of the arc
468  * Command
469  * PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, NbSegm; PU;
470  * Or PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, PU;
471  */
472 void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
473  FILL_T fill, int width )
474 {
475  wxASSERT( outputFile );
476  double angle;
477 
478  if( radius <= 0 )
479  return;
480 
481  DPOINT centre_dev = userToDeviceCoordinates( centre );
482 
483  if( m_plotMirror )
484  angle = StAngle - EndAngle;
485  else
486  angle = EndAngle - StAngle;
487 
489  angle /= 10;
490 
491  // Calculate arc start point:
492  wxPoint cmap;
493  cmap.x = centre.x + KiROUND( cosdecideg( radius, StAngle ) );
494  cmap.y = centre.y - KiROUND( sindecideg( radius, StAngle ) );
495  DPOINT cmap_dev = userToDeviceCoordinates( cmap );
496 
497  fprintf( outputFile,
498  "PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,",
499  cmap_dev.x, cmap_dev.y,
500  centre_dev.x, centre_dev.y );
501  fprintf( outputFile, "%.0f", angle );
502  fprintf( outputFile, ";PU;\n" );
503  PenFinish();
504 }
505 
506 
507 /* Plot oval pad.
508  */
509 void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient,
510  EDA_DRAW_MODE_T trace_mode, void* aData )
511 {
512  wxASSERT( outputFile );
513  int deltaxy, cx, cy;
514  wxSize size( aSize );
515 
516  /* The pad will be drawn as an oblong shape with size.y > size.x
517  * (Oval vertical orientation 0)
518  */
519  if( size.x > size.y )
520  {
521  std::swap( size.x, size.y );
522  orient = AddAngles( orient, 900 );
523  }
524 
525  deltaxy = size.y - size.x; // distance between centers of the oval
526 
527  if( trace_mode == FILLED )
528  {
529  FlashPadRect( pos, wxSize( size.x, deltaxy + KiROUND( penDiameter ) ),
530  orient, trace_mode, aData );
531  cx = 0; cy = deltaxy / 2;
532  RotatePoint( &cx, &cy, orient );
533  FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
534  cx = 0; cy = -deltaxy / 2;
535  RotatePoint( &cx, &cy, orient );
536  FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
537  }
538  else // Plot in outline mode.
539  {
540  sketchOval( pos, size, orient, KiROUND( penDiameter ) );
541  }
542 }
543 
544 
545 /* Plot round pad or via.
546  */
547 void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
548  EDA_DRAW_MODE_T trace_mode, void* aData )
549 {
550  wxASSERT( outputFile );
551  DPOINT pos_dev = userToDeviceCoordinates( pos );
552 
553  int radius = diametre / 2;
554 
555  if( trace_mode == FILLED )
556  {
557  // if filled mode, the pen diameter is removed from diameter
558  // to keep the pad size
559  radius -= KiROUND( penDiameter ) / 2;
560  }
561 
562  if( radius < 0 )
563  radius = 0;
564 
565  double rsize = userToDeviceSize( radius );
566 
567  if( trace_mode == FILLED ) // Plot in filled mode.
568  {
569  // A filled polygon uses always the current point to start the polygon.
570  // Gives a correct current starting point for the circle
571  MoveTo( wxPoint( pos.x+radius, pos.y ) );
572  // Plot filled area and its outline
573  fprintf( outputFile, "PM 0; PA %.0f,%.0f;CI %.0f;%s",
574  pos_dev.x, pos_dev.y, rsize, hpgl_end_polygon_cmd );
575  }
576  else
577  {
578  // Draw outline only:
579  fprintf( outputFile, "PA %.0f,%.0f;CI %.0f;\n",
580  pos_dev.x, pos_dev.y, rsize );
581  }
582 
583  PenFinish();
584 }
585 
586 
587 void HPGL_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize,
588  double orient, EDA_DRAW_MODE_T trace_mode, void* aData )
589 {
590  // Build rect polygon:
591  std::vector<wxPoint> corners;
592 
593  int dx = padsize.x / 2;
594  int dy = padsize.y / 2;
595 
596  if( trace_mode == FILLED )
597  {
598  // in filled mode, the pen diameter is removed from size
599  // to compensate the extra size due to this pen size
600  dx -= KiROUND( penDiameter ) / 2;
601  dx = std::max( dx, 0);
602  dy -= KiROUND( penDiameter ) / 2;
603  dy = std::max( dy, 0);
604  }
605 
606 
607  corners.emplace_back( - dx, - dy );
608  corners.emplace_back( - dx, + dy );
609  corners.emplace_back( + dx, + dy );
610  corners.emplace_back( + dx, - dy );
611  // Close polygon
612  corners.emplace_back( - dx, - dy );
613 
614  for( unsigned ii = 0; ii < corners.size(); ii++ )
615  {
616  RotatePoint( &corners[ii], orient );
617  corners[ii] += pos;
618  }
619 
620  PlotPoly( corners, trace_mode == FILLED ? FILLED_SHAPE : NO_FILL );
621 }
622 
623 
624 void HPGL_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
625  int aCornerRadius, double aOrient,
626  EDA_DRAW_MODE_T aTraceMode, void* aData )
627 {
628  SHAPE_POLY_SET outline;
629 
630  wxSize size = aSize;
631 
632  if( aTraceMode == FILLED )
633  {
634  // in filled mode, the pen diameter is removed from size
635  // to keep the pad size
636  size.x -= KiROUND( penDiameter ) / 2;
637  size.x = std::max( size.x, 0);
638  size.y -= KiROUND( penDiameter ) / 2;
639  size.y = std::max( size.y, 0);
640 
641  // keep aCornerRadius to a value < min size x,y < 2:
642  aCornerRadius = std::min( aCornerRadius, std::min( size.x, size.y ) /2 );
643  }
644 
645  TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient,
646  aCornerRadius, 0.0, 0, GetPlotterArcHighDef() );
647 
648  // TransformRoundRectToPolygon creates only one convex polygon
649  std::vector<wxPoint> cornerList;
650  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
651  cornerList.reserve( poly.PointCount() );
652 
653  for( int ii = 0; ii < poly.PointCount(); ++ii )
654  cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
655 
656  if( cornerList.back() != cornerList.front() )
657  cornerList.push_back( cornerList.front() );
658 
659  PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL );
660 }
661 
662 void HPGL_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
663  SHAPE_POLY_SET* aPolygons,
664  EDA_DRAW_MODE_T aTraceMode, void* aData )
665 {
666  std::vector< wxPoint > cornerList;
667 
668  for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
669  {
670  SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
671 
672  cornerList.clear();
673  cornerList.reserve( poly.PointCount() );
674 
675  for( int ii = 1; ii < poly.PointCount(); ++ii )
676  cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
677 
678  if( cornerList.back() != cornerList.front() )
679  cornerList.push_back( cornerList.front() );
680 
681  PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL );
682  }
683 }
684 
685 
686 void HPGL_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCorners,
687  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData )
688 {
689  std::vector< wxPoint > cornerList;
690  cornerList.reserve( 5 );
691 
692  for( int ii = 0; ii < 4; ii++ )
693  {
694  wxPoint coord( aCorners[ii] );
695  RotatePoint( &coord, aPadOrient );
696  coord += aPadPos;
697  cornerList.push_back( coord );
698  }
699 
700  // Close polygon
701  cornerList.push_back( cornerList.front() );
702 
703  PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL );
704 }
705 
706 
708  int aRadius, int aCornerCount,
709  double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData )
710 {
711  // Do nothing
712  wxASSERT( 0 );
713 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:267
virtual bool EndPlot() override
HPGL end of plot: pen return and release.
int penSpeed
Definition: plotter.h:684
void PenFinish()
Definition: plotter.h:273
int OutlineCount() const
Returns the number of outlines in the set
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:
virtual void SetPenDiameter(double diameter)
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
char penState
Definition: plotter.h:592
void NORMALIZE_ANGLE_180(T &Angle)
Definition: trigo.h:373
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
double m_IUsPerDecimil
Definition: plotter.h:571
int PointCount() const
Function PointCount()
virtual bool StartPlot() override
At the start of the HPGL plot pen speed and number are requested.
wxPoint plotOffset
Plot offset (in IUs)
Definition: plotter.h:577
wxPoint penLastpos
Definition: plotter.h:593
PAGE_INFO pageInfo
Definition: plotter.h:598
This file contains miscellaneous commonly used macros and functions.
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
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void LineTo(const wxPoint &pos)
Definition: plotter.h:262
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:119
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plotter.h:581
#define NULL
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
HPGL doesn't handle line thickness or color.
Definition: plotter.h:626
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:323
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
EDA_DRAW_MODE_T
Definition: eda_text.h:63
virtual void SetPenSpeed(int speed)
Definition: plotter.h:636
static const char hpgl_end_polygon_cmd[]
Base window classes and related definitions.
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:565
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadOval
const wxSize & GetSizeMils() const
Definition: page_info.h:143
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)
Definition: plotter.cpp:125
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRect
PLOT_DASH_TYPE
Enum for choosing dashed line type.
Definition: plotter.h:87
int penNumber
Definition: plotter.h:685
void MoveTo(const wxPoint &pos)
Definition: plotter.h:257
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:94
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:427
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:418
virtual void FlashRegularPolygon(const wxPoint &aShapePos, int aDiameter, int aCornerCount, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
Flash a regular polygon.
SHAPE_LINE_CHAIN.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double penDiameter
Definition: plotter.h:686
virtual void SetPenNumber(int number)
Definition: plotter.h:641
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plotter.h:586
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
int GetPlotterArcHighDef() const
Definition: plotter.h:223
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:42
static const double PLUsPERDECIMIL
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
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aError)
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corner...
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plotter.h:574
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.
Definition: plotter.cpp:438
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 SetDash(PLOT_DASH_TYPE dashed) override
HPGL supports dashed lines.
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)
Definition: plotter.cpp:459
wxSize paperSize
Definition: plotter.h:599
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.