Commit 339dd0da authored by Wayne Stambaugh's avatar Wayne Stambaugh

Coding policy fixes.

parent a1b065c1
......@@ -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,
const PAGE_INFO& aSheet,
PlotFormat aFormat )
......@@ -239,8 +233,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
plotY += intervalle;
plot_diam = KiROUND( m_toolListBuffer[ii].m_Diameter );
x = KiROUND( plotX - textmarginaftersymbol * charScale
- plot_diam / 2.0 );
x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
y = KiROUND( plotY + charSize * charScale );
plotter->Marker( wxPoint( x, y ), plot_diam, ii );
......@@ -267,9 +260,8 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
m_toolListBuffer[ii].m_OvalCount );
msg += FROM_UTF8( line );
plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR,
msg,
0, wxSize( KiROUND( charSize * charScale ),
plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR, msg, 0,
wxSize( KiROUND( charSize * charScale ),
KiROUND( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
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 )
{
unsigned totalHoleCount;
......@@ -461,17 +407,17 @@ bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
return true;
}
// Helper function to plot drill marks:
bool EXCELLON_WRITER::PlotDrillMarks( PLOTTER* aPlotter )
{
// Plot the drill map:
wxPoint pos;
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
{
pos = m_holeListBuffer[ii].m_Hole_Pos;
/* Always plot the drill symbol (for slots identifies the needed
* cutter!) */
// Always plot the drill symbol (for slots identifies the needed cutter!
aPlotter->Marker( pos, m_holeListBuffer[ii].m_Hole_Diameter,
m_holeListBuffer[ii].m_Tool_Reference - 1 );
......
......@@ -69,11 +69,7 @@
*/
/*
* Create the drill file in EXCELLON format
* return hole count
*/
int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
int EXCELLON_WRITER::CreateDrillFile( FILE* aFile )
{
m_file = aFile;
......@@ -100,7 +96,8 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
fputs( "G90\n", m_file ); // Absolute mode
fputs( "G05\n", m_file ); // Drill mode
/* Units : */
// Units :
if( !m_minimalHeader )
{
if( m_unitsDecimal )
......@@ -112,12 +109,14 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
/* Read the hole file and generate lines for normal holes (oblong
* holes will be created later) */
int tool_reference = -2;
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
if( 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++ )
{
HOLE_INFO& hole_descr = m_holeListBuffer[ii];
if( hole_descr.m_Hole_Shape == 0 )
continue; // wait for oblong holes
if( tool_reference != hole_descr.m_Tool_Reference )
{
tool_reference = hole_descr.m_Tool_Reference;
fprintf( m_file, "T%d\n", tool_reference );
}
diam = std::min( hole_descr.m_Hole_Size.x,
hole_descr.m_Hole_Size.y );
diam = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
if( diam == 0 )
continue;
......@@ -166,20 +167,23 @@ int EXCELLON_WRITER::CreateDrillFile( FILE * aFile )
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;
y0 -= delta; yf += delta;
y0 -= delta;
yf += delta;
}
else
{
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( &xf, &yf, xc, yc, hole_descr.m_Hole_Orient );
if( !m_mirror )
{
y0 *= -1; yf *= -1;
y0 *= -1;
yf *= -1;
}
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"
* command to the line: */
for( int kk = 0; line[kk] != 0; kk++ )
{
if( line[kk] == '\n' || line[kk] =='\r' )
line[kk] = 0;
}
fputs( line, m_file );
fputs( "G85", m_file ); // add the "G85" command
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,
zeros_fmt aZerosFmt,
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 )
{
wxString xs, ys;
......@@ -277,8 +270,10 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
//Remove useless trailing 0
while( xs.Last() == '0' )
xs.RemoveLast();
while( ys.Last() == '0' )
ys.RemoveLast();
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
break;
......@@ -301,6 +296,7 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
if( aCoordX < 0 )
xpad++;
if( aCoordY < 0 )
ypad++;
......@@ -308,10 +304,12 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
size_t j = xs.Len() - 1;
while( xs[j] == '0' && j )
xs.Truncate( j-- );
j = ys.Len() - 1;
while( ys[j] == '0' && j )
ys.Truncate( j-- );
......@@ -327,8 +325,10 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
if( aCoordX < 0 )
xpad++;
if( aCoordY < 0 )
ypad++;
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 ) );
......@@ -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()
{
fputs( "M48\n", m_file ); // The beginning of a header
......@@ -361,13 +354,14 @@ void EXCELLON_WRITER::WriteEXCELLONHeader()
msg << m_precision.GetPrecisionString();
else
msg << wxT( "-:-" ); // in decimal format the precision is irrelevant
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
* because some EXCELLON parsers do not like non ascii values
* so we use ONLY english (ascii) strings.
* 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
*/
......@@ -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,
int aLastLayer,
bool aExcludeThroughHoles,
......@@ -467,8 +449,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
return;
}
/* build hole list for vias
*/
// build hole list for vias
if( ! aGenerateNPTH_list ) // vias are always plated !
{
for( TRACK* track = m_pcb->m_Track; track; track = track->Next() )
......@@ -546,7 +527,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), CmpHoleDiameterValue );
// 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) */
DRILL_TOOL new_tool( 0 );
unsigned jj;
......
......@@ -60,7 +60,7 @@ public:
* 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
* because they are drilled after the Pcb process is finished.
*/
*/
class HOLE_INFO
{
public:
......@@ -74,6 +74,7 @@ public:
LAYER_NUM m_Hole_Top_Layer; // hole ending layer (usually front layer):
// m_Hole_First_Layer < m_Hole_Last_Layer
bool m_Hole_NotPlated; // hole not plated. Must be in a specific drill file
public:
HOLE_INFO()
{
......@@ -88,7 +89,7 @@ class DRILL_PRECISION
{
public:
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 )
{
......@@ -120,26 +121,28 @@ public:
SUPPRESS_TRAILING,
KEEP_ZEROS
};
wxPoint m_Offset; // offset coordinates
bool m_ShortHeader; // true to generate the smallest header (strip comments)
private:
FILE* m_file; // The output file
BOARD* m_pcb;
bool m_minimalHeader; // True to use minimal haeder
bool m_minimalHeader; // True to use minimal header
// in excellon file (strip comments)
bool m_unitsDecimal; // true = decimal, false = inches
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
// (i.e inches or mm)
bool m_mirror;
wxPoint m_offset; // Drill offset ooordinates
wxPoint m_offset; // Drill offset coordinates
bool m_mergePTHNPTH;
std::vector<HOLE_INFO> m_holeListBuffer; // Buffer containing holes
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_pcb = aPcb;
......@@ -158,7 +161,7 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
/**
* Return the plot offset (usually the position
* of the auxiliaty axis
* of the auxiliary axis
*/
const wxPoint GetOffset() { return m_offset; }
......@@ -210,8 +213,7 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
/**
* Function CreateDrillFile
* Creates an Excellon drill file
* @param aFile = an opened file to write to
* will be closed by CreateDrillFile
* @param aFile = an opened file to write to will be closed by CreateDrillFile
* @return hole count
*/
int CreateDrillFile( FILE * aFile );
......@@ -222,6 +224,47 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
* 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
*
* @param aFullFileName : the name of the file to create
* 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
* Plot a map of drill marks for holes.
* @param aFullFileNameWithoutExt : the full filename of the file to create,
* without extension (will be added accordint ti the format)
* @param aSheet : the paper sheet touse for plot
* without extension (will be added according to the format)
* @param aSheet : the paper sheet to use for plot
* @param aFormat : one of the supported plot formats (see enum PlotFormat )
*/
bool GenDrillMapFile( const wxString& aFullFileNameWithoutExt,
const PAGE_INFO& aSheet,
PlotFormat aFormat );
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 WriteEXCELLONEndOfFile();
/* Created a line like:
* X48000Y19500
* According to the selected format
*/
void WriteCoordinates( char* aLine, double aCoordX, double aCoordY );
/** Helper function.
......@@ -257,6 +313,4 @@ private:
};
#endif // #ifndef _GENDRILL_EXCELLON_WRITER_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment