2010-11-24 19:54:59 +00:00
|
|
|
/**
|
2011-09-30 18:15:37 +00:00
|
|
|
* @file gendrill.cpp
|
|
|
|
* @brief Functions to create EXCELLON drill files and report files.
|
2010-11-24 19:54:59 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2010-11-24 19:54:59 +00:00
|
|
|
*
|
2010-11-26 11:55:34 +00:00
|
|
|
* Copyright (C) 1992-2010 Jean_Pierre Charras <jp.charras@ujf-grenoble.fr>
|
2011-09-30 18:15:37 +00:00
|
|
|
* Copyright (C) 1992-2010 KiCad Developers, see change_log.txt for contributors.
|
2010-11-24 19:54:59 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
/**
|
2010-12-14 15:56:30 +00:00
|
|
|
* @see for EXCELLON format, see:
|
2010-11-29 15:05:01 +00:00
|
|
|
* http://www.excellon.com/manuals/program.htm
|
2010-11-24 15:10:33 +00:00
|
|
|
* and the CNC-7 manual.
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <plot_common.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <build_version.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <gendrill.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_gendrill.h> // Dialog box for drill file generation
|
2010-04-30 18:39:10 +00:00
|
|
|
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*
|
2008-01-14 19:24:41 +00:00
|
|
|
* Creates the drill files in EXCELLON format
|
|
|
|
* Number format:
|
|
|
|
* - Floating point format
|
|
|
|
* - integer format
|
2009-11-14 22:15:22 +00:00
|
|
|
* - 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
|
|
|
*
|
2008-01-14 19:24:41 +00:00
|
|
|
* The drill maps can be created in HPGL or PS format
|
2007-09-29 13:31:10 +00:00
|
|
|
*
|
2010-11-24 15:10:33 +00:00
|
|
|
* dialog_gendrill.cpp is the file which handles
|
2009-11-14 22:15:22 +00:00
|
|
|
* the Dialog box for drill file generation
|
2007-09-29 13:31:10 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
static std::vector<DRILL_TOOL> s_ToolListBuffer;
|
2008-01-18 08:54:15 +00:00
|
|
|
static std::vector<HOLE_INFO> s_HoleListBuffer;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-11-26 11:55:34 +00:00
|
|
|
/* This function displays the dialog frame for drill tools
|
2007-09-29 13:31:10 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::InstallDrillFrame( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-26 11:55:34 +00:00
|
|
|
DIALOG_GENDRILL dlg( this );
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2010-11-26 11:55:34 +00:00
|
|
|
dlg.ShowModal();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
/**
|
2010-11-24 19:54:59 +00:00
|
|
|
* Function GenDrillAndReportFiles
|
2009-11-14 22:15:22 +00:00
|
|
|
* Calls the functions to create EXCELLON drill files and/or drill map files
|
2010-11-24 15:10:33 +00:00
|
|
|
* >When all holes are through, only one excellon file is created.
|
|
|
|
* >When there are some partial holes (some blind or buried vias),
|
2011-08-19 13:08:24 +00:00
|
|
|
* one excellon file is created, for all plated through holes,
|
2010-11-24 15:10:33 +00:00
|
|
|
* and one file per layer pair, which have one or more holes, excluding
|
|
|
|
* through holes, already in the first file.
|
2011-08-19 13:08:24 +00:00
|
|
|
* one file for all Not Plated through holes
|
2008-01-16 20:37:50 +00:00
|
|
|
*/
|
2011-08-19 13:08:24 +00:00
|
|
|
void DIALOG_GENDRILL::GenDrillAndReportFiles()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2009-11-14 22:15:22 +00:00
|
|
|
wxString layer_extend; /* added to the Board FileName to
|
|
|
|
* create FullFileName (= Board
|
|
|
|
* FileName + layer pair names) */
|
2009-10-21 19:16:25 +00:00
|
|
|
wxString msg;
|
2010-11-24 19:54:59 +00:00
|
|
|
bool hasBuriedVias = false; /* If true, drill files are created
|
2011-08-19 13:08:24 +00:00
|
|
|
* layer pair by layer pair for
|
|
|
|
* buried vias */
|
2009-12-07 03:46:13 +00:00
|
|
|
int layer1 = LAYER_N_BACK;
|
|
|
|
int layer2 = LAYER_N_FRONT;
|
2009-10-21 19:16:25 +00:00
|
|
|
bool gen_through_holes = true;
|
2011-08-19 13:08:24 +00:00
|
|
|
bool gen_NPTH_holes = false;
|
|
|
|
|
|
|
|
wxString currentWD = ::wxGetCwd();
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
UpdateConfig(); // set params and Save drill options
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_parent->ClearMsgPanel();
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( m_microViasCount || m_blindOrBuriedViasCount )
|
2010-11-24 19:54:59 +00:00
|
|
|
hasBuriedVias = true;
|
2008-01-18 08:54:15 +00:00
|
|
|
|
|
|
|
for( ; ; )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
Build_Holes_List( m_parent->GetBoard(), s_HoleListBuffer,
|
2009-04-05 20:49:15 +00:00
|
|
|
s_ToolListBuffer, layer1, layer2,
|
2011-08-19 13:08:24 +00:00
|
|
|
gen_through_holes ? false : true, gen_NPTH_holes );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( s_ToolListBuffer.size() > 0 ) // holes?
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
fn = m_parent->GetScreen()->GetFileName();
|
2008-03-22 05:55:06 +00:00
|
|
|
layer_extend.Empty();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( gen_NPTH_holes )
|
|
|
|
{
|
|
|
|
layer_extend << wxT( "-NPTH" );
|
|
|
|
}
|
|
|
|
else if( !gen_through_holes )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer1 == LAYER_N_BACK )
|
2008-03-22 05:55:06 +00:00
|
|
|
layer_extend << wxT( "-copper" );
|
|
|
|
else
|
|
|
|
layer_extend << wxT( "-inner" ) << layer1;
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer2 == LAYER_N_FRONT )
|
2008-03-22 05:55:06 +00:00
|
|
|
layer_extend << wxT( "-cmp" );
|
|
|
|
else
|
|
|
|
layer_extend << wxT( "-inner" ) << layer2;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
fn.SetName( fn.GetName() + layer_extend );
|
|
|
|
fn.SetExt( DrillFileExtension );
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Drill File" ), ::wxGetCwd(),
|
|
|
|
fn.GetFullName(), wxGetTranslation( DrillFileWildcard ),
|
|
|
|
wxFD_SAVE | wxFD_CHANGE_DIR );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2009-06-30 10:43:20 +00:00
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
FILE* aFile = wxFopen( dlg.GetPath(), wxT( "w" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aFile == 0 )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
msg.Printf( _( "Unable to create drill file %s" ), GetChars( dlg.GetPath() ) );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
::wxSetWorkingDirectory( currentWD );
|
2009-04-05 20:49:15 +00:00
|
|
|
EndModal( 0 );
|
|
|
|
return;
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
EXCELLON_WRITER excellonWriter( m_parent->GetBoard(),
|
2011-08-19 13:08:24 +00:00
|
|
|
aFile, m_FileDrillOffset,
|
|
|
|
&s_HoleListBuffer, &s_ToolListBuffer );
|
2010-11-24 19:54:59 +00:00
|
|
|
excellonWriter.SetFormat( !m_UnitDrillIsInch,
|
|
|
|
(EXCELLON_WRITER::zeros_fmt) m_ZerosFormat,
|
|
|
|
m_Precision.m_lhs, m_Precision.m_rhs );
|
|
|
|
excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset );
|
2011-08-19 13:08:24 +00:00
|
|
|
excellonWriter.CreateDrillFile();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
switch( m_Choice_Drill_Map->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2009-04-05 20:49:15 +00:00
|
|
|
GenDrillMap( dlg.GetPath(), s_HoleListBuffer, s_ToolListBuffer,
|
|
|
|
PLOT_FORMAT_HPGL );
|
2008-03-22 05:55:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2009-04-05 20:49:15 +00:00
|
|
|
GenDrillMap( dlg.GetPath(), s_HoleListBuffer, s_ToolListBuffer,
|
|
|
|
PLOT_FORMAT_POST );
|
2008-03-22 05:55:06 +00:00
|
|
|
break;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
|
|
|
case 3:
|
|
|
|
GenDrillMap( dlg.GetPath(), s_HoleListBuffer, s_ToolListBuffer,
|
|
|
|
PLOT_FORMAT_GERBER );
|
|
|
|
break;
|
2009-06-30 10:43:20 +00:00
|
|
|
|
|
|
|
case 4:
|
|
|
|
GenDrillMap( dlg.GetPath(), s_HoleListBuffer, s_ToolListBuffer,
|
|
|
|
PLOT_FORMAT_DXF );
|
|
|
|
break;
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-19 13:08:24 +00:00
|
|
|
|
|
|
|
if( gen_NPTH_holes ) // The last drill file was created
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( !hasBuriedVias )
|
|
|
|
gen_NPTH_holes = true;
|
2008-01-25 16:47:36 +00:00
|
|
|
else
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
if( gen_through_holes )
|
|
|
|
layer2 = layer1 + 1; // prepare generation of first layer pair
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( layer2 >= LAYER_N_FRONT ) // no more layer pair to consider
|
|
|
|
{
|
|
|
|
layer1 = LAYER_N_BACK;
|
|
|
|
layer2 = LAYER_N_FRONT;
|
|
|
|
gen_NPTH_holes = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
layer1++;
|
|
|
|
layer2++; // use next layer pair
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( layer2 == m_parent->GetBoard()->GetCopperLayerCount() - 1 )
|
2011-08-19 13:08:24 +00:00
|
|
|
layer2 = LAYER_N_FRONT; // the last layer is always the
|
|
|
|
// component layer
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
gen_through_holes = false;
|
2008-01-25 16:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
if( m_Choice_Drill_Report->GetSelection() > 0 )
|
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
fn = m_parent->GetScreen()->GetFileName();
|
2011-08-19 13:08:24 +00:00
|
|
|
GenDrillReport( fn.GetFullName() );
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
2011-08-19 13:08:24 +00:00
|
|
|
|
|
|
|
::wxSetWorkingDirectory( currentWD );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/**
|
|
|
|
* Create the drill file in EXCELLON format
|
|
|
|
* @return hole count
|
2007-09-29 13:31:10 +00:00
|
|
|
*/
|
2011-08-19 13:08:24 +00:00
|
|
|
int EXCELLON_WRITER::CreateDrillFile()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
int diam, holes_count;
|
|
|
|
int x0, y0, xf, yf, xc, yc;
|
2010-11-24 15:10:33 +00:00
|
|
|
double xt, yt;
|
2011-08-19 13:08:24 +00:00
|
|
|
char line[1024];
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
SetLocaleTo_C_standard(); // Use the standard notation for double numbers
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
WriteHeader();
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
holes_count = 0;
|
2010-11-24 19:54:59 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Write the tool list */
|
2010-11-24 19:54:59 +00:00
|
|
|
for( unsigned ii = 0; ii < m_toolListBuffer->size(); ii++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
DRILL_TOOL& tool_descr = (*m_toolListBuffer)[ii];
|
|
|
|
fprintf( m_file, "T%dC%.3f\n", ii + 1,
|
|
|
|
tool_descr.m_Diameter * m_conversionUnits );
|
2008-01-18 08:54:15 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
fputs( "%\n", m_file ); // End of header info
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
fputs( "G90\n", m_file ); // Absolute mode
|
|
|
|
fputs( "G05\n", m_file ); // Drill mode
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Units : */
|
2010-11-24 19:54:59 +00:00
|
|
|
if( !m_minimalHeader )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
if( m_unitsDecimal )
|
2011-08-19 13:08:24 +00:00
|
|
|
fputs( "M71\n", m_file ); /* M71 = metric mode */
|
2010-11-24 19:54:59 +00:00
|
|
|
else
|
2011-08-19 13:08:24 +00:00
|
|
|
fputs( "M72\n", m_file ); /* M72 = inch mode */
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Read the hole file and generate lines for normal holes (oblong
|
|
|
|
* holes will be created later) */
|
2010-11-24 15:10:33 +00:00
|
|
|
int tool_reference = -2;
|
2010-11-24 19:54:59 +00:00
|
|
|
for( unsigned ii = 0; ii < m_holeListBuffer->size(); ii++ )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
HOLE_INFO& hole_descr = (*m_holeListBuffer)[ii];
|
|
|
|
|
|
|
|
if( hole_descr.m_Hole_Shape )
|
2010-11-24 15:10:33 +00:00
|
|
|
continue; // oblong holes will be created later
|
2010-11-24 19:54:59 +00:00
|
|
|
if( tool_reference != hole_descr.m_Tool_Reference )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
tool_reference = hole_descr.m_Tool_Reference;
|
|
|
|
fprintf( m_file, "T%d\n", tool_reference );
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
x0 = hole_descr.m_Hole_Pos.x - m_offset.x;
|
|
|
|
y0 = hole_descr.m_Hole_Pos.y - m_offset.y;
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( !m_mirror )
|
2008-01-18 08:54:15 +00:00
|
|
|
y0 *= -1;
|
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
xt = x0 * m_conversionUnits;
|
|
|
|
yt = y0 * m_conversionUnits;
|
|
|
|
WriteCoordinates( line, xt, yt );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( line, m_file );
|
2008-01-18 08:54:15 +00:00
|
|
|
holes_count++;
|
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2009-11-14 22:15:22 +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
|
|
|
|
// aHoleListBuffer[ii].m_Tool_Reference
|
2010-11-24 19:54:59 +00:00
|
|
|
for( unsigned ii = 0; ii < m_holeListBuffer->size(); ii++ )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
HOLE_INFO& hole_descr = (*m_holeListBuffer)[ii];
|
|
|
|
if( hole_descr.m_Hole_Shape == 0 )
|
2010-11-24 15:10:33 +00:00
|
|
|
continue; // wait for oblong holes
|
2010-11-24 19:54:59 +00:00
|
|
|
if( tool_reference != hole_descr.m_Tool_Reference )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
tool_reference = hole_descr.m_Tool_Reference;
|
|
|
|
fprintf( m_file, "T%d\n", tool_reference );
|
2008-01-16 20:37:50 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
diam = MIN( hole_descr.m_Hole_Size.x,
|
|
|
|
hole_descr.m_Hole_Size.y );
|
2008-01-18 08:54:15 +00:00
|
|
|
if( diam == 0 )
|
|
|
|
continue;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Compute the hole coordinates: */
|
2011-08-19 13:08:24 +00:00
|
|
|
xc = x0 = xf = hole_descr.m_Hole_Pos.x - m_offset.x;
|
|
|
|
yc = y0 = yf = hole_descr.m_Hole_Pos.y - m_offset.y;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Compute the start and end coordinates for the shape */
|
2011-08-19 13:08:24 +00:00
|
|
|
if( hole_descr.m_Hole_Size.x < hole_descr.m_Hole_Size.y )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
int delta = ( hole_descr.m_Hole_Size.y - hole_descr.m_Hole_Size.x ) / 2;
|
2008-01-18 08:54:15 +00:00
|
|
|
y0 -= delta; yf += delta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
int delta = ( hole_descr.m_Hole_Size.x - hole_descr.m_Hole_Size.y ) / 2;
|
2008-01-18 08:54:15 +00:00
|
|
|
x0 -= delta; xf += delta;
|
|
|
|
}
|
2010-11-24 19:54:59 +00:00
|
|
|
RotatePoint( &x0, &y0, xc, yc, hole_descr.m_Hole_Orient );
|
|
|
|
RotatePoint( &xf, &yf, xc, yc, hole_descr.m_Hole_Orient );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( !m_mirror )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
|
|
|
y0 *= -1; yf *= -1;
|
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
xt = x0 * m_conversionUnits;
|
|
|
|
yt = y0 * m_conversionUnits;
|
|
|
|
WriteCoordinates( line, xt, yt );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
|
|
|
/* remove the '\n' from end of line, because we must add the "G85"
|
|
|
|
* command to the line: */
|
2008-01-18 08:54:15 +00:00
|
|
|
for( int kk = 0; line[kk] != 0; kk++ )
|
|
|
|
if( line[kk] == '\n' || line[kk] =='\r' )
|
|
|
|
line[kk] = 0;
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( line, m_file );
|
|
|
|
|
|
|
|
fputs( "G85", m_file ); // add the "G85" command
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
xt = xf * m_conversionUnits;
|
|
|
|
yt = yf * m_conversionUnits;
|
|
|
|
WriteCoordinates( line, xt, yt );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( line, m_file );
|
|
|
|
fputs( "G05\n", m_file );
|
2008-01-18 08:54:15 +00:00
|
|
|
holes_count++;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
WriteEndOfFile();
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
SetLocaleTo_Default(); // Revert to locale double notation
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
return holes_count;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2011-08-19 13:08:24 +00:00
|
|
|
void EXCELLON_WRITER::SetFormat( bool aMetric,
|
|
|
|
zeros_fmt aZerosFmt,
|
|
|
|
int aLeftDigits,
|
|
|
|
int aRightDigits )
|
2010-11-24 19:54:59 +00:00
|
|
|
{
|
|
|
|
m_unitsDecimal = aMetric;
|
2011-08-19 13:08:24 +00:00
|
|
|
m_zeroFormat = aZerosFmt;
|
2010-11-24 19:54:59 +00:00
|
|
|
|
|
|
|
/* Set conversion scale depending on drill file units */
|
|
|
|
if( m_unitsDecimal )
|
2012-05-03 18:37:56 +00:00
|
|
|
m_conversionUnits = 1.0 / IU_PER_MM; // EXCELLON units = mm
|
2010-11-24 19:54:59 +00:00
|
|
|
else
|
2012-05-03 18:37:56 +00:00
|
|
|
m_conversionUnits = 0.001 / IU_PER_MILS; // EXCELLON units = INCHES
|
2010-11-24 19:54:59 +00:00
|
|
|
|
|
|
|
m_precision.m_lhs = aLeftDigits;
|
|
|
|
m_precision.m_rhs = aRightDigits;
|
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Created a line like:
|
|
|
|
* X48000Y19500
|
|
|
|
* According to the selected format
|
|
|
|
*/
|
2011-08-19 13:08:24 +00:00
|
|
|
void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoordY )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-29 13:31:10 +00:00
|
|
|
wxString xs, ys;
|
2010-11-24 19:54:59 +00:00
|
|
|
int xpad = m_precision.m_lhs + m_precision.m_rhs;
|
2007-09-29 13:31:10 +00:00
|
|
|
int ypad = xpad;
|
|
|
|
|
|
|
|
/* I need to come up with an algorithm that handles any lhs:rhs format.*/
|
|
|
|
/* one idea is to take more inputs for xpad/ypad when metric is used. */
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
switch( DIALOG_GENDRILL::m_ZerosFormat )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case DECIMAL_FORMAT:
|
2010-11-24 15:10:33 +00:00
|
|
|
sprintf( aLine, "X%.3fY%.3f\n", aCoordX, aCoordY );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_LEADING: /* that should work now */
|
2010-11-24 19:54:59 +00:00
|
|
|
for( int i = 0; i< m_precision.m_rhs; i++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
aCoordX *= 10; aCoordY *= 10;
|
2007-09-29 13:31:10 +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
|
|
|
sprintf( aLine, "X%dY%d\n", KiROUND( aCoordX ), KiROUND( aCoordY ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_TRAILING:
|
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
for( int i = 0; i < m_precision.m_rhs; i++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
aCoordX *= 10;
|
|
|
|
aCoordY *= 10;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordX < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
xpad++;
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordY < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
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 ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
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-- );
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case KEEP_ZEROS:
|
2010-11-24 19:54:59 +00:00
|
|
|
for( int i = 0; i< m_precision.m_rhs; i++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
aCoordX *= 10; aCoordY *= 10;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordX < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
xpad++;
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordY < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
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 ) );
|
2011-02-28 18:36:19 +00:00
|
|
|
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Print the DRILL file header. The full header is:
|
|
|
|
* M48
|
|
|
|
* ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35
|
2008-08-26 06:00:27 +00:00
|
|
|
* ;FORMAT={ <precision> / absolute / <units> / <numbers format>}
|
2008-01-18 08:54:15 +00:00
|
|
|
* FMAT,2
|
|
|
|
* INCH,TZ
|
2007-09-29 13:31:10 +00:00
|
|
|
*/
|
2011-08-19 13:08:24 +00:00
|
|
|
void EXCELLON_WRITER::WriteHeader()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( "M48\n", m_file ); // The beginning of a header
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( !m_minimalHeader )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2008-08-26 06:00:27 +00:00
|
|
|
// The next 2 lines in EXCELLON files are comments:
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString msg = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
|
2011-02-28 18:36:19 +00:00
|
|
|
fprintf( m_file, ";DRILL file {%s} date %s\n", TO_UTF8( msg ),
|
2011-11-08 16:37:25 +00:00
|
|
|
TO_UTF8( DateAndTime() ) );
|
2008-08-25 13:26:48 +00:00
|
|
|
msg = wxT( ";FORMAT={" );
|
2009-10-21 19:16:25 +00:00
|
|
|
|
2008-08-26 06:00:27 +00:00
|
|
|
// Print precision:
|
2010-11-24 19:54:59 +00:00
|
|
|
if( m_zeroFormat != DECIMAL_FORMAT )
|
|
|
|
msg << m_precision.GetPrecisionString();
|
2008-08-26 06:00:27 +00:00
|
|
|
else
|
2010-11-24 19:54:59 +00:00
|
|
|
msg << wxT( "-:-" ); // in decimal format the precision is irrelevant
|
2008-08-26 06:00:27 +00:00
|
|
|
msg << wxT( "/ absolute / " );
|
2010-11-24 19:54:59 +00:00
|
|
|
msg << ( m_unitsDecimal ? wxT( "metric" ) : wxT( "inch" ) );
|
2008-08-26 06:00:27 +00:00
|
|
|
|
|
|
|
/* 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.
|
2009-11-14 22:15:22 +00:00
|
|
|
* if new options are added in m_Choice_Zeros_Format, they must also
|
|
|
|
* be added here
|
2008-08-26 06:00:27 +00:00
|
|
|
*/
|
|
|
|
msg << wxT( " / " );
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
const wxString zero_fmt[4] =
|
2008-08-26 06:00:27 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
wxT( "decimal" ),
|
|
|
|
wxT( "suppress leading zeros" ),
|
|
|
|
wxT( "suppress trailing zeros" ),
|
|
|
|
wxT( "keep zeros" )
|
2008-08-26 06:00:27 +00:00
|
|
|
};
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
msg << zero_fmt[m_zeroFormat];
|
2008-08-26 06:00:27 +00:00
|
|
|
msg << wxT( "}\n" );
|
2011-02-28 18:36:19 +00:00
|
|
|
fputs( TO_UTF8( msg ), m_file );
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( "FMAT,2\n", m_file ); // Use Format 2 commands (version used since 1979)
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( m_unitsDecimal ? "METRIC" : "INCH", m_file );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
switch( m_zeroFormat )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
|
|
|
case SUPPRESS_LEADING:
|
|
|
|
case DECIMAL_FORMAT:
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( ",TZ\n", m_file );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_TRAILING:
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( ",LZ\n", m_file );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEEP_ZEROS:
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( ",TZ\n", m_file ); // TZ is acceptable when all zeros are kept
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
void EXCELLON_WRITER::WriteEndOfFile()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
//add if minimal here
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( "T0\nM30\n", m_file );
|
|
|
|
fclose( m_file );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Generate the drill plan (Drill map) format HPGL or POSTSCRIPT
|
|
|
|
*/
|
2010-11-24 15:10:33 +00:00
|
|
|
void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
|
|
|
|
std::vector<HOLE_INFO>& aHoleListBuffer,
|
|
|
|
std::vector<DRILL_TOOL>& buffer,
|
|
|
|
int format )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2009-10-21 19:16:25 +00:00
|
|
|
wxString ext, wildcard;
|
|
|
|
wxString msg;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
/* Init extension */
|
|
|
|
switch( format )
|
|
|
|
{
|
|
|
|
case PLOT_FORMAT_HPGL:
|
2009-04-05 20:49:15 +00:00
|
|
|
ext = wxT( "plt" );
|
|
|
|
wildcard = _( "HPGL plot files (.plt)|*.plt" );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_POST:
|
2009-04-05 20:49:15 +00:00
|
|
|
ext = wxT( "ps" );
|
|
|
|
wildcard = _( "PostScript files (.ps)|*.ps" );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
case PLOT_FORMAT_GERBER:
|
|
|
|
ext = wxT( "pho" );
|
|
|
|
wildcard = _( "Gerber files (.pho)|*.pho" );
|
|
|
|
break;
|
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
case PLOT_FORMAT_DXF:
|
|
|
|
ext = wxT( "dxf" );
|
|
|
|
wildcard = _( "DXF files (.dxf)|*.dxf" );
|
|
|
|
break;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
default:
|
2010-04-30 18:39:10 +00:00
|
|
|
DisplayError( this, wxT( "DIALOG_GENDRILL::GenDrillMap() error" ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init file name */
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = aFileName;
|
|
|
|
fn.SetName( fn.GetName() + wxT( "-drl" ) );
|
|
|
|
fn.SetExt( ext );
|
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Drill Plot File" ), fn.GetPath(),
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.GetFullName(), wildcard,
|
2011-08-19 13:08:24 +00:00
|
|
|
wxFD_SAVE );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-09-29 13:31:10 +00:00
|
|
|
return;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
FILE* plotfile = wxFopen( dlg.GetPath(), wxT( "wt" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( plotfile == 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2008-01-18 08:54:15 +00:00
|
|
|
msg = _( "Unable to create file" );
|
2009-04-05 20:49:15 +00:00
|
|
|
msg << wxT( " <" ) << dlg.GetPath() << wxT( ">" );
|
2011-08-19 13:08:24 +00:00
|
|
|
wxMessageBox( msg );
|
2009-04-05 20:49:15 +00:00
|
|
|
return;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
GenDrillMapFile( m_parent->GetBoard(),
|
2010-11-24 15:10:33 +00:00
|
|
|
plotfile,
|
2009-04-05 20:49:15 +00:00
|
|
|
dlg.GetPath(),
|
2012-04-05 18:27:56 +00:00
|
|
|
m_parent->GetPageSettings(),
|
2009-04-05 20:49:15 +00:00
|
|
|
s_HoleListBuffer,
|
|
|
|
s_ToolListBuffer,
|
2010-11-24 15:10:33 +00:00
|
|
|
m_UnitDrillIsInch,
|
|
|
|
format, m_FileDrillOffset );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-09-29 13:31:10 +00:00
|
|
|
* Create a list of drill values and drill count
|
|
|
|
*/
|
2010-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2009-10-21 19:16:25 +00:00
|
|
|
wxString msg;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
fn = aFileName;
|
|
|
|
fn.SetName( fn.GetName() + wxT( "-drl" ) );
|
2012-02-16 20:03:33 +00:00
|
|
|
fn.SetExt( ReportFileExtension );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Drill Report File" ), fn.GetPath(),
|
2012-02-16 20:03:33 +00:00
|
|
|
fn.GetFullName(), wxGetTranslation( ReportFileWildcard ),
|
2011-08-19 13:08:24 +00:00
|
|
|
wxFD_SAVE );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-09-29 13:31:10 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
FILE* report_dest = wxFopen( dlg.GetPath(), wxT( "w" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( report_dest == 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
msg = _( "Unable to create file " ) + dlg.GetPath();
|
2011-08-19 13:08:24 +00:00
|
|
|
wxMessageBox( msg );
|
2007-09-29 13:31:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
GenDrillReportFile( report_dest, m_parent->GetBoard(),
|
|
|
|
m_parent->GetScreen()->GetFileName(),
|
2010-11-24 15:10:33 +00:00
|
|
|
m_UnitDrillIsInch,
|
2009-04-05 20:49:15 +00:00
|
|
|
s_HoleListBuffer,
|
|
|
|
s_ToolListBuffer );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|