KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 (C) 1992-2023 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 <string_utils.h>
32#include <locale_io.h>
33#include <macros.h>
34#include <math/util.h> // for KiROUND
35
36#include <board.h>
37#include <footprint.h>
38
39#include <pcbplot.h>
41#include <pcb_painter.h>
42#include <pcb_shape.h>
43
44
45/* Conversion utilities - these will be used often in there... */
46inline double diameter_in_inches( double ius )
47{
48 return ius * 0.001 / pcbIUScale.IU_PER_MILS;
49}
50
51
52inline double diameter_in_mm( double ius )
53{
54 return ius / pcbIUScale.IU_PER_MM;
55}
56
57
58// return a pen size to plot markers and having a readable shape
59// clamped to be >= MIN_SIZE_MM to avoid too small line width
60static int getMarkerBestPenSize( int aMarkerDiameter )
61{
62 int bestsize = aMarkerDiameter / 10;
63
64 const double MIN_SIZE_MM = 0.1;
65 bestsize = std::max( bestsize, pcbIUScale.mmToIU( MIN_SIZE_MM ) );
66
67 return bestsize;
68}
69
70
71// return a pen size to plot outlines for oval holes
73{
74 const double SKETCH_LINE_WIDTH_MM = 0.1;
75 return pcbIUScale.mmToIU( SKETCH_LINE_WIDTH_MM );
76}
77
78
79// return a default pen size to plot items with no specific line thickness
81{
82 const double DEFAULT_LINE_WIDTH_MM = 0.2;
83 return pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH_MM );
84}
85
86
87bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_FORMAT aFormat )
88{
89 // Remark:
90 // Hole list must be created before calling this function, by buildHolesList(),
91 // for the right holes set (PTH, NPTH, buried/blind vias ...)
92
93 double scale = 1.0;
94 VECTOR2I offset = GetOffset();
95 PLOTTER* plotter = nullptr;
97 int bottom_limit = 0; // Y coord limit of page. 0 mean do not use
98
99 PCB_PLOT_PARAMS plot_opts; // starts plotting with default options
100
101 LOCALE_IO toggle; // use standard C notation for float numbers
102
103 const PAGE_INFO& page_info = m_pageInfo ? *m_pageInfo : dummy;
104
105 // Calculate dimensions and center of PCB. The Edge_Cuts layer must be visible
106 // to calculate the board edges bounding box
107 LSET visibleLayers = m_pcb->GetVisibleLayers();
108 m_pcb->SetVisibleLayers( visibleLayers | LSET( Edge_Cuts ) );
110 m_pcb->SetVisibleLayers( visibleLayers );
111
112 // Some formats cannot be used to generate a document like the map files
113 // Currently HPGL (old format not very used)
114
115 if( aFormat == PLOT_FORMAT::HPGL )
116 aFormat = PLOT_FORMAT::PDF;
117
118 // Calculate the scale for the format type, scale 1 in HPGL, drawing on
119 // an A4 sheet in PS, + text description of symbols
120 switch( aFormat )
121 {
122 case PLOT_FORMAT::GERBER:
123 plotter = new GERBER_PLOTTER();
124 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
125 plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm
126 break;
127
128 default:
129 wxASSERT( false );
131
132 case PLOT_FORMAT::PDF:
133 case PLOT_FORMAT::POST:
134 case PLOT_FORMAT::SVG:
135 {
136 PAGE_INFO pageA4( wxT( "A4" ) );
137 VECTOR2I pageSizeIU = pageA4.GetSizeIU( pcbIUScale.IU_PER_MILS );
138
139 // Reserve a 10 mm margin around the page.
140 int margin = pcbIUScale.mmToIU( 10 );
141
142 // Calculate a scaling factor to print the board on the sheet
143 double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
144
145 // We should print the list of drill sizes, so reserve room for it
146 // 60% height for board 40% height for list
147 int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
148 double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
149
150 scale = std::min( Xscale, Yscale );
151
152 // Experience shows the scale should not to large, because texts
153 // create problem (can be to big or too small).
154 // So the scale is clipped at 3.0;
155 scale = std::min( scale, 3.0 );
156
157 offset.x = KiROUND( double( bbbox.Centre().x ) - ( pageSizeIU.x / 2.0 ) / scale );
158 offset.y = KiROUND( double( bbbox.Centre().y ) - ( ypagesize_for_board / 2.0 ) / scale );
159
160 // bottom_limit is used to plot the legend (drill diameters)
161 // texts are scaled differently for scale > 1.0 and <= 1.0
162 // so the limit is scaled differently.
163 bottom_limit = ( pageSizeIU.y - margin ) / std::min( scale, 1.0 );
164
165 if( aFormat == PLOT_FORMAT::SVG )
166 plotter = new SVG_PLOTTER;
167 else if( aFormat == PLOT_FORMAT::PDF )
168 plotter = new PDF_PLOTTER;
169 else
170 plotter = new PS_PLOTTER;
171
172 plotter->SetPageSettings( pageA4 );
173 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
174 break;
175 }
176
177 case PLOT_FORMAT::DXF:
178 {
179 DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
180
181 if( m_unitsMetric )
182 dxf_plotter->SetUnits( DXF_UNITS::MILLIMETERS );
183 else
184 dxf_plotter->SetUnits( DXF_UNITS::INCHES );
185
186 plotter = dxf_plotter;
187 plotter->SetPageSettings( page_info );
188 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
189 break;
190 }
191 }
192
193 plotter->SetCreator( wxT( "PCBNEW" ) );
194 plotter->SetColorMode( false );
195
196 KIGFX::PCB_RENDER_SETTINGS renderSettings;
197 renderSettings.SetDefaultPenWidth( getDefaultPenSize() );
198
199 plotter->SetRenderSettings( &renderSettings );
200
201 if( !plotter->OpenFile( aFullFileName ) )
202 {
203 delete plotter;
204 return false;
205 }
206
207 plotter->ClearHeaderLinesList();
208
209 // For the Gerber X2 format we need to set the "FileFunction" to Drillmap
210 // and set a few other options.
211 if( plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
212 {
213 GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
214 gbrplotter->DisableApertMacros( false );
215 gbrplotter->UseX2format( true ); // Mandatory
216 gbrplotter->UseX2NetAttributes( false ); // net attributes have no meaning here
217
218 // Attributes are added using X2 format
219 AddGerberX2Header( gbrplotter, m_pcb, false );
220
221 wxString text;
222
223 // Add the TF.FileFunction
224 text = "%TF.FileFunction,Drillmap*%";
225 gbrplotter->AddLineToHeader( text );
226
227 // Add the TF.FilePolarity
228 text = wxT( "%TF.FilePolarity,Positive*%" );
229 gbrplotter->AddLineToHeader( text );
230 }
231
232 plotter->StartPlot( wxT( "1" ) );
233
234 // Draw items on edge layer.
235 // Not all, only items useful for drill map, i.e. board outlines.
236 BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
237
238 // Use attributes of a drawing layer (we are not really draw the Edge.Cuts layer)
239 itemplotter.SetLayerSet( Dwgs_User );
240
241 for( BOARD_ITEM* item : m_pcb->Drawings() )
242 {
243 if( item->GetLayer() != Edge_Cuts )
244 continue;
245
246 switch( item->Type() )
247 {
248 case PCB_SHAPE_T:
249 {
250 PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
251 dummy_shape.SetLayer( Dwgs_User );
252 dummy_shape.SetParentGroup( nullptr ); // Remove group association, not needed for plotting
253 itemplotter.PlotShape( &dummy_shape );
254 }
255 break;
256
257 default:
258 break;
259 }
260 }
261
262 // Plot edge cuts in footprints
263 for( const FOOTPRINT* footprint : m_pcb->Footprints() )
264 {
265 for( BOARD_ITEM* item : footprint->GraphicalItems() )
266 {
267 if( item-> GetLayer() != Edge_Cuts )
268 continue;
269
270 switch( item->Type() )
271 {
272 case PCB_SHAPE_T:
273 {
274 PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
275 dummy_shape.SetLayer( Dwgs_User );
276 dummy_shape.SetParentGroup( nullptr ); // Remove group association, not needed for plotting
277 itemplotter.PlotShape( &dummy_shape );
278 }
279 break;
280
281 default:
282 break;
283 }
284 }
285 }
286
287 int plotX, plotY, TextWidth;
288 int intervalle = 0;
289 char line[1024];
290 wxString msg;
291 int textmarginaftersymbol = pcbIUScale.mmToIU( 2 );
292
293 // Set Drill Symbols width
294 plotter->SetCurrentLineWidth( -1 );
295
296 // Plot board outlines and drill map
297 plotDrillMarks( plotter );
298
299 // Print a list of symbols used.
300 int charSize = pcbIUScale.mmToIU( 2 ); // text size in IUs
301
302 // real char scale will be 1/scale, because the global plot scale is scale
303 // for scale < 1.0 ( plot bigger actual size)
304 // Therefore charScale = 1.0 / scale keep the initial charSize
305 // (for scale < 1 we use the global scaling factor: the board must be plotted
306 // smaller than the actual size)
307 double charScale = std::min( 1.0, 1.0 / scale );
308
309 TextWidth = KiROUND( ( charSize * charScale ) / 10.0 ); // Set text width (thickness)
310 intervalle = KiROUND( charSize * charScale ) + TextWidth;
311
312 // Trace information.
313 plotX = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
314 plotY = bbbox.GetBottom() + intervalle;
315
316 // Plot title "Info"
317 wxString Text = wxT( "Drill Map:" );
318
319 TEXT_ATTRIBUTES attrs;
320 attrs.m_StrokeWidth = TextWidth;
322 attrs.m_Size = VECTOR2I( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) );
325 attrs.m_Multiline = false;
326
327 plotter->PlotText( VECTOR2I( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, attrs,
328 nullptr /* stroke font */, KIFONT::METRICS::Default() );
329
330 // For some formats (PS, PDF SVG) we plot the drill size list on more than one column
331 // because the list must be contained inside the printed page
332 // (others formats do not have a defined page size)
333 int max_line_len = 0; // The max line len in iu of the currently plotted column
334
335 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
336 {
337 DRILL_TOOL& tool = m_toolListBuffer[ii];
338
339 if( tool.m_TotalCount == 0 )
340 continue;
341
342 plotY += intervalle;
343
344 // Ensure there are room to plot the line
345 if( bottom_limit && ( plotY+intervalle > bottom_limit ) )
346 {
347 plotY = bbbox.GetBottom() + intervalle;
348 plotX += max_line_len + pcbIUScale.mmToIU( 10 );//column_width;
349 max_line_len = 0;
350 }
351
352 int plot_diam = KiROUND( tool.m_Diameter );
353
354 // For markers plotted with the comment, keep marker size <= text height
355 plot_diam = std::min( plot_diam, KiROUND( charSize * charScale ) );
356 int x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
357 int y = KiROUND( plotY + charSize * charScale );
358
359 plotter->SetCurrentLineWidth( getMarkerBestPenSize( plot_diam ) );
360 plotter->Marker( VECTOR2I( x, y ), plot_diam, ii );
361 plotter->SetCurrentLineWidth( -1 );
362
363 // List the diameter of each drill in mm and inches.
364 snprintf( line, sizeof(line), "%3.3fmm / %2.4f\" ", diameter_in_mm( tool.m_Diameter ),
366
367 msg = From_UTF8( line );
368
369 // Now list how many holes and ovals are associated with each drill.
370 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
371 snprintf( line, sizeof(line), "(1 hole)" );
372 else if( tool.m_TotalCount == 1 ) // && ( toolm_OvalCount == 1 )
373 snprintf( line, sizeof(line), "(1 slot)" );
374 else if( tool.m_OvalCount == 0 )
375 snprintf( line, sizeof(line), "(%d holes)", tool.m_TotalCount );
376 else if( tool.m_OvalCount == 1 )
377 snprintf( line, sizeof(line), "(%d holes + 1 slot)", tool.m_TotalCount - 1 );
378 else // if ( toolm_OvalCount > 1 )
379 snprintf( line, sizeof(line), "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount,
380 tool.m_OvalCount );
381
382 msg += From_UTF8( line );
383
384 if( tool.m_Hole_NotPlated )
385 msg += wxT( " (not plated)" );
386
387 plotter->PlotText( VECTOR2I( plotX, y ), COLOR4D::UNSPECIFIED, msg, attrs,
388 nullptr /* stroke font */, KIFONT::METRICS::Default() );
389
390 intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );
391
392 if( intervalle < ( plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth ) )
393 intervalle = plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth;
394
395 // Evaluate the text horizontal size, to know the maximal column size
396 // This is a rough value, but ok to create a new column to plot next texts
397 int text_len = msg.Len() * ( ( charSize * charScale ) + TextWidth );
398 max_line_len = std::max( max_line_len, text_len + plot_diam );
399 }
400
401 plotter->EndPlot();
402 delete plotter;
403
404 return true;
405}
406
407
408bool GENDRILL_WRITER_BASE::GenDrillReportFile( const wxString& aFullFileName )
409{
410 FILE_OUTPUTFORMATTER out( aFullFileName );
411
412 static const char separator[] =
413 " =============================================================\n";
414
415 wxASSERT( m_pcb );
416
417 unsigned totalHoleCount;
418 wxFileName brdFilename( m_pcb->GetFileName() );
419
420 std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
421
422 out.Print( 0, "Drill report for %s\n", TO_UTF8( brdFilename.GetFullName() ) );
423 out.Print( 0, "Created on %s\n\n", TO_UTF8( GetISO8601CurrentDateTime() ) );
424
425 // Output the cu layer stackup, so layer name references make sense.
426 out.Print( 0, "Copper Layer Stackup:\n" );
427 out.Print( 0, separator );
428
430
431 int conventional_layer_num = 1;
432
433 for( LSEQ seq = cu.Seq(); seq; ++seq, ++conventional_layer_num )
434 {
435 out.Print( 0, " L%-2d: %-25s %s\n",
436 conventional_layer_num,
437 TO_UTF8( m_pcb->GetLayerName( *seq ) ),
438 layerName( *seq ).c_str() ); // generic layer name
439 }
440
441 out.Print( 0, "\n\n" );
442
443 /* output hole lists:
444 * 1 - through holes
445 * 2 - for partial holes only: by layer starting and ending pair
446 * 3 - Non Plated through holes
447 */
448
449 bool buildNPTHlist = false; // First pass: build PTH list only
450
451 // in this loop are plated only:
452 for( unsigned pair_ndx = 0; pair_ndx < hole_sets.size(); ++pair_ndx )
453 {
454 DRILL_LAYER_PAIR pair = hole_sets[pair_ndx];
455
456 buildHolesList( pair, buildNPTHlist );
457
458 if( pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
459 {
460 out.Print( 0, "Drill file '%s' contains\n",
461 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
462
463 out.Print( 0, " plated through holes:\n" );
464 out.Print( 0, separator );
465 totalHoleCount = printToolSummary( out, false );
466 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
467 }
468 else // blind/buried
469 {
470 out.Print( 0, "Drill file '%s' contains\n",
471 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
472
473 out.Print( 0, " holes connecting layer pair: '%s and %s' (%s vias):\n",
474 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.first ) ) ),
475 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.second ) ) ),
476 pair.first == F_Cu || pair.second == B_Cu ? "blind" : "buried" );
477
478 out.Print( 0, separator );
479 totalHoleCount = printToolSummary( out, false );
480 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
481 }
482
483 out.Print( 0, "\n\n" );
484 }
485
486 // NPTHoles. Generate the full list (pads+vias) if PTH and NPTH are merged,
487 // or only the NPTH list (which never has vias)
488 if( !m_merge_PTH_NPTH )
489 buildNPTHlist = true;
490
491 buildHolesList( DRILL_LAYER_PAIR( F_Cu, B_Cu ), buildNPTHlist );
492
493 // nothing wrong with an empty NPTH file in report.
494 if( m_merge_PTH_NPTH )
495 out.Print( 0, "Not plated through holes are merged with plated holes\n" );
496 else
497 out.Print( 0, "Drill file '%s' contains\n",
499 true, m_merge_PTH_NPTH ) ) );
500
501 out.Print( 0, " unplated through holes:\n" );
502 out.Print( 0, separator );
503 totalHoleCount = printToolSummary( out, true );
504 out.Print( 0, " Total unplated holes count %u\n", totalHoleCount );
505
506 return true;
507}
508
509
511{
512 // Plot the drill map:
513 VECTOR2I pos;
514
515 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
516 {
517 const HOLE_INFO& hole = m_holeListBuffer[ii];
518 pos = hole.m_Hole_Pos;
519
520 // Gives a good line thickness to have a good marker shape:
522
523 // Always plot the drill symbol (for slots identifies the needed cutter!
524 aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
525
526 if( hole.m_Hole_Shape != 0 )
527 {
529 // FlashPadOval uses also the render settings default pen size, so we need
530 // to initialize it:
531 KIGFX::RENDER_SETTINGS* renderSettings = aPlotter->RenderSettings();
532 int curr_default_pensize = renderSettings->GetDefaultPenWidth();
533 renderSettings->SetDefaultPenWidth( getSketchOvalBestPenSize() );
534 aPlotter->FlashPadOval( pos, hole.m_Hole_Size, hole.m_Hole_Orient, SKETCH, nullptr );
535 renderSettings->SetDefaultPenWidth( curr_default_pensize );
536 }
537 }
538
539 aPlotter->SetCurrentLineWidth( -1 );
540
541 return true;
542}
543
544
545unsigned GENDRILL_WRITER_BASE::printToolSummary( OUTPUTFORMATTER& out, bool aSummaryNPTH ) const
546{
547 unsigned totalHoleCount = 0;
548
549 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
550 {
551 const DRILL_TOOL& tool = m_toolListBuffer[ii];
552
553 if( aSummaryNPTH && !tool.m_Hole_NotPlated )
554 continue;
555
556 if( !aSummaryNPTH && tool.m_Hole_NotPlated )
557 continue;
558
559 // List the tool number assigned to each drill in mm then in inches.
560 int tool_number = ii+1;
561 out.Print( 0, " T%d %2.3fmm %2.4f\" ", tool_number,
564
565 // Now list how many holes and ovals are associated with each drill.
566 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
567 out.Print( 0, "(1 hole)\n" );
568 else if( tool.m_TotalCount == 1 )
569 out.Print( 0, "(1 hole) (with 1 slot)\n" );
570 else if( tool.m_OvalCount == 0 )
571 out.Print( 0, "(%d holes)\n", tool.m_TotalCount );
572 else if( tool.m_OvalCount == 1 )
573 out.Print( 0, "(%d holes) (with 1 slot)\n", tool.m_TotalCount );
574 else // tool.m_OvalCount > 1
575 out.Print( 0, "(%d holes) (with %d slots)\n", tool.m_TotalCount, tool.m_OvalCount );
576
577 totalHoleCount += tool.m_TotalCount;
578 }
579
580 out.Print( 0, "\n" );
581
582 return totalHoleCount;
583}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:90
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:677
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:691
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:911
const FOOTPRINTS & Footprints() const
Definition: board.h:323
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:709
const wxString & GetFileName() const
Definition: board.h:319
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:564
const DRAWINGS & Drawings() const
Definition: board.h:325
size_type GetHeight() const
Definition: box2.h:205
size_type GetWidth() const
Definition: box2.h:204
coord_type GetX() const
Definition: box2.h:197
Vec Centre() const
Definition: box2.h:87
coord_type GetBottom() const
Definition: box2.h:212
void SetLayerSet(LSET aLayerMask)
Definition: pcbplot.h:85
void PlotShape(const PCB_SHAPE *aShape)
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
Used for text file output.
Definition: richio.h:475
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:78
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
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:521
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:575
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:418
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:458
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:315
Base plotter engine class.
Definition: plotter.h:105
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:74
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:519
virtual PLOT_FORMAT GetPlotterType() const =0
Returns 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:364
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:154
void ClearHeaderLinesList()
Remove all lines from the list of free lines to print at the beginning of the file.
Definition: plotter.h:172
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:164
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:753
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:431
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
@ Edge_Cuts
Definition: layer_ids.h:113
@ Dwgs_User
Definition: layer_ids.h:109
@ B_Cu
Definition: layer_ids.h:95
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:1022
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:276
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:391
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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:118
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602