KiCad PCB EDA Suite
GERBER_WRITER Class Reference

GERBER_WRITER is a class mainly 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 }
 

Public Member Functions

 GERBER_WRITER (BOARD *aPcb)
 
virtual ~GERBER_WRITER ()
 
void SetFormat (int aRightDigits=6)
 Function SetFormat Initialize internal parameters to match the given format. More...
 
void SetOptions (wxPoint aOffset)
 Function SetOptions Initialize internal parameters to match drill options note: PTH and NPTH are always separate files in Gerber format. More...
 
void CreateDrillandMapFilesSet (const wxString &aPlotDirectory, bool aGenDrill, bool aGenMap, REPORTER *aReporter=NULL)
 Function CreateDrillandMapFilesSet Creates 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...
 
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

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

Private Member Functions

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

Detailed Description

GERBER_WRITER is a class mainly used to create Gerber drill files.

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

◆ 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,
bool  aIsNpth,
bool  aCompatNCdrill = false 
) const
protectedinherited
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, GENDRILL_WRITER_BASE::m_holeListBuffer, and GENDRILL_WRITER_BASE::m_pcb.

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

◆ buildHolesList()

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

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:85
std::vector< DRILL_TOOL > m_toolListBuffer
MODULES & Modules()
Definition: class_board.h:273
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:264

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, 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, BOARD::Modules(), PAD_ATTRIB_HOLE_NOT_PLATED, PAD_DRILL_SHAPE_CIRCLE, PCB_VIA_T, and BOARD::Tracks().

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

◆ CreateDrillandMapFilesSet()

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

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

Parameters
aPlotDirectory= the output folder
aGenDrill= true to generate the EXCELLON drill file
aGenMap= true to generate a drill map file
aReporter= a REPORTER to return activity or any message (can be NULL)

Definition at line 63 of file gendrill_gerber_writer.cpp.

66 {
67  // Note: In Gerber drill files, NPTH and PTH are always separate files
68  m_merge_PTH_NPTH = false;
69 
70  wxFileName fn;
71  wxString msg;
72 
73  std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
74 
75  // append a pair representing the NPTH set of holes, for separate drill files.
76  // (Gerber drill files are separate files for PTH and NPTH)
77  hole_sets.emplace_back( F_Cu, B_Cu );
78 
79  for( std::vector<DRILL_LAYER_PAIR>::const_iterator it = hole_sets.begin();
80  it != hole_sets.end(); ++it )
81  {
82  DRILL_LAYER_PAIR pair = *it;
83  // For separate drill files, the last layer pair is the NPTH drill file.
84  bool doing_npth = ( it == hole_sets.end() - 1 );
85 
86  buildHolesList( pair, doing_npth );
87 
88  // The file is created if it has holes, or if it is the non plated drill file
89  // to be sure the NPTH file is up to date in separate files mode.
90  if( getHolesCount() > 0 || doing_npth )
91  {
92  fn = getDrillFileName( pair, doing_npth, false );
93  fn.SetPath( aPlotDirectory );
94 
95  if( aGenDrill )
96  {
97  wxString fullFilename = fn.GetFullPath();
98 
99  int result = createDrillFile( fullFilename, doing_npth, pair );
100 
101  if( result < 0 )
102  {
103  if( aReporter )
104  {
105  msg.Printf( _( "** Unable to create %s **\n" ), fullFilename );
106  aReporter->Report( msg );
107  }
108  break;
109  }
110  else
111  {
112  if( aReporter )
113  {
114  msg.Printf( _( "Create file %s\n" ), fullFilename );
115  aReporter->Report( msg );
116  }
117  }
118 
119  }
120  }
121  }
122 
123  if( aGenMap )
124  CreateMapFilesSet( aPlotDirectory, aReporter );
125 }
std::vector< DRILL_LAYER_PAIR > getUniqueLayerPairs() const
Get unique layer pairs by examining the micro and blind_buried vias.
void CreateMapFilesSet(const wxString &aPlotDirectory, REPORTER *aReporter=NULL)
Function CreateMapFilesSet Creates the full set of map files for the board, in PS,...
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...
virtual const wxString getDrillFileName(DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const override
#define _(s)
Definition: 3d_actions.cpp:33
int createDrillFile(wxString &aFullFilename, bool aIsNpth, DRILL_LAYER_PAIR aLayerPair)
Function createDrillFile Creates an Excellon drill file.

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, and REPORTER::Report().

Referenced by DIALOG_GENDRILL::GenDrillAndMapFiles().

◆ createDrillFile()

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

Function createDrillFile Creates an Excellon drill file.

Parameters
aFullFilename= the full filename
aIsNpth= true for a NPTH file, false for a PTH file
aLayerPair= 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 130 of file gendrill_gerber_writer.cpp.

132 {
133  int holes_count;
134 
135  LOCALE_IO dummy; // Use the standard notation for double numbers
136 
137  GERBER_PLOTTER plotter;
138 
139  // Gerber drill file imply X2 format:
140  plotter.UseX2format( true );
141  plotter.UseX2NetAttributes( true );
142 
143  // Add the standard X2 header, without FileFunction
144  AddGerberX2Header( &plotter, m_pcb );
145  plotter.SetViewport( m_offset, IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false );
146  // has meaning only for gerber plotter. Must be called only after SetViewport
147  plotter.SetGerberCoordinatesFormat( 6 );
148  plotter.SetCreator( wxT( "PCBNEW" ) );
149 
150  // Add the standard X2 FileFunction for drill files
151  // %TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH][Blind][Buried],Drill[Route][Mixed]*%
152  wxString text = BuildFileFunctionAttributeString( aLayerPair, aIsNpth );
153  plotter.AddLineToHeader( text );
154 
155  // Add file polarity (positive)
156  text = "%TF.FilePolarity,Positive*%";
157  plotter.AddLineToHeader( text );
158 
159  if( !plotter.OpenFile( aFullFilename ) )
160  return -1;
161 
162  plotter.StartPlot();
163 
164  holes_count = 0;
165 
166  wxPoint hole_pos;
167  bool last_item_is_via = true; // a flag to clear object attributes when a via hole is created.
168 
169  for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
170  {
171  HOLE_INFO& hole_descr = m_holeListBuffer[ii];
172  hole_pos = hole_descr.m_Hole_Pos;
173 
174  // Manage the aperture attributes: in drill files 3 attributes can be used:
175  // "ViaDrill", only for vias, not pads
176  // "ComponentDrill", only for Through Holes pads
177  // "Slot" for oblong holes;
178  GBR_METADATA gbr_metadata;
179 
180  if( dyn_cast<const VIA*>(hole_descr.m_ItemParent ) )
181  {
183 
184  if( !last_item_is_via )
185  {
186  // be sure the current object attribute is cleared for vias
187  plotter.EndBlock( NULL );
188  }
189 
190  last_item_is_via = true;
191  }
192  else if( dyn_cast<const D_PAD*>( hole_descr.m_ItemParent ) )
193  {
194  last_item_is_via = false;
195  const D_PAD* pad = dyn_cast<const D_PAD*>( hole_descr.m_ItemParent );
196 
197  if( pad->GetProperty() == PAD_PROP_CASTELLATED )
199  else
200  {
201  // Good practice of oblong pad holes (slots) is to use a specific aperture for routing, not used
202  // in drill commands
203  if( hole_descr.m_Hole_Shape )
205  else
207  }
208 
209  // Add object attribute: component reference to pads (mainly usefull for users)
210  wxString ref = pad->GetParent()->GetReference();
211 
212  gbr_metadata.SetCmpReference( ref );
214  }
215 
216  if( hole_descr.m_Hole_Shape )
217  {
218  #if 0 // set to 1 to use flashed oblong holes.
219  // Currently not possible for hole orient != 0 or 90 deg
220  // Use flashed oblong hole
221  plotter.FlashPadOval( hole_pos, hole_descr.m_Hole_Size,
222  hole_descr.m_Hole_Orient, FILLED, &gbr_metadata );
223  #else
224  // Use routing for oblong hole (Slots)
225  wxPoint start, end;
227  hole_descr.m_Hole_Orient, start, end );
228  int width = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
229 
230  if ( width == 0 )
231  continue;
232 
233  plotter.ThickSegment( start+hole_pos, end+hole_pos,
234  width, FILLED, &gbr_metadata );
235  #endif
236  }
237  else
238  {
239  int diam = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
240  plotter.FlashPadCircle( hole_pos, diam, FILLED, &gbr_metadata );
241  }
242 
243  holes_count++;
244  }
245 
246  plotter.EndPlot();
247 
248  return holes_count;
249 }
BOARD_ITEM * m_ItemParent
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:164
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
void UseX2NetAttributes(bool aEnable)
Definition: plotter.h:1309
aperture used for pads oblong holes in drill files
Definition: gbr_metadata.h:105
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
virtual void EndBlock(void *aData) override
calling this function allows one to define the end of a group of drawing items the group is started b...
print info associated to a component (TO.C attribute)
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:77
static void convertOblong2Segment(wxSize aSize, double aOrient, wxPoint &aStart, wxPoint &aEnd)
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:170
void AddGerberX2Header(PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode)
Calculates some X2 attributes, as defined in the Gerber file format specification J4 (chapter 5) and ...
Definition: pcbplot.cpp:282
void UseX2format(bool aEnable)
Definition: plotter.h:1308
aperture used for via holes in drill files
Definition: gbr_metadata.h:103
aperture used for castellated pads in drill files
Definition: gbr_metadata.h:101
void AddLineToHeader(const wxString &aExtraString)
Function AddLineToHeader Add a line to the list of free lines to print at the beginning of the file.
Definition: plotter.h:179
virtual void FlashPadOval(const wxPoint &pos, const wxSize &size, double orient, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled oval flashes are handled as aperture in the 90 degree positions only.
virtual bool StartPlot() override
Function StartPlot Write GERBER header to file initialize global variable g_Plot_PlotOutputFile.
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:444
a pad with a castellated through hole
Definition: pad_shapes.h:103
#define NULL
aperture used for pad holes in drill files
Definition: gbr_metadata.h:104
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
PAD_PROP_T GetProperty() const
Definition: class_pad.h:341
const wxString BuildFileFunctionAttributeString(DRILL_LAYER_PAIR aLayerPair, bool aIsNpth, bool aCompatNCdrill=false) const
virtual void FlashPadCircle(const wxPoint &pos, int diametre, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
MODULE * GetParent() const
Definition: class_pad.h:111
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
virtual bool EndPlot() override
#define IU_PER_MILS
Definition: plotter.cpp:138
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false) override
Function SetGerberCoordinatesFormat selection of Gerber units and resolution (number of digits in man...
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:160
std::vector< HOLE_INFO > m_holeListBuffer
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:192

References AddGerberX2Header(), PLOTTER::AddLineToHeader(), GENDRILL_WRITER_BASE::BuildFileFunctionAttributeString(), convertOblong2Segment(), 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, D_PAD::GetParent(), D_PAD::GetProperty(), MODULE::GetReference(), 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, NULL, PLOTTER::OpenFile(), PAD_PROP_CASTELLATED, GBR_METADATA::SetApertureAttrib(), GBR_METADATA::SetCmpReference(), PLOTTER::SetCreator(), GERBER_PLOTTER::SetGerberCoordinatesFormat(), GBR_METADATA::SetNetAttribType(), GERBER_PLOTTER::SetViewport(), GERBER_PLOTTER::StartPlot(), GERBER_PLOTTER::ThickSegment(), GERBER_PLOTTER::UseX2format(), and GERBER_PLOTTER::UseX2NetAttributes().

Referenced by CreateDrillandMapFilesSet().

◆ CreateMapFilesSet()

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

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:153
#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, GENDRILL_WRITER_BASE::buildHolesList(), F_Cu, GENDRILL_WRITER_BASE::genDrillMapFile(), GetChars(), 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, and REPORTER::Report().

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

◆ genDrillMapFile()

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

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

68 {
69  // Remark:
70  // Hole list must be created before calling this function, by buildHolesList(),
71  // for the right holes set (PTH, NPTH, buried/blind vias ...)
72 
73  double scale = 1.0;
74  wxPoint offset;
75  PLOTTER* plotter = NULL;
76  PAGE_INFO dummy( PAGE_INFO::A4, false );
77  int bottom_limit = 0; // Y coord limit of page. 0 mean do not use
78 
79  PCB_PLOT_PARAMS plot_opts; // starts plotting with default options
80 
81  LOCALE_IO toggle; // use standard C notation for float numbers
82 
83  const PAGE_INFO& page_info = m_pageInfo ? *m_pageInfo : dummy;
84 
85  // Calculate dimensions and center of PCB
87 
88  // Calculate the scale for the format type, scale 1 in HPGL, drawing on
89  // an A4 sheet in PS, + text description of symbols
90  switch( aFormat )
91  {
93  offset = GetOffset();
94  plotter = new GERBER_PLOTTER();
95  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
96  plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm
97  break;
98 
99  case PLOT_FORMAT::HPGL: // Scale for HPGL format.
100  {
101  HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER;
102  plotter = hpgl_plotter;
103  hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() );
104  hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() );
105  plotter->SetPageSettings( page_info );
106  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
107  }
108  break;
109 
110 
111  default:
112  wxASSERT( false );
114 
115  case PLOT_FORMAT::PDF:
116  case PLOT_FORMAT::POST:
117  case PLOT_FORMAT::SVG:
118  {
119  PAGE_INFO pageA4( wxT( "A4" ) );
120  wxSize pageSizeIU = pageA4.GetSizeIU();
121 
122  // Reserve a 10 mm margin around the page.
123  int margin = Millimeter2iu( 10 );
124 
125  // Calculate a scaling factor to print the board on the sheet
126  double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
127 
128  // We should print the list of drill sizes, so reserve room for it
129  // 60% height for board 40% height for list
130  int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
131  double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
132 
133  scale = std::min( Xscale, Yscale );
134 
135  // Experience shows the scale should not to large, because texts
136  // create problem (can be to big or too small).
137  // So the scale is clipped at 3.0;
138  scale = std::min( scale, 3.0 );
139 
140  offset.x = KiROUND( double( bbbox.Centre().x ) - ( pageSizeIU.x / 2.0 ) / scale );
141  offset.y = KiROUND( double( bbbox.Centre().y ) - ( ypagesize_for_board / 2.0 ) / scale );
142 
143  bottom_limit = ( pageSizeIU.y - margin ) / scale;
144 
145  if( aFormat == PLOT_FORMAT::SVG )
146  plotter = new SVG_PLOTTER;
147  else if( aFormat == PLOT_FORMAT::PDF )
148  plotter = new PDF_PLOTTER;
149  else
150  plotter = new PS_PLOTTER;
151 
152  plotter->SetPageSettings( pageA4 );
153  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
154  }
155  break;
156 
157  case PLOT_FORMAT::DXF:
158  {
159  DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
160 
161  if( m_unitsMetric )
163  else
165 
166  plotter = dxf_plotter;
167  plotter->SetPageSettings( page_info );
168  plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
169  }
170  break;
171  }
172 
173  plotter->SetCreator( wxT( "PCBNEW" ) );
174  plotter->SetColorMode( false );
175 
176  KIGFX::PCB_RENDER_SETTINGS renderSettings;
177  renderSettings.SetDefaultPenWidth( Millimeter2iu( 0.2 ) );
178 
179  plotter->SetRenderSettings( &renderSettings );
180 
181  if( !plotter->OpenFile( aFullFileName ) )
182  {
183  delete plotter;
184  return false;
185  }
186 
187  plotter->StartPlot();
188 
189  // Draw items on edge layer (not all, only items useful for drill map
190  BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
191  itemplotter.SetLayerSet( Edge_Cuts );
192 
193  for( auto PtStruct : m_pcb->Drawings() )
194  {
195  switch( PtStruct->Type() )
196  {
197  case PCB_LINE_T:
198  itemplotter.PlotDrawSegment( (DRAWSEGMENT*) PtStruct );
199  break;
200 
201  case PCB_TEXT_T:
202  itemplotter.PlotTextePcb( (TEXTE_PCB*) PtStruct );
203  break;
204 
205  case PCB_DIMENSION_T:
206  case PCB_TARGET_T:
207  case PCB_MARKER_T: // do not draw
208  default:
209  break;
210  }
211  }
212 
213  int plotX, plotY, TextWidth;
214  int intervalle = 0;
215  char line[1024];
216  wxString msg;
217  int textmarginaftersymbol = Millimeter2iu( 2 );
218 
219  // Set Drill Symbols width
220  plotter->SetCurrentLineWidth( -1 );
221 
222  // Plot board outlines and drill map
223  plotDrillMarks( plotter );
224 
225  // Print a list of symbols used.
226  int charSize = Millimeter2iu( 2 ); // text size in IUs
227  // real char scale will be 1/scale, because the global plot scale is scale
228  // for scale < 1.0 ( plot bigger actual size)
229  // Therefore charScale = 1.0 / scale keep the initial charSize
230  // (for scale < 1 we use the global scaling factor: the board must be plotted
231  // smaller than the actual size)
232  double charScale = std::min( 1.0, 1.0 / scale );
233 
234  TextWidth = KiROUND( ( charSize * charScale ) / 10.0 ); // Set text width (thickness)
235  intervalle = KiROUND( charSize * charScale ) + TextWidth;
236 
237  // Trace information.
238  plotX = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
239  plotY = bbbox.GetBottom() + intervalle;
240 
241  // Plot title "Info"
242  wxString Text = wxT( "Drill Map:" );
243  plotter->Text( wxPoint( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, 0,
244  wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
245  GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false );
246 
247  // For some formats (PS, PDF SVG) we plot the drill size list on more than one column
248  // because the list must be contained inside the printed page
249  // (others formats do not have a defined page size)
250  int max_line_len = 0; // The max line len in iu of the currently plotte column
251 
252  for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
253  {
254  DRILL_TOOL& tool = m_toolListBuffer[ii];
255 
256  if( tool.m_TotalCount == 0 )
257  continue;
258 
259  plotY += intervalle;
260 
261  // Ensure there are room to plot the line
262  if( bottom_limit && plotY+intervalle > bottom_limit )
263  {
264  plotY = bbbox.GetBottom() + intervalle;
265  plotX += max_line_len + Millimeter2iu( 10 );//column_width;
266  max_line_len = 0;
267  }
268 
269  int plot_diam = KiROUND( tool.m_Diameter );
270  // For markers plotted with the comment, keep marker size <= text height
271  plot_diam = std::min( plot_diam, KiROUND( charSize * charScale ) );
272  int x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
273  int y = KiROUND( plotY + charSize * charScale );
274 
275  plotter->SetCurrentLineWidth( getMarkerBestPenSize( plot_diam ) );
276  plotter->Marker( wxPoint( x, y ), plot_diam, ii );
277  plotter->SetCurrentLineWidth( -1 );
278 
279  // List the diameter of each drill in mm and inches.
280  sprintf( line, "%3.3fmm / %2.4f\" ", diameter_in_mm( tool.m_Diameter ),
281  diameter_in_inches( tool.m_Diameter ) );
282 
283  msg = FROM_UTF8( line );
284 
285  // Now list how many holes and ovals are associated with each drill.
286  if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
287  sprintf( line, "(1 hole)" );
288  else if( tool.m_TotalCount == 1 ) // && ( toolm_OvalCount == 1 )
289  sprintf( line, "(1 slot)" );
290  else if( tool.m_OvalCount == 0 )
291  sprintf( line, "(%d holes)", tool.m_TotalCount );
292  else if( tool.m_OvalCount == 1 )
293  sprintf( line, "(%d holes + 1 slot)", tool.m_TotalCount - 1 );
294  else // if ( toolm_OvalCount > 1 )
295  sprintf( line, "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount,
296  tool.m_OvalCount );
297 
298  msg += FROM_UTF8( line );
299 
300  if( tool.m_Hole_NotPlated )
301  msg += wxT( " (not plated)" );
302 
303  plotter->Text( wxPoint( plotX, y ), COLOR4D::UNSPECIFIED, msg, 0,
304  wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
305  GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false );
306 
307  intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );
308 
309  if( intervalle < ( plot_diam + ( 1 * IU_PER_MM / scale ) + TextWidth ) )
310  intervalle = plot_diam + ( 1 * IU_PER_MM / scale ) + TextWidth;
311 
312  // Evaluate the text horizontal size, to know the maximal column size
313  // This is a rough value, but ok to create a new column to plot next texts
314  int text_len = msg.Len() * ( ( charSize * charScale ) + TextWidth );
315  max_line_len = std::max( max_line_len, text_len + plot_diam );
316  }
317 
318  plotter->EndPlot();
319  delete plotter;
320 
321  return true;
322 }
double diameter_in_inches(double ius)
double diameter_in_mm(double ius)
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:164
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:114
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
virtual bool StartPlot()=0
int GetX() const
Definition: eda_rect.h:111
static constexpr double IU_PER_MM
Mock up a conversion function.
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:824
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:77
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:143
int getMarkerBestPenSize(int aMarkerDiameter)
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:146
int GetWidth() const
Definition: eda_rect.h:119
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
int GetHPGLPenSpeed() const
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:88
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:460
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:222
PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:64
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:636
static const wxChar A4[]
Definition: page_info.h:65
wxPoint GetOffset()
Return the plot offset (usually the position of the auxiliary axis.
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:332
int GetHPGLPenNum() const
Base plotter engine class.
Definition: plotter.h:114
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:641
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define IU_PER_MILS
Definition: plotter.cpp:138
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:68
wxPoint Centre() const
Definition: eda_rect.h:62
bool plotDrillMarks(PLOTTER *aPlotter)
Helper function.
void SetDefaultPenWidth(int aWidth)
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
static constexpr int Millimeter2iu(double mm)
DRAWINGS & Drawings()
Definition: class_board.h:282
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: plotter.h:149
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(), getMarkerBestPenSize(), GENDRILL_WRITER_BASE::GetOffset(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, HPGL, DXF_PLOTTER::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(), 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(), GENDRILL_WRITER_BASE::plotDrillMarks(), BRDITEMS_PLOTTER::PlotTextePcb(), POST, scale, PLOTTER::SetColorMode(), PLOTTER::SetCreator(), PLOTTER::SetCurrentLineWidth(), KIGFX::RENDER_SETTINGS::SetDefaultPenWidth(), PLOTTER::SetGerberCoordinatesFormat(), BRDITEMS_PLOTTER::SetLayerSet(), PLOTTER::SetPageSettings(), HPGL_PLOTTER::SetPenNumber(), HPGL_PLOTTER::SetPenSpeed(), PLOTTER::SetRenderSettings(), DXF_PLOTTER::SetUnits(), PLOTTER::SetViewport(), PLOTTER::StartPlot(), SVG, PLOTTER::Text(), wxPoint::x, and wxPoint::y.

Referenced by GENDRILL_WRITER_BASE::CreateMapFilesSet().

◆ GenDrillReportFile()

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

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

326 {
327  FILE_OUTPUTFORMATTER out( aFullFileName );
328 
329  static const char separator[] =
330  " =============================================================\n";
331 
332  wxASSERT( m_pcb );
333 
334  unsigned totalHoleCount;
335  wxString brdFilename = m_pcb->GetFileName();
336 
337  std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
338 
339  out.Print( 0, "Drill report for %s\n", TO_UTF8( brdFilename ) );
340  out.Print( 0, "Created on %s\n\n", TO_UTF8( DateAndTime() ) );
341 
342  // Output the cu layer stackup, so layer name references make sense.
343  out.Print( 0, "Copper Layer Stackup:\n" );
344  out.Print( 0, separator );
345 
347 
348  int conventional_layer_num = 1;
349 
350  for( LSEQ seq = cu.Seq(); seq; ++seq, ++conventional_layer_num )
351  {
352  out.Print( 0, " L%-2d: %-25s %s\n",
353  conventional_layer_num,
354  TO_UTF8( m_pcb->GetLayerName( *seq ) ),
355  layerName( *seq ).c_str() // generic layer name
356  );
357  }
358 
359  out.Print( 0, "\n\n" );
360 
361  /* output hole lists:
362  * 1 - through holes
363  * 2 - for partial holes only: by layer starting and ending pair
364  * 3 - Non Plated through holes
365  */
366 
367  bool buildNPTHlist = false; // First pass: build PTH list only
368 
369  // in this loop are plated only:
370  for( unsigned pair_ndx = 0; pair_ndx < hole_sets.size(); ++pair_ndx )
371  {
372  DRILL_LAYER_PAIR pair = hole_sets[pair_ndx];
373 
374  buildHolesList( pair, buildNPTHlist );
375 
376  if( pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
377  {
378  out.Print( 0, "Drill file '%s' contains\n",
379  TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
380 
381  out.Print( 0, " plated through holes:\n" );
382  out.Print( 0, separator );
383  totalHoleCount = printToolSummary( out, false );
384  out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
385  }
386  else // blind/buried
387  {
388  out.Print( 0, "Drill file '%s' contains\n",
389  TO_UTF8( getDrillFileName( pair, false, m_merge_PTH_NPTH ) ) );
390 
391  out.Print( 0, " holes connecting layer pair: '%s and %s' (%s vias):\n",
392  TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.first ) ) ),
393  TO_UTF8( m_pcb->GetLayerName( ToLAYER_ID( pair.second ) ) ),
394  pair.first == F_Cu || pair.second == B_Cu ? "blind" : "buried"
395  );
396 
397  out.Print( 0, separator );
398  totalHoleCount = printToolSummary( out, false );
399  out.Print( 0, " Total plated holes count %u\n", totalHoleCount );
400  }
401 
402  out.Print( 0, "\n\n" );
403  }
404 
405  // NPTHoles. Generate the full list (pads+vias) if PTH and NPTH are merged,
406  // or only the NPTH list (which never has vias)
407  if( !m_merge_PTH_NPTH )
408  buildNPTHlist = true;
409 
410  buildHolesList( DRILL_LAYER_PAIR( F_Cu, B_Cu ), buildNPTHlist );
411 
412  // nothing wrong with an empty NPTH file in report.
413  if( m_merge_PTH_NPTH )
414  out.Print( 0, "Not plated through holes are merged with plated holes\n" );
415  else
416  out.Print( 0, "Drill file '%s' contains\n",
418  true, m_merge_PTH_NPTH ) ) );
419 
420  out.Print( 0, " unplated through holes:\n" );
421  out.Print( 0, separator );
422  totalHoleCount = printToolSummary( out, true );
423  out.Print( 0, " Total unplated holes count %u\n", totalHoleCount );
424 
425  return true;
426 }
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:714
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.
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:262
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:100
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:851
wxString DateAndTime()
Definition: string.cpp:400

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
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 from GENDRILL_WRITER_BASE.

Definition at line 289 of file gendrill_gerber_writer.cpp.

291 {
292  // Gerber files extension is always .gbr.
293  // Therefore, to mark drill files, add "-drl" to the filename.
294  wxFileName fname( GENDRILL_WRITER_BASE::getDrillFileName( aPair, aNPTH, aMerge_PTH_NPTH ) );
295  fname.SetName( fname.GetName() + "-drl" );
296 
297  return fname.GetFullPath();
298 }
virtual const wxString getDrillFileName(DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const

References GENDRILL_WRITER_BASE::getDrillFileName().

Referenced by CreateDrillandMapFilesSet().

◆ getHolesCount()

int GENDRILL_WRITER_BASE::getHolesCount ( ) const
inlineprotectedinherited

◆ GetOffset()

wxPoint GENDRILL_WRITER_BASE::GetOffset ( )
inlineinherited

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 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 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:101
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:596
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(), GENDRILL_WRITER_BASE::m_pcb, and PCB_VIA_T.

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

◆ layerName()

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

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 *result, const char *format,...)
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 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

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 GENDRILL_WRITER_BASE::layerName().

Referenced by GENDRILL_WRITER_BASE::getDrillFileName().

◆ plotDrillMarks()

bool GENDRILL_WRITER_BASE::plotDrillMarks ( PLOTTER aPlotter)
protectedinherited

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

