KiCad PCB EDA Suite
GERBER_WRITER Class Reference

Used to create Gerber drill files. More...

#include <gendrill_gerber_writer.h>

Inheritance diagram for GERBER_WRITER:
GENDRILL_WRITER_BASE

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

 GERBER_WRITER (BOARD *aPcb)
 
virtual ~GERBER_WRITER ()
 
void SetFormat (int aRightDigits=6)
 Initialize internal parameters to match the given format. More...
 
void SetOptions (const VECTOR2I &aOffset)
 Initialize internal parameters to match drill options. More...
 
void CreateDrillandMapFilesSet (const wxString &aPlotDirectory, bool aGenDrill, bool aGenMap, REPORTER *aReporter=nullptr)
 Create the full set of Excellon drill file for the board filenames are computed from the board name, and layers id. More...
 
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...
 

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
 
const wxString BuildFileFunctionAttributeString (DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHoleType, bool aCompatNCdrill=false) const
 

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
 

Private Member Functions

int createDrillFile (wxString &aFullFilename, bool aIsNpth, DRILL_LAYER_PAIR aLayerPair)
 Create an Excellon drill file. More...
 
virtual const wxString getDrillFileName (DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const override
 

Detailed Description

Used to create Gerber drill files.

Definition at line 40 of file gendrill_gerber_writer.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

◆ GERBER_WRITER()

◆ ~GERBER_WRITER()

virtual GERBER_WRITER::~GERBER_WRITER ( )
inlinevirtual

Definition at line 45 of file gendrill_gerber_writer.h.

46 {
47 }

Member Function Documentation

◆ BuildFileFunctionAttributeString()

const wxString GENDRILL_WRITER_BASE::BuildFileFunctionAttributeString ( DRILL_LAYER_PAIR  aLayerPair,
TYPE_FILE  aHoleType,
bool  aCompatNCdrill = false 
) const
protectedinherited
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 363 of file gendrill_file_writer_base.cpp.

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

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

◆ buildHolesList()

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

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:282
TRACKS & Tracks()
Definition: board.h:279
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:423
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:104

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, GENDRILL_WRITER_BASE::m_holeListBuffer, HOLE_INFO::m_ItemParent, GENDRILL_WRITER_BASE::m_merge_PTH_NPTH, GENDRILL_WRITER_BASE::m_pcb, HOLE_INFO::m_Tool_Reference, GENDRILL_WRITER_BASE::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(), CreateDrillandMapFilesSet(), GENDRILL_WRITER_BASE::CreateMapFilesSet(), and GENDRILL_WRITER_BASE::GenDrillReportFile().

◆ CreateDrillandMapFilesSet()

void GERBER_WRITER::CreateDrillandMapFilesSet ( const wxString &  aPlotDirectory,
bool  aGenDrill,
bool  aGenMap,
REPORTER aReporter = nullptr 
)

Create the full set of Excellon drill file for the board filenames are computed from the board name, and layers id.

Parameters
aPlotDirectoryis the output folder.
aGenDrillset to true to generate the EXCELLON drill file.
aGenMapset to true to generate a drill map file.
aReporteris a REPORTER to return activity or any message (can be NULL).

Definition at line 57 of file gendrill_gerber_writer.cpp.

59{
60 // Note: In Gerber drill files, NPTH and PTH are always separate files
61 m_merge_PTH_NPTH = false;
62
63 wxFileName fn;
64 wxString msg;
65
66 std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
67
68 // append a pair representing the NPTH set of holes, for separate drill files.
69 // (Gerber drill files are separate files for PTH and NPTH)
70 hole_sets.emplace_back( F_Cu, B_Cu );
71
72 for( std::vector<DRILL_LAYER_PAIR>::const_iterator it = hole_sets.begin();
73 it != hole_sets.end(); ++it )
74 {
75 DRILL_LAYER_PAIR pair = *it;
76 // For separate drill files, the last layer pair is the NPTH drill file.
77 bool doing_npth = ( it == hole_sets.end() - 1 );
78
79 buildHolesList( pair, doing_npth );
80
81 // The file is created if it has holes, or if it is the non plated drill file
82 // to be sure the NPTH file is up to date in separate files mode.
83 // Also a PTH drill/map file is always created, to be sure at least one plated hole drill
84 // file is created (do not create any PTH drill file can be seen as not working drill
85 // generator).
86 if( getHolesCount() > 0 || doing_npth || pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
87 {
88 fn = getDrillFileName( pair, doing_npth, false );
89 fn.SetPath( aPlotDirectory );
90
91 if( aGenDrill )
92 {
93 wxString fullFilename = fn.GetFullPath();
94
95 int result = createDrillFile( fullFilename, doing_npth, pair );
96
97 if( result < 0 )
98 {
99 if( aReporter )
100 {
101 msg.Printf( _( "Failed to create file '%s'." ), fullFilename );
102 aReporter->Report( msg, RPT_SEVERITY_ERROR );
103 }
104
105 break;
106 }
107 else
108 {
109 if( aReporter )
110 {
111 msg.Printf( _( "Created file '%s'." ), fullFilename );
112 aReporter->Report( msg, RPT_SEVERITY_ACTION );
113 }
114 }
115
116 }
117 }
118 }
119
120 if( aGenMap )
121 CreateMapFilesSet( aPlotDirectory, aReporter );
122
123 if( aReporter )
124 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
125}
std::vector< DRILL_LAYER_PAIR > getUniqueLayerPairs() const
Get unique layer pairs by examining the micro and blind_buried vias.
void buildHolesList(DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list)
Create the list of holes and tools for a given board.
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 sele...
virtual const wxString getDrillFileName(DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const override
int createDrillFile(wxString &aFullFilename, bool aIsNpth, DRILL_LAYER_PAIR aLayerPair)
Create an Excellon drill file.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Definition: reporter.h:99
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
#define _(s)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION

References _, B_Cu, GENDRILL_WRITER_BASE::buildHolesList(), createDrillFile(), GENDRILL_WRITER_BASE::CreateMapFilesSet(), F_Cu, getDrillFileName(), GENDRILL_WRITER_BASE::getHolesCount(), GENDRILL_WRITER_BASE::getUniqueLayerPairs(), GENDRILL_WRITER_BASE::m_merge_PTH_NPTH, REPORTER::Report(), REPORTER::ReportTail(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, and RPT_SEVERITY_INFO.

Referenced by DIALOG_GENDRILL::GenDrillAndMapFiles().

◆ createDrillFile()

int GERBER_WRITER::createDrillFile ( wxString &  aFullFilename,
bool  aIsNpth,
DRILL_LAYER_PAIR  aLayerPair 
)
private

Create an Excellon drill file.

Parameters
aFullFilenameis the full file name.
aIsNpthset to true for a NPTH file or false for a PTH file.
aLayerPairis the first board layer and the last board layer for this drill file for blind buried vias, they are not always top and bottom layers/
Returns
hole count or -1 if the file cannot be created.

Definition at line 134 of file gendrill_gerber_writer.cpp.

136{
137 int holes_count;
138
139 LOCALE_IO dummy; // Use the standard notation for double numbers
140
141 GERBER_PLOTTER plotter;
142
143 // Gerber drill file imply X2 format:
144 plotter.UseX2format( true );
145 plotter.UseX2NetAttributes( true );
146 plotter.DisableApertMacros( false );
147
148 // Add the standard X2 header, without FileFunction
149 AddGerberX2Header( &plotter, m_pcb );
150 plotter.SetViewport( m_offset, IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false );
151
152 // has meaning only for gerber plotter. Must be called only after SetViewport
153 plotter.SetGerberCoordinatesFormat( 6 );
154 plotter.SetCreator( wxT( "PCBNEW" ) );
155
156 // Add the standard X2 FileFunction for drill files
157 // %TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH][Blind][Buried],Drill[Route][Mixed]*%
158 wxString text = BuildFileFunctionAttributeString( aLayerPair,
159 aIsNpth
160 ? TYPE_FILE::NPTH_FILE
161 : TYPE_FILE::PTH_FILE );
162 plotter.AddLineToHeader( text );
163
164 // Add file polarity (positive)
165 text = wxT( "%TF.FilePolarity,Positive*%" );
166 plotter.AddLineToHeader( text );
167
168 if( !plotter.OpenFile( aFullFilename ) )
169 return -1;
170
171 plotter.StartPlot();
172
173 holes_count = 0;
174
175 VECTOR2I hole_pos;
176 bool last_item_is_via = true; // a flag to clear object attributes when a via hole is created.
177
178 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
179 {
180 HOLE_INFO& hole_descr = m_holeListBuffer[ii];
181 hole_pos = hole_descr.m_Hole_Pos;
182
183 // Manage the aperture attributes: in drill files 3 attributes can be used:
184 // "ViaDrill", only for vias, not pads
185 // "ComponentDrill", only for Through Holes pads
186 // "Slot" for oblong holes;
187 GBR_METADATA gbr_metadata;
188
189 if( dyn_cast<const PCB_VIA*>( hole_descr.m_ItemParent ) )
190 {
192
193 if( !last_item_is_via )
194 {
195 // be sure the current object attribute is cleared for vias
196 plotter.EndBlock( nullptr );
197 }
198
199 last_item_is_via = true;
200 }
201 else if( dyn_cast<const PAD*>( hole_descr.m_ItemParent ) )
202 {
203 last_item_is_via = false;
204 const PAD* pad = dyn_cast<const PAD*>( hole_descr.m_ItemParent );
205
206 if( pad->GetProperty() == PAD_PROP::CASTELLATED )
207 {
208 gbr_metadata.SetApertureAttrib(
210 }
211 else
212 {
213 // Good practice of oblong pad holes (slots) is to use a specific aperture for
214 // routing, not used in drill commands.
215 if( hole_descr.m_Hole_Shape )
216 gbr_metadata.SetApertureAttrib(
218 else
219 gbr_metadata.SetApertureAttrib(
221 }
222
223 // Add object attribute: component reference to pads (mainly useful for users)
224 wxString ref = pad->GetParent()->GetReference();
225
226 gbr_metadata.SetCmpReference( ref );
228 }
229
230 if( hole_descr.m_Hole_Shape )
231 {
232#if FLASH_OVAL_HOLE // set to 1 to use flashed oblong holes,
233 // 0 to draw them as a line.
234 plotter.FlashPadOval( hole_pos, hole_descr.m_Hole_Size, hole_descr.m_Hole_Orient,
235 FILLED, &gbr_metadata );
236#else
237 // Use routing for oblong hole (Slots)
238 VECTOR2I start, end;
239 convertOblong2Segment( hole_descr.m_Hole_Size, hole_descr.m_Hole_Orient, start, end );
240 int width = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
241
242 if ( width == 0 )
243 continue;
244
245 plotter.ThickSegment( start+hole_pos, end+hole_pos, width, FILLED, &gbr_metadata );
246#endif
247 }
248 else
249 {
250 int diam = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
251 plotter.FlashPadCircle( hole_pos, diam, FILLED, &gbr_metadata );
252 }
253
254 holes_count++;
255 }
256
257 plotter.EndPlot();
258
259 return holes_count;
260}
@ GBR_APERTURE_ATTRIB_CMP_DRILL
aperture used for pad holes in drill files.
Definition: gbr_metadata.h:140
@ GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL
aperture used for flashed cmp position in placement files.
Definition: gbr_metadata.h:143
@ GBR_APERTURE_ATTRIB_VIADRILL
aperture used for via holes in drill files.
Definition: gbr_metadata.h:139
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:205
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:241
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:209
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:219
@ GBR_NETINFO_CMP
print info associated to a component (TO.C attribute)
const wxString BuildFileFunctionAttributeString(DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHoleType, bool aCompatNCdrill=false) const
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false) override
Selection of Gerber units and resolution (number of digits in mantissa).
virtual void FlashPadCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool EndPlot() override
void UseX2format(bool aEnable)
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
void UseX2NetAttributes(bool aEnable)
virtual void EndBlock(void *aData) override
Define the end of a group of drawing items the group is started by StartBlock().
virtual bool StartPlot() override
Write GERBER header to file initialize global variable g_Plot_PlotOutputFile.
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
void DisableApertMacros(bool aDisable)
Disable Aperture Macro (AM) command, only for broken Gerber Readers.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:75
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:158
void AddLineToHeader(const wxString &aExtraString)
Add a line to the list of free lines to print at the beginning of the file.
Definition: plotter.h:167
@ FILLED
Definition: outline_mode.h:27
@ CASTELLATED
a pad with a castellated through hole
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
#define IU_PER_MILS
Definition: plotter.cpp:129
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:73

References AddGerberX2Header(), PLOTTER::AddLineToHeader(), GENDRILL_WRITER_BASE::BuildFileFunctionAttributeString(), CASTELLATED, GERBER_PLOTTER::DisableApertMacros(), dummy(), GERBER_PLOTTER::EndBlock(), GERBER_PLOTTER::EndPlot(), FILLED, GERBER_PLOTTER::FlashPadCircle(), GERBER_PLOTTER::FlashPadOval(), GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDDRILL, GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_DRILL, GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL, GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIADRILL, GBR_NETLIST_METADATA::GBR_NETINFO_CMP, IU_PER_MILS, HOLE_INFO::m_Hole_Orient, HOLE_INFO::m_Hole_Pos, HOLE_INFO::m_Hole_Shape, HOLE_INFO::m_Hole_Size, GENDRILL_WRITER_BASE::m_holeListBuffer, HOLE_INFO::m_ItemParent, GENDRILL_WRITER_BASE::m_offset, GENDRILL_WRITER_BASE::m_pcb, PLOTTER::OpenFile(), pad, GBR_METADATA::SetApertureAttrib(), GBR_METADATA::SetCmpReference(), PLOTTER::SetCreator(), GERBER_PLOTTER::SetGerberCoordinatesFormat(), GBR_METADATA::SetNetAttribType(), GERBER_PLOTTER::SetViewport(), GERBER_PLOTTER::StartPlot(), text, GERBER_PLOTTER::ThickSegment(), GERBER_PLOTTER::UseX2format(), GERBER_PLOTTER::UseX2NetAttributes(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CreateDrillandMapFilesSet().

◆ CreateMapFilesSet()

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

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 304 of file gendrill_file_writer_base.cpp.

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

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

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

◆ genDrillMapFile()

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

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 65 of file gen_drill_report_files.cpp.

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

References PAGE_INFO::A4, AddGerberX2Header(), PLOTTER::AddLineToHeader(), ANGLE_HORIZONTAL, EDA_RECT::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(), EDA_RECT::GetBottom(), EDA_RECT::GetHeight(), getMarkerBestPenSize(), GENDRILL_WRITER_BASE::GetOffset(), PLOTTER::GetPlotterType(), BOARD::GetVisibleLayers(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, HPGL, INCHES, IU_PER_MILS, IU_PER_MM, KI_FALLTHROUGH, KiROUND(), DRILL_TOOL::m_Diameter, DRILL_TOOL::m_Hole_NotPlated, DRILL_TOOL::m_OvalCount, GENDRILL_WRITER_BASE::m_pageInfo, GENDRILL_WRITER_BASE::m_pcb, GENDRILL_WRITER_BASE::m_toolListBuffer, DRILL_TOOL::m_TotalCount, GENDRILL_WRITER_BASE::m_unitsMetric, PLOTTER::Marker(), Millimeter2iu(), MILLIMETERS, PLOTTER::OpenFile(), PCB_SHAPE_T, PDF, GENDRILL_WRITER_BASE::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 GENDRILL_WRITER_BASE::CreateMapFilesSet().

◆ GenDrillReportFile()

bool GENDRILL_WRITER_BASE::GenDrillReportFile ( const wxString &  aFullFileName)
inherited

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 355 of file gen_drill_report_files.cpp.

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

Referenced by DIALOG_GENDRILL::OnGenReportFile().

◆ getDrillFileName()

const wxString GERBER_WRITER::getDrillFileName ( DRILL_LAYER_PAIR  aPair,
bool  aNPTH,
bool  aMerge_PTH_NPTH 
) const
overrideprivatevirtual
Parameters
aPairis the layer pair.
aNPTHset to true to generate the filename of NPTH holes.
aMerge_PTH_NPTHset to true to generate the filename of a file which contains 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 from GENDRILL_WRITER_BASE.

Definition at line 300 of file gendrill_gerber_writer.cpp.

302{
303 // Gerber files extension is always .gbr.
304 // Therefore, to mark drill files, add "-drl" to the filename.
305 wxFileName fname( GENDRILL_WRITER_BASE::getDrillFileName( aPair, aNPTH, aMerge_PTH_NPTH ) );
306 fname.SetName( fname.GetName() + wxT( "-drl" ) );
307
308 return fname.GetFullPath();
309}

References GENDRILL_WRITER_BASE::getDrillFileName().

Referenced by CreateDrillandMapFilesSet().

◆ getHolesCount()

int GENDRILL_WRITER_BASE::getHolesCount ( ) const
inlineprotectedinherited

◆ GetOffset()

VECTOR2I GENDRILL_WRITER_BASE::GetOffset ( )
inlineinherited

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 GENDRILL_WRITER_BASE::m_offset.

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile().

◆ getUniqueLayerPairs()

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

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
210 static const KICAD_T interesting_stuff_to_collect[] = {
211 PCB_VIA_T,
212 EOT
213 };
214
216
217 vias.Collect( m_pcb, interesting_stuff_to_collect );
218
219 std::set< DRILL_LAYER_PAIR > unique;
220
221 DRILL_LAYER_PAIR layer_pair;
222
223 for( int i = 0; i < vias.GetCount(); ++i )
224 {
225 PCB_VIA* v = static_cast<PCB_VIA*>( vias[i] );
226
227 v->LayerPair( &layer_pair.first, &layer_pair.second );
228
229 // only make note of blind buried.
230 // thru hole is placed unconditionally as first in fetched list.
231 if( layer_pair != DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
232 {
233 unique.insert( layer_pair );
234 }
235 }
236
237 std::vector<DRILL_LAYER_PAIR> ret;
238
239 ret.emplace_back( F_Cu, B_Cu ); // always first in returned list
240
241 for( std::set<DRILL_LAYER_PAIR>::const_iterator it = unique.begin(); it != unique.end(); ++it )
242 ret.push_back( *it );
243
244 return ret;
245}
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
Definition: collectors.h:552
void Collect(BOARD_ITEM *aBoard, const KICAD_T aScanList[])
Collect BOARD_ITEM objects using this class's Inspector method, which does the collection.
Definition: collectors.cpp:658
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:501
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ EOT
search types array terminator (End Of Types)
Definition: typeinfo.h:81

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

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

◆ layerName()

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

Definition at line 248 of file gendrill_file_writer_base.cpp.

249{
250 // Generic names here.
251 switch( aLayer )
252 {
253 case F_Cu:
254 return "front";
255 case B_Cu:
256 return "back";
257 default:
258 return StrPrintf( "in%d", aLayer );
259 }
260}
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 GENDRILL_WRITER_BASE::GenDrillReportFile(), and GENDRILL_WRITER_BASE::layerPairName().

◆ layerPairName()

const std::string GENDRILL_WRITER_BASE::layerPairName ( DRILL_LAYER_PAIR  aPair) const
protectedinherited
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 263 of file gendrill_file_writer_base.cpp.

264{
265 std::string ret = layerName( aPair.first );
266 ret += '-';
267 ret += layerName( aPair.second );
268
269 return ret;
270}

References GENDRILL_WRITER_BASE::layerName().

Referenced by GENDRILL_WRITER_BASE::getDrillFileName().

◆ plotDrillMarks()

bool GENDRILL_WRITER_BASE::plotDrillMarks ( PLOTTER aPlotter)
protectedinherited

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 457 of file gen_drill_report_files.cpp.

458{
459 // Plot the drill map:
460 VECTOR2I pos;
461
462 for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
463 {
464 const HOLE_INFO& hole = m_holeListBuffer[ii];
465 pos = hole.m_Hole_Pos;
466
467 // Gives a good line thickness to have a good marker shape:
469
470 // Always plot the drill symbol (for slots identifies the needed cutter!
471 aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
472
473 if( hole.m_Hole_Shape != 0 )
474 aPlotter->FlashPadOval( pos, hole.m_Hole_Size, hole.m_Hole_Orient, SKETCH, nullptr );
475 }
476
477 aPlotter->SetCurrentLineWidth( -1 );
478
479 return true;
480}
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, GENDRILL_WRITER_BASE::m_holeListBuffer, HOLE_INFO::m_Tool_Reference, PLOTTER::Marker(), PLOTTER::SetCurrentLineWidth(), and SKETCH.

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile().

◆ printToolSummary()

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

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 483 of file gen_drill_report_files.cpp.

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

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

Referenced by GENDRILL_WRITER_BASE::GenDrillReportFile().

◆ SetFormat()

void GERBER_WRITER::SetFormat ( int  aRightDigits = 6)

Initialize internal parameters to match the given format.

Parameters
aRightDigitsis the number of digits for mantissa part of coordinates (5 or 6).

Definition at line 289 of file gendrill_gerber_writer.cpp.

290{
291 /* Set conversion scale depending on drill file units */
292 m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm
293
294 // Set precision (unit is mm).
295 m_precision.m_Lhs = 4;
296 m_precision.m_Rhs = aRightDigits == 6 ? 6 : 5;
297}

References IU_PER_MM, GENDRILL_WRITER_BASE::m_conversionUnits, DRILL_PRECISION::m_Lhs, GENDRILL_WRITER_BASE::m_precision, and DRILL_PRECISION::m_Rhs.

Referenced by DIALOG_GENDRILL::GenDrillAndMapFiles().

◆ SetMapFileFormat()

void GENDRILL_WRITER_BASE::SetMapFileFormat ( PLOT_FORMAT  aMapFmt)
inlineinherited

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 GENDRILL_WRITER_BASE::m_mapFileFmt.

Referenced by DIALOG_GENDRILL::GenDrillAndMapFiles().

◆ SetMergeOption()

void GENDRILL_WRITER_BASE::SetMergeOption ( bool  aMerge)
inlineinherited

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 GENDRILL_WRITER_BASE::m_merge_PTH_NPTH.

Referenced by DIALOG_GENDRILL::OnGenReportFile().

◆ SetOptions()

void GERBER_WRITER::SetOptions ( const VECTOR2I aOffset)
inline

Initialize internal parameters to match drill options.

Note
PTH and NPTH are always separate files in Gerber format.
Parameters
aOffsetis the drill coordinates offset.

Definition at line 63 of file gendrill_gerber_writer.h.

64 {
65 m_offset = aOffset;
66 m_merge_PTH_NPTH = false;
67 }

References GENDRILL_WRITER_BASE::m_merge_PTH_NPTH, and GENDRILL_WRITER_BASE::m_offset.

Referenced by DIALOG_GENDRILL::GenDrillAndMapFiles().

◆ SetPageInfo()

void GENDRILL_WRITER_BASE::SetPageInfo ( const PAGE_INFO aPageInfo)
inlineinherited

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 GENDRILL_WRITER_BASE::m_pageInfo.

Member Data Documentation

◆ m_conversionUnits

◆ m_drillFileExtension

wxString GENDRILL_WRITER_BASE::m_drillFileExtension
protectedinherited

◆ m_holeListBuffer

◆ m_mapFileFmt

◆ m_merge_PTH_NPTH

◆ m_offset

◆ m_pageInfo

const PAGE_INFO* GENDRILL_WRITER_BASE::m_pageInfo
protectedinherited

◆ m_pcb

◆ m_precision

DRILL_PRECISION GENDRILL_WRITER_BASE::m_precision
protectedinherited

◆ m_toolListBuffer

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

◆ m_unitsMetric

◆ m_zeroFormat


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