KiCad PCB EDA Suite
plotter.h File Reference

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

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

Go to the source code of this file.

Classes

class  PLOTTER
 Base plotter engine class. More...
 

Enumerations

enum  DXF_UNITS { DXF_UNITS::INCHES = 0, DXF_UNITS::MILLIMETERS = 1 }
 
enum  PLOT_FORMAT {
  PLOT_FORMAT::UNDEFINED = -1, PLOT_FORMAT::FIRST_FORMAT = 0, PLOT_FORMAT::HPGL = FIRST_FORMAT, PLOT_FORMAT::GERBER,
  PLOT_FORMAT::POST, PLOT_FORMAT::DXF, PLOT_FORMAT::PDF, PLOT_FORMAT::SVG,
  PLOT_FORMAT::LAST_FORMAT = SVG
}
 The set of supported output plot formats. More...
 
enum  PLOT_TEXT_MODE { PLOT_TEXT_MODE::STROKE, PLOT_TEXT_MODE::NATIVE, PLOT_TEXT_MODE::PHANTOM, PLOT_TEXT_MODE::DEFAULT }
 Which kind of text to output with the PSLIKE plotters. More...
 
enum  PLOT_DASH_TYPE {
  PLOT_DASH_TYPE::DEFAULT = -1, PLOT_DASH_TYPE::SOLID = 0, PLOT_DASH_TYPE::FIRST_TYPE = SOLID, PLOT_DASH_TYPE::DASH,
  PLOT_DASH_TYPE::DOT, PLOT_DASH_TYPE::DASHDOT, PLOT_DASH_TYPE::LAST_TYPE = DASHDOT
}
 Dashed line types. More...
 

Functions

wxPenStyle GetwxPenStyle (PLOT_DASH_TYPE aType)
 Convert KiCad line plot styles to wxWidgets device context styles. More...
 
