KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
18*/
19
21#include <settings/parameters.h>
22#include <wx/config.h>
24
25
27const int cvpcbSchemaVersion = 0;
28
31 m_FilterFlags( 0 ),
34{
35 // We always snap and don't let the user configure it
39
40 // Init settings:
41 m_params.emplace_back( new PARAM<int>( "filter_footprint", &m_FilterFlags, 0 ) );
42 m_params.emplace_back( new PARAM<wxString>( "filter_footprint_text", &m_FilterString, "" ) );
43
44 m_params.emplace_back( new PARAM<int>( "libraries_pane_width", &m_LibrariesWidth, 0 ) );
45 m_params.emplace_back( new PARAM<int>( "footprints_pane_width", &m_FootprintsWidth, 0 ) );
46
47 addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
48
49 m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
50 &m_FootprintViewerZoom, 1.0 ) );
51 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
53
54 m_params.emplace_back( new PARAM<int>( "footprint_viewer.angle_snap_mode",
55 reinterpret_cast<int*>( &m_ViewersDisplay.m_AngleSnapMode ),
56 static_cast<int>( LEADER_MODE::DEG45 ) ) );
57
58 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_pad_fill",
59 &m_ViewersDisplay.m_DisplayPadFill, true ) );
60
61 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_pad_number",
62 &m_ViewersDisplay.m_DisplayPadNumbers, true ) );
63
64 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_text_fill",
65 &m_ViewersDisplay.m_DisplayTextFill, true ) );
66
67 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_graphic_fill",
68 &m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
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)
Migrate legacy window settings into the JSON document.
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath, int aDefaultWidth=0, int aDefaultHeight=0)
Add parameters for the given window object.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
MAGNETIC_SETTINGS m_FootprintViewerMagneticSettings
WINDOW_SETTINGS m_FootprintViewer
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
wxString m_FilterString
bool fromLegacy(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig value to a given JSON pointer value.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
PCB_VIEWERS_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
const int cvpcbSchemaVersion
! Update the schema version whenever a migration is required
a few functions useful in geometry calculations.
@ DEG45
45 Degree only