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( "MagneticGraphics", &m_magneticGraphics, true );
40  Add( "EditActionChangesTrackWidth", &m_editActionChangesTrackWidth, false );
41  Add( "DragSelects", &m_dragSelects, true );
42  break;
43 
45  Add( "Use45DegreeGraphicSegments", &m_use45DegreeGraphicSegments, false);
46  Add( "MagneticPads", reinterpret_cast<int*>( &m_magneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL );
47  Add( "DragSelects", &m_dragSelects, true );
48  break;
49 
50  default:
51  break;
52  }
53 }
54 
55 
56 void PCB_GENERAL_SETTINGS::Load( wxConfigBase* aCfg )
57 {
58  m_colorsSettings.Load( aCfg );
59 
60 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
61 
62  m_pluginSettings.clear();
63 
64  wxString pluginSettings = aCfg->Read( "ActionPluginButtons" );
65 
66  wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( pluginSettings, ";" );
67 
68  while( pluginSettingsTokenizer.HasMoreTokens() )
69  {
70  wxString plugin = pluginSettingsTokenizer.GetNextToken();
71  wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin, "=" );
72 
73  if( pluginTokenizer.CountTokens() != 2 )
74  {
75  // Bad config
76  continue;
77  }
78 
79  plugin = pluginTokenizer.GetNextToken();
80  m_pluginSettings.push_back( std::make_pair( plugin, pluginTokenizer.GetNextToken() ) );
81  }
82 
83 #endif
84 
85  SETTINGS::Load( aCfg );
86 }
87 
88 
89 void PCB_GENERAL_SETTINGS::Save( wxConfigBase* aCfg )
90 {
91  m_colorsSettings.Save( aCfg );
92 
93 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
94 
95  wxString pluginSettings;
96 
97  for( auto const& entry : m_pluginSettings )
98  {
99  if( !pluginSettings.IsEmpty() )
100  {
101  pluginSettings = pluginSettings + wxT( ";" );
102  }
103  pluginSettings = pluginSettings + entry.first + wxT( "=" ) + entry.second;
104  }
105 
106  aCfg->Write( "ActionPluginButtons" , pluginSettings );
107 
108 #endif
109 
110  SETTINGS::Save( aCfg );
111 }
112 
113 
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