2009-11-14 22:15:22 +00:00
|
|
|
/*************************************************************/
|
|
|
|
/* Functions to create EXCELLON drill files and report files */
|
|
|
|
/*************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "plot_common.h"
|
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
#include "gestfich.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "macros.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
#include "gendrill.h"
|
|
|
|
|
2010-04-30 18:39:10 +00:00
|
|
|
#include "dialog_gendrill.h" // Dialog box for drill file generation
|
|
|
|
|
2010-01-05 08:48:49 +00:00
|
|
|
#include "build_version.h"
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
const wxString DrillFileExtension( wxT( "drl" ) );
|
|
|
|
|
|
|
|
const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl" ) );
|
|
|
|
|
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-04-30 18:39:10 +00:00
|
|
|
* dialog_gendrill.cpp is the filewhich 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-14 19:24:41 +00:00
|
|
|
static void Gen_Line_EXCELLON( char* line, float x, float y );
|
2008-01-18 08:54:15 +00:00
|
|
|
static void Write_End_Of_File_Drill( FILE* aFile );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
static float s_ConversionUnits; /* Conversion unite for
|
|
|
|
* drill / pcb */
|
|
|
|
static int s_Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */
|
2008-01-16 20:37:50 +00:00
|
|
|
static int s_Zeros_Format = DECIMAL_FORMAT;
|
|
|
|
static DrillPrecision s_Precision( 2, 4 );
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
static bool DrillOriginIsAuxAxis; /* Axis selection (main /
|
|
|
|
* auxiliary) for drill
|
|
|
|
* origin coordinates */
|
|
|
|
static wxPoint File_Drill_Offset; /* Offset coordinate for
|
|
|
|
* drilling file. */
|
2008-01-16 20:37:50 +00:00
|
|
|
static bool Minimal = false;
|
|
|
|
static bool Mirror = true;
|
2007-09-29 13:31:10 +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
|
|
|
|
|
|
|
// Keywords for read and write config
|
2007-09-29 13:31:10 +00:00
|
|
|
#define ZerosFormatKey wxT( "DrillZerosFormat" )
|
|
|
|
#define LeftPrecisionKey wxT( "DrillLeftPrecisionOpt" )
|
|
|
|
#define RightPrecisionKey wxT( "DrillRightPrecisionOpt" )
|
|
|
|
#define MirrorKey wxT( "DrillMirrorYOpt" )
|
|
|
|
#define MinimalKey wxT( "DrillMinHeader" )
|
|
|
|
#define UnitDrillInchKey wxT( "DrillUnit" )
|
|
|
|
#define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* some param values initialization before display dialog window
|
2008-01-16 20:37:50 +00:00
|
|
|
*/
|
2010-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::InitDisplayParams( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-01-16 20:37:50 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
if( s_Zeros_Format == DECIMAL_FORMAT )
|
2007-09-29 13:31:10 +00:00
|
|
|
m_Choice_Precision->Enable( false );
|
|
|
|
if( DrillOriginIsAuxAxis )
|
|
|
|
m_Choice_Drill_Offset->SetSelection( 1 );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2008-01-14 19:24:41 +00:00
|
|
|
msg << s_Precision.m_lhs << wxT( ":" ) << s_Precision.m_rhs;
|
|
|
|
m_Choice_Precision->SetStringSelection( msg );
|
2009-10-21 19:16:25 +00:00
|
|
|
if( s_Zeros_Format == DECIMAL_FORMAT )
|
2008-01-14 19:24:41 +00:00
|
|
|
m_Choice_Precision->Enable( false );
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
m_ViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
|
|
|
msg.Empty();
|
2009-06-28 16:50:42 +00:00
|
|
|
msg << g_pcb_plot_options.HPGL_Pen_Num;
|
2008-01-16 20:37:50 +00:00
|
|
|
m_PenNum->SetValue( msg );
|
|
|
|
|
|
|
|
msg.Empty();
|
2009-06-28 16:50:42 +00:00
|
|
|
msg << g_pcb_plot_options.HPGL_Pen_Speed;
|
2008-01-16 20:37:50 +00:00
|
|
|
m_PenSpeed->SetValue( msg );
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// See if we have some buried vias or/and microvias, and display
|
|
|
|
// microvias drill value if so
|
2008-01-16 20:37:50 +00:00
|
|
|
m_ThroughViasCount = 0;
|
|
|
|
m_MicroViasCount = 0;
|
|
|
|
m_BlindOrBuriedViasCount = 0;
|
2009-11-14 22:15:22 +00:00
|
|
|
for( TRACK* track = m_Parent->GetBoard()->m_Track; track != NULL;
|
|
|
|
track = track->Next() )
|
2008-01-16 20:37:50 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( track->Type() != TYPE_VIA )
|
2008-01-16 20:37:50 +00:00
|
|
|
continue;
|
|
|
|
if( track->Shape() == VIA_THROUGH )
|
|
|
|
m_ThroughViasCount++;
|
|
|
|
else if( track->Shape() == VIA_MICROVIA )
|
|
|
|
m_MicroViasCount++;
|
|
|
|
else if( track->Shape() == VIA_BLIND_BURIED )
|
|
|
|
m_BlindOrBuriedViasCount++;
|
|
|
|
}
|
2008-01-14 19:24:41 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
m_MicroViaDrillValue->Enable( m_MicroViasCount );
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Pads holes round:
|
2008-01-16 20:37:50 +00:00
|
|
|
m_PadsHoleCount = 0;
|
2009-11-14 22:15:22 +00:00
|
|
|
for( MODULE* module = m_Parent->GetBoard()->m_Modules;
|
|
|
|
module != NULL; module = module->Next() )
|
2008-01-16 20:37:50 +00:00
|
|
|
{
|
|
|
|
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
2008-01-14 19:24:41 +00:00
|
|
|
if( pad->m_DrillShape == PAD_CIRCLE )
|
2008-02-22 20:38:49 +00:00
|
|
|
{
|
2008-01-16 20:37:50 +00:00
|
|
|
if( pad->m_Drill.x != 0 )
|
|
|
|
m_PadsHoleCount++;
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-21 19:16:25 +00:00
|
|
|
if( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 )
|
|
|
|
m_PadsHoleCount++;
|
2008-01-16 20:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = m_PadsCountInfoMsg->GetLabel();
|
|
|
|
msg << wxT( " " ) << m_PadsHoleCount;
|
|
|
|
m_PadsCountInfoMsg->SetLabel( msg );
|
|
|
|
|
|
|
|
msg = m_ThroughViasInfoMsg->GetLabel();
|
|
|
|
msg << wxT( " " ) << m_ThroughViasCount;
|
|
|
|
m_ThroughViasInfoMsg->SetLabel( msg );
|
|
|
|
|
|
|
|
msg = m_MicroViasInfoMsg->GetLabel();
|
|
|
|
msg << wxT( " " ) << m_MicroViasCount;
|
|
|
|
m_MicroViasInfoMsg->SetLabel( msg );
|
|
|
|
|
|
|
|
msg = m_BuriedViasInfoMsg->GetLabel();
|
|
|
|
msg << wxT( " " ) << m_BlindOrBuriedViasCount;
|
|
|
|
m_BuriedViasInfoMsg->SetLabel( msg );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::SetParams( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-01-16 20:37:50 +00:00
|
|
|
wxString msg;
|
|
|
|
long ltmp;
|
2008-01-14 19:24:41 +00:00
|
|
|
|
|
|
|
s_Unit_Drill_is_Inch = (m_Choice_Unit->GetSelection() == 0) ? FALSE : TRUE;
|
2007-09-29 13:31:10 +00:00
|
|
|
Minimal = m_Check_Minimal->IsChecked();
|
|
|
|
Mirror = m_Check_Mirror->IsChecked();
|
|
|
|
s_Zeros_Format = m_Choice_Zeros_Format->GetSelection();
|
|
|
|
DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection();
|
2008-01-14 19:24:41 +00:00
|
|
|
|
|
|
|
msg = m_PenSpeed->GetValue();
|
2008-01-16 20:37:50 +00:00
|
|
|
if( msg.ToLong( <mp ) )
|
2009-06-28 16:50:42 +00:00
|
|
|
g_pcb_plot_options.HPGL_Pen_Speed = ltmp;
|
2008-01-14 19:24:41 +00:00
|
|
|
msg = m_PenNum->GetValue();
|
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
if( msg.ToLong( <mp ) )
|
2009-06-28 16:50:42 +00:00
|
|
|
g_pcb_plot_options.HPGL_Pen_Num = ltmp;
|
2008-01-16 20:37:50 +00:00
|
|
|
if( m_Choice_Drill_Offset->GetSelection() == 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
File_Drill_Offset = wxPoint( 0, 0 );
|
|
|
|
else
|
|
|
|
File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position;
|
|
|
|
|
|
|
|
/* get precision from radio box strings (this just makes it easier to
|
2009-11-14 22:15:22 +00:00
|
|
|
* change options later)*/
|
2007-09-29 13:31:10 +00:00
|
|
|
wxString ps = m_Choice_Precision->GetStringSelection();
|
|
|
|
wxString l = ps.substr( 0, 1 );
|
|
|
|
wxString r = ps.substr( 2, 1 );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
|
|
|
|
2007-12-17 21:54:24 +00:00
|
|
|
// a long is not an int on all machines
|
|
|
|
long lhs;
|
|
|
|
long rhs;
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2007-12-17 21:54:24 +00:00
|
|
|
l.ToLong( &lhs );
|
|
|
|
r.ToLong( &rhs );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2007-12-17 21:54:24 +00:00
|
|
|
s_Precision.m_lhs = lhs;
|
|
|
|
s_Precision.m_rhs = rhs;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-31 06:29:45 +00:00
|
|
|
/* This function displays and deletes the dialog frame for drill tools
|
2007-09-29 13:31:10 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxConfig* Config = wxGetApp().m_EDA_Config;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
if( Config )
|
|
|
|
{
|
|
|
|
Config->Read( ZerosFormatKey, &s_Zeros_Format );
|
|
|
|
Config->Read( LeftPrecisionKey, &s_Precision.m_lhs );
|
|
|
|
Config->Read( RightPrecisionKey, &s_Precision.m_rhs );
|
|
|
|
Config->Read( MirrorKey, &Mirror );
|
|
|
|
Config->Read( MinimalKey, &Minimal );
|
2008-01-14 19:24:41 +00:00
|
|
|
Config->Read( UnitDrillInchKey, &s_Unit_Drill_is_Inch );
|
2007-09-29 13:31:10 +00:00
|
|
|
Config->Read( DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis );
|
|
|
|
}
|
|
|
|
|
2010-04-30 18:39:10 +00:00
|
|
|
DIALOG_GENDRILL* frame = new DIALOG_GENDRILL( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
/* Save drill options: */
|
2010-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::UpdateConfig()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-29 13:31:10 +00:00
|
|
|
SetParams();
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
wxConfig* Config = wxGetApp().m_EDA_Config;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
if( Config )
|
|
|
|
{
|
|
|
|
Config->Write( ZerosFormatKey, s_Zeros_Format );
|
|
|
|
Config->Write( LeftPrecisionKey, s_Precision.m_lhs );
|
|
|
|
Config->Write( RightPrecisionKey, s_Precision.m_rhs );
|
|
|
|
Config->Write( MirrorKey, Mirror );
|
|
|
|
Config->Write( MinimalKey, Minimal );
|
2008-01-14 19:24:41 +00:00
|
|
|
Config->Write( UnitDrillInchKey, s_Unit_Drill_is_Inch );
|
2007-09-29 13:31:10 +00:00
|
|
|
Config->Write( DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
/**
|
|
|
|
* Function GenDrillFiles
|
2009-11-14 22:15:22 +00:00
|
|
|
* Calls the functions to create EXCELLON drill files and/or drill map files
|
2008-01-25 16:47:36 +00:00
|
|
|
* When all holes are through, one excellon file is created
|
|
|
|
* when there are some partial holes (some blind or buried vias:
|
|
|
|
* One excellon file is created, for all through holes.
|
2009-11-14 22:15:22 +00:00
|
|
|
* And one file per layer pair, which have one or more holes, excluding
|
|
|
|
* through holes, already in the first file.
|
2008-01-16 20:37:50 +00:00
|
|
|
*/
|
2010-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::GenDrillFiles( wxCommandEvent& event )
|
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;
|
2009-11-14 22:15:22 +00:00
|
|
|
bool ExistsBuriedVias = false; /* If true, drill files are created
|
|
|
|
* 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;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
UpdateConfig(); /* set params and Save drill options */
|
|
|
|
|
|
|
|
m_Parent->MsgPanel->EraseMsgBox();
|
|
|
|
|
2008-01-14 19:24:41 +00:00
|
|
|
/* Set conversion scale depending on drill file units */
|
2009-11-14 22:15:22 +00:00
|
|
|
s_ConversionUnits = 0.0001f; /* units = INCHES */
|
2008-01-14 19:24:41 +00:00
|
|
|
if( !s_Unit_Drill_is_Inch )
|
2009-11-14 22:15:22 +00:00
|
|
|
s_ConversionUnits = 0.000254f; /* units = mm */
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
if( m_MicroViasCount || m_BlindOrBuriedViasCount )
|
|
|
|
ExistsBuriedVias = true;
|
|
|
|
|
|
|
|
for( ; ; )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Build_Holes_List( m_Parent->GetBoard(), s_HoleListBuffer,
|
|
|
|
s_ToolListBuffer, layer1, layer2,
|
|
|
|
gen_through_holes ? false : true );
|
|
|
|
|
2008-03-05 04:51:48 +00:00
|
|
|
if( s_ToolListBuffer.size() > 0 ) //holes?
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = m_Parent->GetScreen()->m_FileName;
|
2008-03-22 05:55:06 +00:00
|
|
|
layer_extend.Empty();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
if( !gen_through_holes )
|
|
|
|
{
|
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 );
|
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Drill File" ), fn.GetPath(),
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.GetFullName(), DrillFileWildcard,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2009-06-30 10:43:20 +00:00
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
FILE* excellon_dest = wxFopen( dlg.GetPath(), wxT( "w" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( excellon_dest == 0 )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
msg = _( "Unable to create file " ) + dlg.GetPath();
|
|
|
|
DisplayError( this, msg );
|
|
|
|
EndModal( 0 );
|
|
|
|
return;
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
Create_Drill_File_EXCELLON( excellon_dest, s_HoleListBuffer,
|
|
|
|
s_ToolListBuffer );
|
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
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !ExistsBuriedVias )
|
2008-03-22 05:55:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-01-25 16:47:36 +00:00
|
|
|
if( gen_through_holes )
|
|
|
|
layer2 = layer1 + 1;
|
|
|
|
else
|
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer2 >= LAYER_N_FRONT ) // no more layer pair to consider
|
2008-01-25 16:47:36 +00:00
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
layer1++;
|
|
|
|
layer2++; // use next layer pair
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( layer2 == m_Parent->GetBoard()->GetCopperLayerCount() - 1 )
|
2009-12-07 03:46:13 +00:00
|
|
|
layer2 = LAYER_N_FRONT; // the last layer is always the
|
2009-11-14 22:15:22 +00:00
|
|
|
// component layer
|
2008-01-25 16:47:36 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
gen_through_holes = false;
|
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
if( m_Choice_Drill_Report->GetSelection() > 0 )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
GenDrillReport( m_Parent->GetScreen()->m_FileName );
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EndModal( 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::UpdatePrecisionOptions( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-29 13:31:10 +00:00
|
|
|
if( m_Choice_Unit->GetSelection()==1 )
|
2009-10-21 19:16:25 +00:00
|
|
|
{
|
|
|
|
/* inch options */
|
2007-09-29 13:31:10 +00:00
|
|
|
m_Choice_Precision->SetString( 0, _( "2:3" ) );
|
|
|
|
m_Choice_Precision->SetString( 1, _( "2:4" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
else
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
|
|
|
/* metric options */
|
|
|
|
m_Choice_Precision->SetString( 0, _( "3:2" ) );
|
|
|
|
m_Choice_Precision->SetString( 1, _( "3:3" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
if( m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT )
|
|
|
|
m_Choice_Precision->Enable( false );
|
2007-06-05 12:10:51 +00:00
|
|
|
else
|
2007-09-29 13:31:10 +00:00
|
|
|
m_Choice_Precision->Enable( true );
|
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
|
|
|
|
* @param aHoleListBuffer = hole descriptor list
|
|
|
|
* @param aToolListBuffer = Drill tools list
|
2007-09-29 13:31:10 +00:00
|
|
|
*/
|
2010-04-30 18:39:10 +00:00
|
|
|
int DIALOG_GENDRILL::Create_Drill_File_EXCELLON( FILE* excellon_dest,
|
2009-11-14 22:15:22 +00:00
|
|
|
std::vector<HOLE_INFO>& aHoleListBuffer,
|
|
|
|
std::vector<DRILL_TOOL>& aToolListBuffer )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-01-18 08:54:15 +00:00
|
|
|
int diam, holes_count;
|
|
|
|
int x0, y0, xf, yf, xc, yc;
|
|
|
|
float xt, yt;
|
|
|
|
char line[1024];
|
|
|
|
|
2008-08-26 06:00:27 +00:00
|
|
|
SetLocaleTo_C_standard(); // Use the standard notation for float numbers
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
Write_Excellon_Header( excellon_dest );
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
holes_count = 0;
|
2008-01-18 08:54:15 +00:00
|
|
|
int tool_reference = -2;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Write the tool list */
|
|
|
|
for( unsigned ii = 0; ii < aToolListBuffer.size(); ii++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2008-01-18 08:54:15 +00:00
|
|
|
if( s_Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/
|
2009-06-28 16:50:42 +00:00
|
|
|
fprintf( excellon_dest, "T%dC%.3f\n", ii + 1,
|
2009-11-14 22:15:22 +00:00
|
|
|
float (aToolListBuffer[ii].m_Diameter)
|
|
|
|
* s_ConversionUnits );
|
2008-01-18 08:54:15 +00:00
|
|
|
else
|
2009-06-28 16:50:42 +00:00
|
|
|
fprintf( excellon_dest, "T%dC%.3f\n", ii + 1,
|
2009-11-14 22:15:22 +00:00
|
|
|
float (aToolListBuffer[ii].m_Diameter)
|
|
|
|
* s_ConversionUnits * 10.0 );
|
2008-01-18 08:54:15 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
fputs( "%\n", excellon_dest );
|
2008-01-18 08:54:15 +00:00
|
|
|
|
|
|
|
if( !Minimal )
|
2009-10-21 19:16:25 +00:00
|
|
|
fputs( "M47\n", excellon_dest ); /* Operator message */
|
|
|
|
fputs( "G05\n", excellon_dest ); /* Drill mode */
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Units : */
|
|
|
|
if( s_Unit_Drill_is_Inch && !Minimal )
|
2009-10-21 19:16:25 +00:00
|
|
|
fputs( "M72\n", excellon_dest ); /* M72 = inch mode */
|
2008-01-18 08:54:15 +00:00
|
|
|
else if( !Minimal )
|
2009-10-21 19:16:25 +00:00
|
|
|
fputs( "M71\n", excellon_dest ); /* M71 = metric mode */
|
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) */
|
2008-01-18 08:54:15 +00:00
|
|
|
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
|
|
|
|
{
|
|
|
|
if( aHoleListBuffer[ii].m_Hole_Shape )
|
|
|
|
continue; // oblong holes will be created later
|
|
|
|
if( tool_reference != aHoleListBuffer[ii].m_Tool_Reference )
|
|
|
|
{
|
|
|
|
tool_reference = aHoleListBuffer[ii].m_Tool_Reference;
|
2009-06-28 16:50:42 +00:00
|
|
|
fprintf( excellon_dest, "T%d\n", tool_reference );
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
x0 = aHoleListBuffer[ii].m_Hole_Pos_X - File_Drill_Offset.x;
|
|
|
|
y0 = aHoleListBuffer[ii].m_Hole_Pos_Y - File_Drill_Offset.y;
|
|
|
|
|
|
|
|
if( !Mirror )
|
|
|
|
y0 *= -1;
|
|
|
|
|
|
|
|
xt = float (x0) * s_ConversionUnits; yt = float (y0) * s_ConversionUnits;
|
|
|
|
if( s_Unit_Drill_is_Inch )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2008-01-18 08:54:15 +00:00
|
|
|
Gen_Line_EXCELLON( line, xt, yt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* metric 3:3 */
|
|
|
|
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
|
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
fputs( line, excellon_dest );
|
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
|
2008-01-18 08:54:15 +00:00
|
|
|
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
|
|
|
|
{
|
|
|
|
if( aHoleListBuffer[ii].m_Hole_Shape == 0 )
|
|
|
|
continue; // wait for oblong holes
|
|
|
|
if( tool_reference != aHoleListBuffer[ii].m_Tool_Reference )
|
|
|
|
{
|
|
|
|
tool_reference = aHoleListBuffer[ii].m_Tool_Reference;
|
2009-06-28 16:50:42 +00:00
|
|
|
fprintf( excellon_dest, "T%d\n", tool_reference );
|
2008-01-16 20:37:50 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
diam = MIN( aHoleListBuffer[ii].m_Hole_SizeX,
|
|
|
|
aHoleListBuffer[ii].m_Hole_SizeY );
|
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: */
|
|
|
|
xc = x0 = xf = aHoleListBuffer[ii].m_Hole_Pos_X - File_Drill_Offset.x;
|
|
|
|
yc = y0 = yf = aHoleListBuffer[ii].m_Hole_Pos_Y - File_Drill_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 */
|
|
|
|
if( aHoleListBuffer[ii].m_Hole_SizeX < aHoleListBuffer[ii].m_Hole_SizeY )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
int delta = ( aHoleListBuffer[ii].m_Hole_SizeY
|
|
|
|
- aHoleListBuffer[ii].m_Hole_SizeX ) / 2;
|
2008-01-18 08:54:15 +00:00
|
|
|
y0 -= delta; yf += delta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
int delta = ( aHoleListBuffer[ii].m_Hole_SizeX
|
|
|
|
- aHoleListBuffer[ii].m_Hole_SizeY ) / 2;
|
2008-01-18 08:54:15 +00:00
|
|
|
x0 -= delta; xf += delta;
|
|
|
|
}
|
|
|
|
RotatePoint( &x0, &y0, xc, yc, aHoleListBuffer[ii].m_Hole_Orient );
|
|
|
|
RotatePoint( &xf, &yf, xc, yc, aHoleListBuffer[ii].m_Hole_Orient );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
if( !Mirror )
|
|
|
|
{
|
|
|
|
y0 *= -1; yf *= -1;
|
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
xt = float (x0) * s_ConversionUnits;
|
|
|
|
yt = float (y0) * s_ConversionUnits;
|
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
if( s_Unit_Drill_is_Inch )
|
|
|
|
Gen_Line_EXCELLON( line, xt, yt );
|
|
|
|
else
|
|
|
|
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
|
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
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
fputs( line, excellon_dest );
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
fputs( "G85", excellon_dest ); // add the "G85" command
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
xt = float (xf) * s_ConversionUnits;
|
|
|
|
yt = float (yf) * s_ConversionUnits;
|
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
if( s_Unit_Drill_is_Inch )
|
|
|
|
Gen_Line_EXCELLON( line, xt, yt );
|
|
|
|
else
|
|
|
|
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
|
2009-06-28 16:50:42 +00:00
|
|
|
fputs( line, excellon_dest );
|
|
|
|
fputs( "G05\n", excellon_dest );
|
2008-01-18 08:54:15 +00:00
|
|
|
holes_count++;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
Write_End_Of_File_Drill( excellon_dest );
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2008-08-26 06:00:27 +00:00
|
|
|
SetLocaleTo_Default(); // Revert to locale float 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
|
|
|
}
|
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Created a line like:
|
|
|
|
* X48000Y19500
|
|
|
|
* According to the selected format
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void Gen_Line_EXCELLON( char* line, float x, float y )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-29 13:31:10 +00:00
|
|
|
wxString xs, ys;
|
|
|
|
int xpad = s_Precision.m_lhs + s_Precision.m_rhs;
|
|
|
|
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. */
|
|
|
|
|
|
|
|
switch( s_Zeros_Format )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case DECIMAL_FORMAT:
|
|
|
|
sprintf( line, "X%.3fY%.3f\n", x, y );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_LEADING: /* that should work now */
|
|
|
|
for( int i = 0; i< s_Precision.m_rhs; i++ )
|
|
|
|
{
|
|
|
|
x *= 10; y *= 10;
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
sprintf( line, "X%dY%d\n", wxRound( x ), wxRound( y ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_TRAILING:
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
for( int i = 0; i < s_Precision.m_rhs; i++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
x *= 10;
|
|
|
|
y *= 10;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( x<0 )
|
|
|
|
xpad++;
|
|
|
|
if( y<0 )
|
|
|
|
ypad++;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
xs.Printf( wxT( "%0*d" ), xpad, wxRound( x ) );
|
|
|
|
ys.Printf( wxT( "%0*d" ), ypad, wxRound( y ) );
|
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-- );
|
|
|
|
|
|
|
|
sprintf( line, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case KEEP_ZEROS:
|
|
|
|
for( int i = 0; i< s_Precision.m_rhs; i++ )
|
|
|
|
{
|
|
|
|
x *= 10; y *= 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( x<0 )
|
|
|
|
xpad++;
|
|
|
|
if( y<0 )
|
|
|
|
ypad++;
|
2009-04-05 20:49:15 +00:00
|
|
|
xs.Printf( wxT( "%0*d" ), xpad, wxRound( x ) );
|
|
|
|
ys.Printf( wxT( "%0*d" ), ypad, wxRound( y ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
sprintf( line, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) );
|
|
|
|
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
|
|
|
* R,T
|
|
|
|
* VER,1
|
|
|
|
* FMAT,2
|
|
|
|
* INCH,TZ
|
|
|
|
* TCST,OFF
|
|
|
|
* ICI,OFF
|
|
|
|
* ATC,ON
|
2007-09-29 13:31:10 +00:00
|
|
|
*/
|
2010-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::Write_Excellon_Header( FILE* aFile )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-29 13:31:10 +00:00
|
|
|
char Line[256];
|
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
fputs( "M48\n", aFile );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
if( !Minimal )
|
|
|
|
{
|
2009-10-21 19:16:25 +00:00
|
|
|
int ii = m_Choice_Zeros_Format->GetSelection();
|
2007-09-29 13:31:10 +00:00
|
|
|
DateAndTime( Line );
|
2009-10-21 19:16:25 +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();
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile, ";DRILL file {%s} date %s\n", CONV_TO_UTF8( msg ),
|
|
|
|
Line );
|
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:
|
2009-10-21 19:16:25 +00:00
|
|
|
if( ii > 0 )
|
2008-08-26 06:00:27 +00:00
|
|
|
msg << m_Choice_Precision->GetStringSelection();
|
|
|
|
else
|
2009-10-21 19:16:25 +00:00
|
|
|
msg << wxT( "-.-" ); // in decimal format the precision is irrelevant
|
2008-08-26 06:00:27 +00:00
|
|
|
msg << wxT( "/ absolute / " );
|
|
|
|
msg << ( s_Unit_Drill_is_Inch ? wxT( "inch" ) : wxT( "metric" ) );
|
|
|
|
|
|
|
|
/* 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( " / " );
|
|
|
|
const wxString zero_fmt[5] =
|
|
|
|
{
|
2009-10-21 19:16:25 +00:00
|
|
|
wxT( "decimal" ), wxT( "suppress leading zeros" ),
|
2008-08-26 06:00:27 +00:00
|
|
|
wxT( "suppress trailing zeros" ), wxT( "keep zeros" ),
|
|
|
|
wxT( "???" )
|
|
|
|
};
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2008-08-26 06:00:27 +00:00
|
|
|
if( ii < 0 || ii > 4 )
|
|
|
|
ii = 4;
|
|
|
|
msg << zero_fmt[ii];
|
|
|
|
msg << wxT( "}\n" );
|
2008-08-25 13:26:48 +00:00
|
|
|
fputs( CONV_TO_UTF8( msg ), aFile );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
fputs( "R,T\nVER,1\nFMAT,2\n", aFile );
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2008-08-26 06:00:27 +00:00
|
|
|
fputs( s_Unit_Drill_is_Inch ? "INCH" : "METRIC", aFile );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
switch( s_Zeros_Format )
|
|
|
|
{
|
|
|
|
case SUPPRESS_LEADING:
|
|
|
|
case DECIMAL_FORMAT:
|
2008-01-18 08:54:15 +00:00
|
|
|
fputs( ",TZ\n", aFile );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_TRAILING:
|
2008-01-18 08:54:15 +00:00
|
|
|
fputs( ",LZ\n", aFile );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEEP_ZEROS:
|
2008-01-18 08:54:15 +00:00
|
|
|
fputs( ",TZ\n", aFile ); // TZ is acceptable when all zeros are kept
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !Minimal )
|
2008-01-18 08:54:15 +00:00
|
|
|
fputs( "TCST,OFF\nICI,OFF\nATC,ON\n", aFile );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
void Write_End_Of_File_Drill( FILE* aFile )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
//add if minimal here
|
2008-01-18 08:54:15 +00:00
|
|
|
fputs( "T0\nM30\n", aFile ); fclose( aFile );
|
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-04-30 18:39:10 +00:00
|
|
|
void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
|
2008-01-18 08:54:15 +00:00
|
|
|
std::vector<HOLE_INFO>& aHoleListBuffer,
|
2009-11-14 22:15:22 +00:00
|
|
|
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,
|
2009-06-30 10:43:20 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
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* drillplot_dest = wxFopen( dlg.GetPath(), wxT( "wt" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( drillplot_dest == 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( ">" );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GenDrillMapFile( m_Parent->GetBoard(),
|
2009-06-28 16:50:42 +00:00
|
|
|
drillplot_dest,
|
2009-04-05 20:49:15 +00:00
|
|
|
dlg.GetPath(),
|
2009-06-28 16:50:42 +00:00
|
|
|
m_Parent->GetScreen()->m_CurrentSheetDesc,
|
2009-04-05 20:49:15 +00:00
|
|
|
s_HoleListBuffer,
|
|
|
|
s_ToolListBuffer,
|
|
|
|
s_Unit_Drill_is_Inch,
|
2009-06-28 16:50:42 +00:00
|
|
|
format, File_Drill_Offset );
|
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;
|
|
|
|
wxString wildcard = _( "Drill report files (.rpt)|*.rpt" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
fn = aFileName;
|
|
|
|
fn.SetName( fn.GetName() + wxT( "-drl" ) );
|
|
|
|
fn.SetExt( wxT( "rpt" ) );
|
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(),
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.GetFullName(), wildcard,
|
2009-06-30 10:43:20 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
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();
|
2007-09-29 13:31:10 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
GenDrillReportFile( report_dest, m_Parent->GetBoard(),
|
2009-04-05 20:49:15 +00:00
|
|
|
m_Parent->GetScreen()->m_FileName,
|
|
|
|
s_Unit_Drill_is_Inch,
|
|
|
|
s_HoleListBuffer,
|
|
|
|
s_ToolListBuffer );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|