KiCad PCB EDA Suite
GENDRILL_WRITER_BASE Class Reference

GENDRILL_WRITER_BASE is a class to create drill maps and drill report, and a helper class to created 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 }
 

Public Member Functions

virtual ~GENDRILL_WRITER_BASE ()
 
void SetMergeOption (bool aMerge)
 set the option to make separate drill files for PTH and NPTH More...
 
const wxPoint GetOffset ()
 Return the plot offset (usually the position of the auxiliary axis. More...
 
void SetPageInfo (const PAGE_INFO *aPageInfo)
 Sets the page info used to plot drill maps If NULL, a A4 page format will be used. More...
 
void SetMapFileFormat (PLOT_FORMAT aMapFmt)
 Initialize the format for the drill map file. More...
 
void CreateMapFilesSet (const wxString &aPlotDirectory, REPORTER *aReporter=NULL)
 Function CreateMapFilesSet Creates the full set of map files for the board, in PS, PDF ... More...
 
bool GenDrillReportFile (const wxString &aFullFileName)
 Function GenDrillReportFile 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

 GENDRILL_WRITER_BASE (BOARD *aPcb)
 
bool genDrillMapFile (const wxString &aFullFileName, PLOT_FORMAT aFormat)
 Function GenDrillMapFile Plot a map of drill marks for holes. More...
 
void buildHolesList (DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list)
 Function BuildHolesList Create the list of holes and tools for a given board The list is sorted by increasing drill size. More...
 
int getHolesCount () const
 
bool plotDrillMarks (PLOTTER *aPlotter)
 Helper function. 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
 Function printToolSummary prints m_toolListBuffer[] tools to aOut and returns total hole count. More...
 
const std::string layerPairName (DRILL_LAYER_PAIR aPair) const
 minor helper function. More...
 
const std::string layerName (PCB_LAYER_ID aLayer) const
 minor helper function. More...
 
virtual const wxString getDrillFileName (DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const
 
const wxString BuildFileFunctionAttributeString (DRILL_LAYER_PAIR aLayerPair, bool aIsNpth, 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
 
wxPoint 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

GENDRILL_WRITER_BASE is a class to create drill maps and drill report, and a helper class to created drill files.

drill files are created by specialized derived classes, depenfing on the file format.

Definition at line 126 of file gendrill_file_writer_base.h.

Member Enumeration Documentation

◆ ZEROS_FMT

Enumerator
DECIMAL_FORMAT 
SUPPRESS_LEADING 
SUPPRESS_TRAILING 
KEEP_ZEROS 

Definition at line 129 of file gendrill_file_writer_base.h.

129  { // Zero format in coordinates
130  DECIMAL_FORMAT, // Floating point coordinates
131  SUPPRESS_LEADING, // Suppress leading zeros
132  SUPPRESS_TRAILING, // Suppress trainling zeros
133  KEEP_ZEROS // keep zeros
134  };

Constructor & Destructor Documentation

◆ GENDRILL_WRITER_BASE()

◆ ~GENDRILL_WRITER_BASE()

virtual GENDRILL_WRITER_BASE::~GENDRILL_WRITER_BASE ( )
inlinevirtual

Definition at line 167 of file gendrill_file_writer_base.h.

168  {
169  }

Member Function Documentation

◆ BuildFileFunctionAttributeString()

const wxString GENDRILL_WRITER_BASE::BuildFileFunctionAttributeString ( DRILL_LAYER_PAIR  aLayerPair,
bool  aIsNpth,
bool  aCompatNCdrill = false 
) const
protected
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.
Parameters
aLayerPairis the layer pair (Drill from rom first layer to second layer)
aIsNpthis true when generating NPTH drill file
aCompatNCdrillis true when generating NC (Excellon) compatible drill file

Definition at line 352 of file gendrill_file_writer_base.cpp.

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

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

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

◆ buildHolesList()

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

Function BuildHolesList 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 73 of file gendrill_file_writer_base.cpp.

75 {
76  HOLE_INFO new_hole;
77 
78  m_holeListBuffer.clear();
79  m_toolListBuffer.clear();
80 
81  wxASSERT( aLayerPair.first < aLayerPair.second ); // fix the caller
82 
83  // build hole list for vias
84  if( ! aGenerateNPTH_list ) // vias are always plated !
85  {
86  for( auto track : m_pcb->Tracks() )
87  {
88  if( track->Type() != PCB_VIA_T )
89  continue;
90 
91  auto via = static_cast<VIA*>( track );
92  int hole_sz = via->GetDrillValue();
93 
94  if( hole_sz == 0 ) // Should not occur.
95  continue;
96 
97  new_hole.m_ItemParent = via;
98  new_hole.m_Tool_Reference = -1; // Flag value for Not initialized
99  new_hole.m_Hole_Orient = 0;
100  new_hole.m_Hole_Diameter = hole_sz;
101  new_hole.m_Hole_NotPlated = false;
102  new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
103 
104  new_hole.m_Hole_Shape = 0; // hole shape: round
105  new_hole.m_Hole_Pos = via->GetStart();
106 
107  via->LayerPair( &new_hole.m_Hole_Top_Layer, &new_hole.m_Hole_Bottom_Layer );
108 
109  // LayerPair() returns params with m_Hole_Bottom_Layer > m_Hole_Top_Layer
110  // Remember: top layer = 0 and bottom layer = 31 for through hole vias
111  // Any captured via should be from aLayerPair.first to aLayerPair.second exactly.
112  if( new_hole.m_Hole_Top_Layer != aLayerPair.first ||
113  new_hole.m_Hole_Bottom_Layer != aLayerPair.second )
114  continue;
115 
116  m_holeListBuffer.push_back( new_hole );
117  }
118  }
119 
120  if( aLayerPair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
121  {
122  // add holes for thru hole pads
123  for( auto module : m_pcb->Modules() )
124  {
125  for( auto& pad : module->Pads() )
126  {
127  if( !m_merge_PTH_NPTH )
128  {
129  if( !aGenerateNPTH_list && pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
130  continue;
131 
132  if( aGenerateNPTH_list && pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
133  continue;
134  }
135 
136  if( pad->GetDrillSize().x == 0 )
137  continue;
138 
139  new_hole.m_ItemParent = pad;
140  new_hole.m_Hole_NotPlated = (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED);
141  new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
142  new_hole.m_Hole_Orient = pad->GetOrientation();
143  new_hole.m_Hole_Shape = 0; // hole shape: round
144  new_hole.m_Hole_Diameter = std::min( pad->GetDrillSize().x, pad->GetDrillSize().y );
145  new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
146 
147  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
148  new_hole.m_Hole_Shape = 1; // oval flag set
149 
150  new_hole.m_Hole_Size = pad->GetDrillSize();
151  new_hole.m_Hole_Pos = pad->GetPosition(); // hole position
152  new_hole.m_Hole_Bottom_Layer = B_Cu;
153  new_hole.m_Hole_Top_Layer = F_Cu; // pad holes are through holes
154  m_holeListBuffer.push_back( new_hole );
155  }
156  }
157  }
158 
159  // Sort holes per increasing diameter value
160  sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), CmpHoleSorting );
161 
162  // build the tool list
163  int last_hole = -1; // Set to not initialized (this is a value not used
164  // for m_holeListBuffer[ii].m_Hole_Diameter)
165  bool last_notplated_opt = false;
166 
167  DRILL_TOOL new_tool( 0, false );
168  unsigned jj;
169 
170  for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
171  {
172  if( m_holeListBuffer[ii].m_Hole_Diameter != last_hole ||
173  m_holeListBuffer[ii].m_Hole_NotPlated != last_notplated_opt )
174  {
175  new_tool.m_Diameter = m_holeListBuffer[ii].m_Hole_Diameter;
176  new_tool.m_Hole_NotPlated = m_holeListBuffer[ii].m_Hole_NotPlated;
177  m_toolListBuffer.push_back( new_tool );
178  last_hole = new_tool.m_Diameter;
179  last_notplated_opt = new_tool.m_Hole_NotPlated;
180  }
181 
182  jj = m_toolListBuffer.size();
183 
184  if( jj == 0 )
185  continue; // Should not occurs
186 
187  m_holeListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1)
188 
189  m_toolListBuffer.back().m_TotalCount++;
190 
191  if( m_holeListBuffer[ii].m_Hole_Shape )
192  m_toolListBuffer.back().m_OvalCount++;
193  }
194 }
BOARD_ITEM * m_ItemParent
static bool CmpHoleSorting(const HOLE_INFO &a, const HOLE_INFO &b)
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:66
std::vector< DRILL_TOOL > m_toolListBuffer
MODULES & Modules()
Definition: class_board.h:229
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > DRILL_LAYER_PAIR
PCB_LAYER_ID m_Hole_Bottom_Layer
PCB_LAYER_ID m_Hole_Top_Layer
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
std::vector< HOLE_INFO > m_holeListBuffer
TRACKS & Tracks()
Definition: class_board.h:220

References B_Cu, CmpHoleSorting(), F_Cu, 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, m_holeListBuffer, HOLE_INFO::m_ItemParent, m_merge_PTH_NPTH, m_pcb, HOLE_INFO::m_Tool_Reference, m_toolListBuffer, BOARD::Modules(), PAD_ATTRIB_HOLE_NOT_PLATED, PAD_DRILL_SHAPE_CIRCLE, PCB_VIA_T, and BOARD::Tracks().

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

◆ CreateMapFilesSet()

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

Function CreateMapFilesSet Creates the full set of map files for the board, in PS, PDF ...

format (use SetMapFileFormat() to select the format) filenames are computed from the board name, and layers id

Parameters
aPlotDirectory= the output folder
aReporter= a REPORTER to return activity or any message (can be NULL)

Definition at line 295 of file gendrill_file_writer_base.cpp.

297 {
298  wxFileName fn;
299  wxString msg;
300 
301  std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
302 
303  // append a pair representing the NPTH set of holes, for separate drill files.
304  if( !m_merge_PTH_NPTH )
305  hole_sets.emplace_back( F_Cu, B_Cu );
306 
307  for( std::vector<DRILL_LAYER_PAIR>::const_iterator it = hole_sets.begin();
308  it != hole_sets.end(); ++it )
309  {
310  DRILL_LAYER_PAIR pair = *it;
311  // For separate drill files, the last layer pair is the NPTH drill file.
312  bool doing_npth = m_merge_PTH_NPTH ? false : ( it == hole_sets.end() - 1 );
313 
314  buildHolesList( pair, doing_npth );
315 
316  // The file is created if it has holes, or if it is the non plated drill file
317  // to be sure the NPTH file is up to date in separate files mode.
318  if( getHolesCount() > 0 || doing_npth )
319  {
320  fn = getDrillFileName( pair, doing_npth, m_merge_PTH_NPTH );
321  fn.SetPath( aPlotDirectory );
322 
323  fn.SetExt( wxEmptyString ); // Will be added by GenDrillMap
324  wxString fullfilename = fn.GetFullPath() + wxT( "-drl_map" );
325  fullfilename << wxT(".") << GetDefaultPlotExtension( m_mapFileFmt );
326 
327  bool success = genDrillMapFile( fullfilename, m_mapFileFmt );
328 
329  if( ! success )
330  {
331  if( aReporter )
332  {
333  msg.Printf( _( "** Unable to create %s **\n" ), GetChars( fullfilename ) );
334  aReporter->Report( msg );
335  }
336 
337  return;
338  }
339  else
340  {
341  if( aReporter )
342  {
343  msg.Printf( _( "Create file %s\n" ), GetChars( fullfilename ) );
344  aReporter->Report( msg );
345  }
346  }
347  }
348  }
349 }
virtual const wxString getDrillFileName(DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Returns the default plot extension for a format.
std::vector< DRILL_LAYER_PAIR > getUniqueLayerPairs() const
Get unique layer pairs by examining the micro and blind_buried vias.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > DRILL_LAYER_PAIR
void buildHolesList(DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list)
Function BuildHolesList Create the list of holes and tools for a given board The list is sorted by in...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
#define _(s)
Definition: 3d_actions.cpp:33
bool genDrillMapFile(const wxString &aFullFileName, PLOT_FORMAT aFormat)
Function GenDrillMapFile Plot a map of drill marks for holes.

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

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

◆ genDrillMapFile()

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

Function GenDrillMapFile 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
aFullFileName: the full filename of the map file to create,
aFormat: one of the supported plot formats (see enum PlotFormat )

Definition at line 59 of file gen_drill_report_files.cpp.

60 {
61  // Remark:
62  // Hole list must be created before calling this function, by buildHolesList(),
63  // for the right holes set (PTH, NPTH, buried/blind vias ...)
64 
65  double scale = 1.0;
66  wxPoint offset;
67  PLOTTER* plotter = NULL;
68  PAGE_INFO dummy( PAGE_INFO::A4, false );
69 
70  PCB_PLOT_PARAMS plot_opts; // starts plotting with default options
71 
72  LOCALE_IO toggle; // use standard C notation for float numbers
73 
74  const PAGE_INFO& page_info = m_pageInfo ? *m_pageInfo : dummy;
75 
76  // Calculate dimensions and center of PCB
78 
79  // Calculate the scale for the format type, scale 1 in HPGL, drawing on
80  // an A4 sheet in PS, + text description of symbols
81  switch( aFormat )
82  {
84  offset = GetOffset();
85  plotter = new GERBER_PLOTTER();
86  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
87  plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm
88  break;
89 
90  case PLOT_FORMAT::HPGL: // Scale for HPGL format.
91  {
92  HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER;
93  plotter = hpgl_plotter;
94  hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() );
95  hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() );
96  plotter->SetPageSettings( page_info );
97  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
98  }
99  break;
100 
101 
102  default:
103  wxASSERT( false );
104  // fall through
105  case PLOT_FORMAT::PDF:
106  case PLOT_FORMAT::POST:
107  {
108  PAGE_INFO pageA4( wxT( "A4" ) );
109  wxSize pageSizeIU = pageA4.GetSizeIU();
110 
111  // Reserve a margin around the page.
112  int margin = KiROUND( 20 * IU_PER_MM );
113 
114  // Calculate a scaling factor to print the board on the sheet
115  double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
116 
117  // We should print the list of drill sizes, so reserve room for it
118  // 60% height for board 40% height for list
119  int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
120  double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
121 
122  scale = std::min( Xscale, Yscale );
123 
124  // Experience shows the scale should not to large, because texts
125  // create problem (can be to big or too small).
126  // So the scale is clipped at 3.0;
127  scale = std::min( scale, 3.0 );
128 
129  offset.x = KiROUND( double( bbbox.Centre().x ) - ( pageSizeIU.x / 2.0 ) / scale );
130  offset.y = KiROUND( double( bbbox.Centre().y ) - ( ypagesize_for_board / 2.0 ) / scale );
131 
132  if( aFormat == PLOT_FORMAT::PDF )
133  plotter = new PDF_PLOTTER;
134  else
135  plotter = new PS_PLOTTER;
136 
137  plotter->SetPageSettings( pageA4 );
138  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
139  }
140  break;
141 
142  case PLOT_FORMAT::DXF:
143  {
144  DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
145 
146  if( m_unitsMetric )
148  else
150 
151  plotter = dxf_plotter;
152  plotter->SetPageSettings( page_info );
153  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
154  }
155  break;
156 
157  case PLOT_FORMAT::SVG:
158  {
159  SVG_PLOTTER* svg_plotter = new SVG_PLOTTER;
160  plotter = svg_plotter;
161  plotter->SetPageSettings( page_info );
162  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
163  }
164  break;
165  }
166 
167  plotter->SetCreator( wxT( "PCBNEW" ) );
168  plotter->SetDefaultLineWidth( 5 * IU_PER_MILS );
169  plotter->SetColorMode( false );
170 
171  if( !plotter->OpenFile( aFullFileName ) )
172  {
173  delete plotter;
174  return false;
175  }
176 
177  plotter->StartPlot();
178 
179  // Draw items on edge layer (not all, only items useful for drill map
180  BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
181  itemplotter.SetLayerSet( Edge_Cuts );
182 
183  for( auto PtStruct : m_pcb->Drawings() )
184  {
185  switch( PtStruct->Type() )
186  {
187  case PCB_LINE_T:
188  itemplotter.PlotDrawSegment( (DRAWSEGMENT*) PtStruct );
189  break;
190 
191  case PCB_TEXT_T:
192  itemplotter.PlotTextePcb( (TEXTE_PCB*) PtStruct );
193  break;
194 
195  case PCB_DIMENSION_T:
196  case PCB_TARGET_T:
197  case PCB_MARKER_T: // do not draw
198  default:
199  break;
200  }
201  }
202 
203  int x, y;
204  int plotX, plotY, TextWidth;
205  int intervalle = 0;
206  char line[1024];
207  wxString msg;
208  int textmarginaftersymbol = KiROUND( 2 * IU_PER_MM );
209 
210  // Set Drill Symbols width
211  plotter->SetDefaultLineWidth( 0.2 * IU_PER_MM / scale );
212  plotter->SetCurrentLineWidth( -1 );
213 
214  // Plot board outlines and drill map
215  plotDrillMarks( plotter );
216 
217  // Print a list of symbols used.
218  int charSize = 3 * IU_PER_MM; // text size in IUs
219  double charScale = 1.0 / scale; // real scale will be 1/scale,
220  // because the global plot scale is scale
221  TextWidth = KiROUND( ( charSize * charScale ) / 10.0 ); // Set text width (thickness)
222  intervalle = KiROUND( charSize * charScale ) + TextWidth;
223 
224  // Trace information.
225  plotX = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
226  plotY = bbbox.GetBottom() + intervalle;
227 
228  // Plot title "Info"
229  wxString Text = wxT( "Drill Map:" );
230  plotter->Text( wxPoint( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, 0,
231  wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
232  GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false );
233 
234  for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
235  {
236  DRILL_TOOL& tool = m_toolListBuffer[ii];
237 
238  if( tool.m_TotalCount == 0 )
239  continue;
240 
241  plotY += intervalle;
242 
243  int plot_diam = KiROUND( tool.m_Diameter );
244  x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
245  y = KiROUND( plotY + charSize * charScale );
246  plotter->Marker( wxPoint( x, y ), plot_diam, ii );
247 
248  // List the diameter of each drill in mm and inches.
249  sprintf( line, "%2.2fmm / %2.3f\" ", diameter_in_mm( tool.m_Diameter ),
250  diameter_in_inches( tool.m_Diameter ) );
251 
252  msg = FROM_UTF8( line );
253 
254  // Now list how many holes and ovals are associated with each drill.
255  if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
256  sprintf( line, "(1 hole)" );
257  else if( tool.m_TotalCount == 1 ) // && ( toolm_OvalCount == 1 )
258  sprintf( line, "(1 slot)" );
259  else if( tool.m_OvalCount == 0 )
260  sprintf( line, "(%d holes)", tool.m_TotalCount );
261  else if( tool.m_OvalCount == 1 )
262  sprintf( line, "(%d holes + 1 slot)", tool.m_TotalCount - 1 );
263  else // if ( toolm_OvalCount > 1 )
264  sprintf( line, "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount,
265  tool.m_OvalCount );
266 
267  msg += FROM_UTF8( line );
268 
269  if( tool.m_Hole_NotPlated )
270  msg += wxT( " (not plated)" );
271 
272  plotter->Text( wxPoint( plotX, y ), COLOR4D::UNSPECIFIED, msg, 0,
273  wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
274  GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false );
275 
276  intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );
277 
278  if( intervalle < ( plot_diam + ( 1 * IU_PER_MM / scale ) + TextWidth ) )
279  intervalle = plot_diam + ( 1 * IU_PER_MM / scale ) + TextWidth;
280  }
281 
282  plotter->EndPlot();
283  delete plotter;
284 
285  return true;
286 }
double diameter_in_inches(double ius)
double diameter_in_mm(double ius)
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:180
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:62
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:202
virtual bool StartPlot()=0
int GetX() const
Definition: eda_rect.h:111
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:767
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:82
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:133
int GetWidth() const
Definition: eda_rect.h:119
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
int GetHPGLPenSpeed() const
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false)
Definition: plotter.h:476
int GetBottom() const
Definition: eda_rect.h:124
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: gr_text.cpp:232
std::vector< DRILL_TOOL > m_toolListBuffer
virtual bool EndPlot()=0
#define NULL
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
virtual void SetPenSpeed(int speed)
Definition: plotter.h:652
static const wxChar A4[]
Definition: page_info.h:64
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
int GetHeight() const
Definition: eda_rect.h:120
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror)=0
Set the plot offset and scaling for the current plot.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
void Marker(const wxPoint &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
Definition: plotter.cpp:331
virtual void SetDefaultLineWidth(int width)=0
Set the default line width.
int GetHPGLPenNum() const
Base plotter engine class.
Definition: plotter.h:104
const wxPoint GetOffset()
Return the plot offset (usually the position of the auxiliary axis.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
const int scale
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
virtual void SetPenNumber(int number)
Definition: plotter.h:657
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define IU_PER_MILS
Definition: plotter.cpp:137
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:61
wxPoint Centre() const
Definition: eda_rect.h:62
bool plotDrillMarks(PLOTTER *aPlotter)
Helper function.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
DRAWINGS & Drawings()
Definition: class_board.h:238
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: plotter.h:147
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.

References PAGE_INFO::A4, EDA_RECT::Centre(), diameter_in_inches(), diameter_in_mm(), BOARD::Drawings(), dummy(), DXF, Edge_Cuts, PLOTTER::EndPlot(), FROM_UTF8(), GERBER, BOARD::GetBoardEdgesBoundingBox(), EDA_RECT::GetBottom(), EDA_RECT::GetHeight(), PCB_PLOT_PARAMS::GetHPGLPenNum(), PCB_PLOT_PARAMS::GetHPGLPenSpeed(), GetOffset(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, HPGL, DXF_PLOTTER::INCHES, IU_PER_MILS, 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(), DXF_PLOTTER::MILLIMETERS, NULL, PLOTTER::OpenFile(), PCB_DIMENSION_T, PCB_LINE_T, PCB_MARKER_T, PCB_TARGET_T, PCB_TEXT_T, PDF, BRDITEMS_PLOTTER::PlotDrawSegment(), plotDrillMarks(), BRDITEMS_PLOTTER::PlotTextePcb(), POST, scale, PLOTTER::SetColorMode(), PLOTTER::SetCreator(), PLOTTER::SetCurrentLineWidth(), PLOTTER::SetDefaultLineWidth(), PLOTTER::SetGerberCoordinatesFormat(), BRDITEMS_PLOTTER::SetLayerSet(), PLOTTER::SetPageSettings(), HPGL_PLOTTER::SetPenNumber(), HPGL_PLOTTER::SetPenSpeed(), DXF_PLOTTER::SetUnits(), PLOTTER::SetViewport(), PLOTTER::StartPlot(), SVG, PLOTTER::Text(), wxPoint::x, and wxPoint::y.

Referenced by CreateMapFilesSet().

◆ GenDrillReportFile()

bool GENDRILL_WRITER_BASE::GenDrillReportFile ( const wxString &  aFullFileName)

Function GenDrillReportFile 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
aFullFileName: the name of the file to create
Returns
true if the file is created

Definition at line 289 of file gen_drill_report_files.cpp.

290 {
291  FILE_OUTPUTFORMATTER out( aFullFileName );
292 
293  static const char separator[] =
294  " =============================================================\n";
295 
296  wxASSERT( m_pcb );
297 
298  unsigned totalHoleCount;
299  wxString brdFilename = m_pcb->GetFileName();
300 
301  std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
302 
303  out.Print( 0, "Drill report for %s\n", TO_UTF8( brdFilename ) );
304  out.Print( 0, "Created on %s\n\n", TO_UTF8( DateAndTime() ) );
305 
306  // Output the cu layer stackup, so layer name references make sense.
307  out.Print( 0, "Copper Layer Stackup:\n" );
308  out.Print( 0, separator );
309 
311 
312  int conventional_layer_num = 1;
313 
314  for( LSEQ seq = cu.Seq(); seq; ++seq, ++conventional_layer_num )
315  {
316  out.Print( 0, " L%-2d: %-25s %s\n",
317  conventional_layer_num,
318  TO_UTF8( m_pcb->GetLayerName( *seq ) ),
319  layerName( *seq ).c_str() // generic layer name
320  );
321  }
322 
323  out.Print( 0, "\n\n" );
324 
325  /* output hole lists:
326  * 1 - through holes
327  * 2 - for partial holes only: by layer starting and ending pair
328  * 3 - Non Plated through holes
329  */
330 
331  bool buildNPTHlist = false; // First pass: build PTH list only
332 
333  // in this loop are plated only:
334  for( unsigned pair_ndx = 0; pair_ndx < hole_sets.size(); ++pair_ndx )
335  {
336  DRILL_LAYER_PAIR pair = hole_sets[pair_ndx];
337 
338  buildHolesList( pair, buildNPTHlist );
339 
340  if( pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
341  {
342  out.Print( 0, "Drill file '%s' contains\n",
343  TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
344 
345  out.Print( 0, " plated through holes:\n" );
346  out.Print( 0, separator );
347  totalHoleCount = printToolSummary( out, false );
348  out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
349  }
350  else // blind/buried
351  {
352  out.Print( 0, "Drill file '%s' contains\n",
353  TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
354 
355  out.Print( 0, " holes connecting layer pair: '%s and %s' (%s vias):\n",
356  TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.first ) ) ),
357  TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.second ) ) ),
358  pair.first == F_Cu || pair.second == B_Cu ? "blind" : "buried"
359  );
360 
361  out.Print( 0, separator );
362  totalHoleCount = printToolSummary( out, false );
363  out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
364  }
365 
366  out.Print( 0, "\n\n" );
367  }
368 
369  // NPTHoles. Generate the full list (pads+vias) if PTH and NPTH are merged,
370  // or only the NPTH list (which never has vias)
371  if( !m_merge_PTH_NPTH )
372  buildNPTHlist = true;
373 
374  buildHolesList( DRILL_LAYER_PAIR( F_Cu, B_Cu ), buildNPTHlist );
375 
376  // nothing wrong with an empty NPTH file in report.
377  if( m_merge_PTH_NPTH )
378  out.Print( 0, "Not plated through holes are merged with plated holes\n" );
379  else
380  out.Print( 0, "Drill file '%s' contains\n",
382  true, m_merge_PTH_NPTH ) ) );
383 
384  out.Print( 0, " unplated through holes:\n" );
385  out.Print( 0, separator );
386  totalHoleCount = printToolSummary( out, true );
387  out.Print( 0, " Total unplated holes count %u\n", totalHoleCount );
388 
389  return true;
390 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:686
unsigned printToolSummary(OUTPUTFORMATTER &aOut, bool aSummaryNPTH) const
Function printToolSummary prints m_toolListBuffer[] tools to aOut and returns total hole count.
virtual const wxString getDrillFileName(DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
std::vector< DRILL_LAYER_PAIR > getUniqueLayerPairs() const
Get unique layer pairs by examining the micro and blind_buried vias.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:377
const wxString & GetFileName() const
Definition: class_board.h:218
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
LSET is a set of PCB_LAYER_IDs.
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > DRILL_LAYER_PAIR
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
void buildHolesList(DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list)
Function BuildHolesList Create the list of holes and tools for a given board The list is sorted by in...
const std::string layerName(PCB_LAYER_ID aLayer) const
minor helper function.
FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
wxString DateAndTime()
Definition: string.cpp:345

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().

◆ getDrillFileName()

const wxString GENDRILL_WRITER_BASE::getDrillFileName ( DRILL_LAYER_PAIR  aPair,
bool  aNPTH,
bool  aMerge_PTH_NPTH 
) const
protectedvirtual
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
Parameters
aPair= the layer pair
aNPTH= true to generate the filename of NPTH holes
aMerge_PTH_NPTH= true to generate the filename of a file which containd both NPH and NPTH holes

Reimplemented in GERBER_WRITER.

Definition at line 264 of file gendrill_file_writer_base.cpp.

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

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()

const wxPoint GENDRILL_WRITER_BASE::GetOffset ( )
inline

Return the plot offset (usually the position of the auxiliary axis.

Definition at line 182 of file gendrill_file_writer_base.h.

182 { 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 197 of file gendrill_file_writer_base.cpp.

198 {
199  wxASSERT( m_pcb );
200 
201  static const KICAD_T interesting_stuff_to_collect[] = {
202  PCB_VIA_T,
203  EOT
204  };
205 
206  PCB_TYPE_COLLECTOR vias;
207 
208  vias.Collect( m_pcb, interesting_stuff_to_collect );
209 
210  std::set< DRILL_LAYER_PAIR > unique;
211 
212  DRILL_LAYER_PAIR layer_pair;
213 
214  for( int i = 0; i < vias.GetCount(); ++i )
215  {
216  VIA* v = (VIA*) vias[i];
217 
218  v->LayerPair( &layer_pair.first, &layer_pair.second );
219 
220  // only make note of blind buried.
221  // thru hole is placed unconditionally as first in fetched list.
222  if( layer_pair != DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
223  {
224  unique.insert( layer_pair );
225  }
226  }
227 
228  std::vector<DRILL_LAYER_PAIR> ret;
229 
230  ret.emplace_back( F_Cu, B_Cu ); // always first in returned list
231 
232  for( std::set< DRILL_LAYER_PAIR >::const_iterator it = unique.begin(); it != unique.end(); ++it )
233  ret.push_back( *it );
234 
235  return ret;
236 }
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...
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:100
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > DRILL_LAYER_PAIR
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:573
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
Definition: collectors.h:621

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

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

◆ layerName()

const std::string GENDRILL_WRITER_BASE::layerName ( PCB_LAYER_ID  aLayer) const
protected

minor helper function.

Returns
a string from aLayer to identify the layer. string are "front" "back" or "in<aLayer>"

Definition at line 239 of file gendrill_file_writer_base.cpp.

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

References B_Cu, F_Cu, and numEval::StrPrintf().

Referenced by GenDrillReportFile(), and layerPairName().

◆ layerPairName()

const std::string GENDRILL_WRITER_BASE::layerPairName ( DRILL_LAYER_PAIR  aPair) const
protected

minor helper function.

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

255 {
256  std::string ret = layerName( aPair.first );
257  ret += '-';
258  ret += layerName( aPair.second );
259 
260  return ret;
261 }
const std::string layerName(PCB_LAYER_ID aLayer) const
minor helper function.

References layerName().

Referenced by getDrillFileName().

◆ plotDrillMarks()

bool GENDRILL_WRITER_BASE::plotDrillMarks ( PLOTTER aPlotter)
protected

Helper function.

Writes 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
aPlotter= a PLOTTER instance (HPGL, POSTSCRIPT ... plotter).

Definition at line 393 of file gen_drill_report_files.cpp.

394 {
395  // Plot the drill map:
396  wxPoint pos;
397 
398  for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
399  {
400  const HOLE_INFO& hole = m_holeListBuffer[ii];
401  pos = hole.m_Hole_Pos;
402 
403  // Always plot the drill symbol (for slots identifies the needed cutter!
404  aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
405 
406  if( hole.m_Hole_Shape != 0 )
407  {
408  wxSize oblong_size = hole.m_Hole_Size;
409  aPlotter->FlashPadOval( pos, oblong_size, hole.m_Hole_Orient, SKETCH, NULL );
410  }
411  }
412 
413  return true;
414 }
#define NULL
void Marker(const wxPoint &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
Definition: plotter.cpp:331
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadOval
std::vector< HOLE_INFO > m_holeListBuffer

References PLOTTER::FlashPadOval(), 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(), NULL, and SKETCH.

Referenced by genDrillMapFile().

◆ printToolSummary()

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

Function printToolSummary prints m_toolListBuffer[] tools to aOut and returns total hole count.

Parameters
aOut= the current OUTPUTFORMATTER to print summary
aSummaryNPTH= true to print summary for NPTH, false for PTH

Definition at line 417 of file gen_drill_report_files.cpp.

418 {
419  unsigned totalHoleCount = 0;
420 
421  for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
422  {
423  const DRILL_TOOL& tool = m_toolListBuffer[ii];
424 
425  if( aSummaryNPTH && !tool.m_Hole_NotPlated )
426  continue;
427 
428  if( !aSummaryNPTH && tool.m_Hole_NotPlated )
429  continue;
430 
431  // List the tool number assigned to each drill,
432  // in mm then in inches.
433  int tool_number = ii+1;
434  out.Print( 0, " T%d %2.2fmm %2.3f\" ", tool_number,
435  diameter_in_mm( tool.m_Diameter ),
436  diameter_in_inches( tool.m_Diameter ) );
437 
438  // Now list how many holes and ovals are associated with each drill.
439  if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
440  out.Print( 0, "(1 hole)\n" );
441  else if( tool.m_TotalCount == 1 )
442  out.Print( 0, "(1 hole) (with 1 slot)\n" );
443  else if( tool.m_OvalCount == 0 )
444  out.Print( 0, "(%d holes)\n", tool.m_TotalCount );
445  else if( tool.m_OvalCount == 1 )
446  out.Print( 0, "(%d holes) (with 1 slot)\n", tool.m_TotalCount );
447  else // tool.m_OvalCount > 1
448  out.Print( 0, "(%d holes) (with %d slots)\n",
449  tool.m_TotalCount, tool.m_OvalCount );
450 
451  totalHoleCount += tool.m_TotalCount;
452  }
453 
454  out.Print( 0, "\n" );
455 
456  return totalHoleCount;
457 }
double diameter_in_inches(double ius)
double diameter_in_mm(double ius)
std::vector< DRILL_TOOL > m_toolListBuffer

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
aMapFmt= a 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 198 of file gendrill_file_writer_base.h.

199  {
200  m_mapFileFmt = aMapFmt;
201  }

References m_mapFileFmt.

Referenced by DIALOG_GENDRILL::GenDrillAndMapFiles().

◆ SetMergeOption()

void GENDRILL_WRITER_BASE::SetMergeOption ( bool  aMerge)
inline

set the option to make separate drill files for PTH and NPTH

Parameters
aMerge= true to make only one file containing PTH and NPTH = false to create 2 separate files

Definition at line 176 of file gendrill_file_writer_base.h.

References m_merge_PTH_NPTH.

Referenced by DIALOG_GENDRILL::OnGenReportFile().

◆ SetPageInfo()

void GENDRILL_WRITER_BASE::SetPageInfo ( const PAGE_INFO aPageInfo)
inline

Sets the page info used to plot drill maps If NULL, a A4 page format will be used.

Parameters
aPageInfo= a reference to the page info, usually used to plot/display the board

Definition at line 189 of file gendrill_file_writer_base.h.

189 { 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 151 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: