Coding policy fixes.

This commit is contained in:
Wayne Stambaugh 2014-03-06 13:38:39 -05:00
parent a1b065c190
commit 339dd0daf2
3 changed files with 163 additions and 182 deletions

View File

@ -55,12 +55,6 @@ inline double diameter_in_mm( double ius )
} }
/* Creates a hole map of the board in HPGL, POSTSCRIPT or other supported formats
* Each hole size has a the drill mark symbol (circle, cross X, cross + ...) up to
* PLOTTER::MARKER_COUNT different values.
* If more than PLOTTER::MARKER_COUNT different values,
* these other vaules share the same mark
*/
bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName, bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
const PAGE_INFO& aSheet, const PAGE_INFO& aSheet,
PlotFormat aFormat ) PlotFormat aFormat )
@ -87,15 +81,15 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
break; break;
case PLOT_FORMAT_HPGL: // Scale for HPGL format. case PLOT_FORMAT_HPGL: // Scale for HPGL format.
{ {
HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER; HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER;
plotter = hpgl_plotter; plotter = hpgl_plotter;
hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() ); hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() );
hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() ); hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() );
hpgl_plotter->SetPenOverlap( 0 ); hpgl_plotter->SetPenOverlap( 0 );
plotter->SetPageSettings( aSheet ); plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
} }
break; break;
@ -104,59 +98,59 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
// fall through // fall through
case PLOT_FORMAT_PDF: case PLOT_FORMAT_PDF:
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
{ {
PAGE_INFO pageA4( wxT( "A4" ) ); PAGE_INFO pageA4( wxT( "A4" ) );
wxSize pageSizeIU = pageA4.GetSizeIU(); wxSize pageSizeIU = pageA4.GetSizeIU();
// Reserve a margin around the page. // Reserve a margin around the page.
int margin = KiROUND( 20 * IU_PER_MM ); int margin = KiROUND( 20 * IU_PER_MM );
// Calculate a scaling factor to print the board on the sheet // Calculate a scaling factor to print the board on the sheet
double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth(); double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
// We should print the list of drill sizes, so reserve room for it // We should print the list of drill sizes, so reserve room for it
// 60% height for board 40% height for list // 60% height for board 40% height for list
int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 ); int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight(); double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
scale = std::min( Xscale, Yscale ); scale = std::min( Xscale, Yscale );
// Experience shows the scale should not to large, because texts // Experience shows the scale should not to large, because texts
// create problem (can be to big or too small). // create problem (can be to big or too small).
// So the scale is clipped at 3.0; // So the scale is clipped at 3.0;
scale = std::min( scale, 3.0 ); scale = std::min( scale, 3.0 );
offset.x = KiROUND( double( bbbox.Centre().x ) - offset.x = KiROUND( double( bbbox.Centre().x ) -
( pageSizeIU.x / 2.0 ) / scale ); ( pageSizeIU.x / 2.0 ) / scale );
offset.y = KiROUND( double( bbbox.Centre().y ) - offset.y = KiROUND( double( bbbox.Centre().y ) -
( ypagesize_for_board / 2.0 ) / scale ); ( ypagesize_for_board / 2.0 ) / scale );
if( aFormat == PLOT_FORMAT_PDF ) if( aFormat == PLOT_FORMAT_PDF )
plotter = new PDF_PLOTTER; plotter = new PDF_PLOTTER;
else else
plotter = new PS_PLOTTER; plotter = new PS_PLOTTER;
plotter->SetPageSettings( pageA4 ); plotter->SetPageSettings( pageA4 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
} }
break; break;
case PLOT_FORMAT_DXF: case PLOT_FORMAT_DXF:
{ {
DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER; DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
plotter = dxf_plotter; plotter = dxf_plotter;
plotter->SetPageSettings( aSheet ); plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
} }
break; break;
case PLOT_FORMAT_SVG: case PLOT_FORMAT_SVG:
{ {
SVG_PLOTTER* svg_plotter = new SVG_PLOTTER; SVG_PLOTTER* svg_plotter = new SVG_PLOTTER;
plotter = svg_plotter; plotter = svg_plotter;
plotter->SetPageSettings( aSheet ); plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
} }
break; break;
} }
@ -239,8 +233,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
plotY += intervalle; plotY += intervalle;
plot_diam = KiROUND( m_toolListBuffer[ii].m_Diameter ); plot_diam = KiROUND( m_toolListBuffer[ii].m_Diameter );
x = KiROUND( plotX - textmarginaftersymbol * charScale x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
- plot_diam / 2.0 );
y = KiROUND( plotY + charSize * charScale ); y = KiROUND( plotY + charSize * charScale );
plotter->Marker( wxPoint( x, y ), plot_diam, ii ); plotter->Marker( wxPoint( x, y ), plot_diam, ii );
@ -267,10 +260,9 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
m_toolListBuffer[ii].m_OvalCount ); m_toolListBuffer[ii].m_OvalCount );
msg += FROM_UTF8( line ); msg += FROM_UTF8( line );
plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR, plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR, msg, 0,
msg, wxSize( KiROUND( charSize * charScale ),
0, wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
KiROUND( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
TextWidth, false, false ); TextWidth, false, false );
@ -287,52 +279,6 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
} }
/*
* Create a plain text report file giving a list of drill values and drill count
* for through holes, oblong holes, and for buried vias,
* drill values and drill count per layer pair
*/
/* 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
*
*/
bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName ) bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
{ {
unsigned totalHoleCount; unsigned totalHoleCount;
@ -360,7 +306,7 @@ bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
for( ; ; ) for( ; ; )
{ {
BuildHolesList( layer1, layer2, BuildHolesList( layer1, layer2,
gen_through_holes ? false : true, gen_NPTH_holes, false); gen_through_holes ? false : true, gen_NPTH_holes, false);
totalHoleCount = 0; totalHoleCount = 0;
@ -461,17 +407,17 @@ bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
return true; return true;
} }
// Helper function to plot drill marks:
bool EXCELLON_WRITER::PlotDrillMarks( PLOTTER* aPlotter ) bool EXCELLON_WRITER::PlotDrillMarks( PLOTTER* aPlotter )
{ {
// Plot the drill map: // Plot the drill map:
wxPoint pos; wxPoint pos;
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
{ {
pos = m_holeListBuffer[ii].m_Hole_Pos; pos = m_holeListBuffer[ii].m_Hole_Pos;
/* Always plot the drill symbol (for slots identifies the needed // Always plot the drill symbol (for slots identifies the needed cutter!
* cutter!) */
aPlotter->Marker( pos, m_holeListBuffer[ii].m_Hole_Diameter, aPlotter->Marker( pos, m_holeListBuffer[ii].m_Hole_Diameter,
m_holeListBuffer[ii].m_Tool_Reference - 1 ); m_holeListBuffer[ii].m_Tool_Reference - 1 );

View File

@ -69,11 +69,7 @@
*/ */
/* int EXCELLON_WRITER::CreateDrillFile( FILE* aFile )
* Create the drill file in EXCELLON format
* return hole count
*/
int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
{ {
m_file = aFile; m_file = aFile;
@ -100,7 +96,8 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
fputs( "G90\n", m_file ); // Absolute mode fputs( "G90\n", m_file ); // Absolute mode
fputs( "G05\n", m_file ); // Drill mode fputs( "G05\n", m_file ); // Drill mode
/* Units : */
// Units :
if( !m_minimalHeader ) if( !m_minimalHeader )
{ {
if( m_unitsDecimal ) if( m_unitsDecimal )
@ -112,12 +109,14 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
/* Read the hole file and generate lines for normal holes (oblong /* Read the hole file and generate lines for normal holes (oblong
* holes will be created later) */ * holes will be created later) */
int tool_reference = -2; int tool_reference = -2;
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
{ {
HOLE_INFO& hole_descr = m_holeListBuffer[ii]; HOLE_INFO& hole_descr = m_holeListBuffer[ii];
if( hole_descr.m_Hole_Shape ) if( hole_descr.m_Hole_Shape )
continue; // oblong holes will be created later continue; // oblong holes will be created later
if( tool_reference != hole_descr.m_Tool_Reference ) if( tool_reference != hole_descr.m_Tool_Reference )
{ {
tool_reference = hole_descr.m_Tool_Reference; tool_reference = hole_descr.m_Tool_Reference;
@ -145,16 +144,18 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
{ {
HOLE_INFO& hole_descr = m_holeListBuffer[ii]; HOLE_INFO& hole_descr = m_holeListBuffer[ii];
if( hole_descr.m_Hole_Shape == 0 ) if( hole_descr.m_Hole_Shape == 0 )
continue; // wait for oblong holes continue; // wait for oblong holes
if( tool_reference != hole_descr.m_Tool_Reference ) if( tool_reference != hole_descr.m_Tool_Reference )
{ {
tool_reference = hole_descr.m_Tool_Reference; tool_reference = hole_descr.m_Tool_Reference;
fprintf( m_file, "T%d\n", tool_reference ); fprintf( m_file, "T%d\n", tool_reference );
} }
diam = std::min( hole_descr.m_Hole_Size.x, diam = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
hole_descr.m_Hole_Size.y );
if( diam == 0 ) if( diam == 0 )
continue; continue;
@ -166,20 +167,23 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
if( hole_descr.m_Hole_Size.x < hole_descr.m_Hole_Size.y ) if( hole_descr.m_Hole_Size.x < hole_descr.m_Hole_Size.y )
{ {
int delta = ( hole_descr.m_Hole_Size.y - hole_descr.m_Hole_Size.x ) / 2; int delta = ( hole_descr.m_Hole_Size.y - hole_descr.m_Hole_Size.x ) / 2;
y0 -= delta; yf += delta; y0 -= delta;
yf += delta;
} }
else else
{ {
int delta = ( hole_descr.m_Hole_Size.x - hole_descr.m_Hole_Size.y ) / 2; int delta = ( hole_descr.m_Hole_Size.x - hole_descr.m_Hole_Size.y ) / 2;
x0 -= delta; xf += delta; x0 -= delta;
xf += delta;
} }
RotatePoint( &x0, &y0, xc, yc, hole_descr.m_Hole_Orient ); RotatePoint( &x0, &y0, xc, yc, hole_descr.m_Hole_Orient );
RotatePoint( &xf, &yf, xc, yc, hole_descr.m_Hole_Orient ); RotatePoint( &xf, &yf, xc, yc, hole_descr.m_Hole_Orient );
if( !m_mirror ) if( !m_mirror )
{ {
y0 *= -1; yf *= -1; y0 *= -1;
yf *= -1;
} }
xt = x0 * m_conversionUnits; xt = x0 * m_conversionUnits;
@ -189,11 +193,12 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
/* remove the '\n' from end of line, because we must add the "G85" /* remove the '\n' from end of line, because we must add the "G85"
* command to the line: */ * command to the line: */
for( int kk = 0; line[kk] != 0; kk++ ) for( int kk = 0; line[kk] != 0; kk++ )
{
if( line[kk] == '\n' || line[kk] =='\r' ) if( line[kk] == '\n' || line[kk] =='\r' )
line[kk] = 0; line[kk] = 0;
}
fputs( line, m_file ); fputs( line, m_file );
fputs( "G85", m_file ); // add the "G85" command fputs( "G85", m_file ); // add the "G85" command
xt = xf * m_conversionUnits; xt = xf * m_conversionUnits;
@ -213,14 +218,6 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
} }
/**
* SetFormat
* Initialize internal parameters to match the given format
* @param aMetric = true for metric coordinates, false for imperial units
* @param aZerosFmt = DECIMAL_FORMAT, SUPPRESS_LEADING, SUPPRESS_TRAILING, KEEP_ZEROS
* @param aLeftDigits = number of digits for integer part of coordinates
* @param aRightDigits = number of digits for mantissa part of coordinates
*/
void EXCELLON_WRITER::SetFormat( bool aMetric, void EXCELLON_WRITER::SetFormat( bool aMetric,
zeros_fmt aZerosFmt, zeros_fmt aZerosFmt,
int aLeftDigits, int aLeftDigits,
@ -240,10 +237,6 @@ void EXCELLON_WRITER::SetFormat( bool aMetric,
} }
/* Created a line like:
* X48000Y19500
* According to the selected format
*/
void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoordY ) void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoordY )
{ {
wxString xs, ys; wxString xs, ys;
@ -277,8 +270,10 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
//Remove useless trailing 0 //Remove useless trailing 0
while( xs.Last() == '0' ) while( xs.Last() == '0' )
xs.RemoveLast(); xs.RemoveLast();
while( ys.Last() == '0' ) while( ys.Last() == '0' )
ys.RemoveLast(); ys.RemoveLast();
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) ); sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
break; break;
@ -301,6 +296,7 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
if( aCoordX < 0 ) if( aCoordX < 0 )
xpad++; xpad++;
if( aCoordY < 0 ) if( aCoordY < 0 )
ypad++; ypad++;
@ -308,10 +304,12 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) ); ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
size_t j = xs.Len() - 1; size_t j = xs.Len() - 1;
while( xs[j] == '0' && j ) while( xs[j] == '0' && j )
xs.Truncate( j-- ); xs.Truncate( j-- );
j = ys.Len() - 1; j = ys.Len() - 1;
while( ys[j] == '0' && j ) while( ys[j] == '0' && j )
ys.Truncate( j-- ); ys.Truncate( j-- );
@ -327,8 +325,10 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
if( aCoordX < 0 ) if( aCoordX < 0 )
xpad++; xpad++;
if( aCoordY < 0 ) if( aCoordY < 0 )
ypad++; ypad++;
xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) ); xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) );
ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) ); ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) ); sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
@ -337,13 +337,6 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
} }
/* Print the DRILL file header. The full header is:
* M48
* ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35
* ;FORMAT={ <precision> / absolute / <units> / <numbers format>}
* FMAT,2
* INCH,TZ
*/
void EXCELLON_WRITER::WriteEXCELLONHeader() void EXCELLON_WRITER::WriteEXCELLONHeader()
{ {
fputs( "M48\n", m_file ); // The beginning of a header fputs( "M48\n", m_file ); // The beginning of a header
@ -361,13 +354,14 @@ void EXCELLON_WRITER::WriteEXCELLONHeader()
msg << m_precision.GetPrecisionString(); msg << m_precision.GetPrecisionString();
else else
msg << wxT( "-:-" ); // in decimal format the precision is irrelevant msg << wxT( "-:-" ); // in decimal format the precision is irrelevant
msg << wxT( "/ absolute / " ); msg << wxT( "/ absolute / " );
msg << ( m_unitsDecimal ? wxT( "metric" ) : wxT( "inch" ) ); msg << ( m_unitsDecimal ? wxT( "metric" ) : wxT( "inch" ) );
/* Adding numbers notation format. /* Adding numbers notation format.
* this is same as m_Choice_Zeros_Format strings, but NOT translated * this is same as m_Choice_Zeros_Format strings, but NOT translated
* because some EXCELLON parsers do not like non ascii values * because some EXCELLON parsers do not like non ASCII values
* so we use ONLY english (ascii) strings. * so we use ONLY English (ASCII) strings.
* if new options are added in m_Choice_Zeros_Format, they must also * if new options are added in m_Choice_Zeros_Format, they must also
* be added here * be added here
*/ */
@ -432,18 +426,6 @@ static bool CmpHoleDiameterValue( const HOLE_INFO& a, const HOLE_INFO& b )
} }
/*
* Create the list of holes and tools for a given board
* The list is sorted by increasing drill values
* Only holes from aFirstLayer to aLastLayer copper layers are listed (for vias, because pad holes are always through holes)
* param aFirstLayer = first layer to consider. if < 0 aFirstLayer is ignored (used to creates report file)
* param aLastLayer = last layer to consider. if < 0 aLastLayer is ignored
* param aExcludeThroughHoles : if true, exclude through holes ( pads and vias through )
* param aGenerateNPTH_list :
* true to create NPTH only list (with no plated holes)
* false to created plated holes list (with no NPTH )
* param aMergePTHNPTH : if true, merge PTH and NPTH holes into one file by treating all holes as PTH
*/
void EXCELLON_WRITER::BuildHolesList( int aFirstLayer, void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
int aLastLayer, int aLastLayer,
bool aExcludeThroughHoles, bool aExcludeThroughHoles,
@ -467,8 +449,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
return; return;
} }
/* build hole list for vias // build hole list for vias
*/
if( ! aGenerateNPTH_list ) // vias are always plated ! if( ! aGenerateNPTH_list ) // vias are always plated !
{ {
for( TRACK* track = m_pcb->m_Track; track; track = track->Next() ) for( TRACK* track = m_pcb->m_Track; track; track = track->Next() )
@ -526,15 +507,15 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
new_hole.m_Hole_NotPlated = (pad->GetAttribute() == PAD_HOLE_NOT_PLATED); new_hole.m_Hole_NotPlated = (pad->GetAttribute() == PAD_HOLE_NOT_PLATED);
new_hole.m_Tool_Reference = -1; // Flag is: Not initialized new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
new_hole.m_Hole_Orient = pad->GetOrientation(); new_hole.m_Hole_Orient = pad->GetOrientation();
new_hole.m_Hole_Shape = 0; // hole shape: round new_hole.m_Hole_Shape = 0; // hole shape: round
new_hole.m_Hole_Diameter = std::min( pad->GetDrillSize().x, pad->GetDrillSize().y ); new_hole.m_Hole_Diameter = std::min( pad->GetDrillSize().x, pad->GetDrillSize().y );
new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter; new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
if( pad->GetDrillShape() != PAD_DRILL_CIRCLE ) if( pad->GetDrillShape() != PAD_DRILL_CIRCLE )
new_hole.m_Hole_Shape = 1; // oval flag set new_hole.m_Hole_Shape = 1; // oval flag set
new_hole.m_Hole_Size = pad->GetDrillSize(); new_hole.m_Hole_Size = pad->GetDrillSize();
new_hole.m_Hole_Pos = pad->GetPosition(); // hole position new_hole.m_Hole_Pos = pad->GetPosition(); // hole position
new_hole.m_Hole_Bottom_Layer = LAYER_N_BACK; new_hole.m_Hole_Bottom_Layer = LAYER_N_BACK;
new_hole.m_Hole_Top_Layer = LAYER_N_FRONT;// pad holes are through holes new_hole.m_Hole_Top_Layer = LAYER_N_FRONT;// pad holes are through holes
m_holeListBuffer.push_back( new_hole ); m_holeListBuffer.push_back( new_hole );
@ -546,7 +527,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), CmpHoleDiameterValue ); sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), CmpHoleDiameterValue );
// build the tool list // build the tool list
int LastHole = -1; /* Set to not initialised (this is a value not used int LastHole = -1; /* Set to not initialized (this is a value not used
* for m_holeListBuffer[ii].m_Hole_Diameter) */ * for m_holeListBuffer[ii].m_Hole_Diameter) */
DRILL_TOOL new_tool( 0 ); DRILL_TOOL new_tool( 0 );
unsigned jj; unsigned jj;
@ -563,7 +544,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
jj = m_toolListBuffer.size(); jj = m_toolListBuffer.size();
if( jj == 0 ) if( jj == 0 )
continue; // Should not occurs continue; // Should not occurs
m_holeListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1) m_holeListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1)

