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 {
38  // We always snap and don't let the user configure it
42 
43  // Init settings:
44  m_params.emplace_back( new PARAM<int>( "filter_footprint", &m_FilterFootprint, 0 ) );
45 
46  addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
47 
48  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_fill",
50 
51  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_numbers",
53 
54  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.footprint_text_fill",
56 
57  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.graphic_items_fill",
59 
60  m_params.emplace_back( new PARAM<bool>( "footprint_viewer.auto_zoom",
61  &m_FootprintViewerAutoZoom, false ) );
62 
63  m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
64  &m_FootprintViewerZoom, 1.0 ) );
65 
66 }
67 
68 
69 bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
70 {
71  bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
72 
73  ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" );
74 
75  ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" );
76 
77  ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" );
78  ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" );
79  ret &= fromLegacy<bool>(
80  aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" );
81 
82  ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameAutoZoom", "footprint_viewer.auto_zoom" );
83  ret &= fromLegacy<double>( aCfg, "FootprintViewerFrameZoom", "footprint_viewer.zoom" );
84 
85  return ret;
86 }
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:91
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