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) 2022 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
25#include <settings/parameters.h>
26#include <wx/config.h>
27
28
30const int cvpcbSchemaVersion = 0;
31
34 m_FootprintViewerZoom( 1.0 ),
35 m_FootprintViewerAutoZoomOnSelect( true ),
36 m_FilterFlags( 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_FilterFlags, 0 ) );
47 m_params.emplace_back( new PARAM<wxString>( "filter_footprint_text", &m_FilterString, "" ) );
48
49 m_params.emplace_back( new PARAM<int>( "libraries_pane_width", &m_LibrariesWidth, 0 ) );
50 m_params.emplace_back( new PARAM<int>( "footprints_pane_width", &m_FootprintsWidth, 0 ) );
51
52 addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
53
54 m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom", &m_FootprintViewerZoom, 1.0 ) );
55 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
57
58 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_pad_fill",
60
61 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_pad_number",
63
64 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_text_fill",
66
67 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_graphic_fill",
69}
70
71
72bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
73{
74 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
75
76 ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" );
77
78 ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" );
79
80 ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" );
81 ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" );
82 ret &= fromLegacy<bool>(
83 aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" );
84
85 ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameAutoZoom", "footprint_viewer.auto_zoom" );
86 ret &= fromLegacy<double>( aCfg, "FootprintViewerFrameZoom", "footprint_viewer.zoom" );
87
88 return ret;
89}
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrates legacy window settings into the JSON document.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Adds parameters for the given window object.
MAGNETIC_SETTINGS m_FootprintViewerMagneticSettings
WINDOW_SETTINGS m_FootprintViewer
double m_FootprintViewerZoom
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
bool m_FootprintViewerAutoZoomOnSelect
wxString m_FilterString
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
const int cvpcbSchemaVersion
! Update the schema version whenever a migration is required
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads