KiCad PCB EDA Suite
plotter.h File Reference
#include <vector>
#include <math/box2.h>
#include <gr_text.h>
#include <page_info.h>
#include <eda_text.h>

Go to the source code of this file.

Classes

class  PLOTTER
 Base plotter engine class. More...
 
class  HPGL_PLOTTER
 
class  PSLIKE_PLOTTER
 The PSLIKE_PLOTTER class is an intermediate class to handle common routines for engines working more or less with the postscript imaging model. More...
 
class  PS_PLOTTER
 
class  PDF_PLOTTER
 
class  SVG_PLOTTER
 
class  APERTURE
 
class  GERBER_PLOTTER
 
class  DXF_PLOTTER
 

Macros

#define FIRST_DCODE_VALUE   10
 

Enumerations

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
}
 Enum PlotFormat is 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 }
 Enum for choosing 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
}
 Enum for choosing dashed line type. More...
 

Functions

void PlotWorkSheet (PLOTTER *plotter, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, int aSheetNumber, int aNumberOfSheets, const wxString &aSheetDesc, const wxString &aFilename, const COLOR4D aColor=COLOR4D::UNSPECIFIED)
 
wxString GetDefaultPlotExtension (PLOT_FORMAT aFormat)
 Returns the default plot extension for a format. More...
 

Macro Definition Documentation

◆ FIRST_DCODE_VALUE

#define FIRST_DCODE_VALUE   10

Definition at line 1053 of file plotter.h.

Enumeration Type Documentation

◆ PLOT_DASH_TYPE

enum PLOT_DASH_TYPE
strong

Enum for choosing dashed line type.

Enumerator
DEFAULT 
SOLID 
FIRST_TYPE 
DASH 
DOT 
DASHDOT 
LAST_TYPE 

Definition at line 86 of file plotter.h.

◆ PLOT_FORMAT

enum PLOT_FORMAT
strong

Enum PlotFormat is 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 50 of file plotter.h.

◆ PLOT_TEXT_MODE

enum PLOT_TEXT_MODE
strong

Enum for choosing 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 75 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  {
41  case PLOT_FORMAT::DXF:
43  case PLOT_FORMAT::POST:
45  case PLOT_FORMAT::PDF:
47  case PLOT_FORMAT::HPGL:
51  case PLOT_FORMAT::SVG:
53  default:
54  wxASSERT( false );
55  return wxEmptyString;
56  }
57 }
static wxString GetDefaultFileExtension()
Definition: plotter.h:860
static wxString GetDefaultFileExtension()
Definition: plotter.h:797
static wxString GetDefaultFileExtension()
Definition: plotter.h:939
static wxString GetDefaultFileExtension()
Definition: plotter.h:1151
static wxString GetDefaultFileExtension()
Definition: plotter.h:1406
static wxString GetDefaultFileExtension()
Definition: plotter.h:616

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

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

◆ PlotWorkSheet()

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

Definition at line 60 of file common_plot_functions.cpp.