void PlotWorkSheet (PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const wxString &aSheetNumber, int aNumberOfSheets, const wxString &aSheetDesc, 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 DXF_UNITS
strong
Enumerator
INCHES 
MILLIMETERS 

Definition at line 55 of file plotter.h.

◆ PLOT_DASH_TYPE

enum PLOT_DASH_TYPE
strong

Dashed line types.

Enumerator
DEFAULT 
SOLID 
FIRST_TYPE 
DASH 
DOT 
DASHDOT 
LAST_TYPE 

Definition at line 104 of file plotter.h.

◆ PLOT_FORMAT

enum 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 67 of file plotter.h.

◆ PLOT_TEXT_MODE

enum 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 93 of file plotter.h.

Function Documentation

◆ GetDefaultPlotExtension()

wxString GetDefaultPlotExtension ( PLOT_FORMAT  aFormat)

Returns the default plot extension for a format.

Definition at line 34 of file common_plot_functions.cpp.

35 {
36  switch( aFormat )
37  {
38  case PLOT_FORMAT::DXF:
40  case PLOT_FORMAT::POST:
42  case PLOT_FORMAT::PDF:
44  case PLOT_FORMAT::HPGL:
48  case PLOT_FORMAT::SVG:
50  default:
51  wxASSERT( false );
52  return wxEmptyString;
53  }
54 }
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:50
static wxString GetDefaultFileExtension()
Definition: plotter_hpgl.h:44

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

Referenced by GENDRILL_WRITER_BASE::CreateMapFilesSet(), PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().

◆ GetwxPenStyle()

wxPenStyle GetwxPenStyle ( PLOT_DASH_TYPE  aType)

Convert KiCad line plot styles to wxWidgets device context styles.

Parameters
aTypeThe KiCad line plot style to convert.
Returns
The equivalent wxPenStyle of aType.

Definition at line 614 of file plotter.cpp.

615 {
616  switch( aType )
617  {
620  return wxPENSTYLE_SOLID;
622  return wxPENSTYLE_SHORT_DASH;
623  case PLOT_DASH_TYPE::DOT:
624  return wxPENSTYLE_DOT;
626  return wxPENSTYLE_DOT_DASH;
627  default:
628  wxFAIL_MSG( "Unhandled PlotDashType" );
629  return wxPENSTYLE_SOLID;
630  }
631 }

References DASH, DASHDOT, DEFAULT, DOT, and SOLID.

Referenced by SCH_BUS_ENTRY_BASE::Print(), and SCH_LINE::Print().

◆ PlotWorkSheet()

void PlotWorkSheet ( PLOTTER plotter,
const PROJECT aProject,
const TITLE_BLOCK aTitleBlock,
const PAGE_INFO aPageInfo,
const wxString &  aSheetNumber,
int  aNumberOfSheets,
const wxString &  aSheetDesc,
const wxString &  aFilename,
COLOR4D  aColor = COLOR4D::UNSPECIFIED,
bool  aIsFirstPage = true 
)

Definition at line 57 of file common_plot_functions.cpp.

61 {
62  /* Note: Page sizes values are given in mils
63  */
64  double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
65  COLOR4D plotColor = plotter->GetColorMode() ? aColor : COLOR4D::BLACK;
66  int defaultPenWidth = plotter->RenderSettings()->GetDefaultPenWidth();
67 
68  if( plotColor == COLOR4D::UNSPECIFIED )
69  plotColor = COLOR4D( RED );
70 
71  plotter->SetColor( plotColor );
72  WS_DRAW_ITEM_LIST drawList;
73 
74  // Print only a short filename, if aFilename is the full filename
75  wxFileName fn( aFilename );
76 
77  // Prepare plot parameters
79  drawList.SetMilsToIUfactor( iusPerMil );
80  drawList.SetPageNumber( aSheetNumber );
81  drawList.SetSheetCount( aNumberOfSheets );
82  drawList.SetFileName( fn.GetFullName() ); // Print only the short filename
83  drawList.SetSheetName( aSheetDesc );
84  drawList.SetProject( aProject );
85  drawList.SetIsFirstPage( aIsFirstPage );
86 
87  drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );
88 
89  // Draw item list
90  for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
91  {
93 
94  switch( item->Type() )
95  {
96  case WSG_LINE_T:
97  {
98  WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
99  plotter->SetCurrentLineWidth( std::max( line->GetPenWidth(), defaultPenWidth ) );
100  plotter->MoveTo( line->GetStart() );
101  plotter->FinishTo( line->GetEnd() );
102  }
103  break;
104 
105  case WSG_RECT_T:
106  {
107  WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
108  int penWidth = std::max( rect->GetPenWidth(), defaultPenWidth );
109  plotter->Rect( rect->GetStart(), rect->GetEnd(), FILL_TYPE::NO_FILL, penWidth );
110  }
111  break;
112 
113  case WSG_TEXT_T:
114  {
115  WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
116  int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth );
117  plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(),
118  text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(),
119  text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(),
120  text->IsMultilineAllowed() );
121  }
122  break;
123 
124  case WSG_POLY_T:
125  {
127  int penWidth = std::max( poly->GetPenWidth(), defaultPenWidth );
128  std::vector<wxPoint> points;
129 
130  for( int idx = 0; idx < poly->GetPolygons().OutlineCount(); ++idx )
131  {
132  points.clear();
133  SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
134 
135  for( int ii = 0; ii < outline.PointCount(); ii++ )
136  points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
137 
138  plotter->PlotPoly( points, FILL_TYPE::FILLED_SHAPE, penWidth );
139  }
140  }
141  break;
142 
143  case WSG_BITMAP_T:
144  {
145  WS_DRAW_ITEM_BITMAP* drawItem = (WS_DRAW_ITEM_BITMAP*) item;
146  auto* bitmap = (WS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
147 
148  if( bitmap->m_ImageBitmap == NULL )
149  break;
150 
151  bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,
153  }
154  break;
155 
156  default:
157  wxFAIL_MSG( "PlotWorkSheet(): Unknown worksheet item." );
158  break;
159  }
160  }
161 }
const wxPoint & GetStart() const
Definition: ws_draw_item.h:217
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
WS_DATA_ITEM * GetPeer() const
Definition: ws_draw_item.h:75
bool IsBold() const
Definition: eda_text.h:189
const wxPoint & GetEnd() const
Definition: ws_draw_item.h:219
void SetDefaultPenSize(int aPenSize)
Definition: ws_draw_item.h:437
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ws_draw_item.h:416
int OutlineCount() const
Returns the number of outlines in the set
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
const wxPoint & GetEnd() const
Definition: ws_draw_item.h:137
virtual void SetColor(COLOR4D color)=0
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)=0
SHAPE_POLY_SET & GetPolygons()
Definition: ws_draw_item.h:180
WS_DRAW_ITEM_BASE * GetNext()
Definition: ws_draw_item.h:490
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ws_draw_item.h:424
double GetTextAngle() const
Definition: eda_text.h:180
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Draw a polygon ( filled or not )
WS_DRAW_ITEM_BASE * GetFirst()
Definition: ws_draw_item.h:480
Definition: color4d.h:45
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ws_draw_item.h:451
wxPoint GetPosition() const override
Definition: ws_draw_item.h:336
int PointCount() const
Function PointCount()
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: gr_text.cpp:219
bool IsItalic() const
Definition: eda_text.h:186
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ws_draw_item.h:359
const VECTOR2I & CPoint(int aIndex) const
Function Point()
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
Definition: ws_draw_item.h:459
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
#define NULL
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the page layout.
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ws_draw_item.h:464
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
const wxSize & GetTextSize() const
Definition: eda_text.h:245
const wxPoint & GetStart() const
Definition: ws_draw_item.h:135
void SetMilsToIUfactor(double aScale)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ws_draw_item.h:443
double GetIUsPerDecimil() const
The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establ...
Definition: plotter.h:230
Definition: color4d.h:60
bool IsMultilineAllowed() const
Definition: eda_text.h:203
virtual int GetPenWidth() const
Definition: ws_draw_item.h:82
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:165
SHAPE_LINE_CHAIN.
Helper classes to handle basic graphic items used to draw/plot title blocks and frame references segm...
Definition: ws_draw_item.h:56
int GetDefaultPenWidth() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
void SetProject(const PROJECT *aProject)
Definition: ws_draw_item.h:401
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:140
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
bool GetColorMode() const
Definition: plotter.h:162

