kicad/pcbnew/exporters/gendrill_Excellon_writer.cpp

556 lines
17 KiB
C++
Raw Normal View History

/**
* @file gendrill_Excellon_writer.cpp
* @brief Functions to create EXCELLON drill files and report files.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @see for EXCELLON format, see:
* http://www.excellon.com/manuals/program.htm
* and the CNC-7 manual.
*/
#include <fctsys.h>
2008-01-16 20:37:50 +00:00
#include <vector>
#include <plot_common.h>
#include <trigo.h>
#include <macros.h>
#include <kicad_string.h>
#include <wxPcbStruct.h>
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
#include <pgm_base.h>
#include <build_version.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <pcbplot.h>
#include <pcbnew.h>
#include <gendrill_Excellon_writer.h>
#include <wildcards_and_files_ext.h>
#include <dialog_gendrill.h> // Dialog box for drill file generation
/*
2008-01-14 19:24:41 +00:00
* Creates the drill files in EXCELLON format
* Number format:
* - Floating point format
* - integer format
* - integer format: "Trailing Zero" ( TZ ) or "Leading Zero"
2008-01-14 19:24:41 +00:00
* Units
* - Decimal
* - Metric
2008-01-16 20:37:50 +00:00
*/
2014-03-06 18:38:39 +00:00
int EXCELLON_WRITER::CreateDrillFile( FILE* aFile )
{
m_file = aFile;
int diam, holes_count;
int x0, y0, xf, yf, xc, yc;
double xt, yt;
char line[1024];
SetLocaleTo_C_standard(); // Use the standard notation for double numbers
WriteEXCELLONHeader();
2008-01-16 20:37:50 +00:00
holes_count = 0;
/* Write the tool list */
for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
{
DRILL_TOOL& tool_descr = m_toolListBuffer[ii];
fprintf( m_file, "T%dC%.3f\n", ii + 1,
tool_descr.m_Diameter * m_conversionUnits );
}
fputs( "%\n", m_file ); // End of header info
fputs( "G90\n", m_file ); // Absolute mode
fputs( "G05\n", m_file ); // Drill mode
2014-03-06 18:38:39 +00:00
// Units :
if( !m_minimalHeader )
{
if( m_unitsDecimal )
fputs( "M71\n", m_file ); /* M71 = metric mode */
else
fputs( "M72\n", m_file ); /* M72 = inch mode */
}
/* Read the hole file and generate lines for normal holes (oblong
* holes will be created later) */
int tool_reference = -2;
2014-03-06 18:38:39 +00:00
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
{
HOLE_INFO& hole_descr = m_holeListBuffer[ii];
if( hole_descr.m_Hole_Shape )
continue; // oblong holes will be created later
2014-03-06 18:38:39 +00:00
if( tool_reference != hole_descr.m_Tool_Reference )
{
tool_reference = hole_descr.m_Tool_Reference;
fprintf( m_file, "T%d\n", tool_reference );
}
x0 = hole_descr.m_Hole_Pos.x - m_offset.x;
y0 = hole_descr.m_Hole_Pos.y - m_offset.y;
if( !m_mirror )
y0 *= -1;
xt = x0 * m_conversionUnits;
yt = y0 * m_conversionUnits;
WriteCoordinates( line, xt, yt );
fputs( line, m_file );
holes_count++;
}
2008-01-16 20:37:50 +00:00
/* Read the hole file and generate lines for normal holes (oblong holes
* will be created later) */
tool_reference = -2; // set to a value not used for
// m_holeListBuffer[ii].m_Tool_Reference
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
{
HOLE_INFO& hole_descr = m_holeListBuffer[ii];
2014-03-06 18:38:39 +00:00
if( hole_descr.m_Hole_Shape == 0 )
continue; // wait for oblong holes
2014-03-06 18:38:39 +00:00
if( tool_reference != hole_descr.m_Tool_Reference )
{
tool_reference = hole_descr.m_Tool_Reference;
fprintf( m_file, "T%d\n", tool_reference );
2008-01-16 20:37:50 +00:00
}
2014-03-06 18:38:39 +00:00
diam = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
if( diam == 0 )
continue;
/* Compute the hole coordinates: */
xc = x0 = xf = hole_descr.m_Hole_Pos.x - m_offset.x;
yc = y0 = yf = hole_descr.m_Hole_Pos.y - m_offset.y;
/* Compute the start and end coordinates for the shape */
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;
2014-03-06 18:38:39 +00:00
y0 -= delta;
yf += delta;
}
else
{
int delta = ( hole_descr.m_Hole_Size.x - hole_descr.m_Hole_Size.y ) / 2;
2014-03-06 18:38:39 +00:00
x0 -= delta;
xf += delta;
}
2014-03-06 18:38:39 +00:00
RotatePoint( &x0, &y0, xc, yc, hole_descr.m_Hole_Orient );
RotatePoint( &xf, &yf, xc, yc, hole_descr.m_Hole_Orient );
if( !m_mirror )
{
2014-03-06 18:38:39 +00:00
y0 *= -1;
yf *= -1;
}
xt = x0 * m_conversionUnits;
yt = y0 * m_conversionUnits;
WriteCoordinates( line, xt, yt );
/* remove the '\n' from end of line, because we must add the "G85"
* command to the line: */
for( int kk = 0; line[kk] != 0; kk++ )
2014-03-06 18:38:39 +00:00
{
if( line[kk] == '\n' || line[kk] =='\r' )
line[kk] = 0;
2014-03-06 18:38:39 +00:00
}
2008-01-16 20:37:50 +00:00
fputs( line, m_file );
fputs( "G85", m_file ); // add the "G85" command
xt = xf * m_conversionUnits;
yt = yf * m_conversionUnits;
WriteCoordinates( line, xt, yt );
2008-01-16 20:37:50 +00:00
fputs( line, m_file );
fputs( "G05\n", m_file );
holes_count++;
}
WriteEXCELLONEndOfFile();
SetLocaleTo_Default(); // Revert to locale double notation
2008-01-16 20:37:50 +00:00
return holes_count;
}
void EXCELLON_WRITER::SetFormat( bool aMetric,
zeros_fmt aZerosFmt,
int aLeftDigits,
int aRightDigits )
{
m_unitsDecimal = aMetric;
m_zeroFormat = aZerosFmt;
/* Set conversion scale depending on drill file units */
if( m_unitsDecimal )
m_conversionUnits = 1.0 / IU_PER_MM; // EXCELLON units = mm
else
m_conversionUnits = 0.001 / IU_PER_MILS; // EXCELLON units = INCHES
m_precision.m_lhs = aLeftDigits;
m_precision.m_rhs = aRightDigits;
}
void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoordY )
{
wxString xs, ys;
int xpad = m_precision.m_lhs + m_precision.m_rhs;
int ypad = xpad;
switch( m_zeroFormat )
{
default:
case DECIMAL_FORMAT:
/* In Excellon files, resolution is 1/1000 mm or 1/10000 inch (0.1 mil)
* Although in decimal format, Excellon specifications do not specify
* clearly the resolution. However it seems to be 1/1000mm or 0.1 mil
* like in non decimal formats, so we trunk coordinates to 3 or 4 digits in mantissa
* Decimal format just prohibit useless leading 0:
* 0.45 or .45 is right, but 00.54 is incorrect.
*/
if( m_unitsDecimal )
{
// resolution is 1/1000 mm
xs.Printf( wxT( "%.3f" ), aCoordX );
ys.Printf( wxT( "%.3f" ), aCoordY );
}
else
{
// resolution is 1/10000 inch
xs.Printf( wxT( "%.4f" ), aCoordX );
ys.Printf( wxT( "%.4f" ), aCoordY );
}
//Remove useless trailing 0
while( xs.Last() == '0' )
xs.RemoveLast();
2014-03-06 18:38:39 +00:00
while( ys.Last() == '0' )
ys.RemoveLast();
2014-03-06 18:38:39 +00:00
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
break;
case SUPPRESS_LEADING:
for( int i = 0; i< m_precision.m_rhs; i++ )
{
aCoordX *= 10; aCoordY *= 10;
}
// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
2012-04-19 06:55:45 +00:00
sprintf( aLine, "X%dY%d\n", KiROUND( aCoordX ), KiROUND( aCoordY ) );
break;
case SUPPRESS_TRAILING:
{
for( int i = 0; i < m_precision.m_rhs; i++ )
{
aCoordX *= 10;
aCoordY *= 10;
}
if( aCoordX < 0 )
xpad++;
2014-03-06 18:38:39 +00:00
if( aCoordY < 0 )
ypad++;
// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
2012-04-19 06:55:45 +00:00
xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) );
ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
size_t j = xs.Len() - 1;
2014-03-06 18:38:39 +00:00
while( xs[j] == '0' && j )
xs.Truncate( j-- );
j = ys.Len() - 1;
2014-03-06 18:38:39 +00:00
while( ys[j] == '0' && j )
ys.Truncate( j-- );
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
break;
}
case KEEP_ZEROS:
for( int i = 0; i< m_precision.m_rhs; i++ )
{
aCoordX *= 10; aCoordY *= 10;
}
if( aCoordX < 0 )
xpad++;
2014-03-06 18:38:39 +00:00
if( aCoordY < 0 )
ypad++;
2014-03-06 18:38:39 +00:00
// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
2012-04-19 06:55:45 +00:00
xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) );
ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
break;
}
}
void EXCELLON_WRITER::WriteEXCELLONHeader()
{
fputs( "M48\n", m_file ); // The beginning of a header
if( !m_minimalHeader )
{
// The next 2 lines in EXCELLON files are comments:
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
wxString msg = Pgm().App().GetAppName() + wxT( " " ) + GetBuildVersion();
fprintf( m_file, ";DRILL file {%s} date %s\n", TO_UTF8( msg ),
TO_UTF8( DateAndTime() ) );
2008-08-25 13:26:48 +00:00
msg = wxT( ";FORMAT={" );
// Print precision:
if( m_zeroFormat != DECIMAL_FORMAT )
msg << m_precision.GetPrecisionString();
else
msg << wxT( "-:-" ); // in decimal format the precision is irrelevant
2014-03-06 18:38:39 +00:00
msg << wxT( "/ absolute / " );
msg << ( m_unitsDecimal ? wxT( "metric" ) : wxT( "inch" ) );
/* Adding numbers notation format.
* this is same as m_Choice_Zeros_Format strings, but NOT translated
2014-03-06 18:38:39 +00:00
* because some EXCELLON parsers do not like non ASCII values
* so we use ONLY English (ASCII) strings.
* if new options are added in m_Choice_Zeros_Format, they must also
* be added here
*/
msg << wxT( " / " );
const wxString zero_fmt[4] =
{
wxT( "decimal" ),
wxT( "suppress leading zeros" ),
wxT( "suppress trailing zeros" ),
wxT( "keep zeros" )
};
msg << zero_fmt[m_zeroFormat];
msg << wxT( "}\n" );
fputs( TO_UTF8( msg ), m_file );
fputs( "FMAT,2\n", m_file ); // Use Format 2 commands (version used since 1979)
}
fputs( m_unitsDecimal ? "METRIC" : "INCH", m_file );
switch( m_zeroFormat )
{
case SUPPRESS_LEADING:
case DECIMAL_FORMAT:
fputs( ",TZ\n", m_file );
break;
case SUPPRESS_TRAILING:
fputs( ",LZ\n", m_file );
break;
case KEEP_ZEROS:
fputs( ",TZ\n", m_file ); // TZ is acceptable when all zeros are kept
break;
}
}
void EXCELLON_WRITER::WriteEXCELLONEndOfFile()
{
//add if minimal here
fputs( "T0\nM30\n", m_file );
fclose( m_file );
}
/* Helper function for sorting hole list.
* Compare function used for sorting holes by increasing diameter value
* and X value
*/
static bool CmpHoleDiameterValue( const HOLE_INFO& a, const HOLE_INFO& b )
{
if( a.m_Hole_Diameter != b.m_Hole_Diameter )
return a.m_Hole_Diameter < b.m_Hole_Diameter;
if( a.m_Hole_Pos.x != b.m_Hole_Pos.x )
return a.m_Hole_Pos.x < b.m_Hole_Pos.x;
return a.m_Hole_Pos.y < b.m_Hole_Pos.y;
}
void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
int aLastLayer,
bool aExcludeThroughHoles,
bool aGenerateNPTH_list,
bool aMergePTHNPTH )
{
HOLE_INFO new_hole;
int hole_value;
m_holeListBuffer.clear();
m_toolListBuffer.clear();
if( (aFirstLayer >= 0) && (aLastLayer >= 0) )
{
if( aFirstLayer > aLastLayer )
EXCHG( aFirstLayer, aLastLayer );
}
if ( aGenerateNPTH_list && aMergePTHNPTH )
{
return;
}
2014-03-06 18:38:39 +00:00
// build hole list for vias
if( ! aGenerateNPTH_list ) // vias are always plated !
{
for( VIA* via = GetFirstVia( m_pcb->m_Track ); via; via = GetFirstVia( via->Next() ) )
{
hole_value = via->GetDrillValue();
if( hole_value == 0 ) // Should not occur.
continue;
new_hole.m_Tool_Reference = -1; // Flag value for Not initialized
new_hole.m_Hole_Orient = 0;
new_hole.m_Hole_Diameter = hole_value;
new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
new_hole.m_Hole_Shape = 0; // hole shape: round
new_hole.m_Hole_Pos = via->GetStart();
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
via->LayerPair( &new_hole.m_Hole_Top_Layer, &new_hole.m_Hole_Bottom_Layer );
// LayerPair return params with m_Hole_Bottom_Layer > m_Hole_Top_Layer
// (remember top layer = 0 and bottom layer = 31 for through hole vias)
if( (new_hole.m_Hole_Top_Layer < aFirstLayer) && (aFirstLayer >= 0) )
continue;
if( (new_hole.m_Hole_Bottom_Layer > aLastLayer) && (aLastLayer >= 0) )
continue;
if( aExcludeThroughHoles && (new_hole.m_Hole_Bottom_Layer == B_Cu)
&& (new_hole.m_Hole_Top_Layer == F_Cu) )
continue;
m_holeListBuffer.push_back( new_hole );
}
}
// build hole list for pads (assumed always through holes)
if( !aExcludeThroughHoles || aGenerateNPTH_list )
{
for( MODULE* module = m_pcb->m_Modules; module; module = module->Next() )
{
// Read and analyse pads
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{
if( ! aGenerateNPTH_list && pad->GetAttribute() == PAD_HOLE_NOT_PLATED && ! aMergePTHNPTH )
continue;
if( aGenerateNPTH_list && pad->GetAttribute() != PAD_HOLE_NOT_PLATED )
continue;
if( pad->GetDrillSize().x == 0 )
continue;
new_hole.m_Hole_NotPlated = (pad->GetAttribute() == PAD_HOLE_NOT_PLATED);
new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
new_hole.m_Hole_Orient = pad->GetOrientation();
2014-03-06 18:38:39 +00:00
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_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
if( pad->GetDrillShape() != PAD_DRILL_CIRCLE )
new_hole.m_Hole_Shape = 1; // oval flag set
2014-03-06 18:38:39 +00:00
new_hole.m_Hole_Size = pad->GetDrillSize();
new_hole.m_Hole_Pos = pad->GetPosition(); // hole position
new_hole.m_Hole_Bottom_Layer = B_Cu;
new_hole.m_Hole_Top_Layer = F_Cu;// pad holes are through holes
m_holeListBuffer.push_back( new_hole );
}
}
}
// Sort holes per increasing diameter value
sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), CmpHoleDiameterValue );
// build the tool list
2014-03-06 18:38:39 +00:00
int LastHole = -1; /* Set to not initialized (this is a value not used
* for m_holeListBuffer[ii].m_Hole_Diameter) */
DRILL_TOOL new_tool( 0 );
unsigned jj;
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
{
if( m_holeListBuffer[ii].m_Hole_Diameter != LastHole )
{
new_tool.m_Diameter = ( m_holeListBuffer[ii].m_Hole_Diameter );
m_toolListBuffer.push_back( new_tool );
LastHole = new_tool.m_Diameter;
}
jj = m_toolListBuffer.size();
if( jj == 0 )
2014-03-06 18:38:39 +00:00
continue; // Should not occurs
m_holeListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1)
m_toolListBuffer.back().m_TotalCount++;
if( m_holeListBuffer[ii].m_Hole_Shape )
m_toolListBuffer.back().m_OvalCount++;
}
}