KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_pcbnew_display_origin.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, [email protected]
5 * Copyright (C) 1992-2023 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 <pgm_base.h>
27#include <pcbnew_settings.h>
30
31
34 FRAME_T aFrameType ) :
36 m_cfg( aCfg ),
37 m_frameType( aFrameType )
38{
40}
41
42
44{
46 {
47 FOOTPRINT_EDITOR_SETTINGS* cfg = static_cast<FOOTPRINT_EDITOR_SETTINGS*>( aCfg );
48
49 m_XAxisDirection->SetSelection( cfg->m_DisplayInvertXAxis ? 1 : 0 );
50 m_YAxisDirection->SetSelection( cfg->m_DisplayInvertYAxis ? 0 : 1 );
51 }
52 else
53 {
54 PCBNEW_SETTINGS* cfg = static_cast<PCBNEW_SETTINGS*>( aCfg );
55 int origin = 0;
56
57 switch( cfg->m_Display.m_DisplayOrigin )
58 {
59 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE: origin = 0; break;
60 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX: origin = 1; break;
61 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID: origin = 2; break;
62 }
63
64 m_DisplayOrigin->SetSelection( origin );
65 m_XAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertXAxis ? 1 : 0 );
66 m_YAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertYAxis ? 0 : 1 );
67 }
68}
69
70
72{
74
75 return true;
76}
77
78
80{
82 {
84
85 cfg->m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0;
86 cfg->m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0;
87 }
88 else
89 {
90 PCBNEW_SETTINGS* cfg = static_cast<PCBNEW_SETTINGS*>( m_cfg );
91
92 switch( m_DisplayOrigin->GetSelection() )
93 {
94 case 0: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE; break;
95 case 1: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX; break;
96 case 2: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID; break;
97 }
98
99 cfg->m_Display.m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0;
100 cfg->m_Display.m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0;
101 }
102
103 return true;
104}
105
106
108{
110 {
112 cfg.Load(); // Loading without a file will init to defaults
113
114 loadSettings( &cfg );
115 }
116 else
117 {
118 PCBNEW_SETTINGS cfg;
119 cfg.Load(); // Loading without a file will init to defaults
120
121 loadSettings( &cfg );
122 }
123}
124
125
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
Class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE.
void ResetPanel() override
Reset the contents of this panel.
PANEL_PCBNEW_DISPLAY_ORIGIN(wxWindow *aParent, APP_SETTINGS_BASE *aCfg, FRAME_T aFrameType)
void loadSettings(APP_SETTINGS_BASE *aCfg)
DISPLAY_OPTIONS m_Display
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
see class PGM_BASE