KiCad PCB EDA Suite
GENDRILL_WRITER_BASE Class Reference

Create drill maps and drill reports and drill files. More...

#include <gendrill_file_writer_base.h>

Inheritance diagram for GENDRILL_WRITER_BASE:
EXCELLON_WRITER GERBER_WRITER

Public Types

enum  ZEROS_FMT { DECIMAL_FORMAT , SUPPRESS_LEADING , SUPPRESS_TRAILING , KEEP_ZEROS }
 
enum  TYPE_FILE { PTH_FILE , NPTH_FILE , MIXED_FILE }
 

Public Member Functions

virtual ~GENDRILL_WRITER_BASE ()
 
void SetMergeOption (bool aMerge)
 Set the option to make separate drill files for PTH and NPTH. More...
 
VECTOR2I GetOffset ()
 Return the plot offset (usually the position of the drill/place origin). More...
 
void SetPageInfo (const PAGE_INFO *aPageInfo)
 Set the page info used to plot drill maps. More...
 
void SetMapFileFormat (PLOT_FORMAT aMapFmt)
 Initialize the format for the drill map file. More...
 
void CreateMapFilesSet (const wxString &aPlotDirectory, REPORTER *aReporter=nullptr)
 Create the full set of map files for the board, in PS, PDF ... format (use SetMapFileFormat() to select the format). More...
 
bool GenDrillReportFile (const wxString &aFullFileName)
 Create a plain text report file giving a list of drill values and drill count for through holes, oblong holes, and for buried vias, drill values and drill count per layer pair there is only one report for all drill files even when buried or blinds vias exist. More...
 
wxString GetDrillFileExt () const
 Returns the file extension of the drill writer format. More...
 

Protected Member Functions

bool genDrillMapFile (const wxString &aFullFileName, PLOT_FORMAT aFormat)
 Plot a map of drill marks for holes. More...
 
void buildHolesList (DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list)
 Create the list of holes and tools for a given board. More...
 
int getHolesCount () const
 
bool plotDrillMarks (PLOTTER *aPlotter)
 Write the drill marks in HPGL, POSTSCRIPT or other supported formats/. More...
 
std::vector< DRILL_LAYER_PAIRgetUniqueLayerPairs () const
 Get unique layer pairs by examining the micro and blind_buried vias. More...
 
unsigned printToolSummary (OUTPUTFORMATTER &aOut, bool aSummaryNPTH) const
 Print m_toolListBuffer[] tools to aOut and returns total hole count. More...
 
const std::string layerPairName (DRILL_LAYER_PAIR aPair) const
 
const std::string layerName (PCB_LAYER_ID aLayer) const
 
virtual const wxString getDrillFileName (DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const
 
const wxString BuildFileFunctionAttributeString (DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHoleType, bool aCompatNCdrill=false) const
 
 GENDRILL_WRITER_BASE (BOARD *aPcb)
 

Protected Attributes

BOARDm_pcb
 
wxString m_drillFileExtension
 
bool m_unitsMetric
 
ZEROS_FMT m_zeroFormat
 
DRILL_PRECISION m_precision
 
double m_conversionUnits
 
VECTOR2I m_offset
 
bool m_merge_PTH_NPTH
 
std::vector< HOLE_INFOm_holeListBuffer
 
std::vector< DRILL_TOOLm_toolListBuffer
 
PLOT_FORMAT m_mapFileFmt
 
const PAGE_INFOm_pageInfo
 

Detailed Description

Create drill maps and drill reports and drill files.

Drill files are created by specialized derived classes, depending on the file format.

Definition at line 152 of file gendrill_file_writer_base.h.

Member Enumeration Documentation

◆ TYPE_FILE

Enumerator
PTH_FILE 
NPTH_FILE 
MIXED_FILE 

Definition at line 162 of file gendrill_file_writer_base.h.

162 { // type of holes in file: PTH, NPTH, mixed
163 PTH_FILE, // PTH only, this is the default also for blind/buried holes
164 NPTH_FILE, // NPTH only
165 MIXED_FILE // PHT+NPTH (mixed)
166 };

◆ ZEROS_FMT

Enumerator
DECIMAL_FORMAT 
SUPPRESS_LEADING 
SUPPRESS_TRAILING 
KEEP_ZEROS 

Definition at line 155 of file gendrill_file_writer_base.h.

155 { // Zero format in coordinates
156 DECIMAL_FORMAT, // Floating point coordinates
157 SUPPRESS_LEADING, // Suppress leading zeros
158 SUPPRESS_TRAILING, // Suppress trailing zeros
159 KEEP_ZEROS // keep zeros
160 };

Constructor & Destructor Documentation

◆ ~GENDRILL_WRITER_BASE()

virtual GENDRILL_WRITER_BASE::~GENDRILL_WRITER_BASE ( )
inlinevirtual

Definition at line 168 of file gendrill_file_writer_base.h.

169 {
170 }

◆ GENDRILL_WRITER_BASE()

Member Function Documentation

◆ BuildFileFunctionAttributeString()

const wxString GENDRILL_WRITER_BASE::BuildFileFunctionAttributeString ( DRILL_LAYER_PAIR  aLayerPair,
TYPE_FILE  aHoleType,
bool  aCompatNCdrill = false 
) const
protected
Parameters
aLayerPairis the layer pair (Drill from rom first layer to second layer)
aHoleTypeis type of drill file (PTH, NPTH, mixed)
aCompatNCdrillis true when generating NC (Excellon) compatible drill file
Returns
a wxString containing the .FileFunction attribute. the standard X2 FileFunction for drill files is TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH][Blind][Buried], Drill[Route][Mixed]*% There is no X1 version, as the Gerber drill files uses only X2 format There is a compatible NC drill version.

Definition at line 355 of file gendrill_file_writer_base.cpp.

