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  enum EDA_TEXT_HJUSTIFY_T aH_justify,
696  enum EDA_TEXT_VJUSTIFY_T aV_justify,
697  int aWidth,
698  bool aItalic,
699  bool aBold,
700  double *wideningFactor,
701  double *ctm_a,
702  double *ctm_b,
703  double *ctm_c,
704  double *ctm_d,
705  double *ctm_e,
706  double *ctm_f,
707  double *heightFactor );
708  void postscriptOverlinePositions( const wxString& aText, int aXSize,
709  bool aItalic, bool aBold,
710  std::vector<int> *pos_pairs );
711  void fputsPostscriptString(FILE *fout, const wxString& txt);
712 
714  virtual void emitSetRGBColor( double r, double g, double b ) = 0;
715 
717  static const double postscriptTextAscent; // = 0.718;
718 
719  int returnPostscriptTextWidth( const wxString& aText, int aXSize,
720  bool aItalic, bool aBold );
721 
724 
727 };
728 
729 
731 {
732 public:
734  {
735  // The phantom plot in postscript is an hack and reportedly
736  // crashes Adobe's own postscript interpreter!
738  }
739 
740  static wxString GetDefaultFileExtension()
741  {
742  return wxString( wxT( "ps" ) );
743  }
744 
745  virtual PlotFormat GetPlotterType() const override
746  {
747  return PLOT_FORMAT_POST;
748  }
749 
750  virtual bool StartPlot() override;
751  virtual bool EndPlot() override;
752  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
753  virtual void SetDash( bool dashed ) override;
754 
755  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
756  double aScale, bool aMirror ) override;
757  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
758  int width = USE_DEFAULT_LINE_WIDTH ) override;
759  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
760  int width = USE_DEFAULT_LINE_WIDTH ) override;
761  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
762  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
763 
764  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
765  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
766  void * aData = NULL ) override;
767 
768  virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
769  double aScaleFactor ) override;
770 
771  virtual void PenTo( const wxPoint& pos, char plume ) override;
772  virtual void Text( const wxPoint& aPos,
773  const COLOR4D aColor,
774  const wxString& aText,
775  double aOrient,
776  const wxSize& aSize,
777  enum EDA_TEXT_HJUSTIFY_T aH_justify,
778  enum EDA_TEXT_VJUSTIFY_T aV_justify,
779  int aWidth,
780  bool aItalic,
781  bool aBold,
782  bool aMultilineAllowed = false,
783  void* aData = NULL ) override;
784 protected:
785  virtual void emitSetRGBColor( double r, double g, double b ) override;
786 };
787 
789 {
790 public:
792  {
793  // Avoid non initialized variables:
795  pageTreeHandle = 0;
796  }
797 
798  virtual PlotFormat GetPlotterType() const override
799  {
800  return PLOT_FORMAT_PDF;
801  }
802 
803  static wxString GetDefaultFileExtension()
804  {
805  return wxString( wxT( "pdf" ) );
806  }
807 
816  virtual bool OpenFile( const wxString& aFullFilename ) override;
817 
818  virtual bool StartPlot() override;
819  virtual bool EndPlot() override;
820  virtual void StartPage();
821  virtual void ClosePage();
822  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
823  virtual void SetDash( bool dashed ) override;
824 
827  virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
828  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
829  double aScale, bool aMirror ) override;
830  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
831  int width = USE_DEFAULT_LINE_WIDTH ) override;
832  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
833  int width = USE_DEFAULT_LINE_WIDTH ) override;
834  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
835  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
836 
837  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
838  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
839  void * aData = NULL ) override;
840 
841  virtual void PenTo( const wxPoint& pos, char plume ) override;
842 
843  virtual void Text( const wxPoint& aPos,
844  const COLOR4D aColor,
845  const wxString& aText,
846  double aOrient,
847  const wxSize& aSize,
848  enum EDA_TEXT_HJUSTIFY_T aH_justify,
849  enum EDA_TEXT_VJUSTIFY_T aV_justify,
850  int aWidth,
851  bool aItalic,
852  bool aBold,
853  bool aMultilineAllowed = false,
854  void* aData = NULL ) override;
855 
856  virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
857  double aScaleFactor ) override;
858 
859 
860 protected:
861  virtual void emitSetRGBColor( double r, double g, double b ) override;
862  int allocPdfObject();
863  int startPdfObject(int handle = -1);
864  void closePdfObject();
865  int startPdfStream(int handle = -1);
866  void closePdfStream();
869  std::vector<int> pageHandles;
872  wxString workFilename;
873  FILE* workFile;
874  std::vector<long> xrefTable;
875 };
876 
878 {
879 public:
880  SVG_PLOTTER();
881 
882  static wxString GetDefaultFileExtension()
883  {
884  return wxString( wxT( "svg" ) );
885  }
886 
887  virtual PlotFormat GetPlotterType() const override
888  {
889  return PLOT_FORMAT_SVG;
890  }
891 
892  virtual void SetColor( COLOR4D color ) override;
893  virtual bool StartPlot() override;
894  virtual bool EndPlot() override;
895  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
896  virtual void SetDash( bool dashed ) override;
897 
898  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
899  double aScale, bool aMirror ) override;
900  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
901  int width = USE_DEFAULT_LINE_WIDTH ) override;
902  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
903  int width = USE_DEFAULT_LINE_WIDTH ) override;
904  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
905  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
906 
907  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
908  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
909  void * aData = NULL ) override;
910 
911  virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
912  double aScaleFactor ) override;
913 
914  virtual void PenTo( const wxPoint& pos, char plume ) override;
915  virtual void Text( const wxPoint& aPos,
916  const COLOR4D aColor,
917  const wxString& aText,
918  double aOrient,
919  const wxSize& aSize,
920  enum EDA_TEXT_HJUSTIFY_T aH_justify,
921  enum EDA_TEXT_VJUSTIFY_T aV_justify,
922  int aWidth,
923  bool aItalic,
924  bool aBold,
925  bool aMultilineAllowed = false,
926  void* aData = NULL ) override;
927 
928 protected:
929  FILL_T m_fillMode; // true if the current contour
930  // rect, arc, circle, polygon must be filled
931  long m_pen_rgb_color; // current rgb color value: each color has
932  // a value 0 ... 255, and the 3 colors are
933  // grouped in a 3x8 bits value
934  // (written in hex to svg files)
935  long m_brush_rgb_color; // same as m_pen_rgb_color, used to fill
936  // some contours.
937  bool m_graphics_changed; // true if a pen/brush parameter is modified
938  // color, pen size, fil mode ...
939  // the new SVG stype must be output on file
940  bool m_dashed; // true to use plot dashed line style
941 
947  virtual void emitSetRGBColor( double r, double g, double b ) override;
948 
953  void setSVGPlotStyle();
954 
959  void setFillMode( FILL_T fill );
960 };
961 
962 /* Class to handle a D_CODE when plotting a board : */
963 #define FIRST_DCODE_VALUE 10 // D_CODE < 10 is a command, D_CODE >= 10 is a tool
964 
965 class APERTURE
966 {
967 public:
969  Circle = 1,
970  Rect = 2,
971  Plotting = 3,
972  Oval = 4
973  };
974 
975  wxSize m_Size; // horiz and Vert size
976  APERTURE_TYPE m_Type; // Type ( Line, rect , circulaire , ovale .. )
977  int m_DCode; // code number ( >= 10 );
978  int m_ApertureAttribute; // the attribute attached to this aperture
979  // Only one attribute is allowed by aperture
980  // 0 = no specific aperture attribute
981 };
982 
983 
984 class GERBER_PLOTTER : public PLOTTER
985 {
986 public:
987  GERBER_PLOTTER();
988 
989  virtual PlotFormat GetPlotterType() const override
990  {
991  return PLOT_FORMAT_GERBER;
992  }
993 
994  static wxString GetDefaultFileExtension()
995  {
996  return wxString( wxT( "gbr" ) );
997  }
998 
1004  virtual bool StartPlot() override;
1005  virtual bool EndPlot() override;
1006  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
1007  virtual void SetDefaultLineWidth( int width ) override;
1008 
1009  // RS274X has no dashing, nor colours
1010  virtual void SetDash( bool dashed ) override {}
1011  virtual void SetColor( COLOR4D color ) override {}
1012  // Currently, aScale and aMirror are not used in gerber plotter
1013  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
1014  double aScale, bool aMirror ) override;
1015  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
1016  int width = USE_DEFAULT_LINE_WIDTH ) override;
1017  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
1018  int width = USE_DEFAULT_LINE_WIDTH ) override;
1019  virtual void Arc( const wxPoint& aCenter, double aStAngle, double aEndAngle,
1020  int aRadius, FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
1021 
1022  virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
1023  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1024 
1025  virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
1026  int rayon, int width, EDA_DRAW_MODE_T tracemode, void* aData ) override;
1027  virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
1028  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1029  virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
1030  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1035  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
1036  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
1037  void * aData = NULL ) override;
1038 
1039  virtual void PenTo( const wxPoint& pos, char plume ) override;
1040 
1041  virtual void Text( const wxPoint& aPos,
1042  const COLOR4D aColor,
1043  const wxString& aText,
1044  double aOrient,
1045  const wxSize& aSize,
1046  enum EDA_TEXT_HJUSTIFY_T aH_justify,
1047  enum EDA_TEXT_VJUSTIFY_T aV_justify,
1048  int aWidth,
1049  bool aItalic,
1050  bool aBold,
1051  bool aMultilineAllowed = false,
1052  void* aData = NULL ) override;
1053 
1057  virtual void FlashPadCircle( const wxPoint& pos, int diametre,
1058  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1059 
1063  virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, double orient,
1064  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1070  virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
1071  double orient, EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1072 
1078  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
1079  int aCornerRadius, double aOrient,
1080  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1081  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
1082  SHAPE_POLY_SET* aPolygons,
1083  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1089  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
1090  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1091 
1096  virtual void SetLayerPolarity( bool aPositive ) override;
1097 
1108  virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false ) override;
1109 
1110  void UseX2Attributes( bool aEnable ) { m_useX2Attributes = aEnable; }
1111  void UseX2NetAttributes( bool aEnable ) { m_useNetAttributes = aEnable; }
1112 
1118  virtual void StartBlock( void* aData ) override;
1119 
1126  virtual void EndBlock( void* aData ) override;
1127 
1128 protected:
1134  void selectAperture( const wxSize& aSize, APERTURE::APERTURE_TYPE aType,
1135  int aApertureAttribute );
1136 
1142  void emitDcode( const DPOINT& pt, int dcode );
1143 
1152 
1157  void clearNetAttribute();
1158 
1167  std::vector<APERTURE>::iterator getAperture( const wxSize& aSize,
1168  APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
1169 
1170  // the attributes dictionnary created/modifed by %TO, attached the objects, when they are created
1171  // by D01, D03 G36/G37 commands
1172  // standard attributes are .P, .C and .N
1173  // this is used by gerber readers when creating a new object. Cleared by %TD command
1174  // Note: m_objectAttributesDictionnary can store more than one attribute
1175  // the string stores the line(s) actually written to the gerber file
1176  // it can store a .P, .C or .N attribute, or 2 or 3 attributes, separated by a \n char (EOL)
1178 
1179  // The last aperture attribute generated (only one aperture attribute can be set)
1181 
1182  FILE* workFile;
1183  FILE* finalFile;
1184  wxString m_workFilename;
1185 
1189  void writeApertureList();
1190 
1191  std::vector<APERTURE> apertures;
1192  std::vector<APERTURE>::iterator currentAperture;
1193 
1194  bool m_gerberUnitInch; // true if the gerber units are inches, false for mm
1195  int m_gerberUnitFmt; // number of digits in mantissa.
1196  // usually 6 in Inches and 5 or 6 in mm
1197  bool m_useX2Attributes; // In recent gerber files, attributes can be added.
1198  // It will be added if this parm is true
1199  bool m_useNetAttributes; // In recent gerber files, netlist info can be added.
1200  // It will be added if this parm is true
1201  // (imply m_useX2Attributes == true)
1202 };
1203 
1204 
1205 class DXF_PLOTTER : public PLOTTER
1206 {
1207 public:
1209  {
1210  textAsLines = true;
1212  }
1213 
1214  virtual PlotFormat GetPlotterType() const override
1215  {
1216  return PLOT_FORMAT_DXF;
1217  }
1218 
1219  static wxString GetDefaultFileExtension()
1220  {
1221  return wxString( wxT( "dxf" ) );
1222  }
1223 
1227  virtual void SetTextMode( PlotTextMode mode ) override
1228  {
1229  if( mode != PLOTTEXTMODE_DEFAULT )
1230  textAsLines = ( mode != PLOTTEXTMODE_NATIVE );
1231  }
1232 
1233  virtual bool StartPlot() override;
1234  virtual bool EndPlot() override;
1235 
1236  // For now we don't use 'thick' primitives, so no line width
1237  virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
1238  {
1239  currentPenWidth = 0;
1240  }
1241 
1242  virtual void SetDefaultLineWidth( int width ) override
1243  {
1244  // DXF lines are infinitesimal
1245  defaultPenWidth = 0;
1246  }
1247 
1248  virtual void SetDash( bool dashed ) override;
1249 
1250  virtual void SetColor( COLOR4D color ) override;
1251 
1252  virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
1253  double aScale, bool aMirror ) override;
1254  virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
1255  int width = USE_DEFAULT_LINE_WIDTH ) override;
1256  virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
1257  int width = USE_DEFAULT_LINE_WIDTH ) override;
1258  virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
1259  FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) override;
1260  virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
1261  EDA_DRAW_MODE_T tracemode, void* aData ) override;
1262  virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
1263  int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
1264  virtual void PenTo( const wxPoint& pos, char plume ) override;
1265 
1266  virtual void FlashPadCircle( const wxPoint& pos, int diametre,
1267  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1268  virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, double orient,
1269  EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1270  virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
1271  double orient, EDA_DRAW_MODE_T trace_mode, void* aData ) override;
1272  virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
1273  int aCornerRadius, double aOrient,
1274  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1275  virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
1276  SHAPE_POLY_SET* aPolygons,
1277  EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1278  virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
1279  double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
1280 
1281  virtual void Text( const wxPoint& aPos,
1282  const COLOR4D aColor,
1283  const wxString& aText,
1284  double aOrient,
1285  const wxSize& aSize,
1286  enum EDA_TEXT_HJUSTIFY_T aH_justify,
1287  enum EDA_TEXT_VJUSTIFY_T aV_justify,
1288  int aWidth,
1289  bool aItalic,
1290  bool aBold,
1291  bool aMultilineAllowed = false,
1292  void* aData = NULL ) override;
1293 
1294 protected:
1297 };
1298 
1299 class TITLE_BLOCK;
1300 void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
1301  const PAGE_INFO& aPageInfo,
1302  int aSheetNumber, int aNumberOfSheets,
1303  const wxString &aSheetDesc,
1304  const wxString &aFilename );
1305 
1308 wxString GetDefaultPlotExtension( PlotFormat aFormat );
1309 
1310 
1311 #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:803
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:887
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:740
void UseX2NetAttributes(bool aEnable)
Definition: plot_common.h:1111
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:1237
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:929
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:976
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:975
bool textAsLines
Definition: plot_common.h:1295
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:882
bool m_useNetAttributes
Definition: plot_common.h:1199
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:867
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:798
std::vector< int > pageHandles
Font resource dictionary.
Definition: plot_common.h:869
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:1191
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:1296
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:994
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:872
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:1219
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:871
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:989
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:931
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:723
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:873
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:717
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:868
bool m_useX2Attributes
Definition: plot_common.h:1197
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:874
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:1242
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:937
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:935
virtual PlotFormat GetPlotterType() const override
Returns the effective plot engine in use.
Definition: plot_common.h:1214
double plotScaleAdjX
Fine user scale adjust ( = 1.0 if no correction)
Definition: plot_common.h:723
virtual void SetColor(COLOR4D color) override
Definition: plot_common.h:1011
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:1177
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:1184
virtual void SetDash(bool dashed) override
Definition: plot_common.h:1010
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:977
virtual void SetTextMode(PlotTextMode mode) override
DXF handles NATIVE text emitting TEXT entities.
Definition: plot_common.h:1227
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:978
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:1192
PlotTextMode m_textMode
How to draw text.
Definition: plot_common.h:726
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 computeTextParameters(const wxPoint &aPos, const wxString &aText, int aOrient, const wxSize &aSize, 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 ...
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:870
void UseX2Attributes(bool aEnable)
Definition: plot_common.h:1110
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:745
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