KiCad PCB EDA Suite
dialog_modedit_options.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) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
27 #include <fctsys.h>
28 #include <pcbnew.h>
29 #include <pcb_edit_frame.h>
30 #include <board_design_settings.h>
31 #include <base_units.h>
32 #include <widgets/text_ctrl_eval.h>
33 
34 #include <footprint_edit_frame.h>
35 
37 
38 
40 {
43 
44 public:
46 
47 private:
48  void OnCancelClick( wxCommandEvent& event ) override { EndModal( wxID_CANCEL ); }
49  void OnOkClick( wxCommandEvent& event ) override;
50 
51  void initValues( );
52 };
53 
54 
57 {
58  m_parent = aParent;
60  initValues();
61 
62  m_sdbSizer1OK->SetDefault();
63  GetSizer()->SetSizeHints( this );
64 
65  Centre();
66 }
67 
68 
70 {
71  DIALOG_MODEDIT_OPTIONS dlg( aCaller );
72 
73  int ret = dlg.ShowModal();
74 
75  return ret == wxID_OK;
76 }
77 
78 
80 {
81  EDA_UNITS_T units = g_UserUnit;
82  auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_parent->GetDisplayOptions();
83 
84  // Modules: graphic lines width:
87 
88  // Modules: Texts: Size & width:
91 
94 
97 
98  // Ref: default values
100  int sel = m_brdSettings.m_RefDefaultlayer == F_SilkS ? 0 : 1;
101  m_choiceLayerReference->SetSelection( sel );
103  m_choiceVisibleReference->SetSelection( sel );
104 
105  // Value: default values
107  sel = m_brdSettings.m_ValueDefaultlayer == F_SilkS ? 0 : 1;
108  m_choiceLayerValue->SetSelection( sel );
110  m_choiceVisibleValue->SetSelection( sel );
111 
112  // Display options
113  m_PolarDisplay->SetSelection( displ_opts->m_DisplayPolarCood ? 1 : 0 );
114  m_UnitsSelection->SetSelection( g_UserUnit == INCHES ? 0 : 1 );
115 
116  // Editing options
120 }
121 
122 
123 void DIALOG_MODEDIT_OPTIONS::OnOkClick( wxCommandEvent& event )
124 {
129 
130  // Ref: default values
132  int sel = m_choiceLayerReference->GetSelection();
134  sel = m_choiceVisibleReference->GetSelection();
136 
137  // Value: default values
139  sel = m_choiceLayerValue->GetSelection();
141  sel = m_choiceVisibleValue->GetSelection();
143 
145 
146  // Display options
147  auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_parent->GetDisplayOptions();
148  displ_opts->m_DisplayPolarCood = m_PolarDisplay->GetSelection() != 0;
149 
150  EDA_UNITS_T units = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES;
151  if( units != g_UserUnit )
152  {
153  g_UserUnit = units;
155  }
156 
157  // Editing options
160  m_parent->Settings().m_dragSelects = m_dragSelects->GetValue();
161 
162  EndModal( wxID_OK );
163 }
wxString m_RefDefaultText
Default ref text on fp creation.
DIALOG_MODEDIT_OPTIONS(FOOTPRINT_EDIT_FRAME *aParent)
bool m_ValueDefaultVisibility
Default value text visibility on fp creation.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
Implementation of conversion functions that require both schematic and board internal units...
int m_ModuleTextWidth
Default footprint texts thickness.
int m_ModuleSegmentWidth
Default width for all graphic lines.
void ReCreateAuxiliaryToolbar() override
MAGNETIC_PAD_OPTION_VALUES m_magneticPads
Class DIALOG_MODEDIT_OPTIONS_BASE.
int m_ValueDefaultlayer
Default value text layer on fp creation.
wxSize m_ModuleTextSize
Default footprint texts size.
void OnCancelClick(wxCommandEvent &event) override
Definition of class FOOTPRINT_EDIT_FRAME.
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
bool InvokeFPEditorPrefsDlg(FOOTPRINT_EDIT_FRAME *aCaller)
Function InvokeSVGPrint shows the SVG print dialog.
static bool m_use45DegreeGraphicSegments
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_GENERAL_SETTINGS & Settings()
Definition: common.h:146
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit)
Definition: base_units.cpp:485
FOOTPRINT_EDIT_FRAME * m_parent
void OnOkClick(wxCommandEvent &event) override
wxString m_ValueDefaultText
Default value text on fp creation.
int ValueFromTextCtrl(const wxTextCtrl &aTextCtr)
Convert the number Value in a string according to the internal units and the selected unit (g_UserUni...
Definition: base_units.cpp:386
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings) override
void PutValueInLocalUnits(wxTextCtrl &aTextCtr, int aValue)
Function PutValueInLocalUnits converts aValue from internal units to user units and append the units ...
Definition: base_units.cpp:267
BOARD_DESIGN_SETTINGS m_brdSettings
int m_RefDefaultlayer
Default ref text layer on fp creation.
bool m_RefDefaultVisibility
Default ref text visibility on fp creation.
EDA_UNITS_T
Definition: common.h:145
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.