358{
359// Build a wxString containing the .FileFunction attribute for drill files.
360// %TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH][Blind][Buried],Drill[Route][Mixed]*%
361 wxString text;
362
363 if( aCompatNCdrill )
364 text = wxT( "; #@! " );
365 else
366 text = wxT( "%" );
367
368 text << wxT( "TF.FileFunction," );
369
370 if( aHoleType == NPTH_FILE )
371 text << wxT( "NonPlated," );
372 else if( aHoleType == MIXED_FILE ) // only for Excellon format
373 text << wxT( "MixedPlating," );
374 else
375 text << wxT( "Plated," );
376
377 int layer1 = aLayerPair.first;
378 int layer2 = aLayerPair.second;
379 // In Gerber files, layers num are 1 to copper layer count instead of F_Cu to B_Cu
380 // (0 to copper layer count-1)
381 // Note also for a n copper layers board, gerber layers num are 1 ... n
382 layer1 += 1;
383
384 if( layer2 == B_Cu )
385 layer2 = m_pcb->GetCopperLayerCount();
386 else
387 layer2 += 1;
388
389 text << layer1 << wxT( "," ) << layer2;
390
391 // Now add PTH or NPTH or Blind or Buried attribute
392 int toplayer = 1;
393 int bottomlayer = m_pcb->GetCopperLayerCount();
394
395 if( aHoleType == NPTH_FILE )
396 text << wxT( ",NPTH" );
397 else if( aHoleType == MIXED_FILE ) // only for Excellon format
398 {
399 // write nothing
400 }
401 else if( layer1 == toplayer && layer2 == bottomlayer )
402 text << wxT( ",PTH" );
403 else if( layer1 == toplayer || layer2 == bottomlayer )
404 text << wxT( ",Blind" );
405 else
406 text << wxT( ",Buried" );
407
408 // In NC drill file, these previous parameters should be enough:
409 if( aCompatNCdrill )
410 return text;
411
412
413 // Now add Drill or Route or Mixed:
414 // file containing only round holes have Drill attribute
415 // file containing only oblong holes have Routed attribute
416 // file containing both holes have Mixed attribute
417 bool hasOblong = false;
418 bool hasDrill = false;
419
420 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
421 {
422 const HOLE_INFO& hole_descr = m_holeListBuffer[ii];
423
424 if( hole_descr.m_Hole_Shape ) // m_Hole_Shape not 0 is an oblong hole)
425 hasOblong = true;
426 else
427 hasDrill = true;
428 }
429
430 if( hasOblong && hasDrill )
431 text << wxT( ",Mixed" );
432 else if( hasDrill )
433 text << wxT( ",Drill" );
434 else if( hasOblong )
435 text << wxT( ",Route" );
436
437 // else: empty file.
438
439 // End of .FileFunction attribute:
440 text << wxT( "*%" );
441
442 return text;
443}
int GetCopperLayerCount() const
Definition: board.cpp:502
std::vector< HOLE_INFO > m_holeListBuffer
Handle hole which must be drilled (diameter, position and layers).
@ B_Cu
Definition: layer_ids.h:95

References B_Cu, BOARD::GetCopperLayerCount(), HOLE_INFO::m_Hole_Shape, m_holeListBuffer, m_pcb, MIXED_FILE, NPTH_FILE, and text.

Referenced by GERBER_WRITER::createDrillFile(), and EXCELLON_WRITER::writeEXCELLONHeader().

◆ buildHolesList()

void GENDRILL_WRITER_BASE::buildHolesList ( DRILL_LAYER_PAIR  aLayerPair,
bool  aGenerateNPTH_list 
)
protected

Create the list of holes and tools for a given board.

The list is sorted by increasing drill size. Only holes included within aLayerPair are listed. If aLayerPair identifies with [F_Cu, B_Cu], then pad holes are always included also.

Parameters
aLayerPairis an inclusive range of layers.
aGenerateNPTH_list: true to create NPTH only list (with no plated holes) false to created plated holes list (with no NPTH )

Definition at line 66 of file gendrill_file_writer_base.cpp.

68{
69 HOLE_INFO new_hole;
70
71 m_holeListBuffer.clear();
72 m_toolListBuffer.clear();
73
74 wxASSERT( aLayerPair.first < aLayerPair.second ); // fix the caller
75
76 // build hole list for vias
77 if( ! aGenerateNPTH_list ) // vias are always plated !
78 {
79 for( auto track : m_pcb->Tracks() )
80 {
81 if( track->Type() != PCB_VIA_T )
82 continue;
83
84 PCB_VIA* via = static_cast<PCB_VIA*>( track );
85 int hole_sz = via->GetDrillValue();
86
87 if( hole_sz == 0 ) // Should not occur.
88 continue;
89
90 new_hole.m_ItemParent = via;
91
92 if( aLayerPair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
94 else
96
97 new_hole.m_Tool_Reference = -1; // Flag value for Not initialized
98 new_hole.m_Hole_Orient = ANGLE_0;
99 new_hole.m_Hole_Diameter = hole_sz;
100 new_hole.m_Hole_NotPlated = false;
101 new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
102
103 new_hole.m_Hole_Shape = 0; // hole shape: round
104 new_hole.m_Hole_Pos = via->GetStart();
105
106 via->LayerPair( &new_hole.m_Hole_Top_Layer, &new_hole.m_Hole_Bottom_Layer );
107
108 // LayerPair() returns params with m_Hole_Bottom_Layer > m_Hole_Top_Layer
109 // Remember: top layer = 0 and bottom layer = 31 for through hole vias
110 // Any captured via should be from aLayerPair.first to aLayerPair.second exactly.
111 if( new_hole.m_Hole_Top_Layer != aLayerPair.first ||
112 new_hole.m_Hole_Bottom_Layer != aLayerPair.second )
113 continue;
114
115 m_holeListBuffer.push_back( new_hole );
116 }
117 }
118
119 if( aLayerPair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
120 {
121 // add holes for thru hole pads
122 for( FOOTPRINT* footprint : m_pcb->Footprints() )
123 {
124 for( PAD* pad : footprint->Pads() )
125 {
126 if( !m_merge_PTH_NPTH )
127 {
128 if( !aGenerateNPTH_list && pad->GetAttribute() == PAD_ATTRIB::NPTH )
129 continue;
130
131 if( aGenerateNPTH_list && pad->GetAttribute() != PAD_ATTRIB::NPTH )
132 continue;
133 }
134
135 if( pad->GetDrillSize().x == 0 )
136 continue;
137
138 new_hole.m_ItemParent = pad;
139 new_hole.m_Hole_NotPlated = (pad->GetAttribute() == PAD_ATTRIB::NPTH);
140 new_hole.m_HoleAttribute = new_hole.m_Hole_NotPlated
143 new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
144 new_hole.m_Hole_Orient = pad->GetOrientation();
145 new_hole.m_Hole_Shape = 0; // hole shape: round
146 new_hole.m_Hole_Diameter = std::min( pad->GetDrillSize().x, pad->GetDrillSize().y );
147 new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
148
149 if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
150 new_hole.m_Hole_Shape = 1; // oval flag set
151
152 new_hole.m_Hole_Size = pad->GetDrillSize();
153 new_hole.m_Hole_Pos = pad->GetPosition(); // hole position
154 new_hole.m_Hole_Bottom_Layer = B_Cu;
155 new_hole.m_Hole_Top_Layer = F_Cu; // pad holes are through holes
156 m_holeListBuffer.push_back( new_hole );
157 }
158 }
159 }
160
161 // Sort holes per increasing diameter value (and for each dimater, by position)
162 sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), cmpHoleSorting );
163
164 // build the tool list
165 int last_hole = -1; // Set to not initialized (this is a value not used
166 // for m_holeListBuffer[ii].m_Hole_Diameter)
167 bool last_notplated_opt = false;
169
170 DRILL_TOOL new_tool( 0, false );
171 unsigned jj;
172
173 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
174 {
175 if( m_holeListBuffer[ii].m_Hole_Diameter != last_hole
176 || m_holeListBuffer[ii].m_Hole_NotPlated != last_notplated_opt
178 || m_holeListBuffer[ii].m_HoleAttribute != last_attribute
179#endif
180 )
181 {
182 new_tool.m_Diameter = m_holeListBuffer[ii].m_Hole_Diameter;
183 new_tool.m_Hole_NotPlated = m_holeListBuffer[ii].m_Hole_NotPlated;
184 new_tool.m_HoleAttribute = m_holeListBuffer[ii].m_HoleAttribute;
185 m_toolListBuffer.push_back( new_tool );
186 last_hole = new_tool.m_Diameter;
187 last_notplated_opt = new_tool.m_Hole_NotPlated;
188 last_attribute = new_tool.m_HoleAttribute;
189 }
190
191 jj = m_toolListBuffer.size();
192
193 if( jj == 0 )
194 continue; // Should not occurs
195
196 m_holeListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1)
197
198 m_toolListBuffer.back().m_TotalCount++;
199
200 if( m_holeListBuffer[ii].m_Hole_Shape )
201 m_toolListBuffer.back().m_OvalCount++;
202 }
203}
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
std::vector< DRILL_TOOL > m_toolListBuffer
PCB_LAYER_ID m_Hole_Bottom_Layer
PCB_LAYER_ID m_Hole_Top_Layer
HOLE_ATTRIBUTE m_HoleAttribute
BOARD_ITEM * m_ItemParent
Definition: pad.h:59
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
static bool cmpHoleSorting(const HOLE_INFO &a, const HOLE_INFO &b)
#define USE_ATTRIB_FOR_HOLES
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > DRILL_LAYER_PAIR
@ F_Cu
Definition: layer_ids.h:64
@ NPTH
like PAD_PTH, but not plated
@ PAD_DRILL_SHAPE_CIRCLE
Definition: pad_shapes.h:70
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102

