2010-11-26 11:55:34 +00:00
|
|
|
/**
|
2011-09-30 18:15:37 +00:00
|
|
|
* @file dialog_gendrill.cpp
|
|
|
|
*/
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2010-11-26 11:55:34 +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-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-26 11:55:34 +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
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <gendrill.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_module.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_gendrill.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Keywords for read and write config
|
|
|
|
#define ZerosFormatKey wxT( "DrillZerosFormat" )
|
|
|
|
#define PrecisionKey wxT( "DrilltPrecisionOpt" )
|
|
|
|
#define MirrorKey wxT( "DrillMirrorYOpt" )
|
|
|
|
#define MinimalHeaderKey wxT( "DrillMinHeader" )
|
|
|
|
#define UnitDrillInchKey wxT( "DrillUnit" )
|
|
|
|
#define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" )
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
// list of allowed precision for EXCELLON files, for integer format:
|
2010-11-24 15:10:33 +00:00
|
|
|
// Due to difference between inches and mm,
|
|
|
|
// there are 2 set of reasonnable precision values, one for inches and one for metric
|
|
|
|
static DRILL_PRECISION precisionListForInches[] =
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
DRILL_PRECISION( 2, 3 ), DRILL_PRECISION( 2, 4 )
|
2010-11-24 15:10:33 +00:00
|
|
|
};
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
static DRILL_PRECISION precisionListForMetric[] =
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
DRILL_PRECISION( 3, 2 ), DRILL_PRECISION( 3, 3 )
|
2010-11-24 15:10:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_GENDRILL::DIALOG_GENDRILL( PCB_EDIT_FRAME* parent ) :
|
2010-11-24 15:10:33 +00:00
|
|
|
DIALOG_GENDRILL_BASE( parent )
|
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_parent = parent;
|
|
|
|
m_board = parent->GetBoard();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
SetReturnCode( 1 );
|
|
|
|
initDialog();
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Static members of DIALOG_GENDRILL
|
|
|
|
int DIALOG_GENDRILL:: m_UnitDrillIsInch = true;
|
2010-11-24 19:54:59 +00:00
|
|
|
int DIALOG_GENDRILL:: m_ZerosFormat = EXCELLON_WRITER::DECIMAL_FORMAT;
|
2010-11-24 15:10:33 +00:00
|
|
|
bool DIALOG_GENDRILL::m_MinimalHeader = false;
|
2012-09-11 07:33:17 +00:00
|
|
|
bool DIALOG_GENDRILL::m_Mirror = false;
|
2010-11-24 15:10:33 +00:00
|
|
|
bool DIALOG_GENDRILL::m_DrillOriginIsAuxAxis = false;
|
|
|
|
int DIALOG_GENDRILL:: m_PrecisionFormat = 1;
|
2011-08-19 13:08:24 +00:00
|
|
|
bool DIALOG_GENDRILL::m_createRpt = false;
|
|
|
|
int DIALOG_GENDRILL::m_createMap = 0;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
DIALOG_GENDRILL::~DIALOG_GENDRILL()
|
|
|
|
{
|
|
|
|
UpdateConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::initDialog()
|
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfig* Config = wxGetApp().GetSettings();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( Config )
|
|
|
|
{
|
|
|
|
Config->Read( ZerosFormatKey, &DIALOG_GENDRILL::m_ZerosFormat );
|
|
|
|
Config->Read( PrecisionKey, &DIALOG_GENDRILL::m_PrecisionFormat );
|
|
|
|
Config->Read( MirrorKey, &DIALOG_GENDRILL::m_Mirror );
|
|
|
|
Config->Read( MinimalHeaderKey, &DIALOG_GENDRILL::m_MinimalHeader );
|
|
|
|
Config->Read( UnitDrillInchKey, &DIALOG_GENDRILL::m_UnitDrillIsInch );
|
|
|
|
Config->Read( DrillOriginIsAuxAxisKey, &DIALOG_GENDRILL::m_DrillOriginIsAuxAxis );
|
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
InitDisplayParams();
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
void DIALOG_GENDRILL::InitDisplayParams()
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2012-04-05 18:27:56 +00:00
|
|
|
const PCB_PLOT_PARAMS& plot_opts = m_board->GetPlotOptions();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
m_Choice_Unit->SetSelection( m_UnitDrillIsInch ? 1 : 0 );
|
|
|
|
m_Choice_Precision->SetSelection( m_PrecisionFormat );
|
|
|
|
m_Choice_Zeros_Format->SetSelection( m_ZerosFormat );
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( m_ZerosFormat == EXCELLON_WRITER::DECIMAL_FORMAT )
|
2010-11-24 15:10:33 +00:00
|
|
|
m_Choice_Precision->Enable( false );
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
UpdatePrecisionOptions();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
m_Check_Minimal->SetValue( m_MinimalHeader );
|
|
|
|
|
|
|
|
if( m_DrillOriginIsAuxAxis )
|
|
|
|
m_Choice_Drill_Offset->SetSelection( 1 );
|
|
|
|
|
|
|
|
m_Check_Mirror->SetValue( m_Mirror );
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
m_Choice_Drill_Map->SetSelection( m_createMap );
|
|
|
|
m_Choice_Drill_Report->SetSelection( m_createRpt );
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
m_ViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
|
|
|
|
|
|
|
|
m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
|
|
|
|
|
|
|
|
msg.Empty();
|
2012-08-30 18:06:13 +00:00
|
|
|
msg << plot_opts.GetHPGLPenNum();
|
2010-11-24 15:10:33 +00:00
|
|
|
m_PenNum->SetValue( msg );
|
|
|
|
|
|
|
|
msg.Empty();
|
2012-08-30 18:06:13 +00:00
|
|
|
msg << plot_opts.GetHPGLPenSpeed();
|
2010-11-24 15:10:33 +00:00
|
|
|
m_PenSpeed->SetValue( msg );
|
|
|
|
|
|
|
|
// See if we have some buried vias or/and microvias, and display
|
|
|
|
// microvias drill value if so
|
2011-08-19 13:08:24 +00:00
|
|
|
m_throughViasCount = 0;
|
|
|
|
m_microViasCount = 0;
|
|
|
|
m_blindOrBuriedViasCount = 0;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
for( TRACK* track = m_parent->GetBoard()->m_Track; track != NULL; track = track->Next() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() != PCB_VIA_T )
|
2010-11-24 15:10:33 +00:00
|
|
|
continue;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
if( track->GetShape() == VIA_THROUGH )
|
2011-08-19 13:08:24 +00:00
|
|
|
m_throughViasCount++;
|
2011-12-14 04:29:25 +00:00
|
|
|
else if( track->GetShape() == VIA_MICROVIA )
|
2011-08-19 13:08:24 +00:00
|
|
|
m_microViasCount++;
|
2011-12-14 04:29:25 +00:00
|
|
|
else if( track->GetShape() == VIA_BLIND_BURIED )
|
2011-08-19 13:08:24 +00:00
|
|
|
m_blindOrBuriedViasCount++;
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
m_MicroViaDrillValue->Enable( m_microViasCount );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Count plated pad holes and not plated pad holes:
|
2011-08-19 13:08:24 +00:00
|
|
|
m_platedPadsHoleCount = 0;
|
|
|
|
m_notplatedPadsHoleCount = 0;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
for( MODULE* module = m_parent->GetBoard()->m_Modules; module; module = module->Next() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetDrillShape() == PAD_CIRCLE )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetDrillSize().x != 0 )
|
2011-08-19 13:08:24 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetAttribute() == PAD_HOLE_NOT_PLATED )
|
2011-08-19 13:08:24 +00:00
|
|
|
m_notplatedPadsHoleCount++;
|
|
|
|
else
|
|
|
|
m_platedPadsHoleCount++;
|
|
|
|
}
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
else
|
2011-10-01 19:24:27 +00:00
|
|
|
{
|
2012-08-04 09:43:27 +00:00
|
|
|
if( std::min( pad->GetDrillSize().x, pad->GetDrillSize().y ) != 0 )
|
2011-08-19 13:08:24 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetAttribute() == PAD_HOLE_NOT_PLATED )
|
2011-08-19 13:08:24 +00:00
|
|
|
m_notplatedPadsHoleCount++;
|
|
|
|
else
|
|
|
|
m_platedPadsHoleCount++;
|
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
}
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
// Display hole counts:
|
|
|
|
msg = m_PlatedPadsCountInfoMsg->GetLabel();
|
|
|
|
msg << wxT( " " ) << m_platedPadsHoleCount;
|
|
|
|
m_PlatedPadsCountInfoMsg->SetLabel( msg );
|
|
|
|
|
|
|
|
msg = m_NotPlatedPadsCountInfoMsg->GetLabel();
|
|
|
|
msg << wxT( " " ) << m_notplatedPadsHoleCount;
|
|
|
|
m_NotPlatedPadsCountInfoMsg->SetLabel( msg );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
msg = m_ThroughViasInfoMsg->GetLabel();
|
2011-08-19 13:08:24 +00:00
|
|
|
msg << wxT( " " ) << m_throughViasCount;
|
2010-11-24 15:10:33 +00:00
|
|
|
m_ThroughViasInfoMsg->SetLabel( msg );
|
|
|
|
|
|
|
|
msg = m_MicroViasInfoMsg->GetLabel();
|
2011-08-19 13:08:24 +00:00
|
|
|
msg << wxT( " " ) << m_microViasCount;
|
2010-11-24 15:10:33 +00:00
|
|
|
m_MicroViasInfoMsg->SetLabel( msg );
|
|
|
|
|
|
|
|
msg = m_BuriedViasInfoMsg->GetLabel();
|
2011-08-19 13:08:24 +00:00
|
|
|
msg << wxT( " " ) << m_blindOrBuriedViasCount;
|
2010-11-24 15:10:33 +00:00
|
|
|
m_BuriedViasInfoMsg->SetLabel( msg );
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
void DIALOG_GENDRILL::UpdateConfig()
|
|
|
|
{
|
|
|
|
SetParams();
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
wxConfig* config = wxGetApp().GetSettings();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( config )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
config->Write( ZerosFormatKey, m_ZerosFormat );
|
|
|
|
config->Write( PrecisionKey, m_PrecisionFormat );
|
|
|
|
config->Write( MirrorKey, m_Mirror );
|
|
|
|
config->Write( MinimalHeaderKey, m_MinimalHeader );
|
|
|
|
config->Write( UnitDrillInchKey, m_UnitDrillIsInch );
|
|
|
|
config->Write( DrillOriginIsAuxAxisKey, m_DrillOriginIsAuxAxis );
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
void DIALOG_GENDRILL::OnSelDrillUnitsSelected( wxCommandEvent& event )
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
UpdatePrecisionOptions();
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::OnOkClick( wxCommandEvent& event )
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
GenDrillAndReportFiles();
|
|
|
|
EndModal( wxID_OK );
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
UpdateConfig(); // Save drill options:
|
2011-08-19 13:08:24 +00:00
|
|
|
EndModal( wxID_CANCEL ); // Process the default cancel event (close dialog)
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::OnSelZerosFmtSelected( wxCommandEvent& event )
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
UpdatePrecisionOptions();
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
void DIALOG_GENDRILL::UpdatePrecisionOptions()
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
if( m_Choice_Unit->GetSelection()== 1 ) // Units = inches
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// inch options
|
2010-11-24 15:10:33 +00:00
|
|
|
m_Choice_Precision->SetString( 0, precisionListForInches[0].GetPrecisionString() );
|
|
|
|
m_Choice_Precision->SetString( 1, precisionListForInches[1].GetPrecisionString() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// metric options
|
2010-11-24 15:10:33 +00:00
|
|
|
m_Choice_Precision->SetString( 0, precisionListForMetric[0].GetPrecisionString() );
|
|
|
|
m_Choice_Precision->SetString( 1, precisionListForMetric[1].GetPrecisionString() );
|
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( m_Choice_Zeros_Format->GetSelection() == EXCELLON_WRITER::DECIMAL_FORMAT )
|
2010-11-24 15:10:33 +00:00
|
|
|
m_Choice_Precision->Enable( false );
|
|
|
|
else
|
|
|
|
m_Choice_Precision->Enable( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
void DIALOG_GENDRILL::SetParams()
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
long ltmp;
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
PCB_PLOT_PARAMS plot_opts = m_board->GetPlotOptions();
|
|
|
|
|
2012-08-29 12:40:09 +00:00
|
|
|
m_plotDefaultpath = plot_opts.GetOutputDirectory();
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
m_createMap = m_Choice_Drill_Map->GetSelection();
|
|
|
|
m_createRpt = m_Choice_Drill_Report->GetSelection();
|
|
|
|
|
2012-01-22 17:20:22 +00:00
|
|
|
m_UnitDrillIsInch = (m_Choice_Unit->GetSelection() == 0) ? false : true;
|
2010-11-24 15:10:33 +00:00
|
|
|
m_MinimalHeader = m_Check_Minimal->IsChecked();
|
|
|
|
m_Mirror = m_Check_Mirror->IsChecked();
|
|
|
|
m_ZerosFormat = m_Choice_Zeros_Format->GetSelection();
|
|
|
|
m_DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection();
|
|
|
|
m_PrecisionFormat = m_Choice_Precision->GetSelection();
|
|
|
|
|
|
|
|
msg = m_PenSpeed->GetValue();
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( msg.ToLong( <mp ) )
|
2012-08-30 18:06:13 +00:00
|
|
|
plot_opts.SetHPGLPenSpeed( ltmp );
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
msg = m_PenNum->GetValue();
|
|
|
|
|
|
|
|
if( msg.ToLong( <mp ) )
|
2012-08-30 18:06:13 +00:00
|
|
|
plot_opts.SetHPGLPenNum( ltmp );
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( m_Choice_Drill_Offset->GetSelection() == 0 )
|
|
|
|
m_FileDrillOffset = wxPoint( 0, 0 );
|
|
|
|
else
|
2012-04-05 18:27:56 +00:00
|
|
|
m_FileDrillOffset = m_parent->GetOriginAxisPosition();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
// get precision
|
|
|
|
int idx = m_Choice_Precision->GetSelection();
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( m_UnitDrillIsInch )
|
|
|
|
m_Precision = precisionListForInches[idx];
|
|
|
|
else
|
|
|
|
m_Precision = precisionListForMetric[idx];
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
m_board->SetPlotOptions( plot_opts );
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|