KiCad PCB EDA Suite
common_plot_functions.cpp File Reference
#include <fctsys.h>
#include <base_struct.h>
#include <plotter.h>
#include <ws_painter.h>
#include <base_screen.h>
#include <gr_text.h>
#include <title_block.h>
#include "ws_draw_item.h"
#include "ws_data_item.h"
#include <wx/filename.h>

Go to the source code of this file.


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, const COLOR4D aColor)

Function Documentation

◆ GetDefaultPlotExtension()

wxString GetDefaultPlotExtension ( PlotFormat  aFormat)

Returns the default plot extension for a format.

Definition at line 38 of file common_plot_functions.cpp.

39 {
40  switch( aFormat )
41  {
48  default: wxASSERT( false ); return wxEmptyString;
49  }
50 }
static wxString GetDefaultFileExtension()
Definition: plotter.h:855
static wxString GetDefaultFileExtension()
Definition: plotter.h:792
static wxString GetDefaultFileExtension()
Definition: plotter.h:934
static wxString GetDefaultFileExtension()
Definition: plotter.h:1149
static wxString GetDefaultFileExtension()
Definition: plotter.h:1401
static wxString GetDefaultFileExtension()
Definition: plotter.h:610

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 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 

Definition at line 54 of file common_plot_functions.cpp.

57 {
58  /* Note: Page sizes values are given in mils
59  */
60  double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
62  COLOR4D plotColor = plotter->GetColorMode() ? aColor : COLOR4D::BLACK;
64  if( plotColor == COLOR4D::UNSPECIFIED )
65  plotColor = COLOR4D( RED );
67  plotter->SetColor( plotColor );
68  WS_DRAW_ITEM_LIST drawList;
70  // Print only a short filename, if aFilename is the full filename
71  wxFileName fn( aFilename );
73  // Prepare plot parameters
75  drawList.SetMilsToIUfactor( iusPerMil );
76  drawList.SetSheetNumber( aSheetNumber );
77  drawList.SetSheetCount( aNumberOfSheets );
78  drawList.SetFileName( fn.GetFullName() ); // Print only the short filename
79  drawList.SetSheetName( aSheetDesc );
82  drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );
84  // Draw item list
85  for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
86  {
89  switch( item->Type() )
90  {
91  case WSG_LINE_T:
92  {
93  WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
94  plotter->SetCurrentLineWidth( line->GetPenWidth() );
95  plotter->MoveTo( line->GetStart() );
96  plotter->FinishTo( line->GetEnd() );
97  }
98  break;
100  case WSG_RECT_T:
101  {
102  WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
103  plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL, rect->GetPenWidth() );
104  }
105  break;
107  case WSG_TEXT_T:
108  {
109  WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
110  plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(),
111  text->GetTextAngle(), text->GetTextSize(),
112  text->GetHorizJustify(), text->GetVertJustify(),
113  text->GetPenWidth(), text->IsItalic(), text->IsBold(),
114  text->IsMultilineAllowed() );
115  }
116  break;
118  case WSG_POLY_T:
119  {
121  std::vector<wxPoint> points;
123  for( int idx = 0; idx < poly->GetPolygons().OutlineCount(); ++idx )
124  {
125  points.clear();
126  SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
128  for( int ii = 0; ii < outline.PointCount(); ii++ )
129  points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
131  plotter->PlotPoly( points, FILLED_SHAPE, poly->GetPenWidth() );
132  }
133  }
134  break;
136  case WSG_BITMAP_T:
137  {
139  auto* bitmap = (WS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
141  if( bitmap->m_ImageBitmap == NULL )
142  break;
144  bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,
146  }
147  break;
149  default:
150  wxFAIL_MSG( "PlotWorkSheet(): Unknown worksheet item." );
151  break;
152  }
153  }
154 }
const wxPoint & GetStart() const
Definition: ws_draw_item.h:206
void FinishTo(const wxPoint &pos)
Definition: plotter.h:264
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:185
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
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
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:215
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:102
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
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:217
Definition: colors.h:60
bool IsMultilineAllowed() const
Definition: eda_text.h:182
void MoveTo(const wxPoint &pos)
Definition: plotter.h:254
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
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
Returns 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.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
bool GetColorMode() const
Definition: plotter.h:131

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, 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.