References ANGLE_0, B_Cu, cmpHoleSorting(), F_Cu, BOARD::Footprints(), HOLE_MECHANICAL, HOLE_PAD, HOLE_UNKNOWN, HOLE_VIA_BURIED, HOLE_VIA_THROUGH, DRILL_TOOL::m_Diameter, HOLE_INFO::m_Hole_Bottom_Layer, HOLE_INFO::m_Hole_Diameter, DRILL_TOOL::m_Hole_NotPlated, HOLE_INFO::m_Hole_NotPlated, HOLE_INFO::m_Hole_Orient, HOLE_INFO::m_Hole_Pos, HOLE_INFO::m_Hole_Shape, HOLE_INFO::m_Hole_Size, HOLE_INFO::m_Hole_Top_Layer, DRILL_TOOL::m_HoleAttribute, HOLE_INFO::m_HoleAttribute, m_holeListBuffer, HOLE_INFO::m_ItemParent, m_merge_PTH_NPTH, m_pcb, HOLE_INFO::m_Tool_Reference, m_toolListBuffer, NPTH, pad, PAD_DRILL_SHAPE_CIRCLE, PCB_VIA_T, BOARD::Tracks(), USE_ATTRIB_FOR_HOLES, via, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EXCELLON_WRITER::CreateDrillandMapFilesSet(), GERBER_WRITER::CreateDrillandMapFilesSet(), CreateMapFilesSet(), and GenDrillReportFile().

◆ CreateMapFilesSet()

void GENDRILL_WRITER_BASE::CreateMapFilesSet ( const wxString &  aPlotDirectory,
REPORTER aReporter = nullptr 
)

Create the full set of map files for the board, in PS, PDF ... format (use SetMapFileFormat() to select the format).

File names are computed from the board name and layer ID.

Parameters
aPlotDirectoryis the output folder.
aReporteris a REPORTER to return activity or any message (can be NULL)

Definition at line 296 of file gendrill_file_writer_base.cpp.

