KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
gen_drill_report_files.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
28#include <eda_item.h>
29#include <font/font.h>
30#include <confirm.h>
31#include <richio.h>
32#include <string_utils.h>
33#include <locale_io.h>
34#include <macros.h>
35#include <math/util.h> // for KiROUND
36
37#include <board.h>
38#include <footprint.h>
39
40#include <pcbplot.h>
42#include <pcb_painter.h>
43#include <pcb_shape.h>
44
45
46/* Conversion utilities - these will be used often in there... */
47inline double diameter_in_inches( double ius )
48{
49 return ius * 0.001 / pcbIUScale.IU_PER_MILS;
50}
51
52
53inline double diameter_in_mm( double ius )
54{
55 return ius / pcbIUScale.IU_PER_MM;
56}
57
58
59// return a pen size to plot markers and having a readable shape
60// clamped to be >= MIN_SIZE_MM to avoid too small line width
61static int getMarkerBestPenSize( int aMarkerDiameter )
62{
63 int bestsize = aMarkerDiameter / 10;
64
65 const double MIN_SIZE_MM = 0.1;
66 bestsize = std::max( bestsize, pcbIUScale.mmToIU( MIN_SIZE_MM ) );
67
68 return bestsize;
69}
70
71
72// return a pen size to plot outlines for oval holes
74{
75 const double SKETCH_LINE_WIDTH_MM = 0.1;
76 return pcbIUScale.mmToIU( SKETCH_LINE_WIDTH_MM );
77}
78
79
80// return a default pen size to plot items with no specific line thickness
82{
83 const double DEFAULT_LINE_WIDTH_MM = 0.2;
84 return pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH_MM );
85}
86
87
88bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_FORMAT aFormat )
89{
90 // Remark:
91 // Hole list must be created before calling this function, by buildHolesList(),
92 // for the right holes set (PTH, NPTH, buried/blind vias ...)
93
94 double scale = 1.0;
95 VECTOR2I offset = GetOffset();
96 PLOTTER* plotter = nullptr;
98 int bottom_limit = 0; // Y coord limit of page. 0 mean do not use
99
100 PCB_PLOT_PARAMS plot_opts; // starts plotting with default options
101
102 LOCALE_IO toggle; // use standard C notation for float numbers
103
104 const PAGE_INFO& page_info = m_pageInfo ? *m_pageInfo : dummy;
105
106 // Calculate dimensions and center of PCB. The Edge_Cuts layer must be visible
107 // to calculate the board edges bounding box
108 LSET visibleLayers = m_pcb->GetVisibleLayers();
109 m_pcb->SetVisibleLayers( visibleLayers | LSET( { Edge_Cuts } ) );
111 m_pcb->SetVisibleLayers( visibleLayers );
112
113 // Some formats cannot be used to generate a document like the map files
114 // Currently HPGL (old format not very used)
115
116 if( aFormat == PLOT_FORMAT::HPGL )
117 aFormat = PLOT_FORMAT::PDF;
118
119 // Calculate the scale for the format type, scale 1 in HPGL, drawing on
120 // an A4 sheet in PS, + text description of symbols
121 switch( aFormat )
122 {
123 case PLOT_FORMAT::GERBER:
124 plotter = new GERBER_PLOTTER();
125 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
126 plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm
127 break;
128
129 default:
130 wxASSERT( false );
132
133 case PLOT_FORMAT::PDF:
134 case PLOT_FORMAT::POST:
135 case PLOT_FORMAT::SVG:
136 {
137 PAGE_INFO pageA4( wxT( "A4" ) );
138 VECTOR2I pageSizeIU = pageA4.GetSizeIU( pcbIUScale.IU_PER_MILS );
139
140 // Reserve a 10 mm margin around the page.
141 int margin = pcbIUScale.mmToIU( 10 );
142
143 // Calculate a scaling factor to print the board on the sheet
144 double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
145
146 // We should print the list of drill sizes, so reserve room for it
147 // 60% height for board 40% height for list
148 int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
149 double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
150
151 scale = std::min( Xscale, Yscale );
152
153 // Experience shows the scale should not to large, because texts
154 // create problem (can be to big or too small).
155 // So the scale is clipped at 3.0;
156 scale = std::min( scale, 3.0 );
157
158 offset.x = KiROUND( double( bbbox.Centre().x ) - ( pageSizeIU.x / 2.0 ) / scale );
159 offset.y = KiROUND( double( bbbox.Centre().y ) - ( ypagesize_for_board / 2.0 ) / scale );
160
161 // bottom_limit is used to plot the legend (drill diameters)
162 // texts are scaled differently for scale > 1.0 and <= 1.0
163 // so the limit is scaled differently.
164 bottom_limit = ( pageSizeIU.y - margin ) / std::min( scale, 1.0 );
165
166 if( aFormat == PLOT_FORMAT::SVG )
167 plotter = new SVG_PLOTTER;
168 else if( aFormat == PLOT_FORMAT::PDF )
169 plotter = new PDF_PLOTTER;
170 else
171 plotter = new PS_PLOTTER;
172
173 plotter->SetPageSettings( pageA4 );
174 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
175 break;
176 }
177
178 case PLOT_FORMAT::DXF:
179 {
180 DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
181
182 dxf_plotter->SetUnits( m_unitsMetric ? DXF_UNITS::MM : DXF_UNITS::INCH );
183
184 plotter = dxf_plotter;
185 plotter->SetPageSettings( page_info );
186 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
187 break;
188 }
189 }
190
191 plotter->SetCreator( wxT( "PCBNEW" ) );
192 plotter->SetColorMode( false );
193
194 KIGFX::PCB_RENDER_SETTINGS renderSettings;
195 renderSettings.SetDefaultPenWidth( getDefaultPenSize() );
196
197 plotter->SetRenderSettings( &renderSettings );
198
199 if( !plotter->OpenFile( aFullFileName ) )
200 {
201 delete plotter;
202 return false;
203 }
204
205 plotter->ClearHeaderLinesList();
206
207 // For the Gerber X2 format we need to set the "FileFunction" to Drillmap
208 // and set a few other options.
209 if( plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
210 {
211 GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
212 gbrplotter->DisableApertMacros( false );
213 gbrplotter->UseX2format( true ); // Mandatory
214 gbrplotter->UseX2NetAttributes( false ); // net attributes have no meaning here
215
216 // Attributes are added using X2 format
217 AddGerberX2Header( gbrplotter, m_pcb, false );
218
219 wxString text;
220
221 // Add the TF.FileFunction
222 text = "%TF.FileFunction,Drillmap*%";
223 gbrplotter->AddLineToHeader( text );
224
225 // Add the TF.FilePolarity
226 text = wxT( "%TF.FilePolarity,Positive*%" );
227 gbrplotter->AddLineToHeader( text );
228 }
229
230 plotter->StartPlot( wxT( "1" ) );
231
232 // Draw items on edge layer.
233 // Not all, only items useful for drill map, i.e. board outlines.
234 BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
235
236 // Use attributes of a drawing layer (we are not really draw the Edge.Cuts layer)
237 itemplotter.SetLayerSet( { Dwgs_User } );
238
239 for( BOARD_ITEM* item : m_pcb->Drawings() )
240 {
241 if( item->GetLayer() != Edge_Cuts )
242 continue;
243
244 switch( item->Type() )
245 {
246 case PCB_SHAPE_T:
247 {
248 PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
249 dummy_shape.SetLayer( Dwgs_User );
250 dummy_shape.SetParentGroup( nullptr ); // Remove group association, not needed for plotting
251 itemplotter.PlotShape( &dummy_shape );
252 }
253 break;
254
255 default:
256 break;
257 }
258 }
259
260 // Plot edge cuts in footprints
261 for( const FOOTPRINT* footprint : m_pcb->Footprints() )
262 {
263 for( BOARD_ITEM* item : footprint->GraphicalItems() )
264 {
265 if( item-> GetLayer() != Edge_Cuts )
266 continue;
267
268 switch( item->Type() )
269 {
270 case PCB_SHAPE_T:
271 {
272 PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
273 dummy_shape.SetLayer( Dwgs_User );
274 dummy_shape.SetParentGroup( nullptr ); // Remove group association, not needed for plotting
275 itemplotter.PlotShape( &dummy_shape );
276 }
277 break;
278
279 default:
280 break;
281 }
282 }
283 }
284
285 int plotX, plotY, TextWidth;
286 int intervalle = 0;
287 char line[1024];
288 wxString msg;
289 int textmarginaftersymbol = pcbIUScale.mmToIU( 2 );
290
291 // Set Drill Symbols width
292 plotter->SetCurrentLineWidth( -1 );
293
294 // Plot board outlines and drill map
295 plotDrillMarks( plotter );
296
297 // Print a list of symbols used.
298 int charSize = pcbIUScale.mmToIU( 2 ); // text size in IUs
299
300 // real char scale will be 1/scale, because the global plot scale is scale
301 // for scale < 1.0 ( plot bigger actual size)
302 // Therefore charScale = 1.0 / scale keep the initial charSize
303 // (for scale < 1 we use the global scaling factor: the board must be plotted
304 // smaller than the actual size)
305 double charScale = std::min( 1.0, 1.0 / scale );
306
307 TextWidth = KiROUND( ( charSize * charScale ) / 10.0 ); // Set text width (thickness)
308 intervalle = KiROUND( charSize * charScale ) + TextWidth;
309
310 // Trace information.
311 plotX = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
312 plotY = bbbox.GetBottom() + intervalle;
313
314 // Plot title "Info"
315 wxString Text = wxT( "Drill Map:" );
316
317 TEXT_ATTRIBUTES attrs;
318 attrs.m_StrokeWidth = TextWidth;
320 attrs.m_Size = VECTOR2I( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) );
323 attrs.m_Multiline = false;
324
325 plotter->PlotText( VECTOR2I( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, attrs,
326 nullptr /* stroke font */, KIFONT::METRICS::Default() );
327
328 // For some formats (PS, PDF SVG) we plot the drill size list on more than one column
329 // because the list must be contained inside the printed page
330 // (others formats do not have a defined page size)
331 int max_line_len = 0; // The max line len in iu of the currently plotted column
332
333 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
334 {
335 DRILL_TOOL& tool = m_toolListBuffer[ii];
336
337 if( tool.m_TotalCount == 0 )
338 continue;
339
340 plotY += intervalle;
341
342 // Ensure there are room to plot the line
343 if( bottom_limit && ( plotY+intervalle > bottom_limit ) )
344 {
345 plotY = bbbox.GetBottom() + intervalle;
346 plotX += max_line_len + pcbIUScale.mmToIU( 10 );//column_width;
347 max_line_len = 0;
348 }
349
350 int plot_diam = KiROUND( tool.m_Diameter );
351
352 // For markers plotted with the comment, keep marker size <= text height
353 plot_diam = std::min( plot_diam, KiROUND( charSize * charScale ) );
354 int x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
355 int y = KiROUND( plotY + charSize * charScale );
356
357 plotter->SetCurrentLineWidth( getMarkerBestPenSize( plot_diam ) );
358 plotter->Marker( VECTOR2I( x, y ), plot_diam, ii );
359 plotter->SetCurrentLineWidth( -1 );
360
361 // List the diameter of each drill in mm and inches.
362 snprintf( line, sizeof(line), "%3.3fmm / %2.4f\" ", diameter_in_mm( tool.m_Diameter ),
364
365 msg = From_UTF8( line );
366
367 // Now list how many holes and ovals are associated with each drill.
368 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
369 snprintf( line, sizeof(line), "(1 hole)" );
370 else if( tool.m_TotalCount == 1 ) // && ( toolm_OvalCount == 1 )
371 snprintf( line, sizeof(line), "(1 slot)" );
372 else if( tool.m_OvalCount == 0 )
373 snprintf( line, sizeof(line), "(%d holes)", tool.m_TotalCount );
374 else if( tool.m_OvalCount == 1 )
375 snprintf( line, sizeof(line), "(%d holes + 1 slot)", tool.m_TotalCount - 1 );
376 else // if ( toolm_OvalCount > 1 )
377 snprintf( line, sizeof(line), "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount,
378 tool.m_OvalCount );
379
380 msg += From_UTF8( line );
381
382 if( tool.m_Hole_NotPlated )
383 msg += wxT( " (not plated)" );
384
385 plotter->PlotText( VECTOR2I( plotX, y ), COLOR4D::UNSPECIFIED, msg, attrs,
386 nullptr /* stroke font */, KIFONT::METRICS::Default() );
387
388 intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );
389
390 if( intervalle < ( plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth ) )
391 intervalle = plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth;
392
393 // Evaluate the text horizontal size, to know the maximal column size
394 // This is a rough value, but ok to create a new column to plot next texts
395 int text_len = msg.Len() * ( ( charSize * charScale ) + TextWidth );
396 max_line_len = std::max( max_line_len, text_len + plot_diam );
397 }
398
399 plotter->EndPlot();
400 delete plotter;
401
402 return true;
403}
404
405
406bool GENDRILL_WRITER_BASE::GenDrillReportFile( const wxString& aFullFileName )
407{
408 FILE_OUTPUTFORMATTER out( aFullFileName );
409
410 static const char separator[] =
411 " =============================================================\n";
412
413 wxASSERT( m_pcb );
414
415 unsigned totalHoleCount;
416 wxFileName brdFilename( m_pcb->GetFileName() );
417
418 std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
419
420 out.Print( 0, "Drill report for %s\n", TO_UTF8( brdFilename.GetFullName() ) );
421 out.Print( 0, "Created on %s\n\n", TO_UTF8( GetISO8601CurrentDateTime() ) );
422
423 // Output the cu layer stackup, so layer name references make sense.
424 out.Print( 0, "Copper Layer Stackup:\n" );
425 out.Print( 0, separator );
426
428
429 int conventional_layer_num = 1;
430
431 for( PCB_LAYER_ID layer : cu.UIOrder() )
432 {
433 out.Print( 0, " L%-2d: %-25s %s\n",
434 conventional_layer_num++,
435 TO_UTF8( m_pcb->GetLayerName( layer ) ),
436 layerName( layer ).c_str() ); // generic layer name
437 }
438
439 out.Print( 0, "\n\n" );
440
441 /* output hole lists:
442 * 1 - through holes
443 * 2 - for partial holes only: by layer starting and ending pair
444 * 3 - Non Plated through holes
445 */
446
447 bool buildNPTHlist = false; // First pass: build PTH list only
448
449 // in this loop are plated only:
450 for( unsigned pair_ndx = 0; pair_ndx < hole_sets.size(); ++pair_ndx )
451 {
452 DRILL_LAYER_PAIR pair = hole_sets[pair_ndx];
453
454 buildHolesList( pair, buildNPTHlist );
455
456 if( pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
457 {
458 out.Print( 0, "Drill file '%s' contains\n",
459 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
460
461 out.Print( 0, " plated through holes:\n" );
462 out.Print( 0, separator );
463 totalHoleCount = printToolSummary( out, false );
464 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
465 }
466 else // blind/buried
467 {
468 out.Print( 0, "Drill file '%s' contains\n",
469 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
470
471 out.Print( 0, " holes connecting layer pair: '%s and %s' (%s vias):\n",
472 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.first ) ) ),
473 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.second ) ) ),
474 pair.first == F_Cu || pair.second == B_Cu ? "blind" : "buried" );
475
476 out.Print( 0, separator );
477 totalHoleCount = printToolSummary( out, false );
478 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
479 }
480
481 out.Print( 0, "\n\n" );
482 }
483
484 // NPTHoles. Generate the full list (pads+vias) if PTH and NPTH are merged,
485 // or only the NPTH list (which never has vias)
486 if( !m_merge_PTH_NPTH )
487 buildNPTHlist = true;
488
489 buildHolesList( DRILL_LAYER_PAIR( F_Cu, B_Cu ), buildNPTHlist );
490
491 // nothing wrong with an empty NPTH file in report.
492 if( m_merge_PTH_NPTH )
493 out.Print( 0, "Not plated through holes are merged with plated holes\n" );
494 else
495 out.Print( 0, "Drill file '%s' contains\n",
497 true, m_merge_PTH_NPTH ) ) );
498
499 out.Print( 0, " unplated through holes:\n" );
500 out.Print( 0, separator );
501 totalHoleCount = printToolSummary( out, true );
502 out.Print( 0, " Total unplated holes count %u\n", totalHoleCount );
503
504 return true;
505}
506
507
509{
510 // Plot the drill map:
511 VECTOR2I pos;
512
513 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
514 {
515 const HOLE_INFO& hole = m_holeListBuffer[ii];
516 pos = hole.m_Hole_Pos;
517
518 // Gives a good line thickness to have a good marker shape:
520
521 // Always plot the drill symbol (for slots identifies the needed cutter!
522 aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
523
524 if( hole.m_Hole_Shape != 0 )
525 {
527 // FlashPadOval uses also the render settings default pen size, so we need
528 // to initialize it:
529 KIGFX::RENDER_SETTINGS* renderSettings = aPlotter->RenderSettings();
530 int curr_default_pensize = renderSettings->GetDefaultPenWidth();
531 renderSettings->SetDefaultPenWidth( getSketchOvalBestPenSize() );
532 aPlotter->FlashPadOval( pos, hole.m_Hole_Size, hole.m_Hole_Orient, SKETCH, nullptr );
533 renderSettings->SetDefaultPenWidth( curr_default_pensize );
534 }
535 }
536
537 aPlotter->SetCurrentLineWidth( -1 );
538
539 return true;
540}
541
542
543unsigned GENDRILL_WRITER_BASE::printToolSummary( OUTPUTFORMATTER& out, bool aSummaryNPTH ) const
544{
545 unsigned totalHoleCount = 0;
546
547 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
548 {
549 const DRILL_TOOL& tool = m_toolListBuffer[ii];
550
551 if( aSummaryNPTH && !tool.m_Hole_NotPlated )
552 continue;
553
554 if( !aSummaryNPTH && tool.m_Hole_NotPlated )
555 continue;
556
557 // List the tool number assigned to each drill in mm then in inches.
558 int tool_number = ii+1;
559 out.Print( 0, " T%d %2.3fmm %2.4f\" ", tool_number,
562
563 // Now list how many holes and ovals are associated with each drill.
564 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
565 out.Print( 0, "(1 hole)\n" );
566 else if( tool.m_TotalCount == 1 )
567 out.Print( 0, "(1 hole) (with 1 slot)\n" );
568 else if( tool.m_OvalCount == 0 )
569 out.Print( 0, "(%d holes)\n", tool.m_TotalCount );
570 else if( tool.m_OvalCount == 1 )
571 out.Print( 0, "(%d holes) (with 1 slot)\n", tool.m_TotalCount );
572 else // tool.m_OvalCount > 1
573 out.Print( 0, "(%d holes) (with %d slots)\n", tool.m_TotalCount, tool.m_OvalCount );
574
575 totalHoleCount += tool.m_TotalCount;
576 }
577
578 out.Print( 0, "\n" );
579
580 return totalHoleCount;
581}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:78
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:861
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:955
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:843
const FOOTPRINTS & Footprints() const
Definition: board.h:338
const wxString & GetFileName() const
Definition: board.h:334
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:614
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:829
const DRAWINGS & Drawings() const
Definition: board.h:340
constexpr size_type GetWidth() const
Definition: box2.h:214
constexpr Vec Centre() const
Definition: box2.h:97
constexpr coord_type GetX() const
Definition: box2.h:207
constexpr size_type GetHeight() const
Definition: box2.h:215
constexpr coord_type GetBottom() const
Definition: box2.h:222
void SetLayerSet(const LSET &aLayerMask)
Definition: pcbplot.h:86
void PlotShape(const PCB_SHAPE *aShape)
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
virtual void SetParentGroup(EDA_GROUP *aGroup)
Definition: eda_item.h:113
Used for text file output.
Definition: richio.h:491
std::vector< DRILL_LAYER_PAIR > getUniqueLayerPairs() const
Get unique layer pairs by examining the micro and blind_buried vias.
virtual const wxString getDrillFileName(DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const
void buildHolesList(DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list)
Create the list of holes and tools for a given board.
unsigned printToolSummary(OUTPUTFORMATTER &aOut, bool aSummaryNPTH) const
Print m_toolListBuffer[] tools to aOut and returns total hole count.
std::vector< HOLE_INFO > m_holeListBuffer
bool genDrillMapFile(const wxString &aFullFileName, PLOT_FORMAT aFormat)
Plot a map of drill marks for holes.
VECTOR2I GetOffset()
Return the plot offset (usually the position of the drill/place origin).
std::vector< DRILL_TOOL > m_toolListBuffer
bool GenDrillReportFile(const wxString &aFullFileName)
Create a plain text report file giving a list of drill values and drill count for through holes,...
const std::string layerName(PCB_LAYER_ID aLayer) const
bool plotDrillMarks(PLOTTER *aPlotter)
Write the drill marks in HPGL, POSTSCRIPT or other supported formats/.
void UseX2format(bool aEnable)
void UseX2NetAttributes(bool aEnable)
void DisableApertMacros(bool aDisable)
Disable Aperture Macro (AM) command, only for broken Gerber Readers.
Handle hole which must be drilled (diameter, position and layers).
static const METRICS & Default()
Definition: font.cpp:52
PCB specific render settings.
Definition: pcb_painter.h:79
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
void SetDefaultPenWidth(int aWidth)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
Definition: lset.cpp:710
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:572
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
int PRINTF_FUNC_N Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:460
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
static const wxChar A4[]
Definition: page_info.h:68
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:171
Parameters and options when plotting/printing a board.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:179
Base plotter engine class.
Definition: plotter.h:105
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:75
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: plotter.h:138
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:135
virtual bool EndPlot()=0
virtual bool StartPlot(const wxString &aPageNumber)=0
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:136
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false)
Definition: plotter.h:525
virtual PLOT_FORMAT GetPlotterType() const =0
Return the effective plot engine in use.
void Marker(const VECTOR2I &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
Definition: plotter.cpp:363
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:157
void ClearHeaderLinesList()
Remove all lines from the list of free lines to print at the beginning of the file.
Definition: plotter.h:175
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror)=0
Set the plot offset and scaling for the current plot.
void AddLineToHeader(const wxString &aExtraString)
Add a line to the list of free lines to print at the beginning of the file.
Definition: plotter.h:167
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:132
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Definition: plotter.cpp:754
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
This file is part of the common library.
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
double diameter_in_mm(double ius)
double diameter_in_inches(double ius)
int getDefaultPenSize()
static int getMarkerBestPenSize(int aMarkerDiameter)
int getSketchOvalBestPenSize()
helper classes to handle hole info for drill files generators.
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > DRILL_LAYER_PAIR
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:112
@ Dwgs_User
Definition: layer_ids.h:107
@ B_Cu
Definition: layer_ids.h:65
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:721
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
@ SKETCH
Definition: outline_mode.h:26
void AddGerberX2Header(PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode)
Calculate some X2 attributes as defined in the Gerber file format specification J4 (chapter 5) and ad...
Definition: pcbplot.cpp:294
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:65
Plotting engines similar to ps (PostScript, Gerber, svg)
const int scale
std::vector< FAB_LAYER_COLOR > dummy
wxString From_UTF8(const char *cstring)
wxString GetISO8601CurrentDateTime()
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:403
const double IU_PER_MM
Definition: base_units.h:76
const double IU_PER_MILS
Definition: base_units.h:77
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_CENTER
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695