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 The 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
33 FRAME_T aFrameType ) :
35 m_cfg( aCfg ),
36 m_frameType( aFrameType )
37{
39}
40
41
43{
45 {
46 FOOTPRINT_EDITOR_SETTINGS* cfg = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" );
47
48 if( cfg && cfg->m_DisplayInvertXAxis )
49 m_xIncreasesLeft->SetValue( true );
50 else
51 m_xIncreasesRight->SetValue( true );
52
53 if( cfg && cfg->m_DisplayInvertYAxis )
54 m_yIncreasesUp->SetValue( true );
55 else
56 m_yIncreasesDown->SetValue( true );
57 }
58 else
59 {
60 PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
61
62 if( cfg && cfg->m_Display.m_DisplayOrigin == PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE )
63 m_pageOrigin->SetValue( true );
64 else if( cfg && cfg->m_Display.m_DisplayOrigin == PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID )
65 m_gridOrigin->SetValue( true );
66 else
67 m_drillPlaceOrigin->SetValue( true );
68
69 if( cfg &&cfg->m_Display.m_DisplayInvertXAxis )
70 m_xIncreasesLeft->SetValue( true );
71 else
72 m_xIncreasesRight->SetValue( true );
73
74 if( cfg && cfg->m_Display.m_DisplayInvertYAxis )
75 m_yIncreasesUp->SetValue( true );
76 else
77 m_yIncreasesDown->SetValue( true );
78 }
79}
80
81
83{
85
86 return true;
87}
88
89
91{
93 {
94 if( FOOTPRINT_EDITOR_SETTINGS* cfg = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" ) )
95 {
96 cfg->m_DisplayInvertXAxis = m_xIncreasesLeft->GetValue();
97 cfg->m_DisplayInvertYAxis = m_yIncreasesUp->GetValue();
98 }
99 }
100 else
101 {
102 if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
103 {
104 if( m_pageOrigin->GetValue() )
105 cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE;
106 else if( m_gridOrigin->GetValue() )
107 cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID;
108 else
109 cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX;
110
111 cfg->m_Display.m_DisplayInvertXAxis = m_xIncreasesLeft->GetValue();
112 cfg->m_Display.m_DisplayInvertYAxis = m_yIncreasesUp->GetValue();
113 }
114 }
115
116 return true;
117}
118
119
121{
123 {
125 cfg.Load(); // Loading without a file will init to defaults
126
127 loadSettings( &cfg );
128 }
129 else
130 {
131 PCBNEW_SETTINGS cfg;
132 cfg.Load(); // Loading without a file will init to defaults
133
134 loadSettings( &cfg );
135 }
136}
137
138
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:108
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