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
|
|
|
*
|
2012-10-05 12:25:12 +00:00
|
|
|
* Copyright (C) 1992-2012 Jean_Pierre Charras <jp.charras at wanadoo.fr>
|
2015-09-25 19:38:09 +00:00
|
|
|
* Copyright (C) 1992-2015 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>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <pcbplot.h>
|
2012-10-05 12:25:12 +00:00
|
|
|
#include <gendrill_Excellon_writer.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.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>
|
2012-10-05 12:25:12 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2015-04-29 15:37:37 +00:00
|
|
|
#include <reporter.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2015-09-25 19:38:09 +00:00
|
|
|
#include <wx/stdpaths.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" )
|
2015-11-16 18:42:58 +00:00
|
|
|
#define MergePTHNPTHKey wxT( "DrillMergePTHNPTH" )
|
2010-11-24 15:10:33 +00:00
|
|
|
#define UnitDrillInchKey wxT( "DrillUnit" )
|
|
|
|
#define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" )
|
2012-12-06 21:53:00 +00:00
|
|
|
#define DrillMapFileTypeKey wxT( "DrillMapFileType" )
|
2010-11-24 15:10:33 +00:00
|
|
|
|
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,
|
2012-10-05 19:04:17 +00:00
|
|
|
// there are 2 precision values, one for inches and one for metric
|
|
|
|
static DRILL_PRECISION precisionListForInches( 2, 4 );
|
|
|
|
static DRILL_PRECISION precisionListForMetric( 3, 3 );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* This function displays the dialog frame for drill tools
|
|
|
|
*/
|
|
|
|
void PCB_EDIT_FRAME::InstallDrillFrame( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
DIALOG_GENDRILL dlg( this );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
2012-10-05 12:25:12 +00:00
|
|
|
m_plotOpts = m_parent->GetPlotSettings();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
SetReturnCode( 1 );
|
|
|
|
initDialog();
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Static members of DIALOG_GENDRILL
|
2012-10-05 12:25:12 +00:00
|
|
|
int DIALOG_GENDRILL::m_UnitDrillIsInch = true;
|
|
|
|
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;
|
2015-11-16 18:42:58 +00:00
|
|
|
bool DIALOG_GENDRILL::m_Merge_PTH_NPTH = false;
|
2010-11-24 15:10:33 +00:00
|
|
|
bool DIALOG_GENDRILL::m_DrillOriginIsAuxAxis = false;
|
2012-10-05 12:25:12 +00:00
|
|
|
int DIALOG_GENDRILL::m_mapFileType = 1;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
DIALOG_GENDRILL::~DIALOG_GENDRILL()
|
|
|
|
{
|
|
|
|
UpdateConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::initDialog()
|
|
|
|
{
|
2012-12-06 21:53:00 +00:00
|
|
|
m_config->Read( ZerosFormatKey, &m_ZerosFormat );
|
|
|
|
m_config->Read( MirrorKey, &m_Mirror );
|
2015-11-16 18:42:58 +00:00
|
|
|
m_config->Read( MergePTHNPTHKey, &m_Merge_PTH_NPTH );
|
2012-12-06 21:53:00 +00:00
|
|
|
m_config->Read( MinimalHeaderKey, &m_MinimalHeader );
|
|
|
|
m_config->Read( UnitDrillInchKey, &m_UnitDrillIsInch );
|
|
|
|
m_config->Read( DrillOriginIsAuxAxisKey, &m_DrillOriginIsAuxAxis );
|
|
|
|
m_config->Read( DrillMapFileTypeKey, &m_mapFileType );
|
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;
|
|
|
|
|
|
|
|
m_Choice_Unit->SetSelection( m_UnitDrillIsInch ? 1 : 0 );
|
|
|
|
m_Choice_Zeros_Format->SetSelection( m_ZerosFormat );
|
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 );
|
2015-11-16 18:42:58 +00:00
|
|
|
m_Check_Merge_PTH_NPTH->SetValue( m_Merge_PTH_NPTH );
|
2012-10-05 12:25:12 +00:00
|
|
|
m_Choice_Drill_Map->SetSelection( m_mapFileType );
|
2010-11-24 15:10:33 +00:00
|
|
|
m_ViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
|
|
|
|
m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
|
|
|
|
|
|
|
|
// 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
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
const VIA *via = dynamic_cast<const VIA*>( track );
|
|
|
|
if( via )
|
|
|
|
{
|
|
|
|
switch( via->GetViaType() )
|
|
|
|
{
|
|
|
|
case VIA_THROUGH:
|
|
|
|
m_throughViasCount++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_MICROVIA:
|
|
|
|
m_microViasCount++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_BLIND_BURIED:
|
|
|
|
m_blindOrBuriedViasCount++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
if( pad->GetDrillShape() == PAD_DRILL_SHAPE_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
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
if( pad->GetAttribute() == PAD_ATTRIB_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-12-06 21:53:00 +00:00
|
|
|
if( pad->GetDrillSize().x != 0 && pad->GetDrillSize().y != 0 )
|
2011-08-19 13:08:24 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
if( pad->GetAttribute() == PAD_ATTRIB_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 );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
// Output directory
|
|
|
|
m_outputDirectoryName->SetValue( m_plotOpts.GetOutputDirectory() );
|
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::UpdateConfig()
|
|
|
|
{
|
|
|
|
SetParams();
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
m_config->Write( ZerosFormatKey, m_ZerosFormat );
|
|
|
|
m_config->Write( MirrorKey, m_Mirror );
|
2015-11-16 18:42:58 +00:00
|
|
|
m_config->Write( MergePTHNPTHKey, m_Merge_PTH_NPTH );
|
2012-10-05 12:25:12 +00:00
|
|
|
m_config->Write( MinimalHeaderKey, m_MinimalHeader );
|
|
|
|
m_config->Write( UnitDrillInchKey, m_UnitDrillIsInch );
|
|
|
|
m_config->Write( DrillOriginIsAuxAxisKey, m_DrillOriginIsAuxAxis );
|
2012-12-06 21:53:00 +00:00
|
|
|
m_config->Write( DrillMapFileTypeKey, m_mapFileType );
|
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
|
|
|
}
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
void DIALOG_GENDRILL::OnGenMapFile( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
GenDrillAndMapFiles( false, true);
|
|
|
|
}
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2014-03-03 14:28:05 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
void DIALOG_GENDRILL::OnGenDrillFile( wxCommandEvent& event )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
GenDrillAndMapFiles(true, false);
|
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-10-05 19:04:17 +00:00
|
|
|
m_staticTextPrecision->SetLabel( precisionListForInches.GetPrecisionString() );
|
2010-11-24 15:10:33 +00:00
|
|
|
else
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// metric options
|
2012-10-05 19:04:17 +00:00
|
|
|
m_staticTextPrecision->SetLabel( precisionListForMetric.GetPrecisionString() );
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
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 )
|
2012-10-05 19:04:17 +00:00
|
|
|
m_staticTextPrecision->Enable( false );
|
2010-11-24 15:10:33 +00:00
|
|
|
else
|
2012-10-05 19:04:17 +00:00
|
|
|
m_staticTextPrecision->Enable( true );
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 14:28:05 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
void DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Build the absolute path of current output plot directory
|
|
|
|
// to preselect it when opening the dialog.
|
|
|
|
wxFileName fn( m_outputDirectoryName->GetValue() );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
|
|
|
|
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
|
|
|
|
2016-07-27 12:53:45 +00:00
|
|
|
fn = Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() );
|
|
|
|
wxString defaultPath = fn.GetPathWithSep();
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Do you want to use a path relative to\n'%s'" ),
|
|
|
|
GetChars( defaultPath ) );
|
|
|
|
|
|
|
|
wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
|
2012-10-05 12:25:12 +00:00
|
|
|
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
{
|
2016-07-27 12:53:45 +00:00
|
|
|
if( !dirName.MakeRelativeTo( defaultPath ) )
|
|
|
|
wxMessageBox( _( "Cannot make path relative (target volume different from file volume)!" ),
|
2012-10-05 12:25:12 +00:00
|
|
|
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
|
|
|
}
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2014-03-03 14:28:05 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
void DIALOG_GENDRILL::SetParams()
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
// Set output directory and replace backslashes with forward ones
|
|
|
|
wxString dirStr;
|
|
|
|
dirStr = m_outputDirectoryName->GetValue();
|
|
|
|
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
m_plotOpts.SetOutputDirectory( dirStr );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
m_mapFileType = m_Choice_Drill_Map->GetSelection();
|
2011-08-19 13:08:24 +00:00
|
|
|
|
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();
|
2015-11-16 18:42:58 +00:00
|
|
|
m_Merge_PTH_NPTH = m_Check_Merge_PTH_NPTH->IsChecked();
|
2010-11-24 15:10:33 +00:00
|
|
|
m_ZerosFormat = m_Choice_Zeros_Format->GetSelection();
|
|
|
|
m_DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection();
|
|
|
|
|
|
|
|
if( m_Choice_Drill_Offset->GetSelection() == 0 )
|
|
|
|
m_FileDrillOffset = wxPoint( 0, 0 );
|
|
|
|
else
|
2013-08-03 05:15:23 +00:00
|
|
|
m_FileDrillOffset = m_parent->GetAuxOrigin();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( m_UnitDrillIsInch )
|
2012-10-05 19:04:17 +00:00
|
|
|
m_Precision = precisionListForInches;
|
2010-11-24 15:10:33 +00:00
|
|
|
else
|
2012-10-05 19:04:17 +00:00
|
|
|
m_Precision = precisionListForMetric;
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
m_board->SetPlotOptions( m_plotOpts );
|
|
|
|
}
|
|
|
|
|
2014-03-03 14:28:05 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
void DIALOG_GENDRILL::GenDrillAndMapFiles(bool aGenDrill, bool aGenMap)
|
|
|
|
{
|
2014-07-20 14:46:59 +00:00
|
|
|
UpdateConfig(); // set params and Save drill options
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
m_parent->ClearMsgPanel();
|
2015-04-29 15:37:37 +00:00
|
|
|
wxString defaultPath = Prj().AbsolutePath( m_plotOpts.GetOutputDirectory() );
|
|
|
|
WX_TEXT_CTRL_REPORTER reporter( m_messagesBox );
|
|
|
|
|
|
|
|
const PlotFormat filefmt[6] =
|
|
|
|
{ // Keep these format ids in the same order than m_Choice_Drill_Map choices
|
|
|
|
PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER,
|
|
|
|
PLOT_FORMAT_DXF, PLOT_FORMAT_SVG, PLOT_FORMAT_PDF
|
|
|
|
};
|
|
|
|
unsigned choice = (unsigned) m_Choice_Drill_Map->GetSelection();
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2015-04-29 15:37:37 +00:00
|
|
|
if( choice >= DIM( filefmt ) )
|
|
|
|
choice = 1;
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2015-04-28 15:07:36 +00:00
|
|
|
EXCELLON_WRITER excellonWriter( m_parent->GetBoard() );
|
2012-10-05 12:25:12 +00:00
|
|
|
excellonWriter.SetFormat( !m_UnitDrillIsInch,
|
2015-04-29 15:37:37 +00:00
|
|
|
(EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat,
|
2012-10-05 12:25:12 +00:00
|
|
|
m_Precision.m_lhs, m_Precision.m_rhs );
|
2015-11-16 18:42:58 +00:00
|
|
|
excellonWriter.SetOptions( m_Mirror, m_MinimalHeader,
|
|
|
|
m_FileDrillOffset, m_Merge_PTH_NPTH );
|
2015-04-29 15:37:37 +00:00
|
|
|
excellonWriter.SetMapFileFormat( filefmt[choice] );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2015-04-29 15:37:37 +00:00
|
|
|
excellonWriter.CreateDrillandMapFilesSet( defaultPath, aGenDrill, aGenMap,
|
|
|
|
&reporter);
|
2012-10-05 12:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::OnGenReportFile( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
UpdateConfig(); // set params and Save drill options
|
|
|
|
|
|
|
|
wxFileName fn = m_parent->GetBoard()->GetFileName();
|
|
|
|
|
|
|
|
fn.SetName( fn.GetName() + wxT( "-drl" ) );
|
|
|
|
fn.SetExt( ReportFileExtension );
|
|
|
|
|
2015-10-23 14:30:22 +00:00
|
|
|
wxString defaultPath = Prj().AbsolutePath( m_plotOpts.GetOutputDirectory() );
|
2014-03-03 14:28:05 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
if( defaultPath.IsEmpty() )
|
2015-09-25 19:38:09 +00:00
|
|
|
defaultPath = wxStandardPaths::Get().GetDocumentsDir();
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Save Drill Report File" ), defaultPath,
|
|
|
|
fn.GetFullName(), wxGetTranslation( ReportFileWildcard ),
|
|
|
|
wxFD_SAVE );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2015-04-28 15:07:36 +00:00
|
|
|
EXCELLON_WRITER excellonWriter( m_parent->GetBoard() );
|
2012-10-05 12:25:12 +00:00
|
|
|
excellonWriter.SetFormat( !m_UnitDrillIsInch,
|
2015-04-29 15:37:37 +00:00
|
|
|
(EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat,
|
2012-10-05 12:25:12 +00:00
|
|
|
m_Precision.m_lhs, m_Precision.m_rhs );
|
2015-11-16 18:42:58 +00:00
|
|
|
excellonWriter.SetOptions( m_Mirror, m_MinimalHeader,
|
|
|
|
m_FileDrillOffset, m_Merge_PTH_NPTH );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
bool success = excellonWriter.GenDrillReportFile( dlg.GetPath() );
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( ! success )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "** Unable to create %s **\n" ), GetChars( dlg.GetPath() ) );
|
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-05 07:38:00 +00:00
|
|
|
msg.Printf( _( "Report file %s created\n" ), GetChars( dlg.GetPath() ) );
|
2012-10-05 12:25:12 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
}
|