KiCad PCB EDA Suite
PS_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 
30 #include <fctsys.h>
31 #include <trigo.h>
32 #include <eda_base_frame.h>
33 #include <base_struct.h>
34 #include <common.h>
35 #include <plotter.h>
36 #include <macros.h>
38 #include <math/util.h> // for KiROUND
39 
40 /* Forward declaration of the font width metrics
41  (yes extern! this is the way to forward declare variables */
42 extern const double hv_widths[256];
43 extern const double hvb_widths[256];
44 extern const double hvo_widths[256];
45 extern const double hvbo_widths[256];
46 
47 const double PSLIKE_PLOTTER::postscriptTextAscent = 0.718;
48 
49 
50 // Common routines for Postscript-like plotting engines
51 
53 {
54  if( colorMode )
55  {
56  if( negativeMode )
57  emitSetRGBColor( 1 - color.r, 1 - color.g, 1 - color.b );
58  else
59  emitSetRGBColor( color.r, color.g, color.b );
60  }
61  else
62  {
63  /* B/W Mode - Use BLACK or WHITE for all items
64  * note the 2 colors are used in B&W mode, mainly by Pcbnew to draw
65  * holes in white on pads in black
66  */
67  double k = 1; // White
68  if( color != COLOR4D::WHITE )
69  k = 0;
70  if( negativeMode )
71  emitSetRGBColor( 1 - k, 1 - k, 1 - k );
72  else
73  emitSetRGBColor( k, k, k );
74  }
75 }
76 
77 
78 void PSLIKE_PLOTTER::FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize,
79  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData )
80 {
81  wxASSERT( outputFile );
82  int x0, y0, x1, y1, delta;
83  wxSize size( aSize );
84 
85  // The pad is reduced to an oval by dy > dx
86  if( size.x > size.y )
87  {
88  std::swap( size.x, size.y );
89  aPadOrient = AddAngles( aPadOrient, 900 );
90  }
91 
92  delta = size.y - size.x;
93  x0 = 0;
94  y0 = -delta / 2;
95  x1 = 0;
96  y1 = delta / 2;
97  RotatePoint( &x0, &y0, aPadOrient );
98  RotatePoint( &x1, &y1, aPadOrient );
99 
100  if( aTraceMode == FILLED )
101  ThickSegment( wxPoint( aPadPos.x + x0, aPadPos.y + y0 ),
102  wxPoint( aPadPos.x + x1, aPadPos.y + y1 ), size.x, aTraceMode, NULL );
103  else
104  sketchOval( aPadPos, size, aPadOrient, -1 );
105 }
106 
107 
108 void PSLIKE_PLOTTER::FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
109  EDA_DRAW_MODE_T aTraceMode, void* aData )
110 {
111  if( aTraceMode == FILLED )
112  Circle( aPadPos, aDiameter, FILLED_SHAPE, 0 );
113  else // Plot a ring:
114  {
116  int linewidth = GetCurrentLineWidth();
117 
118  // avoid aDiameter <= 1 )
119  if( linewidth > aDiameter-2 )
120  linewidth = aDiameter-2;
121 
122  Circle( aPadPos, aDiameter - linewidth, NO_FILL, linewidth );
123  }
124 
126 }
127 
128 
129 void PSLIKE_PLOTTER::FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
130  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData )
131 {
132  static std::vector< wxPoint > cornerList;
133  wxSize size( aSize );
134  cornerList.clear();
135 
136  if( aTraceMode == FILLED )
137  SetCurrentLineWidth( 0 );
138  else
140 
141  size.x -= GetCurrentLineWidth();
142  size.y -= GetCurrentLineWidth();
143 
144  if( size.x < 1 )
145  size.x = 1;
146 
147  if( size.y < 1 )
148  size.y = 1;
149 
150  int dx = size.x / 2;
151  int dy = size.y / 2;
152 
153  wxPoint corner;
154  corner.x = aPadPos.x - dx;
155  corner.y = aPadPos.y + dy;
156  cornerList.push_back( corner );
157  corner.x = aPadPos.x - dx;
158  corner.y = aPadPos.y - dy;
159  cornerList.push_back( corner );
160  corner.x = aPadPos.x + dx;
161  corner.y = aPadPos.y - dy;
162  cornerList.push_back( corner );
163  corner.x = aPadPos.x + dx;
164  corner.y = aPadPos.y + dy,
165  cornerList.push_back( corner );
166 
167  for( unsigned ii = 0; ii < cornerList.size(); ii++ )
168  {
169  RotatePoint( &cornerList[ii], aPadPos, aPadOrient );
170  }
171 
172  cornerList.push_back( cornerList[0] );
173 
174  PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL,
176 }
177 
178 void PSLIKE_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
179  int aCornerRadius, double aOrient,
180  EDA_DRAW_MODE_T aTraceMode, void* aData )
181 {
182  wxSize size( aSize );
183 
184  if( aTraceMode == FILLED )
185  SetCurrentLineWidth( 0 );
186  else
187  {
189  size.x -= GetCurrentLineWidth();
190  size.y -= GetCurrentLineWidth();
191  aCornerRadius -= GetCurrentLineWidth()/2;
192  }
193 
194 
195  SHAPE_POLY_SET outline;
196  TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient,
197  aCornerRadius, 0.0, 0, GetPlotterArcHighDef() );
198 
199  std::vector< wxPoint > cornerList;
200  // TransformRoundRectToPolygon creates only one convex polygon
201  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
202  cornerList.reserve( poly.PointCount() );
203 
204  for( int ii = 0; ii < poly.PointCount(); ++ii )
205  cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
206 
207  // Close polygon
208  cornerList.push_back( cornerList[0] );
209 
210  PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL,
212 }
213 
214 void PSLIKE_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
215  SHAPE_POLY_SET* aPolygons,
216  EDA_DRAW_MODE_T aTraceMode, void* aData )
217 {
218  wxSize size( aSize );
219 
220  if( aTraceMode == FILLED )
221  SetCurrentLineWidth( 0 );
222  else
223  {
225  size.x -= GetCurrentLineWidth();
226  size.y -= GetCurrentLineWidth();
227  }
228 
229 
230  std::vector< wxPoint > cornerList;
231 
232  for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
233  {
234  SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
235  cornerList.clear();
236 
237  for( int ii = 0; ii < poly.PointCount(); ++ii )
238  cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
239 
240  // Close polygon
241  cornerList.push_back( cornerList[0] );
242 
243  PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL,
245  }
246 }
247 
248 void PSLIKE_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
249  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData )
250 {
251  static std::vector< wxPoint > cornerList;
252  cornerList.clear();
253 
254  for( int ii = 0; ii < 4; ii++ )
255  cornerList.push_back( aCorners[ii] );
256 
257  if( aTraceMode == FILLED )
258  {
259  SetCurrentLineWidth( 0 );
260  }
261  else
262  {
264  int w = GetCurrentLineWidth();
265  // offset polygon by w
266  // coord[0] is assumed the lower left
267  // coord[1] is assumed the upper left
268  // coord[2] is assumed the upper right
269  // coord[3] is assumed the lower right
270 
271  /* Trace the outline. */
272  cornerList[0].x += w;
273  cornerList[0].y -= w;
274  cornerList[1].x += w;
275  cornerList[1].y += w;
276  cornerList[2].x -= w;
277  cornerList[2].y += w;
278  cornerList[3].x -= w;
279  cornerList[3].y -= w;
280  }
281 
282  for( int ii = 0; ii < 4; ii++ )
283  {
284  RotatePoint( &cornerList[ii], aPadOrient );
285  cornerList[ii] += aPadPos;
286  }
287 
288  cornerList.push_back( cornerList[0] );
289  PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL,
291 }
292 
293 
295  int aRadius, int aCornerCount,
296  double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData )
297 {
298  // Do nothing
299  wxASSERT( 0 );
300 }
301 
302 
303 std::string PSLIKE_PLOTTER::encodeStringForPlotter( const wxString& aUnicode )
304 {
305  // Write on a std::string a string escaped for postscript/PDF
306  std::string converted;
307 
308  converted += '(';
309 
310  for( unsigned i = 0; i < aUnicode.Len(); i++ )
311  {
312  // Lazyness made me use stdio buffering yet another time...
313  wchar_t ch = aUnicode[i];
314 
315  if( ch < 256 )
316  {
317  switch (ch)
318  {
319  // The ~ shouldn't reach the outside
320  case '~':
321  break;
322  // These characters must be escaped
323  case '(':
324  case ')':
325  case '\\':
326  converted += '\\';
328 
329  default:
330  converted += ch;
331  break;
332  }
333  }
334  }
335 
336  converted += ')';
337 
338  return converted;
339 }
340 
341 
348 int PSLIKE_PLOTTER::returnPostscriptTextWidth( const wxString& aText, int aXSize,
349  bool aItalic, bool aBold )
350 {
351  const double *width_table = aBold ? ( aItalic ? hvbo_widths : hvb_widths )
352  : ( aItalic ? hvo_widths : hv_widths );
353  double tally = 0;
354 
355  for( unsigned i = 0; i < aText.length(); i++ )
356  {
357  wchar_t AsciiCode = aText[i];
358  // Skip the negation marks and untabled points
359  if( AsciiCode != '~' && AsciiCode < 256 )
360  {
361  tally += width_table[AsciiCode];
362  }
363  }
364 
365  // Widths are proportional to height, but height is enlarged by a
366  // scaling factor
367  return KiROUND( aXSize * tally / postscriptTextAscent );
368 }
369 
370 
377 void PSLIKE_PLOTTER::postscriptOverlinePositions( const wxString& aText, int aXSize,
378  bool aItalic, bool aBold,
379  std::vector<int> *pos_pairs )
380 {
381  /* XXX This function is *too* similar to returnPostscriptTextWidth.
382  Consider merging them... */
383  const double *width_table = aBold ? ( aItalic ? hvbo_widths : hvb_widths )
384  : ( aItalic ? hvo_widths : hv_widths );
385  double tally = 0;
386 
387  for( unsigned i = 0; i < aText.length(); i++ )
388  {
389  wchar_t AsciiCode = aText[i];
390  // Skip the negation marks and untabled points
391  if( AsciiCode != '~' && AsciiCode < 256 )
392  {
393  tally += width_table[AsciiCode];
394  }
395  else
396  {
397  if( AsciiCode == '~' )
398  pos_pairs->push_back( KiROUND( aXSize * tally / postscriptTextAscent ) );
399  }
400  }
401 
402  // Special rule: we have to complete the last bar if the ~ aren't matched
403  if( pos_pairs->size() % 2 == 1 )
404  pos_pairs->push_back( KiROUND( aXSize * tally / postscriptTextAscent ) );
405 }
406 
407 void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
408  double aScale, bool aMirror )
409 {
410  wxASSERT( !outputFile );
411  m_plotMirror = aMirror;
412  plotOffset = aOffset;
413  plotScale = aScale;
414  m_IUsPerDecimil = aIusPerDecimil;
415  iuPerDeviceUnit = 1.0 / aIusPerDecimil;
416  /* Compute the paper size in IUs */
418  paperSize.x *= 10.0 * aIusPerDecimil;
419  paperSize.y *= 10.0 * aIusPerDecimil;
420 }
421 
422 
430  const wxString& aText,
431  int aOrient,
432  const wxSize& aSize,
433  bool aMirror,
434  enum EDA_TEXT_HJUSTIFY_T aH_justify,
435  enum EDA_TEXT_VJUSTIFY_T aV_justify,
436  int aWidth,
437  bool aItalic,
438  bool aBold,
439  double *wideningFactor,
440  double *ctm_a,
441  double *ctm_b,
442  double *ctm_c,
443  double *ctm_d,
444  double *ctm_e,
445  double *ctm_f,
446  double *heightFactor )
447 {
448  // Compute the starting position (compensated for alignment)
449  wxPoint start_pos = aPos;
450 
451  // This is an approximation of the text bounds (in IUs)
452  int tw = returnPostscriptTextWidth( aText, aSize.x, aItalic, aWidth );
453  int th = aSize.y;
454  int dx, dy;
455 
456  switch( aH_justify )
457  {
459  dx = -tw / 2;
460  break;
461 
463  dx = -tw;
464  break;
465 
467  dx = 0;
468  break;
469  }
470 
471  switch( aV_justify )
472  {
474  dy = th / 2;
475  break;
476 
478  dy = th;
479  break;
480 
482  dy = 0;
483  break;
484  }
485 
486  RotatePoint( &dx, &dy, aOrient );
487  RotatePoint( &tw, &th, aOrient );
488  start_pos.x += dx;
489  start_pos.y += dy;
490  DPOINT pos_dev = userToDeviceCoordinates( start_pos );
491  DPOINT sz_dev = userToDeviceSize( aSize );
492 
493  // Now returns the final values... the widening factor
494  *wideningFactor = sz_dev.x / sz_dev.y;
495 
496  // Mirrored texts must be plotted as mirrored!
497  if( m_plotMirror )
498  {
499  *wideningFactor = -*wideningFactor;
500  aOrient = -aOrient;
501  }
502 
503  // The CTM transformation matrix
504  double alpha = DECIDEG2RAD( aOrient );
505  double sinalpha = sin( alpha );
506  double cosalpha = cos( alpha );
507 
508  *ctm_a = cosalpha;
509  *ctm_b = sinalpha;
510  *ctm_c = -sinalpha;
511  *ctm_d = cosalpha;
512  *ctm_e = pos_dev.x;
513  *ctm_f = pos_dev.y;
514 
515  // This is because the letters are less than 1 unit high
516  *heightFactor = sz_dev.y / postscriptTextAscent;
517 }
518 
519 
520 /* Set the current line width (in IUs) for the next plot
521  */
522 void PS_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
523 {
524  wxASSERT( outputFile );
525 
526  if( aWidth == DO_NOT_SET_LINE_WIDTH )
527  return;
528  else if( aWidth == USE_DEFAULT_LINE_WIDTH )
530  else if( aWidth == 0 )
531  aWidth = 1;
532 
533  wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" );
534 
535  if( aWidth != GetCurrentLineWidth() )
536  fprintf( outputFile, "%g setlinewidth\n", userToDeviceSize( aWidth ) );
537 
538  currentPenWidth = aWidth;
539 }
540 
541 
542 void PS_PLOTTER::emitSetRGBColor( double r, double g, double b )
543 {
544  wxASSERT( outputFile );
545 
546  // XXX why %.3g ? shouldn't %g suffice? who cares...
547  fprintf( outputFile, "%.3g %.3g %.3g setrgbcolor\n", r, g, b );
548 }
549 
550 
555 {
556  switch( dashed )
557  {
559  fprintf( outputFile, "[%d %d] 0 setdash\n",
560  (int) GetDashMarkLenIU(), (int) GetDashGapLenIU() );
561  break;
562  case PLOT_DASH_TYPE::DOT:
563  fprintf( outputFile, "[%d %d] 0 setdash\n",
564  (int) GetDotMarkLenIU(), (int) GetDashGapLenIU() );
565  break;
567  fprintf( outputFile, "[%d %d %d %d] 0 setdash\n",
568  (int) GetDashMarkLenIU(), (int) GetDashGapLenIU(),
569  (int) GetDotMarkLenIU(), (int) GetDashGapLenIU() );
570  break;
571  default:
572  fputs( "solidline\n", outputFile );
573  }
574 }
575 
576 
577 void PS_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
578 {
579  DPOINT p1_dev = userToDeviceCoordinates( p1 );
580  DPOINT p2_dev = userToDeviceCoordinates( p2 );
581 
582  SetCurrentLineWidth( width );
583  fprintf( outputFile, "%g %g %g %g rect%d\n", p1_dev.x, p1_dev.y,
584  p2_dev.x - p1_dev.x, p2_dev.y - p1_dev.y, fill );
585 }
586 
587 
588 void PS_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_T fill, int width )
589 {
590  wxASSERT( outputFile );
591  DPOINT pos_dev = userToDeviceCoordinates( pos );
592  double radius = userToDeviceSize( diametre / 2.0 );
593 
594  SetCurrentLineWidth( width );
595  fprintf( outputFile, "%g %g %g cir%d\n", pos_dev.x, pos_dev.y, radius, fill );
596 }
597 
598 
599 void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
600  int radius, FILL_T fill, int width )
601 {
602  wxASSERT( outputFile );
603  if( radius <= 0 )
604  return;
605 
606  if( StAngle > EndAngle )
607  std::swap( StAngle, EndAngle );
608 
609  SetCurrentLineWidth( width );
610 
611  // Calculate start point.
612  DPOINT centre_dev = userToDeviceCoordinates( centre );
613  double radius_dev = userToDeviceSize( radius );
614 
615  if( m_plotMirror )
616  {
618  {
619  StAngle = 1800.0 -StAngle;
620  EndAngle = 1800.0 -EndAngle;
621  std::swap( StAngle, EndAngle );
622  }
623  else
624  {
625  StAngle = -StAngle;
626  EndAngle = -EndAngle;
627  }
628  }
629 
630  fprintf( outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y,
631  radius_dev, StAngle / 10.0, EndAngle / 10.0, fill );
632 }
633 
634 
635 void PS_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList,
636  FILL_T aFill, int aWidth, void * aData )
637 {
638  if( aCornerList.size() <= 1 )
639  return;
640 
641  SetCurrentLineWidth( aWidth );
642 
643  DPOINT pos = userToDeviceCoordinates( aCornerList[0] );
644  fprintf( outputFile, "newpath\n%g %g moveto\n", pos.x, pos.y );
645 
646  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
647  {
648  pos = userToDeviceCoordinates( aCornerList[ii] );
649  fprintf( outputFile, "%g %g lineto\n", pos.x, pos.y );
650  }
651 
652  // Close/(fill) the path
653  fprintf( outputFile, "poly%d\n", aFill );
654 }
655 
656 
660 void PS_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
661  double aScaleFactor )
662 {
663  wxSize pix_size; // size of the bitmap in pixels
664  pix_size.x = aImage.GetWidth();
665  pix_size.y = aImage.GetHeight();
666  DPOINT drawsize( aScaleFactor * pix_size.x,
667  aScaleFactor * pix_size.y ); // requested size of image
668 
669  // calculate the bottom left corner position of bitmap
670  wxPoint start = aPos;
671  start.x -= drawsize.x / 2; // left
672  start.y += drawsize.y / 2; // bottom (Y axis reversed)
673 
674  // calculate the top right corner position of bitmap
675  wxPoint end;
676  end.x = start.x + drawsize.x;
677  end.y = start.y - drawsize.y;
678 
679  fprintf( outputFile, "/origstate save def\n" );
680  fprintf( outputFile, "/pix %d string def\n", pix_size.x );
681 
682  // Locate lower-left corner of image
683  DPOINT start_dev = userToDeviceCoordinates( start );
684  fprintf( outputFile, "%g %g translate\n", start_dev.x, start_dev.y );
685  // Map image size to device
686  DPOINT end_dev = userToDeviceCoordinates( end );
687  fprintf( outputFile, "%g %g scale\n",
688  std::abs(end_dev.x - start_dev.x), std::abs(end_dev.y - start_dev.y));
689 
690  // Dimensions of source image (in pixels
691  fprintf( outputFile, "%d %d 8", pix_size.x, pix_size.y );
692  // Map unit square to source
693  fprintf( outputFile, " [%d 0 0 %d 0 %d]\n", pix_size.x, -pix_size.y , pix_size.y);
694  // include image data in ps file
695  fprintf( outputFile, "{currentfile pix readhexstring pop}\n" );
696 
697  if( colorMode )
698  fputs( "false 3 colorimage\n", outputFile );
699  else
700  fputs( "image\n", outputFile );
701  // Single data source, 3 colors, Output RGB data (hexadecimal)
702  // (or the same downscaled to gray)
703  int jj = 0;
704 
705  for( int yy = 0; yy < pix_size.y; yy ++ )
706  {
707  for( int xx = 0; xx < pix_size.x; xx++, jj++ )
708  {
709  if( jj >= 16 )
710  {
711  jj = 0;
712  fprintf( outputFile, "\n");
713  }
714 
715  int red, green, blue;
716  red = aImage.GetRed( xx, yy) & 0xFF;
717  green = aImage.GetGreen( xx, yy) & 0xFF;
718  blue = aImage.GetBlue( xx, yy) & 0xFF;
719 
720  // PS doesn't support alpha, so premultiply against white background
721  if( aImage.HasAlpha() )
722  {
723  unsigned char alpha = aImage.GetAlpha( xx, yy ) & 0xFF;
724 
725  if( alpha < 0xFF )
726  {
727  float a = 1.0 - ( (float) alpha / 255.0 );
728  red = ( int )( red + ( a * 0xFF ) ) & 0xFF;
729  green = ( int )( green + ( a * 0xFF ) ) & 0xFF;
730  blue = ( int )( blue + ( a * 0xFF ) ) & 0xFF;
731  }
732  }
733 
734  if( aImage.HasMask() )
735  {
736  if( red == aImage.GetMaskRed() && green == aImage.GetMaskGreen()
737  && blue == aImage.GetMaskBlue() )
738  {
739  red = 0xFF;
740  green = 0xFF;
741  blue = 0xFF;
742  }
743  }
744 
745  if( colorMode )
746  fprintf( outputFile, "%2.2X%2.2X%2.2X", red, green, blue );
747  else
748  {
749  // Greyscale conversion (CIE 1931)
750  unsigned char grey = KiROUND( red * 0.2126 + green * 0.7152 + blue * 0.0722 );
751 
752  fprintf( outputFile, "%2.2X", grey );
753  }
754  }
755  }
756 
757  fprintf( outputFile, "\n");
758  fprintf( outputFile, "origstate restore\n" );
759 }
760 
761 
762 void PS_PLOTTER::PenTo( const wxPoint& pos, char plume )
763 {
764  wxASSERT( outputFile );
765 
766  if( plume == 'Z' )
767  {
768  if( penState != 'Z' )
769  {
770  fputs( "stroke\n", outputFile );
771  penState = 'Z';
772  penLastpos.x = -1;
773  penLastpos.y = -1;
774  }
775 
776  return;
777  }
778 
779  if( penState == 'Z' )
780  {
781  fputs( "newpath\n", outputFile );
782  }
783 
784  if( penState != plume || pos != penLastpos )
785  {
786  DPOINT pos_dev = userToDeviceCoordinates( pos );
787  fprintf( outputFile, "%g %g %sto\n",
788  pos_dev.x, pos_dev.y,
789  ( plume=='D' ) ? "line" : "move" );
790  }
791 
792  penState = plume;
793  penLastpos = pos;
794 }
795 
796 
811 {
812  wxASSERT( outputFile );
813  wxString msg;
814 
815  static const char* PSMacro[] =
816  {
817  "%%BeginProlog\n",
818  "/line { newpath moveto lineto stroke } bind def\n",
819  "/cir0 { newpath 0 360 arc stroke } bind def\n",
820  "/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
821  "/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
822  "/arc0 { newpath arc stroke } bind def\n",
823  "/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
824  " grestore stroke } bind def\n",
825  "/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
826  " grestore stroke } bind def\n",
827  "/poly0 { stroke } bind def\n",
828  "/poly1 { closepath gsave fill grestore stroke } bind def\n",
829  "/poly2 { closepath gsave fill grestore stroke } bind def\n",
830  "/rect0 { rectstroke } bind def\n",
831  "/rect1 { rectfill } bind def\n",
832  "/rect2 { rectfill } bind def\n",
833  "/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
834  "/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
835  "/dashedline { [200] 100 setdash } bind def\n",
836  "/solidline { [] 0 setdash } bind def\n",
837 
838  // This is for 'hidden' text (search anchors for PDF)
839  "/phantomshow { moveto\n",
840  " /KicadFont findfont 0.000001 scalefont setfont\n",
841  " show } bind def\n",
842 
843  // This is for regular postscript text
844  "/textshow { gsave\n",
845  " findfont exch scalefont setfont concat 1 scale 0 0 moveto show\n",
846  " } bind def\n",
847 
848  // Utility for getting Latin1 encoded fonts
849  "/reencodefont {\n",
850  " findfont dup length dict begin\n",
851  " { 1 index /FID ne\n",
852  " { def }\n",
853  " { pop pop } ifelse\n",
854  " } forall\n",
855  " /Encoding ISOLatin1Encoding def\n",
856  " currentdict\n",
857  " end } bind def\n"
858 
859  // Remap AdobeStandard fonts to Latin1
860  "/KicadFont /Helvetica reencodefont definefont pop\n",
861  "/KicadFont-Bold /Helvetica-Bold reencodefont definefont pop\n",
862  "/KicadFont-Oblique /Helvetica-Oblique reencodefont definefont pop\n",
863  "/KicadFont-BoldOblique /Helvetica-BoldOblique reencodefont definefont pop\n",
864  "%%EndProlog\n",
865  NULL
866  };
867 
868  time_t time1970 = time( NULL );
869 
870  fputs( "%!PS-Adobe-3.0\n", outputFile ); // Print header
871 
872  fprintf( outputFile, "%%%%Creator: %s\n", TO_UTF8( creator ) );
873 
874  /* A "newline" character ("\n") is not included in the following string,
875  because it is provided by the ctime() function. */
876  fprintf( outputFile, "%%%%CreationDate: %s", ctime( &time1970 ) );
877  fprintf( outputFile, "%%%%Title: %s\n", encodeStringForPlotter( title ).c_str() );
878  fprintf( outputFile, "%%%%Pages: 1\n" );
879  fprintf( outputFile, "%%%%PageOrder: Ascend\n" );
880 
881  // Print boundary box in 1/72 pixels per inch, box is in mils
882  const double BIGPTsPERMIL = 0.072;
883 
884  /* The coordinates of the lower left corner of the boundary
885  box need to be "rounded down", but the coordinates of its
886  upper right corner need to be "rounded up" instead. */
887  wxSize psPaperSize = pageInfo.GetSizeMils();
888 
889  if( !pageInfo.IsPortrait() )
890  psPaperSize.Set( pageInfo.GetHeightMils(), pageInfo.GetWidthMils() );
891 
892  fprintf( outputFile, "%%%%BoundingBox: 0 0 %d %d\n",
893  (int) ceil( psPaperSize.x * BIGPTsPERMIL ),
894  (int) ceil( psPaperSize.y * BIGPTsPERMIL ) );
895 
896  // Specify the size of the sheet and the name associated with that size.
897  // (If the "User size" option has been selected for the sheet size,
898  // identify the sheet size as "Custom" (rather than as "User"), but
899  // otherwise use the name assigned by KiCad for each sheet size.)
900  //
901  // (The Document Structuring Convention also supports sheet weight,
902  // sheet color, and sheet type properties being specified within a
903  // %%DocumentMedia comment, but they are not being specified here;
904  // a zero and two null strings are subsequently provided instead.)
905  //
906  // (NOTE: m_Size.y is *supposed* to be listed before m_Size.x;
907  // the order in which they are specified is not wrong!)
908  // Also note pageSize is given in mils, not in internal units and must be
909  // converted to internal units.
910 
911  if( pageInfo.IsCustom() )
912  fprintf( outputFile, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
913  KiROUND( psPaperSize.x * BIGPTsPERMIL ),
914  KiROUND( psPaperSize.y * BIGPTsPERMIL ) );
915 
916  else // a standard paper size
917  fprintf( outputFile, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
918  TO_UTF8( pageInfo.GetType() ),
919  KiROUND( psPaperSize.x * BIGPTsPERMIL ),
920  KiROUND( psPaperSize.y * BIGPTsPERMIL ) );
921 
922  if( pageInfo.IsPortrait() )
923  fprintf( outputFile, "%%%%Orientation: Portrait\n" );
924  else
925  fprintf( outputFile, "%%%%Orientation: Landscape\n" );
926 
927  fprintf( outputFile, "%%%%EndComments\n" );
928 
929  // Now specify various other details.
930 
931  for( int ii = 0; PSMacro[ii] != NULL; ii++ )
932  {
933  fputs( PSMacro[ii], outputFile );
934  }
935 
936  // The following string has been specified here (rather than within
937  // PSMacro[]) to highlight that it has been provided to ensure that the
938  // contents of the postscript file comply with the details specified
939  // within the Document Structuring Convention.
940  fputs( "%%Page: 1 1\n"
941  "%%BeginPageSetup\n"
942  "gsave\n"
943  "0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
944  "linemode1\n", outputFile );
945 
946 
947  // Rototranslate the coordinate to achieve the landscape layout
948  if( !pageInfo.IsPortrait() )
949  fprintf( outputFile, "%d 0 translate 90 rotate\n", 10 * psPaperSize.x );
950 
951  // Apply the user fine scale adjustments
952  if( plotScaleAdjX != 1.0 || plotScaleAdjY != 1.0 )
953  fprintf( outputFile, "%g %g scale\n", plotScaleAdjX, plotScaleAdjY );
954 
955  // Set default line width
956  fprintf( outputFile, "%g setlinewidth\n",
958  fputs( "%%EndPageSetup\n", outputFile );
959 
960  return true;
961 }
962 
963 
965 {
966  wxASSERT( outputFile );
967  fputs( "showpage\n"
968  "grestore\n"
969  "%%EOF\n", outputFile );
970  fclose( outputFile );
971  outputFile = NULL;
972 
973  return true;
974 }
975 
976 
977 
978 void PS_PLOTTER::Text( const wxPoint& aPos,
979  const COLOR4D aColor,
980  const wxString& aText,
981  double aOrient,
982  const wxSize& aSize,
983  enum EDA_TEXT_HJUSTIFY_T aH_justify,
984  enum EDA_TEXT_VJUSTIFY_T aV_justify,
985  int aWidth,
986  bool aItalic,
987  bool aBold,
988  bool aMultilineAllowed,
989  void* aData )
990 {
991  SetCurrentLineWidth( aWidth );
992  SetColor( aColor );
993 
994  // Draw the hidden postscript text (if requested)
996  {
997  std::string ps_test = encodeStringForPlotter( aText );
998  DPOINT pos_dev = userToDeviceCoordinates( aPos );
999  fprintf( outputFile, "%s %g %g phantomshow\n", ps_test.c_str(), pos_dev.x, pos_dev.y );
1000  }
1001 
1002  PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
1003  aItalic, aBold, aMultilineAllowed );
1004 }
1005 
1006 
1010 const double hv_widths[256] = {
1011  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1012  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1013  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1014  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1015  0.278, 0.278, 0.355, 0.556, 0.556, 0.889, 0.667, 0.191,
1016  0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278,
1017  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556,
1018  0.556, 0.556, 0.278, 0.278, 0.584, 0.584, 0.584, 0.556,
1019  1.015, 0.667, 0.667, 0.722, 0.722, 0.667, 0.611, 0.778,
1020  0.722, 0.278, 0.500, 0.667, 0.556, 0.833, 0.722, 0.778,
1021  0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944,
1022  0.667, 0.667, 0.611, 0.278, 0.278, 0.278, 0.469, 0.556,
1023  0.333, 0.556, 0.556, 0.500, 0.556, 0.556, 0.278, 0.556,
1024  0.556, 0.222, 0.222, 0.500, 0.222, 0.833, 0.556, 0.556,
1025  0.556, 0.556, 0.333, 0.500, 0.278, 0.556, 0.500, 0.722,
1026  0.500, 0.500, 0.500, 0.334, 0.260, 0.334, 0.584, 0.278,
1027  0.278, 0.278, 0.222, 0.556, 0.333, 1.000, 0.556, 0.556,
1028  0.333, 1.000, 0.667, 0.333, 1.000, 0.278, 0.278, 0.278,
1029  0.278, 0.222, 0.222, 0.333, 0.333, 0.350, 0.556, 1.000,
1030  0.333, 1.000, 0.500, 0.333, 0.944, 0.278, 0.278, 0.667,
1031  0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.260, 0.556,
1032  0.333, 0.737, 0.370, 0.556, 0.584, 0.333, 0.737, 0.333,
1033  0.400, 0.584, 0.333, 0.333, 0.333, 0.556, 0.537, 0.278,
1034  0.333, 0.333, 0.365, 0.556, 0.834, 0.834, 0.834, 0.611,
1035  0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 1.000, 0.722,
1036  0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278,
1037  0.722, 0.722, 0.778, 0.778, 0.778, 0.778, 0.778, 0.584,
1038  0.778, 0.722, 0.722, 0.722, 0.722, 0.667, 0.667, 0.611,
1039  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.889, 0.500,
1040  0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278,
1041  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584,
1042  0.611, 0.556, 0.556, 0.556, 0.556, 0.500, 0.556, 0.500
1043 };
1044 
1048 const double hvb_widths[256] = {
1049  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1050  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1051  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1052  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1053  0.278, 0.333, 0.474, 0.556, 0.556, 0.889, 0.722, 0.238,
1054  0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278,
1055  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556,
1056  0.556, 0.556, 0.333, 0.333, 0.584, 0.584, 0.584, 0.611,
1057  0.975, 0.722, 0.722, 0.722, 0.722, 0.667, 0.611, 0.778,
1058  0.722, 0.278, 0.556, 0.722, 0.611, 0.833, 0.722, 0.778,
1059  0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944,
1060  0.667, 0.667, 0.611, 0.333, 0.278, 0.333, 0.584, 0.556,
1061  0.333, 0.556, 0.611, 0.556, 0.611, 0.556, 0.333, 0.611,
1062  0.611, 0.278, 0.278, 0.556, 0.278, 0.889, 0.611, 0.611,
1063  0.611, 0.611, 0.389, 0.556, 0.333, 0.611, 0.556, 0.778,
1064  0.556, 0.556, 0.500, 0.389, 0.280, 0.389, 0.584, 0.278,
1065  0.278, 0.278, 0.278, 0.556, 0.500, 1.000, 0.556, 0.556,
1066  0.333, 1.000, 0.667, 0.333, 1.000, 0.278, 0.278, 0.278,
1067  0.278, 0.278, 0.278, 0.500, 0.500, 0.350, 0.556, 1.000,
1068  0.333, 1.000, 0.556, 0.333, 0.944, 0.278, 0.278, 0.667,
1069  0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.280, 0.556,
1070  0.333, 0.737, 0.370, 0.556, 0.584, 0.333, 0.737, 0.333,
1071  0.400, 0.584, 0.333, 0.333, 0.333, 0.611, 0.556, 0.278,
1072  0.333, 0.333, 0.365, 0.556, 0.834, 0.834, 0.834, 0.611,
1073  0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722,
1074  0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278,
1075  0.722, 0.722, 0.778, 0.778, 0.778, 0.778, 0.778, 0.584,
1076  0.778, 0.722, 0.722, 0.722, 0.722, 0.667, 0.667, 0.611,
1077  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.889, 0.556,
1078  0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278,
1079  0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584,
1080  0.611, 0.611, 0.611, 0.611, 0.611, 0.556, 0.611, 0.556
1081 };
1082 
1086 const double hvo_widths[256] = {
1087  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1088  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1089  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1090  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1091  0.278, 0.278, 0.355, 0.556, 0.556, 0.889, 0.667, 0.191,
1092  0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278,
1093  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556,
1094  0.556, 0.556, 0.278, 0.278, 0.584, 0.584, 0.584, 0.556,
1095  1.015, 0.667, 0.667, 0.722, 0.722, 0.667, 0.611, 0.778,
1096  0.722, 0.278, 0.500, 0.667, 0.556, 0.833, 0.722, 0.778,
1097  0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944,
1098  0.667, 0.667, 0.611, 0.278, 0.278, 0.278, 0.469, 0.556,
1099  0.333, 0.556, 0.556, 0.500, 0.556, 0.556, 0.278, 0.556,
1100  0.556, 0.222, 0.222, 0.500, 0.222, 0.833, 0.556, 0.556,
1101  0.556, 0.556, 0.333, 0.500, 0.278, 0.556, 0.500, 0.722,
1102  0.500, 0.500, 0.500, 0.334, 0.260, 0.334, 0.584, 0.278,
1103  0.278, 0.278, 0.222, 0.556, 0.333, 1.000, 0.556, 0.556,
1104  0.333, 1.000, 0.667, 0.333, 1.000, 0.278, 0.278, 0.278,
1105  0.278, 0.222, 0.222, 0.333, 0.333, 0.350, 0.556, 1.000,
1106  0.333, 1.000, 0.500, 0.333, 0.944, 0.278, 0.278, 0.667,
1107  0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.260, 0.556,
1108  0.333, 0.737, 0.370, 0.556, 0.584, 0.333, 0.737, 0.333,
1109  0.400, 0.584, 0.333, 0.333, 0.333, 0.556, 0.537, 0.278,
1110  0.333, 0.333, 0.365, 0.556, 0.834, 0.834, 0.834, 0.611,
1111  0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 1.000, 0.722,
1112  0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278,
1113  0.722, 0.722, 0.778, 0.778, 0.778, 0.778, 0.778, 0.584,
1114  0.778, 0.722, 0.722, 0.722, 0.722, 0.667, 0.667, 0.611,
1115  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.889, 0.500,
1116  0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278,
1117  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584,
1118  0.611, 0.556, 0.556, 0.556, 0.556, 0.500, 0.556, 0.500
1119 };
1120 
1124 const double hvbo_widths[256] = {
1125  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1126  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1127  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1128  0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278, 0.278,
1129  0.278, 0.333, 0.474, 0.556, 0.556, 0.889, 0.722, 0.238,
1130  0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278,
1131  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556,
1132  0.556, 0.556, 0.333, 0.333, 0.584, 0.584, 0.584, 0.611,
1133  0.975, 0.722, 0.722, 0.722, 0.722, 0.667, 0.611, 0.778,
1134  0.722, 0.278, 0.556, 0.722, 0.611, 0.833, 0.722, 0.778,
1135  0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944,
1136  0.667, 0.667, 0.611, 0.333, 0.278, 0.333, 0.584, 0.556,
1137  0.333, 0.556, 0.611, 0.556, 0.611, 0.556, 0.333, 0.611,
1138  0.611, 0.278, 0.278, 0.556, 0.278, 0.889, 0.611, 0.611,
1139  0.611, 0.611, 0.389, 0.556, 0.333, 0.611, 0.556, 0.778,
1140  0.556, 0.556, 0.500, 0.389, 0.280, 0.389, 0.584, 0.278,
1141  0.278, 0.278, 0.278, 0.556, 0.500, 1.000, 0.556, 0.556,
1142  0.333, 1.000, 0.667, 0.333, 1.000, 0.278, 0.278, 0.278,
1143  0.278, 0.278, 0.278, 0.500, 0.500, 0.350, 0.556, 1.000,
1144  0.333, 1.000, 0.556, 0.333, 0.944, 0.278, 0.278, 0.667,
1145  0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.280, 0.556,
1146  0.333, 0.737, 0.370, 0.556, 0.584, 0.333, 0.737, 0.333,
1147  0.400, 0.584, 0.333, 0.333, 0.333, 0.611, 0.556, 0.278,
1148  0.333, 0.333, 0.365, 0.556, 0.834, 0.834, 0.834, 0.611,
1149  0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722,
1150  0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278,
1151  0.722, 0.722, 0.778, 0.778, 0.778, 0.778, 0.778, 0.584,
1152  0.778, 0.722, 0.722, 0.722, 0.722, 0.667, 0.667, 0.611,
1153  0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.889, 0.556,
1154  0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278,
1155  0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584,
1156  0.611, 0.611, 0.611, 0.611, 0.611, 0.556, 0.611, 0.556
1157 };
const double hvb_widths[256]
Character widths for Helvetica-Bold.
const double hv_widths[256]
Character widths for Helvetica.
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
Definition: PS_plotter.cpp:407
double GetDotMarkLenIU() const
Definition: plotter.cpp:140
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:48
int OutlineCount() const
Returns the number of outlines in the set
virtual void emitSetRGBColor(double r, double g, double b) override
Virtual primitive for emitting the setrgbcolor operator.
Definition: PS_plotter.cpp:542
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
Definition: PS_plotter.cpp:248
int GetHeightMils() const
Definition: page_info.h:141
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
Definition: PS_plotter.cpp:762
int color
Definition: DXF_plotter.cpp:61
virtual bool EndPlot() override
Definition: PS_plotter.cpp:964
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:88
const wxString & GetType() const
Definition: page_info.h:98
bool colorMode
Definition: plotter.h:589
const double hvo_widths[256]
Character widths for Helvetica-Oblique.
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Function PlotPoly.
Definition: PS_plotter.cpp:635
char penState
Definition: plotter.h:592
bool IsCustom() const
Function IsCustom returns true if the type is Custom.
Definition: page_info.cpp:180
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
PLOT_TEXT_MODE m_textMode
How to draw text.
Definition: plotter.h:787
double m_IUsPerDecimil
Definition: plotter.h:571
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
int PointCount() const
Function PointCount()
virtual std::string encodeStringForPlotter(const wxString &aUnicode)
convert a wxString unicode string to a char string compatible with the accepted string plotter format...
Definition: PS_plotter.cpp:303
wxPoint plotOffset
Plot offset (in IUs)
Definition: plotter.h:577
wxPoint penLastpos
Definition: plotter.h:593
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCircle
Definition: PS_plotter.cpp:108
PAGE_INFO pageInfo
Definition: plotter.h:598
This file contains miscellaneous commonly used macros and functions.
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: gr_text.cpp:222
double GetDashGapLenIU() const
Definition: plotter.cpp:152
virtual int GetCurrentLineWidth() const
Definition: plotter.h:158
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:100
const VECTOR2I & CPoint(int aIndex) const
Function Point()
virtual bool StartPlot() override
The code within this function (and the CloseFilePS function) creates postscript files whose contents ...
Definition: PS_plotter.cpp:810
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:119
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCustom
Definition: PS_plotter.cpp:214
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plotter.h:581
#define NULL
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:323
virtual void emitSetRGBColor(double r, double g, double b)=0
Virtual primitive for emitting the setrgbcolor operator.
SHAPE_POLY_SET.
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRoundRect
Definition: PS_plotter.cpp:178
int returnPostscriptTextWidth(const wxString &aText, int aXSize, bool aItalic, bool aBold)
Sister function for the GraphicTextWidth in drawtxt.cpp Does the same processing (i....
Definition: PS_plotter.cpp:348
double plotScaleAdjY
Definition: plotter.h:784
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 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.
Definition: PS_plotter.cpp:978
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRect
Definition: PS_plotter.cpp:129
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.
Definition: PS_plotter.cpp:599
virtual void SetColor(COLOR4D color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values,...
Definition: PS_plotter.cpp:52
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Definition: PS_plotter.cpp:588
Base window classes and related definitions.
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:565
RENDER_SETTINGS * m_renderSettings
Definition: plotter.h:603
const wxSize & GetSizeMils() const
Definition: page_info.h:143
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 SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Definition: PS_plotter.cpp:522
PLOT_DASH_TYPE
Enum for choosing dashed line type.
Definition: plotter.h:87
static const double postscriptTextAscent
Height of the postscript font (from the AFM)
Definition: plotter.h:778
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:55
Definition: color4d.h:48
wxString title
Definition: plotter.h:597
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:94
virtual void PlotImage(const wxImage &aImage, const wxPoint &aPos, double aScaleFactor) override
Postscript-likes at the moment are the only plot engines supporting bitmaps...
Definition: PS_plotter.cpp:660
int currentPenWidth
Definition: plotter.h:591
virtual void FlashRegularPolygon(const wxPoint &aShapePos, int aDiameter, int aCornerCount, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
Flash a regular polygon.
Definition: PS_plotter.cpp:294
const double hvbo_widths[256]
Character widths for Helvetica-BoldOblique.
bool IsPortrait() const
Definition: page_info.h:122
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Definition: PS_plotter.cpp:577
double GetDashMarkLenIU() const
Definition: plotter.cpp:146
SHAPE_LINE_CHAIN.
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData)
Definition: plotter.cpp:507
double plotScaleAdjX
Fine user scale adjust ( = 1.0 if no correction)
Definition: plotter.h:784
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plotter.h:586
double DECIDEG2RAD(double deg)
Definition: trigo.h:223
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
The common library.
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
void postscriptOverlinePositions(const wxString &aText, int aXSize, bool aItalic, bool aBold, std::vector< int > *pos_pairs)
Computes the x coordinates for the overlining in a string of text.
Definition: PS_plotter.cpp:377
int GetDefaultPenWidth() const
void computeTextParameters(const wxPoint &aPos, const wxString &aText, int aOrient, const wxSize &aSize, bool aMirror, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, double *wideningFactor, double *ctm_a, double *ctm_b, double *ctm_c, double *ctm_d, double *ctm_e, double *ctm_f, double *heightFactor)
This is the core for postscript/PDF text alignment It computes the transformation matrix to generate ...
Definition: PS_plotter.cpp:429
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadOval
Definition: PS_plotter.cpp:78
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
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:118
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
Definition: plotter.cpp:459
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
wxString creator
Definition: plotter.h:595
wxSize paperSize
Definition: plotter.h:599
int GetWidthMils() const
Definition: page_info.h:138
bool m_mirrorIsHorizontal
Definition: plotter.h:582
virtual void SetDash(PLOT_DASH_TYPE dashed) override
Postscript supports dashed lines.
Definition: PS_plotter.cpp:554
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
bool negativeMode
Definition: plotter.h:590