298{
299 wxFileName fn;
300 wxString msg;
301
302 std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
303
304 // append a pair representing the NPTH set of holes, for separate drill files.
305 if( !m_merge_PTH_NPTH )
306 hole_sets.emplace_back( F_Cu, B_Cu );
307
308 for( std::vector<DRILL_LAYER_PAIR>::const_iterator it = hole_sets.begin();
309 it != hole_sets.end(); ++it )
310 {
311 DRILL_LAYER_PAIR pair = *it;
312 // For separate drill files, the last layer pair is the NPTH drill file.
313 bool doing_npth = m_merge_PTH_NPTH ? false : ( it == hole_sets.end() - 1 );
314
315 buildHolesList( pair, doing_npth );
316
317 // The file is created if it has holes, or if it is the non plated drill file
318 // to be sure the NPTH file is up to date in separate files mode.
319 // Also a PTH drill file is always created, to be sure at least one plated hole drill file
320 // is created (do not create any PTH drill file can be seen as not working drill generator).
321 if( getHolesCount() > 0 || doing_npth || pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
322 {
323 fn = getDrillFileName( pair, doing_npth, m_merge_PTH_NPTH );
324 fn.SetPath( aPlotDirectory );
325
326 fn.SetExt( wxEmptyString ); // Will be added by GenDrillMap
327 wxString fullfilename = fn.GetFullPath() + wxT( "-drl_map" );
328 fullfilename << wxT(".") << GetDefaultPlotExtension( m_mapFileFmt );
329
330 bool success = genDrillMapFile( fullfilename, m_mapFileFmt );
331
332 if( ! success )
333 {
334 if( aReporter )
335 {
336 msg.Printf( _( "Failed to create file '%s'." ), fullfilename );
337 aReporter->Report( msg, RPT_SEVERITY_ERROR );
338 }
339
340 return;
341 }
342 else
343 {
344 if( aReporter )
345 {
346 msg.Printf( _( "Created file '%s'." ), fullfilename );
347 aReporter->Report( msg, RPT_SEVERITY_ACTION );
348 }
349 }
350 }
351 }
352}
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.
bool genDrillMapFile(const wxString &aFullFileName, PLOT_FORMAT aFormat)
Plot a map of drill marks for holes.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Returns the default plot extension for a format.
#define _(s)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_ACTION

References _, B_Cu, buildHolesList(), F_Cu, genDrillMapFile(), GetDefaultPlotExtension(), getDrillFileName(), getHolesCount(), getUniqueLayerPairs(), m_mapFileFmt, m_merge_PTH_NPTH, REPORTER::Report(), RPT_SEVERITY_ACTION, and RPT_SEVERITY_ERROR.

Referenced by EXCELLON_WRITER::CreateDrillandMapFilesSet(), and GERBER_WRITER::CreateDrillandMapFilesSet().

◆ genDrillMapFile()

bool GENDRILL_WRITER_BASE::genDrillMapFile ( const wxString &  aFullFileName,
PLOT_FORMAT  aFormat 
)
protected

Plot a map of drill marks for holes.

Hole list must be created before calling this function, by buildHolesList() for the right holes set (PTH, NPTH, buried/blind vias ...) the paper sheet to use to plot the map is set in m_pageInfo ( calls SetPageInfo() to set it ). If NULL, A4 format will be used.

Parameters
aFullFileNameis the full filename of the map file to create.
aFormatis one of the supported plot formats (see enum PlotFormat ).

Definition at line 64 of file gen_drill_report_files.cpp.

65{
66 // Remark:
67 // Hole list must be created before calling this function, by buildHolesList(),
68 // for the right holes set (PTH, NPTH, buried/blind vias ...)
69
70 double scale = 1.0;
71 VECTOR2I offset = GetOffset();
72 PLOTTER* plotter = nullptr;
74 int bottom_limit = 0; // Y coord limit of page. 0 mean do not use
75
76 PCB_PLOT_PARAMS plot_opts; // starts plotting with default options
77
78 LOCALE_IO toggle; // use standard C notation for float numbers
79
80 const PAGE_INFO& page_info = m_pageInfo ? *m_pageInfo : dummy;
81
82 // Calculate dimensions and center of PCB. The Edge_Cuts layer must be visible
83 // to calculate the board edges bounding box
84 LSET visibleLayers = m_pcb->GetVisibleLayers();
85 m_pcb->SetVisibleLayers( visibleLayers | LSET( Edge_Cuts ) );
87 m_pcb->SetVisibleLayers( visibleLayers );
88
89 // Some formats cannot be used to generate a document like the map files
90 // Currently HPGL (old format not very used)
91
92 if( aFormat == PLOT_FORMAT::HPGL )
93 aFormat = PLOT_FORMAT::PDF;
94
95 // Calculate the scale for the format type, scale 1 in HPGL, drawing on
96 // an A4 sheet in PS, + text description of symbols
97 switch( aFormat )
98 {
100 plotter = new GERBER_PLOTTER();
101 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
102 plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm
103 break;
104
105 default:
106 wxASSERT( false );
108
109 case PLOT_FORMAT::PDF:
111 case PLOT_FORMAT::SVG:
112 {
113 PAGE_INFO pageA4( wxT( "A4" ) );
114 wxSize pageSizeIU = pageA4.GetSizeIU( pcbIUScale.IU_PER_MILS );
115
116 // Reserve a 10 mm margin around the page.
117 int margin = pcbIUScale.mmToIU( 10 );
118
119 // Calculate a scaling factor to print the board on the sheet
120 double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
121
122 // We should print the list of drill sizes, so reserve room for it
123 // 60% height for board 40% height for list
124 int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
125 double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
126
127 scale = std::min( Xscale, Yscale );
128
129 // Experience shows the scale should not to large, because texts
130 // create problem (can be to big or too small).
131 // So the scale is clipped at 3.0;
132 scale = std::min( scale, 3.0 );
133
134 offset.x = KiROUND( double( bbbox.Centre().x ) - ( pageSizeIU.x / 2.0 ) / scale );
135 offset.y = KiROUND( double( bbbox.Centre().y ) - ( ypagesize_for_board / 2.0 ) / scale );
136
137 // bottom_limit is used to plot the legend (drill diameters)
138 // texts are scaled differently for scale > 1.0 and <= 1.0
139 // so the limit is scaled differently.
140 bottom_limit = ( pageSizeIU.y - margin ) / std::min( scale, 1.0 );
141
142 if( aFormat == PLOT_FORMAT::SVG )
143 plotter = new SVG_PLOTTER;
144 else if( aFormat == PLOT_FORMAT::PDF )
145 plotter = new PDF_PLOTTER;
146 else
147 plotter = new PS_PLOTTER;
148
149 plotter->SetPageSettings( pageA4 );
150 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
151 break;
152 }
153
154 case PLOT_FORMAT::DXF:
155 {
156 DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
157
158 if( m_unitsMetric )
159 dxf_plotter->SetUnits( DXF_UNITS::MILLIMETERS );
160 else
161 dxf_plotter->SetUnits( DXF_UNITS::INCHES );
162
163 plotter = dxf_plotter;
164 plotter->SetPageSettings( page_info );
165 plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false );
166 break;
167 }
168 }
169
170 plotter->SetCreator( wxT( "PCBNEW" ) );
171 plotter->SetColorMode( false );
172
173 KIGFX::PCB_RENDER_SETTINGS renderSettings;
174 renderSettings.SetDefaultPenWidth( pcbIUScale.mmToIU( 0.2 ) );
175
176 plotter->SetRenderSettings( &renderSettings );
177
178 if( !plotter->OpenFile( aFullFileName ) )
179 {
180 delete plotter;
181 return false;
182 }
183
184 plotter->ClearHeaderLinesList();
185
186 // For the Gerber X2 format we need to set the "FileFunction" to Drillmap
187 // and set a few other options.
188 if( plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
189 {
190 GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
191 gbrplotter->DisableApertMacros( false );
192 gbrplotter->UseX2format( true ); // Mandatory
193 gbrplotter->UseX2NetAttributes( false ); // net attributes have no meaning here
194
195 // Attributes are added using X2 format
196 AddGerberX2Header( gbrplotter, m_pcb, false );
197
198 wxString text;
199
200 // Add the TF.FileFunction
201 text = "%TF.FileFunction,Drillmap*%";
202 gbrplotter->AddLineToHeader( text );
203
204 // Add the TF.FilePolarity
205 text = wxT( "%TF.FilePolarity,Positive*%" );
206 gbrplotter->AddLineToHeader( text );
207 }
208
209 plotter->StartPlot( wxT( "1" ) );
210
211 // Draw items on edge layer.
212 // Not all, only items useful for drill map, i.e. board outlines.
213 BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
214
215 // Use attributes of a drawing layer (we are not really draw the Edge.Cuts layer)
216 itemplotter.SetLayerSet( Dwgs_User );
217
218 for( BOARD_ITEM* item : m_pcb->Drawings() )
219 {
220 if( item->GetLayer() != Edge_Cuts )
221 continue;
222
223 switch( item->Type() )
224 {
225 case PCB_SHAPE_T:
226 {
227 PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
228 dummy_shape.SetLayer( Dwgs_User );
229 itemplotter.PlotPcbShape( &dummy_shape );
230 }
231 break;
232
233 default:
234 break;
235 }
236 }
237
238 int plotX, plotY, TextWidth;
239 int intervalle = 0;
240 char line[1024];
241 wxString msg;
242 int textmarginaftersymbol = pcbIUScale.mmToIU( 2 );
243
244 // Set Drill Symbols width
245 plotter->SetCurrentLineWidth( -1 );
246
247 // Plot board outlines and drill map
248 plotDrillMarks( plotter );
249
250 // Print a list of symbols used.
251 int charSize = pcbIUScale.mmToIU( 2 ); // text size in IUs
252
253 // real char scale will be 1/scale, because the global plot scale is scale
254 // for scale < 1.0 ( plot bigger actual size)
255 // Therefore charScale = 1.0 / scale keep the initial charSize
256 // (for scale < 1 we use the global scaling factor: the board must be plotted
257 // smaller than the actual size)
258 double charScale = std::min( 1.0, 1.0 / scale );
259
260 TextWidth = KiROUND( ( charSize * charScale ) / 10.0 ); // Set text width (thickness)
261 intervalle = KiROUND( charSize * charScale ) + TextWidth;
262
263 // Trace information.
264 plotX = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
265 plotY = bbbox.GetBottom() + intervalle;
266
267 // Plot title "Info"
268 wxString Text = wxT( "Drill Map:" );
269 plotter->Text( VECTOR2I( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, ANGLE_HORIZONTAL,
270 wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
271 GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false,
272 false, nullptr /* stroke font */ );
273
274 // For some formats (PS, PDF SVG) we plot the drill size list on more than one column
275 // because the list must be contained inside the printed page
276 // (others formats do not have a defined page size)
277 int max_line_len = 0; // The max line len in iu of the currently plotted column
278
279 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
280 {
281 DRILL_TOOL& tool = m_toolListBuffer[ii];
282
283 if( tool.m_TotalCount == 0 )
284 continue;
285
286 plotY += intervalle;
287
288 // Ensure there are room to plot the line
289 if( bottom_limit && ( plotY+intervalle > bottom_limit ) )
290 {
291 plotY = bbbox.GetBottom() + intervalle;
292 plotX += max_line_len + pcbIUScale.mmToIU( 10 );//column_width;
293 max_line_len = 0;
294 }
295
296 int plot_diam = KiROUND( tool.m_Diameter );
297
298 // For markers plotted with the comment, keep marker size <= text height
299 plot_diam = std::min( plot_diam, KiROUND( charSize * charScale ) );
300 int x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
301 int y = KiROUND( plotY + charSize * charScale );
302
303 plotter->SetCurrentLineWidth( getMarkerBestPenSize( plot_diam ) );
304 plotter->Marker( VECTOR2I( x, y ), plot_diam, ii );
305 plotter->SetCurrentLineWidth( -1 );
306
307 // List the diameter of each drill in mm and inches.
308 sprintf( line, "%3.3fmm / %2.4f\" ", diameter_in_mm( tool.m_Diameter ),
310
311 msg = FROM_UTF8( line );
312
313 // Now list how many holes and ovals are associated with each drill.
314 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
315 sprintf( line, "(1 hole)" );
316 else if( tool.m_TotalCount == 1 ) // && ( toolm_OvalCount == 1 )
317 sprintf( line, "(1 slot)" );
318 else if( tool.m_OvalCount == 0 )
319 sprintf( line, "(%d holes)", tool.m_TotalCount );
320 else if( tool.m_OvalCount == 1 )
321 sprintf( line, "(%d holes + 1 slot)", tool.m_TotalCount - 1 );
322 else // if ( toolm_OvalCount > 1 )
323 sprintf( line, "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount,
324 tool.m_OvalCount );
325
326 msg += FROM_UTF8( line );
327
328 if( tool.m_Hole_NotPlated )
329 msg += wxT( " (not plated)" );
330
331 plotter->Text( VECTOR2I( plotX, y ), COLOR4D::UNSPECIFIED, msg, ANGLE_HORIZONTAL,
332 VECTOR2I( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
333 GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false,
334 false, nullptr /* stroke font */ );
335
336 intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );
337
338 if( intervalle < ( plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth ) )
339 intervalle = plot_diam + ( 1 * pcbIUScale.IU_PER_MM / scale ) + TextWidth;
340
341 // Evaluate the text horizontal size, to know the maximal column size
342 // This is a rough value, but ok to create a new column to plot next texts
343 int text_len = msg.Len() * ( ( charSize * charScale ) + TextWidth );
344 max_line_len = std::max( max_line_len, text_len + plot_diam );
345 }
346
347 plotter->EndPlot();
348 delete plotter;
349
350 return true;
351}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:540
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:823
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:558
DRAWINGS & Drawings()
Definition: board.h:310
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
coord_type GetX() const
Definition: box2.h:180
Vec Centre() const
Definition: box2.h:70
coord_type GetBottom() const
Definition: box2.h:190
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
VECTOR2I GetOffset()
Return the plot offset (usually the position of the drill/place origin).
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.
PCB specific render settings.
Definition: pcb_painter.h:72
void SetDefaultPenWidth(int aWidth)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
static const wxChar A4[]
Definition: page_info.h:63
Parameters and options when plotting/printing a board.
Base plotter engine class.
Definition: plotter.h:110
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:143
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:140
virtual bool EndPlot()=0
virtual bool StartPlot(const wxString &aPageNumber)=0
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false)
Definition: plotter.h:500
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
Definition: plotter.cpp:714
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:359
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:159
void ClearHeaderLinesList()
Remove all lines from the list of free lines to print at the beginning of the file.
Definition: plotter.h:176
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:168
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:137
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
double diameter_in_mm(double ius)
double diameter_in_inches(double ius)
int getMarkerBestPenSize(int aMarkerDiameter)
@ Edge_Cuts
Definition: layer_ids.h:113
@ Dwgs_User
Definition: layer_ids.h:109
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
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
const int scale
std::vector< FAB_LAYER_COLOR > dummy
const double IU_PER_MM
Definition: base_units.h:77
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
@ 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:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References PAGE_INFO::A4, AddGerberX2Header(), PLOTTER::AddLineToHeader(), ANGLE_HORIZONTAL, BOX2< Vec >::Centre(), PLOTTER::ClearHeaderLinesList(), diameter_in_inches(), diameter_in_mm(), GERBER_PLOTTER::DisableApertMacros(), BOARD::Drawings(), dummy, Dwgs_User, DXF, Edge_Cuts, PLOTTER::EndPlot(), FROM_UTF8(), GERBER, BOARD::GetBoardEdgesBoundingBox(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetHeight(), getMarkerBestPenSize(), GetOffset(), PLOTTER::GetPlotterType(), PAGE_INFO::GetSizeIU(), BOARD::GetVisibleLayers(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, HPGL, INCHES, EDA_IU_SCALE::IU_PER_MILS, EDA_IU_SCALE::IU_PER_MM, KI_FALLTHROUGH, KiROUND(), DRILL_TOOL::m_Diameter, DRILL_TOOL::m_Hole_NotPlated, DRILL_TOOL::m_OvalCount, m_pageInfo, m_pcb, m_toolListBuffer, DRILL_TOOL::m_TotalCount, m_unitsMetric, PLOTTER::Marker(), MILLIMETERS, EDA_IU_SCALE::mmToIU(), PLOTTER::OpenFile(), PCB_SHAPE_T, pcbIUScale, PDF, plotDrillMarks(), BRDITEMS_PLOTTER::PlotPcbShape(), POST, scale, PLOTTER::SetColorMode(), PLOTTER::SetCreator(), PLOTTER::SetCurrentLineWidth(), KIGFX::RENDER_SETTINGS::SetDefaultPenWidth(), PLOTTER::SetGerberCoordinatesFormat(), BOARD_ITEM::SetLayer(), BRDITEMS_PLOTTER::SetLayerSet(), PLOTTER::SetPageSettings(), PLOTTER::SetRenderSettings(), DXF_PLOTTER::SetUnits(), PLOTTER::SetViewport(), BOARD::SetVisibleLayers(), PLOTTER::StartPlot(), SVG, text, PLOTTER::Text(), GERBER_PLOTTER::UseX2format(), GERBER_PLOTTER::UseX2NetAttributes(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CreateMapFilesSet().

◆ GenDrillReportFile()

bool GENDRILL_WRITER_BASE::GenDrillReportFile ( const wxString &  aFullFileName)

Create a plain text report file giving a list of drill values and drill count for through holes, oblong holes, and for buried vias, drill values and drill count per layer pair there is only one report for all drill files even when buried or blinds vias exist.

Here is a sample created by this function: Drill report for F:/tmp/interf_u/interf_u.brd Created on 04/10/2012 20:48:38 Selected Drill Unit: Imperial (inches)

Drill report for plated through holes : T1 0,025" 0,64mm (88 holes) T2 0,031" 0,79mm (120 holes) T3 0,032" 0,81mm (151 holes) (with 1 slot) T4 0,040" 1,02mm (43 holes) T5 0,079" 2,00mm (1 hole) (with 1 slot) T6 0,120" 3,05mm (1 hole) (with 1 slot)

Total plated holes count 404

Drill report for buried and blind vias :

Drill report for holes from layer Soudure to layer Interne1 :

Total plated holes count 0

Drill report for holes from layer Interne1 to layer Interne2 : T1 0,025" 0,64mm (3 holes) Total plated holes count 3 Drill report for holes from layer Interne2 to layer Composant : T1 0,025" 0,64mm (1 hole)

Total plated holes count 1

Drill report for unplated through holes : T1 0,120" 3,05mm (1 hole) (with 1 slot)

Total unplated holes count 1

Parameters
aFullFileNameis the name of the file to create.
Returns
true if the file is created.

Definition at line 354 of file gen_drill_report_files.cpp.

355{
356 FILE_OUTPUTFORMATTER out( aFullFileName );
357
358 static const char separator[] =
359 " =============================================================\n";
360
361 wxASSERT( m_pcb );
362
363 unsigned totalHoleCount;
364 wxFileName brdFilename( m_pcb->GetFileName() );
365
366 std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
367
368 out.Print( 0, "Drill report for %s\n", TO_UTF8( brdFilename.GetFullName() ) );
369 out.Print( 0, "Created on %s\n\n", TO_UTF8( DateAndTime() ) );
370
371 // Output the cu layer stackup, so layer name references make sense.
372 out.Print( 0, "Copper Layer Stackup:\n" );
373 out.Print( 0, separator );
374
376
377 int conventional_layer_num = 1;
378
379 for( LSEQ seq = cu.Seq(); seq; ++seq, ++conventional_layer_num )
380 {
381 out.Print( 0, " L%-2d: %-25s %s\n",
382 conventional_layer_num,
383 TO_UTF8( m_pcb->GetLayerName( *seq ) ),
384 layerName( *seq ).c_str() ); // generic layer name
385 }
386
387 out.Print( 0, "\n\n" );
388
389 /* output hole lists:
390 * 1 - through holes
391 * 2 - for partial holes only: by layer starting and ending pair
392 * 3 - Non Plated through holes
393 */
394
395 bool buildNPTHlist = false; // First pass: build PTH list only
396
397 // in this loop are plated only:
398 for( unsigned pair_ndx = 0; pair_ndx < hole_sets.size(); ++pair_ndx )
399 {
400 DRILL_LAYER_PAIR pair = hole_sets[pair_ndx];
401
402 buildHolesList( pair, buildNPTHlist );
403
404 if( pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
405 {
406 out.Print( 0, "Drill file '%s' contains\n",
407 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
408
409 out.Print( 0, " plated through holes:\n" );
410 out.Print( 0, separator );
411 totalHoleCount = printToolSummary( out, false );
412 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
413 }
414 else // blind/buried
415 {
416 out.Print( 0, "Drill file '%s' contains\n",
417 TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
418
419 out.Print( 0, " holes connecting layer pair: '%s and %s' (%s vias):\n",
420 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.first ) ) ),
421 TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.second ) ) ),
422 pair.first == F_Cu || pair.second == B_Cu ? "blind" : "buried" );
423
424 out.Print( 0, separator );
425 totalHoleCount = printToolSummary( out, false );
426 out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
427 }
428
429 out.Print( 0, "\n\n" );
430 }
431
432 // NPTHoles. Generate the full list (pads+vias) if PTH and NPTH are merged,
433 // or only the NPTH list (which never has vias)
434 if( !m_merge_PTH_NPTH )
435 buildNPTHlist = true;
436
437 buildHolesList( DRILL_LAYER_PAIR( F_Cu, B_Cu ), buildNPTHlist );
438
439 // nothing wrong with an empty NPTH file in report.
440 if( m_merge_PTH_NPTH )
441 out.Print( 0, "Not plated through holes are merged with plated holes\n" );
442 else
443 out.Print( 0, "Drill file '%s' contains\n",
445 true, m_merge_PTH_NPTH ) ) );
446
447 out.Print( 0, " unplated through holes:\n" );
448 out.Print( 0, separator );
449 totalHoleCount = printToolSummary( out, true );
450 out.Print( 0, " Total unplated holes count %u\n", totalHoleCount );
451
452 return true;
453}
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:526
const wxString & GetFileName() const
Definition: board.h:302
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:413
Used for text file output.
Definition: richio.h:457
unsigned printToolSummary(OUTPUTFORMATTER &aOut, bool aSummaryNPTH) const
Print m_toolListBuffer[] tools to aOut and returns total hole count.
const std::string layerName(PCB_LAYER_ID aLayer) const
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:491
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:411
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
wxString DateAndTime()

