1 /*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020-2021 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 #ifndef _EESCHEMA_SETTINGS_H
25 #define _EESCHEMA_SETTINGS_H
26 
27 #include <settings/app_settings.h>
28 
29 
30 using KIGFX::COLOR4D;
31 
32 
33 class EESCHEMA_SETTINGS : public APP_SETTINGS_BASE
34 {
35 public:
36     struct APPEARANCE
37     {
38         wxString edit_component_visible_columns;
39         wxString edit_sheet_visible_columns;
40         int  erc_severities;
41         bool footprint_preview;
42         bool navigator_stays_open;
43         bool print_sheet_reference;
44         bool show_hidden_pins;
45         bool show_hidden_fields;
46         bool show_illegal_symbol_lib_dialog;
47         bool show_page_limits;
48         bool show_sexpr_file_convert_warning;
49         bool show_sheet_filename_case_sensitivity_dialog;
50     };
51 
52     struct AUTOPLACE_FIELDS
53     {
54         bool enable;
55         bool allow_rejustify;
56         bool align_to_grid;
57     };
58 
59     struct BOM_PLUGIN_SETTINGS
60     {
61         BOM_PLUGIN_SETTINGS() = default;
62 
BOM_PLUGIN_SETTINGSBOM_PLUGIN_SETTINGS63         BOM_PLUGIN_SETTINGS( const wxString& aName, const wxString& aPath ) :
64                 name( aName ),
65                 path( aPath )
66         {}
67 
68         wxString name;
69         wxString path;
70         wxString command;
71     };
72 
73     struct NETLIST_PLUGIN_SETTINGS
74     {
75         NETLIST_PLUGIN_SETTINGS() = default;
76 
NETLIST_PLUGIN_SETTINGSNETLIST_PLUGIN_SETTINGS77         NETLIST_PLUGIN_SETTINGS( const wxString& aName, const wxString& aPath ) :
78                 name( aName ),
79                 path( aPath )
80         {}
81 
82         wxString name;
83         wxString path;
84         wxString command;
85     };
86 
87     struct DRAWING
88     {
89         int      default_bus_thickness;
90         int      default_junction_size;
91         int      default_line_thickness;
92         int      default_repeat_offset_x;
93         int      default_repeat_offset_y;
94         int      default_wire_thickness;
95         int      default_text_size;
96         int      pin_symbol_size;
97         double   text_offset_ratio;
98         COLOR4D  default_sheet_border_color;
99         COLOR4D  default_sheet_background_color;
100         wxString field_names;
101         bool     hv_lines_only;
102         int      repeat_label_increment;
103         bool     intersheets_ref_show;
104         bool     intersheets_ref_own_page;
105         bool     intersheets_ref_short;
106         wxString intersheets_ref_prefix;
107         wxString intersheets_ref_suffix;
108         bool     auto_start_wires;
109         std::vector<double> junction_size_mult_list;
110         // Pulldown index for user default junction dot size (e.g. smallest = 0, small = 1, etc)
111         int      junction_size_choice;
112     };
113 
114     struct INPUT
115     {
116         bool drag_is_move;
117     };
118 
119     struct SELECTION
120     {
121         int  thickness;
122         bool draw_selected_children;
123         bool fill_shapes;
124         bool select_pin_selects_symbol;
125         bool text_as_box;
126     };
127 
128     struct PAGE_SETTINGS
129     {
130         bool export_paper;
131         bool export_revision;
132         bool export_date;
133         bool export_title;
134         bool export_company;
135         bool export_comment1;
136         bool export_comment2;
137         bool export_comment3;
138         bool export_comment4;
139         bool export_comment5;
140         bool export_comment6;
141         bool export_comment7;
142         bool export_comment8;
143         bool export_comment9;
144     };
145 
146     struct PANEL_ANNOTATE
147     {
148         int scope;
149         int options;
150         int method;
151         int messages_filter;
152         int sort_order;
153     };
154 
155     struct PANEL_BOM
156     {
157         wxString selected_plugin;
158         std::vector<BOM_PLUGIN_SETTINGS> plugins;
159     };
160 
161     struct PANEL_FIELD_EDITOR
162     {
163         std::map<std::string, bool> fields_show;
164         std::map<std::string, bool> fields_group_by;
165         std::map<std::string, int> column_widths;
166     };
167 
168     struct PANEL_LIB_VIEW
169     {
170         int lib_list_width;
171         int cmp_list_width;
172         bool show_pin_electrical_type;
173         WINDOW_SETTINGS window;
174     };
175 
176     struct PANEL_NETLIST
177     {
178         std::vector<NETLIST_PLUGIN_SETTINGS> plugins;
179     };
180 
181     struct PANEL_PLOT
182     {
183         bool     background_color;
184         bool     color;
185         wxString color_theme;
186         int      format;
187         bool     frame_reference;
188         int      hpgl_paper_size;
189         double   hpgl_pen_size;
190         int      hpgl_origin;
191     };
192 
193     struct PANEL_SYM_CHOOSER
194     {
195         int  sash_pos_h;
196         int  sash_pos_v;
197         int  width;
198         int  height;
199         bool keep_symbol;
200         bool place_all_units;
201     };
202 
203     struct SIMULATOR
204     {
205         int plot_panel_width;
206         int plot_panel_height;
207         int signal_panel_height;
208         int cursors_panel_height;
209         bool white_background;
210         WINDOW_SETTINGS window;
211     };
212 
213     EESCHEMA_SETTINGS();
214 
~EESCHEMA_SETTINGS()215     virtual ~EESCHEMA_SETTINGS() {}
216 
217     virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
218 
219     static std::vector<BOM_PLUGIN_SETTINGS> DefaultBomPlugins();
220 
221 
222 protected:
getLegacyFrameName()223     virtual std::string getLegacyFrameName() const override { return "SchematicFrame"; }
224 
225 private:
226     bool migrateBomSettings();
227 
228     nlohmann::json bomSettingsToJson() const;
229 
230     static std::vector<BOM_PLUGIN_SETTINGS> bomSettingsFromJson( const nlohmann::json& aObj );
231 
232     nlohmann::json netlistSettingsToJson() const;
233     static std::vector<NETLIST_PLUGIN_SETTINGS> netlistSettingsFromJson( const nlohmann::json& aObj );
234 
235 public:
236     APPEARANCE m_Appearance;
237 
238     AUTOPLACE_FIELDS m_AutoplaceFields;
239 
240     DRAWING m_Drawing;
241 
242     INPUT m_Input;
243 
244     PAGE_SETTINGS m_PageSettings;
245 
246     PANEL_ANNOTATE m_AnnotatePanel;
247 
248     PANEL_BOM m_BomPanel;
249 
250     PANEL_FIELD_EDITOR m_FieldEditorPanel;
251 
252     PANEL_LIB_VIEW m_LibViewPanel;
253 
254     PANEL_NETLIST m_NetlistPanel;
255 
256     PANEL_PLOT m_PlotPanel;
257 
258     PANEL_SYM_CHOOSER m_SymChooserPanel;
259 
260     SELECTION m_Selection;
261 
262     SIMULATOR m_Simulator;
263 
264     bool m_RescueNeverShow;
265 
266     wxString m_lastSymbolLibDir;
267 };
268 
269 
270 #endif
271