KiCad PCB EDA Suite
plot_common.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2016-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 
32 #ifndef PLOT_COMMON_H_
33 #define PLOT_COMMON_H_
34 
35 #include <vector>
36 #include <math/box2.h>
37 #include <drawtxt.h>
38 #include <class_page_info.h>
39 #include <eda_text.h> // FILL_T
40 
41 class SHAPE_POLY_SET;
43 
49 enum PlotFormat {
58 };
59 
77 };
78 
79 
86 class PLOTTER
87 {
88 private:
91 
92 public:
93  // These values are used as flag for pen or aperture selection
94  static const int DO_NOT_SET_LINE_WIDTH = -2; // Skip selection
95  static const int USE_DEFAULT_LINE_WIDTH = -1; // use the default pen
96 
97  PLOTTER();
98 
99  virtual ~PLOTTER();
100 
106  virtual PlotFormat GetPlotterType() const = 0;
107 
108  virtual bool StartPlot() = 0;
109  virtual bool EndPlot() = 0;
110 
111  virtual void SetNegative( bool _negative )
112  {
113  negativeMode = _negative;
114  }
115 
116  virtual void SetColorMode( bool _color_mode )
117  {
118  colorMode = _color_mode;
119  }
120 
121  bool GetColorMode() const
122  {
123  return colorMode;
124  }
125 
126  virtual void SetPageSettings( const PAGE_INFO& aPageSettings );
127 
133  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) = 0;
134 
140  virtual void SetDefaultLineWidth( int width ) = 0;
141 
142  virtual int GetCurrentLineWidth() const
143  {
144  return currentPenWidth;
145  }
146 
147  virtual void SetColor( COLOR4D color ) = 0;
148 
149  virtual void SetDash( bool dashed ) = 0;
150 
151  virtual void SetCreator( const wxString& aCreator )
152  {
153  creator = aCreator;
154  }
155 
156  virtual void SetTitle( const wxString& aTitle )
157  {
158  title = aTitle;
159  }
160 
166  void AddLineToHeader( const wxString& aExtraString )
167  {
168  m_headerExtraLines.Add( aExtraString );
169  }
170 
176  {
177  m_headerExtraLines.Clear();
178  }
179 
189  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
190  double aScale, bool aMirror ) = 0;
191 
200  virtual bool OpenFile( const wxString& aFullFilename );
201 
207  double GetIUsPerDecimil() const { return m_IUsPerDecimil; }
208 
209  // Low level primitives
210  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
211  int width = USE_DEFAULT_LINE_WIDTH ) = 0;
212  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
213  int width = USE_DEFAULT_LINE_WIDTH ) = 0;
214 
218  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
219  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH );
220 
228  virtual void PenTo( const wxPoint& pos, char plume ) = 0;
229 
230  // Convenience functions for PenTo
231  void MoveTo( const wxPoint& pos )
232  {
233  PenTo( pos, 'U' );
234  }
235 
236  void LineTo( const wxPoint& pos )
237  {
238  PenTo( pos, 'D' );
239  }
240 
241  void FinishTo( const wxPoint& pos )
242  {
243  PenTo( pos, 'D' );
244  PenTo( pos, 'Z' );
245  }
246 
247  void PenFinish()
248  {
249  // The point is not important with Z motion
250  PenTo( wxPoint( 0, 0 ), 'Z' );
251  }
252 
261  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill,
262  int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) = 0;
263 
274  virtual void PlotImage( const wxImage & aImage, const wxPoint& aPos,
275  double aScaleFactor );
276 
277  // Higher level primitives -- can be drawn as line, sketch or 'filled'
278  virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
279  EDA_DRAW_MODE_T tracemode, void* aData );
280  virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
281  int rayon, int width, EDA_DRAW_MODE_T tracemode, void* aData );
282  virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
283  EDA_DRAW_MODE_T tracemode, void* aData );
284  virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
285  EDA_DRAW_MODE_T tracemode, void* aData );
286 
287  // Flash primitives
288 
296  virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
297  EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
298 
307  virtual void FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
308  EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
309 
318  virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
319  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
320 
330  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
331  int aCornerRadius, double aOrient,
332  EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
333 
342  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
343  SHAPE_POLY_SET* aPolygons,
344  EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
345 
355  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
356  double aPadOrient, EDA_DRAW_MODE_T aTraceMode,
357  void* aData ) = 0;
358 
359 
364  virtual void Text( const wxPoint& aPos,
365  const COLOR4D aColor,
366  const wxString& aText,
367  double aOrient,
368  const wxSize& aSize,
369  enum EDA_TEXT_HJUSTIFY_T aH_justify,
370  enum EDA_TEXT_VJUSTIFY_T aV_justify,
371  int aWidth,
372  bool aItalic,
373  bool aBold,
374  bool aMultilineAllowed = false,
375  void* aData = NULL );
376 
380  static const unsigned MARKER_COUNT = 58;
381 
387  void Marker( const wxPoint& position, int diametre, unsigned aShapeId );
388 
398  virtual void SetLayerPolarity( bool aPositive )
399  {
400  // NOP for most plotters
401  }
402 
407  virtual void SetTextMode( PlotTextMode mode )
408  {
409  // NOP for most plotters.
410  }
411 
412  virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false )
413  {
414  // NOP for most plotters. Only for Gerber plotter
415  }
416 
424  virtual void StartBlock( void* aData ) {}
425 
433  virtual void EndBlock( void* aData ) {}
434 
435 
436 protected:
437  // These are marker subcomponents
441  void markerCircle( const wxPoint& pos, int radius );
442 
446  void markerHBar( const wxPoint& pos, int radius );
447 
451  void markerSlash( const wxPoint& pos, int radius );
452 
456  void markerBackSlash( const wxPoint& pos, int radius );
457 
461  void markerVBar( const wxPoint& pos, int radius );
462 
466  void markerSquare( const wxPoint& position, int radius );
467 
471  void markerLozenge( const wxPoint& position, int radius );
472 
473  // Helper function for sketched filler segment
474 
478  void segmentAsOval( const wxPoint& start, const wxPoint& end, int width,
479  EDA_DRAW_MODE_T tracemode );
480 
481  void sketchOval( const wxPoint& pos, const wxSize& size, double orient, int width );
482 
483  // Coordinate and scaling conversion functions
484 
490  virtual DPOINT userToDeviceCoordinates( const wxPoint& aCoordinate );
491 
496  virtual DPOINT userToDeviceSize( const wxSize& size );
497 
502  virtual double userToDeviceSize( double size ) const;
503 
504  double GetDashMarkLenIU() const;
505 
506  double GetDashGapLenIU() const;
507 
508 protected: // variables used in most of plotters:
510  double plotScale;
511 
512  /* Caller scale (how many IUs in a decimil - always); it's a double
513  * because in eeschema there are 0.1 IUs in a decimil (eeschema
514  * always works in mils internally) while pcbnew can work in decimil
515  * or nanometers, so this value would be >= 1 */
517 
520 
523 
529 
531  FILE* outputFile;
532 
533  // Pen handling
534  bool colorMode;
539  char penState;
542  wxString creator;
543  wxString filename;
544  wxString title;
547  wxSize paperSize;
548 
549  wxArrayString m_headerExtraLines;
550 };
551 
552 
553 class HPGL_PLOTTER : public PLOTTER
554 {
555 public:
556  HPGL_PLOTTER();
557 
558  virtual PlotFormat GetPlotterType() const override
559  {
560  return PLOT_FORMAT_HPGL;
561  }
562 
563  static wxString GetDefaultFileExtension()
564  {
565  return wxString( wxT( "plt" ) );
566  }
567 
568  virtual bool StartPlot() override;
569  virtual bool EndPlot() override;
570 
572  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
573  {
574  // This is the truth
576  }
577 
578  virtual void SetDefaultLineWidth( int width ) override {}
579  virtual void SetDash( bool dashed ) override;
580 
581  virtual void SetColor( COLOR4D color ) override {}
582 
583  virtual void SetPenSpeed( int speed )
584  {
585  penSpeed = speed;
586  }
587 
588  virtual void SetPenNumber( int number )
589  {
590  penNumber = number;
591  }
592 
593  virtual void SetPenDiameter( double diameter );
594 
595  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
596  double aScale, bool aMirror ) override;
597  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
598  int width = USE_DEFAULT_LINE_WIDTH ) override;
599  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
600  int width = USE_DEFAULT_LINE_WIDTH ) override;
601  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
602  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
603  void * aData = NULL) override;
604 
605  virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
606  EDA_DRAW_MODE_T tracemode, void* aData ) override;
607  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
608  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
609  virtual void PenTo( const wxPoint& pos, char plume ) override;
610  virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
611  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
612  virtual void FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
613  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
614  virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
615  double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
616  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
617  int aCornerRadius, double aOrient,
618  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
619  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
620  SHAPE_POLY_SET* aPolygons,
621  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
622  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
623  double aPadOrient, EDA_DRAW_MODE_T aTraceMode,
624  void* aData ) override;
625 
626 protected:
627  void penControl( char plume );
628 
629  int penSpeed;
631  double penDiameter;
632 };
633 
639 class PSLIKE_PLOTTER : public PLOTTER
640 {
641 public:
644  {
645  }
646 
650  virtual void SetTextMode( PlotTextMode mode ) override
651  {
652  if( mode != PLOTTEXTMODE_DEFAULT )
653  m_textMode = mode;
654  }
655 
656  virtual void SetDefaultLineWidth( int width ) override;
657 
661  void SetScaleAdjust( double scaleX, double scaleY )
662  {
663  plotScaleAdjX = scaleX;
664  plotScaleAdjY = scaleY;
665  }
666 
667  // Pad routines are handled with lower level primitives
668  virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
669  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
670  virtual void FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
671  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
672  virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
673  double aPadOrient, EDA_DRAW_MODE_T aTraceMode,
674  void* aData ) override;
675  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
676  int aCornerRadius, double aOrient,
677  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
678  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
679  SHAPE_POLY_SET* aPolygons,
680  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
681  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
682  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
683 
688  virtual void SetColor( COLOR4D color ) override;
689 
690 protected:
691  void computeTextParameters( const wxPoint& aPos,
692  const wxString& aText,
693  int aOrient,
694  const wxSize& aSize,
695  bool aMirror,
696  enum EDA_TEXT_HJUSTIFY_T aH_justify,
697  enum EDA_TEXT_VJUSTIFY_T aV_justify,
698  int aWidth,
699  bool aItalic,
700  bool aBold,
701  double *wideningFactor,
702  double *ctm_a,
703  double *ctm_b,
704  double *ctm_c,
705  double *ctm_d,
706  double *ctm_e,
707  double *ctm_f,
708  double *heightFactor );
709  void postscriptOverlinePositions( const wxString& aText, int aXSize,
710  bool aItalic, bool aBold,
711  std::vector<int> *pos_pairs );
712  void fputsPostscriptString(FILE *fout, const wxString& txt);
713 
715  virtual void emitSetRGBColor( double r, double g, double b ) = 0;
716 
718  static const double postscriptTextAscent; // = 0.718;
719 
720  int returnPostscriptTextWidth( const wxString& aText, int aXSize,
721  bool aItalic, bool aBold );
722 
725 
728 };
729 
730 
732 {
733 public:
735  {
736  // The phantom plot in postscript is an hack and reportedly
737  // crashes Adobe's own postscript interpreter!
739  }
740 
741  static wxString GetDefaultFileExtension()
742  {
743  return wxString( wxT( "ps" ) );
744  }
745 
746  virtual PlotFormat GetPlotterType() const override
747  {
748  return PLOT_FORMAT_POST;
749  }
750 
751  virtual bool StartPlot() override;
752  virtual bool EndPlot() override;
753  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
754  virtual void SetDash( bool dashed ) override;
755 
756  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
757  double aScale, bool aMirror ) override;
758  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
759  int width = USE_DEFAULT_LINE_WIDTH ) override;
760  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
761  int width = USE_DEFAULT_LINE_WIDTH ) override;
762  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
763  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
764 
765  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
766  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
767  void * aData = NULL ) override;
768 
769  virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
770  double aScaleFactor ) override;
771 
772  virtual void PenTo( const wxPoint& pos, char plume ) override;
773  virtual void Text( const wxPoint& aPos,
774  const COLOR4D aColor,
775  const wxString& aText,
776  double aOrient,
777  const wxSize& aSize,
778  enum EDA_TEXT_HJUSTIFY_T aH_justify,
779  enum EDA_TEXT_VJUSTIFY_T aV_justify,
780  int aWidth,
781  bool aItalic,
782  bool aBold,
783  bool aMultilineAllowed = false,
784  void* aData = NULL ) override;
785 protected:
786  virtual void emitSetRGBColor( double r, double g, double b ) override;
787 };
788 
790 {
791 public:
793  {
794  // Avoid non initialized variables:
796  pageTreeHandle = 0;
797  }
798 
799  virtual PlotFormat GetPlotterType() const override
800  {
801  return PLOT_FORMAT_PDF;
802  }
803 
804  static wxString GetDefaultFileExtension()
805  {
806  return wxString( wxT( "pdf" ) );
807  }
808 
817  virtual bool OpenFile( const wxString& aFullFilename ) override;
818 
819  virtual bool StartPlot() override;
820  virtual bool EndPlot() override;
821  virtual void StartPage();
822  virtual void ClosePage();
823  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
824  virtual void SetDash( bool dashed ) override;
825 
828  virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
829  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
830  double aScale, bool aMirror ) override;
831  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
832  int width = USE_DEFAULT_LINE_WIDTH ) override;
833  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
834  int width = USE_DEFAULT_LINE_WIDTH ) override;
835  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
836  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
837 
838  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
839  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
840  void * aData = NULL ) override;
841 
842  virtual void PenTo( const wxPoint& pos, char plume ) override;
843 
844  virtual void Text( const wxPoint& aPos,
845  const COLOR4D aColor,
846  const wxString& aText,
847  double aOrient,
848  const wxSize& aSize,
849  enum EDA_TEXT_HJUSTIFY_T aH_justify,
850  enum EDA_TEXT_VJUSTIFY_T aV_justify,
851  int aWidth,
852  bool aItalic,
853  bool aBold,
854  bool aMultilineAllowed = false,
855  void* aData = NULL ) override;
856 
857  virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
858  double aScaleFactor ) override;
859 
860 
861 protected:
862  virtual void emitSetRGBColor( double r, double g, double b ) override;
863  int allocPdfObject();
864  int startPdfObject(int handle = -1);
865  void closePdfObject();
866  int startPdfStream(int handle = -1);
867  void closePdfStream();
870  std::vector<int> pageHandles;
873  wxString workFilename;
874  FILE* workFile;
875  std::vector<long> xrefTable;
876 };
877 
879 {
880 public:
881  SVG_PLOTTER();
882 
883  static wxString GetDefaultFileExtension()
884  {
885  return wxString( wxT( "svg" ) );
886  }
887 
888  virtual PlotFormat GetPlotterType() const override
889  {
890  return PLOT_FORMAT_SVG;
891  }
892 
893  virtual void SetColor( COLOR4D color ) override;
894  virtual bool StartPlot() override;
895  virtual bool EndPlot() override;
896  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
897  virtual void SetDash( bool dashed ) override;
898 
899  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
900  double aScale, bool aMirror ) override;
901  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
902  int width = USE_DEFAULT_LINE_WIDTH ) override;
903  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
904  int width = USE_DEFAULT_LINE_WIDTH ) override;
905  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
906  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
907 
908  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
909  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
910  void * aData = NULL ) override;
911 
912  virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
913  double aScaleFactor ) override;
914 
915  virtual void PenTo( const wxPoint& pos, char plume ) override;
916  virtual void Text( const wxPoint& aPos,
917  const COLOR4D aColor,
918  const wxString& aText,
919  double aOrient,
920  const wxSize& aSize,
921  enum EDA_TEXT_HJUSTIFY_T aH_justify,
922  enum EDA_TEXT_VJUSTIFY_T aV_justify,
923  int aWidth,
924  bool aItalic,
925  bool aBold,
926  bool aMultilineAllowed = false,
927  void* aData = NULL ) override;
928 
929 protected:
930  FILL_T m_fillMode; // true if the current contour
931  // rect, arc, circle, polygon must be filled
932  long m_pen_rgb_color; // current rgb color value: each color has
933  // a value 0 ... 255, and the 3 colors are
934  // grouped in a 3x8 bits value
935  // (written in hex to svg files)
936  long m_brush_rgb_color; // same as m_pen_rgb_color, used to fill
937  // some contours.
938  bool m_graphics_changed; // true if a pen/brush parameter is modified
939  // color, pen size, fil mode ...
940  // the new SVG stype must be output on file
941  bool m_dashed; // true to use plot dashed line style
942 
948  virtual void emitSetRGBColor( double r, double g, double b ) override;
949 
954  void setSVGPlotStyle();
955 
960  void setFillMode( FILL_T fill );
961 };
962 
963 /* Class to handle a D_CODE when plotting a board : */
964 #define FIRST_DCODE_VALUE 10 // D_CODE < 10 is a command, D_CODE >= 10 is a tool
965 
966 class APERTURE
967 {
968 public:
970  Circle = 1,
971  Rect = 2,
972  Plotting = 3,
973  Oval = 4
974  };
975 
976  wxSize m_Size; // horiz and Vert size
977  APERTURE_TYPE m_Type; // Type ( Line, rect , circulaire , ovale .. )
978  int m_DCode; // code number ( >= 10 );
979  int m_ApertureAttribute; // the attribute attached to this aperture
980  // Only one attribute is allowed by aperture
981  // 0 = no specific aperture attribute
982 };
983 
984 
985 class GERBER_PLOTTER : public PLOTTER
986 {
987 public:
988  GERBER_PLOTTER();
989 
990  virtual PlotFormat GetPlotterType() const override
991  {
992  return PLOT_FORMAT_GERBER;
993  }
994 
995  static wxString GetDefaultFileExtension()
996  {
997  return wxString( wxT( "gbr" ) );
998  }
999 
1005  virtual bool StartPlot() override;
1006  virtual bool EndPlot() override;
1007  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
1008  virtual void SetDefaultLineWidth( int width ) override;
1009 
1010  // RS274X has no dashing, nor colours
1011  virtual void SetDash( bool dashed ) override {}
1012  virtual void SetColor( COLOR4D color ) override {}
1013  // Currently, aScale and aMirror are not used in gerber plotter
1014  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
1015  double aScale, bool aMirror ) override;
1016  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
1017  int width = USE_DEFAULT_LINE_WIDTH ) override;
1018  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
1019  int width = USE_DEFAULT_LINE_WIDTH ) override;
1020  virtual void Arc( const wxPoint& aCenter, double aStAngle, double aEndAngle,
1021  int aRadius, FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
1022 
1023  virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
1024  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1025 
1026  virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
1027  int rayon, int width, EDA_DRAW_MODE_T tracemode, void* aData ) override;
1028  virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
1029  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1030  virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
1031  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1036  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
1037  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
1038  void * aData = NULL ) override;
1039 
1040  virtual void PenTo( const wxPoint& pos, char plume ) override;
1041 
1042  virtual void Text( const wxPoint& aPos,
1043  const COLOR4D aColor,
1044  const wxString& aText,
1045  double aOrient,
1046  const wxSize& aSize,
1047  enum EDA_TEXT_HJUSTIFY_T aH_justify,
1048  enum EDA_TEXT_VJUSTIFY_T aV_justify,
1049  int aWidth,
1050  bool aItalic,
1051  bool aBold,
1052  bool aMultilineAllowed = false,
1053  void* aData = NULL ) override;
1054 
1058  virtual void FlashPadCircle( const wxPoint& pos, int diametre,
1059  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1060 
1064  virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, double orient,
1065  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1071  virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
1072  double orient, EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1073 
1079  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
1080  int aCornerRadius, double aOrient,
1081  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1082  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
1083  SHAPE_POLY_SET* aPolygons,
1084  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1090  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
1091  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1092 
1097  virtual void SetLayerPolarity( bool aPositive ) override;
1098 
1109  virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false ) override;
1110 
1111  void UseX2Attributes( bool aEnable ) { m_useX2Attributes = aEnable; }
1112  void UseX2NetAttributes( bool aEnable ) { m_useNetAttributes = aEnable; }
1113 
1119  virtual void StartBlock( void* aData ) override;
1120 
1127  virtual void EndBlock( void* aData ) override;
1128 
1129 protected:
1135  void selectAperture( const wxSize& aSize, APERTURE::APERTURE_TYPE aType,
1136  int aApertureAttribute );
1137 
1143  void emitDcode( const DPOINT& pt, int dcode );
1144 
1153 
1158  void clearNetAttribute();
1159 
1168  std::vector<APERTURE>::iterator getAperture( const wxSize& aSize,
1169  APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
1170 
1171  // the attributes dictionnary created/modifed by %TO, attached the objects, when they are created
1172  // by D01, D03 G36/G37 commands
1173  // standard attributes are .P, .C and .N
1174  // this is used by gerber readers when creating a new object. Cleared by %TD command
1175  // Note: m_objectAttributesDictionnary can store more than one attribute
1176  // the string stores the line(s) actually written to the gerber file
1177  // it can store a .P, .C or .N attribute, or 2 or 3 attributes, separated by a \n char (EOL)
1179 
1180  // The last aperture attribute generated (only one aperture attribute can be set)
1182 
1183  FILE* workFile;
1184  FILE* finalFile;
1185  wxString m_workFilename;
1186 
1190  void writeApertureList();
1191 
1192  std::vector<APERTURE> apertures;
1193  std::vector<APERTURE>::iterator currentAperture;
1194 
1195  bool m_gerberUnitInch; // true if the gerber units are inches, false for mm
1196  int m_gerberUnitFmt; // number of digits in mantissa.
1197  // usually 6 in Inches and 5 or 6 in mm
1198  bool m_useX2Attributes; // In recent gerber files, attributes can be added.
1199  // It will be added if this parm is true
1200  bool m_useNetAttributes; // In recent gerber files, netlist info can be added.
1201  // It will be added if this parm is true
1202  // (imply m_useX2Attributes == true)
1203 };
1204 
1205 
1206 class DXF_PLOTTER : public PLOTTER
1207 {
1208 public:
1210  {
1211  textAsLines = true;
1213  }
1214 
1215  virtual PlotFormat GetPlotterType() const override
1216  {
1217  return PLOT_FORMAT_DXF;
1218  }
1219 
1220  static wxString GetDefaultFileExtension()
1221  {
1222  return wxString( wxT( "dxf" ) );
1223  }
1224 
1228  virtual void SetTextMode( PlotTextMode mode ) override
1229  {
1230  if( mode != PLOTTEXTMODE_DEFAULT )
1231  textAsLines = ( mode != PLOTTEXTMODE_NATIVE );
1232  }
1233 
1234  virtual bool StartPlot() override;
1235  virtual bool EndPlot() override;
1236 
1237  // For now we don't use 'thick' primitives, so no line width
1238  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
1239  {
1240  currentPenWidth = 0;
1241  }
1242 
1243  virtual void SetDefaultLineWidth( int width ) override
1244  {
1245  // DXF lines are infinitesimal
1246  defaultPenWidth = 0;
1247  }
1248 
1249  virtual void SetDash( bool dashed ) override;
1250 
1251  virtual void SetColor( COLOR4D color ) override;
1252 
1253  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
1254  double aScale, bool aMirror ) override;
1255  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
1256  int width = USE_DEFAULT_LINE_WIDTH ) override;
1257  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
1258  int width = USE_DEFAULT_LINE_WIDTH ) override;
1259  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
1260  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) override;
1261  virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
1262  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1263  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
1264  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
1265  virtual void PenTo( const wxPoint& pos, char plume ) override;
1266 
1267  virtual void FlashPadCircle( const wxPoint& pos, int diametre,
1268  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1269  virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, double orient,
1270  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1271  virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
1272  double orient, EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1273  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
1274  int aCornerRadius, double aOrient,
1275  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1276  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
1277  SHAPE_POLY_SET* aPolygons,
1278  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1279  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
1280  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1281 
1282  virtual void Text( const wxPoint& aPos,
1283  const COLOR4D aColor,
1284  const wxString& aText,
1285  double aOrient,
1286  const wxSize& aSize,
1287  enum EDA_TEXT_HJUSTIFY_T aH_justify,
1288  enum EDA_TEXT_VJUSTIFY_T aV_justify,
1289  int aWidth,
1290  bool aItalic,
1291  bool aBold,
1292  bool aMultilineAllowed = false,
1293  void* aData = NULL ) override;
1294 
1295 protected:
1298 };
1299 
1300 class TITLE_BLOCK;
1301 void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
1302  const PAGE_INFO& aPageInfo,
1303  int aSheetNumber, int aNumberOfSheets,
1304  const wxString &aSheetDesc,
1305  const wxString &aFilename );
1306 
1309 wxString GetDefaultPlotExtension( PlotFormat aFormat );
1310 
1311 
1312 #endif // PLOT_COMMON_H_
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
std::vector< APERTURE >::iterator getAperture(const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Function getAperture returns a reference to the aperture which meets the size anf type of tool if the...
static wxString GetDefaultFileExtension()
Definition: plot_common.h:804
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:888
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
DXF polygon: doesn't fill it but at least it close the filled ones DXF does not know thick outline...
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
Roundrect pad at the moment are not handled as aperture, since they require aperture macros TODO: alw...
virtual bool EndPlot() override
HPGL end of plot: pen return and release.
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
void writeApertureList()
Generate the table of D codes.
void markerHBar(const wxPoint &pos, int radius)
Plot a - bar centered on the position.
void closePdfStream()
Finish the current PDF stream (writes the deferred length, too)
void clearNetAttribute()
clear a Gerber net attribute record (clear object attribute dictionnary) and output the clear object ...
virtual void SetColor(COLOR4D color) override
Definition: plot_common.h:581
virtual void SetCreator(const wxString &aCreator)
Definition: plot_common.h:151
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
void PenFinish()
Definition: plot_common.h:247
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
Trapezoidal pad at the moment are never handled as aperture, since they require aperture macros TODO:...
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCircle
static wxString GetDefaultFileExtension()
Definition: plot_common.h:741
void UseX2NetAttributes(bool aEnable)
Definition: plot_common.h:1112
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 EndBlock(void *aData)
calling this function allows to define the end of a group of drawing items for instance in SVG or Ger...
Definition: plot_common.h:433
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Definition: plot_common.h:1238
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 SetLayerPolarity(bool aPositive) override
Change the plot polarity and begin a new layer Used to 'scratch off' silk screen away from solder mas...
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 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.
virtual bool StartPlot()=0
virtual void EndBlock(void *aData) override
calling this function allows to define the end of a group of drawing items the group is started by St...
virtual bool EndPlot() override
FILL_T m_fillMode
Definition: plot_common.h:930
virtual void emitSetRGBColor(double r, double g, double b) override
Virtual primitive for emitting the setrgbcolor operator.
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
PlotFormat
Enum PlotFormat is the set of supported output plot formats.
Definition: plot_common.h:49
APERTURE_TYPE m_Type
Definition: plot_common.h:977
virtual void SetColor(COLOR4D color)=0
void setSVGPlotStyle()
function setSVGPlotStyle() output the string which define pen and brush color, shape, transparence
virtual void ThickCircle(const wxPoint &pos, int diametre, int width, EDA_DRAW_MODE_T tracemode, void *aData)
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot The DXF engine doesn't support line widths and mirroring...
void setFillMode(FILL_T fill)
function setFillMode() prepare parameters for setSVGPlotStyle()
virtual void StartPage()
Starts a new page in the PDF document.
virtual void SetTitle(const wxString &aTitle)
Definition: plot_common.h:156
wxSize m_Size
Definition: plot_common.h:976
bool textAsLines
Definition: plot_common.h:1296
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map)
Definition: plot_common.h:380
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
static wxString GetDefaultFileExtension()
Definition: plot_common.h:883
bool m_useNetAttributes
Definition: plot_common.h:1200
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
DXF trapezoidal pad: only sketch mode is supported.
int pageTreeHandle
Definition: plot_common.h:868
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
void SetScaleAdjust(double scaleX, double scaleY)
Set the 'fine' scaling for the postscript engine.
Definition: plot_common.h:661
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
virtual void SetLayerPolarity(bool aPositive)
Function SetLayerPolarity sets current Gerber layer polarity to positive or negative by writing %LPD*...
Definition: plot_common.h:398
virtual void SetDash(bool dashed) override
Dashed lines are not (yet) supported by DXF_PLOTTER.
The PSLIKE_PLOTTER class is an intermediate class to handle common routines for engines working more ...
Definition: plot_common.h:639
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCustom
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
virtual bool EndPlot() override
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCustom
virtual void SetPenDiameter(double diameter)
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.
virtual void StartBlock(void *aData)
calling this function allows to define the beginning of a group of drawing items, for instance in SVG...
Definition: plot_common.h:424
virtual void PenTo(const wxPoint &pos, char plume)=0
moveto/lineto primitive, moves the 'pen' to the specified direction
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:799
std::vector< int > pageHandles
Font resource dictionary.
Definition: plot_common.h:870
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
std::vector< APERTURE > apertures
Definition: plot_common.h:1192
virtual void SetDash(bool dashed) override
SVG supports dashed lines.
bool colorMode
Definition: plot_common.h:534
virtual ~PLOTTER()
void selectAperture(const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Function PlotPoly.
char penState
Current pen state: 'U', 'D' or 'Z' (see PenTo)
Definition: plot_common.h:539
void AddLineToHeader(const wxString &aExtraString)
Function AddLineToHeader Add a line to the list of free lines to print at the beginning of the file...
Definition: plot_common.h:166
COLOR4D m_currentColor
Definition: plot_common.h:1297
this class handle info which can be added in a gerber file as attribute of an obtect the GBR_INFO_TYP...
double m_IUsPerDecimil
Definition: plot_common.h:516
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
virtual void SetDash(bool dashed) override
HPGL supports dashed lines.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition of base KiCad text object.
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
wxArrayString m_headerExtraLines
Definition: plot_common.h:549
static wxString GetDefaultFileExtension()
Definition: plot_common.h:995
virtual bool StartPlot() override
At the start of the HPGL plot pen speed and number are requested.
virtual void FlashPadOval(const wxPoint &pos, const wxSize &size, double orient, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled oval flashes are handled as aperture in the 90 degree positions only.
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
Definition: plot_common.h:578
wxPoint plotOffset
Plot offset (in IUs)
Definition: plot_common.h:522
wxPoint penLastpos
Last pen positions; set to -1,-1 when the pen is at rest.
Definition: plot_common.h:541
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCircle
virtual bool StartPlot() override
Function StartPlot Write GERBER header to file initialize global variable g_Plot_PlotOutputFile.
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false)
Definition: plot_common.h:412
PAGE_INFO pageInfo
Definition: plot_common.h:545
virtual void SetDash(bool dashed) override
PDF supports dashed lines.
virtual void ThickArc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, EDA_DRAW_MODE_T tracemode, void *aData)
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadCustom
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 ThickRect(const wxPoint &p1, const wxPoint &p2, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
HPGL rectangle: fill not supported.
wxString workFilename
Handle to the deferred stream length.
Definition: plot_common.h:873
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 FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRoundRect
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Polygon plotting for PDF.
static wxString GetDefaultFileExtension()
Definition: plot_common.h:1220
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.
virtual void ThickRect(const wxPoint &p1, const wxPoint &p2, int width, EDA_DRAW_MODE_T tracemode, void *aData)
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.
double m_dashMarkLength_mm
Dashed line parameter in mm: segment.
Definition: plot_common.h:89
virtual bool EndPlot() override
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
double GetIUsPerDecimil() const
The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establ...
Definition: plot_common.h:207
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream)
bool m_yaxisReversed
true to mirror horizontally (else vertically)
Definition: plot_common.h:528
virtual bool EndPlot()=0
int streamLengthHandle
Handle of the page content object.
Definition: plot_common.h:872
virtual bool StartPlot() override
The code within this function (and the CloseFilePS function) creates postscript files whose contents ...
virtual void SetColor(COLOR4D color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values...
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:990
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadCircle
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual void SetDash(bool dashed)=0
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCustom
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plot_common.h:526
virtual bool StartPlot() override
Opens the DXF plot with a skeleton header.
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
PlotTextMode
Enum for choosing which kind of text to output with the PSLIKE plotters.
Definition: plot_common.h:72
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
HPGL doesn't handle line thickness or color.
Definition: plot_common.h:572
virtual void emitSetRGBColor(double r, double g, double b)=0
Virtual primitive for emitting the setrgbcolor operator.
Class SHAPE_POLY_SET.
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
The PDF engine can't directly plot arcs, it uses the base emulation.
long m_pen_rgb_color
Definition: plot_common.h:932
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRoundRect
int returnPostscriptTextWidth(const wxString &aText, int aXSize, bool aItalic, bool aBold)
Sister function for the GraphicTextWidth in drawtxt.cpp Does the same processing (i.e.
double plotScaleAdjY
Definition: plot_common.h:724
int startPdfStream(int handle=-1)
Starts a PDF stream (for the page).
EDA_DRAW_MODE_T
Definition: eda_text.h:62
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
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.
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.
virtual void SetTextMode(PlotTextMode mode)
Change the current text mode.
Definition: plot_common.h:407
int startPdfObject(int handle=-1)
Open a new PDF object and returns the handle if the parameter is -1.
virtual void SetPenSpeed(int speed)
Definition: plot_common.h:583
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRect
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadRoundRect
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.
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 SetColor(COLOR4D color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values...
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:510
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool EndPlot() override
virtual bool StartPlot() override
The code within this function creates SVG files header.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF rectangle: fill not supported.
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadOval
FILE * workFile
Definition: plot_common.h:874
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
virtual void FlashPadCircle(const wxPoint &pos, int diametre, EDA_DRAW_MODE_T trace_mode, void *aData) override
DXF round pad: always done in sketch mode; it could be filled but it isn't pretty if other kinds of p...
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
bool GetColorMode() const
Definition: plot_common.h:121
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual void ThickArc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
void markerSlash(const wxPoint &pos, int radius)
Plot a / bar centered on the position.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF circle: full functionality; it even does 'fills' drawing a circle with a dual-arc polyline wide a...
virtual void FlashPadCircle(const wxPoint &pos, int diametre, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror)=0
Set the plot offset and scaling for the current plot.
void closePdfObject()
Close the current PDF object.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
void Marker(const wxPoint &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRect
double m_dashGapLength_mm
Dashed line parameter in mm: gap.
Definition: plot_common.h:90
virtual void SetDefaultLineWidth(int width)=0
Set the default line width.
virtual void FlashPadRect(const wxPoint &pos, const wxSize &size, double orient, EDA_DRAW_MODE_T trace_mode, void *aData) override
DXF rectangular pad: alwayd done in sketch mode.
static const double postscriptTextAscent
Height of the postscript font (from the AFM)
Definition: plot_common.h:718
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
wxString title
Definition: plot_common.h:544
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Rectangles in PDF.
int fontResDictHandle
Handle to the root of the page tree object.
Definition: plot_common.h:869
bool m_useX2Attributes
Definition: plot_common.h:1198
Base plotter engine class.
Definition: plot_common.h:86
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadRect
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
virtual void PlotImage(const wxImage &aImage, const wxPoint &aPos, double aScaleFactor) override
Postscript-likes at the moment are the only plot engines supporting bitmaps...
void fputsPostscriptString(FILE *fout, const wxString &txt)
Write on a stream a string escaped for postscript/PDF.
virtual void emitSetRGBColor(double r, double g, double b) override
PDF supports colors fully.
virtual void StartBlock(void *aData) override
calling this function allows to define the beginning of a group of drawing items (used in X2 format w...
std::vector< long > xrefTable
Temporary file to costruct the stream before zipping.
Definition: plot_common.h:875
virtual void Arc(const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
int currentPenWidth
Definition: plot_common.h:537
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
virtual void SetDash(bool dashed) override
Postscript supports dashed lines.
int defaultPenWidth
true to generate a negative image (PS mode mainly)
Definition: plot_common.h:536
virtual bool EndPlot() override
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadOval
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
Definition: plot_common.h:1243
virtual PlotFormat GetPlotterType() const =0
Returns the effective plot engine in use.
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData)
bool m_graphics_changed
Definition: plot_common.h:938
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Circle drawing for PDF.
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:558
long m_brush_rgb_color
Definition: plot_common.h:936
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:1215
double plotScaleAdjX
Fine user scale adjust ( = 1.0 if no correction)
Definition: plot_common.h:724
virtual void SetColor(COLOR4D color) override
Definition: plot_common.h:1012
double penDiameter
Definition: plot_common.h:631
virtual void SetPenNumber(int number)
Definition: plot_common.h:588
void markerLozenge(const wxPoint &position, int radius)
Plot a lozenge centered on the position.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:531
static wxString GetDefaultFileExtension()
Definition: plot_common.h:563
std::string m_objectAttributesDictionnary
Definition: plot_common.h:1178
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...
void markerCircle(const wxPoint &pos, int radius)
Plot a circle centered on the position.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColor(COLOR4D color) override
The DXF exporter handles 'colors' as layers...
void ClearHeaderLinesList()
Function ClearHeaderLinesList remove all lines from the list of free lines to print at the beginning ...
Definition: plot_common.h:175
virtual void FlashPadOval(const wxPoint &pos, const wxSize &size, double orient, EDA_DRAW_MODE_T trace_mode, void *aData) override
DXF oval pad: always done in sketch mode.
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false) override
Function SetGerberCoordinatesFormat selection of Gerber units and resolution (number of digits in man...
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:56
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.
virtual void FlashPadRect(const wxPoint &pos, const wxSize &size, double orient, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled rect flashes are handled as aperture in the 0 90 180 or 270 degree orientation only and as pol...
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
This file is part of the common libary.
wxString m_workFilename
Definition: plot_common.h:1185
virtual void SetDash(bool dashed) override
Definition: plot_common.h:1011
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: colors.h:45
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadOval
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
PDF can have multiple pages, so SetPageSettings can be called with the outputFile open (but not insid...
int m_DCode
Definition: plot_common.h:978
virtual void SetTextMode(PlotTextMode mode) override
DXF handles NATIVE text emitting TEXT entities.
Definition: plot_common.h:1228
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.
void penControl(char plume)
Pen control logic (remove redundant pen activations)
double GetDashMarkLenIU() const
int m_ApertureAttribute
Definition: plot_common.h:979
virtual bool StartPlot() override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadCustom
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:519
static const int DO_NOT_SET_LINE_WIDTH
Definition: plot_common.h:94
void segmentAsOval(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode)
Cdonvert a thick segment and plot it as an oval.
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadTrapez flash a trapezoidal pad
wxString filename
Definition: plot_common.h:543
void markerVBar(const wxPoint &pos, int radius)
Plot a | bar centered on the position.
std::vector< APERTURE >::iterator currentAperture
Definition: plot_common.h:1193
PlotTextMode m_textMode
How to draw text.
Definition: plot_common.h:727
int allocPdfObject()
Allocate a new handle in the table of the PDF object.
virtual void ThickCircle(const wxPoint &pos, int diametre, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
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
void markerSquare(const wxPoint &position, int radius)
Plot a square centered on the position.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
void markerBackSlash(const wxPoint &pos, int radius)
Plot a \ bar centered on the position.
wxString GetDefaultPlotExtension(PlotFormat aFormat)
Returns the default plot extension for a format.
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
int pageStreamHandle
Handles to the page objects.
Definition: plot_common.h:871
void UseX2Attributes(bool aEnable)
Definition: plot_common.h:1111
virtual void SetNegative(bool _negative)
Definition: plot_common.h:111
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
virtual function FlashPadRoundRect
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:746
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColorMode(bool _color_mode)
Definition: plot_common.h:116
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 SetCurrentLineWidth(int width, void *aData=NULL) override
Pen width setting for PDF.
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Function PlotPoly.
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.
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PlotWorkSheet(PLOTTER *plotter, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, int aSheetNumber, int aNumberOfSheets, const wxString &aSheetDesc, const wxString &aFilename)
virtual void PlotImage(const wxImage &aImage, const wxPoint &aPos, double aScaleFactor) override
PDF images are handles as inline, not XObject streams...
bool negativeMode
true to plot in color, false to plot in black and white
Definition: plot_common.h:535