63 {
64  /* Note: Page sizes values are given in mils
65  */
66  double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
67 
68  COLOR4D plotColor = plotter->GetColorMode() ? aColor : COLOR4D::BLACK;
69 
70  if( plotColor == COLOR4D::UNSPECIFIED )
71  plotColor = COLOR4D( RED );
72 
73  plotter->SetColor( plotColor );
74  WS_DRAW_ITEM_LIST drawList;
75 
76  // Print only a short filename, if aFilename is the full filename
77  wxFileName fn( aFilename );
78 
79  // Prepare plot parameters
81  drawList.SetMilsToIUfactor( iusPerMil );
82  drawList.SetSheetNumber( aSheetNumber );
83  drawList.SetSheetCount( aNumberOfSheets );
84  drawList.SetFileName( fn.GetFullName() ); // Print only the short filename
85  drawList.SetSheetName( aSheetDesc );
86 
87 
88  drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );
89 
90  // Draw item list
91  for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
92  {
94 
95  switch( item->Type() )
96  {
97  case WSG_LINE_T:
98  {
99  WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
100  plotter->SetCurrentLineWidth( line->GetPenWidth() );
101  plotter->MoveTo( line->GetStart() );
102  plotter->FinishTo( line->GetEnd() );
103  }
104  break;
105 
106  case WSG_RECT_T:
107  {
108  WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
109  plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL, rect->GetPenWidth() );
110  }
111  break;
112 
113  case WSG_TEXT_T:
114  {
115  WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
116  plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(),
117  text->GetTextAngle(), text->GetTextSize(),
118  text->GetHorizJustify(), text->GetVertJustify(),
119  text->GetPenWidth(), text->IsItalic(), text->IsBold(),
120  text->IsMultilineAllowed() );
121  }
122  break;
123 
124  case WSG_POLY_T:
125  {
127  std::vector<wxPoint> points;
128 
129  for( int idx = 0; idx < poly->GetPolygons().OutlineCount(); ++idx )
130  {
131  points.clear();
132  SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
133 
134  for( int ii = 0; ii < outline.PointCount(); ii++ )
135  points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
136 
137  plotter->PlotPoly( points, FILLED_SHAPE, poly->GetPenWidth() );
138  }
139  }
140  break;
141 
142  case WSG_BITMAP_T:
143  {
144  WS_DRAW_ITEM_BITMAP* drawItem = (WS_DRAW_ITEM_BITMAP*) item;
145  auto* bitmap = (WS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
146 
147  if( bitmap->m_ImageBitmap == NULL )
148  break;
149 
150  bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,
152  }
153  break;
154 
155  default:
156  wxFAIL_MSG( "PlotWorkSheet(): Unknown worksheet item." );
157  break;
158  }
159  }
160 }
const wxPoint & GetStart() const
Definition: ws_draw_item.h:206
void FinishTo(const wxPoint &pos)
Definition: plotter.h:270
WS_DATA_ITEM * GetPeer() const
Definition: ws_draw_item.h:66
bool IsBold() const
Definition: eda_text.h:167
const wxPoint & GetEnd() const
Definition: ws_draw_item.h:208
void SetDefaultPenSize(int aPenSize)
Definition: ws_draw_item.h:425
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ws_draw_item.h:404
int OutlineCount() const
Returns the number of outlines in the set
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:184
const wxPoint & GetEnd() const
Definition: ws_draw_item.h:124
virtual void SetColor(COLOR4D color)=0
SHAPE_POLY_SET & GetPolygons()
Definition: ws_draw_item.h:167
int GetPenWidth() const
Definition: ws_draw_item.h:205
WS_DRAW_ITEM_BASE * GetNext()
Definition: ws_draw_item.h:476
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ws_draw_item.h:412
double GetTextAngle() const
Definition: eda_text.h:158
WS_DRAW_ITEM_BASE * GetFirst()
Definition: ws_draw_item.h:466
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
int PointCount() const
Function PointCount()
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:232
bool IsItalic() const
Definition: eda_text.h:164
const VECTOR2I & CPoint(int aIndex) const
Function Point()
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:108
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:183
#define NULL
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
void SetSheetCount(int aSheetCount)
Function SetSheetCount Set the value of the count of sheets, for basic inscriptions.
Definition: ws_draw_item.h:450
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
const wxSize & GetTextSize() const
Definition: eda_text.h:223
const wxPoint & GetStart() const
Definition: ws_draw_item.h:122
int GetPenWidth() const
Definition: ws_draw_item.h:121
void SetMilsToIUfactor(double aScale)
Function SetMilsToIUfactor Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ws_draw_item.h:432
double GetIUsPerDecimil() const
The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establ...
Definition: plotter.h:223
Definition: colors.h:60
bool IsMultilineAllowed() const
Definition: eda_text.h:181
void MoveTo(const wxPoint &pos)
Definition: plotter.h:260
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.
Definition: ws_draw_item.h:441
const wxPoint GetPosition() const override
Definition: ws_draw_item.h:330
SHAPE_LINE_CHAIN.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
Definition: colors.h:45
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:39
bool GetColorMode() const
Definition: plotter.h:137

References BLACK, WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), SHAPE_LINE_CHAIN::CPoint(), FILLED_SHAPE, PLOTTER::FinishTo(), PLOTTER::GetColorMode(), 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_LINE::GetPenWidth(), WS_DRAW_ITEM_POLYPOLYGONS::GetPenWidth(), WS_DRAW_ITEM_RECT::GetPenWidth(), WS_DRAW_ITEM_TEXT::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::SetColor(), PLOTTER::SetCurrentLineWidth(), WS_DRAW_ITEM_LIST::SetDefaultPenSize(), WS_DRAW_ITEM_LIST::SetFileName(), WS_DRAW_ITEM_LIST::SetMilsToIUfactor(), WS_DRAW_ITEM_LIST::SetSheetCount(), WS_DRAW_ITEM_LIST::SetSheetName(), WS_DRAW_ITEM_LIST::SetSheetNumber(), 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().