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  m_MaxShowLinks->SetValue( displ_opts->m_MaxLinksShowed );
76 
77  m_DrcOn->SetValue( g_Drc_On );
82  m_ZoomCenterOpt->SetValue( ! GetParent()->GetCanvas()->GetEnableZoomNoCenter() );
83  m_MousewheelPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableMousewheelPan() );
84  m_AutoPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableAutoPan() );
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  displ_opts->m_MaxLinksShowed = m_MaxShowLinks->GetValue();
114  g_Drc_On = m_DrcOn->GetValue();
115 
117  {
119  GetParent()->GetCanvas()->Refresh();
120  GetParent()->OnModify();
121  }
122 
123  g_AutoDeleteOldTrack = m_TrackAutodel->GetValue();
126 
129  GetParent()->GetCanvas()->SetEnableAutoPan( m_AutoPANOpt->GetValue() );
130 
132  g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection();
134 
135  EndModal( wxID_OK );
136 }
bool g_Segments_45_Only
Definition: pcbnew.cpp:75
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:1004
bool g_Drc_On
Definition: pcbnew.cpp:70
void SetElementVisibility(int aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Definition: pcbframe.cpp:944
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
bool g_AutoDeleteOldTrack
Definition: pcbnew.cpp:71
This file is part of the common library.
void SetEnableZoomNoCenter(bool aEnable)
Definition: draw_panel.cpp:657
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
void OnOkClick(wxCommandEvent &event) override
Class BOARD to handle a board.
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...
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
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
void SetAutoSaveInterval(int aInterval)
Definition: basicframe.cpp:205
DIALOG_GENERALOPTIONS(PCB_EDIT_FRAME *parent)
int g_MagneticTrackOption
Definition: pcbnew.cpp:81
bool IsElementVisible(int aPCB_VISIBLE) const
Function IsElementVisible tests whether a given element category is visible.
bool g_Track_45_Only_Allowed
Definition: pcbnew.cpp:74
void SetEnableMousewheelPan(bool aEnable)
Definition: draw_panel.cpp:648
Class DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE.
int m_MaxLinksShowed
Definition: pcbstruct.h:86
int g_MagneticPadOption
Definition: pcbnew.cpp:80
void SetEnableAutoPan(bool aEnable)
void SetRotationAngle(int aRotationAngle)
Function SetRotationAngle() Sets the angle used for rotate operations.
bool g_TwoSegmentTrackBuild
Definition: pcbnew.cpp:76
void ReCreateAuxiliaryToolbar() override
Definition: tool_pcb.cpp:541
EDA_UNITS_T
Definition: common.h:144
int GetAutoSaveInterval() const
Definition: wxstruct.h:214