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-2019 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  const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions();
45  const PCB_GENERAL_SETTINGS& general_opts = m_Frame->Settings();
46 
47  /* Set display options */
48  m_PolarDisplay->SetSelection( m_Frame->GetShowPolarCoords() ? 1 : 0 );
49  m_UnitsSelection->SetSelection( m_Frame->GetUserUnits() == INCHES ? 0 : 1 );
51  m_showGlobalRatsnest->SetValue( displ_opts.m_ShowGlobalRatsnest );
52  m_showSelectedRatsnest->SetValue( displ_opts.m_ShowModuleRatsnest );
54 
55  wxString rotationAngle;
56  rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() );
57  m_RotationAngle->SetValue( rotationAngle );
58 
59  m_Segments_45_Only_Ctrl->SetValue( general_opts.m_Use45DegreeGraphicSegments );
60  m_magneticPadChoice->SetSelection( general_opts.m_MagneticPads );
61  m_magneticTrackChoice->SetSelection( general_opts.m_MagneticTracks );
62  m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticGraphics );
63  m_FlipLeftRight->SetValue( general_opts.m_FlipLeftRight );
64 
66 
67  return true;
68 }
69 
70 
72 {
73  m_Frame->SetShowPolarCoords( m_PolarDisplay->GetSelection() != 0 );
74  m_Frame->SetUserUnits( m_UnitsSelection->GetSelection() == 0 ? INCHES : MILLIMETRES );
75 
76  m_Frame->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );
77 
78  /* Updating the combobox to display the active layer. */
79 
85 
87 
88  // Apply changes to the GAL
90  KIGFX::VIEW* view = m_Frame->GetCanvas()->GetView();
91  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
92  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
93 
95  displ_opts.m_ShowGlobalRatsnest = m_showGlobalRatsnest->GetValue();
96  displ_opts.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
97 
98  m_Frame->SetDisplayOptions( displ_opts );
99  settings->LoadDisplayOptions( displ_opts, m_Frame->ShowPageLimits() );
100  view->RecacheAllItems();
102 
103  m_Frame->GetCanvas()->Refresh();
104 
105  return true;
106 }
107 
108 
bool TransferDataFromWindow() override
PANEL_PCBNEW_SETTINGS(PCB_EDIT_FRAME *aFrame, PAGED_DIALOG *aWindow)
void SetUserUnits(EDA_UNITS_T aUnits)
bool TransferDataToWindow() override
void SetShowPolarCoords(bool aShow)
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
MAGNETIC_OPTIONS m_MagneticTracks
Class PANEL_PCBNEW_SETTINGS_BASE.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:226
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions returns the display options current in use Display options are relative to...
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
bool ShowPageLimits() const
Auxiliary rendering target (noncached)
Definition: definitions.h:49
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:61
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
MAGNETIC_OPTIONS m_MagneticPads
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:238
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
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:439
Definition: common.h:134
MAGNETIC_OPTIONS
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
int GetRotationAngle() const
Function GetRotationAngle() Returns the angle used for rotate operations.
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
void SetShowPageLimits(bool aShow)
Class VIEW.
Definition: view.h:61
void SetRotationAngle(int aRotationAngle)
Function SetRotationAngle() Sets the angle used for rotate operations.