KiCad PCB EDA Suite
gerbview_config.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) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <id.h>
33 #include <common.h>
34 #include <class_drawpanel.h>
35 #include <config_params.h>
36 
37 #include <gerbview.h>
38 #include <gerbview_frame.h>
39 #include <hotkeys.h>
40 #include <dialog_hotkeys_editor.h>
41 
42 
43 void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event )
44 {
45  int id = event.GetId();
46 
47  switch( id )
48  {
49  // Hotkey IDs
51  ExportHotkeyConfigToFile( GerbviewHokeysDescr, wxT( "gerbview" ) );
52  break;
53 
55  ImportHotkeyConfigFromFile( GerbviewHokeysDescr, wxT( "gerbview" ) );
56  break;
57 
60  break;
61 
63 
64  // Display current hotkey list for GerbView.
66  break;
67 
68  default:
69  wxMessageBox( wxT( "GERBVIEW_FRAME::Process_Config error" ) );
70  break;
71  }
72 }
73 
74 
76 {
77  if( !m_configSettings.empty() )
78  return m_configSettings;
79 
80  m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ),
81  (int*) &g_UserUnit, 0, 0, 1 ) );
82 
83  m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "DrawModeOption" ),
84  &m_displayMode, 2, 0, 2 ) );
85  m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
86  wxT( "DCodeColorEx" ),
88  LAYER_DCODES],
89  WHITE ) );
90  m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
91  wxT( "NegativeObjectsColorEx" ),
94  DARKGRAY ) );
95  m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
96  wxT( "GridColorEx" ),
99  DARKGRAY ) );
100  m_configSettings.push_back( new PARAM_CFG_BOOL( true,
101  wxT( "DisplayPolarCoordinates" ),
103  false ) );
104 
105  // Default colors for layers 0 to 31
106  static const COLOR4D color_default[] = {
115  };
116 
117  // List of keywords used as identifiers in config.
118  // They *must* be static const and not temporarily created,
119  // because the parameter list that use these keywords does not store them,
120  // just points to them.
121  static const wxChar* keys[] = {
122  wxT("ColorLayer0Ex"), wxT("ColorLayer1Ex"), wxT("ColorLayer2Ex"), wxT("ColorLayer3Ex"),
123  wxT("ColorLayer4Ex"), wxT("ColorLayer5Ex"), wxT("ColorLayer6Ex"), wxT("ColorLayer7Ex"),
124  wxT("ColorLayer8Ex"), wxT("ColorLayer9Ex"), wxT("ColorLayer10Ex"), wxT("ColorLayer11Ex"),
125  wxT("ColorLayer12Ex"), wxT("ColorLayer13Ex"), wxT("ColorLayer14Ex"), wxT("ColorLayer15Ex"),
126  wxT("ColorLayer16Ex"), wxT("ColorLayer17Ex"), wxT("ColorLayer18Ex"), wxT("ColorLayer19Ex"),
127  wxT("ColorLayer20Ex"), wxT("ColorLayer21Ex"), wxT("ColorLayer22Ex"), wxT("ColorLayer23Ex"),
128  wxT("ColorLayer24Ex"), wxT("ColorLayer25Ex"), wxT("ColorLayer26Ex"), wxT("ColorLayer27Ex"),
129  wxT("ColorLayer28Ex"), wxT("ColorLayer29Ex"), wxT("ColorLayer30Ex"), wxT("ColorLayer31Ex"),
130  };
131 
132  wxASSERT( DIM(keys) == DIM(color_default) );
133  wxASSERT( DIM(keys) <= DIM(g_ColorsSettings.m_LayersColors) && DIM(keys) <= DIM(color_default) );
134 
135  for( unsigned i = 0; i < DIM(keys); ++i )
136  {
138 
139  PARAM_CFG_SETCOLOR* prm_entry =
140  new PARAM_CFG_SETCOLOR( true, keys[i], prm, color_default[i] );
141 
142  m_configSettings.push_back( prm_entry );
143  }
144 
145  return m_configSettings;
146 }
Definition: colors.h:57
#define DIM(x)
of elements in an array
Definition: macros.h:98
A list of parameters type.
Definition: colors.h:61
void ExportHotkeyConfigToFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it...
The common library.
void Process_Config(wxCommandEvent &event)
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
PARAM_CFG_ARRAY m_configSettings
Configuration parameter - SetColor Class.
GBR_DISPLAY_OPTIONS m_DisplayOptions
Configuration parameter - Integer Class.
Definition: colors.h:59
COLORS_DESIGN_SETTINGS g_ColorsSettings(FRAME_CVPCB_DISPLAY)
Configuration parameter - Boolean Class.
Definition: colors.h:60
bool m_DisplayPolarCood
Option to display coordinates in status bar in X,Y or Polar coords.
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
void InstallHotkeyFrame(EDA_BASE_FRAME *aParent, EDA_HOTKEY_CONFIG *aHotkeys)
Function InstallHotkeyFrame Create a hotkey editor dialog window with the provided hotkey configurati...
Definition: colors.h:58
PARAM_CFG_ARRAY & GetConfigurationSettings(void)
Function GetConfigurationSettings Populates the GerbView applications settings list.
struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[]
The common library.
Definition: colors.h:49
#define GERBER_DRAW_LAYER(x)
void ImportHotkeyConfigFromFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it.
Definition: colors.h:68
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62