References LSET::AllCuMask(), B_Cu, buildHolesList(), DateAndTime(), F_Cu, getDrillFileName(), BOARD::GetEnabledLayers(), BOARD::GetFileName(), BOARD::GetLayerName(), getUniqueLayerPairs(), layerName(), m_merge_PTH_NPTH, m_pcb, OUTPUTFORMATTER::Print(), printToolSummary(), LSET::Seq(), TO_UTF8, and ToLAYER_ID().

Referenced by DIALOG_GENDRILL::OnGenReportFile().

◆ GetDrillFileExt()

wxString GENDRILL_WRITER_BASE::GetDrillFileExt ( ) const
inline

Returns the file extension of the drill writer format.

Definition at line 270 of file gendrill_file_writer_base.h.

References m_drillFileExtension.

◆ getDrillFileName()

const wxString GENDRILL_WRITER_BASE::getDrillFileName ( DRILL_LAYER_PAIR  aPair,
bool  aNPTH,
bool  aMerge_PTH_NPTH 
) const
protectedvirtual
Parameters
aPairis the layer pair.
aNPTHuse true to generate the filename of NPTH holes.
aMerge_PTH_NPTHuse true to generate the filename of a file which containd both NPH and NPTH holes.
Returns
a filename which identify the drill file function. it is the board name with the layer pair names added, and for separate (PTH and NPTH) files, "-NPH" or "-NPTH" added

