KiCad PCB EDA Suite
Loading...
Searching...
No Matches
plotters_pslike.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
25
26#pragma once
27
28#include "plotter.h"
29#include <memory>
30#include <optional>
33#include <math/vector3.h>
34
35namespace MARKUP { struct NODE; }
36
41class PSLIKE_PLOTTER : public PLOTTER
42{
43public:
44 PSLIKE_PLOTTER( const PROJECT* aProject = nullptr) :
45 PLOTTER( aProject ),
46 plotScaleAdjX( 1 ),
47 plotScaleAdjY( 1 ),
49 {
50 }
51
55 virtual void SetTextMode( PLOT_TEXT_MODE mode ) override
56 {
57 if( mode != PLOT_TEXT_MODE::DEFAULT )
58 m_textMode = mode;
59 }
60
64 void SetScaleAdjust( double scaleX, double scaleY )
65 {
66 plotScaleAdjX = scaleX;
67 plotScaleAdjY = scaleY;
68 }
69
70 // Pad routines are handled with lower level primitives
71 virtual void FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter, void* aData ) override;
72 virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
73 const EDA_ANGLE& aPadOrient, void* aData ) override;
74 virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
75 const EDA_ANGLE& aPadOrient, void* aData ) override;
76 virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
77 int aCornerRadius, const EDA_ANGLE& aOrient,
78 void* aData ) override;
79 virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
80 const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
81 void* aData ) override;
82 virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
83 const EDA_ANGLE& aPadOrient, void* aData ) override;
84 virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
85 const EDA_ANGLE& aOrient, void* aData ) override;
86
91 virtual void SetColor( const COLOR4D& color ) override;
92
93protected:
101 void computeTextParameters( const VECTOR2I& aPos,
102 const wxString& aText,
103 const EDA_ANGLE& aOrient,
104 const VECTOR2I& aSize,
105 bool aMirror,
106 enum GR_TEXT_H_ALIGN_T aH_justify,
107 enum GR_TEXT_V_ALIGN_T aV_justify,
108 int aWidth,
109 bool aItalic,
110 bool aBold,
111 double *wideningFactor,
112 double *ctm_a,
113 double *ctm_b,
114 double *ctm_c,
115 double *ctm_d,
116 double *ctm_e,
117 double *ctm_f,
118 double *heightFactor );
119
122 virtual std::string encodeStringForPlotter( const wxString& aUnicode );
123
125 virtual void emitSetRGBColor( double r, double g, double b, double a ) = 0;
126
128 static const double postscriptTextAscent; // = 0.718;
129
135 int returnPostscriptTextWidth( const wxString& aText, int aXSize, bool aItalic, bool aBold );
136
139
142};
143
144
146{
147public:
148 PS_PLOTTER( const PROJECT* aProject = nullptr ) :
149 PSLIKE_PLOTTER( aProject )
150 {
151 // The phantom plot in postscript is an hack and reportedly
152 // crashes Adobe's own postscript interpreter!
154 }
155
156 static wxString GetDefaultFileExtension()
157 {
158 return wxString( wxT( "ps" ) );
159 }
160
161 virtual PLOT_FORMAT GetPlotterType() const override
162 {
163 return PLOT_FORMAT::POST;
164 }
165
179 virtual bool StartPlot( const wxString& aPageNumber ) override;
180 virtual bool EndPlot() override;
181
185 virtual void SetCurrentLineWidth( int width, void* aData = nullptr ) override;
186
190 virtual void SetDash( int aLineWidth, LINE_STYLE aLineStyle ) override;
191
192 virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
193 double aScale, bool aMirror ) override;
194 virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int width,
195 int aCornerRadius = 0 ) override;
196 virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width ) override;
197 virtual void Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
198 const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill, int aWidth ) override;
199
200 virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
201 int aWidth, void* aData = nullptr ) override;
202
206 virtual void PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double aScaleFactor, double aAlpha ) override;
207
208 virtual void PenTo( const VECTOR2I& pos, char plume ) override;
209 virtual void Text( const VECTOR2I& aPos,
210 const COLOR4D& aColor,
211 const wxString& aText,
212 const EDA_ANGLE& aOrient,
213 const VECTOR2I& aSize,
214 enum GR_TEXT_H_ALIGN_T aH_justify,
215 enum GR_TEXT_V_ALIGN_T aV_justify,
216 int aWidth,
217 bool aItalic,
218 bool aBold,
219 bool aMultilineAllowed,
220 KIFONT::FONT* aFont,
221 const KIFONT::METRICS& aFontMetrics,
222 void* aData = nullptr ) override;
223
224 virtual void PlotText( const VECTOR2I& aPos,
225 const COLOR4D& aColor,
226 const wxString& aText,
227 const TEXT_ATTRIBUTES& aAttributes,
228 KIFONT::FONT* aFont,
229 const KIFONT::METRICS& aFontMetrics,
230 void* aData = nullptr ) override;
231
232 virtual void PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill,
233 int aWidth, void* aData = nullptr ) override;
234
235
236protected:
237 virtual void emitSetRGBColor( double r, double g, double b, double a ) override;
238};
239
240
242{
243 std::string m_name;
244 std::vector<float> m_cameraMatrix;
246 float m_fov;
247};
248
249
251{
252public:
253 PDF_PLOTTER( const PROJECT* aProject = nullptr ) :
254 PSLIKE_PLOTTER( aProject ),
255 m_pageTreeHandle( 0 ),
259 m_jsNamesHandle( 0 ),
260 m_pageStreamHandle( -1 ),
262 m_workFile( nullptr ),
264 m_3dModelHandle( -1 ),
265 m_3dExportMode( false ),
266 m_usedBase14Fonts( false ),
267 m_currentAlpha( 1.0 ),
268 m_strokeFontManager( nullptr ),
269 m_outlineFontManager( nullptr )
270 {
271 }
272
273 virtual ~PDF_PLOTTER();
274
275 virtual PLOT_FORMAT GetPlotterType() const override
276 {
277 return PLOT_FORMAT::PDF;
278 }
279
280 static wxString GetDefaultFileExtension()
281 {
282 return wxString( wxT( "pdf" ) );
283 }
284
294 virtual bool OpenFile( const wxString& aFullFilename ) override;
295
300 virtual bool StartPlot( const wxString& aPageNumber ) override;
301
302 virtual bool StartPlot( const wxString& aPageNumber,
303 const wxString& aPageName = wxEmptyString );
304
305 virtual bool EndPlot() override;
306
310 virtual void StartPage( const wxString& aPageNumber,
311 const wxString& aPageName = wxEmptyString,
312 const wxString& aParentPageNumber = wxEmptyString,
313 const wxString& aParentPageName = wxEmptyString );
314
318 virtual void ClosePage();
319
328 virtual void SetCurrentLineWidth( int width, void* aData = nullptr ) override;
329
333 virtual void SetDash( int aLineWidth, LINE_STYLE aLineStyle ) override;
334
339 virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil, double aScale,
340 bool aMirror ) override;
341
345 virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int width,
346 int aCornerRadius = 0 ) override;
347
351 virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width ) override;
352
356 virtual void Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle,
357 double aRadius, FILL_T aFill, int aWidth ) override;
358
362 virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
363 int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
364
365 virtual void PlotPoly( const SHAPE_LINE_CHAIN& aLineChain, FILL_T aFill,
366 int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
367
368 virtual void PenTo( const VECTOR2I& pos, char plume ) override;
369
370 virtual void Text( const VECTOR2I& aPos,
371 const COLOR4D& aColor,
372 const wxString& aText,
373 const EDA_ANGLE& aOrient,
374 const VECTOR2I& aSize,
375 enum GR_TEXT_H_ALIGN_T aH_justify,
376 enum GR_TEXT_V_ALIGN_T aV_justify,
377 int aWidth,
378 bool aItalic,
379 bool aBold,
380 bool aMultilineAllowed,
381 KIFONT::FONT* aFont,
382 const KIFONT::METRICS& aFontMetrics,
383 void* aData = nullptr ) override;
384
385private:
386 // Structure to hold overbar drawing information
388 {
389 VECTOR2I startPos; // Start position of overbar text
390 VECTOR2I endPos; // End position of overbar text
391 VECTOR2I fontSize; // Font size for proper overbar positioning
392 bool isOutline; // True if the overbar applies to an outline font run
393 GR_TEXT_V_ALIGN_T vAlign; // Original vertical alignment of the parent text
394 };
395
399 VECTOR2I renderWord( const wxString& aWord, const VECTOR2I& aPosition, const VECTOR2I& aSize,
400 const EDA_ANGLE& aOrient, bool aTextMirrored, int aWidth, bool aBold, bool aItalic,
401 KIFONT::FONT* aFont, const KIFONT::METRICS& aFontMetrics,
402 enum GR_TEXT_V_ALIGN_T aV_justify, TEXT_STYLE_FLAGS aTextStyle );
403
407 VECTOR2I renderMarkupNode( const MARKUP::NODE* aNode, const VECTOR2I& aPosition,
408 const VECTOR2I& aBaseSize, const EDA_ANGLE& aOrient, bool aTextMirrored,
409 int aWidth, bool aBaseBold, bool aBaseItalic, KIFONT::FONT* aFont,
410 const KIFONT::METRICS& aFontMetrics, enum GR_TEXT_V_ALIGN_T aV_justify,
411 TEXT_STYLE_FLAGS aTextStyle, std::vector<OVERBAR_INFO>& aOverbars );
412
416 void drawOverbars( const std::vector<OVERBAR_INFO>& aOverbars, const EDA_ANGLE& aOrient,
417 const KIFONT::METRICS& aFontMetrics );
418
419 std::vector<VECTOR2D> arcPath( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
420 const EDA_ANGLE& aAngle, double aRadius );
421
422public:
423 virtual void PlotText( const VECTOR2I& aPos,
424 const COLOR4D& aColor,
425 const wxString& aText,
426 const TEXT_ATTRIBUTES& aAttributes,
427 KIFONT::FONT* aFont,
428 const KIFONT::METRICS& aFontMetrics,
429 void* aData = nullptr ) override;
430
431 void HyperlinkBox( const BOX2I& aBox, const wxString& aDestinationURL ) override;
432
433 void HyperlinkMenu( const BOX2I& aBox, const std::vector<wxString>& aDestURLs ) override;
434
435 void Bookmark( const BOX2I& aBox, const wxString& aName,
436 const wxString& aGroupName = wxEmptyString ) override;
437
438 void Plot3DModel( const wxString& aSourcePath, const std::vector<PDF_3D_VIEW>& a3DViews );
439
440 void Set3DExport( bool aYes ) { m_3dExportMode = aYes; }
441
442 /*
443 * PDF images are handles as inline, not XObject streams...
444 */
445 void PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double aScaleFactor, double aAlpha ) override;
446
460 static std::vector<float> CreateC2WMatrixFromAngles( const VECTOR3D& aTargetPosition,
461 float aCameraDistance,
462 float aYawDegrees,
463 float aPitchDegrees,
464 float aRollDegrees );
465
466protected:
468 {
470 wxString title;
472
473 std::vector<OUTLINE_NODE*> children;
474
476 {
477 std::for_each( children.begin(), children.end(),
478 []( OUTLINE_NODE* node )
479 {
480 delete node;
481 } );
482 }
483
484 OUTLINE_NODE* AddChild( int aActionHandle, const wxString& aTitle, int aEntryHandle )
485 {
486 OUTLINE_NODE* child = new OUTLINE_NODE
487 {
488 aActionHandle, aTitle, aEntryHandle, {}
489 };
490
491 children.push_back( child );
492
493 return child;
494 }
495 };
496
507 OUTLINE_NODE* addOutlineNode( OUTLINE_NODE* aParent, int aActionHandle,
508 const wxString& aTitle );
509
512 std::string encodeStringForPlotter( const wxString& aUnicode ) override;
513
515 std::string encodeDoubleForPlotter( double aValue ) const;
516
529 virtual void emitSetRGBColor( double r, double g, double b, double a ) override;
530
537 int allocPdfObject();
538
545 int getExtGStateHandleForAlpha( double aAlpha );
546
551 int startPdfObject( int aHandle = -1 );
552
556 void closePdfObject();
557
565 int startPdfStream( int aHandle = -1 );
566
570 void closePdfStream();
571
575 int emitOutline();
576
580 void emitOutlineNode( OUTLINE_NODE* aNode, int aParentHandle, int aNextNode, int aPrevNode );
581
587 int emitGoToAction( int aPageHandle, const VECTOR2I& aBottomLeft, const VECTOR2I& aTopRight );
588 int emitGoToAction( int aPageHandle );
589
590
592
593 void emitStrokeFonts();
594 void emitOutlineFonts();
595
596 std::string encodeByteString( const std::string& aBytes );
597
598protected:
605 {
606 public:
607 void Reset()
608 {
609 m_offsets.assign( 1, 0 );
610 }
611
622 {
623 m_offsets.push_back( 0 );
624 return static_cast<int>( m_offsets.size() ) - 1;
625 }
626
630 bool IsValid( int aHandle ) const
631 {
632 return aHandle > 0 && aHandle < static_cast<int>( m_offsets.size() );
633 }
634
641 void SetOffset( int aHandle, long aOffset )
642 {
643 wxASSERT_MSG( IsValid( aHandle ), "PDF object handle is not valid" );
644 wxASSERT_MSG( aOffset >= 0, "PDF object offset must be non-negative" );
645
646 if( IsValid( aHandle ) )
647 m_offsets[aHandle] = aOffset;
648 }
649
650 const std::vector<long>& Entries() const
651 {
652 return m_offsets;
653 }
654
655 private:
656 std::vector<long> m_offsets = { 0 };
657 };
658
664 std::vector<int> m_pageHandles;
667
669 wxString m_pageName;
671
673
676
678 std::vector<wxString> m_pageNumbers;
679
681 std::vector<std::pair<BOX2I, wxString>> m_hyperlinksInPage;
682 std::vector<std::pair<BOX2I, std::vector<wxString>>> m_hyperlinkMenusInPage;
683
685 std::map<int, std::pair<BOX2D, wxString>> m_hyperlinkHandles;
686 std::map<int, std::pair<BOX2D, std::vector<wxString>>> m_hyperlinkMenuHandles;
687
688 std::map<wxString, std::vector<std::pair<BOX2I, wxString>>> m_bookmarksInPage;
689
690 std::map<int, wxImage> m_imageHandles;
691
692 std::unique_ptr<OUTLINE_NODE> m_outlineRoot;
694
697
700
702 double m_currentAlpha = 1.0;
703
705 std::map<double, int> m_alphaToExtGStateHandles;
706
707 std::unique_ptr<PDF_STROKE_FONT_MANAGER> m_strokeFontManager;
708 std::unique_ptr<PDF_OUTLINE_FONT_MANAGER> m_outlineFontManager;
709};
710
711
713{
714public:
715 SVG_PLOTTER( const PROJECT* aProject = nullptr );
716
717 static wxString GetDefaultFileExtension()
718 {
719 return wxString( wxT( "svg" ) );
720 }
721
722 virtual PLOT_FORMAT GetPlotterType() const override
723 {
724 return PLOT_FORMAT::SVG;
725 }
726
730 virtual bool StartPlot( const wxString& aPageNumber ) override;
731 virtual bool EndPlot() override;
732
736 virtual void SetCurrentLineWidth( int width, void* aData = nullptr ) override;
737
741 virtual void SetDash( int aLineWidth, LINE_STYLE aLineStyle ) override;
742
743 virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil, double aScale,
744 bool aMirror ) override;
745 virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int width,
746 int aCornerRadius = 0 ) override;
747 virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width ) override;
748 virtual void Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
749 const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill,
750 int aWidth ) override;
751
752 virtual void BezierCurve( const VECTOR2I& aStart, const VECTOR2I& aControl1,
753 const VECTOR2I& aControl2, const VECTOR2I& aEnd,
754 int aTolerance, int aLineThickness ) override;
755
756 virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
757 int aWidth, void * aData ) override;
758
762 virtual void PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double aScaleFactor, double aAlpha ) override;
763
764 virtual void PenTo( const VECTOR2I& pos, char plume ) override;
765
776 virtual void SetSvgCoordinatesFormat( unsigned aPrecision ) override;
777
787 virtual void SetPlotBBox( const BOX2I& aBBoxIU ) override;
788
794 virtual void StartBlock( void* aData ) override;
795
801 virtual void EndBlock( void* aData ) override;
802
803 virtual void Text( const VECTOR2I& aPos,
804 const COLOR4D& aColor,
805 const wxString& aText,
806 const EDA_ANGLE& aOrient,
807 const VECTOR2I& aSize,
808 enum GR_TEXT_H_ALIGN_T aH_justify,
809 enum GR_TEXT_V_ALIGN_T aV_justify,
810 int aWidth,
811 bool aItalic,
812 bool aBold,
813 bool aMultilineAllowed,
814 KIFONT::FONT* aFont,
815 const KIFONT::METRICS& aFontMetrics,
816 void* aData = nullptr ) override;
817
818
819 virtual void PlotText( const VECTOR2I& aPos,
820 const COLOR4D& aColor,
821 const wxString& aText,
822 const TEXT_ATTRIBUTES& aAttributes,
823 KIFONT::FONT* aFont,
824 const KIFONT::METRICS& aFontMetrics,
825 void* aData = nullptr ) override;
826
827protected:
828 virtual VECTOR2D userToDeviceCoordinates( const VECTOR2I& aCoordinate ) override;
829
834 virtual void emitSetRGBColor( double r, double g, double b, double a ) override;
835
843 void setSVGPlotStyle( int aLineWidth, bool aIsGroup = true,
844 const std::string& aExtraStyle = {} );
845
849 void setFillMode( FILL_T fill );
850
851 FILL_T m_fillMode; // true if the current contour rect, arc, circle, polygon must
852 // be filled
853 uint32_t m_pen_rgb_color; // current rgb color value: each color has a value 0 ... 255,
854 // and the 3 colors are grouped in a 3x8 bits value (written
855 // in hex to svg files)
856 uint32_t m_brush_rgb_color; // same as m_pen_rgb_color, used to fill some contours.
858 bool m_graphics_changed; // true if a pen/brush parameter is modified color, pen size,
859 // fill mode ... the new SVG stype must be output on file
860 LINE_STYLE m_dashed; // plot line style
861 unsigned m_precision; // How fine the step size is
862 // Use 3-6 (3 means um precision, 6 nm precision) in PcbNew
863 // 3-4 in other modules (avoid values >4 to avoid overflow)
864 // see also comment for m_useInch.
865
866 std::optional<BOX2I> m_plotBBoxIU; // Explicit plot content bounding box (IUs), when set.
867};
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
The PDF cross-reference table.
std::vector< long > m_offsets
void SetOffset(int aHandle, long aOffset)
Set the file offset for a given PDF object handle.
const std::vector< long > & Entries() const
int Allocate()
Allocate a new PDF object handle.
bool IsValid(int aHandle) const
Is the given PDF object handle in the table?
XREF_TABLE m_xrefTable
The PDF xref offset table.
std::vector< int > m_pageHandles
Handles to the page objects.
FILE * m_workFile
Temporary file to construct the stream before zipping.
void emitOutlineFonts()
wxString m_parentPageName
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
void emitOutlineNode(OUTLINE_NODE *aNode, int aParentHandle, int aNextNode, int aPrevNode)
Emits a outline item object and recurses into any children.
std::map< int, wxImage > m_imageHandles
int emitOutline()
Starts emitting the outline object.
virtual bool EndPlot() override
int startPdfObject(int aHandle=-1)
Open a new PDF object and returns the handle if the parameter is -1.
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Polygon plotting for PDF.
virtual ~PDF_PLOTTER()
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width) override
Circle drawing for PDF.
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Pen width setting for PDF.
double m_currentAlpha
Alpha currently set in the page graphics state (PDF starts each page with 1.0).
int m_streamLengthHandle
Handle to the deferred stream length.
int m_jsNamesHandle
Handle for Names dictionary with JS.
wxString m_pageName
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
PDF supports dashed lines.
void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs) override
Create a clickable hyperlink menu with a rectangular click area.
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
std::string encodeDoubleForPlotter(double aValue) const
Convert a double to a PDF-compatible numeric token (no exponent notation).
int m_fontResDictHandle
Font resource dictionary.
virtual void emitSetRGBColor(double r, double g, double b, double a) override
PDF supports colors fully.
void emitStrokeFonts()
void Set3DExport(bool aYes)
PDF_PLOTTER(const PROJECT *aProject=nullptr)
std::map< int, std::pair< BOX2D, wxString > > m_hyperlinkHandles
Handles for all the hyperlink objects that will be deferred.
int m_pageTreeHandle
Handle to the root of the page tree object.
std::map< double, int > m_alphaToExtGStateHandles
Graphics state objects keyed by alpha.
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
int emitGoToAction(int aPageHandle, const VECTOR2I &aBottomLeft, const VECTOR2I &aTopRight)
Emit an action object that instructs a goto coordinates on a page.
void closePdfStream()
Finish the current PDF stream (writes the deferred length, too).
void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString) override
Create a bookmark to a symbol.
void endPlotEmitResources()
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0) override
Rectangles in PDF.
int startPdfStream(int aHandle=-1)
Start a PDF stream (for the page).
VECTOR2I renderMarkupNode(const MARKUP::NODE *aNode, const VECTOR2I &aPosition, const VECTOR2I &aBaseSize, const EDA_ANGLE &aOrient, bool aTextMirrored, int aWidth, bool aBaseBold, bool aBaseItalic, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, enum GR_TEXT_V_ALIGN_T aV_justify, TEXT_STYLE_FLAGS aTextStyle, std::vector< OVERBAR_INFO > &aOverbars)
Recursively render markup nodes with appropriate styling.
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth) override
The PDF engine can't directly plot arcs so we use polygonization.
void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL) override
Create a clickable hyperlink with a rectangular click area.
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
int m_extGStateResDictHandle
Graphics state resource dictionary.
std::map< wxString, std::vector< std::pair< BOX2I, wxString > > > m_bookmarksInPage
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
static wxString GetDefaultFileExtension()
bool m_usedBase14Fonts
Set when the non-embeddable font fallback references the base-14 /KicadFont* resources.
int getExtGStateHandleForAlpha(double aAlpha)
Return the ExtGState resource handle for the given alpha, allocating a new object the first time that...
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString, const wxString &aParentPageNumber=wxEmptyString, const wxString &aParentPageName=wxEmptyString)
Start a new page in the PDF document.
std::unique_ptr< PDF_OUTLINE_FONT_MANAGER > m_outlineFontManager
OUTLINE_NODE * addOutlineNode(OUTLINE_NODE *aParent, int aActionHandle, const wxString &aTitle)
Add a new outline node entry.
int m_imgResDictHandle
Image resource dictionary.
std::string encodeStringForPlotter(const wxString &aUnicode) override
convert a wxString unicode string to a char string compatible with the accepted string PDF format (co...
std::unique_ptr< PDF_STROKE_FONT_MANAGER > m_strokeFontManager
void Plot3DModel(const wxString &aSourcePath, const std::vector< PDF_3D_VIEW > &a3DViews)
std::vector< wxString > m_pageNumbers
List of user-space page numbers for resolving internal hyperlinks.
int allocPdfObject()
Allocate a new handle in the table of the PDF object.
void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor, double aAlpha) override
Plot a bitmap.
VECTOR2I renderWord(const wxString &aWord, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, bool aTextMirrored, int aWidth, bool aBold, bool aItalic, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, enum GR_TEXT_V_ALIGN_T aV_justify, TEXT_STYLE_FLAGS aTextStyle)
Render a single word with the given style parameters.
wxString m_workFilename
std::string encodeByteString(const std::string &aBytes)
void drawOverbars(const std::vector< OVERBAR_INFO > &aOverbars, const EDA_ANGLE &aOrient, const KIFONT::METRICS &aFontMetrics)
Draw overbar lines above text.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
PDF can have multiple pages, so SetPageSettings can be called with the outputFile open (but not insid...
std::map< int, std::pair< BOX2D, std::vector< wxString > > > m_hyperlinkMenuHandles
int m_pageStreamHandle
Handle of the page content object.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
static std::vector< float > CreateC2WMatrixFromAngles(const VECTOR3D &aTargetPosition, float aCameraDistance, float aYawDegrees, float aPitchDegrees, float aRollDegrees)
Generates the camera to world matrix for use with a 3D View.
std::vector< std::pair< BOX2I, wxString > > m_hyperlinksInPage
List of loaded hyperlinks in current page.
std::unique_ptr< OUTLINE_NODE > m_outlineRoot
Root outline node.
std::vector< std::pair< BOX2I, std::vector< wxString > > > m_hyperlinkMenusInPage
void closePdfObject()
Close the current PDF object.
virtual PLOT_FORMAT GetPlotterType() const override
Return the effective plot engine in use.
int m_totalOutlineNodes
Total number of outline nodes.
std::vector< VECTOR2D > arcPath(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius)
static const int USE_DEFAULT_LINE_WIDTH
Definition plotter.h:142
PLOTTER(const PROJECT *aProject=nullptr)
Definition plotter.cpp:46
Container for project specific data.
Definition project.h:63
static const double postscriptTextAscent
Height of the postscript font (from the AFM)
void SetScaleAdjust(double scaleX, double scaleY)
Set the 'fine' scaling for the postscript engine.
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: the PSLIKE computes the rgb values,...
PSLIKE_PLOTTER(const PROJECT *aProject=nullptr)
virtual void emitSetRGBColor(double r, double g, double b, double a)=0
Virtual primitive for emitting the setrgbcolor operator.
PLOT_TEXT_MODE m_textMode
How to draw text.
virtual void SetTextMode(PLOT_TEXT_MODE mode) override
PS and PDF fully implement native text (for the Latin-1 subset)
virtual void FlashRegularPolygon(const VECTOR2I &aShapePos, int aDiameter, int aCornerCount, const EDA_ANGLE &aOrient, void *aData) override
Flash a regular polygon.
int returnPostscriptTextWidth(const wxString &aText, int aXSize, bool aItalic, bool aBold)
Sister function for the GRTextWidth in gr_text.cpp Does the same processing (i.e.
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, void *aData) override
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, void *aData) override
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, void *aData) override
double plotScaleAdjX
Fine user scale adjust ( = 1.0 if no correction)
void computeTextParameters(const VECTOR2I &aPos, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, bool aMirror, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_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.
virtual std::string encodeStringForPlotter(const wxString &aUnicode)
convert a wxString unicode string to a char string compatible with the accepted string plotter format...
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, SHAPE_POLY_SET *aPolygons, void *aData) override
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, void *aData) override
Flash a trapezoidal pad.
virtual void FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, void *aData) override
virtual bool EndPlot() override
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0) override
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width) override
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData=nullptr) override
Draw a polygon ( filled or not ).
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
PostScript supports dashed lines.
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth) override
virtual bool StartPlot(const wxString &aPageNumber) override
The code within this function (and the CloseFilePS function) creates postscript files whose contents ...
virtual PLOT_FORMAT GetPlotterType() const override
Return the effective plot engine in use.
PS_PLOTTER(const PROJECT *aProject=nullptr)
virtual void emitSetRGBColor(double r, double g, double b, double a) override
Virtual primitive for emitting the setrgbcolor operator.
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Set the current line width (in IUs) for the next plot.
static wxString GetDefaultFileExtension()
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
virtual void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor, double aAlpha) override
Plot a bitmap, applying an overall opacity on top of the image's own alpha.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
virtual void emitSetRGBColor(double r, double g, double b, double a) override
Initialize m_pen_rgb_color from reduced values r, g ,b ( reduced values are 0.0 to 1....
unsigned m_precision
virtual bool StartPlot(const wxString &aPageNumber) override
Create SVG file header.
virtual void SetPlotBBox(const BOX2I &aBBoxIU) override
Set an explicit bounding box for the plotted content (in IUs).
virtual void EndBlock(void *aData) override
Calling this function allows one to define the end of a group of drawing items the group is started b...
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
LINE_STYLE m_dashed
SVG_PLOTTER(const PROJECT *aProject=nullptr)
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
virtual PLOT_FORMAT GetPlotterType() const override
Return the effective plot engine in use.
uint32_t m_brush_rgb_color
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0) override
virtual void SetSvgCoordinatesFormat(unsigned aPrecision) override
Select SVG coordinate precision (number of digits needed for 1 mm ) (SVG plotter uses always metric u...
virtual void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor, double aAlpha) override
PostScript-likes at the moment are the only plot engines supporting bitmaps.
virtual bool EndPlot() override
void setSVGPlotStyle(int aLineWidth, bool aIsGroup=true, const std::string &aExtraStyle={})
Output the string which define pen and brush color, shape, transparency.
std::optional< BOX2I > m_plotBBoxIU
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width) override
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData) override
Draw a polygon ( filled or not ).
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate) override
Modify coordinates according to the orientation, scale factor, and offsets trace.
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness) override
Generic fallback: Cubic Bezier curve rendered as a polyline.
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth) override
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
uint32_t m_pen_rgb_color
static wxString GetDefaultFileExtension()
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
SVG supports dashed lines.
virtual void StartBlock(void *aData) override
Calling this function allows one to define the beginning of a group of drawing items (used in SVG for...
void setFillMode(FILL_T fill)
Prepare parameters for setSVGPlotStyle()
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Set the current line width (in IUs) for the next plot.
FILL_T
Definition eda_fill.h:29
unsigned int TEXT_STYLE_FLAGS
Definition font.h:61
PLOT_TEXT_MODE
Which kind of text to output with the PSLIKE plotters.
Definition plotter.h:101
PLOT_FORMAT
The set of supported output plot formats.
Definition plotter.h:65
LINE_STYLE
Dashed line types.
std::vector< float > m_cameraMatrix
std::string m_name
wxString title
Title of outline node.
std::vector< OUTLINE_NODE * > children
Ordered list of children.
int entryHandle
Allocated handle for this outline entry.
OUTLINE_NODE * AddChild(int aActionHandle, const wxString &aTitle, int aEntryHandle)
int actionHandle
Handle to action.
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
VECTOR3< double > VECTOR3D
Definition vector3.h:230