KiCad PCB EDA Suite
cvpcb_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) 2020 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23 
24 #include <cvpcb_settings.h>
25 #include <settings/parameters.h>
26 #include <wx/config.h>
27 
28 
30 const int cvpcbSchemaVersion = 0;
31 
34  m_FootprintViewerAutoZoom( false ),
35  m_FootprintViewerZoom( 1.0 ),
36  m_FilterFootprint( 0 ),
37  m_LibrariesWidth( 0 ),
38  m_FootprintsWidth( 0 )
39 {
40  // We always snap and don't let the user configure it
44 
45  // Init settings:
46  m_params.emplace_back( new PARAM<int>( "filter_footprint", &m_FilterFootprint, 0 ) );
47 
48  m_params.emplace_back( new PARAM<int>( "libraries_pane_width", &m_LibrariesWidth, 0 ) );
49  m_params.emplace_back( new PARAM<int>( "footprints_pane_width", &m_FootprintsWidth, 0 ) );
50 
51  addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
52 
53  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_fill",
55 
56  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_numbers",
58 
59  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.footprint_text_fill",
61 
62  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.graphic_items_fill",
64 
65  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.auto_zoom",
66  &m_FootprintViewerAutoZoom, false ) );
67 
68  m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
69  &m_FootprintViewerZoom, 1.0 ) );
70 
71 }
72 
73 
74 bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
75 {
76  bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
77 
78  ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" );
79 
80  ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" );
81 
82  ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" );
83  ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" );
84  ret &= fromLegacy<bool>(
85  aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" );
86 
87  ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameAutoZoom", "footprint_viewer.auto_zoom" );
88  ret &= fromLegacy<double>( aCfg, "FootprintViewerFrameZoom", "footprint_viewer.zoom" );
89 
90  return ret;
91 }
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Adds parameters for the given window object.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
double m_FootprintViewerZoom
MAGNETIC_SETTINGS m_FootprintViewerMagneticSettings
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
bool m_FootprintViewerAutoZoom
WINDOW_SETTINGS m_FootprintViewer
const int cvpcbSchemaVersion
! Update the schema version whenever a migration is required
MAGNETIC_OPTIONS pads
PCB_DISPLAY_OPTIONS m_FootprintViewerDisplayOptions
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrates legacy window settings into the JSON document.
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
MAGNETIC_OPTIONS tracks