KiCad PCB EDA Suite
common_plot_functions.cpp File Reference

Kicad: Common plotting functions. More...

#include <fctsys.h>
#include <base_struct.h>
#include <plot_common.h>
#include <worksheet.h>
#include <class_base_screen.h>
#include <drawtxt.h>
#include <class_title_block.h>
#include "worksheet_shape_builder.h"
#include "class_worksheet_dataitem.h"
#include <wx/filename.h>

Go to the source code of this file.

Functions

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

Detailed Description

Kicad: Common plotting functions.

Definition in file common_plot_functions.cpp.

Function Documentation

wxString GetDefaultPlotExtension ( PlotFormat  aFormat)

Returns the default plot extension for a format.

Definition at line 43 of file common_plot_functions.cpp.

References HPGL_PLOTTER::GetDefaultFileExtension(), PS_PLOTTER::GetDefaultFileExtension(), PDF_PLOTTER::GetDefaultFileExtension(), SVG_PLOTTER::GetDefaultFileExtension(), GERBER_PLOTTER::GetDefaultFileExtension(), DXF_PLOTTER::GetDefaultFileExtension(), PLOT_FORMAT_DXF, PLOT_FORMAT_GERBER, PLOT_FORMAT_HPGL, PLOT_FORMAT_PDF, PLOT_FORMAT_POST, and PLOT_FORMAT_SVG.

Referenced by EXCELLON_WRITER::CreateDrillandMapFilesSet(), PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().

44 {
45  switch( aFormat )
46  {
47  case PLOT_FORMAT_DXF:
49 
50  case PLOT_FORMAT_POST:
52 
53  case PLOT_FORMAT_PDF:
55 
56  case PLOT_FORMAT_HPGL:
58 
59  case PLOT_FORMAT_GERBER:
61 
62  case PLOT_FORMAT_SVG:
64 
65  default:
66  wxASSERT( false );
67  return wxEmptyString;
68  }
69 }
static wxString GetDefaultFileExtension()
Definition: plot_common.h:804
static wxString GetDefaultFileExtension()
Definition: plot_common.h:741
static wxString GetDefaultFileExtension()
Definition: plot_common.h:883
static wxString GetDefaultFileExtension()
Definition: plot_common.h:995
static wxString GetDefaultFileExtension()
Definition: plot_common.h:1220
static wxString GetDefaultFileExtension()
Definition: plot_common.h:566
void PlotWorkSheet ( PLOTTER plotter,
const TITLE_BLOCK aTitleBlock,
const PAGE_INFO aPageInfo,
int  aSheetNumber,
int  aNumberOfSheets,
const wxString &  aSheetDesc,
const wxString &  aFilename 
)

Definition at line 73 of file common_plot_functions.cpp.