References BLACK, WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), SHAPE_LINE_CHAIN::CPoint(), FILLED_SHAPE, PLOTTER::FinishTo(), PLOTTER::GetColorMode(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), WS_DRAW_ITEM_LINE::GetEnd(), WS_DRAW_ITEM_RECT::GetEnd(), WS_DRAW_ITEM_LIST::GetFirst(), EDA_TEXT::GetHorizJustify(), PLOTTER::GetIUsPerDecimil(), WS_DRAW_ITEM_LIST::GetNext(), WS_DRAW_ITEM_BASE::GetPeer(), WS_DRAW_ITEM_BASE::GetPenWidth(), WS_DRAW_ITEM_POLYPOLYGONS::GetPolygons(), WS_DRAW_ITEM_BITMAP::GetPosition(), EDA_TEXT::GetShownText(), WS_DRAW_ITEM_LINE::GetStart(), WS_DRAW_ITEM_RECT::GetStart(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMultilineAllowed(), PLOTTER::MoveTo(), NO_FILL, NULL, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PLOTTER::PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), PLOTTER::Rect(), RED, PLOTTER::RenderSettings(), PLOTTER::SetColor(), PLOTTER::SetCurrentLineWidth(), WS_DRAW_ITEM_LIST::SetDefaultPenSize(), WS_DRAW_ITEM_LIST::SetFileName(), WS_DRAW_ITEM_LIST::SetIsFirstPage(), WS_DRAW_ITEM_LIST::SetMilsToIUfactor(), WS_DRAW_ITEM_LIST::SetPageNumber(), WS_DRAW_ITEM_LIST::SetProject(), WS_DRAW_ITEM_LIST::SetSheetCount(), WS_DRAW_ITEM_LIST::SetSheetName(), 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 DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL(), DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPS(), DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG(), and StartPlotBoard().