KiCad PCB EDA Suite
dialog_general_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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 /* functions relatives to the dialogs opened from the main menu :
30  * Preferences/general
31  * Preferences/display
32  */
33 #include <fctsys.h>
34 #include <class_drawpanel.h>
35 #include <confirm.h>
36 #include <pcbnew.h>
37 #include <wxPcbStruct.h>
39 #include <kicad_string.h>
40 #include <pcbnew_id.h>
41 #include <class_board.h>
42 #include <collectors.h>
43 #include <dialog_general_options.h>
44 
45 
48 {
49  init();
50 
51  GetSizer()->SetSizeHints( this );
52  Center();
53 }
54 
55 
57 {
58  SetFocus();
59  m_sdbSizerOK->SetDefault();
60 
61  m_Board = GetParent()->GetBoard();
63 
64  /* Set display options */
65  m_PolarDisplay->SetSelection( displ_opts->m_DisplayPolarCood ? 1 : 0 );
66  m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 );
67 
68  wxString rotationAngle;
69  rotationAngle = AngleToStringDegrees( (double)GetParent()->GetRotationAngle() );
70  m_RotationAngle->SetValue( rotationAngle );
71 
72  wxString timevalue;
73  timevalue << GetParent()->GetAutoSaveInterval() / 60;
74  m_SaveTime->SetValue( timevalue );
75 
76  m_DrcOn->SetValue( GetParent()->Settings().m_legacyDrcOn );
78  m_TrackAutodel->SetValue( GetParent()->Settings().m_legacyAutoDeleteOldTrack );
79  m_Track_45_Only_Ctrl->SetValue( GetParent()->Settings().m_legacyUse45DegreeTracks );
80  m_Segments_45_Only_Ctrl->SetValue( GetParent()->Settings().m_use45DegreeGraphicSegments );
81  m_ZoomCenterOpt->SetValue( ! GetParent()->GetCanvas()->GetEnableZoomNoCenter() );
82  m_MousewheelPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableMousewheelPan() );
83  m_AutoPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableAutoPan() );
84  m_Track_DoubleSegm_Ctrl->SetValue( GetParent()->Settings().m_legacyUseTwoSegmentTracks );
85  m_MagneticPadOptCtrl->SetSelection( GetParent()->Settings().m_magneticPads );
86  m_MagneticTrackOptCtrl->SetSelection( GetParent()->Settings().m_magneticTracks );
87  m_UseEditKeyForWidth->SetValue( GetParent()->Settings().m_editActionChangesTrackWidth );
88 }
89 
90 
91 void DIALOG_GENERALOPTIONS::OnCancelClick( wxCommandEvent& event )
92 {
93  event.Skip();
94 }
95 
96 
97 void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event )
98 {
99  EDA_UNITS_T ii;
101 
102  displ_opts->m_DisplayPolarCood = ( m_PolarDisplay->GetSelection() == 0 ) ? false : true;
103  ii = g_UserUnit;
104  g_UserUnit = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES;
105 
106  if( ii != g_UserUnit )
108 
109  GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 );
110  GetParent()->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );
111 
112  /* Updating the combobox to display the active layer. */
113  GetParent()->Settings().m_legacyDrcOn = m_DrcOn->GetValue();
114 
116  {
118  GetParent()->GetCanvas()->Refresh();
119  GetParent()->OnModify();
120  }
121 
125 
128  GetParent()->GetCanvas()->SetEnableAutoPan( m_AutoPANOpt->GetValue() );
129 
134 
135  EndModal( wxID_OK );
136 }
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:1001
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Definition: pcbframe.cpp:941
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
This file is part of the common library.
void SetEnableZoomNoCenter(bool aEnable)
Definition: draw_panel.cpp:656
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:337
void OnOkClick(wxCommandEvent &event) override
Class BOARD to handle a board.
MAGNETIC_PAD_OPTION_VALUES m_magneticPads
BOARD * GetBoard() const
bool m_DisplayPolarCood
Definition: pcbstruct.h:76
PCB_EDIT_FRAME * GetParent() const
void OnCancelClick(wxCommandEvent &event) override
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
MAGNETIC_PAD_OPTION_VALUES m_magneticTracks
PCB_GENERAL_SETTINGS & Settings()
wxString AngleToStringDegrees(double aAngle)
Function AngleToStringDegrees is a helper to convert the double aAngle (in internal unit) to a string...
Definition: base_units.cpp:409
Definition: common.h:145
MAGNETIC_PAD_OPTION_VALUES
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
void SetAutoSaveInterval(int aInterval)
Definition: basicframe.cpp:224
DIALOG_GENERALOPTIONS(PCB_EDIT_FRAME *parent)
void SetEnableMousewheelPan(bool aEnable)
Definition: draw_panel.cpp:647
Class DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE.
void SetEnableAutoPan(bool aEnable)
void SetRotationAngle(int aRotationAngle)
Function SetRotationAngle() Sets the angle used for rotate operations.
void ReCreateAuxiliaryToolbar() override
Definition: tool_pcb.cpp:546
EDA_UNITS_T
Definition: common.h:144
int GetAutoSaveInterval() const
Definition: wxstruct.h:227