View File

@ -60,7 +60,7 @@ public:
* So we must generate a drill file for each layer pair (adjacent layers) * So we must generate a drill file for each layer pair (adjacent layers)
* Not plated holes are always through holes, and must be output on a specific drill file * Not plated holes are always through holes, and must be output on a specific drill file
* because they are drilled after the Pcb process is finished. * because they are drilled after the Pcb process is finished.
*/ */
class HOLE_INFO class HOLE_INFO
{ {
public: public:
@ -74,6 +74,7 @@ public:
LAYER_NUM m_Hole_Top_Layer; // hole ending layer (usually front layer): LAYER_NUM m_Hole_Top_Layer; // hole ending layer (usually front layer):
// m_Hole_First_Layer < m_Hole_Last_Layer // m_Hole_First_Layer < m_Hole_Last_Layer
bool m_Hole_NotPlated; // hole not plated. Must be in a specific drill file bool m_Hole_NotPlated; // hole not plated. Must be in a specific drill file
public: public:
HOLE_INFO() HOLE_INFO()
{ {
@ -88,7 +89,7 @@ class DRILL_PRECISION
{ {
public: public:
int m_lhs; // Left digit number (integer value of coordinates) int m_lhs; // Left digit number (integer value of coordinates)
int m_rhs; // Right digit number (deciam value of coordinates) int m_rhs; // Right digit number (decimal value of coordinates)
public: DRILL_PRECISION( int l = 2, int r = 4 ) public: DRILL_PRECISION( int l = 2, int r = 4 )
{ {
@ -120,26 +121,28 @@ public:
SUPPRESS_TRAILING, SUPPRESS_TRAILING,
KEEP_ZEROS KEEP_ZEROS
}; };
wxPoint m_Offset; // offset coordinates
bool m_ShortHeader; // true to generate the smallest header (strip comments) wxPoint m_Offset; // offset coordinates
bool m_ShortHeader; // true to generate the smallest header (strip comments)
private: private:
FILE* m_file; // The output file FILE* m_file; // The output file
BOARD* m_pcb; BOARD* m_pcb;
bool m_minimalHeader; // True to use minimal haeder bool m_minimalHeader; // True to use minimal header
// in excellon file (strip comments) // in excellon file (strip comments)
bool m_unitsDecimal; // true = decimal, false = inches bool m_unitsDecimal; // true = decimal, false = inches
zeros_fmt m_zeroFormat; // the zero format option for output file zeros_fmt m_zeroFormat; // the zero format option for output file
DRILL_PRECISION m_precision; // The current coordinate precision (not used in decimat format) DRILL_PRECISION m_precision; // The current coordinate precision (not used in decimal format)
double m_conversionUnits; // scaling factor to convert the board unites to Excellon units double m_conversionUnits; // scaling factor to convert the board unites to Excellon units
// (i.e inches or mm) // (i.e inches or mm)
bool m_mirror; bool m_mirror;
wxPoint m_offset; // Drill offset ooordinates wxPoint m_offset; // Drill offset coordinates
bool m_mergePTHNPTH; bool m_mergePTHNPTH;
std::vector<HOLE_INFO> m_holeListBuffer; // Buffer containing holes std::vector<HOLE_INFO> m_holeListBuffer; // Buffer containing holes
std::vector<DRILL_TOOL> m_toolListBuffer; // Buffer containing tools std::vector<DRILL_TOOL> m_toolListBuffer; // Buffer containing tools
public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset ) public:
EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
{ {
m_file = NULL; m_file = NULL;
m_pcb = aPcb; m_pcb = aPcb;
@ -158,7 +161,7 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
/** /**
* Return the plot offset (usually the position * Return the plot offset (usually the position
* of the auxiliaty axis * of the auxiliary axis
*/ */
const wxPoint GetOffset() { return m_offset; } const wxPoint GetOffset() { return m_offset; }
@ -201,17 +204,16 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
* false to created plated holes list (with no NPTH ) * false to created plated holes list (with no NPTH )
*/ */
void BuildHolesList( int aFirstLayer, int aLastLayer, void BuildHolesList( int aFirstLayer, int aLastLayer,
bool aExcludeThroughHoles, bool aExcludeThroughHoles,
bool aGenerateNPTH_list, bool aGenerateNPTH_list,
bool aMergePTHNPTH ); bool aMergePTHNPTH );
int GetHolesCount() const { return m_holeListBuffer.size(); } int GetHolesCount() const { return m_holeListBuffer.size(); }
/** /**
* Function CreateDrillFile * Function CreateDrillFile
* Creates an Excellon drill file * Creates an Excellon drill file
* @param aFile = an opened file to write to * @param aFile = an opened file to write to will be closed by CreateDrillFile
* will be closed by CreateDrillFile
* @return hole count * @return hole count
*/ */
int CreateDrillFile( FILE * aFile ); int CreateDrillFile( FILE * aFile );
@ -222,6 +224,47 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
* for through holes, oblong holes, and for buried vias, * for through holes, oblong holes, and for buried vias,
* drill values and drill count per layer pair * drill values and drill count per layer pair
* there is only one report for all drill files even when buried or blinds vias exist * 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
*
* @param aFullFileName : the name of the file to create * @param aFullFileName : the name of the file to create
* m_unitsDecimal = false tu use inches, true to use mm in report file * m_unitsDecimal = false tu use inches, true to use mm in report file
* *
@ -233,16 +276,29 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
* Function GenDrillMapFile * Function GenDrillMapFile
* Plot a map of drill marks for holes. * Plot a map of drill marks for holes.
* @param aFullFileNameWithoutExt : the full filename of the file to create, * @param aFullFileNameWithoutExt : the full filename of the file to create,
* without extension (will be added accordint ti the format) * without extension (will be added according to the format)
* @param aSheet : the paper sheet touse for plot * @param aSheet : the paper sheet to use for plot
* @param aFormat : one of the supported plot formats (see enum PlotFormat ) * @param aFormat : one of the supported plot formats (see enum PlotFormat )
*/ */
bool GenDrillMapFile( const wxString& aFullFileNameWithoutExt, bool GenDrillMapFile( const wxString& aFullFileNameWithoutExt,
const PAGE_INFO& aSheet, const PAGE_INFO& aSheet,
PlotFormat aFormat ); PlotFormat aFormat );
private: private:
/* Print the DRILL file header. The full header is:
* M48
* ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35
* ;FORMAT={ <precision> / absolute / <units> / <numbers format>}
* FMAT,2
* INCH,TZ
*/
void WriteEXCELLONHeader(); void WriteEXCELLONHeader();
void WriteEXCELLONEndOfFile(); void WriteEXCELLONEndOfFile();
/* Created a line like:
* X48000Y19500
* According to the selected format
*/
void WriteCoordinates( char* aLine, double aCoordX, double aCoordY ); void WriteCoordinates( char* aLine, double aCoordX, double aCoordY );
/** Helper function. /** Helper function.
@ -257,6 +313,4 @@ private:
}; };
#endif // #ifndef _GENDRILL_EXCELLON_WRITER_ #endif // #ifndef _GENDRILL_EXCELLON_WRITER_