430 {
431  // Plot the drill map:
432  wxPoint pos;
433 
434  for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
435  {
436  const HOLE_INFO& hole = m_holeListBuffer[ii];
437  pos = hole.m_Hole_Pos;
438 
439  // Gives a good line thickness to have a good marker shape:
441 
442  // Always plot the drill symbol (for slots identifies the needed cutter!
443  aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
444 
445  if( hole.m_Hole_Shape != 0 )
446  {
447  wxSize oblong_size = hole.m_Hole_Size;
448  aPlotter->FlashPadOval( pos, oblong_size, hole.m_Hole_Orient, SKETCH, NULL );
449  }
450  }
451 
452  aPlotter->SetCurrentLineWidth( -1 );
453 
454  return true;
455 }
int getMarkerBestPenSize(int aMarkerDiameter)
#define NULL
void Marker(const wxPoint &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
Definition: plotter.cpp:332
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
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.

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

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile().

◆ printToolSummary()

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

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

459 {
460  unsigned totalHoleCount = 0;
461 
462  for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
463  {
464  const DRILL_TOOL& tool = m_toolListBuffer[ii];
465 
466  if( aSummaryNPTH && !tool.m_Hole_NotPlated )
467  continue;
468 
469  if( !aSummaryNPTH && tool.m_Hole_NotPlated )
470  continue;
471 
472  // List the tool number assigned to each drill,
473  // in mm then in inches.
474  int tool_number = ii+1;
475  out.Print( 0, " T%d %2.2fmm %2.3f\" ", tool_number,
476  diameter_in_mm( tool.m_Diameter ),
477  diameter_in_inches( tool.m_Diameter ) );
478 
479  // Now list how many holes and ovals are associated with each drill.
480  if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) )
481  out.Print( 0, "(1 hole)\n" );
482  else if( tool.m_TotalCount == 1 )
483  out.Print( 0, "(1 hole) (with 1 slot)\n" );
484  else if( tool.m_OvalCount == 0 )
485  out.Print( 0, "(%d holes)\n", tool.m_TotalCount );
486  else if( tool.m_OvalCount == 1 )
487  out.Print( 0, "(%d holes) (with 1 slot)\n", tool.m_TotalCount );
488  else // tool.m_OvalCount > 1
489  out.Print( 0, "(%d holes) (with %d slots)\n",
490  tool.m_TotalCount, tool.m_OvalCount );
491 
492  totalHoleCount += tool.m_TotalCount;
493  }
494 
495  out.Print( 0, "\n" );
496 
497  return totalHoleCount;
498 }
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, 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)

Function SetFormat Initialize internal parameters to match the given format.

Parameters
aRightDigits= number of digits for mantissa part of coordinates (5 or 6)

Definition at line 278 of file gendrill_gerber_writer.cpp.

279 {
280  /* Set conversion scale depending on drill file units */
281  m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm
282 
283  // Set precison (unit is mm).
284  m_precision.m_lhs = 4;
285  m_precision.m_rhs = aRightDigits == 6 ? 6 : 5;
286 }
static constexpr double IU_PER_MM
Mock up a conversion function.

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

Referenced by DIALOG_GENDRILL::OnGenReportFile().

◆ SetOptions()

void GERBER_WRITER::SetOptions ( wxPoint  aOffset)
inline

Function SetOptions Initialize internal parameters to match drill options note: PTH and NPTH are always separate files in Gerber format.

Parameters
aOffset= drill coordinates offset

Definition at line 62 of file gendrill_gerber_writer.h.

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

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

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 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: