KiCad PCB EDA Suite
pcb_general_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) 2012-2017 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 <pcb_general_settings.h>
25 #include <wx/tokenzr.h>
26 
28  : m_frameType( aFrameType ), m_colorsSettings( aFrameType )
29 {
30  switch( m_frameType )
31  {
32  case FRAME_PCB:
33  Add( "LegacyAutoDeleteOldTrack", &m_legacyAutoDeleteOldTrack, true );
34  Add( "LegacyUse45DegreeTracks",&m_legacyUse45DegreeTracks, true);
35  Add( "LegacyUseTwoSegmentTracks", &m_legacyUseTwoSegmentTracks, true);
36  Add( "Use45DegreeGraphicSegments", &m_use45DegreeGraphicSegments, false);
37  Add( "MagneticPads", reinterpret_cast<int*>( &m_magneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL );
38  Add( "MagneticTracks", reinterpret_cast<int*>( &m_magneticTracks ), CAPTURE_CURSOR_IN_TRACK_TOOL );
39  Add( "EditActionChangesTrackWidth", &m_editActionChangesTrackWidth, false );
40  Add( "DragSelects", &m_dragSelects, true );
41  break;
42 
44  Add( "Use45DegreeGraphicSegments", &m_use45DegreeGraphicSegments, false);
45  Add( "MagneticPads", reinterpret_cast<int*>( &m_magneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL );
46  Add( "DragSelects", &m_dragSelects, true );
47  break;
48 
49  default:
50  break;
51  }
52 }
53 
54 
55 void PCB_GENERAL_SETTINGS::Load( wxConfigBase* aCfg )
56 {
57  m_colorsSettings.Load( aCfg );
58 
59 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
60 
61  m_pluginSettings.clear();
62 
63  wxString pluginSettings = aCfg->Read( "ActionPluginButtons" );
64 
65  wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( pluginSettings, ";" );
66 
67  while( pluginSettingsTokenizer.HasMoreTokens() )
68  {
69  wxString plugin = pluginSettingsTokenizer.GetNextToken();
70  wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin, "=" );
71 
72  if( pluginTokenizer.CountTokens() != 2 )
73  {
74  // Bad config
75  continue;
76  }
77 
78  plugin = pluginTokenizer.GetNextToken();
79  m_pluginSettings.push_back( std::make_pair( plugin, pluginTokenizer.GetNextToken() ) );
80  }
81 
82 #endif
83 
84  SETTINGS::Load( aCfg );
85 }
86 
87 
88 void PCB_GENERAL_SETTINGS::Save( wxConfigBase* aCfg )
89 {
90  m_colorsSettings.Save( aCfg );
91 
92 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
93 
94  wxString pluginSettings;
95 
96  for( auto const& entry : m_pluginSettings )
97  {
98  if( !pluginSettings.IsEmpty() )
99  {
100  pluginSettings = pluginSettings + wxT( ";" );
101  }
102  pluginSettings = pluginSettings + entry.first + wxT( "=" ) + entry.second;
103  }
104 
105  aCfg->Write( "ActionPluginButtons" , pluginSettings );
106 
107 #endif
108 
109  SETTINGS::Save( aCfg );
110 }
111 
112 
void Load(wxConfigBase *aCfg) override
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
virtual void Save(wxConfigBase *aConfig)
Definition: settings.cpp:39
MAGNETIC_PAD_OPTION_VALUES m_magneticPads
virtual void Load(wxConfigBase *aConfig)
Definition: settings.cpp:26
virtual void Save(wxConfigBase *aConfig) override
void Add(const wxString &name, int *aPtr, int aDefaultValue)
Definition: settings.h:93
PCB_GENERAL_SETTINGS(FRAME_T aFrameType)
static bool m_use45DegreeGraphicSegments
MAGNETIC_PAD_OPTION_VALUES m_magneticTracks
COLORS_DESIGN_SETTINGS m_colorsSettings
virtual void Load(wxConfigBase *aConfig) override
void Save(wxConfigBase *aCfg) override