KiCad PCB EDA Suite
plotter.h File Reference

Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF) More...

#include <eda_shape.h>
#include <vector>
#include <math/box2.h>
#include <gr_text.h>
#include <page_info.h>
#include <outline_mode.h>
#include <gal/color4d.h>
#include <stroke_params.h>
#include <render_settings.h>

Go to the source code of this file.

Classes

class  PLOTTER
 Base plotter engine class. More...
 

Enumerations

enum class  DXF_UNITS { INCHES = 0 , MILLIMETERS = 1 }
 
enum class  PLOT_FORMAT {
  UNDEFINED = -1 , FIRST_FORMAT = 0 , HPGL = FIRST_FORMAT , GERBER ,
  POST , DXF , PDF , SVG ,
  LAST_FORMAT = SVG
}
 The set of supported output plot formats. More...
 
enum class  PLOT_TEXT_MODE { STROKE , NATIVE , PHANTOM , DEFAULT }
 Which kind of text to output with the PSLIKE plotters. More...
 

Functions

void PlotDrawingSheet (PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const std::map< wxString, wxString > *aProperties, const wxString &aSheetNumber, int aSheetCount, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aFilename, COLOR4D aColor=COLOR4D::UNSPECIFIED, bool aIsFirstPage=true)
 
wxString GetDefaultPlotExtension (PLOT_FORMAT aFormat)
 Returns the default plot extension for a format. More...
 

Detailed Description

Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)

Definition in file plotter.h.

Enumeration Type Documentation

◆ DXF_UNITS

enum class DXF_UNITS
strong
Enumerator
INCHES 
MILLIMETERS 

Definition at line 57 of file plotter.h.

58{
59 INCHES = 0,
60 MILLIMETERS = 1
61};

◆ PLOT_FORMAT

enum class PLOT_FORMAT
strong

The set of supported output plot formats.

They should be kept in order of the radio buttons in the plot panel/windows.

Enumerator
UNDEFINED 
FIRST_FORMAT 
HPGL 
GERBER 
POST 
DXF 
PDF 
SVG 
LAST_FORMAT 

Definition at line 69 of file plotter.h.

◆ PLOT_TEXT_MODE

enum class PLOT_TEXT_MODE
strong

Which kind of text to output with the PSLIKE plotters.

You can: 1) only use the internal vector font 2) only use native postscript fonts 3) use the internal vector font and add 'phantom' text to aid searching 4) keep the default for the plot driver

This is recognized by the DXF driver too, where NATIVE emits TEXT entities instead of stroking the text

Enumerator
STROKE 
NATIVE 
PHANTOM 
DEFAULT 

Definition at line 95 of file plotter.h.

Function Documentation

◆ GetDefaultPlotExtension()

wxString GetDefaultPlotExtension ( PLOT_FORMAT  aFormat)

Returns the default plot extension for a format.

Definition at line 37 of file common_plot_functions.cpp.

38{
39 switch( aFormat )
40 {
53 default:
54 wxASSERT( false );
55 return wxEmptyString;
56 }
57}
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:47
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
Definition: plotter_hpgl.h:43
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()

References DXF, GERBER, DXF_PLOTTER::GetDefaultFileExtension(), GERBER_PLOTTER::GetDefaultFileExtension(), HPGL_PLOTTER::GetDefaultFileExtension(), PS_PLOTTER::GetDefaultFileExtension(), PDF_PLOTTER::GetDefaultFileExtension(), SVG_PLOTTER::GetDefaultFileExtension(), HPGL, PDF, POST, and SVG.

Referenced by GENDRILL_WRITER_BASE::CreateMapFilesSet(), PCBNEW_JOBS_HANDLER::JobExportDxf(), PCBNEW_JOBS_HANDLER::JobExportGerber(), PCBNEW_JOBS_HANDLER::JobExportPdf(), PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().

◆ PlotDrawingSheet()

void PlotDrawingSheet ( PLOTTER plotter,
const PROJECT aProject,
const TITLE_BLOCK aTitleBlock,
const PAGE_INFO aPageInfo,
const std::map< wxString, wxString > *  aProperties,
const wxString &  aSheetNumber,
int  aSheetCount,
const wxString &  aSheetName,
const wxString &  aSheetPath,
const wxString &  aFilename,
COLOR4D  aColor = COLOR4D::UNSPECIFIED,
bool  aIsFirstPage = true 
)

Definition at line 60 of file common_plot_functions.cpp.

