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
|
|
|
*
|
2019-02-09 13:56:02 +00:00
|
|
|
* Copyright (C) 1992-2019 Jean_Pierre Charras <jp.charras at wanadoo.fr>
|
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.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>
|
2017-05-01 18:42:18 +00:00
|
|
|
#include <confirm.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.h>
|
2012-10-05 12:25:12 +00:00
|
|
|
#include <gendrill_Excellon_writer.h>
|
2017-04-28 10:53:30 +00:00
|
|
|
#include <gendrill_gerber_writer.h>
|
2018-02-09 18:00:13 +00:00
|
|
|
#include <bitmaps.h>
|
2019-06-04 20:59:59 +00:00
|
|
|
#include <tools/pcb_editor_control.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#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>
|
2015-09-25 19:38:09 +00:00
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2019-02-09 13:56:02 +00:00
|
|
|
// Keywords for read and write parameters in project config
|
2010-11-24 15:10:33 +00:00
|
|
|
#define ZerosFormatKey wxT( "DrillZerosFormat" )
|
|
|
|
#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" )
|
2012-12-06 21:53:00 +00:00
|
|
|
#define DrillMapFileTypeKey wxT( "DrillMapFileType" )
|
2017-04-28 10:53:30 +00:00
|
|
|
#define DrillFileFormatKey wxT( "DrillFileType" )
|
2019-02-09 13:56:02 +00:00
|
|
|
#define OvalHolesRouteModeKey wxT( "OvalHolesRouteMode" )
|
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
|
2019-02-09 13:56:02 +00:00
|
|
|
// Note: for decimla format, the precision is not used
|
2012-10-05 19:04:17 +00:00
|
|
|
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
|
|
|
|
*/
|
2019-06-04 20:59:59 +00:00
|
|
|
int PCB_EDITOR_CONTROL::GenerateDrillFiles( const TOOL_EVENT& aEvent )
|
2012-10-05 12:25:12 +00:00
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
|
|
|
DIALOG_GENDRILL dlg( editFrame, editFrame );
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
dlg.ShowModal();
|
2019-06-04 20:59:59 +00:00
|
|
|
return 0;
|
2012-10-05 12:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-13 10:41:52 +00:00
|
|
|
DIALOG_GENDRILL::DIALOG_GENDRILL( PCB_EDIT_FRAME* aPcbEditFrame, wxWindow* aParent ) :
|
|
|
|
DIALOG_GENDRILL_BASE( aParent )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2019-02-13 10:41:52 +00:00
|
|
|
m_pcbEditFrame = aPcbEditFrame;
|
|
|
|
m_board = m_pcbEditFrame->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();
|
2019-02-13 10:41:52 +00:00
|
|
|
m_plotOpts = m_pcbEditFrame->GetPlotSettings();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
|
|
|
|
// that requires us to correct the button labels here.
|
2019-02-13 10:41:52 +00:00
|
|
|
m_sdbSizerOK->SetLabel( _( "Generate Drill File" ) );
|
|
|
|
m_sdbSizerApply->SetLabel( _( "Generate Map File" ) );
|
|
|
|
m_sdbSizerCancel->SetLabel( _( "Close" ) );
|
2018-02-28 09:44:22 +00:00
|
|
|
m_buttonsSizer->Layout();
|
|
|
|
|
2019-02-13 10:41:52 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2010-11-24 15:10:33 +00:00
|
|
|
SetReturnCode( 1 );
|
|
|
|
initDialog();
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Static members of DIALOG_GENDRILL
|
2017-04-28 10:53:30 +00:00
|
|
|
int DIALOG_GENDRILL::m_UnitDrillIsInch = true; // Only for Excellon format
|
|
|
|
int DIALOG_GENDRILL::m_ZerosFormat = EXCELLON_WRITER::DECIMAL_FORMAT;
|
|
|
|
bool DIALOG_GENDRILL::m_MinimalHeader = false; // Only for Excellon format
|
|
|
|
bool DIALOG_GENDRILL::m_Mirror = false; // Only for Excellon format
|
|
|
|
bool DIALOG_GENDRILL::m_Merge_PTH_NPTH = false; // Only for Excellon format
|
|
|
|
int DIALOG_GENDRILL::m_mapFileType = 1;
|
|
|
|
int DIALOG_GENDRILL::m_drillFileType = 0;
|
2019-02-09 13:56:02 +00:00
|
|
|
bool DIALOG_GENDRILL::m_UseRouteModeForOvalHoles = true; // Use G00 route mode to "drill" oval holes
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
DIALOG_GENDRILL::~DIALOG_GENDRILL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
2017-04-28 10:53:30 +00:00
|
|
|
m_drillOriginIsAuxAxis = m_plotOpts.GetUseAuxOrigin();
|
2012-12-06 21:53:00 +00:00
|
|
|
m_config->Read( DrillMapFileTypeKey, &m_mapFileType );
|
2017-04-28 10:53:30 +00:00
|
|
|
m_config->Read( DrillFileFormatKey, &m_drillFileType );
|
2019-02-09 13:56:02 +00:00
|
|
|
m_config->Read( OvalHolesRouteModeKey, &m_UseRouteModeForOvalHoles );
|
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
|
|
|
{
|
2018-02-28 09:44:22 +00:00
|
|
|
m_browseButton->SetBitmap( KiBitmap( folder_xpm ) );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
m_rbExcellon->SetValue( m_drillFileType == 0 );
|
|
|
|
m_rbGerberX2->SetValue( m_drillFileType == 1 );
|
2010-11-24 15:10:33 +00:00
|
|
|
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 );
|
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
if( m_drillOriginIsAuxAxis )
|
2010-11-24 15:10:33 +00:00
|
|
|
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 );
|
2019-02-09 13:56:02 +00:00
|
|
|
m_radioBoxOvalHoleMode->SetSelection( m_UseRouteModeForOvalHoles ? 0 : 1 );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
m_platedPadsHoleCount = 0;
|
|
|
|
m_notplatedPadsHoleCount = 0;
|
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
|
|
|
|
2019-05-31 00:15:57 +00:00
|
|
|
for( auto module : m_board->Modules() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2019-06-01 23:23:36 +00:00
|
|
|
for( auto pad : module->Pads() )
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-31 02:30:28 +00:00
|
|
|
for( auto track : m_board->Tracks() )
|
2018-02-28 09:44:22 +00:00
|
|
|
{
|
|
|
|
const VIA *via = dynamic_cast<const VIA*>( track );
|
|
|
|
if( via )
|
|
|
|
{
|
|
|
|
switch( via->GetViaType() )
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::THROUGH:
|
2018-02-28 09:44:22 +00:00
|
|
|
m_throughViasCount++;
|
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::MICROVIA:
|
2018-02-28 09:44:22 +00:00
|
|
|
m_microViasCount++;
|
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::BLIND_BURIED:
|
2018-02-28 09:44:22 +00:00
|
|
|
m_blindOrBuriedViasCount++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
// Display hole counts:
|
2018-02-09 18:00:13 +00:00
|
|
|
m_PlatedPadsCountInfoMsg-> SetLabel( wxString() << m_platedPadsHoleCount );
|
|
|
|
m_NotPlatedPadsCountInfoMsg->SetLabel( wxString() << m_notplatedPadsHoleCount );
|
|
|
|
m_ThroughViasInfoMsg-> SetLabel( wxString() << m_throughViasCount );
|
|
|
|
m_MicroViasInfoMsg-> SetLabel( wxString() << m_microViasCount );
|
|
|
|
m_BuriedViasInfoMsg-> SetLabel( wxString() << m_blindOrBuriedViasCount );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
// Output directory
|
|
|
|
m_outputDirectoryName->SetValue( m_plotOpts.GetOutputDirectory() );
|
2017-04-28 10:53:30 +00:00
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
onFileFormatSelection( dummy );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::onFileFormatSelection( wxCommandEvent& event )
|
|
|
|
{
|
2018-02-28 09:44:22 +00:00
|
|
|
bool enbl_Excellon = m_rbExcellon->GetValue();
|
|
|
|
|
|
|
|
m_drillFileType = enbl_Excellon ? 0 : 1;
|
2017-04-28 10:53:30 +00:00
|
|
|
|
|
|
|
m_Choice_Unit->Enable( enbl_Excellon );
|
|
|
|
m_Choice_Zeros_Format->Enable( enbl_Excellon );
|
|
|
|
m_Check_Mirror->Enable( enbl_Excellon );
|
|
|
|
m_Check_Minimal->Enable( enbl_Excellon );
|
|
|
|
m_Check_Merge_PTH_NPTH->Enable( enbl_Excellon );
|
2019-02-09 13:56:02 +00:00
|
|
|
m_radioBoxOvalHoleMode->Enable( enbl_Excellon );
|
2017-04-28 10:53:30 +00:00
|
|
|
|
|
|
|
if( enbl_Excellon )
|
|
|
|
UpdatePrecisionOptions();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_staticTextPrecision->Enable( true );
|
|
|
|
m_staticTextPrecision->SetLabel( m_plotOpts.GetGerberPrecision() == 6 ? "4.6" : "4.5" );
|
|
|
|
}
|
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()
|
|
|
|
{
|
2019-02-13 10:41:52 +00:00
|
|
|
UpdateDrillParams();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
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 );
|
2012-12-06 21:53:00 +00:00
|
|
|
m_config->Write( DrillMapFileTypeKey, m_mapFileType );
|
2017-04-28 10:53:30 +00:00
|
|
|
m_config->Write( DrillFileFormatKey, m_drillFileType );
|
2019-02-09 13:56:02 +00:00
|
|
|
m_config->Write( OvalHolesRouteModeKey, m_UseRouteModeForOvalHoles );
|
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
|
|
|
}
|
|
|
|
|
2016-10-07 14:57:45 +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::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() );
|
|
|
|
|
2019-02-13 10:41:52 +00:00
|
|
|
fn = Prj().AbsolutePath( m_board->GetFileName() );
|
2016-07-27 12:53:45 +00:00
|
|
|
wxString defaultPath = fn.GetPathWithSep();
|
|
|
|
wxString msg;
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "Do you want to use a path relative to\n\"%s\"" ), GetChars( defaultPath ) );
|
2016-07-27 12:53:45 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-02-13 10:41:52 +00:00
|
|
|
void DIALOG_GENDRILL::UpdateDrillParams()
|
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 );
|
2017-04-28 10:53:30 +00:00
|
|
|
m_drillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection();
|
|
|
|
m_plotOpts.SetUseAuxOrigin( m_drillOriginIsAuxAxis );
|
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();
|
2019-02-09 13:56:02 +00:00
|
|
|
m_UseRouteModeForOvalHoles = m_radioBoxOvalHoleMode->GetSelection() == 0;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( m_Choice_Drill_Offset->GetSelection() == 0 )
|
|
|
|
m_FileDrillOffset = wxPoint( 0, 0 );
|
|
|
|
else
|
2019-02-13 10:41:52 +00:00
|
|
|
m_FileDrillOffset = m_pcbEditFrame->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
|
|
|
|
2016-10-07 14:57:45 +00:00
|
|
|
void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap )
|
2012-10-05 12:25:12 +00:00
|
|
|
{
|
2014-07-20 14:46:59 +00:00
|
|
|
UpdateConfig(); // set params and Save drill options
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2019-02-13 10:41:52 +00:00
|
|
|
m_pcbEditFrame->ClearMsgPanel();
|
2015-04-29 15:37:37 +00:00
|
|
|
WX_TEXT_CTRL_REPORTER reporter( m_messagesBox );
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
const PLOT_FORMAT 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
|
2015-04-29 15:37:37 +00:00
|
|
|
};
|
2016-10-07 14:57:45 +00:00
|
|
|
|
2015-04-29 15:37:37 +00:00
|
|
|
unsigned choice = (unsigned) m_Choice_Drill_Map->GetSelection();
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
if( choice >= arrayDim( filefmt ) )
|
2015-04-29 15:37:37 +00:00
|
|
|
choice = 1;
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2017-05-01 18:42:18 +00:00
|
|
|
// Create output directory if it does not exist (also transform it in
|
|
|
|
// absolute form). Bail if it fails
|
|
|
|
wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() );
|
2019-02-13 10:41:52 +00:00
|
|
|
wxString boardFilename = m_board->GetFileName();
|
2017-05-01 18:42:18 +00:00
|
|
|
|
|
|
|
if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Could not write drill and/or map files to folder \"%s\"." ),
|
|
|
|
GetChars( outputDir.GetPath() ) );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
if( m_drillFileType == 0 )
|
|
|
|
{
|
2019-02-13 10:41:52 +00:00
|
|
|
EXCELLON_WRITER excellonWriter( m_board );
|
2017-04-28 10:53:30 +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, m_Merge_PTH_NPTH );
|
2019-02-09 13:56:02 +00:00
|
|
|
excellonWriter.SetRouteModeForOvalHoles( m_UseRouteModeForOvalHoles );
|
2017-04-28 10:53:30 +00:00
|
|
|
excellonWriter.SetMapFileFormat( filefmt[choice] );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2017-05-01 18:42:18 +00:00
|
|
|
excellonWriter.CreateDrillandMapFilesSet( outputDir.GetFullPath(),
|
|
|
|
aGenDrill, aGenMap, &reporter );
|
2017-04-28 10:53:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-13 10:41:52 +00:00
|
|
|
GERBER_WRITER gerberWriter( m_board );
|
2017-04-28 10:53:30 +00:00
|
|
|
// Set gerber precision: only 5 or 6 digits for mantissa are allowed
|
|
|
|
// (SetFormat() accept 5 or 6, and any other value set the precision to 5)
|
|
|
|
// the integer part precision is always 4, and units always mm
|
|
|
|
gerberWriter.SetFormat( m_plotOpts.GetGerberPrecision() );
|
|
|
|
gerberWriter.SetOptions( m_FileDrillOffset );
|
|
|
|
gerberWriter.SetMapFileFormat( filefmt[choice] );
|
|
|
|
|
2017-05-01 18:42:18 +00:00
|
|
|
gerberWriter.CreateDrillandMapFilesSet( outputDir.GetFullPath(),
|
|
|
|
aGenDrill, aGenMap, &reporter );
|
2017-04-28 10:53:30 +00:00
|
|
|
}
|
2012-10-05 12:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GENDRILL::OnGenReportFile( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
UpdateConfig(); // set params and Save drill options
|
|
|
|
|
2019-02-13 10:41:52 +00:00
|
|
|
wxFileName fn = m_board->GetFileName();
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2016-10-07 14:57:45 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Drill Report File" ), defaultPath, fn.GetFullName(),
|
2017-11-12 00:31:38 +00:00
|
|
|
ReportFileWildcard(), wxFD_SAVE );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
bool success;
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
// Info is slightly different between Excellon and Gerber
|
|
|
|
// (file ext, Merge PTH/NPTH option)
|
|
|
|
if( m_drillFileType == 0 )
|
|
|
|
{
|
2019-02-13 10:41:52 +00:00
|
|
|
EXCELLON_WRITER excellonWriter( m_board );
|
2017-04-28 10:53:30 +00:00
|
|
|
excellonWriter.SetMergeOption( m_Merge_PTH_NPTH );
|
|
|
|
success = excellonWriter.GenDrillReportFile( dlg.GetPath() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-13 10:41:52 +00:00
|
|
|
GERBER_WRITER gerberWriter( m_board );
|
2017-04-28 10:53:30 +00:00
|
|
|
success = gerberWriter.GenDrillReportFile( dlg.GetPath() );
|
|
|
|
}
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|