KiCad PCB EDA Suite
common_plot_functions.cpp File Reference

Go to the source code of this file.

Functions

wxString GetDefaultPlotExtension (PLOT_FORMAT aFormat)
 Returns the default plot extension for a format. More...
 
void PlotDrawingSheet (PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const wxString &aSheetNumber, int aSheetCount, const wxString &aSheetDesc, const wxString &aFilename, COLOR4D aColor, bool aIsFirstPage)
 

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()
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:47
static wxString GetDefaultFileExtension()
Definition: plotter_hpgl.h:43

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

◆ PlotDrawingSheet()

void PlotDrawingSheet ( PLOTTER plotter,
const PROJECT aProject,
const TITLE_BLOCK aTitleBlock,
const PAGE_INFO aPageInfo,
const wxString &  aSheetNumber,
int  aSheetCount,
const wxString &  aSheetDesc,
const wxString &  aFilename,
COLOR4D  aColor,
bool  aIsFirstPage 
)

Definition at line 60 of file common_plot_functions.cpp.

64 {
65  /* Note: Page sizes values are given in mils
66  */
67  double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
68  COLOR4D plotColor = plotter->GetColorMode() ? aColor : COLOR4D::BLACK;
69  int defaultPenWidth = plotter->RenderSettings()->GetDefaultPenWidth();
70 
71  if( plotColor == COLOR4D::UNSPECIFIED )
72  plotColor = COLOR4D( RED );
73 
74  plotter->SetColor( plotColor );
75  DS_DRAW_ITEM_LIST drawList;
76 
77  // Print only a short filename, if aFilename is the full filename
78  wxFileName fn( aFilename );
79 
80  // Prepare plot parameters
82  drawList.SetMilsToIUfactor( iusPerMil );
83  drawList.SetPageNumber( aSheetNumber );
84  drawList.SetSheetCount( aSheetCount );
85  drawList.SetFileName( fn.GetFullName() ); // Print only the short filename
86  drawList.SetSheetName( aSheetDesc );
87  drawList.SetProject( aProject );
88  drawList.SetIsFirstPage( aIsFirstPage );
89 
90  drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
91 
92  // Draw item list
93  for( DS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
94  {
96 
97  switch( item->Type() )
98  {
99  case WSG_LINE_T:
100  {
101  DS_DRAW_ITEM_LINE* line = (DS_DRAW_ITEM_LINE*) item;
102  plotter->SetCurrentLineWidth( std::max( line->GetPenWidth(), defaultPenWidth ) );
103  plotter->MoveTo( line->GetStart() );
104  plotter->FinishTo( line->GetEnd() );
105  }
106  break;
107 
108  case WSG_RECT_T:
109  {
110  DS_DRAW_ITEM_RECT* rect = (DS_DRAW_ITEM_RECT*) item;
111  int penWidth = std::max( rect->GetPenWidth(), defaultPenWidth );
112  plotter->Rect( rect->GetStart(), rect->GetEnd(), FILL_T::NO_FILL, penWidth );
113  }
114  break;
115 
116  case WSG_TEXT_T:
117  {
119  int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth );
120  plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(),
121  text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(),
122  text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(),
123  text->IsMultilineAllowed() );
124  }
125  break;
126 
127  case WSG_POLY_T:
128  {
130  int penWidth = std::max( poly->GetPenWidth(), defaultPenWidth );
131  std::vector<wxPoint> points;
132 
133  for( int idx = 0; idx < poly->GetPolygons().OutlineCount(); ++idx )
134  {
135  points.clear();
136  SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
137 
138  for( int ii = 0; ii < outline.PointCount(); ii++ )
139  points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
140 
141  plotter->PlotPoly( points, FILL_T::FILLED_SHAPE, penWidth );
142  }
143  }
144  break;
145 
146  case WSG_BITMAP_T:
147  {
148  DS_DRAW_ITEM_BITMAP* drawItem = (DS_DRAW_ITEM_BITMAP*) item;
149  DS_DATA_ITEM_BITMAP* bitmap = (DS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
150 
151  if( bitmap->m_ImageBitmap == nullptr )
152  break;
153 
154  bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,
156  }
157  break;
158 
159  default:
160  wxFAIL_MSG( "PlotDrawingSheet(): Unknown drawing sheet item." );
161  break;
162  }
163  }
164 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
Definition: ds_draw_item.h:463
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:442
wxPoint GetPosition() const override
Definition: ds_draw_item.h:350
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
void SetDefaultPenSize(int aPenSize)
Definition: ds_draw_item.h:436
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ds_draw_item.h:415
void PlotImage(PLOTTER *aPlotter, const wxPoint &aPos, const KIGFX::COLOR4D &aDefaultColor, int aDefaultPensize) const
Plot bitmap on plotter.
Definition: color4d.h:44
int PointCount() const
Return the number of points (vertices) in this line chain.
const wxPoint & GetStart() const
Definition: ds_draw_item.h:133
const wxPoint & GetStart() const
Definition: ds_draw_item.h:219
Base class to handle basic graphic items.
Definition: ds_draw_item.h:58
A graphic text.
Definition: ds_draw_item.h:297
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:126
SHAPE_POLY_SET & GetPolygons()
Definition: ds_draw_item.h:170
DS_DRAW_ITEM_BASE * GetNext()
Definition: ds_draw_item.h:494
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:368
SHAPE_LINE_CHAIN & Outline(int aIndex)
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:455
double GetIUsPerDecimil() const
The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establ...
Definition: plotter.h:225
Definition: color4d.h:59
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ds_draw_item.h:423
virtual void SetColor(const COLOR4D &color)=0
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
Non filled rectangle with thick segment.
Definition: ds_draw_item.h:205
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
DS_DATA_ITEM * GetPeer() const
Definition: ds_draw_item.h:63
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:156
Represent a polyline (an zero-thickness chain of connected line segments).
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:400
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ds_draw_item.h:468
int GetDefaultPenWidth() const
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ds_draw_item.h:376
const wxPoint & GetEnd() const
Definition: ds_draw_item.h:221
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=nullptr)
Draw text with the plotter.
Definition: gr_text.cpp:219
virtual int GetPenWidth() const
Definition: ds_draw_item.h:70
DS_DRAW_ITEM_BASE * GetFirst()
Definition: ds_draw_item.h:484
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
const wxPoint & GetEnd() const
Definition: ds_draw_item.h:135
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
bool GetColorMode() const
Definition: plotter.h:153

References BLACK, DS_DRAW_ITEM_LIST::BuildDrawItemsList(), SHAPE_LINE_CHAIN::CPoint(), FILLED_SHAPE, PLOTTER::FinishTo(), PLOTTER::GetColorMode(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), DS_DRAW_ITEM_LINE::GetEnd(), DS_DRAW_ITEM_RECT::GetEnd(), DS_DRAW_ITEM_LIST::GetFirst(), PLOTTER::GetIUsPerDecimil(), 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(), DS_DATA_ITEM_BITMAP::m_ImageBitmap, PLOTTER::MoveTo(), NO_FILL, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), BITMAP_BASE::PlotImage(), PLOTTER::PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), PLOTTER::Rect(), 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::SetSheetCount(), DS_DRAW_ITEM_LIST::SetSheetName(), PLOTTER::Text(), 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::plotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPS(), DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG(), and StartPlotBoard().