65{
66 /* Note: Page sizes values are given in mils
67 */
68 double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
69 COLOR4D plotColor = plotter->GetColorMode() ? aColor : COLOR4D::BLACK;
70 RENDER_SETTINGS* settings = plotter->RenderSettings();
71 int defaultPenWidth = settings->GetDefaultPenWidth();
72
73 if( plotColor == COLOR4D::UNSPECIFIED )
74 plotColor = COLOR4D( RED );
75
76 DS_DRAW_ITEM_LIST drawList;
77
78 // Print only a short filename, if aFilename is the full filename
79 wxFileName fn( aFilename );
80
81 // Prepare plot parameters
83 drawList.SetMilsToIUfactor( iusPerMil );
84 drawList.SetPageNumber( aSheetNumber );
85 drawList.SetSheetCount( aSheetCount );
86 drawList.SetFileName( fn.GetFullName() ); // Print only the short filename
87 drawList.SetSheetName( aSheetName );
88 drawList.SetSheetPath( aSheetPath );
89 drawList.SetSheetLayer( settings->GetLayerName() );
90 drawList.SetProject( aProject );
91 drawList.SetIsFirstPage( aIsFirstPage );
92 drawList.SetProperties( aProperties );
93
94 drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
95
96 // Draw item list
97 for( DS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
98 {
99 plotter->SetColor( plotColor );
101
102 switch( item->Type() )
103 {
104 case WSG_LINE_T:
105 {
106 DS_DRAW_ITEM_LINE* line = (DS_DRAW_ITEM_LINE*) item;
107 plotter->SetCurrentLineWidth( std::max( line->GetPenWidth(), defaultPenWidth ) );
108 plotter->MoveTo( line->GetStart() );
109 plotter->FinishTo( line->GetEnd() );
110 }
111 break;
112
113 case WSG_RECT_T:
114 {
115 DS_DRAW_ITEM_RECT* rect = (DS_DRAW_ITEM_RECT*) item;
116 plotter->SetCurrentLineWidth( std::max( rect->GetPenWidth(), defaultPenWidth ) );
117 plotter->MoveTo( rect->GetStart() );
118 plotter->LineTo( VECTOR2I( rect->GetEnd().x, rect->GetStart().y ) );
119 plotter->LineTo( VECTOR2I( rect->GetEnd().x, rect->GetEnd().y ) );
120 plotter->LineTo( VECTOR2I( rect->GetStart().x, rect->GetEnd().y ) );
121 plotter->FinishTo( rect->GetStart() );
122 }
123 break;
124
125 case WSG_TEXT_T:
126 {
128 KIFONT::FONT* font = text->GetFont();
129 COLOR4D color = plotColor;
130
131 if( !font )
132 {
133 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), text->IsBold(),
134 text->IsItalic() );
135 }
136
137 if( plotter->GetColorMode() && text->GetTextColor() != COLOR4D::UNSPECIFIED )
138 color = text->GetTextColor();
139
140 int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth );
141
142 plotter->Text( text->GetTextPos(), color, text->GetShownText(), text->GetTextAngle(),
143 text->GetTextSize(), text->GetHorizJustify(), text->GetVertJustify(),
144 penWidth, text->IsItalic(), text->IsBold(), text->IsMultilineAllowed(),
145 font );
146 }
147 break;
148
149 case WSG_POLY_T:
150 {
152 int penWidth = std::max( poly->GetPenWidth(), defaultPenWidth );
153 std::vector<VECTOR2I> points;
154
155 for( int idx = 0; idx < poly->GetPolygons().OutlineCount(); ++idx )
156 {
157 points.clear();
158 SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
159
160 for( int ii = 0; ii < outline.PointCount(); ii++ )
161 points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
162
163 plotter->PlotPoly( points, FILL_T::FILLED_SHAPE, penWidth );
164 }
165 }
166 break;
167
168 case WSG_BITMAP_T:
169 {
170 DS_DRAW_ITEM_BITMAP* drawItem = (DS_DRAW_ITEM_BITMAP*) item;
171 DS_DATA_ITEM_BITMAP* bitmap = (DS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
172
173 if( bitmap->m_ImageBitmap == nullptr )
174 break;
175
176 bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,
178 }
179 break;
180
181 default:
182 wxFAIL_MSG( "PlotDrawingSheet(): Unknown drawing sheet item." );
183 break;
184 }
185 }
186}
int color
Definition: DXF_plotter.cpp:57
void PlotImage(PLOTTER *aPlotter, const VECTOR2I &aPos, const KIGFX::COLOR4D &aDefaultColor, int aDefaultPensize) const
Plot bitmap on plotter.
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:370
Base class to handle basic graphic items.
Definition: ds_draw_item.h:59
virtual int GetPenWidth() const
Definition: ds_draw_item.h:70
DS_DATA_ITEM * GetPeer() const
Definition: ds_draw_item.h:63
VECTOR2I GetPosition() const override
Definition: ds_draw_item.h:357
const VECTOR2I & GetStart() const
Definition: ds_draw_item.h:133
const VECTOR2I & GetEnd() const
Definition: ds_draw_item.h:135
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ds_draw_item.h:385
DS_DRAW_ITEM_BASE * GetFirst()
Definition: ds_draw_item.h:483
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetSheetPath(const wxString &aSheetPath)
Set the sheet path to draw/plot.
Definition: ds_draw_item.h:437
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ds_draw_item.h:427
void SetDefaultPenSize(int aPenSize)
Definition: ds_draw_item.h:444
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ds_draw_item.h:432
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
Definition: ds_draw_item.h:465
void SetProperties(const std::map< wxString, wxString > *aProps)
Set properties used for text variable resolution.
Definition: ds_draw_item.h:417
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: ds_draw_item.h:442
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ds_draw_item.h:470
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:460
DS_DRAW_ITEM_BASE * GetNext()
Definition: ds_draw_item.h:493
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:450
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:407
SHAPE_POLY_SET & GetPolygons()
Definition: ds_draw_item.h:171
Non filled rectangle with thick segment.
Definition: ds_draw_item.h:208
const VECTOR2I & GetEnd() const
Definition: ds_draw_item.h:223
const VECTOR2I & GetStart() const
Definition: ds_draw_item.h:221
A graphic text.
Definition: ds_draw_item.h:303
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:138
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const wxString & GetDefaultFont() const
const wxString & GetLayerName() const
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:114
void MoveTo(const VECTOR2I &pos)
Definition: plotter.h:247
void FinishTo(const VECTOR2I &pos)
Definition: plotter.h:257
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
double GetIUsPerDecimil() const
The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establ...
Definition: plotter.h:210
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 aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
Definition: plotter.cpp:697
bool GetColorMode() const
Definition: plotter.h:138
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void LineTo(const VECTOR2I &pos)
Definition: plotter.h:252
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void SetColor(const COLOR4D &color)=0
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
@ BLACK
Definition: color4d.h:42
@ RED
Definition: color4d.h:57
@ FILLED_SHAPE
@ WSG_POLY_T
Definition: typeinfo.h:222
@ WSG_LINE_T
Definition: typeinfo.h:220
@ WSG_TEXT_T
Definition: typeinfo.h:223
@ WSG_RECT_T
Definition: typeinfo.h:221
@ WSG_BITMAP_T
Definition: typeinfo.h:224
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References BLACK, DS_DRAW_ITEM_LIST::BuildDrawItemsList(), color, SHAPE_LINE_CHAIN::CPoint(), FILLED_SHAPE, PLOTTER::FinishTo(), PLOTTER::GetColorMode(), KIGFX::RENDER_SETTINGS::GetDefaultFont(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), DS_DRAW_ITEM_LINE::GetEnd(), DS_DRAW_ITEM_RECT::GetEnd(), DS_DRAW_ITEM_LIST::GetFirst(), KIFONT::FONT::GetFont(), PLOTTER::GetIUsPerDecimil(), KIGFX::RENDER_SETTINGS::GetLayerName(), DS_DRAW_ITEM_LIST::GetNext(), DS_DRAW_ITEM_BASE::GetPeer(), DS_DRAW_ITEM_BASE::GetPenWidth(), DS_DRAW_ITEM_POLYPOLYGONS::GetPolygons(), DS_DRAW_ITEM_BITMAP::GetPosition(), DS_DRAW_ITEM_LINE::GetStart(), DS_DRAW_ITEM_RECT::GetStart(), PLOTTER::LineTo(), DS_DATA_ITEM_BITMAP::m_ImageBitmap, PLOTTER::MoveTo(), SHAPE_POLY_SET::Outline(), BITMAP_BASE::PlotImage(), PLOTTER::PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), RED, PLOTTER::RenderSettings(), PLOTTER::SetColor(), PLOTTER::SetCurrentLineWidth(), DS_DRAW_ITEM_LIST::SetDefaultPenSize(), DS_DRAW_ITEM_LIST::SetFileName(), DS_DRAW_ITEM_LIST::SetIsFirstPage(), DS_DRAW_ITEM_LIST::SetMilsToIUfactor(), DS_DRAW_ITEM_LIST::SetPageNumber(), DS_DRAW_ITEM_LIST::SetProject(), DS_DRAW_ITEM_LIST::SetProperties(), DS_DRAW_ITEM_LIST::SetSheetCount(), DS_DRAW_ITEM_LIST::SetSheetLayer(), DS_DRAW_ITEM_LIST::SetSheetName(), DS_DRAW_ITEM_LIST::SetSheetPath(), text, PLOTTER::Text(), PLOTTER::USE_DEFAULT_LINE_WIDTH, WSG_BITMAP_T, WSG_LINE_T, WSG_POLY_T, WSG_RECT_T, WSG_TEXT_T, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_PLOTTER::plotOneSheetDXF(), SCH_PLOTTER::plotOneSheetHpgl(), SCH_PLOTTER::plotOneSheetPDF(), SCH_PLOTTER::plotOneSheetPS(), SCH_PLOTTER::plotOneSheetSVG(), and StartPlotBoard().