Pcbnew: fix drill file naming issue.

On windows when the project path include a remote volume name (\\NAME),
the volume name does not get cleared by calling wxFileName.SetDir( "" ).
This caused the volume name to be prepended to the file name when
calling wxFileName::GetFullPath().  Use wxFileName::GetFullName()
which resolves the issue.

Fix some minor grammar errors.

Fix some minor coding policy issues.

Fixes lp:1606240

https://bugs.launchpad.net/kicad/+bug/1606240
This commit is contained in:
Wayne Stambaugh 2016-10-07 10:57:45 -04:00
parent 7a4f1685df
commit abf33cce68
2 changed files with 35 additions and 55 deletions

View File

@ -6,7 +6,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -131,8 +131,8 @@ void DIALOG_GENDRILL::InitDisplayParams()
m_Check_Mirror->SetValue( m_Mirror ); m_Check_Mirror->SetValue( m_Mirror );
m_Check_Merge_PTH_NPTH->SetValue( m_Merge_PTH_NPTH ); m_Check_Merge_PTH_NPTH->SetValue( m_Merge_PTH_NPTH );
m_Choice_Drill_Map->SetSelection( m_mapFileType ); m_Choice_Drill_Map->SetSelection( m_mapFileType );
m_ViaDrillValue->SetLabel( _( "Use Netclasses values" ) ); m_ViaDrillValue->SetLabel( _( "Use Netclass values" ) );
m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) ); m_MicroViaDrillValue->SetLabel( _( "Use Netclass values" ) );
// See if we have some buried vias or/and microvias, and display // See if we have some buried vias or/and microvias, and display
// microvias drill value if so // microvias drill value if so
@ -243,6 +243,7 @@ void DIALOG_GENDRILL::OnSelDrillUnitsSelected( wxCommandEvent& event )
UpdatePrecisionOptions(); UpdatePrecisionOptions();
} }
void DIALOG_GENDRILL::OnGenMapFile( wxCommandEvent& event ) void DIALOG_GENDRILL::OnGenMapFile( wxCommandEvent& event )
{ {
GenDrillAndMapFiles( false, true); GenDrillAndMapFiles( false, true);
@ -302,8 +303,7 @@ void DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
fn = Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() ); fn = Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() );
wxString defaultPath = fn.GetPathWithSep(); wxString defaultPath = fn.GetPathWithSep();
wxString msg; wxString msg;
msg.Printf( _( "Do you want to use a path relative to\n'%s'" ), msg.Printf( _( "Do you want to use a path relative to\n'%s'" ), GetChars( defaultPath ) );
GetChars( defaultPath ) );
wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ), wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
@ -352,7 +352,7 @@ void DIALOG_GENDRILL::SetParams()
} }
void DIALOG_GENDRILL::GenDrillAndMapFiles(bool aGenDrill, bool aGenMap) void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap )
{ {
UpdateConfig(); // set params and Save drill options UpdateConfig(); // set params and Save drill options
@ -365,21 +365,19 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles(bool aGenDrill, bool aGenMap)
PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER, PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER,
PLOT_FORMAT_DXF, PLOT_FORMAT_SVG, PLOT_FORMAT_PDF PLOT_FORMAT_DXF, PLOT_FORMAT_SVG, PLOT_FORMAT_PDF
}; };
unsigned choice = (unsigned) m_Choice_Drill_Map->GetSelection(); unsigned choice = (unsigned) m_Choice_Drill_Map->GetSelection();
if( choice >= DIM( filefmt ) ) if( choice >= DIM( filefmt ) )
choice = 1; choice = 1;
EXCELLON_WRITER excellonWriter( m_parent->GetBoard() ); EXCELLON_WRITER excellonWriter( m_parent->GetBoard() );
excellonWriter.SetFormat( !m_UnitDrillIsInch, excellonWriter.SetFormat( !m_UnitDrillIsInch, (EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat,
(EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat,
m_Precision.m_lhs, m_Precision.m_rhs ); m_Precision.m_lhs, m_Precision.m_rhs );
excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset, m_Merge_PTH_NPTH );
m_FileDrillOffset, m_Merge_PTH_NPTH );
excellonWriter.SetMapFileFormat( filefmt[choice] ); excellonWriter.SetMapFileFormat( filefmt[choice] );
excellonWriter.CreateDrillandMapFilesSet( defaultPath, aGenDrill, aGenMap, excellonWriter.CreateDrillandMapFilesSet( defaultPath, aGenDrill, aGenMap, &reporter );
&reporter);
} }
@ -397,19 +395,16 @@ void DIALOG_GENDRILL::OnGenReportFile( wxCommandEvent& event )
if( defaultPath.IsEmpty() ) if( defaultPath.IsEmpty() )
defaultPath = wxStandardPaths::Get().GetDocumentsDir(); defaultPath = wxStandardPaths::Get().GetDocumentsDir();
wxFileDialog dlg( this, _( "Save Drill Report File" ), defaultPath, wxFileDialog dlg( this, _( "Save Drill Report File" ), defaultPath, fn.GetFullName(),
fn.GetFullName(), wxGetTranslation( ReportFileWildcard ), wxGetTranslation( ReportFileWildcard ), wxFD_SAVE );
wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
EXCELLON_WRITER excellonWriter( m_parent->GetBoard() ); EXCELLON_WRITER excellonWriter( m_parent->GetBoard() );
excellonWriter.SetFormat( !m_UnitDrillIsInch, excellonWriter.SetFormat( !m_UnitDrillIsInch, (EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat,
(EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat,
m_Precision.m_lhs, m_Precision.m_rhs ); m_Precision.m_lhs, m_Precision.m_rhs );
excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset, m_Merge_PTH_NPTH );
m_FileDrillOffset, m_Merge_PTH_NPTH );
bool success = excellonWriter.GenDrillReportFile( dlg.GetPath() ); bool success = excellonWriter.GenDrillReportFile( dlg.GetPath() );

View File

@ -8,7 +8,7 @@
* *
* Copyright (C) 2015 Jean_Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 2015 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -80,8 +80,8 @@ EXCELLON_WRITER::EXCELLON_WRITER( BOARD* aPcb )
void EXCELLON_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory, void EXCELLON_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory,
bool aGenDrill, bool aGenMap, bool aGenDrill, bool aGenMap,
REPORTER * aReporter ) REPORTER * aReporter )
{ {
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
@ -93,10 +93,10 @@ void EXCELLON_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory,
hole_sets.push_back( LAYER_PAIR( F_Cu, B_Cu ) ); hole_sets.push_back( LAYER_PAIR( F_Cu, B_Cu ) );
for( std::vector<LAYER_PAIR>::const_iterator it = hole_sets.begin(); for( std::vector<LAYER_PAIR>::const_iterator it = hole_sets.begin();
it != hole_sets.end(); ++it ) it != hole_sets.end(); ++it )
{ {
LAYER_PAIR pair = *it; LAYER_PAIR pair = *it;
// For separate drill files, the last layer pair is the NPTH dril file. // For separate drill files, the last layer pair is the NPTH drill file.
bool doing_npth = m_merge_PTH_NPTH ? false : ( it == hole_sets.end() - 1 ); bool doing_npth = m_merge_PTH_NPTH ? false : ( it == hole_sets.end() - 1 );
BuildHolesList( pair, doing_npth ); BuildHolesList( pair, doing_npth );
@ -118,8 +118,7 @@ void EXCELLON_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory,
{ {
if( aReporter ) if( aReporter )
{ {
msg.Printf( _( "** Unable to create %s **\n" ), msg.Printf( _( "** Unable to create %s **\n" ), GetChars( fullFilename ) );
GetChars( fullFilename ) );
aReporter->Report( msg ); aReporter->Report( msg );
} }
break; break;
@ -168,17 +167,6 @@ void EXCELLON_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory,
} }
/*
* Creates the drill files in EXCELLON format
* Number format:
* - Floating point format
* - integer format
* - integer format: "Trailing Zero" ( TZ ) or "Leading Zero"
* Units
* - Decimal
* - Metric
*/
int EXCELLON_WRITER::CreateDrillFile( FILE* aFile ) int EXCELLON_WRITER::CreateDrillFile( FILE* aFile )
{ {
m_file = aFile; m_file = aFile;
@ -207,25 +195,23 @@ int EXCELLON_WRITER::CreateDrillFile( FILE* aFile )
DRILL_TOOL& tool_descr = m_toolListBuffer[ii]; DRILL_TOOL& tool_descr = m_toolListBuffer[ii];
#ifdef WRITE_PTH_NPTH_COMMENT #ifdef WRITE_PTH_NPTH_COMMENT
if( writePTHcomment && !tool_descr.m_Hole_NotPlated ) if( writePTHcomment && !tool_descr.m_Hole_NotPlated )
{ {
writePTHcomment = false; writePTHcomment = false;
fprintf( m_file, ";TYPE=PLATED\n" ); fprintf( m_file, ";TYPE=PLATED\n" );
} }
if( writeNPTHcomment && tool_descr.m_Hole_NotPlated ) if( writeNPTHcomment && tool_descr.m_Hole_NotPlated )
{ {
writeNPTHcomment = false; writeNPTHcomment = false;
fprintf( m_file, ";TYPE=NON_PLATED\n" ); fprintf( m_file, ";TYPE=NON_PLATED\n" );
} }
#endif #endif
fprintf( m_file, "T%dC%.3f\n", ii + 1, fprintf( m_file, "T%dC%.3f\n", ii + 1, tool_descr.m_Diameter * m_conversionUnits );
tool_descr.m_Diameter * m_conversionUnits );
} }
fputs( "%\n", m_file ); // End of header info fputs( "%\n", m_file ); // End of header info
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
@ -485,8 +471,7 @@ void EXCELLON_WRITER::WriteEXCELLONHeader()
wxString msg; wxString msg;
msg << wxT("KiCad") << wxT( " " ) << GetBuildVersion(); msg << wxT("KiCad") << wxT( " " ) << GetBuildVersion();
fprintf( m_file, ";DRILL file {%s} date %s\n", TO_UTF8( msg ), fprintf( m_file, ";DRILL file {%s} date %s\n", TO_UTF8( msg ), TO_UTF8( DateAndTime() ) );
TO_UTF8( DateAndTime() ) );
msg = wxT( ";FORMAT={" ); msg = wxT( ";FORMAT={" );
// Print precision: // Print precision:
@ -754,7 +739,8 @@ const std::string EXCELLON_WRITER::layerPairName( LAYER_PAIR aPair ) const
} }
const wxString EXCELLON_WRITER::drillFileName( LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH ) const const wxString EXCELLON_WRITER::drillFileName( LAYER_PAIR aPair, bool aNPTH,
bool aMerge_PTH_NPTH ) const
{ {
wxASSERT( m_pcb ); wxASSERT( m_pcb );
@ -777,10 +763,9 @@ const wxString EXCELLON_WRITER::drillFileName( LAYER_PAIR aPair, bool aNPTH, boo
wxFileName fn = m_pcb->GetFileName(); wxFileName fn = m_pcb->GetFileName();
fn.SetName( fn.GetName() + extend ); fn.SetName( fn.GetName() + extend );
fn.SetPath( "" );
fn.SetExt( DrillFileExtension ); fn.SetExt( DrillFileExtension );
wxString ret = fn.GetFullPath(); // show me in debugger wxString ret = fn.GetFullName(); // show me in debugger
return ret; return ret;
} }