KiCad PCB EDA Suite
common_plotSVG_functions.cpp
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
10  * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, you may find one here:
24  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25  * or you may search the http://www.gnu.org website for the version 2 license,
26  * or you may write to the Free Software Foundation, Inc.,
27  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28  */
29 
30 /* Some info on basic items SVG format, used here:
31  * The root element of all SVG files is the <svg> element.
32  *
33  * The <g> element is used to group SVG shapes together.
34  * Once grouped you can transform the whole group of shapes as if it was a single shape.
35  * This is an advantage compared to a nested <svg> element
36  * which cannot be the target of transformation by itself.
37  *
38  * The <rect> element represents a rectangle.
39  * Using this element you can draw rectangles of various width, height,
40  * with different stroke (outline) and fill colors, with sharp or rounded corners etc.
41  *
42  * <svg xmlns="http://www.w3.org/2000/svg"
43  * xmlns:xlink="http://www.w3.org/1999/xlink">
44  *
45  * <rect x="10" y="10" height="100" width="100"
46  * style="stroke:#006600; fill: #00cc00"/>
47  *
48  * </svg>
49  *
50  * The <circle> element is used to draw circles.
51  * <circle cx="40" cy="40" r="24" style="stroke:#006600; fill:#00cc00"/>
52  *
53  * The <ellipse> element is used to draw ellipses.
54  * An ellipse is a circle that does not have equal height and width.
55  * Its radius in the x and y directions are different, in other words.
56  * <ellipse cx="40" cy="40" rx="30" ry="15"
57  * style="stroke:#006600; fill:#00cc00"/>
58  *
59  * The <line> element is used to draw lines.
60  *
61  * <line x1="0" y1="10" x2="0" y2="100" style="stroke:#006600;"/>
62  * <line x1="10" y1="10" x2="100" y2="100" style="stroke:#006600;"/>
63  *
64  * The <polyline> element is used to draw multiple connected lines
65  * Here is a simple example:
66  *
67  * <polyline points="0,0 30,0 15,30" style="stroke:#006600;"/>
68  *
69  * The <polygon> element is used to draw with multiple (3 or more) sides / edges.
70  * Here is a simple example:
71  *
72  * <polygon points="0,0 50,0 25,50" style="stroke:#660000; fill:#cc3333;"/>
73  *
74  * The <path> element is used to draw advanced shapes combined from lines and arcs,
75  * with or without fill.
76  * It is probably the most advanced and versatile SVG shape of them all.
77  * It is probably also the hardest element to master.
78  * <path d="M50,50
79  * A30,30 0 0,1 35,20
80  * L100,100
81  * M110,110
82  * L100,0"
83  * style="stroke:#660000; fill:none;"/>
84  *
85  * Draw an elliptic arc: it is one of basic path command:
86  * <path d="M(startx,starty) A(radiusx,radiusy)
87  * rotation-axe-x
88  * flag_arc_large,flag_sweep endx,endy">
89  * flag_arc_large: 0 = small arc > 180 deg, 1 = large arc > 180 deg
90  * flag_sweep : 0 = CCW, 1 = CW
91  * The center of ellipse is automatically calculated.
92  */
93 #include <fctsys.h>
94 #include <trigo.h>
95 #include <wxstruct.h>
96 #include <class_eda_rect.h>
97 #include <base_struct.h>
98 #include <common.h>
99 #include <plot_common.h>
100 #include <macros.h>
101 #include <kicad_string.h>
102 
103 
104 
111 static wxString XmlEsc( const wxString& aStr, bool isAttribute = false )
112 {
113  wxString escaped;
114 
115  escaped.reserve( aStr.length() );
116 
117  for( wxString::const_iterator it = aStr.begin(); it != aStr.end(); ++it )
118  {
119  const wxChar c = *it;
120 
121  switch( c )
122  {
123  case wxS( '<' ):
124  escaped.append( wxS( "&lt;" ) );
125  break;
126  case wxS( '>' ):
127  escaped.append( wxS( "&gt;" ) );
128  break;
129  case wxS( '&' ):
130  escaped.append( wxS( "&amp;" ) );
131  break;
132  case wxS( '\r' ):
133  escaped.append( wxS( "&#xD;" ) );
134  break;
135  default:
136  if( isAttribute )
137  {
138  switch( c )
139  {
140  case wxS( '"' ):
141  escaped.append( wxS( "&quot;" ) );
142  break;
143  case wxS( '\t' ):
144  escaped.append( wxS( "&#x9;" ) );
145  break;
146  case wxS( '\n' ):
147  escaped.append( wxS( "&#xA;" ));
148  break;
149  default:
150  escaped.append(c);
151  }
152  }
153  else
154  escaped.append(c);
155  }
156  }
157 
158  return escaped;
159 }
160 
161 
163 {
164  m_graphics_changed = true;
166  m_fillMode = NO_FILL; // or FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR
167  m_pen_rgb_color = 0; // current color value (black)
168  m_brush_rgb_color = 0; // current color value (black)
169  m_dashed = false;
170 }
171 
172 
173 void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
174  double aScale, bool aMirror )
175 {
176  m_plotMirror = aMirror;
177  m_yaxisReversed = true; // unlike other plotters, SVG has Y axis reversed
178  plotOffset = aOffset;
179  plotScale = aScale;
180  m_IUsPerDecimil = aIusPerDecimil;
181  iuPerDeviceUnit = 1.0 / aIusPerDecimil;
182  /* Compute the paper size in IUs */
184  paperSize.x *= 10.0 * aIusPerDecimil;
185  paperSize.y *= 10.0 * aIusPerDecimil;
186  SetDefaultLineWidth( 100 * aIusPerDecimil ); // arbitrary default
187 }
188 
189 
191 {
192  PSLIKE_PLOTTER::SetColor( color );
193 
194  if( m_graphics_changed )
195  setSVGPlotStyle();
196 }
197 
198 
200 {
201  if( m_fillMode != fill )
202  {
203  m_graphics_changed = true;
204  m_fillMode = fill;
205  }
206 }
207 
208 
210 {
211  fputs( "</g>\n<g style=\"", outputFile );
212  fputs( "fill:#", outputFile );
213  // output the background fill color
214  fprintf( outputFile, "%6.6lX; ", m_brush_rgb_color );
215 
216  switch( m_fillMode )
217  {
218  case NO_FILL:
219  fputs( "fill-opacity:0.0; ", outputFile );
220  break;
221 
222  case FILLED_SHAPE:
223  fputs( "fill-opacity:1.0; ", outputFile );
224  break;
225 
227  fputs( "fill-opacity:0.6; ", outputFile );
228  break;
229  }
230 
231  double pen_w = userToDeviceSize( GetCurrentLineWidth() );
232  fprintf( outputFile, "\nstroke:#%6.6lX; stroke-width:%g; stroke-opacity:1; \n",
233  m_pen_rgb_color, pen_w );
234  fputs( "stroke-linecap:round; stroke-linejoin:round;", outputFile );
235 
236  if( m_dashed )
237  fprintf( outputFile, "stroke-dasharray:%g,%g;",
239 
240  fputs( "\">\n", outputFile );
241 
242  m_graphics_changed = false;
243 }
244 
245 /* Set the current line width (in IUs) for the next plot
246  */
247 void SVG_PLOTTER::SetCurrentLineWidth( int width, void* aData )
248 {
249  int pen_width;
250 
251  if( width >= 0 )
252  pen_width = width;
253  else
254  pen_width = defaultPenWidth;
255 
256  if( pen_width != currentPenWidth )
257  {
258  m_graphics_changed = true;
259  currentPenWidth = pen_width;
260  }
261 
262  if( m_graphics_changed )
263  setSVGPlotStyle();
264 }
265 
266 
267 /* initialize m_red, m_green, m_blue ( 0 ... 255)
268  * from reduced values r, g ,b ( 0.0 to 1.0 )
269  */
270 void SVG_PLOTTER::emitSetRGBColor( double r, double g, double b )
271 {
272  int red = (int) ( 255.0 * r );
273  int green = (int) ( 255.0 * g );
274  int blue = (int) ( 255.0 * b );
275  long rgb_color = (red << 16) | (green << 8) | blue;
276 
277  if( m_pen_rgb_color != rgb_color )
278  {
279  m_graphics_changed = true;
280  m_pen_rgb_color = rgb_color;
281 
282  // Currently, use the same color for brush and pen
283  // (i.e. to draw and fill a contour)
284  m_brush_rgb_color = rgb_color;
285  }
286 }
287 
288 
292 void SVG_PLOTTER::SetDash( bool dashed )
293 {
294  if( m_dashed != dashed )
295  {
296  m_graphics_changed = true;
297  m_dashed = dashed;
298  }
299 
300  if( m_graphics_changed )
301  setSVGPlotStyle();
302 }
303 
304 
305 void SVG_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
306 {
307  EDA_RECT rect( p1, wxSize( p2.x -p1.x, p2.y -p1.y ) );
308  rect.Normalize();
309  DPOINT org_dev = userToDeviceCoordinates( rect.GetOrigin() );
310  DPOINT end_dev = userToDeviceCoordinates( rect.GetEnd() );
311  DSIZE size_dev = end_dev - org_dev;
312  // Ensure size of rect in device coordinates is > 0
313  // I don't know if this is a SVG issue or a Inkscape issue, but
314  // Inkscape has problems with negative or null values for width and/or height, so avoid them
315  DBOX rect_dev( org_dev, size_dev);
316  rect_dev.Normalize();
317 
318  setFillMode( fill );
319  SetCurrentLineWidth( width );
320 
321  // Rectangles having a 0 size value for height or width are just not drawn on Inscape,
322  // so use a line when happens.
323  if( rect_dev.GetSize().x == 0.0 || rect_dev.GetSize().y == 0.0 ) // Draw a line
324  fprintf( outputFile,
325  "<line x1=\"%g\" y1=\"%g\" x2=\"%g\" y2=\"%g\" />\n",
326  rect_dev.GetPosition().x, rect_dev.GetPosition().y,
327  rect_dev.GetEnd().x, rect_dev.GetEnd().y
328  );
329 
330  else
331  fprintf( outputFile,
332  "<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" rx=\"%g\" />\n",
333  rect_dev.GetPosition().x, rect_dev.GetPosition().y,
334  rect_dev.GetSize().x, rect_dev.GetSize().y,
335  0.0 // radius of rounded corners
336  );
337 }
338 
339 
340 void SVG_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_T fill, int width )
341 {
342  DPOINT pos_dev = userToDeviceCoordinates( pos );
343  double radius = userToDeviceSize( diametre / 2.0 );
344 
345  setFillMode( fill );
346  SetCurrentLineWidth( width );
347 
348  fprintf( outputFile,
349  "<circle cx=\"%g\" cy=\"%g\" r=\"%g\" /> \n",
350  pos_dev.x, pos_dev.y, radius );
351 }
352 
353 
354 void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
355  FILL_T fill, int width )
356 {
357  /* Draws an arc of a circle, centred on (xc,yc), with starting point
358  * (x1, y1) and ending at (x2, y2). The current pen is used for the outline
359  * and the current brush for filling the shape.
360  *
361  * The arc is drawn in an anticlockwise direction from the start point to
362  * the end point
363  */
364 
365  if( radius <= 0 )
366  return;
367 
368  if( StAngle > EndAngle )
369  std::swap( StAngle, EndAngle );
370 
371  setFillMode( fill );
372  SetCurrentLineWidth( width );
373 
374  // Calculate start point.
375  DPOINT centre_dev = userToDeviceCoordinates( centre );
376  double radius_dev = userToDeviceSize( radius );
377 
378  if( !m_yaxisReversed ) // Should be never the case
379  {
380  double tmp = StAngle;
381  StAngle = -EndAngle;
382  EndAngle = -tmp;
383  }
384 
385  if( m_plotMirror )
386  {
388  {
389  StAngle = 1800.0 -StAngle;
390  EndAngle = 1800.0 -EndAngle;
391  std::swap( StAngle, EndAngle );
392  }
393  else
394  {
395  StAngle = -StAngle;
396  EndAngle = -EndAngle;
397  }
398  }
399 
400  DPOINT start;
401  start.x = radius_dev;
402  RotatePoint( &start.x, &start.y, StAngle );
403  DPOINT end;
404  end.x = radius_dev;
405  RotatePoint( &end.x, &end.y, EndAngle );
406  start += centre_dev;
407  end += centre_dev;
408 
409  double theta1 = DECIDEG2RAD( StAngle );
410 
411  if( theta1 < 0 )
412  theta1 = theta1 + M_PI * 2;
413 
414  double theta2 = DECIDEG2RAD( EndAngle );
415 
416  if( theta2 < 0 )
417  theta2 = theta2 + M_PI * 2;
418 
419  if( theta2 < theta1 )
420  theta2 = theta2 + M_PI * 2;
421 
422  int flg_arc = 0; // flag for large or small arc. 0 means less than 180 degrees
423 
424  if( fabs( theta2 - theta1 ) > M_PI )
425  flg_arc = 1;
426 
427  int flg_sweep = 0; // flag for sweep always 0
428 
429  // Draw a single arc: an arc is one of 3 curve commands (2 other are 2 bezier curves)
430  // params are start point, radius1, radius2, X axe rotation,
431  // flag arc size (0 = small arc > 180 deg, 1 = large arc > 180 deg),
432  // sweep arc ( 0 = CCW, 1 = CW),
433  // end point
434  fprintf( outputFile, "<path d=\"M%g %g A%g %g 0.0 %d %d %g %g \" />\n",
435  start.x, start.y, radius_dev, radius_dev,
436  flg_arc, flg_sweep,
437  end.x, end.y );
438 }
439 
440 
441 void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
442  FILL_T aFill, int aWidth, void * aData )
443 {
444  if( aCornerList.size() <= 1 )
445  return;
446 
447  setFillMode( aFill );
448  SetCurrentLineWidth( aWidth );
449 
450  switch( aFill )
451  {
452  case NO_FILL:
453  fprintf( outputFile, "<polyline fill=\"none;\"\n" );
454  break;
455 
457  case FILLED_SHAPE:
458  fprintf( outputFile, "<polyline style=\"fill-rule:evenodd;\"\n" );
459  break;
460  }
461 
462  DPOINT pos = userToDeviceCoordinates( aCornerList[0] );
463  fprintf( outputFile, "points=\"%d,%d\n", (int) pos.x, (int) pos.y );
464 
465  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
466  {
467  pos = userToDeviceCoordinates( aCornerList[ii] );
468  fprintf( outputFile, "%d,%d\n", (int) pos.x, (int) pos.y );
469  }
470 
471  // Close/(fill) the path
472  fprintf( outputFile, "\" /> \n" );
473 }
474 
475 
479 void SVG_PLOTTER::PlotImage( const wxImage& aImage, const wxPoint& aPos,
480  double aScaleFactor )
481 {
482  // in svg file we must insert a link to a png image file to plot an image
483  // the image itself is not included in the svg file.
484  // So we prefer skip the image, and just draw a rectangle,
485  // like other plotters which do not support images
486 
487  PLOTTER::PlotImage( aImage, aPos, aScaleFactor );
488 
489 }
490 
491 
492 void SVG_PLOTTER::PenTo( const wxPoint& pos, char plume )
493 {
494  if( plume == 'Z' )
495  {
496  if( penState != 'Z' )
497  {
498  fputs( "\" />\n", outputFile );
499  penState = 'Z';
500  penLastpos.x = -1;
501  penLastpos.y = -1;
502  }
503 
504  return;
505  }
506 
507  if( penState == 'Z' ) // here plume = 'D' or 'U'
508  {
509  DPOINT pos_dev = userToDeviceCoordinates( pos );
510 
511  // Ensure we do not use a fill mode when moving tne pen,
512  // in SVG mode (i;e. we are plotting only basic lines, not a filled area
513  if( m_fillMode != NO_FILL )
514  {
515  setFillMode( NO_FILL );
516  setSVGPlotStyle();
517  }
518 
519  fprintf( outputFile, "<path d=\"M%d %d\n",
520  (int) pos_dev.x, (int) pos_dev.y );
521  }
522  else if( penState != plume || pos != penLastpos )
523  {
524  DPOINT pos_dev = userToDeviceCoordinates( pos );
525  fprintf( outputFile, "L%d %d\n",
526  (int) pos_dev.x, (int) pos_dev.y );
527  }
528 
529  penState = plume;
530  penLastpos = pos;
531 }
532 
533 
539 {
540  wxASSERT( outputFile );
541  wxString msg;
542 
543  static const char* header[] =
544  {
545  "<?xml version=\"1.0\" standalone=\"no\"?>\n",
546  " <!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \n",
547  " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"> \n",
548  "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" \n",
549  NULL
550  };
551 
552  // Write header.
553  for( int ii = 0; header[ii] != NULL; ii++ )
554  {
555  fputs( header[ii], outputFile );
556  }
557 
558  // Write viewport pos and size
559  wxPoint origin; // TODO set to actual value
560  fprintf( outputFile,
561  " width=\"%gcm\" height=\"%gcm\" viewBox=\"%d %d %d %d \">\n",
562  (double) paperSize.x / m_IUsPerDecimil * 2.54 / 10000,
563  (double) paperSize.y / m_IUsPerDecimil * 2.54 / 10000,
564  origin.x, origin.y,
565  (int) ( paperSize.x / m_IUsPerDecimil ),
566  (int) ( paperSize.y / m_IUsPerDecimil) );
567 
568  // Write title
569  char date_buf[250];
570  time_t ltime = time( NULL );
571  strftime( date_buf, 250, "%Y/%m/%d %H:%M:%S",
572  localtime( &ltime ) );
573 
574  fprintf( outputFile,
575  "<title>SVG Picture created as %s date %s </title>\n",
576  TO_UTF8( XmlEsc( wxFileName( filename ).GetFullName() ) ), date_buf );
577  // End of header
578  fprintf( outputFile, " <desc>Picture generated by %s </desc>\n",
579  TO_UTF8( XmlEsc( creator ) ) );
580 
581  // output the pen and brush color (RVB values in hex) and opacity
582  double opacity = 1.0; // 0.0 (transparent to 1.0 (solid)
583  fprintf( outputFile,
584  "<g style=\"fill:#%6.6lX; fill-opacity:%g;stroke:#%6.6lX; stroke-opacity:%g;\n",
585  m_brush_rgb_color, opacity, m_pen_rgb_color, opacity );
586 
587  // output the pen cap and line joint
588  fputs( "stroke-linecap:round; stroke-linejoin:round; \"\n", outputFile );
589  fputs( " transform=\"translate(0 0) scale(1 1)\">\n", outputFile );
590  return true;
591 }
592 
593 
595 {
596  fputs( "</g> \n</svg>\n", outputFile );
597  fclose( outputFile );
598  outputFile = NULL;
599 
600  return true;
601 }
602 
603 
604 void SVG_PLOTTER::Text( const wxPoint& aPos,
605  const COLOR4D aColor,
606  const wxString& aText,
607  double aOrient,
608  const wxSize& aSize,
609  enum EDA_TEXT_HJUSTIFY_T aH_justify,
610  enum EDA_TEXT_VJUSTIFY_T aV_justify,
611  int aWidth,
612  bool aItalic,
613  bool aBold,
614  bool aMultilineAllowed,
615  void* aData )
616 {
617  setFillMode( NO_FILL );
618  SetColor( aColor );
619  SetCurrentLineWidth( aWidth );
620 
621  // TODO: see if the postscript native text code can be used in SVG plotter
622 
623  PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
624  aWidth, aItalic, aBold, aMultilineAllowed );
625 }
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
virtual void PlotImage(const wxImage &aImage, const wxPoint &aPos, double aScaleFactor) override
Postscript-likes at the moment are the only plot engines supporting bitmaps...
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
FILL_T m_fillMode
Definition: plot_common.h:929
void setSVGPlotStyle()
function setSVGPlotStyle() output the string which define pen and brush color, shape, transparence
void setFillMode(FILL_T fill)
function setFillMode() prepare parameters for setSVGPlotStyle()
const Vec GetEnd() const
Definition: box2.h:183
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
virtual void SetDash(bool dashed) override
SVG supports dashed lines.
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
double m_IUsPerDecimil
Definition: plot_common.h:516
const Vec & GetSize() const
Definition: box2.h:177
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
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
This file contains miscellaneous commonly used macros and functions.
const wxSize & GetSizeMils() const
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: drawtxt.cpp:229
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL) override
Draws text with the plotter.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
const wxPoint & GetOrigin() const
virtual bool EndPlot() override
bool m_yaxisReversed
true to mirror horizontally (else vertically)
Definition: plot_common.h:528
virtual void SetColor(COLOR4D color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values...
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plot_common.h:526
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
long m_pen_rgb_color
Definition: plot_common.h:931
Base window classes and related definitions.
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.
BOX2< Vec > & Normalize()
Function Normalize ensures that the height ant width are positive.
Definition: box2.h:117
virtual void SetColor(COLOR4D color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values...
const Vec & GetPosition() const
Definition: box2.h:182
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:510
virtual bool StartPlot() override
The code within this function creates SVG files header.
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
const wxPoint GetEnd() const
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
void Normalize()
Function Normalize ensures that the height ant width are positive.
virtual void PlotImage(const wxImage &aImage, const wxPoint &aPos, double aScaleFactor)
Function PlotImage Only Postscript plotters can plot bitmaps for plotters that cannot plot a bitmap...
virtual void SetTextMode(PlotTextMode mode) override
PS and PDF fully implement native text (for the Latin-1 subset)
Definition: plot_common.h:650
int currentPenWidth
Definition: plot_common.h:537
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
int defaultPenWidth
true to generate a negative image (PS mode mainly)
Definition: plot_common.h:536
bool m_graphics_changed
Definition: plot_common.h:937
long m_brush_rgb_color
Definition: plot_common.h:935
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
Class EDA_RECT handles the component boundary box.
double DECIDEG2RAD(double deg)
Definition: trigo.h:195
static wxString XmlEsc(const wxString &aStr, bool isAttribute=false)
Function XmlEsc translates '<' to "<", '>' to ">" and so on, according to the spec: http://www...
double GetDashGapLenIU() const
virtual void emitSetRGBColor(double r, double g, double b) override
function emitSetRGBColor() initialize m_pen_rgb_color from reduced values r, g ,b ( reduced values ar...
The common library.
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:56
Basic classes for most KiCad items.
double GetDashMarkLenIU() const
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:519
wxString filename
Definition: plot_common.h:543
wxString creator
Definition: plot_common.h:542
wxSize paperSize
Paper size in IU - not in mils.
Definition: plot_common.h:547
bool m_mirrorIsHorizontal
Definition: plot_common.h:527
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Function PlotPoly.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39