KiCad PCB EDA Suite
panel_gerbview_excellon_settings.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2021 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <gerbview.h>
22 #include <gerbview_frame.h>
23 #include <gerbview_settings.h>
24 
26 #include <widgets/paged_dialog.h>
27 
28 
30  GERBVIEW_FRAME *aFrame, wxWindow* aWindow ) :
31  PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE( aWindow, wxID_ANY ),
32  m_Parent( aFrame )
33 {
34 }
35 
36 
38 {
39  GERBVIEW_SETTINGS* config = static_cast<GERBVIEW_SETTINGS*>( m_Parent->config() );
40  EXCELLON_DEFAULTS curr_settings;
41  config->GetExcellonDefaults( curr_settings );
42 
43  applySettingsToPanel( curr_settings );
44 
45  return true;
46 }
47 
48 
50 {
51  GERBVIEW_SETTINGS* config = static_cast<GERBVIEW_SETTINGS*>( m_Parent->config() );
52 
53  config->m_ExcellonDefaults.m_UnitsMM = m_rbUnits->GetSelection() != 0;
54  config->m_ExcellonDefaults.m_LeadingZero = m_rbZeroFormat->GetSelection();
55  // The first value of these param is 2, not 0
56  #define FIRST_VALUE 2
57  config->m_ExcellonDefaults.m_MmIntegerLen = m_choiceIntegerMM->GetSelection()+FIRST_VALUE;
58  config->m_ExcellonDefaults.m_MmMantissaLen = m_choiceMantissaMM->GetSelection()+FIRST_VALUE;
59  config->m_ExcellonDefaults.m_InchIntegerLen = m_choiceIntegerInch->GetSelection()+FIRST_VALUE;
60  config->m_ExcellonDefaults.m_InchMantissaLen = m_choiceMantissaInch->GetSelection()+FIRST_VALUE;
61 
62  return true;
63 }
64 
65 
67 {
68  EXCELLON_DEFAULTS defaults;
69  applySettingsToPanel( defaults );
70 }
71 
72 
74 {
75  m_rbUnits->SetSelection( aSettings.m_UnitsMM ? 1 : 0 );
76  m_rbZeroFormat->SetSelection( aSettings.m_LeadingZero );
77 
78  // The first value of these param is 2, not 0
79  #define FIRST_VALUE 2
80  m_choiceIntegerMM->SetSelection( aSettings.m_MmIntegerLen-FIRST_VALUE );
81  m_choiceMantissaMM->SetSelection( aSettings.m_MmMantissaLen-FIRST_VALUE );
82  m_choiceIntegerInch->SetSelection( aSettings.m_InchIntegerLen-FIRST_VALUE );
83  m_choiceMantissaInch->SetSelection( aSettings.m_InchMantissaLen-FIRST_VALUE );
84 }
85 
void applySettingsToPanel(const EXCELLON_DEFAULTS &aSettings)
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
PANEL_GERBVIEW_EXCELLON_SETTINGS(GERBVIEW_FRAME *aFrame, wxWindow *aWindow)
Class PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE.
#define FIRST_VALUE
management of default values used to read a Excellon (.nc) drill file Some important parameters are n...
void ResetPanel() override
Reset the contents of this panel.