KiCad PCB EDA Suite
panel_pcbnew_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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2018 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 
25 #include <fctsys.h>
26 #include <pcbnew.h>
27 #include <pcb_edit_frame.h>
28 #include <board_design_settings.h>
29 #include <pcbnew_id.h>
30 #include <class_board.h>
31 #include <panel_pcbnew_settings.h>
32 #include <widgets/paged_dialog.h>
33 #include <pcb_view.h>
34 #include <pcb_painter.h>
35 
37  PANEL_PCBNEW_SETTINGS_BASE( aParent->GetTreebook() ),
38  m_Frame( aFrame )
39 {}
40 
41 
43 {
44  auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_Frame->GetDisplayOptions();
45 
46  /* Set display options */
47  m_PolarDisplay->SetSelection( displ_opts->m_DisplayPolarCood ? 1 : 0 );
48  m_UnitsSelection->SetSelection( m_Frame->GetUserUnits() == INCHES ? 0 : 1 );
49 
50  wxString rotationAngle;
51  rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() );
52  m_RotationAngle->SetValue( rotationAngle );
53 
54  m_DrcOn->SetValue( m_Frame->Settings().m_legacyDrcOn );
63 
65 
66  return true;
67 }
68 
69 
71 {
72  auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_Frame->GetDisplayOptions();
73  displ_opts->m_DisplayPolarCood = m_PolarDisplay->GetSelection() != 0;
74 
75  m_Frame->SetUserUnits( m_UnitsSelection->GetSelection() == 0 ? INCHES : MILLIMETRES );
76 
77  m_Frame->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );
78 
79  /* Updating the combobox to display the active layer. */
80  m_Frame->Settings().m_legacyDrcOn = m_DrcOn->GetValue();
81 
85 
91 
93 
94  // Apply changes to the GAL
96  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
97  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
98  settings->LoadDisplayOptions( displ_opts, m_Frame->ShowPageLimits() );
99 
100  return true;
101 }
102 
103 
bool ShowPageLimits() const
Definition: draw_frame.h:385
bool TransferDataFromWindow() override
PANEL_PCBNEW_SETTINGS(PCB_EDIT_FRAME *aFrame, PAGED_DIALOG *aWindow)
bool TransferDataToWindow() override
Class BOARD to handle a board.
MAGNETIC_PAD_OPTION_VALUES m_magneticPads
Class PANEL_PCBNEW_SETTINGS_BASE.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:211
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
static bool m_use45DegreeGraphicSegments
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
MAGNETIC_PAD_OPTION_VALUES m_magneticTracks
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:223
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:421
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
Definition: common.h:160
int GetRotationAngle() const
Function GetRotationAngle() Returns the angle used for rotate operations.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
MAGNETIC_PAD_OPTION_VALUES
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS *aOptions, bool aShowPageLimits)
Function LoadDisplayOptions Loads settings related to display options (high-contrast mode...
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:921
void SetShowPageLimits(bool aShow)
Definition: draw_frame.h:386
Class VIEW.
Definition: view.h:61
void SetRotationAngle(int aRotationAngle)
Function SetRotationAngle() Sets the angle used for rotate operations.
void SetUserUnits(EDA_UNITS_T aUnits)
Definition: draw_frame.h:285