KiCad PCB EDA Suite
common_plot_functions.cpp File Reference
#include <eda_item.h>
#include <plotters_specific.h>
#include <drawing_sheet/ds_data_item.h>
#include <drawing_sheet/ds_draw_item.h>
#include <drawing_sheet/ds_painter.h>
#include <title_block.h>
#include <wx/filename.h>

Go to the source code of this file.


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 34 of file common_plot_functions.cpp.

35 {
36  switch( aFormat )
37  {
38  case PLOT_FORMAT::DXF:
42  case PLOT_FORMAT::PDF:
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:46

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 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();
68  if( plotColor == COLOR4D::UNSPECIFIED )
69  plotColor = COLOR4D( RED );
71  plotter->SetColor( plotColor );
72  DS_DRAW_ITEM_LIST drawList;
74  // Print only a short filename, if aFilename is the full filename
75  wxFileName fn( aFilename );
77  // Prepare plot parameters
79  drawList.SetMilsToIUfactor( iusPerMil );
80  drawList.SetPageNumber( aSheetNumber );
81  drawList.SetSheetCount( aSheetCount );
82  drawList.SetFileName( fn.GetFullName() ); // Print only the short filename
83  drawList.SetSheetName( aSheetDesc );
84  drawList.SetProject( aProject );
85  drawList.SetIsFirstPage( aIsFirstPage );
87  drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
89  // Draw item list
90  for( DS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
91  {
94  switch( item->Type() )
95  {
96  case WSG_LINE_T:
97  {
98  DS_DRAW_ITEM_LINE* line = (DS_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;
105  case WSG_RECT_T:
106  {
107  DS_DRAW_ITEM_RECT* rect = (DS_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;
113  case WSG_TEXT_T:
114  {
115  DS_DRAW_ITEM_TEXT* text = (DS_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;
124  case WSG_POLY_T:
125  {
127  int penWidth = std::max( poly->GetPenWidth(), defaultPenWidth );
128  std::vector<wxPoint> points;
130  for( int idx = 0; idx < poly->GetPolygons().OutlineCount(); ++idx )
131  {
132  points.clear();
133  SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
135  for( int ii = 0; ii < outline.PointCount(); ii++ )
136  points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
138  plotter->PlotPoly( points, FILL_TYPE::FILLED_SHAPE, penWidth );
139  }
140  }
141  break;
143  case WSG_BITMAP_T:
144  {
146  DS_DATA_ITEM_BITMAP* bitmap = (DS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
148  if( bitmap->m_ImageBitmap == NULL )
149  break;
151  bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,
153  }
154  break;
156  default:
157  wxFAIL_MSG( "PlotDrawingSheet(): Unknown drawing sheet item." );
158  break;
159  }
160  }
161 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:267
bool IsBold() const
Definition: eda_text.h:190
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.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:442
virtual void SetColor(COLOR4D color)=0
wxPoint GetPosition() const override
Definition: ds_draw_item.h:350
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)=0
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
double GetTextAngle() const
Definition: eda_text.h:181
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 )
Definition: color4d.h:44
int PointCount() const
Function PointCount()
const wxPoint & GetStart() const
Definition: ds_draw_item.h:133
const wxPoint & GetStart() const
Definition: ds_draw_item.h:219
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:187
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
Function Point()
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:126
SHAPE_POLY_SET & GetPolygons()
Definition: ds_draw_item.h:170
Definition: ds_draw_item.h:494
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
#define NULL
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:373
SHAPE_LINE_CHAIN & Outline(int aIndex)
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:455
const wxSize & GetTextSize() const
Definition: eda_text.h:245
double GetIUsPerDecimil() const
The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establ...
Definition: plotter.h:220
Definition: color4d.h:59
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ds_draw_item.h:423
bool IsMultilineAllowed() const
Definition: eda_text.h:203
void MoveTo(const wxPoint &pos)
Definition: plotter.h:257
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 page layout.
DS_DATA_ITEM * GetPeer() const
Definition: ds_draw_item.h:63
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:155
void PlotImage(PLOTTER *aPlotter, const wxPoint &aPos, KIGFX::COLOR4D aDefaultColor, int aDefaultPensize)
Plot bitmap on plotter.
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:400
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 & GetTextPos() const
Definition: eda_text.h:254
const wxPoint & GetEnd() const
Definition: ds_draw_item.h:221
virtual int GetPenWidth() const
Definition: ds_draw_item.h:70
Definition: ds_draw_item.h:484
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:141
const wxPoint & GetEnd() const
Definition: ds_draw_item.h:135
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
bool GetColorMode() const
Definition: plotter.h:152

References BLACK, DS_DRAW_ITEM_LIST::BuildDrawItemsList(), SHAPE_LINE_CHAIN::CPoint(), FILLED_SHAPE, PLOTTER::FinishTo(), PLOTTER::GetColorMode(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), DS_DRAW_ITEM_LINE::GetEnd(), DS_DRAW_ITEM_RECT::GetEnd(), DS_DRAW_ITEM_LIST::GetFirst(), EDA_TEXT::GetHorizJustify(), 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(), EDA_TEXT::GetShownText(), DS_DRAW_ITEM_LINE::GetStart(), DS_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(), DS_DATA_ITEM_BITMAP::m_ImageBitmap, PLOTTER::MoveTo(), NO_FILL, NULL, 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(), 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.