References BLACK, WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), FILLED_SHAPE, PLOTTER::FinishTo(), WS_DRAW_ITEM_BASE::GetColor(), PLOTTER::GetColorMode(), WS_DRAW_ITEM_LINE::GetEnd(), WS_DRAW_ITEM_LIST::GetFirst(), EDA_TEXT::GetHorizJustify(), PLOTTER::GetIUsPerDecimil(), WS_DRAW_ITEM_LIST::GetNext(), WS_DRAW_ITEM_BASE::GetParent(), WS_DRAW_ITEM_LINE::GetPenWidth(), WS_DRAW_ITEM_POLYGON::GetPenWidth(), WS_DRAW_ITEM_TEXT::GetPenWidth(), WS_DRAW_ITEM_BITMAP::GetPosition(), EDA_TEXT::GetShownText(), WS_DRAW_ITEM_LINE::GetStart(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsBold(), WS_DRAW_ITEM_POLYGON::IsFilled(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMultilineAllowed(), WS_DRAW_ITEM_POLYGON::m_Corners, WORKSHEET_DATAITEM_BITMAP::m_ImageBitmap, PLOTTER::MoveTo(), NO_FILL, BITMAP_BASE::PlotImage(), PLOTTER::PlotPoly(), PLOTTER::Rect(), RED, PLOTTER::SetColor(), PLOTTER::SetCurrentLineWidth(), WS_DRAW_ITEM_LIST::SetFileName(), WS_DRAW_ITEM_LIST::SetMilsToIUfactor(), WS_DRAW_ITEM_LIST::SetPenSize(), WS_DRAW_ITEM_LIST::SetSheetCount(), WS_DRAW_ITEM_LIST::SetSheetName(), WS_DRAW_ITEM_LIST::SetSheetNumber(), PLOTTER::Text(), PLOTTER::USE_DEFAULT_LINE_WIDTH, WS_DRAW_ITEM_BASE::wsg_bitmap, WS_DRAW_ITEM_BASE::wsg_line, WS_DRAW_ITEM_BASE::wsg_poly, WS_DRAW_ITEM_BASE::wsg_rect, and WS_DRAW_ITEM_BASE::wsg_text.

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().

77 {
78  /* Note: Page sizes values are given in mils
79  */
80  double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
81 
82  COLOR4D plotColor = plotter->GetColorMode() ? COLOR4D( RED ) : COLOR4D::BLACK;
83  plotter->SetColor( plotColor );
84  WS_DRAW_ITEM_LIST drawList;
85 
86  // Print only a short filename, if aFilename is the full filename
87  wxFileName fn( aFilename );
88 
89  // Prepare plot parameters
91  drawList.SetMilsToIUfactor( iusPerMil );
92  drawList.SetSheetNumber( aSheetNumber );
93  drawList.SetSheetCount( aNumberOfSheets );
94  drawList.SetFileName( fn.GetFullName() ); // Print only the short filename
95  drawList.SetSheetName( aSheetDesc );
96 
97 
98  drawList.BuildWorkSheetGraphicList( aPageInfo,
99  aTitleBlock, plotColor, plotColor );
100 
101  // Draw item list
102  for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item;
103  item = drawList.GetNext() )
104  {
106 
107  switch( item->GetType() )
108  {
110  {
111  WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
112  plotter->SetCurrentLineWidth( line->GetPenWidth() );
113  plotter->MoveTo( line->GetStart() );
114  plotter->FinishTo( line->GetEnd() );
115  }
116  break;
117 
119  {
120  WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
121  plotter->Rect( rect->GetStart(),
122  rect->GetEnd(),
123  NO_FILL,
124  rect->GetPenWidth() );
125  }
126  break;
127 
129  {
130  WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
131  plotter->Text( text->GetTextPos(), text->GetColor(),
132  text->GetShownText(), text->GetTextAngle(),
133  text->GetTextSize(),
134  text->GetHorizJustify(), text->GetVertJustify(),
135  text->GetPenWidth(),
136  text->IsItalic(), text->IsBold(),
137  text->IsMultilineAllowed() );
138  }
139  break;
140 
142  {
144  plotter->PlotPoly( poly->m_Corners,
145  poly->IsFilled() ? FILLED_SHAPE : NO_FILL,
146  poly->GetPenWidth() );
147  }
148  break;
149 
151  {
153 
155 
156  if( parent->m_ImageBitmap == NULL )
157  break;
158 
159  parent->m_ImageBitmap->PlotImage( plotter, bm->GetPosition(),
160  plotColor, PLOTTER::USE_DEFAULT_LINE_WIDTH );
161  }
162  break;
163  }
164  }
165 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetPenSize(int aPenSize)
Function SetPenSize Set the default pen size to draw/plot lines and texts.
bool IsMultilineAllowed() const
Definition: eda_text.h:188
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
bool IsItalic() const
Definition: eda_text.h:170
virtual void SetColor(COLOR4D color)=0
WS_DRAW_ITEM_BASE * GetNext()
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
WS_DRAW_ITEM_BASE * GetFirst()
void PlotImage(PLOTTER *aPlotter, const wxPoint &aPos, COLOR4D aDefaultColor, int aDefaultPensize)
Function PlotImage Plot bitmap on plotter.
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock, COLOR4D aColor, COLOR4D aAltColor)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
bool IsBold() const
Definition: eda_text.h:173
double GetTextAngle() const
Definition: eda_text.h:164
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:227
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
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
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
void SetSheetCount(int aSheetCount)
Function SetSheetCount Set the value of the count of sheets, for basic inscriptions.
WORKSHEET_DATAITEM * GetParent() const
void SetMilsToIUfactor(double aScale)
Function SetMilsToIUfactor Set the scalar to convert pages units ( mils) to draw/plot units...
const wxPoint & GetEnd() const
COLOR4D GetColor() const
Definition: colors.h:60
std::vector< wxPoint > m_Corners
bool GetColorMode() const
Definition: plot_common.h:121
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.
const wxPoint & GetPosition()
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:215
const wxPoint & GetStart() const
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