diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 55c8b9cf7d..c54b5b5d25 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -18,6 +18,8 @@ include_directories( set( DIALOGS_SRCS dialogs/panel_gerbview_display_options.cpp dialogs/panel_gerbview_display_options_base.cpp + dialogs/panel_gerbview_excellon_settings.cpp + dialogs/panel_gerbview_excellon_settings_base.cpp dialogs/panel_gerbview_settings.cpp dialogs/panel_gerbview_settings_base.cpp dialogs/dialog_layers_select_to_pcb.cpp diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.cpp b/gerbview/dialogs/panel_gerbview_display_options_base.cpp index 958a7cdc5e..69d330767b 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.cpp +++ b/gerbview/dialogs/panel_gerbview_display_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,53 +9,53 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE::PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE::PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { wxBoxSizer* bDialogSizer; bDialogSizer = new wxBoxSizer( wxVERTICAL ); - + m_UpperSizer = new wxBoxSizer( wxHORIZONTAL ); - + m_galOptionsSizer = new wxBoxSizer( wxVERTICAL ); - - + + m_UpperSizer->Add( m_galOptionsSizer, 1, wxEXPAND, 5 ); - + wxBoxSizer* bRightSizer; bRightSizer = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbSizer1; sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Annotations") ), wxVERTICAL ); - + m_OptDisplayDCodes = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Show D codes"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptDisplayDCodes->SetValue(true); + m_OptDisplayDCodes->SetValue(true); sbSizer1->Add( m_OptDisplayDCodes, 0, wxBOTTOM|wxLEFT, 5 ); - - + + bRightSizer->Add( sbSizer1, 0, wxEXPAND|wxALL, 5 ); - + wxStaticBoxSizer* sbSizer2; sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Drawing Mode") ), wxVERTICAL ); - + m_OptDisplayFlashedItems = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Sketch flashed items"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer2->Add( m_OptDisplayFlashedItems, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + m_OptDisplayLines = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Sketch lines"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer2->Add( m_OptDisplayLines, 0, wxALL, 5 ); - + m_OptDisplayPolygons = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Sketch polygons"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer2->Add( m_OptDisplayPolygons, 0, wxALL, 5 ); - - + + bRightSizer->Add( sbSizer2, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - + + m_UpperSizer->Add( bRightSizer, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - + + bDialogSizer->Add( m_UpperSizer, 1, wxEXPAND, 5 ); - - + + this->SetSizer( bDialogSizer ); this->Layout(); bDialogSizer->Fit( this ); diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.fbp b/gerbview/dialogs/panel_gerbview_display_options_base.fbp index 34b1372571..0290c324db 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.fbp +++ b/gerbview/dialogs/panel_gerbview_display_options_base.fbp @@ -1,8 +1,8 @@ - + - + C++ 1 source_name @@ -16,9 +16,9 @@ none 1 PanelGerbviewDisplayOptions - + . - + 1 1 1 @@ -29,57 +29,57 @@ 0 wxAUI_MGR_DEFAULT - - + + 1 1 impl_virtual - - + + 0 wxID_ANY - - + + PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE - + -1,-1 ; forward_declare - - - + + + wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bDialogSizer wxVERTICAL none @@ -88,7 +88,7 @@ wxEXPAND 1 - + m_UpperSizer wxHORIZONTAL protected @@ -97,7 +97,7 @@ wxEXPAND 1 - + m_galOptionsSizer wxVERTICAL protected @@ -108,7 +108,7 @@ wxEXPAND|wxRIGHT|wxLEFT 1 - + bRightSizer wxVERTICAL none @@ -119,12 +119,12 @@ wxID_ANY Annotations - + sbSizer1 wxVERTICAL 1 none - + 5 wxBOTTOM|wxLEFT @@ -134,83 +134,83 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Show D codes - + 0 - - + + 0 - + 1 m_OptDisplayDCodes 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -222,12 +222,12 @@ wxID_ANY Drawing Mode - + sbSizer2 wxVERTICAL 1 none - + 5 wxBOTTOM|wxRIGHT|wxLEFT @@ -237,83 +237,83 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Sketch flashed items - + 0 - - + + 0 - + 1 m_OptDisplayFlashedItems 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -325,83 +325,83 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Sketch lines - + 0 - - + + 0 - + 1 m_OptDisplayLines 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -413,83 +413,83 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Sketch polygons - + 0 - - + + 0 - + 1 m_OptDisplayPolygons 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.h b/gerbview/dialogs/panel_gerbview_display_options_base.h index f50a64698a..0343b5be08 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.h +++ b/gerbview/dialogs/panel_gerbview_display_options_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE_H__ -#define __PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE_H__ +#pragma once #include #include @@ -27,10 +26,10 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE : public wxPanel +class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE : public wxPanel { private: - + protected: wxBoxSizer* m_UpperSizer; wxBoxSizer* m_galOptionsSizer; @@ -38,12 +37,11 @@ class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE : public wxPanel wxCheckBox* m_OptDisplayFlashedItems; wxCheckBox* m_OptDisplayLines; wxCheckBox* m_OptDisplayPolygons; - + public: - - PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); + + PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE(); - + }; -#endif //__PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE_H__ diff --git a/gerbview/dialogs/panel_gerbview_excellon_settings.cpp b/gerbview/dialogs/panel_gerbview_excellon_settings.cpp new file mode 100644 index 0000000000..b5bd3ea887 --- /dev/null +++ b/gerbview/dialogs/panel_gerbview_excellon_settings.cpp @@ -0,0 +1,85 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 Jean-Pierre Charras jp.charras at wanadoo.fr + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 3 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, see . + */ + +#include +#include +#include + +#include "panel_gerbview_excellon_settings.h" +#include + + +PANEL_GERBVIEW_EXCELLON_SETTINGS::PANEL_GERBVIEW_EXCELLON_SETTINGS( + GERBVIEW_FRAME *aFrame, wxWindow* aWindow ) : + PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE( aWindow, wxID_ANY ), + m_Parent( aFrame ) +{ +} + + +bool PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataToWindow( ) +{ + GERBVIEW_SETTINGS* config = static_cast( m_Parent->config() ); + EXCELLON_DEFAULTS curr_settings; + config->GetExcellonDefaults( curr_settings ); + + applySettingsToPanel( curr_settings ); + + return true; +} + + +bool PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataFromWindow() +{ + GERBVIEW_SETTINGS* config = static_cast( m_Parent->config() ); + + config->m_ExcellonDefaults.m_UnitsMM = m_rbUnits->GetSelection() != 0; + config->m_ExcellonDefaults.m_LeadingZero = m_rbZeroFormat->GetSelection(); + // The first value of these param is 2, not 0 + #define FIRST_VALUE 2 + config->m_ExcellonDefaults.m_MmIntegerLen = m_choiceIntegerMM->GetSelection()+FIRST_VALUE; + config->m_ExcellonDefaults.m_MmMantissaLen = m_choiceMantissaMM->GetSelection()+FIRST_VALUE; + config->m_ExcellonDefaults.m_InchIntegerLen = m_choiceIntegerInch->GetSelection()+FIRST_VALUE; + config->m_ExcellonDefaults.m_InchMantissaLen = m_choiceMantissaInch->GetSelection()+FIRST_VALUE; + + return true; +} + + +void PANEL_GERBVIEW_EXCELLON_SETTINGS::ResetPanel() +{ + EXCELLON_DEFAULTS defaults; + applySettingsToPanel( defaults ); +} + + +void PANEL_GERBVIEW_EXCELLON_SETTINGS::applySettingsToPanel( const EXCELLON_DEFAULTS& aSettings ) +{ + m_rbUnits->SetSelection( aSettings.m_UnitsMM ? 1 : 0 ); + m_rbZeroFormat->SetSelection( aSettings.m_LeadingZero ); + + // The first value of these param is 2, not 0 + #define FIRST_VALUE 2 + m_choiceIntegerMM->SetSelection( aSettings.m_MmIntegerLen-FIRST_VALUE ); + m_choiceMantissaMM->SetSelection( aSettings.m_MmMantissaLen-FIRST_VALUE ); + m_choiceIntegerInch->SetSelection( aSettings.m_InchIntegerLen-FIRST_VALUE ); + m_choiceMantissaInch->SetSelection( aSettings.m_InchMantissaLen-FIRST_VALUE ); +} + diff --git a/gerbview/dialogs/panel_gerbview_excellon_settings.h b/gerbview/dialogs/panel_gerbview_excellon_settings.h new file mode 100644 index 0000000000..e2c0956e34 --- /dev/null +++ b/gerbview/dialogs/panel_gerbview_excellon_settings.h @@ -0,0 +1,49 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 + */ + +#pragma once + +#include "panel_gerbview_excellon_settings_base.h" + + +class GERBVIEW_FRAME; +class GAL_OPTIONS_PANEL; +struct EXCELLON_DEFAULTS; + + +class PANEL_GERBVIEW_EXCELLON_SETTINGS : public PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE +{ +public: + PANEL_GERBVIEW_EXCELLON_SETTINGS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow ); + ~PANEL_GERBVIEW_EXCELLON_SETTINGS() {}; + +private: + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + void ResetPanel() override; + + void applySettingsToPanel( const EXCELLON_DEFAULTS& aSettings ); + + GERBVIEW_FRAME* m_Parent; +}; + diff --git a/gerbview/dialogs/panel_gerbview_excellon_settings_base.cpp b/gerbview/dialogs/panel_gerbview_excellon_settings_base.cpp new file mode 100644 index 0000000000..757c0ab55c --- /dev/null +++ b/gerbview/dialogs/panel_gerbview_excellon_settings_base.cpp @@ -0,0 +1,131 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_gerbview_excellon_settings_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE::PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) +{ + wxBoxSizer* bDialogSizer; + bDialogSizer = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizerFileFormat; + sbSizerFileFormat = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("File Format") ), wxVERTICAL ); + + m_staticText11 = new wxStaticText( sbSizerFileFormat->GetStaticBox(), wxID_ANY, _("These parameters are usually specified in files, but not always."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText11->Wrap( -1 ); + sbSizerFileFormat->Add( m_staticText11, 0, wxALL, 5 ); + + wxBoxSizer* bSizer8; + bSizer8 = new wxBoxSizer( wxHORIZONTAL ); + + wxString m_rbUnitsChoices[] = { _("Inches"), _("mm") }; + int m_rbUnitsNChoices = sizeof( m_rbUnitsChoices ) / sizeof( wxString ); + m_rbUnits = new wxRadioBox( sbSizerFileFormat->GetStaticBox(), wxID_ANY, _("File units"), wxDefaultPosition, wxDefaultSize, m_rbUnitsNChoices, m_rbUnitsChoices, 1, wxRA_SPECIFY_COLS ); + m_rbUnits->SetSelection( 0 ); + bSizer8->Add( m_rbUnits, 1, wxALL, 5 ); + + wxString m_rbZeroFormatChoices[] = { _("No leading zeros (TZ format)"), _("No trailing zeros (LZ format)") }; + int m_rbZeroFormatNChoices = sizeof( m_rbZeroFormatChoices ) / sizeof( wxString ); + m_rbZeroFormat = new wxRadioBox( sbSizerFileFormat->GetStaticBox(), wxID_ANY, _("Zero format"), wxDefaultPosition, wxDefaultSize, m_rbZeroFormatNChoices, m_rbZeroFormatChoices, 1, wxRA_SPECIFY_COLS ); + m_rbZeroFormat->SetSelection( 0 ); + m_rbZeroFormat->SetToolTip( _("Integers in files can have their zeros stripped.\nNo leading zeros format means the leading zeros are stripped\nNo trailing zeros format means the trainling zeros are stripped") ); + + bSizer8->Add( m_rbZeroFormat, 1, wxALL, 5 ); + + + sbSizerFileFormat->Add( bSizer8, 1, wxEXPAND, 5 ); + + + bDialogSizer->Add( sbSizerFileFormat, 1, wxEXPAND, 5 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bDialogSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + + wxStaticBoxSizer* sbSizerCoordinates; + sbSizerCoordinates = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Coordinates Format") ), wxVERTICAL ); + + m_staticText6 = new wxStaticText( sbSizerCoordinates->GetStaticBox(), wxID_ANY, _("The coordinates format is not specified in Excellon format."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText6->Wrap( -1 ); + sbSizerCoordinates->Add( m_staticText6, 0, wxALL, 5 ); + + m_staticText10 = new wxStaticText( sbSizerCoordinates->GetStaticBox(), wxID_ANY, _("(The decimal format does not use these settings)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText10->Wrap( -1 ); + sbSizerCoordinates->Add( m_staticText10, 0, wxALL, 5 ); + + m_staticText7 = new wxStaticText( sbSizerCoordinates->GetStaticBox(), wxID_ANY, _("Usually: 3:3 in mm and 2:4 in inches"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText7->Wrap( -1 ); + sbSizerCoordinates->Add( m_staticText7, 0, wxALL, 5 ); + + wxFlexGridSizer* fgSizerFmt; + fgSizerFmt = new wxFlexGridSizer( 0, 4, 0, 0 ); + fgSizerFmt->SetFlexibleDirection( wxBOTH ); + fgSizerFmt->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticTextUnitsmm = new wxStaticText( sbSizerCoordinates->GetStaticBox(), wxID_ANY, _("Format for mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextUnitsmm->Wrap( -1 ); + fgSizerFmt->Add( m_staticTextUnitsmm, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_choiceIntegerMMChoices[] = { _("2"), _("3"), _("4"), _("5"), _("6") }; + int m_choiceIntegerMMNChoices = sizeof( m_choiceIntegerMMChoices ) / sizeof( wxString ); + m_choiceIntegerMM = new wxChoice( sbSizerCoordinates->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceIntegerMMNChoices, m_choiceIntegerMMChoices, 0 ); + m_choiceIntegerMM->SetSelection( 1 ); + fgSizerFmt->Add( m_choiceIntegerMM, 0, wxALL, 5 ); + + m_staticText8 = new wxStaticText( sbSizerCoordinates->GetStaticBox(), wxID_ANY, _(":"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText8->Wrap( -1 ); + fgSizerFmt->Add( m_staticText8, 0, wxALL, 5 ); + + wxString m_choiceMantissaMMChoices[] = { _("2"), _("3"), _("4"), _("5"), _("6") }; + int m_choiceMantissaMMNChoices = sizeof( m_choiceMantissaMMChoices ) / sizeof( wxString ); + m_choiceMantissaMM = new wxChoice( sbSizerCoordinates->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceMantissaMMNChoices, m_choiceMantissaMMChoices, 0 ); + m_choiceMantissaMM->SetSelection( 1 ); + fgSizerFmt->Add( m_choiceMantissaMM, 0, wxALL, 5 ); + + m_staticTextUnitsInch = new wxStaticText( sbSizerCoordinates->GetStaticBox(), wxID_ANY, _("Format for inches"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextUnitsInch->Wrap( -1 ); + fgSizerFmt->Add( m_staticTextUnitsInch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_choiceIntegerInchChoices[] = { _("2"), _("3"), _("4"), _("5"), _("6") }; + int m_choiceIntegerInchNChoices = sizeof( m_choiceIntegerInchChoices ) / sizeof( wxString ); + m_choiceIntegerInch = new wxChoice( sbSizerCoordinates->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceIntegerInchNChoices, m_choiceIntegerInchChoices, 0 ); + m_choiceIntegerInch->SetSelection( 0 ); + fgSizerFmt->Add( m_choiceIntegerInch, 0, wxALL, 5 ); + + m_staticText9 = new wxStaticText( sbSizerCoordinates->GetStaticBox(), wxID_ANY, _(":"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText9->Wrap( -1 ); + fgSizerFmt->Add( m_staticText9, 0, wxALL, 5 ); + + wxString m_choiceMantissaInchChoices[] = { _("2"), _("3"), _("4"), _("5"), _("6") }; + int m_choiceMantissaInchNChoices = sizeof( m_choiceMantissaInchChoices ) / sizeof( wxString ); + m_choiceMantissaInch = new wxChoice( sbSizerCoordinates->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceMantissaInchNChoices, m_choiceMantissaInchChoices, 0 ); + m_choiceMantissaInch->SetSelection( 2 ); + fgSizerFmt->Add( m_choiceMantissaInch, 0, wxALL, 5 ); + + + sbSizerCoordinates->Add( fgSizerFmt, 1, wxEXPAND, 5 ); + + + bDialogSizer->Add( sbSizerCoordinates, 1, wxEXPAND, 5 ); + + + this->SetSizer( bDialogSizer ); + this->Layout(); + + // Connect Events + m_choiceIntegerMM->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE::onUnitsChange ), NULL, this ); + m_choiceIntegerInch->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE::onUnitsChange ), NULL, this ); +} + +PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE::~PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE() +{ + // Disconnect Events + m_choiceIntegerMM->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE::onUnitsChange ), NULL, this ); + m_choiceIntegerInch->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE::onUnitsChange ), NULL, this ); + +} diff --git a/gerbview/dialogs/panel_gerbview_excellon_settings_base.fbp b/gerbview/dialogs/panel_gerbview_excellon_settings_base.fbp new file mode 100644 index 0000000000..9a222f2e0b --- /dev/null +++ b/gerbview/dialogs/panel_gerbview_excellon_settings_base.fbp @@ -0,0 +1,1053 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_gerbview_excellon_settings_base + 1000 + none + + 1 + PanelGerbviewExcellonSettings + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE + + 440,336 + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare + + + + wxTAB_TRAVERSAL + + + bDialogSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + File Format + + sbSizerFileFormat + wxVERTICAL + 1 + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + These parameters are usually specified in files, but not always. + 0 + + 0 + + + 0 + + 1 + m_staticText11 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 1 + + + bSizer8 + wxHORIZONTAL + none + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Inches" "mm" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + File units + 1 + + 0 + + + 0 + + 1 + m_rbUnits + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "No leading zeros (TZ format)" "No trailing zeros (LZ format)" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Zero format + 1 + + 0 + + + 0 + + 1 + m_rbZeroFormat + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + ; ; forward_declare + 0 + Integers in files can have their zeros stripped. No leading zeros format means the leading zeros are stripped No trailing zeros format means the trainling zeros are stripped + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND + 1 + + wxID_ANY + Coordinates Format + + sbSizerCoordinates + wxVERTICAL + 1 + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + The coordinates format is not specified in Excellon format. + 0 + + 0 + + + 0 + + 1 + m_staticText6 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (The decimal format does not use these settings) + 0 + + 0 + + + 0 + + 1 + m_staticText10 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Usually: 3:3 in mm and 2:4 in inches + 0 + + 0 + + + 0 + + 1 + m_staticText7 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 1 + + 4 + wxBOTH + + + 0 + + fgSizerFmt + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Format for mm + 0 + + 0 + + + 0 + + 1 + m_staticTextUnitsmm + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "2" "3" "4" "5" "6" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choiceIntegerMM + 1 + + + protected + 1 + + Resizable + 1 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onUnitsChange + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + : + 0 + + 0 + + + 0 + + 1 + m_staticText8 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "2" "3" "4" "5" "6" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choiceMantissaMM + 1 + + + protected + 1 + + Resizable + 1 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Format for inches + 0 + + 0 + + + 0 + + 1 + m_staticTextUnitsInch + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "2" "3" "4" "5" "6" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choiceIntegerInch + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onUnitsChange + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + : + 0 + + 0 + + + 0 + + 1 + m_staticText9 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "2" "3" "4" "5" "6" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choiceMantissaInch + 1 + + + protected + 1 + + Resizable + 2 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + diff --git a/gerbview/dialogs/panel_gerbview_excellon_settings_base.h b/gerbview/dialogs/panel_gerbview_excellon_settings_base.h new file mode 100644 index 0000000000..8d669a4ec3 --- /dev/null +++ b/gerbview/dialogs/panel_gerbview_excellon_settings_base.h @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include "widgets/resettable_panel.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE : public RESETTABLE_PANEL +{ + private: + + protected: + wxStaticText* m_staticText11; + wxRadioBox* m_rbUnits; + wxRadioBox* m_rbZeroFormat; + wxStaticLine* m_staticline1; + wxStaticText* m_staticText6; + wxStaticText* m_staticText10; + wxStaticText* m_staticText7; + wxStaticText* m_staticTextUnitsmm; + wxChoice* m_choiceIntegerMM; + wxStaticText* m_staticText8; + wxChoice* m_choiceMantissaMM; + wxStaticText* m_staticTextUnitsInch; + wxChoice* m_choiceIntegerInch; + wxStaticText* m_staticText9; + wxChoice* m_choiceMantissaInch; + + // Virtual event handlers, overide them in your derived class + virtual void onUnitsChange( wxCommandEvent& event ) { event.Skip(); } + + + public: + + PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 440,336 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE(); + +}; + diff --git a/gerbview/excellon_defaults.h b/gerbview/excellon_defaults.h new file mode 100644 index 0000000000..6775dd3355 --- /dev/null +++ b/gerbview/excellon_defaults.h @@ -0,0 +1,60 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 Jean-Pierre Charras jp.charras at wanadoo.fr + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 3 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, see . + */ + +#pragma once + +// Default format for coordinates: they are the default values, not the actual values +// defaut format is 3:3 in mm and 2:4 in inch +// +// number of digits in mantissa: +#define FMT_MANTISSA_MM 3 +#define FMT_MANTISSA_INCH 4 +// number of digits, integer part: +#define FMT_INTEGER_MM 3 +#define FMT_INTEGER_INCH 2 + + +/** + * management of default values used to read a Excellon (.nc) drill file + * Some important parameters are not defined in drill files, and some others + * can be missing in poor drill files. + * These default values are used when parameter is not found in file + */ +struct EXCELLON_DEFAULTS +{ + bool m_UnitsMM; // false = inch, true = mm + bool m_LeadingZero; // True = LZ false = TZ + int m_MmIntegerLen; // number of digits for the integer part of a coordinate in mm + int m_MmMantissaLen; // number of digits for the mantissa part of a coordinate in mm + int m_InchIntegerLen; // number of digits for the integer part of a coordinate in inch + int m_InchMantissaLen; // number of digits for the mantissa part of a coordinate in inch + + EXCELLON_DEFAULTS() { ResetToDefaults(); } + + void ResetToDefaults() + { + m_UnitsMM = false; + m_LeadingZero = true; + m_MmIntegerLen = FMT_INTEGER_MM; + m_MmMantissaLen = FMT_MANTISSA_MM; + m_InchIntegerLen = FMT_INTEGER_INCH; + m_InchMantissaLen = FMT_MANTISSA_INCH; + } +}; diff --git a/gerbview/excellon_image.h b/gerbview/excellon_image.h index 5bda861442..ed2f2572f4 100644 --- a/gerbview/excellon_image.h +++ b/gerbview/excellon_image.h @@ -25,6 +25,8 @@ #ifndef EXCELLON_IMAGE_H #define EXCELLON_IMAGE_H +struct EXCELLON_DEFAULTS; + enum drill_M_code_t { DRILL_M_UNKNOWN, @@ -155,10 +157,11 @@ public: EXCELLON_IMAGE( int layer ) : * * When the file cannot be loaded, warning and info messages are stored in m_Messages. * - * @param aFullFileName is the full filename of the Gerber file. + * @param aFullFileName is the full filename of the Excellon file. + * @param aDefaults is the default values when not found in file. * @return true if OK, false if the gerber file was not loaded. */ - bool LoadFile( const wxString& aFullFileName ); + bool LoadFile( const wxString& aFullFileName, EXCELLON_DEFAULTS* aDefaults ); private: bool Execute_HEADER_And_M_Command( char*& text ); @@ -190,7 +193,10 @@ private: */ void FinishRouteCommand(); - void SelectUnits( bool aMetric ); + /** + * Switch unit selection, and the coordinate format (nn:mm) if not yet set + */ + void SelectUnits( bool aMetric, EXCELLON_DEFAULTS* aDefaults ); private: enum EXCELLON_STATE { @@ -204,6 +210,12 @@ private: bool m_RouteModeOn; // true during a route mode (for instance a oval hole) or // a cutout. std::vector m_RoutePositions; // The list of points in a route mode + + /// Excellon file do not have a format statement to specify the coordinate format + /// like nn:mm. + /// However Altium files have a comment to specify it (";FILE_FORMET_" + /// m_hasFormat is set to true if this comment is found, and coordinate format is known. + bool m_hasFormat; }; diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 8ef546fa1d..f9f48a1070 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -69,24 +69,18 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include -// Default format for dimensions: they are the default values, not the actual values -// number of digits in mantissa: -static const int fmtMantissaMM = 3; -static const int fmtMantissaInch = 4; -// number of digits, integer part: -static const int fmtIntegerMM = 3; -static const int fmtIntegerInch = 2; - // A helper function to calculate the arc center of an arc // known by 2 end points, the radius, and the angle direction (CW or CCW) // Arc angles are <= 180 degrees in circular interpol. @@ -257,8 +251,12 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) std::unique_ptr drill_layer_uptr = std::make_unique( layerId ); + EXCELLON_DEFAULTS nc_defaults; + GERBVIEW_SETTINGS* cfg = static_cast( config() ); + cfg->GetExcellonDefaults( nc_defaults ); + // Read the Excellon drill file: - bool success = drill_layer_uptr->LoadFile( aFullFileName ); + bool success = drill_layer_uptr->LoadFile( aFullFileName, &nc_defaults ); if( !success ) { @@ -300,7 +298,9 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) void EXCELLON_IMAGE::ResetDefaultValues() { GERBER_FILE_IMAGE::ResetDefaultValues(); - SelectUnits( false ); // Default unit = inch + SelectUnits( false, nullptr ); // Default unit = inch + m_hasFormat = false; // will be true if a Altium file containing + // the nn:mm file format is read // Files using non decimal can use No Trailing zeros or No leading Zeros // Unfortunately, the identifier (INCH,TZ or INCH,LZ for instance) is not @@ -321,7 +321,7 @@ void EXCELLON_IMAGE::ResetDefaultValues() * integer 2.4 format in imperial units, * integer 3.2 or 3.3 format (metric units). */ -bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName ) +bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName, EXCELLON_DEFAULTS* aDefaults ) { // Set the default parameter values: ResetDefaultValues(); @@ -332,6 +332,10 @@ bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName ) if( m_Current_File == nullptr ) return false; + // Initial format setting, usualy defined in file, but not always... + m_NoTrailingZeros = aDefaults->m_LeadingZero; + m_GerbMetric = aDefaults->m_UnitsMM; + wxString msg; m_FileName = aFullFileName; @@ -354,6 +358,9 @@ bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName ) if( m_State == EXCELLON_IMAGE::READ_HEADER_STATE ) { Execute_HEADER_And_M_Command( text ); + + // Now units (inch/mm) are known, set the coordinate format + SelectUnits( m_GerbMetric, aDefaults ); } else { @@ -486,12 +493,12 @@ bool EXCELLON_IMAGE::Execute_HEADER_And_M_Command( char*& text ) break; case DRILL_M_METRIC: - SelectUnits( true ); + SelectUnits( true, nullptr ); break; case DRILL_IMPERIAL_HEADER: // command like INCH,TZ or INCH,LZ case DRILL_METRIC_HEADER: // command like METRIC,TZ or METRIC,LZ - SelectUnits( cmd->m_Code == DRILL_METRIC_HEADER ? true : false ); + SelectUnits( cmd->m_Code == DRILL_METRIC_HEADER ? true : false, nullptr ); if( *text != ',' ) { @@ -915,7 +922,7 @@ bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command( char*& text ) return success; } -void EXCELLON_IMAGE::SelectUnits( bool aMetric ) +void EXCELLON_IMAGE::SelectUnits( bool aMetric, EXCELLON_DEFAULTS* aDefaults ) { /* Coordinates are measured either in inch or metric (millimeters). * Inch coordinates are in six digits (00.0000) with increments @@ -928,6 +935,8 @@ void EXCELLON_IMAGE::SelectUnits( bool aMetric ) * * Inches: Default fmt = 2.4 for X and Y axis: 6 digits with 0.0001 resolution * metric: Default fmt = 3.3 for X and Y axis: 6 digits, 1 micron resolution + * + * However some drill files do not use standard values. */ if( aMetric ) { @@ -935,10 +944,19 @@ void EXCELLON_IMAGE::SelectUnits( bool aMetric ) if( !m_hasFormat ) { - // number of digits in mantissa - m_FmtScale.x = m_FmtScale.y = fmtMantissaMM; - // number of digits (mantissa+integer) - m_FmtLen.x = m_FmtLen.y = fmtIntegerMM + fmtMantissaMM; + if( aDefaults ) + { + // number of digits in mantissa + m_FmtScale.x = m_FmtScale.y = aDefaults->m_MmMantissaLen; + // number of digits (mantissa+integer) + m_FmtLen.x = m_FmtLen.y = aDefaults->m_MmIntegerLen + + aDefaults->m_MmMantissaLen; + } + else + { + m_FmtScale.x = m_FmtScale.y = FMT_MANTISSA_MM; + m_FmtLen.x = m_FmtLen.y = FMT_INTEGER_MM + FMT_MANTISSA_MM; + } } } else @@ -947,8 +965,17 @@ void EXCELLON_IMAGE::SelectUnits( bool aMetric ) if( !m_hasFormat ) { - m_FmtScale.x = m_FmtScale.y = fmtMantissaInch; - m_FmtLen.x = m_FmtLen.y = fmtIntegerInch + fmtMantissaInch; + if( aDefaults ) + { + m_FmtScale.x = m_FmtScale.y = aDefaults->m_InchMantissaLen; + m_FmtLen.x = m_FmtLen.y = aDefaults->m_InchIntegerLen + + aDefaults->m_InchMantissaLen; + } + else + { + m_FmtScale.x = m_FmtScale.y = FMT_MANTISSA_INCH; + m_FmtLen.x = m_FmtLen.y = FMT_INTEGER_INCH + FMT_MANTISSA_INCH; + } } } } diff --git a/gerbview/gerber_file_image.cpp b/gerbview/gerber_file_image.cpp index a65130b009..fbdc3501ab 100644 --- a/gerbview/gerber_file_image.cpp +++ b/gerbview/gerber_file_image.cpp @@ -183,7 +183,6 @@ void GERBER_FILE_IMAGE::ResetDefaultValues() m_ImageJustifyXCenter = false; // Image Justify Center on X axis (default = false) m_ImageJustifyYCenter = false; // Image Justify Center on Y axis (default = false) m_GerbMetric = false; // false = Inches (default), true = metric - m_hasFormat = false; m_Relative = false; // false = absolute Coord, // true = relative Coord m_NoTrailingZeros = false; // true: trailing zeros deleted diff --git a/gerbview/gerber_file_image.h b/gerbview/gerber_file_image.h index 933a59e00e..348448a894 100644 --- a/gerbview/gerber_file_image.h +++ b/gerbview/gerber_file_image.h @@ -379,7 +379,6 @@ public: ///< Image Justify Offset on XY axis (default = 0,0). wxPoint m_ImageJustifyOffset; bool m_GerbMetric; // false = Inches, true = metric - bool m_hasFormat; ///< false = absolute Coord, true = relative Coord. bool m_Relative; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 824d479577..e799f7fd63 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -1015,8 +1016,11 @@ void GERBVIEW_FRAME::InstallPreferences( PAGED_DIALOG* aParent, wxTreebook* book = aParent->GetTreebook(); book->AddPage( new wxPanel( book ), _( "GerbView" ) ); - book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) ); + book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), + _( "Display Options" ) ); book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) ); + book->AddSubPage( new PANEL_GERBVIEW_EXCELLON_SETTINGS( this, book ), + _( "Excellon Options" ) ); aHotkeysPanel->AddHotKeys( GetToolManager() ); } diff --git a/gerbview/gerbview_settings.cpp b/gerbview/gerbview_settings.cpp index b29ccc0f7a..f7e798f2d7 100644 --- a/gerbview/gerbview_settings.cpp +++ b/gerbview/gerbview_settings.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * -* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. +* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -67,6 +67,24 @@ GERBVIEW_SETTINGS::GERBVIEW_SETTINGS() : m_params.emplace_back( new PARAM( "gerber_to_pcb_copperlayers_count", &m_BoardLayersCount, 2 ) ); + + m_params.emplace_back( new PARAM( "excellon_defaults.unit_mm", + &m_ExcellonDefaults.m_UnitsMM, false ) ); + + m_params.emplace_back( new PARAM( "excellon_defaults.lz_format", + &m_ExcellonDefaults.m_LeadingZero, true ) ); + + m_params.emplace_back( new PARAM( "excellon_defaults.mm_integer_len", + &m_ExcellonDefaults.m_MmIntegerLen, FMT_INTEGER_MM, 2 , 6 ) ); + + m_params.emplace_back( new PARAM( "excellon_defaults.mm_mantissa_len", + &m_ExcellonDefaults.m_MmMantissaLen, FMT_MANTISSA_MM, 2 , 6 ) ); + + m_params.emplace_back( new PARAM( "excellon_defaults.inch_integer_len", + &m_ExcellonDefaults.m_InchIntegerLen, FMT_INTEGER_INCH, 2 , 6 ) ); + + m_params.emplace_back( new PARAM( "excellon_defaults.inch_mantissa_len", + &m_ExcellonDefaults.m_InchMantissaLen, FMT_MANTISSA_INCH, 2 , 6 ) ); } diff --git a/gerbview/gerbview_settings.h b/gerbview/gerbview_settings.h index 55a624d5d2..6804915190 100644 --- a/gerbview/gerbview_settings.h +++ b/gerbview/gerbview_settings.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * -* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. +* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,6 +25,7 @@ #define _GERBVIEW_SETTINGS_H #include +#include class GERBVIEW_SETTINGS : public APP_SETTINGS_BASE @@ -44,6 +45,15 @@ public: virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; + /** + * return the Excellon default values to read a drill file + * @param aNCDefaults is the EXCELLON_DEFAULTS to store these prms + */ + void GetExcellonDefaults( EXCELLON_DEFAULTS& aNCDefaults ) + { + aNCDefaults = m_ExcellonDefaults; + } + public: APPEARANCE m_Appearance; @@ -62,6 +72,8 @@ public: */ std::vector m_GerberToPcbLayerMapping; + EXCELLON_DEFAULTS m_ExcellonDefaults; + protected: virtual std::string getLegacyFrameName() const override { return "GerberFrame"; }