Reimplemented in GERBER_WRITER.

Definition at line 265 of file gendrill_file_writer_base.cpp.

267{
268 wxASSERT( m_pcb );
269
270 wxString extend;
271
272 if( aNPTH )
273 extend = wxT( "-NPTH" );
274 else if( aPair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
275 {
276 if( !aMerge_PTH_NPTH )
277 extend = wxT( "-PTH" );
278 // if merged, extend with nothing
279 }
280 else
281 {
282 extend += '-';
283 extend += layerPairName( aPair );
284 }
285
286 wxFileName fn = m_pcb->GetFileName();
287
288 fn.SetName( fn.GetName() + extend );
289 fn.SetExt( m_drillFileExtension );
290
291 wxString ret = fn.GetFullName();
292
293 return ret;
294}
const std::string layerPairName(DRILL_LAYER_PAIR aPair) const

References B_Cu, F_Cu, BOARD::GetFileName(), layerPairName(), m_drillFileExtension, and m_pcb.

Referenced by EXCELLON_WRITER::CreateDrillandMapFilesSet(), CreateMapFilesSet(), GenDrillReportFile(), and GERBER_WRITER::getDrillFileName().

◆ getHolesCount()

int GENDRILL_WRITER_BASE::getHolesCount ( ) const
inlineprotected

◆ GetOffset()

VECTOR2I GENDRILL_WRITER_BASE::GetOffset ( )
inline

Return the plot offset (usually the position of the drill/place origin).

Definition at line 183 of file gendrill_file_writer_base.h.

183{ return m_offset; }

References m_offset.

Referenced by genDrillMapFile().

◆ getUniqueLayerPairs()

std::vector< DRILL_LAYER_PAIR > GENDRILL_WRITER_BASE::getUniqueLayerPairs ( ) const
protected

Get unique layer pairs by examining the micro and blind_buried vias.

Definition at line 206 of file gendrill_file_writer_base.cpp.

207{
208 wxASSERT( m_pcb );
209
211
212 vias.Collect( m_pcb, { PCB_VIA_T } );
213
214 std::set<DRILL_LAYER_PAIR> unique;
215 DRILL_LAYER_PAIR layer_pair;
216
217 for( int i = 0; i < vias.GetCount(); ++i )
218 {
219 PCB_VIA* v = static_cast<PCB_VIA*>( vias[i] );
220
221 v->LayerPair( &layer_pair.first, &layer_pair.second );
222
223 // only make note of blind buried.
224 // thru hole is placed unconditionally as first in fetched list.
225 if( layer_pair != DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
226 unique.insert( layer_pair );
227 }
228
229 std::vector<DRILL_LAYER_PAIR> ret;
230
231 ret.emplace_back( F_Cu, B_Cu ); // always first in returned list
232
233 for( const DRILL_LAYER_PAIR& pair : unique )
234 ret.push_back( pair );
235
236 return ret;
237}
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
Definition: collectors.h:522
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Collect BOARD_ITEM objects using this class's Inspector method, which does the collection.
Definition: collectors.cpp:631
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
Definition: pcb_track.cpp:542

References B_Cu, PCB_TYPE_COLLECTOR::Collect(), F_Cu, COLLECTOR::GetCount(), PCB_VIA::LayerPair(), m_pcb, and PCB_VIA_T.

Referenced by EXCELLON_WRITER::CreateDrillandMapFilesSet(), GERBER_WRITER::CreateDrillandMapFilesSet(), CreateMapFilesSet(), and GenDrillReportFile().

◆ layerName()

const std::string GENDRILL_WRITER_BASE::layerName ( PCB_LAYER_ID  aLayer) const
protected
Returns
a string from aLayer to identify the layer. string are "front" "back" or "in<aLayer>"

Definition at line 240 of file gendrill_file_writer_base.cpp.

241{
242 // Generic names here.
243 switch( aLayer )
244 {
245 case F_Cu:
246 return "front";
247 case B_Cu:
248 return "back";
249 default:
250 return StrPrintf( "in%d", aLayer );
251 }
252}
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
Definition: richio.cpp:84

References B_Cu, F_Cu, and StrPrintf().

Referenced by GenDrillReportFile(), and layerPairName().

◆ layerPairName()

const std::string GENDRILL_WRITER_BASE::layerPairName ( DRILL_LAYER_PAIR  aPair) const
protected
Returns
a string from aPair to identify the layer layer pair. string is "<layer1Name>"-"<layer2Name>" used to generate a filename for drill files and drill maps

Definition at line 255 of file gendrill_file_writer_base.cpp.

256{
257 std::string ret = layerName( aPair.first );
258 ret += '-';
259 ret += layerName( aPair.second );
260
261 return ret;
262}

References layerName().

Referenced by getDrillFileName().

◆ plotDrillMarks()

bool GENDRILL_WRITER_BASE::plotDrillMarks ( PLOTTER aPlotter)
protected

Write the drill marks in HPGL, POSTSCRIPT or other supported formats/.

Each hole size has a symbol (circle, cross X, cross + ...) up to PLOTTER::MARKER_COUNT different values. If more than PLOTTER::MARKER_COUNT different values, these other values share the same mark shape.

Parameters
aPlotteris a PLOTTER instance (HPGL, POSTSCRIPT ... plotter).

Definition at line 456 of file gen_drill_report_files.cpp.

457{
458 // Plot the drill map:
459 VECTOR2I pos;
460
461 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
462 {
463 const HOLE_INFO& hole = m_holeListBuffer[ii];
464 pos = hole.m_Hole_Pos;
465
466 // Gives a good line thickness to have a good marker shape:
468
469 // Always plot the drill symbol (for slots identifies the needed cutter!
470 aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
471
472 if( hole.m_Hole_Shape != 0 )
473 aPlotter->FlashPadOval( pos, hole.m_Hole_Size, hole.m_Hole_Orient, SKETCH, nullptr );
474 }
475
476 aPlotter->SetCurrentLineWidth( -1 );
477
478 return true;
479}
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
@ SKETCH
Definition: outline_mode.h:26

References PLOTTER::FlashPadOval(), getMarkerBestPenSize(), HOLE_INFO::m_Hole_Diameter, HOLE_INFO::m_Hole_Orient, HOLE_INFO::m_Hole_Pos, HOLE_INFO::m_Hole_Shape, HOLE_INFO::m_Hole_Size, m_holeListBuffer, HOLE_INFO::m_Tool_Reference, PLOTTER::Marker(), PLOTTER::SetCurrentLineWidth(), and SKETCH.

Referenced by genDrillMapFile().

◆ printToolSummary()

unsigned GENDRILL_WRITER_BASE::printToolSummary ( OUTPUTFORMATTER aOut,
bool  aSummaryNPTH 
) const
protected

Print m_toolListBuffer[] tools to aOut and returns total hole count.

Parameters
aOutis the current OUTPUTFORMATTER to print summary.
aSummaryNPTHis true to print summary for NPTH, false for PTH.

Definition at line 482 of file gen_drill_report_files.cpp.

483{
484 unsigned totalHoleCount = 0;
485
486 for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
487 {
488 const DRILL_TOOL& tool = m_toolListBuffer[ii];
489
490 if( aSummaryNPTH && !tool.m_Hole_NotPlated )
491 continue;
492
493 if( !aSummaryNPTH && tool.m_Hole_NotPlated )
494 continue;
495
496 // List the tool number assigned to each drill in mm then in inches.
497 int tool_number = ii+1;
498 out.Print( 0, " T%d %2.3fmm %2.4f\" ", tool_number,
501
502 // Now list how many holes and ovals are associated with each drill.
503 if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
504 out.Print( 0, "(1 hole)\n" );
505 else if( tool.m_TotalCount == 1 )
506 out.Print( 0, "(1 hole) (with 1 slot)\n" );
507 else if( tool.m_OvalCount == 0 )
508 out.Print( 0, "(%d holes)\n", tool.m_TotalCount );
509 else if( tool.m_OvalCount == 1 )
510 out.Print( 0, "(%d holes) (with 1 slot)\n", tool.m_TotalCount );
511 else // tool.m_OvalCount > 1
512 out.Print( 0, "(%d holes) (with %d slots)\n", tool.m_TotalCount, tool.m_OvalCount );
513
514 totalHoleCount += tool.m_TotalCount;
515 }
516
517 out.Print( 0, "\n" );
518
519 return totalHoleCount;
520}

References diameter_in_inches(), diameter_in_mm(), DRILL_TOOL::m_Diameter, DRILL_TOOL::m_Hole_NotPlated, DRILL_TOOL::m_OvalCount, m_toolListBuffer, DRILL_TOOL::m_TotalCount, and OUTPUTFORMATTER::Print().

Referenced by GenDrillReportFile().

◆ SetMapFileFormat()

void GENDRILL_WRITER_BASE::SetMapFileFormat ( PLOT_FORMAT  aMapFmt)
inline

Initialize the format for the drill map file.

Parameters
aMapFmta PlotFormat value (one of PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER, PLOT_FORMAT_DXF, PLOT_FORMAT_SVG, PLOT_FORMAT_PDF the most useful are PLOT_FORMAT_PDF and PLOT_FORMAT_POST.

Definition at line 201 of file gendrill_file_writer_base.h.

202 {
203 m_mapFileFmt = aMapFmt;
204 }

References m_mapFileFmt.

Referenced by DIALOG_GENDRILL::GenDrillAndMapFiles(), and PCBNEW_JOBS_HANDLER::JobExportDrill().

◆ SetMergeOption()

void GENDRILL_WRITER_BASE::SetMergeOption ( bool  aMerge)
inline

Set the option to make separate drill files for PTH and NPTH.

Parameters
aMergeset to true to make only one file containing PTH and NPTH or false to create 2 separate files.

Definition at line 178 of file gendrill_file_writer_base.h.

178{ m_merge_PTH_NPTH = aMerge; }

References m_merge_PTH_NPTH.

Referenced by DIALOG_GENDRILL::OnGenReportFile().

◆ SetPageInfo()

void GENDRILL_WRITER_BASE::SetPageInfo ( const PAGE_INFO aPageInfo)
inline

Set the page info used to plot drill maps.

If NULL, a A4 page format will be used.

Parameters
aPageInfois a reference to the page info, usually used to plot/display the board.

Definition at line 192 of file gendrill_file_writer_base.h.

192{ m_pageInfo = aPageInfo; }

References m_pageInfo.

Member Data Documentation

◆ m_conversionUnits

◆ m_drillFileExtension

wxString GENDRILL_WRITER_BASE::m_drillFileExtension
protected

◆ m_holeListBuffer

std::vector<HOLE_INFO> GENDRILL_WRITER_BASE::m_holeListBuffer
protected

◆ m_mapFileFmt

PLOT_FORMAT GENDRILL_WRITER_BASE::m_mapFileFmt
protected

◆ m_merge_PTH_NPTH

◆ m_offset

◆ m_pageInfo

const PAGE_INFO* GENDRILL_WRITER_BASE::m_pageInfo
protected

Definition at line 395 of file gendrill_file_writer_base.h.

Referenced by GENDRILL_WRITER_BASE(), genDrillMapFile(), and SetPageInfo().

◆ m_pcb

◆ m_precision

◆ m_toolListBuffer

std::vector<DRILL_TOOL> GENDRILL_WRITER_BASE::m_toolListBuffer
protected

◆ m_unitsMetric

◆ m_zeroFormat


The documentation for this class was generated from the following files: