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 <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 if( m_unitsMetric )
183 dxf_plotter->SetUnits( DXF_UNITS::MILLIMETERS );
184 else
185 dxf_plotter->SetUnits( DXF_UNITS::INCHES );
186
187 plotter = dxf_plotter;
188 plotter->SetPageSettings( page_info );
189 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
190 break;
191 }
192 }
193
194 plotter->SetCreator( wxT( "PCBNEW" ) );
195 plotter->SetColorMode( false );
196
197 KIGFX::PCB_RENDER_SETTINGS renderSettings;
198 renderSettings.SetDefaultPenWidth( getDefaultPenSize() );
199
200 plotter->SetRenderSettings( &renderSettings );
201
202 if( !plotter->OpenFile( aFullFileName ) )
203 {
204 delete plotter;
205 return false;
206 }
207
208 plotter->ClearHeaderLinesList();
209
210 // For the Gerber X2 format we need to set the "FileFunction" to Drillmap
211 // and set a few other options.
212 if( plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
213 {
214 GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
215 gbrplotter->DisableApertMacros( false );
216 gbrplotter->UseX2format( true ); // Mandatory
217 gbrplotter->UseX2NetAttributes( false ); // net attributes have no meaning here
218
219 // Attributes are added using X2 format
220 AddGerberX2Header( gbrplotter, m_pcb, false );
221
222 wxString text;
223
224 // Add the TF.FileFunction
225 text = "%TF.FileFunction,Drillmap*%";
226 gbrplotter->AddLineToHeader( text );
227
228 // Add the TF.FilePolarity
229 text = wxT( "%TF.FilePolarity,Positive*%" );
230 gbrplotter->AddLineToHeader( text );
231 }
232
233 plotter->StartPlot( wxT( "1" ) );
234
235 // Draw items on edge layer.
236 // Not all, only items useful for drill map, i.e. board outlines.
237 BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
238
239 // Use attributes of a drawing layer (we are not really draw the Edge.Cuts layer)
240 itemplotter.SetLayerSet( { Dwgs_User } );
241
242 for( BOARD_ITEM* item : m_pcb->Drawings() )
243 {
244 if( item->GetLayer() != Edge_Cuts )
245 continue;
246
247 switch( item->Type() )
248 {
249 case PCB_SHAPE_T:
250 {
251 PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
252 dummy_shape.SetLayer( Dwgs_User );
253 dummy_shape.SetParentGroup( nullptr ); // Remove group association, not needed for plotting
254 itemplotter.PlotShape( &dummy_shape );
255 }
256 break;
257
258 default:
259 break;
260 }
261 }
262
263 // Plot edge cuts in footprints
264 for( const FOOTPRINT* footprint : m_pcb->Footprints() )
265 {
266 for( BOARD_ITEM* item : footprint->GraphicalItems() )
267 {
268 if( item-> GetLayer() != Edge_Cuts )
269 continue;
270
271 switch( item->Type() )
272 {
273 case PCB_SHAPE_T:
274 {
275 PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
276 dummy_shape.SetLayer( Dwgs_User );
277 dummy_shape.SetParentGroup( nullptr ); // Remove group association, not needed for plotting
278 itemplotter.PlotShape( &dummy_shape );
279 }
280 break;
281
282 default:
283 break;
284 }
285 }
286 }
287
288 int plotX, plotY, TextWidth;
289 int intervalle = 0;
290 char line[1024];
291 wxString msg;
292 int textmarginaftersymbol = pcbIUScale.mmToIU( 2 );
293
294 // Set Drill Symbols width
295 plotter->SetCurrentLineWidth( -1 );
296
297 // Plot board outlines and drill map
298 plotDrillMarks( plotter );
299
300 // Print a list of symbols used.
301 int charSize = pcbIUScale.mmToIU( 2 ); // text size in IUs
302
303 // real char scale will be 1/scale, because the global plot scale is scale
304 // for scale < 1.0 ( plot bigger actual size)
305 // Therefore charScale = 1.0 / scale keep the initial charSize
306 // (for scale < 1 we use the global scaling factor: the board must be plotted
307 // smaller than the actual size)
308 double charScale = std::min( 1.0, 1.0 / scale );
309
310 TextWidth = KiROUND( ( charSize * charScale ) / 10.0 ); // Set text width (thickness)
311 intervalle = KiROUND( charSize * charScale ) + TextWidth;
312
313 // Trace information.
314 plotX = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
315 plotY = bbbox.GetBottom() + intervalle;
316
317 // Plot title "Info"
318 wxString Text = wxT( "Drill Map:" );
319
320 TEXT_ATTRIBUTES attrs;
321 attrs.m_StrokeWidth = TextWidth;
323 attrs.m_Size = VECTOR2I( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) );
326 attrs.m_Multiline = false;
327
328 plotter->PlotText( VECTOR2I( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, attrs,
329 nullptr /* stroke font */, KIFONT::METRICS::Default() );
330
331 // For some formats (PS, PDF SVG) we plot the drill size list on more than one column
332 // because the list must be contained inside the printed page
333 // (others formats do not have a defined page size)
334 int max_line_len = 0; // The max line len in iu of the currently plotted column
335
336 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
337 {
338 DRILL_TOOL& tool = m_toolListBuffer[ii];
339
340 if( tool.m_TotalCount == 0 )
341 continue;
342
343 plotY += intervalle;
344
345 // Ensure there are room to plot the line
346 if( bottom_limit && ( plotY+intervalle > bottom_limit ) )
347 {
348 plotY = bbbox.GetBottom() + intervalle;
349 plotX += max_line_len + pcbIUScale.mmToIU( 10 );//column_width;
350 max_line_len = 0;
351 }
352
353 int plot_diam = KiROUND( tool.m_Diameter );
354
355 // For markers plotted with the comment, keep marker size <= text height
356 plot_diam = std::min( plot_diam, KiROUND( charSize * charScale ) );
357 int x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
358 int y = KiROUND( plotY + charSize * charScale );
359
360 plotter->SetCurrentLineWidth( getMarkerBestPenSize( plot_diam ) );
361 plotter->Marker( VECTOR2I( x, y ), plot_diam, ii );
362 plotter->SetCurrentLineWidth( -1 );
363
364 // List the diameter of each drill in mm and inches.
365 snprintf( line, sizeof(line), "%3.3fmm / %2.4f\" ", diameter_in_mm( tool.m_Diameter ),
367
368 msg = From_UTF8( line );
369
370 // Now list how many holes and ovals are associated with each drill.
371 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
372 snprintf( line, sizeof(line), "(1 hole)" );
373 else if( tool.m_TotalCount == 1 ) // && ( toolm_OvalCount == 1 )
374 snprintf( line, sizeof(line), "(1 slot)" );
375 else if( tool.m_OvalCount == 0 )
376 snprintf( line, sizeof(line), "(%d holes)", tool.m_TotalCount );
377 else if( tool.m_OvalCount == 1 )
378 snprintf( line, sizeof(line), "(%d holes + 1 slot)", tool.m_TotalCount - 1 );
379 else // if ( toolm_OvalCount > 1 )
380 snprintf( line, sizeof(line), "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount,
381 tool.m_OvalCount );
382
383 msg += From_UTF8( line );
384
385 if( tool.m_Hole_NotPlated )
386 msg += wxT( " (not plated)" );
387
388 plotter->PlotText( VECTOR2I( plotX, y ), COLOR4D::UNSPECIFIED, msg, attrs,
389 nullptr /* stroke font */, KIFONT::METRICS::Default() );
390
391 intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );
392
393 if( intervalle < ( plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth ) )
394 intervalle = plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth;
395
396 // Evaluate the text horizontal size, to know the maximal column size
397 // This is a rough value, but ok to create a new column to plot next texts
398 int text_len = msg.Len() * ( ( charSize * charScale ) + TextWidth );
399 max_line_len = std::max( max_line_len, text_len + plot_diam );
400 }
401
402 plotter->EndPlot();
403 delete plotter;
404
405 return true;
406}
407
408
409bool GENDRILL_WRITER_BASE::GenDrillReportFile( const wxString& aFullFileName )
410{
411 FILE_OUTPUTFORMATTER out( aFullFileName );
412
413 static const char separator[] =
414 " =============================================================\n";
415
416 wxASSERT( m_pcb );
417
418 unsigned totalHoleCount;
419 wxFileName brdFilename( m_pcb->GetFileName() );
420
421 std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
422
423 out.Print( 0, "Drill report for %s\n", TO_UTF8( brdFilename.GetFullName() ) );
424 out.Print( 0, "Created on %s\n\n", TO_UTF8( GetISO8601CurrentDateTime() ) );
425
426 // Output the cu layer stackup, so layer name references make sense.
427 out.Print( 0, "Copper Layer Stackup:\n" );
428 out.Print( 0, separator );
429
431
432 int conventional_layer_num = 1;
433
434 for( PCB_LAYER_ID layer : cu.Seq() )
435 {
436 out.Print( 0, " L%-2d: %-25s %s\n",
437 conventional_layer_num,
438 TO_UTF8( m_pcb->GetLayerName( layer ) ),
439 layerName( layer ).c_str() ); // generic layer name
440 }
441
442 out.Print( 0, "\n\n" );
443
444 /* output hole lists:
445 * 1 - through holes
446 * 2 - for partial holes only: by layer starting and ending pair
447 * 3 - Non Plated through holes
448 */
449
450 bool buildNPTHlist = false; // First pass: build PTH list only
451
452 // in this loop are plated only:
453 for( unsigned pair_ndx = 0; pair_ndx < hole_sets.size(); ++pair_ndx )
454 {
455 DRILL_LAYER_PAIR pair = hole_sets[pair_ndx];
456
457 buildHolesList( pair, buildNPTHlist );
458
459 if( pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
460 {
461 out.Print( 0, "Drill file '%s' contains\n",
462 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
463
464 out.Print( 0, " plated through holes:\n" );
465 out.Print( 0, separator );
466 totalHoleCount = printToolSummary( out, false );
467 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
468 }
469 else // blind/buried
470 {
471 out.Print( 0, "Drill file '%s' contains\n",
472 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
473
474 out.Print( 0, " holes connecting layer pair: '%s and %s' (%s vias):\n",
475 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.first ) ) ),
476 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.second ) ) ),
477 pair.first == F_Cu || pair.second == B_Cu ? "blind" : "buried" );
478
479 out.Print( 0, separator );
480 totalHoleCount = printToolSummary( out, false );
481 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
482 }
483
484 out.Print( 0, "\n\n" );
485 }
486
487 // NPTHoles. Generate the full list (pads+vias) if PTH and NPTH are merged,
488 // or only the NPTH list (which never has vias)
489 if( !m_merge_PTH_NPTH )
490 buildNPTHlist = true;
491
492 buildHolesList( DRILL_LAYER_PAIR( F_Cu, B_Cu ), buildNPTHlist );
493
494 // nothing wrong with an empty NPTH file in report.
495 if( m_merge_PTH_NPTH )
496 out.Print( 0, "Not plated through holes are merged with plated holes\n" );
497 else
498 out.Print( 0, "Drill file '%s' contains\n",
500 true, m_merge_PTH_NPTH ) ) );
501
502 out.Print( 0, " unplated through holes:\n" );
503 out.Print( 0, separator );
504 totalHoleCount = printToolSummary( out, true );
505 out.Print( 0, " Total unplated holes count %u\n", totalHoleCount );
506
507 return true;
508}
509
510
512{
513 // Plot the drill map:
514 VECTOR2I pos;
515
516 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
517 {
518 const HOLE_INFO& hole = m_holeListBuffer[ii];
519 pos = hole.m_Hole_Pos;
520
521 // Gives a good line thickness to have a good marker shape:
523
524 // Always plot the drill symbol (for slots identifies the needed cutter!
525 aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
526
527 if( hole.m_Hole_Shape != 0 )
528 {
530 // FlashPadOval uses also the render settings default pen size, so we need
531 // to initialize it:
532 KIGFX::RENDER_SETTINGS* renderSettings = aPlotter->RenderSettings();
533 int curr_default_pensize = renderSettings->GetDefaultPenWidth();
534 renderSettings->SetDefaultPenWidth( getSketchOvalBestPenSize() );
535 aPlotter->FlashPadOval( pos, hole.m_Hole_Size, hole.m_Hole_Orient, SKETCH, nullptr );
536 renderSettings->SetDefaultPenWidth( curr_default_pensize );
537 }
538 }
539
540 aPlotter->SetCurrentLineWidth( -1 );
541
542 return true;
543}
544
545
546unsigned GENDRILL_WRITER_BASE::printToolSummary( OUTPUTFORMATTER& out, bool aSummaryNPTH ) const
547{
548 unsigned totalHoleCount = 0;
549
550 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
551 {
552 const DRILL_TOOL& tool = m_toolListBuffer[ii];
553
554 if( aSummaryNPTH && !tool.m_Hole_NotPlated )
555 continue;
556
557 if( !aSummaryNPTH && tool.m_Hole_NotPlated )
558 continue;
559
560 // List the tool number assigned to each drill in mm then in inches.
561 int tool_number = ii+1;
562 out.Print( 0, " T%d %2.3fmm %2.4f\" ", tool_number,
565
566 // Now list how many holes and ovals are associated with each drill.
567 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
568 out.Print( 0, "(1 hole)\n" );
569 else if( tool.m_TotalCount == 1 )
570 out.Print( 0, "(1 hole) (with 1 slot)\n" );
571 else if( tool.m_OvalCount == 0 )
572 out.Print( 0, "(%d holes)\n", tool.m_TotalCount );
573 else if( tool.m_OvalCount == 1 )
574 out.Print( 0, "(%d holes) (with 1 slot)\n", tool.m_TotalCount );
575 else // tool.m_OvalCount > 1
576 out.Print( 0, "(%d holes) (with %d slots)\n", tool.m_TotalCount, tool.m_OvalCount );
577
578 totalHoleCount += tool.m_TotalCount;
579 }
580
581 out.Print( 0, "\n" );
582
583 return totalHoleCount;
584}
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:79
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:89
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:778
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:792
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:929
const FOOTPRINTS & Footprints() const
Definition: board.h:331
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:810
const wxString & GetFileName() const
Definition: board.h:327
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:574
const DRAWINGS & Drawings() const
Definition: board.h:333
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(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.
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: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
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:686
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:420
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: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:170
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: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: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:820
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:398
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:691