KiCad PCB EDA Suite
PCBNEW_SETTINGS Class Reference

#include <pcbnew_settings.h>

Inheritance diagram for PCBNEW_SETTINGS:
PCB_VIEWERS_SETTINGS_BASE APP_SETTINGS_BASE JSON_SETTINGS

Classes

struct  AUI_PANELS
 
struct  DIALOG_CLEANUP
 
struct  DIALOG_DRC
 
struct  DIALOG_EXPORT_IDF
 
struct  DIALOG_EXPORT_STEP
 
struct  DIALOG_EXPORT_SVG
 
struct  DIALOG_EXPORT_VRML
 
struct  DIALOG_FOOTPRINT_WIZARD_LIST
 
struct  DIALOG_GENERATE_DRILL
 
struct  DIALOG_IMPORT_GRAPHICS
 
struct  DIALOG_NETLIST
 
struct  DIALOG_PLACE_FILE
 
struct  DIALOG_PLOT
 
struct  DIALOG_REANNOTATE
 
struct  DISPLAY_OPTIONS
 
struct  FOOTPRINT_CHOOSER
 
struct  ZONES
 

Public Member Functions

 PCBNEW_SETTINGS ()
 
virtual ~PCBNEW_SETTINGS ()
 
virtual bool MigrateFromLegacy (wxConfigBase *aLegacyConfig) override
 Migrates from wxConfig to JSON-based configuration. More...
 
virtual const std::vector< wxString > DefaultGridSizeList () const
 By default, this returns the list of grids available in PcbNew-based applications. More...
 
wxString GetFilename () const
 
wxString GetFullFilename () const
 
void SetFilename (const wxString &aFilename)
 
void SetLocation (SETTINGS_LOC aLocation)
 
SETTINGS_LOC GetLocation () const
 
void SetLegacyFilename (const wxString &aFilename)
 
bool IsReadOnly () const
 
void SetReadOnly (bool aReadOnly)
 
nlohmann::jsonAt (const std::string &aPath)
 Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these functions take a string that is passed to PointerFromString internally. More...
 
bool Contains (const std::string &aPath) const
 
size_t Count (const std::string &aPath) const
 
JSON_SETTINGS_INTERNALSInternals ()
 
virtual void Load ()
 Updates the parameters of this object based on the current JSON document contents. More...
 
virtual bool Store ()
 Stores the current parameters into the JSON document represented by this object Note: this doesn't do any writing to disk; that's handled by SETTINGS_MANAGER. More...
 
virtual bool LoadFromFile (const wxString &aDirectory="")
 Loads the backing file from disk and then calls Load() More...
 
virtual bool SaveToFile (const wxString &aDirectory="", bool aForce=false)
 
void ResetToDefaults ()
 Resets all parameters to default values. More...
 
std::optional< nlohmann::jsonGetJson (const std::string &aPath) const
 Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1.key2.key3" to refer to nested objects. More...
 
template<typename ValueType >
std::optional< ValueType > Get (const std::string &aPath) const
 Fetches a value from within the JSON document. More...
 
template<>
std::optional< wxString > Get (const std::string &aPath) const
 
template<typename ValueType >
void Set (const std::string &aPath, ValueType aVal)
 Stores a value into the JSON document Will throw an exception if ValueType isn't something that the library can handle. More...
 
template<>
void Set (const std::string &aPath, wxString aVal)
 
template<>
void Set (const std::string &aPath, wxString aVal)
 
bool Migrate ()
 Migrates the schema of this settings from the version in the file to the latest version. More...
 
void AddNestedSettings (NESTED_SETTINGS *aSettings)
 Transfers ownership of a given NESTED_SETTINGS to this object. More...
 
void ReleaseNestedSettings (NESTED_SETTINGS *aSettings)
 Saves and frees a nested settings object, if it exists within this one. More...
 
void SetManager (SETTINGS_MANAGER *aManager)
 

Static Public Member Functions

static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, wxString &aTarget)
 Sets the given string if the given key/path is present. More...
 
static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, bool &aTarget)
 Sets the given bool if the given key/path is present. More...
 
static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, int &aTarget)
 Sets the given int if the given key/path is present. More...
 
static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, unsigned int &aTarget)
 Sets the given unsigned int if the given key/path is present. More...
 

Public Attributes

AUI_PANELS m_AuiPanels
 
DIALOG_CLEANUP m_Cleanup
 
DIALOG_DRC m_DrcDialog
 
DIALOG_EXPORT_IDF m_ExportIdf
 
DIALOG_EXPORT_STEP m_ExportStep
 
DIALOG_EXPORT_SVG m_ExportSvg
 
DIALOG_EXPORT_VRML m_ExportVrml
 
DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList
 
DIALOG_GENERATE_DRILL m_GenDrill
 
DIALOG_IMPORT_GRAPHICS m_ImportGraphics
 
DIALOG_NETLIST m_NetlistDialog
 
DIALOG_PLACE_FILE m_PlaceFile
 
DIALOG_PLOT m_Plot
 
DIALOG_REANNOTATE m_Reannotate
 
FOOTPRINT_CHOOSER m_FootprintChooser
 
ZONES m_Zones
 
WINDOW_SETTINGS m_FootprintViewer
 
WINDOW_SETTINGS m_FootprintWizard
 
DISPLAY_OPTIONS m_Display
 
MAGNETIC_SETTINGS m_MagneticItems
 
TRACK_DRAG_ACTION m_TrackDragAction
 
bool m_CtrlClickHighlight
 
bool m_Use45DegreeLimit
 
bool m_FlipLeftRight
 
bool m_ESCClearsNetHighlight
 
bool m_PolarCoords
 
EDA_ANGLE m_RotationAngle
 
bool m_ShowPageLimits
 
bool m_AutoRefillZones
 
bool m_AllowFreePads
 
wxString m_FootprintTextShownColumns
 
std::unique_ptr< PNS::ROUTING_SETTINGSm_PnsSettings
 
double m_FootprintViewerZoom
 The last zoom level used (0 for auto) More...
 
bool m_FootprintViewerAutoZoomOnSelect
 true to use automatic zoom on fp selection More...
 
int m_FootprintViewerLibListWidth
 
int m_FootprintViewerFPListWidth
 
wxString m_lastFootprintLibDir
 
wxString m_lastFootprint3dDir
 
ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins
 
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
 
CROSS_PROBING_SETTINGS m_CrossProbing
 
FIND_REPLACE m_FindReplace
 
GRAPHICS m_Graphics
 
COLOR_PICKER m_ColorPicker
 
LIB_TREE m_LibTree
 
PRINTING m_Printing
 
SYSTEM m_System
 
WINDOW_SETTINGS m_Window
 
wxString m_ColorTheme
 Active color theme name. More...
 
int m_appSettingsSchemaVersion
 ! Local schema version for common app settings More...
 

Protected Member Functions

virtual std::string getLegacyFrameName () const override
 
void migrateFindReplace (wxConfigBase *aCfg)
 ! Migrates the find/replace history string lists More...
 
bool migrateWindowConfig (wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
 Migrates legacy window settings into the JSON document. More...
 
void addParamsForWindow (WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
 Adds parameters for the given window object. More...
 
bool migrateLibTreeWidth ()
 Migrates the library tree width setting from a single column (Item) to multi-column. More...
 
void registerMigration (int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
 Registers a migration from one schema version to another. More...
 
template<typename ValueType >
bool fromLegacy (wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
 Translates a legacy wxConfig value to a given JSON pointer value. More...
 
bool fromLegacyString (wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
 Translates a legacy wxConfig string value to a given JSON pointer value. More...
 
bool fromLegacyColor (wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
 Translates a legacy COLOR4D stored in a wxConfig string to a given JSON pointer value. More...
 
virtual wxString getFileExt () const
 
virtual wxString getLegacyFileExt () const
 

Protected Attributes

wxString m_filename
 The filename (not including path) of this settings file (inicode) More...
 
wxString m_legacy_filename
 The filename of the wxConfig legacy file (if different from m_filename) More...
 
SETTINGS_LOC m_location
 The location of this settings file (. More...
 
std::vector< PARAM_BASE * > m_params
 The list of parameters (owned by this object) More...
 
std::vector< NESTED_SETTINGS * > m_nested_settings
 Nested settings files that live inside this one, if any. More...
 
bool m_createIfMissing
 Whether or not the backing store file should be created it if doesn't exist. More...
 
bool m_createIfDefault
 Whether or not the backing store file should be created if all parameters are still at their default values. More...
 
bool m_writeFile
 Whether or not the backing store file should be written. More...
 
bool m_deleteLegacyAfterMigration
 Whether or not to delete legacy file after migration. More...
 
bool m_resetParamsIfMissing
 Whether or not to set parameters to their default value if missing from JSON on Load() More...
 
int m_schemaVersion
 Version of this settings schema. More...
 
SETTINGS_MANAGERm_manager
 A pointer to the settings manager managing this file (may be null) More...
 
std::map< int, std::pair< int, std::function< bool()> > > m_migrators
 A map of starting schema version to a pair of <ending version, migrator function> More...
 
std::unique_ptr< JSON_SETTINGS_INTERNALSm_internals
 

Detailed Description

Definition at line 121 of file pcbnew_settings.h.

Constructor & Destructor Documentation

◆ PCBNEW_SETTINGS()

PCBNEW_SETTINGS::PCBNEW_SETTINGS ( )

Definition at line 49 of file pcbnew_settings.cpp.

52 m_Cleanup(),
59 m_GenDrill(),
63 m_Plot(),
65 m_Zones(),
68 m_Display(),
70 m_CtrlClickHighlight( false ),
71 m_Use45DegreeLimit( false ),
72 m_FlipLeftRight( false ),
74 m_PolarCoords( false ),
76 m_ShowPageLimits( true ),
77 m_AutoRefillZones( false ),
78 m_AllowFreePads( false ),
79 m_PnsSettings( nullptr ),
84{
88
89 m_params.emplace_back( new PARAM<bool>( "aui.show_layer_manager",
91
92 m_params.emplace_back( new PARAM<int>( "aui.right_panel_width",
94
95 m_params.emplace_back( new PARAM<int>( "aui.appearance_panel_tab",
97
98 m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
100
101 m_params.emplace_back( new PARAM<bool>( "aui.show_search",
102 &m_AuiPanels.show_search, false ) );
103
104 m_params.emplace_back( new PARAM<int>( "footprint_chooser.width",
105 &m_FootprintChooser.width, -1 ) );
106
107 m_params.emplace_back( new PARAM<int>( "footprint_chooser.height",
108 &m_FootprintChooser.height, -1 ) );
109
110 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sash_h",
111 &m_FootprintChooser.sash_h, -1 ) );
112
113 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sash_v",
114 &m_FootprintChooser.sash_v, -1 ) );
115
116 m_params.emplace_back( new PARAM<bool>( "editing.flip_left_right",
117 &m_FlipLeftRight, true ) );
118
119 m_params.emplace_back( new PARAM<bool>( "editing.esc_clears_net_highlight",
120 &m_ESCClearsNetHighlight, true ) );
121
122 m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics",
123 &m_MagneticItems.graphics, true ) );
124
125 m_params.emplace_back( new PARAM<int>( "editing.magnetic_pads",
126 reinterpret_cast<int*>( &m_MagneticItems.pads ),
128
129 m_params.emplace_back( new PARAM<int>( "editing.magnetic_tracks",
130 reinterpret_cast<int*>( &m_MagneticItems.tracks ),
132
133 m_params.emplace_back( new PARAM<bool>( "editing.polar_coords",
134 &m_PolarCoords, false ) );
135
136 m_params.emplace_back( new PARAM<int>( "editing.track_drag_action",
137 reinterpret_cast<int*>( &m_TrackDragAction ),
138 static_cast<int>( TRACK_DRAG_ACTION::DRAG ) ) );
139
140 m_params.emplace_back( new PARAM<bool>( "editing.ctrl_click_highlight",
141 &m_CtrlClickHighlight, false ) );
142
143 m_params.emplace_back( new PARAM<bool>( "editing.pcb_use_45_degree_limit",
144 &m_Use45DegreeLimit, false ) );
145
146 m_params.emplace_back( new PARAM<bool>( "editing.auto_fill_zones",
147 &m_AutoRefillZones, false ) );
148
149 m_params.emplace_back( new PARAM<bool>( "editing.allow_free_pads",
150 &m_AllowFreePads, false ) );
151
152 m_params.emplace_back( new PARAM_LAMBDA<int>( "editing.rotation_angle",
153 [this] () -> int
154 {
156
157 // Don't store values larger than 360 degrees
158 return rot % 3600;
159 },
160 [this] ( int aVal )
161 {
162 if( aVal )
164
165 // A misconfiguration allowed some angles to be stored as tenth of a degree but read
166 // as tens of degrees. By disallowing storage of values larger than 360, we can weed out
167 // those invalid values here.
168 while( m_RotationAngle > ANGLE_360 )
170
171 },
172 900 ) );
173
174 m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill",
176
177 m_params.emplace_back( new PARAM<int>( "pcb_display.max_links_shown",
178 &m_Display.m_MaxLinksShowed, 3, 0, 15 ) );
179
180 m_params.emplace_back( new PARAM<bool>( "pcb_display.graphics_fill",
182
183 m_params.emplace_back( new PARAM<bool>( "pcb_display.text_fill",
185
186 m_params.emplace_back( new PARAM<int>( "pcb_display.net_names_mode",
187 &m_Display.m_NetNames, 3, 0, 3 ) );
188
189 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_clearance",
190 &m_Display.m_PadClearance, true ) );
191
192 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_fill",
194
195 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_numbers",
197
198 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_global",
200
201 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_footprint",
203
204 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_curved",
206
207 m_params.emplace_back( new PARAM<int>( "pcb_display.track_clearance_mode",
208 reinterpret_cast<int*>( &m_Display.m_TrackClearance ), SHOW_WITH_VIA_WHILE_ROUTING ) );
209
210 m_params.emplace_back( new PARAM<bool>( "pcb_display.track_fill",
212
213 m_params.emplace_back( new PARAM<bool>( "pcb_display.via_fill",
214 &m_Display.m_DisplayViaFill, true ) );
215
216 m_params.emplace_back( new PARAM<int>( "pcb_display.origin_mode",
217 reinterpret_cast<int*>( &m_Display.m_DisplayOrigin ),
219
220 m_params.emplace_back( new PARAM<bool>( "pcb_display.origin_invert_x_axis",
222
223 m_params.emplace_back( new PARAM<bool>( "pcb_display.origin_invert_y_axis",
225
226 m_params.emplace_back( new PARAM<bool>( "pcb_display.live_3d_refresh",
227 &m_Display.m_Live3DRefresh, false ) );
228
229 m_params.emplace_back( new PARAM<bool>( "pcb_display.show_page_borders",
230 &m_ShowPageLimits, true ) );
231
232 m_params.emplace_back( new PARAM<bool>( "cleanup.cleanup_vias",
233 &m_Cleanup.cleanup_vias, true ) );
234
235 m_params.emplace_back( new PARAM<bool>( "cleanup.delete_dangling_vias",
237
238 m_params.emplace_back( new PARAM<bool>( "cleanup.merge_segments",
239 &m_Cleanup.merge_segments, true ) );
240
241 m_params.emplace_back( new PARAM<bool>( "cleanup.cleanup_unconnected",
243
244 m_params.emplace_back( new PARAM<bool>( "cleanup.cleanup_short_circuits",
246
247 m_params.emplace_back( new PARAM<bool>( "cleanup.cleanup_tracks_in_pad",
249
250 m_params.emplace_back( new PARAM<bool>( "drc_dialog.refill_zones",
251 &m_DrcDialog.refill_zones, true ) );
252
253 m_params.emplace_back( new PARAM<bool>( "drc_dialog.test_all_track_errors",
255
256 m_params.emplace_back( new PARAM<bool>( "drc_dialog.test_footprints",
257 &m_DrcDialog.test_footprints, false ) );
258
259 m_params.emplace_back( new PARAM<int>( "drc_dialog.severities",
261
262 m_params.emplace_back( new PARAM<bool>( "gen_drill.merge_pth_npth",
263 &m_GenDrill.merge_pth_npth, false ) );
264
265 m_params.emplace_back( new PARAM<bool>( "gen_drill.minimal_header",
266 &m_GenDrill.minimal_header, false ) );
267
268 m_params.emplace_back( new PARAM<bool>( "gen_drill.mirror",
269 &m_GenDrill.mirror, false ) );
270
271 m_params.emplace_back( new PARAM<bool>( "gen_drill.unit_drill_is_inch",
273
274 m_params.emplace_back( new PARAM<bool>( "gen_drill.use_route_for_oval_holes",
276
277 m_params.emplace_back( new PARAM<int>( "gen_drill.drill_file_type",
279
280 m_params.emplace_back( new PARAM<int>( "gen_drill.map_file_type",
282
283 m_params.emplace_back( new PARAM<int>( "gen_drill.zeros_format",
284 &m_GenDrill.zeros_format, 0, 0, 3 ) );
285
286 m_params.emplace_back( new PARAM<bool>( "export_idf.auto_adjust",
287 &m_ExportIdf.auto_adjust, false ) );
288
289 m_params.emplace_back( new PARAM<int>( "export_idf.ref_units",
290 &m_ExportIdf.ref_units, 0 ) );
291
292 m_params.emplace_back( new PARAM<double>( "export_idf.ref_x",
293 &m_ExportIdf.ref_x, 0 ) );
294
295 m_params.emplace_back( new PARAM<double>( "export_idf.ref_y",
296 &m_ExportIdf.ref_y, 0 ) );
297
298 m_params.emplace_back( new PARAM<bool>( "export_idf.units_mils",
299 &m_ExportIdf.units_mils, false ) );
300
301 m_params.emplace_back( new PARAM<int>( "export_step.origin_mode",
303
304 m_params.emplace_back( new PARAM<int>( "export_step.origin_units",
306
307 m_params.emplace_back( new PARAM<double>( "export_step.origin_x",
308 &m_ExportStep.origin_x, 0 ) );
309
310 m_params.emplace_back( new PARAM<double>( "export_step.origin_y",
311 &m_ExportStep.origin_y, 0 ) );
312
313 m_params.emplace_back( new PARAM<bool>( "export_step.no_virtual",
314 &m_ExportStep.no_virtual, false ) );
315
316 m_params.emplace_back( new PARAM<bool>( "export_step.replace_models",
317 &m_ExportStep.replace_models, false ) );
318
319 m_params.emplace_back( new PARAM<bool>( "export_step.overwrite_file",
320 &m_ExportStep.overwrite_file, true ) );
321
322 m_params.emplace_back( new PARAM<bool>( "export_svg.black_and_white",
323 &m_ExportSvg.black_and_white, false ) );
324
325 m_params.emplace_back( new PARAM<bool>( "export_svg.mirror",
326 &m_ExportSvg.mirror, false ) );
327
328 m_params.emplace_back( new PARAM<bool>( "export_svg.one_file",
329 &m_ExportSvg.one_file, false ) );
330
331 m_params.emplace_back(new PARAM<bool>( "export_svg.plot_board_edges",
332 &m_ExportSvg.plot_board_edges, true ) );
333
334 m_params.emplace_back( new PARAM<int>( "export_svg.page_size",
335 &m_ExportSvg.page_size, 0 ) );
336
337 m_params.emplace_back( new PARAM<wxString>( "export_svg.output_dir",
338 &m_ExportSvg.output_dir, "" ) );
339
340 m_params.emplace_back( new PARAM_LIST<int>( "export_svg.layers",
341 &m_ExportSvg.layers, {} ) );
342
343 m_params.emplace_back( new PARAM<int>( "export_vrml.units",
344 &m_ExportVrml.units, 1 ) );
345
346 m_params.emplace_back( new PARAM<bool>( "export_vrml.copy_3d_models",
347 &m_ExportVrml.copy_3d_models, false ) );
348
349 m_params.emplace_back( new PARAM<bool>( "export_vrml.use_relative_paths",
351
352 m_params.emplace_back( new PARAM<int>( "export_vrml.ref_units",
353 &m_ExportVrml.ref_units, 0 ) );
354
355 m_params.emplace_back( new PARAM<double>( "export_vrml.ref_x",
356 &m_ExportVrml.ref_x, 0 ) );
357
358 m_params.emplace_back( new PARAM<double>( "export_vrml.ref_y",
359 &m_ExportVrml.ref_y, 0 ) );
360
361 m_params.emplace_back( new PARAM<int>( "export_vrml.origin_mode",
363
364 m_params.emplace_back( new PARAM<int>( "zones.net_sort_mode",
365 &m_Zones.net_sort_mode, -1 ) );
366
367 m_params.emplace_back( new PARAM<int>( "import_graphics.layer",
369
370 m_params.emplace_back( new PARAM<bool>( "import_graphics.interactive_placement",
372
373 m_params.emplace_back( new PARAM<int>( "import_graphics.line_width_units",
375
376 m_params.emplace_back( new PARAM<double>( "import_graphics.line_width",
378
379 m_params.emplace_back( new PARAM<int>( "import_graphics.origin_units",
381
382 m_params.emplace_back( new PARAM<double>( "import_graphics.origin_x",
384
385 m_params.emplace_back( new PARAM<double>( "import_graphics.origin_y",
387
388 m_params.emplace_back( new PARAM<int>( "import_graphics.dxf_units",
390
391 m_params.emplace_back( new PARAM<int>( "netlist.report_filter",
393
394 m_params.emplace_back( new PARAM<bool>( "netlist.update_footprints",
396
397 m_params.emplace_back( new PARAM<bool>( "netlist.delete_shorting_tracks",
399
400 m_params.emplace_back( new PARAM<bool>( "netlist.delete_extra_footprints",
402
403 m_params.emplace_back( new PARAM<bool>( "netlist.associate_by_ref_sch",
405
406 m_params.emplace_back(new PARAM<int>( "place_file.units",
407 &m_PlaceFile.units, 1 ) );
408
409 m_params.emplace_back( new PARAM<int>( "place_file.file_options",
411
412 m_params.emplace_back( new PARAM<int>( "place_file.file_format",
413 &m_PlaceFile.file_format, 0 ) );
414
415 m_params.emplace_back( new PARAM<bool>( "place_file.include_board_edge",
417
418 m_params.emplace_back( new PARAM<bool>( "place_file.use_place_file_origin",
419 &m_PlaceFile.use_aux_origin, true ) );
420
421 m_params.emplace_back( new PARAM<bool>( "place_file.negate_xcoord",
422 &m_PlaceFile.negate_xcoord, false ) );
423
424 m_params.emplace_back( new PARAM<int>( "plot.all_layers_on_one_page",
426
427 m_params.emplace_back( new PARAM<bool>( "plot.edgecut_on_all_layers",
428 &m_Plot.edgecut_on_all_layers, true ) );
429
430 m_params.emplace_back( new PARAM<int>( "plot.pads_drill_mode",
431 &m_Plot.pads_drill_mode, 2 ) );
432
433 m_params.emplace_back( new PARAM<double>( "plot.fine_scale_x",
434 &m_Plot.fine_scale_x, 0 ) );
435
436 m_params.emplace_back( new PARAM<double>( "plot.fine_scale_y",
437 &m_Plot.fine_scale_y, 0 ) );
438
439 m_params.emplace_back( new PARAM<double>( "plot.ps_fine_width_adjust",
441
442 m_params.emplace_back( new PARAM<bool>( "plot.check_zones_before_plotting",
444
445 m_params.emplace_back( new PARAM<bool>( "plot.mirror",
446 &m_Plot.mirror, false ) );
447
448 m_params.emplace_back( new PARAM<wxString>( "window.footprint_text_shown_columns",
449 &m_FootprintTextShownColumns, "0 1 2 3 4 5 6" ) );
450
451 m_params.emplace_back( new PARAM<int>( "footprint_wizard_list.width",
453
454 m_params.emplace_back( new PARAM<int>( "footprint_wizard_list.height",
456
457 m_params.emplace_back( new PARAM<bool>( "reannotate_dialog.annotate_sort_on_modules",
459 m_params.emplace_back( new PARAM<bool>( "reannotate_dialog.annotate_remove_front_prefix",
461 m_params.emplace_back( new PARAM<bool>( "reannotate_dialog.annotate_remove_back_prefix",
463 m_params.emplace_back( new PARAM<bool>( "reannotate_dialog.annotate_exclude_locked",
464 &m_Reannotate.exclude_locked, false ) );
465
466 m_params.emplace_back( new PARAM<int>( "reannotate_dialog.annotate_grid_index",
467 &m_Reannotate.grid_index, 0 ) );
468 m_params.emplace_back( new PARAM<int>( "reannotate_dialog.annotate_sort_code",
469 &m_Reannotate.sort_code, 0 ) );
470 m_params.emplace_back( new PARAM<int>( "reannotate_dialog.annotate_choice",
472 m_params.emplace_back( new PARAM<int>( "reannotate_dialog.annotate_report_severity",
474
475 m_params.emplace_back( new PARAM<wxString>( "reannotate_dialog.annotate_front_refdes_start",
477 m_params.emplace_back( new PARAM<wxString>( "reannotate_dialog.annotate_back_refdes_start",
479 m_params.emplace_back( new PARAM<wxString>( "reannotate_dialog.annotate_front_prefix",
480 &m_Reannotate.front_prefix, "" ) );
481 m_params.emplace_back( new PARAM<wxString>( "reannotate_dialog.annotate_back_prefix",
482 &m_Reannotate.back_prefix, "" ) );
483 m_params.emplace_back( new PARAM<wxString>( "reannotate_dialog.annotate_exclude_list",
484 &m_Reannotate.exclude_list, "" ) );
485 m_params.emplace_back( new PARAM<wxString>( "reannotate_dialog.annotate_report_file_name",
487
488 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "action_plugins",
489 [&]() -> nlohmann::json
490 {
491 nlohmann::json js = nlohmann::json::array();
492
493 for( const auto& pair : m_VisibleActionPlugins )
494 js.push_back( nlohmann::json( { { pair.first.ToUTF8(), pair.second } } ) );
495
496 return js;
497 },
498 [&]( const nlohmann::json& aObj )
499 {
501
502 if( !aObj.is_array() )
503 {
504 return;
505 }
506
507 for( const auto& entry : aObj )
508 {
509 if( entry.empty() || !entry.is_object() )
510 continue;
511
512 for( const auto& pair : entry.items() )
513 {
514 m_VisibleActionPlugins.emplace_back( std::make_pair(
515 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
516 }
517 }
518 },
519 nlohmann::json::array() ) );
520
521 addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
522
523 m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
524 &m_FootprintViewerZoom, 1.0 ) );
525
526 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
528
529 m_params.emplace_back( new PARAM<int>( "footprint_viewer.lib_list_width",
531
532 m_params.emplace_back( new PARAM<int>( "footprint_viewer.fp_list_width",
534
535 addParamsForWindow( &m_FootprintWizard, "footprint_wizard" );
536
537 m_params.emplace_back( new PARAM<wxString>( "system.last_footprint_lib_dir",
538 &m_lastFootprintLibDir, "" ) );
539
540 m_params.emplace_back( new PARAM<wxString>( "system.last_footprint3d_dir",
541 &m_lastFootprint3dDir, "" ) );
542
543 registerMigration( 0, 1,
544 [&]()
545 {
546 if( std::optional<int> optval = Get<int>( "pcb_display.rotation_angle" ) )
547 Set( "editing.rotation_angle", *optval );
548
549 try
550 {
551 At( "pcb_display" ).erase( "rotation_angle" );
552 }
553 catch( ... )
554 {}
555
556 return true;
557 } );
558
559 registerMigration( 1, 2,
560 [&]()
561 {
562 // In version 1 this meant "after Zone Properties dialog", but it now means
563 // "everywhere" so we knock it off on transition.
564 Set( "editing.auto_fill_zones", false );
565
566 return true;
567 } );
568
569
570 registerMigration( 2, 3,
571 [&]() -> bool
572 {
573 // We used to have a bug on GTK which would set the lib tree column width way
574 // too narrow.
575 if( std::optional<int> optval = Get<int>( "lib_tree.column_width" ) )
576 {
577 if( optval < 150 )
578 Set( "lib_tree.column_width", 300 );
579 }
580
581 return true;
582 } );
583
584 registerMigration( 3, 4,
585 [&]() -> bool
586 {
587 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
588 return migrateLibTreeWidth();
589 } );
590}
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Adds parameters for the given window object.
bool migrateLibTreeWidth()
Migrates the library tree width setting from a single column (Item) to multi-column.
int AsTenthsOfADegree() const
Definition: eda_angle.h:151
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:282
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
DISPLAY_OPTIONS m_Display
DIALOG_NETLIST m_NetlistDialog
DIALOG_CLEANUP m_Cleanup
EDA_ANGLE m_RotationAngle
DIALOG_PLACE_FILE m_PlaceFile
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList
FOOTPRINT_CHOOSER m_FootprintChooser
DIALOG_EXPORT_VRML m_ExportVrml
DIALOG_EXPORT_IDF m_ExportIdf
TRACK_DRAG_ACTION m_TrackDragAction
wxString m_lastFootprintLibDir
DIALOG_PLOT m_Plot
WINDOW_SETTINGS m_FootprintWizard
ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins
DIALOG_IMPORT_GRAPHICS m_ImportGraphics
DIALOG_DRC m_DrcDialog
AUI_PANELS m_AuiPanels
DIALOG_EXPORT_STEP m_ExportStep
WINDOW_SETTINGS m_FootprintViewer
wxString m_lastFootprint3dDir
DIALOG_GENERATE_DRILL m_GenDrill
MAGNETIC_SETTINGS m_MagneticItems
DIALOG_REANNOTATE m_Reannotate
int m_FootprintViewerFPListWidth
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
DIALOG_EXPORT_SVG m_ExportSvg
wxString m_FootprintTextShownColumns
int m_FootprintViewerLibListWidth
PCB_VIEWERS_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
@ TENTHS_OF_A_DEGREE_T
Definition: eda_angle.h:30
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:418
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
nlohmann::json json
Definition: gerbview.cpp:44
@ Dwgs_User
Definition: layer_ids.h:109
const int pcbnewSchemaVersion
! Update the schema version whenever a migration is required
@ SHOW_WITH_VIA_WHILE_ROUTING
@ PCB_ORIGIN_PAGE
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads
TRACK_CLEARANCE_MODE m_TrackClearance

References APP_SETTINGS_BASE::addParamsForWindow(), PCBNEW_SETTINGS::DIALOG_PLOT::all_layers_on_one_page, ANGLE_360, PCBNEW_SETTINGS::DIALOG_REANNOTATE::annotation_choice, PCBNEW_SETTINGS::AUI_PANELS::appearance_panel_tab, PCBNEW_SETTINGS::DIALOG_NETLIST::associate_by_ref_sch, EDA_ANGLE::AsTenthsOfADegree(), JSON_SETTINGS::At(), PCBNEW_SETTINGS::DIALOG_EXPORT_IDF::auto_adjust, PCBNEW_SETTINGS::DIALOG_REANNOTATE::back_prefix, PCBNEW_SETTINGS::DIALOG_REANNOTATE::back_refdes_start, PCBNEW_SETTINGS::DIALOG_EXPORT_SVG::black_and_white, CAPTURE_CURSOR_IN_TRACK_TOOL, PCBNEW_SETTINGS::DIALOG_PLOT::check_zones_before_plotting, PCBNEW_SETTINGS::DIALOG_CLEANUP::cleanup_short_circuits, PCBNEW_SETTINGS::DIALOG_CLEANUP::cleanup_tracks_in_pad, PCBNEW_SETTINGS::DIALOG_CLEANUP::cleanup_unconnected, PCBNEW_SETTINGS::DIALOG_CLEANUP::cleanup_vias, PCBNEW_SETTINGS::DIALOG_EXPORT_VRML::copy_3d_models, PCBNEW_SETTINGS::DIALOG_CLEANUP::delete_dangling_vias, PCBNEW_SETTINGS::DIALOG_NETLIST::delete_extra_footprints, PCBNEW_SETTINGS::DIALOG_NETLIST::delete_shorting_tracks, DRAG, PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::drill_file_type, Dwgs_User, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::dxf_line_width, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::dxf_line_width_units, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::dxf_units, PCBNEW_SETTINGS::DIALOG_PLOT::edgecut_on_all_layers, PCBNEW_SETTINGS::DIALOG_REANNOTATE::exclude_list, PCBNEW_SETTINGS::DIALOG_REANNOTATE::exclude_locked, PCBNEW_SETTINGS::DIALOG_PLACE_FILE::file_format, PCBNEW_SETTINGS::DIALOG_PLACE_FILE::file_options, PCBNEW_SETTINGS::DIALOG_PLOT::fine_scale_x, PCBNEW_SETTINGS::DIALOG_PLOT::fine_scale_y, PCBNEW_SETTINGS::DIALOG_REANNOTATE::front_prefix, PCBNEW_SETTINGS::DIALOG_REANNOTATE::front_refdes_start, MAGNETIC_SETTINGS::graphics, PCBNEW_SETTINGS::DIALOG_REANNOTATE::grid_index, PCBNEW_SETTINGS::DIALOG_FOOTPRINT_WIZARD_LIST::height, PCBNEW_SETTINGS::FOOTPRINT_CHOOSER::height, PCBNEW_SETTINGS::DIALOG_PLACE_FILE::include_board_edge, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::interactive_placement, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::layer, PCBNEW_SETTINGS::DIALOG_EXPORT_SVG::layers, m_AllowFreePads, m_AuiPanels, m_AutoRefillZones, m_Cleanup, m_CtrlClickHighlight, m_Display, PCB_VIEWERS_SETTINGS_BASE::VIEWERS_DISPLAY_OPTIONS::m_DisplayGraphicsFill, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_DisplayInvertXAxis, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_DisplayInvertYAxis, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_DisplayOrigin, PCB_VIEWERS_SETTINGS_BASE::VIEWERS_DISPLAY_OPTIONS::m_DisplayPadFill, PCB_VIEWERS_SETTINGS_BASE::VIEWERS_DISPLAY_OPTIONS::m_DisplayPadNumbers, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_DisplayPcbTrackFill, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_DisplayRatsnestLinesCurved, PCB_VIEWERS_SETTINGS_BASE::VIEWERS_DISPLAY_OPTIONS::m_DisplayTextFill, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_DisplayViaFill, m_DrcDialog, m_ESCClearsNetHighlight, m_ExportIdf, m_ExportStep, m_ExportSvg, m_ExportVrml, m_FlipLeftRight, m_FootprintChooser, m_FootprintTextShownColumns, m_FootprintViewer, m_FootprintViewerAutoZoomOnSelect, m_FootprintViewerFPListWidth, m_FootprintViewerLibListWidth, m_FootprintViewerZoom, m_FootprintWizard, m_FootprintWizardList, m_GenDrill, m_ImportGraphics, m_lastFootprint3dDir, m_lastFootprintLibDir, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_Live3DRefresh, m_MagneticItems, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_MaxLinksShowed, m_NetlistDialog, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_NetNames, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_PadClearance, JSON_SETTINGS::m_params, m_PlaceFile, m_Plot, m_PolarCoords, m_Reannotate, m_RotationAngle, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_ShowGlobalRatsnest, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_ShowModuleRatsnest, m_ShowPageLimits, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_TrackClearance, m_TrackDragAction, m_Use45DegreeLimit, PCB_VIEWERS_SETTINGS_BASE::m_ViewersDisplay, m_VisibleActionPlugins, m_Zones, PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::map_file_type, PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::merge_pth_npth, PCBNEW_SETTINGS::DIALOG_CLEANUP::merge_segments, APP_SETTINGS_BASE::migrateLibTreeWidth(), PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::minimal_header, PCBNEW_SETTINGS::DIALOG_EXPORT_SVG::mirror, PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::mirror, PCBNEW_SETTINGS::DIALOG_PLOT::mirror, PCBNEW_SETTINGS::DIALOG_PLACE_FILE::negate_xcoord, PCBNEW_SETTINGS::ZONES::net_sort_mode, PCBNEW_SETTINGS::DIALOG_EXPORT_STEP::no_virtual, PCBNEW_SETTINGS::DIALOG_EXPORT_SVG::one_file, PCBNEW_SETTINGS::DIALOG_EXPORT_STEP::origin_mode, PCBNEW_SETTINGS::DIALOG_EXPORT_VRML::origin_mode, PCBNEW_SETTINGS::DIALOG_EXPORT_STEP::origin_units, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::origin_units, PCBNEW_SETTINGS::DIALOG_EXPORT_STEP::origin_x, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::origin_x, PCBNEW_SETTINGS::DIALOG_EXPORT_STEP::origin_y, PCBNEW_SETTINGS::DIALOG_IMPORT_GRAPHICS::origin_y, PCBNEW_SETTINGS::DIALOG_EXPORT_SVG::output_dir, PCBNEW_SETTINGS::DIALOG_EXPORT_STEP::overwrite_file, MAGNETIC_SETTINGS::pads, PCBNEW_SETTINGS::DIALOG_PLOT::pads_drill_mode, PCBNEW_SETTINGS::DIALOG_EXPORT_SVG::page_size, PCB_ORIGIN_PAGE, PCBNEW_SETTINGS::DIALOG_EXPORT_SVG::plot_board_edges, PCBNEW_SETTINGS::DIALOG_PLOT::ps_fine_width_adjust, PCBNEW_SETTINGS::DIALOG_EXPORT_IDF::ref_units, PCBNEW_SETTINGS::DIALOG_EXPORT_VRML::ref_units, PCBNEW_SETTINGS::DIALOG_EXPORT_IDF::ref_x, PCBNEW_SETTINGS::DIALOG_EXPORT_VRML::ref_x, PCBNEW_SETTINGS::DIALOG_EXPORT_IDF::ref_y, PCBNEW_SETTINGS::DIALOG_EXPORT_VRML::ref_y, PCBNEW_SETTINGS::DIALOG_DRC::refill_zones, JSON_SETTINGS::registerMigration(), PCBNEW_SETTINGS::DIALOG_REANNOTATE::remove_back_prefix, PCBNEW_SETTINGS::DIALOG_REANNOTATE::remove_front_prefix, PCBNEW_SETTINGS::DIALOG_EXPORT_STEP::replace_models, PCBNEW_SETTINGS::DIALOG_REANNOTATE::report_file_name, PCBNEW_SETTINGS::DIALOG_NETLIST::report_filter, PCBNEW_SETTINGS::DIALOG_REANNOTATE::report_severity, PCBNEW_SETTINGS::AUI_PANELS::right_panel_width, RPT_SEVERITY_ERROR, RPT_SEVERITY_WARNING, PCBNEW_SETTINGS::FOOTPRINT_CHOOSER::sash_h, PCBNEW_SETTINGS::FOOTPRINT_CHOOSER::sash_v, JSON_SETTINGS::Set(), PCBNEW_SETTINGS::DIALOG_DRC::severities, PCBNEW_SETTINGS::AUI_PANELS::show_layer_manager, PCBNEW_SETTINGS::AUI_PANELS::show_properties, PCBNEW_SETTINGS::AUI_PANELS::show_search, SHOW_WITH_VIA_WHILE_ROUTING, PCBNEW_SETTINGS::DIALOG_REANNOTATE::sort_code, PCBNEW_SETTINGS::DIALOG_REANNOTATE::sort_on_fp_location, TENTHS_OF_A_DEGREE_T, PCBNEW_SETTINGS::DIALOG_DRC::test_all_track_errors, PCBNEW_SETTINGS::DIALOG_DRC::test_footprints, MAGNETIC_SETTINGS::tracks, PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::unit_drill_is_inch, PCBNEW_SETTINGS::DIALOG_EXPORT_VRML::units, PCBNEW_SETTINGS::DIALOG_PLACE_FILE::units, PCBNEW_SETTINGS::DIALOG_EXPORT_IDF::units_mils, PCBNEW_SETTINGS::DIALOG_NETLIST::update_footprints, PCBNEW_SETTINGS::DIALOG_PLACE_FILE::use_aux_origin, PCBNEW_SETTINGS::DIALOG_EXPORT_VRML::use_relative_paths, PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::use_route_for_oval_holes, PCBNEW_SETTINGS::DIALOG_FOOTPRINT_WIZARD_LIST::width, PCBNEW_SETTINGS::FOOTPRINT_CHOOSER::width, and PCBNEW_SETTINGS::DIALOG_GENERATE_DRILL::zeros_format.

◆ ~PCBNEW_SETTINGS()

PCBNEW_SETTINGS::~PCBNEW_SETTINGS ( )
virtualdefault

Member Function Documentation

◆ AddNestedSettings()

void JSON_SETTINGS::AddNestedSettings ( NESTED_SETTINGS aSettings)
inherited

Transfers ownership of a given NESTED_SETTINGS to this object.

Can be used to construct a NESTED_SETTINGS without the parent object needing to know about the implementation of the nested object;

Parameters
aSettingsis the settings object to take ownership of
aTargetis a pointer to update to the passed in settings

Definition at line 743 of file json_settings.cpp.

744{
745 wxLogTrace( traceSettings, wxT( "AddNestedSettings %s" ), aSettings->GetFilename() );
746 m_nested_settings.push_back( aSettings );
747}
std::vector< NESTED_SETTINGS * > m_nested_settings
Nested settings files that live inside this one, if any.
wxString GetFilename() const
Definition: json_settings.h:73
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.

References JSON_SETTINGS::GetFilename(), JSON_SETTINGS::m_nested_settings, and traceSettings.

Referenced by NESTED_SETTINGS::SetParent().

◆ addParamsForWindow()

void APP_SETTINGS_BASE::addParamsForWindow ( WINDOW_SETTINGS aWindow,
const std::string &  aJsonPath 
)
protectedinherited

Adds parameters for the given window object.

Parameters
aWindowis the target window settings object
aJsonPathis the path to read parameters from

Definition at line 292 of file app_settings.cpp.

293{
294 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".maximized",
295 &aWindow->state.maximized, false ) );
296
297 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path",
298 &aWindow->mru_path, "" ) );
299
300 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->state.size_x, 0 ) );
301
302 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->state.size_y, 0 ) );
303
304 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".perspective",
305 &aWindow->perspective, "" ) );
306
307 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->state.pos_x, 0 ) );
308
309 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->state.pos_y, 0 ) );
310
311 m_params.emplace_back( new PARAM<unsigned int>( aJsonPath + ".display", &aWindow->state.display, 0 ) );
312
313 m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
314 &aWindow->zoom_factors, {} ) );
315
316 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
317 &aWindow->grid.axes_enabled, false ) );
318
319 m_params.emplace_back( new PARAM_LIST<wxString>( aJsonPath + ".grid.sizes",
320 &aWindow->grid.sizes, DefaultGridSizeList() ) );
321
322 int defaultGridIdx;
323
324 if( m_filename == "eeschema" || m_filename == "symbol_editor" || m_filename == "pl_editor" )
325 defaultGridIdx = 1;
326 else
327 defaultGridIdx = 4;
328
329 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
330 &aWindow->grid.last_size_idx, defaultGridIdx ) );
331
332 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_1",
333 &aWindow->grid.fast_grid_1, defaultGridIdx ) );
334
335 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_2",
336 &aWindow->grid.fast_grid_2, defaultGridIdx + 1 ) );
337
338 // for grid user, use a default value compatible with eeschema and pcbnew (10 mils)
339 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
340 &aWindow->grid.user_grid_x, "10 mil" ) );
341 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_y",
342 &aWindow->grid.user_grid_y, "10 mil" ) );
343
344 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.line_width",
345 &aWindow->grid.line_width, 1.0 ) );
346
347 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.min_spacing",
348 &aWindow->grid.min_spacing, 10 ) );
349
350 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show",
351 &aWindow->grid.show, true ) );
352
353 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
354 &aWindow->grid.style, 0 ) );
355
356 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.snap",
357 &aWindow->grid.snap, 0 ) );
358
359 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
360 &aWindow->cursor.always_show_cursor, true ) );
361
362 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor",
363 &aWindow->cursor.fullscreen_cursor, false ) );
364}
virtual const std::vector< wxString > DefaultGridSizeList() const
By default, this returns the list of grids available in PcbNew-based applications.
wxString m_filename
The filename (not including path) of this settings file (inicode)
bool always_show_cursor
Definition: app_settings.h:43
bool fullscreen_cursor
Definition: app_settings.h:44
wxString user_grid_x
Definition: app_settings.h:54
double line_width
Definition: app_settings.h:59
wxString user_grid_y
Definition: app_settings.h:55
double min_spacing
Definition: app_settings.h:60
std::vector< wxString > sizes
Definition: app_settings.h:53
CURSOR_SETTINGS cursor
Definition: app_settings.h:89
WINDOW_STATE state
Definition: app_settings.h:84
GRID_SETTINGS grid
Definition: app_settings.h:90
wxString mru_path
Definition: app_settings.h:85
std::vector< double > zoom_factors
Definition: app_settings.h:87
wxString perspective
Definition: app_settings.h:86
unsigned int display
Definition: app_settings.h:76

References CURSOR_SETTINGS::always_show_cursor, GRID_SETTINGS::axes_enabled, WINDOW_SETTINGS::cursor, APP_SETTINGS_BASE::DefaultGridSizeList(), WINDOW_STATE::display, GRID_SETTINGS::fast_grid_1, GRID_SETTINGS::fast_grid_2, CURSOR_SETTINGS::fullscreen_cursor, WINDOW_SETTINGS::grid, GRID_SETTINGS::last_size_idx, GRID_SETTINGS::line_width, JSON_SETTINGS::m_filename, JSON_SETTINGS::m_params, WINDOW_STATE::maximized, GRID_SETTINGS::min_spacing, WINDOW_SETTINGS::mru_path, WINDOW_SETTINGS::perspective, WINDOW_STATE::pos_x, WINDOW_STATE::pos_y, GRID_SETTINGS::show, WINDOW_STATE::size_x, WINDOW_STATE::size_y, GRID_SETTINGS::sizes, GRID_SETTINGS::snap, WINDOW_SETTINGS::state, GRID_SETTINGS::style, GRID_SETTINGS::user_grid_x, GRID_SETTINGS::user_grid_y, and WINDOW_SETTINGS::zoom_factors.

Referenced by APP_SETTINGS_BASE::APP_SETTINGS_BASE(), CVPCB_SETTINGS::CVPCB_SETTINGS(), and PCBNEW_SETTINGS().

◆ At()

nlohmann::json & JSON_SETTINGS::At ( const std::string &  aPath)
inherited

Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these functions take a string that is passed to PointerFromString internally.

Definition at line 111 of file json_settings.cpp.

112{
113 return m_internals->At( aPath );
114}
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals

References JSON_SETTINGS::m_internals.

Referenced by EESCHEMA_SETTINGS::migrateBomSettings(), GERBVIEW_SETTINGS::MigrateFromLegacy(), APP_SETTINGS_BASE::migrateLibTreeWidth(), BOARD_DESIGN_SETTINGS::migrateSchema0to1(), FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1(), COLOR_SETTINGS::migrateSchema0to1(), PCBNEW_SETTINGS(), and PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS().

◆ Contains()

bool JSON_SETTINGS::Contains ( const std::string &  aPath) const
inherited

◆ Count()

size_t JSON_SETTINGS::Count ( const std::string &  aPath) const
inherited

◆ DefaultGridSizeList()

const std::vector< wxString > APP_SETTINGS_BASE::DefaultGridSizeList ( ) const
virtualinherited

By default, this returns the list of grids available in PcbNew-based applications.

Eeschema does not allow customization of the grid. If it ever does, override this in Eeschema settings to provide a different set of defaults.

Returns
a default value for the window.grid.sizes parameter

Definition at line 367 of file app_settings.cpp.

368{
369 return { "1000 mil",
370 "500 mil",
371 "250 mil",
372 "200 mil",
373 "100 mil",
374 "50 mil",
375 "25 mil",
376 "20 mil",
377 "10 mil",
378 "5 mil",
379 "2 mil",
380 "1 mil",
381 "5.0 mm",
382 "2.5 mm",
383 "1.0 mm",
384 "0.5 mm",
385 "0.25 mm",
386 "0.2 mm",
387 "0.1 mm",
388 "0.05 mm",
389 "0.025 mm",
390 "0.01 mm" };
391}

Referenced by APP_SETTINGS_BASE::addParamsForWindow(), DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS(), PCB_BASE_FRAME::LoadSettings(), FOOTPRINT_PREVIEW_PANEL::New(), and DIALOG_GRID_SETTINGS::TransferDataToWindow().

◆ fromLegacy()

template<typename ValueType >
template bool JSON_SETTINGS::fromLegacy< bool > ( wxConfigBase *  aConfig,
const std::string &  aKey,
const std::string &  aDest 
)
protectedinherited

Translates a legacy wxConfig value to a given JSON pointer value.

Template Parameters
ValueTypeis the basic type of the value
Parameters
aConfigis the legacy config to read from
aKeyis the key (within the current path) to read
aDestis a string that will form a JSON pointer (key1.key2.key3) to write to

Definition at line 655 of file json_settings.cpp.

657{
658 ValueType val;
659
660 if( aConfig->Read( aKey, &val ) )
661 {
662 try
663 {
664 ( *m_internals )[aDest] = val;
665 }
666 catch( ... )
667 {
668 wxASSERT_MSG( false, wxT( "Could not write value in fromLegacy!" ) );
669 return false;
670 }
671
672 return true;
673 }
674
675 return false;
676}

◆ fromLegacyColor()

bool JSON_SETTINGS::fromLegacyColor ( wxConfigBase *  aConfig,
const std::string &  aKey,
const std::string &  aDest 
)
protectedinherited

Translates a legacy COLOR4D stored in a wxConfig string to a given JSON pointer value.

Parameters
aConfigis the legacy config to read from
aKeyis the key (within the current path) to read
aDestis a string that will form a JSON pointer (key1.key2.key3) to write to

Definition at line 715 of file json_settings.cpp.

717{
718 wxString str;
719
720 if( aConfig->Read( aKey, &str ) )
721 {
723 color.SetFromWxString( str );
724
725 try
726 {
727 nlohmann::json js = nlohmann::json::array( { color.r, color.g, color.b, color.a } );
728 ( *m_internals )[aDest] = js;
729 }
730 catch( ... )
731 {
732 wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyColor!" ) );
733 return false;
734 }
735
736 return true;
737 }
738
739 return false;
740}
int color
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104

References color.

Referenced by APP_SETTINGS_BASE::migrateWindowConfig().

◆ fromLegacyString()

bool JSON_SETTINGS::fromLegacyString ( wxConfigBase *  aConfig,
const std::string &  aKey,
const std::string &  aDest 
)
protectedinherited

Translates a legacy wxConfig string value to a given JSON pointer value.

Parameters
aConfigis the legacy config to read from
aKeyis the key (within the current path) to read
aDestis a string that will form a JSON pointer (key1.key2.key3) to write to

Definition at line 691 of file json_settings.cpp.

693{
694 wxString str;
695
696 if( aConfig->Read( aKey, &str ) )
697 {
698 try
699 {
700 ( *m_internals )[aDest] = str.ToUTF8();
701 }
702 catch( ... )
703 {
704 wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyString!" ) );
705 return false;
706 }
707
708 return true;
709 }
710
711 return false;
712}

Referenced by PROJECT_FILE::MigrateFromLegacy(), APP_SETTINGS_BASE::MigrateFromLegacy(), BITMAP2CMP_SETTINGS::MigrateFromLegacy(), EESCHEMA_SETTINGS::MigrateFromLegacy(), SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy(), GERBVIEW_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), COMMON_SETTINGS::MigrateFromLegacy(), PCB_CALCULATOR_SETTINGS::MigrateFromLegacy(), MigrateFromLegacy(), and APP_SETTINGS_BASE::migrateWindowConfig().

◆ Get() [1/2]

template<>
std::optional< wxString > JSON_SETTINGS::Get ( const std::string &  aPath) const
inherited

Definition at line 773 of file json_settings.cpp.

774{
775 if( std::optional<nlohmann::json> opt_json = GetJson( aPath ) )
776 return wxString( opt_json->get<std::string>().c_str(), wxConvUTF8 );
777
778 return std::nullopt;
779}
std::optional< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....

References JSON_SETTINGS::GetJson().

◆ Get() [2/2]

template<typename ValueType >
template std::optional< unsigned long long > JSON_SETTINGS::Get< unsigned long long > ( const std::string &  aPath) const
inherited

Fetches a value from within the JSON document.

Will return an empty optional if the value is not found or a mismatching type.

Template Parameters
ValueTypeis the type to cast to
Parameters
aPathis the path within the document to retrieve
Returns
a value from within this document

Definition at line 494 of file json_settings.cpp.

495{
496 if( std::optional<nlohmann::json> ret = GetJson( aPath ) )
497 {
498 try
499 {
500 return ret->get<ValueType>();
501 }
502 catch( ... )
503 {
504 }
505 }
506
507 return std::nullopt;
508}

References JSON_SETTINGS::GetJson().

Referenced by COLOR_MAP_PARAM::Load(), PARAM< ValueType >::Load(), PARAM_ENUM< EnumType >::Load(), PARAM_LAMBDA< ValueType >::Load(), PARAM_SCALED< ValueType >::Load(), COLOR_MAP_PARAM::MatchesFile(), PARAM< ValueType >::MatchesFile(), PARAM_PATH::MatchesFile(), PARAM_ENUM< EnumType >::MatchesFile(), PARAM_LAMBDA< ValueType >::MatchesFile(), and PARAM_SCALED< ValueType >::MatchesFile().

◆ getFileExt()

virtual wxString JSON_SETTINGS::getFileExt ( ) const
inlineprotectedvirtualinherited

Reimplemented in DATABASE_LIB_SETTINGS, PROJECT_FILE, and PROJECT_LOCAL_SETTINGS.

Definition at line 271 of file json_settings.h.

272 {
273 return wxT( "json" );
274 }

Referenced by JSON_SETTINGS::GetFullFilename(), JSON_SETTINGS::LoadFromFile(), and JSON_SETTINGS::SaveToFile().

◆ GetFilename()

◆ GetFullFilename()

wxString JSON_SETTINGS::GetFullFilename ( ) const
inherited

Definition at line 105 of file json_settings.cpp.

106{
107 return wxString( m_filename + "." + getFileExt() );
108}
virtual wxString getFileExt() const

References JSON_SETTINGS::getFileExt(), and JSON_SETTINGS::m_filename.

Referenced by JSON_SETTINGS::JSON_SETTINGS(), JSON_SETTINGS::LoadFromFile(), NESTED_SETTINGS::LoadFromFile(), and JSON_SETTINGS::SaveToFile().

◆ GetJson()

std::optional< nlohmann::json > JSON_SETTINGS::GetJson ( const std::string &  aPath) const
inherited

Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1.key2.key3" to refer to nested objects.

Parameters
aPathis a string containing one or more keys separated by '.'
Returns
a JSON object from within this one

Definition at line 474 of file json_settings.cpp.

475{
476 nlohmann::json::json_pointer ptr = m_internals->PointerFromString( aPath );
477
478 if( m_internals->contains( ptr ) )
479 {
480 try
481 {
482 return std::optional<nlohmann::json>{ m_internals->at( ptr ) };
483 }
484 catch( ... )
485 {
486 }
487 }
488
489 return std::optional<nlohmann::json>{};
490}

References JSON_SETTINGS::m_internals.

Referenced by JSON_SETTINGS::Get(), PARAM_LAMBDA< ValueType >::Load(), PARAM_LIST< Type >::Load(), PARAM_SET< Type >::Load(), PARAM_MAP< Value >::Load(), PARAM_LAMBDA< ValueType >::MatchesFile(), PARAM_LIST< Type >::MatchesFile(), PARAM_SET< Type >::MatchesFile(), PARAM_PATH_LIST::MatchesFile(), PARAM_MAP< Value >::MatchesFile(), PARAM_WXSTRING_MAP::MatchesFile(), SETTINGS_MANAGER::SaveColorSettings(), and NESTED_SETTINGS::SaveToFile().

◆ getLegacyFileExt()

virtual wxString JSON_SETTINGS::getLegacyFileExt ( ) const
inlineprotectedvirtualinherited

Reimplemented in PROJECT_FILE, and PROJECT_LOCAL_SETTINGS.

Definition at line 276 of file json_settings.h.

277 {
278 return wxEmptyString;
279 }

Referenced by JSON_SETTINGS::LoadFromFile().

◆ getLegacyFrameName()

virtual std::string PCBNEW_SETTINGS::getLegacyFrameName ( ) const
inlineoverrideprotectedvirtual

Reimplemented from APP_SETTINGS_BASE.

Definition at line 399 of file pcbnew_settings.h.

399{ return "PcbFrame"; }

Referenced by MigrateFromLegacy().

◆ GetLocation()

SETTINGS_LOC JSON_SETTINGS::GetLocation ( ) const
inlineinherited

Definition at line 80 of file json_settings.h.

80{ return m_location; }
SETTINGS_LOC m_location
The location of this settings file (.

References JSON_SETTINGS::m_location.

Referenced by SETTINGS_MANAGER::GetPathForSettingsFile().

◆ Internals()

JSON_SETTINGS_INTERNALS * JSON_SETTINGS::Internals ( )
inherited

Definition at line 129 of file json_settings.cpp.

130{
131 return m_internals.get();
132}

References JSON_SETTINGS::m_internals.

Referenced by COLOR_SETTINGS::migrateSchema0to1(), and SETTINGS_MANAGER::SaveColorSettings().

◆ IsReadOnly()

◆ Load()

void JSON_SETTINGS::Load ( )
virtualinherited

Updates the parameters of this object based on the current JSON document contents.

Definition at line 135 of file json_settings.cpp.

136{
137 for( auto param : m_params )
138 {
139 try
140 {
141 param->Load( this, m_resetParamsIfMissing );
142 }
143 catch( ... )
144 {
145 // Skip unreadable parameters in file
146 wxLogTrace( traceSettings, wxT( "param '%s' load err" ), param->GetJsonPath().c_str() );
147 }
148 }
149}
bool m_resetParamsIfMissing
Whether or not to set parameters to their default value if missing from JSON on Load()

References JSON_SETTINGS::m_params, JSON_SETTINGS::m_resetParamsIfMissing, and traceSettings.

Referenced by COLOR_SETTINGS::CreateBuiltinColorSettings(), JSON_SETTINGS::LoadFromFile(), BOARD_DESIGN_SETTINGS::LoadFromFile(), NESTED_SETTINGS::LoadFromFile(), COLOR_SETTINGS::migrateSchema0to1(), PANEL_3D_DISPLAY_OPTIONS::ResetPanel(), PANEL_3D_OPENGL_OPTIONS::ResetPanel(), PANEL_3D_RAYTRACING_OPTIONS::ResetPanel(), PANEL_EESCHEMA_ANNOTATION_OPTIONS::ResetPanel(), PANEL_EESCHEMA_DISPLAY_OPTIONS::ResetPanel(), PANEL_EESCHEMA_EDITING_OPTIONS::ResetPanel(), PANEL_SYM_DISPLAY_OPTIONS::ResetPanel(), PANEL_SYM_EDITING_OPTIONS::ResetPanel(), PANEL_GERBVIEW_DISPLAY_OPTIONS::ResetPanel(), PANEL_PL_EDITOR_DISPLAY_OPTIONS::ResetPanel(), PANEL_DISPLAY_OPTIONS::ResetPanel(), PANEL_EDIT_OPTIONS::ResetPanel(), PANEL_FP_EDITOR_DEFAULTS::ResetPanel(), PANEL_PCBNEW_DISPLAY_ORIGIN::ResetPanel(), and SETTINGS_MANAGER::SaveColorSettings().

◆ LoadFromFile()

bool JSON_SETTINGS::LoadFromFile ( const wxString &  aDirectory = "")
virtualinherited

Loads the backing file from disk and then calls Load()

Parameters
aDirectoryis the path to the file
Returns
true if the file was found on disk and loaded or migrated

Reimplemented in BOARD_DESIGN_SETTINGS, and NESTED_SETTINGS.

Definition at line 152 of file json_settings.cpp.

153{
154 // First, load all params to default values
155 m_internals->clear();
156 Load();
157
158 bool success = true;
159 bool migrated = false;
160 bool legacy_migrated = false;
161
162 LOCALE_IO locale;
163
164 auto migrateFromLegacy = [&] ( wxFileName& aPath ) {
165 // Backup and restore during migration so that the original can be mutated if convenient
166 bool backed_up = false;
167 wxFileName temp;
168
169 if( aPath.IsDirWritable() )
170 {
171 temp.AssignTempFileName( aPath.GetFullPath() );
172
173 if( !wxCopyFile( aPath.GetFullPath(), temp.GetFullPath() ) )
174 {
175 wxLogTrace( traceSettings, wxT( "%s: could not create temp file for migration" ),
176 GetFullFilename() );
177 }
178 else
179 backed_up = true;
180 }
181
182 // Silence popups if legacy file is read-only
183 wxLogNull doNotLog;
184
185 wxConfigBase::DontCreateOnDemand();
186 auto cfg = std::make_unique<wxFileConfig>( wxT( "" ), wxT( "" ), aPath.GetFullPath() );
187
188 // If migrate fails or is not implemented, fall back to built-in defaults that were
189 // already loaded above
190 if( !MigrateFromLegacy( cfg.get() ) )
191 {
192 wxLogTrace( traceSettings,
193 wxT( "%s: migrated; not all settings were found in legacy file" ),
194 GetFullFilename() );
195 }
196 else
197 {
198 wxLogTrace( traceSettings, wxT( "%s: migrated from legacy format" ), GetFullFilename() );
199 }
200
201 if( backed_up )
202 {
203 cfg.reset();
204
205 if( !wxCopyFile( temp.GetFullPath(), aPath.GetFullPath() ) )
206 {
207 wxLogTrace( traceSettings,
208 wxT( "migrate; copy temp file %s to %s failed" ),
209 temp.GetFullPath(), aPath.GetFullPath() );
210 }
211
212 if( !wxRemoveFile( temp.GetFullPath() ) )
213 {
214 wxLogTrace( traceSettings,
215 wxT( "migrate; failed to remove temp file %s" ),
216 temp.GetFullPath() );
217 }
218 }
219
220 // Either way, we want to clean up the old file afterwards
221 legacy_migrated = true;
222 };
223
224 wxFileName path;
225
226 if( aDirectory.empty() )
227 {
228 path.Assign( m_filename );
229 path.SetExt( getFileExt() );
230 }
231 else
232 {
233 wxString dir( aDirectory );
234 path.Assign( dir, m_filename, getFileExt() );
235 }
236
237 if( !path.Exists() )
238 {
239 // Case 1: legacy migration, no .json extension yet
240 path.SetExt( getLegacyFileExt() );
241
242 if( path.Exists() )
243 {
244 migrateFromLegacy( path );
245 }
246 // Case 2: legacy filename is different from new one
247 else if( !m_legacy_filename.empty() )
248 {
249 path.SetName( m_legacy_filename );
250
251 if( path.Exists() )
252 migrateFromLegacy( path );
253 }
254 else
255 {
256 success = false;
257 }
258 }
259 else
260 {
261 if( !path.IsFileWritable() )
262 m_writeFile = false;
263
264 try
265 {
266 wxFFileInputStream fp( path.GetFullPath(), wxT( "rt" ) );
267 wxStdInputStream fstream( fp );
268
269 if( fp.IsOk() )
270 {
271 *static_cast<nlohmann::json*>( m_internals.get() ) =
272 nlohmann::json::parse( fstream, nullptr,
273 /* allow_exceptions = */ true,
274 /* ignore_comments = */ true );
275
276 // If parse succeeds, check if schema migration is required
277 int filever = -1;
278
279 try
280 {
281 filever = m_internals->Get<int>( "meta.version" );
282 }
283 catch( ... )
284 {
285 wxLogTrace( traceSettings, wxT( "%s: file version could not be read!" ),
286 GetFullFilename() );
287 success = false;
288 }
289
290 if( filever >= 0 && filever < m_schemaVersion )
291 {
292 wxLogTrace( traceSettings, wxT( "%s: attempting migration from version %d to %d" ),
293 GetFullFilename(), filever, m_schemaVersion );
294
295 if( Migrate() )
296 {
297 migrated = true;
298 }
299 else
300 {
301 wxLogTrace( traceSettings, wxT( "%s: migration failed!" ), GetFullFilename() );
302 }
303 }
304 else if( filever > m_schemaVersion )
305 {
306 wxLogTrace( traceSettings,
307 wxT( "%s: warning: file version %d is newer than latest (%d)" ),
308 GetFullFilename(), filever, m_schemaVersion );
309 }
310 }
311 else
312 {
313 wxLogTrace( traceSettings, wxT( "%s exists but can't be opened for read" ),
314 GetFullFilename() );
315 }
316 }
317 catch( nlohmann::json::parse_error& error )
318 {
319 wxLogTrace( traceSettings, wxT( "Json parse error reading %s: %s" ),
320 path.GetFullPath(), error.what() );
321 wxLogTrace( traceSettings, wxT( "Attempting migration in case file is in legacy format" ) );
322 migrateFromLegacy( path );
323 }
324 }
325
326 // Now that we have new data in the JSON structure, load the params again
327 Load();
328
329 // And finally load any nested settings
330 for( auto settings : m_nested_settings )
331 settings->LoadFromFile();
332
333 wxLogTrace( traceSettings, wxT( "Loaded <%s> with schema %d" ), GetFullFilename(), m_schemaVersion );
334
335 // If we migrated, clean up the legacy file (with no extension)
336 if( legacy_migrated || migrated )
337 {
338 if( legacy_migrated && m_deleteLegacyAfterMigration && !wxRemoveFile( path.GetFullPath() ) )
339 {
340 wxLogTrace( traceSettings, wxT( "Warning: could not remove legacy file %s" ),
341 path.GetFullPath() );
342 }
343
344 // And write-out immediately so that we don't lose data if the program later crashes.
346 SaveToFile( aDirectory, true );
347 }
348
349 return success;
350}
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
wxString GetFullFilename() const
bool Migrate()
Migrates the schema of this settings from the version in the file to the latest version.
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig)
Migrates from wxConfig to JSON-based configuration.
bool m_deleteLegacyAfterMigration
Whether or not to delete legacy file after migration.
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
virtual wxString getLegacyFileExt() const
int m_schemaVersion
Version of this settings schema.
wxString m_legacy_filename
The filename of the wxConfig legacy file (if different from m_filename)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
bool parse(std::istream &aStream, bool aVerbose)
Parse a PCB or footprint file from the given input stream.

References JSON_SETTINGS::getFileExt(), JSON_SETTINGS::GetFullFilename(), JSON_SETTINGS::getLegacyFileExt(), JSON_SETTINGS::Load(), JSON_SETTINGS::m_deleteLegacyAfterMigration, JSON_SETTINGS::m_filename, JSON_SETTINGS::m_internals, JSON_SETTINGS::m_legacy_filename, JSON_SETTINGS::m_nested_settings, JSON_SETTINGS::m_schemaVersion, JSON_SETTINGS::m_writeFile, JSON_SETTINGS::Migrate(), JSON_SETTINGS::MigrateFromLegacy(), parse(), path, JSON_SETTINGS::SaveToFile(), and traceSettings.

Referenced by SETTINGS_MANAGER::LoadProject(), SETTINGS_MANAGER::loadProjectFile(), SETTINGS_MANAGER::MigrateIfNeeded(), SAVE_AS_TRAVERSER::OnFile(), and SETTINGS_MANAGER::SaveColorSettings().

◆ Migrate()

bool JSON_SETTINGS::Migrate ( )
inherited

Migrates the schema of this settings from the version in the file to the latest version.

Schema migration doesn't need to be used every time a setting is added! This is intended to be more of an "escape hatch" in the event that we decide to move settings around or make other changes to a settings file format that can't simply be handled by loading a new default

Returns
true if migration was successful

Definition at line 552 of file json_settings.cpp.

553{
554 int filever = m_internals->Get<int>( "meta.version" );
555
556 while( filever < m_schemaVersion )
557 {
558 if( !m_migrators.count( filever ) )
559 {
560 wxLogTrace( traceSettings, wxT( "Migrator missing for %s version %d!" ),
561 typeid( *this ).name(), filever );
562 return false;
563 }
564
565 std::pair<int, std::function<bool()>> pair = m_migrators.at( filever );
566
567 if( pair.second() )
568 {
569 wxLogTrace( traceSettings, wxT( "Migrated %s from %d to %d" ), typeid( *this ).name(),
570 filever, pair.first );
571 filever = pair.first;
572 m_internals->At( "meta.version" ) = filever;
573 }
574 else
575 {
576 wxLogTrace( traceSettings, wxT( "Migration failed for %s from %d to %d" ),
577 typeid( *this ).name(), filever, pair.first );
578 return false;
579 }
580 }
581
582 return true;
583}
std::map< int, std::pair< int, std::function< bool()> > > m_migrators
A map of starting schema version to a pair of <ending version, migrator function>

References JSON_SETTINGS::m_internals, JSON_SETTINGS::m_migrators, JSON_SETTINGS::m_schemaVersion, and traceSettings.

Referenced by JSON_SETTINGS::LoadFromFile(), and NESTED_SETTINGS::LoadFromFile().

◆ migrateFindReplace()

void APP_SETTINGS_BASE::migrateFindReplace ( wxConfigBase *  aCfg)
protectedinherited

! Migrates the find/replace history string lists

Definition at line 232 of file app_settings.cpp.

233{
234 const int find_replace_history_size = 10;
235 nlohmann::json find_history = nlohmann::json::array();
236 nlohmann::json replace_history = nlohmann::json::array();
237 wxString tmp, find_key, replace_key;
238
239 for( int i = 0; i < find_replace_history_size; ++i )
240 {
241 find_key.Printf( "FindStringHistoryList%d", i );
242 replace_key.Printf( "ReplaceStringHistoryList%d", i );
243
244 if( aCfg->Read( find_key, &tmp ) )
245 find_history.push_back( tmp.ToStdString() );
246
247 if( aCfg->Read( replace_key, &tmp ) )
248 replace_history.push_back( tmp.ToStdString() );
249 }
250
251 Set( "find_replace.find_history", find_history );
252 Set( "find_replace.replace_history", replace_history );
253}

References JSON_SETTINGS::Set().

Referenced by APP_SETTINGS_BASE::MigrateFromLegacy().

◆ MigrateFromLegacy()

bool PCBNEW_SETTINGS::MigrateFromLegacy ( wxConfigBase *  aLegacyConfig)
overridevirtual

Migrates from wxConfig to JSON-based configuration.

Should be implemented by any subclasses of JSON_SETTINGS that map to a legacy (wxConfig-based) config file.

Parameters
aLegacyConfigis a wxConfigBase holding a loaded configuration to migrate
Returns
true if migration was successful

Reimplemented from APP_SETTINGS_BASE.

Definition at line 596 of file pcbnew_settings.cpp.

597{
598 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
599
600 const std::string f = getLegacyFrameName();
601
602 //
603 // NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
604 //
605 ret &= fromLegacy<bool>( aCfg, "ShowLayerManagerTools", "aui.show_layer_manager" );
606
607 ret &= fromLegacy<int>( aCfg, "FootprintChooserHSashPosition", "footprint_chooser.sash_h" );
608 ret &= fromLegacy<int>( aCfg, "FootprintChooserVSashPosition", "footprint_chooser.sash_v" );
609 ret &= fromLegacy<int>( aCfg, "FootprintChooserWidth", "footprint_chooser.width" );
610 ret &= fromLegacy<int>( aCfg, "FootprintChooserHeight", "footprint_chooser.height" );
611
612 ret &= fromLegacy<bool>( aCfg, "FlipLeftRight", "editing.flip_left_right" );
613 ret &= fromLegacy<bool>( aCfg, "MagneticGraphics", "editing.magnetic_graphics" );
614 ret &= fromLegacy<int>( aCfg, "MagneticPads", "editing.magnetic_pads" );
615 ret &= fromLegacy<int>( aCfg, "MagneticTracks", "editing.magnetic_tracks" );
616 ret &= fromLegacy<bool>( aCfg, "DisplayPolarCoords", "editing.polar_coords" );
617 ret &= fromLegacy<bool>( aCfg, "Use45DegreeGraphicSegments", "editing.use_45_degree_graphic_segments" );
618
619 ret &= fromLegacy<bool>( aCfg, "PcbAffT", "pcb_display.graphic_items_fill" );
620 ret &= fromLegacy<int>( aCfg, "MaxLnkS", "pcb_display.max_links_shown" );
621 ret &= fromLegacy<bool>( aCfg, "ModAffC", "pcb_display.footprint_edge_fill" );
622 ret &= fromLegacy<bool>( aCfg, "ModAffT", "pcb_display.footprint_text_fill" );
623 ret &= fromLegacy<int>( aCfg, "ShowNetNamesMode", "pcb_display.net_names_mode" );
624 ret &= fromLegacy<int>( aCfg, "PcbDisplayOrigin", "pcb_display.origin_mode" );
625 ret &= fromLegacy<bool>( aCfg, "PcbInvertXAxis", "pcb_display.origin_invert_x_axis" );
626 ret &= fromLegacy<bool>( aCfg, "PcbInvertYAxis", "pcb_display.origin_invert_y_axis" );
627 ret &= fromLegacy<bool>( aCfg, "PadAffG", "pcb_display.pad_clearance" );
628 ret &= fromLegacy<bool>( aCfg, "PadFill", "pcb_display.pad_fill" );
629 ret &= fromLegacy<bool>( aCfg, "PadSNum", "pcb_display.pad_numbers" );
630 ret &= fromLegacy<bool>( aCfg, "ShowRatsnestLines", "pcb_display.ratsnest_global" );
631 ret &= fromLegacy<bool>( aCfg, "ShowRatsnestModuleLines", "pcb_display.ratsnest_footprint" );
632 ret &= fromLegacy<bool>( aCfg, "CurvedRatsnestLines", "pcb_display.ratsnest_curved" );
633 ret &= fromLegacy<int>( aCfg, "RotationAngle", "pcb_display.rotation_angle" );
634 ret &= fromLegacy<int>( aCfg, "TrackDisplayClearance", "pcb_display.track_clearance_mode" );
635 ret &= fromLegacy<bool>( aCfg, "DisplayTrackFilled", "pcb_display.track_fill" );
636 ret &= fromLegacy<bool>( aCfg, "ViaFill", "pcb_display.via_fill" );
637 ret &= fromLegacy<int>( aCfg, "PcbShowZonesMode", "pcb_display.zone_mode" );
638
639 ret &= fromLegacy<double>( aCfg, "PlotLineWidth_mm", "plot.line_width" );
640
641 aCfg->SetPath( "/dialogs/cleanup_tracks" );
642 ret &= fromLegacy<bool>( aCfg, "DialogCleanupVias", "cleanup.cleanup_vias" );
643 ret &= fromLegacy<bool>( aCfg, "DialogCleanupMergeSegments", "cleanup.merge_segments" );
644 ret &= fromLegacy<bool>( aCfg, "DialogCleanupUnconnected", "cleanup.cleanup_unconnected" );
645 ret &= fromLegacy<bool>( aCfg, "DialogCleanupShortCircuit", "cleanup.cleanup_short_circuits" );
646 ret &= fromLegacy<bool>( aCfg, "DialogCleanupTracksInPads", "cleanup.cleanup_tracks_in_pad" );
647 aCfg->SetPath( "../.." );
648
649 ret &= fromLegacy<bool>( aCfg, "RefillZonesBeforeDrc", "drc_dialog.refill_zones" );
650 ret &= fromLegacy<bool>( aCfg, "DrcTestFootprints", "drc_dialog.test_footprints" );
651
652 ret &= fromLegacy<bool>( aCfg, "DrillMergePTHNPTH", "gen_drill.merge_pth_npth" );
653 ret &= fromLegacy<bool>( aCfg, "DrillMinHeader", "gen_drill.minimal_header" );
654 ret &= fromLegacy<bool>( aCfg, "DrillMirrorYOpt", "gen_drill.mirror" );
655 ret &= fromLegacy<bool>( aCfg, "DrillUnit", "gen_drill.unit_drill_is_inch" );
656 ret &= fromLegacy<bool>( aCfg, "OvalHolesRouteMode", "gen_drill.use_route_for_oval_holes" );
657 ret &= fromLegacy<int>( aCfg, "DrillFileType", "gen_drill.drill_file_type" );
658 ret &= fromLegacy<int>( aCfg, "DrillMapFileType", "gen_drill.map_file_type" );
659 ret &= fromLegacy<int>( aCfg, "DrillZerosFormat", "gen_drill.zeros_format" );
660
661 ret &= fromLegacy<bool>( aCfg, "IDFRefAutoAdj", "export_idf.auto_adjust" );
662 ret &= fromLegacy<int>( aCfg, "IDFRefUnits", "export_idf.ref_units" );
663 ret &= fromLegacy<double>( aCfg, "IDFRefX", "export_idf.ref_x" );
664 ret &= fromLegacy<double>( aCfg, "IDFRefY", "export_idf.ref_y" );
665 ret &= fromLegacy<bool>( aCfg, "IDFExportThou", "export_idf.units_mils" );
666
667 ret &= fromLegacy<int>( aCfg, "STEP_Origin_Opt", "export_step.origin_mode" );
668 ret &= fromLegacy<int>( aCfg, "STEP_UserOriginUnits", "export_step.origin_units" );
669 ret &= fromLegacy<double>( aCfg, "STEP_UserOriginX", "export_step.origin_x" );
670 ret &= fromLegacy<double>( aCfg, "STEP_UserOriginY", "export_step.origin_y" );
671 ret &= fromLegacy<bool>( aCfg, "STEP_NoVirtual", "export_step.no_virtual" );
672
673 ret &= fromLegacy<bool>( aCfg, "PlotSVGModeColor", "export_svg.black_and_white" );
674 ret &= fromLegacy<bool>( aCfg, "PlotSVGModeMirror", "export_svg.mirror" );
675 ret &= fromLegacy<bool>( aCfg, "PlotSVGModeOneFile", "export_svg.one_file" );
676 ret &= fromLegacy<bool>( aCfg, "PlotSVGBrdEdge", "export_svg.plot_board_edges" );
677 ret &= fromLegacy<int>( aCfg, "PlotSVGPageOpt", "export_svg.page_size" );
678 ret &= fromLegacyString( aCfg, "PlotSVGDirectory", "export_svg.output_dir" );
679
680 {
681 nlohmann::json js = nlohmann::json::array();
682 wxString key;
683 bool val = false;
684
685 for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
686 {
687 key.Printf( wxT( "PlotSVGLayer_%d" ), i );
688
689 if( aCfg->Read( key, &val ) && val )
690 js.push_back( i );
691 }
692
693 Set( "export_svg.layers", js );
694 }
695
696 {
697 nlohmann::json js = nlohmann::json::array();
698
699 wxString packed;
700
701 if( aCfg->Read( "ActionPluginButtons", &packed ) )
702 {
703 wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( packed, ";" );
704
705 while( pluginSettingsTokenizer.HasMoreTokens() )
706 {
707 nlohmann::json row;
708 wxString plugin = pluginSettingsTokenizer.GetNextToken();
709 wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin, "=" );
710
711 if( pluginTokenizer.CountTokens() != 2 )
712 {
713 // Bad config
714 continue;
715 }
716
717 std::string key( pluginTokenizer.GetNextToken().ToUTF8() );
718 bool value( pluginTokenizer.GetNextToken().Cmp( wxT( "Visible" ) ) == 0 );
719
720 js.push_back( nlohmann::json( { { key, value } } ) );
721 }
722 }
723
724 Set( "action_plugins", js );
725 }
726
727 //
728 // NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
729 //
730 ret &= fromLegacy<int>( aCfg, "VrmlExportUnit", "export_vrml.units" );
731 ret &= fromLegacy<bool>( aCfg, "VrmlExportCopyFiles", "export_vrml.copy_3d_models" );
732 ret &= fromLegacy<bool>( aCfg, "VrmlUseRelativePaths", "export_vrml.use_relative_paths" );
733 ret &= fromLegacy<int>( aCfg, "VrmlRefUnits", "export_vrml.ref_units" );
734 ret &= fromLegacy<double>( aCfg, "VrmlRefX", "export_vrml.ref_x" );
735 ret &= fromLegacy<double>( aCfg, "VrmlRefY", "export_vrml.ref_y" );
736 ret &= fromLegacy<int> ( aCfg, "VrmlOriginMode", "export_vrml.origin_mode" );
737
738 ret &= fromLegacy<int>( aCfg, "Zone_Ouline_Hatch_Opt", "zones.hatching_style" );
739 ret &= fromLegacy<int>( aCfg, "Zone_NetSort_Opt", "zones.net_sort_mode" );
740 ret &= fromLegacy<double>( aCfg, "Zone_Clearance", "zones.clearance" );
741 ret &= fromLegacy<double>( aCfg, "Zone_Thickness", "zones.min_thickness" );
742 ret &= fromLegacy<double>( aCfg, "Zone_TH_Gap", "zones.thermal_relief_gap" );
743 ret &= fromLegacy<double>( aCfg, "Zone_TH_Copper_Width", "zones.thermal_relief_copper_width" );
744
745 aCfg->SetPath( "ImportGraphics" );
746 ret &= fromLegacy<int>( aCfg, "BoardLayer", "import_graphics.layer" );
747 ret &= fromLegacy<bool>( aCfg, "InteractivePlacement", "import_graphics.interactive_placement" );
748 ret &= fromLegacyString( aCfg, "LastFile", "import_graphics.last_file" );
749 ret &= fromLegacy<double>( aCfg, "LineWidth", "import_graphics.line_width" );
750 ret &= fromLegacy<int>( aCfg, "LineWidthUnits", "import_graphics.line_width_units" );
751 ret &= fromLegacy<int>( aCfg, "PositionUnits", "import_graphics.origin_units" );
752 ret &= fromLegacy<double>( aCfg, "PositionX", "import_graphics.origin_x" );
753 ret &= fromLegacy<double>( aCfg, "PositionY", "import_graphics.origin_y" );
754 aCfg->SetPath( ".." );
755
756 ret &= fromLegacy<int>( aCfg, "NetlistReportFilterMsg", "netlist.report_filter" );
757 ret &= fromLegacy<bool>( aCfg, "NetlistUpdateFootprints", "netlist.update_footprints" );
758 ret &= fromLegacy<bool>( aCfg, "NetlistDeleteShortingTracks", "netlist.delete_shorting_tracks" );
759 ret &= fromLegacy<bool>( aCfg, "NetlistDeleteExtraFootprints", "netlist.delete_extra_footprints" );
760
761 ret &= fromLegacy<int>( aCfg, "PlaceFileUnits", "place_file.units" );
762 ret &= fromLegacy<int>( aCfg, "PlaceFileOpts", "place_file.file_options" );
763 ret &= fromLegacy<int>( aCfg, "PlaceFileFormat", "place_file.file_format" );
764 ret &= fromLegacy<bool>( aCfg, "PlaceFileIncludeBrdEdge", "place_file.include_board_edge" );
765
766 ret &= fromLegacy<int>( aCfg, "PrintSinglePage", "plot.all_layers_on_one_page" );
767 ret &= fromLegacy<int>( aCfg, "PrintPadsDrillOpt", "plot.pads_drill_mode" );
768 ret &= fromLegacy<double>( aCfg, "PlotXFineScaleAdj", "plot.fine_scale_x" );
769 ret &= fromLegacy<double>( aCfg, "PlotYFineScaleAdj", "plot.fine_scale_y" );
770 ret &= fromLegacy<double>( aCfg, "PSPlotFineWidthAdj", "plot.ps_fine_width_adjust" );
771 ret &= fromLegacy<bool>( aCfg, "CheckZonesBeforePlotting", "plot.check_zones_before_plotting" );
772
773 ret &= fromLegacyString( aCfg, "FootprintTextShownColumns", "window.footprint_text_shown_columns" );
774
775 ret &= fromLegacy<int>( aCfg, "FpWizardListWidth", "footprint_wizard_list.width" );
776 ret &= fromLegacy<int>( aCfg, "FpWizardListHeight", "footprint_wizard_list.height" );
777
778 migrateWindowConfig( aCfg, "ModViewFrame", "footprint_viewer" );
779
780 ret &= fromLegacy<bool>( aCfg, "ModViewFrameAutoZoom", "footprint_viewer.auto_zoom" );
781 ret &= fromLegacy<double>( aCfg, "ModViewFrameZoom", "footprint_viewer.zoom" );
782
783 migrateWindowConfig( aCfg, "FootprintWizard", "footprint_wizard" );
784 ret &= fromLegacyString( aCfg, "Fpwizard_auiPerspective", "footprint_wizard.perspective" );
785
786
787 const std::string p = "pcbnew.InteractiveRouter.";
788
789 Set( "tools.pns.meta", nlohmann::json( {
790 { "filename", "pns" },
791 { "version", 0 }
792 } ) );
793
794 ret &= fromLegacy<int>( aCfg, p + "Mode", "tools.pns.mode" );
795 ret &= fromLegacy<int>( aCfg, p + "OptimizerEffort", "tools.pns.effort" );
796 ret &= fromLegacy<bool>( aCfg, p + "RemoveLoops", "tools.pns.remove_loops" );
797 ret &= fromLegacy<bool>( aCfg, p + "SmartPads", "tools.pns.smart_pads" );
798 ret &= fromLegacy<bool>( aCfg, p + "ShoveVias", "tools.pns.shove_vias" );
799 ret &= fromLegacy<bool>( aCfg, p + "StartDiagonal", "tools.pns.start_diagonal" );
800 ret &= fromLegacy<int>( aCfg, p + "ShoveTimeLimit", "tools.pns.shove_time_limit" );
801 ret &= fromLegacy<int>( aCfg, p + "ShoveIterationLimit", "tools.pns.shove_iteration_limit" );
802 ret &= fromLegacy<int>( aCfg, p + "WalkaroundIterationLimit", "tools.pns.walkaround_iteration_limit" );
803 ret &= fromLegacy<bool>( aCfg, p + "JumpOverObstacles", "tools.pns.jump_over_obstacles" );
804 ret &= fromLegacy<bool>( aCfg, p + "SmoothDraggedSegments", "tools.pns.smooth_dragged_segments" );
805 ret &= fromLegacy<bool>( aCfg, p + "CanViolateDRC", "tools.pns.can_violate_drc" );
806 ret &= fromLegacy<bool>( aCfg, p + "SuggestFinish", "tools.pns.suggest_finish" );
807 ret &= fromLegacy<bool>( aCfg, p + "FreeAngleMode", "tools.pns.free_angle_mode" );
808 ret &= fromLegacy<bool>( aCfg, p + "InlineDragEnabled", "editing.track_drag_action" );
809
810 // Initialize some new PNS settings to legacy behaviors if coming from legacy
811 Set( "tools.pns.fix_all_segments", false );
812
813 // Migrate color settings that were stored in the pcbnew config file
814
815 COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetMigratedColorSettings();
816
817 auto migrateLegacyColor =
818 [&] ( const std::string& aKey, int aLayerId )
819 {
820 wxString str;
821
822 if( aCfg->Read( aKey, &str ) )
823 cs->SetColor( aLayerId, COLOR4D( str ) );
824 };
825
826 for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
827 {
828 wxString layer = LSET::Name( PCB_LAYER_ID( i ) );
829 migrateLegacyColor( "Color4DPCBLayer_" + layer.ToStdString(), PCB_LAYER_ID( i ) );
830 }
831
832 migrateLegacyColor( "Color4DAnchorEx", LAYER_ANCHOR );
833 migrateLegacyColor( "Color4DAuxItems", LAYER_AUX_ITEMS );
834 migrateLegacyColor( "Color4DGrid", LAYER_GRID );
835 migrateLegacyColor( "Color4DNonPlatedEx", LAYER_NON_PLATEDHOLES );
836 migrateLegacyColor( "Color4DPadThruHoleEx", LAYER_PADS_TH );
837 migrateLegacyColor( "Color4DPCBBackground", LAYER_PCB_BACKGROUND );
838 migrateLegacyColor( "Color4DPCBCursor", LAYER_CURSOR );
839 migrateLegacyColor( "Color4DRatsEx", LAYER_RATSNEST );
840 migrateLegacyColor( "Color4DTxtInvisEx", LAYER_MOD_TEXT_INVISIBLE );
841 migrateLegacyColor( "Color4DViaBBlindEx", LAYER_VIA_BBLIND );
842 migrateLegacyColor( "Color4DViaMicroEx", LAYER_VIA_MICROVIA );
843 migrateLegacyColor( "Color4DViaThruEx", LAYER_VIA_THROUGH );
844 migrateLegacyColor( "Color4DWorksheet", LAYER_DRAWINGSHEET );
845 migrateLegacyColor( "Color4DGrid", LAYER_PAGE_LIMITS );
846
847 Pgm().GetSettingsManager().SaveColorSettings( cs, "board" );
848
849 Set( "appearance.color_theme", cs->GetFilename() );
850
851 double x, y;
852
853 if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) )
854 {
855 EDA_UNITS u = static_cast<EDA_UNITS>( aCfg->ReadLong( f + "PcbUserGrid_Unit",
856 static_cast<long>( EDA_UNITS::INCHES ) ) );
857
858 // Convert to internal units
861
862 Set( "window.grid.user_grid_x", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, x ) );
863 Set( "window.grid.user_grid_y", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, y ) );
864 }
865
866 // Footprint editor settings were stored in pcbnew config file. Migrate them here.
867 auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( false );
868 fpedit->MigrateFromLegacy( aCfg );
869 fpedit->Load();
870
871 // Same with 3D viewer
872 auto viewer3d = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>( false );
873 viewer3d->MigrateFromLegacy( aCfg );
874 viewer3d->Load();
875
876 return ret;
877}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrates legacy window settings into the JSON document.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetColor(int aLayer, const COLOR4D &aColor)
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
virtual std::string getLegacyFrameName() const override
EDA_UNITS
Definition: eda_units.h:43
@ LAYER_GRID
Definition: layer_ids.h:205
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
Definition: layer_ids.h:200
@ LAYER_PAGE_LIMITS
color for drawing the page extents (visibility stored in PCBNEW_SETTINGS::m_ShowPageLimits)
Definition: layer_ids.h:249
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
Definition: layer_ids.h:197
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:217
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:220
@ LAYER_CURSOR
PCB cursor.
Definition: layer_ids.h:221
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc)
Definition: layer_ids.h:222
@ LAYER_RATSNEST
Definition: layer_ids.h:204
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
Definition: layer_ids.h:201
@ LAYER_PADS_TH
multilayer pads, usually with holes
Definition: layer_ids.h:213
@ LAYER_VIA_MICROVIA
to draw micro vias
Definition: layer_ids.h:194
@ LAYER_VIA_THROUGH
to draw usual through hole vias
Definition: layer_ids.h:196
@ LAYER_VIA_BBLIND
to draw blind/buried vias
Definition: layer_ids.h:195
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137
double FromUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg".
Definition: eda_units.cpp:393
wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:233
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References JSON_SETTINGS::fromLegacyString(), EDA_UNIT_UTILS::UI::FromUserUnit(), JSON_SETTINGS::GetFilename(), getLegacyFrameName(), INCHES, LAYER_ANCHOR, LAYER_AUX_ITEMS, LAYER_CURSOR, LAYER_DRAWINGSHEET, LAYER_GRID, LAYER_MOD_TEXT_INVISIBLE, LAYER_NON_PLATEDHOLES, LAYER_PADS_TH, LAYER_PAGE_LIMITS, LAYER_PCB_BACKGROUND, LAYER_RATSNEST, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, APP_SETTINGS_BASE::MigrateFromLegacy(), EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), APP_SETTINGS_BASE::migrateWindowConfig(), LSET::Name(), PCB_LAYER_ID_COUNT, pcbIUScale, Pgm(), JSON_SETTINGS::Set(), COLOR_SETTINGS::SetColor(), and EDA_UNIT_UTILS::UI::StringFromValue().

◆ migrateLibTreeWidth()

bool APP_SETTINGS_BASE::migrateLibTreeWidth ( )
protectedinherited

Migrates the library tree width setting from a single column (Item) to multi-column.

Definition at line 394 of file app_settings.cpp.

395{
396 // We used to store only the width of the first column, because there were only
397 // two possible columns.
398 if( std::optional<int> optWidth = Get<int>( "lib_tree.column_width" ) )
399 {
400 Set<nlohmann::json>( "lib_tree.column_widths", { { "Item", *optWidth } } );
401 At( "lib_tree" ).erase( "column_width" );
402 }
403
404 return true;
405}

References JSON_SETTINGS::At().

Referenced by EESCHEMA_SETTINGS::EESCHEMA_SETTINGS(), FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS(), PCBNEW_SETTINGS(), and SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS().

◆ migrateWindowConfig()

bool APP_SETTINGS_BASE::migrateWindowConfig ( wxConfigBase *  aCfg,
const std::string &  aFrameName,
const std::string &  aJsonPath 
)
protectedinherited

Migrates legacy window settings into the JSON document.

Parameters
aCfgis the wxConfig object to read from
aFrameNameis the prefix for window settings in the legacy config file
aJsonPathis the prefix for storing window settings in the JSON file
Returns
true if all settings were migrated

Definition at line 256 of file app_settings.cpp.

258{
259 bool ret = true;
260
261 const std::string frameGDO = aFrame + "GalDisplayOptions";
262 const std::string cursorPath = aJsonPath + ".cursor";
263 const std::string gridPath = aJsonPath + ".grid";
264
265 ret &= fromLegacy<bool>( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" );
266 ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" );
267 ret &= fromLegacy<int>( aCfg, aFrame + "Size_x", aJsonPath + ".size_x" );
268 ret &= fromLegacy<int>( aCfg, aFrame + "Size_y", aJsonPath + ".size_y" );
269 ret &= fromLegacyString( aCfg, aFrame + "Perspective", aJsonPath + ".perspective" );
270 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
271 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
272
273 ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor", cursorPath + ".always_show_cursor" );
274 ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen", cursorPath + ".fullscreen_cursor" );
275
276 ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );
277
278 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid1", gridPath + ".fast_grid_1" );
279 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid2", gridPath + ".fast_grid_2" );
280
281 ret &= fromLegacy<bool>( aCfg, frameGDO + "GridAxesEnabled", gridPath + ".axes_enabled" );
282 ret &= fromLegacy<double>( aCfg, frameGDO + "GridLineWidth", gridPath + ".line_width" );
283 ret &= fromLegacy<double>( aCfg, frameGDO + "GridMaxDensity", gridPath + ".min_spacing" );
284 ret &= fromLegacy<bool>( aCfg, frameGDO + "ShowGrid", gridPath + ".show" );
285 ret &= fromLegacy<int>( aCfg, frameGDO + "GridStyle", gridPath + ".style" );
286 ret &= fromLegacyColor( aCfg, frameGDO + "GridColor", gridPath + ".color" );
287
288 return ret;
289}
bool fromLegacyColor(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy COLOR4D stored in a wxConfig string to a given JSON pointer value.

References JSON_SETTINGS::fromLegacyColor(), and JSON_SETTINGS::fromLegacyString().

Referenced by APP_SETTINGS_BASE::MigrateFromLegacy(), CVPCB_SETTINGS::MigrateFromLegacy(), and MigrateFromLegacy().

◆ registerMigration()

void JSON_SETTINGS::registerMigration ( int  aOldSchemaVersion,
int  aNewSchemaVersion,
std::function< bool(void)>  aMigrator 
)
protectedinherited

Registers a migration from one schema version to another.

If the schema version in the file loaded from disk is less than the schema version of the JSON_SETTINGS class, migration functions will be called one after the other until the data is up-to-date.

Parameters
aOldSchemaVersionis the starting schema version for this migration
aNewSchemaVersionis the ending schema version for this migration
aMigratoris a function that performs the migration and returns true if successful

Definition at line 543 of file json_settings.cpp.

545{
546 wxASSERT( aNewSchemaVersion > aOldSchemaVersion );
547 wxASSERT( aNewSchemaVersion <= m_schemaVersion );
548 m_migrators[aOldSchemaVersion] = std::make_pair( aNewSchemaVersion, aMigrator );
549}

References JSON_SETTINGS::m_migrators, and JSON_SETTINGS::m_schemaVersion.

Referenced by BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS(), COLOR_SETTINGS::COLOR_SETTINGS(), EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS(), EESCHEMA_SETTINGS::EESCHEMA_SETTINGS(), FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS(), NET_SETTINGS::NET_SETTINGS(), PCBNEW_SETTINGS(), PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS(), SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS(), and SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS().

◆ ReleaseNestedSettings()

void JSON_SETTINGS::ReleaseNestedSettings ( NESTED_SETTINGS aSettings)
inherited

Saves and frees a nested settings object, if it exists within this one.

Parameters
aSettingsis a pointer to a NESTED_SETTINGS that has already been added to this one

Definition at line 750 of file json_settings.cpp.

751{
752 if( !aSettings || !m_manager )
753 return;
754
755 auto it = std::find_if( m_nested_settings.begin(), m_nested_settings.end(),
756 [&aSettings]( const JSON_SETTINGS* aPtr ) {
757 return aPtr == aSettings;
758 } );
759
760 if( it != m_nested_settings.end() )
761 {
762 wxLogTrace( traceSettings, wxT( "Flush and release %s" ), ( *it )->GetFilename() );
763 ( *it )->SaveToFile();
764 m_nested_settings.erase( it );
765 }
766
767 aSettings->SetParent( nullptr );
768}
SETTINGS_MANAGER * m_manager
A pointer to the settings manager managing this file (may be null)
void SetParent(JSON_SETTINGS *aParent, bool aLoadFromFile=true)

References JSON_SETTINGS::m_manager, JSON_SETTINGS::m_nested_settings, NESTED_SETTINGS::SetParent(), and traceSettings.

Referenced by BOARD_DESIGN_SETTINGS::~BOARD_DESIGN_SETTINGS(), ERC_SETTINGS::~ERC_SETTINGS(), NESTED_SETTINGS::~NESTED_SETTINGS(), NET_SETTINGS::~NET_SETTINGS(), and SCHEMATIC_SETTINGS::~SCHEMATIC_SETTINGS().

◆ ResetToDefaults()

void JSON_SETTINGS::ResetToDefaults ( )
inherited

Resets all parameters to default values.

Does NOT write to file or update underlying JSON.

Definition at line 367 of file json_settings.cpp.

368{
369 for( auto param : m_params )
370 param->SetDefault();
371}

References JSON_SETTINGS::m_params.

Referenced by EDA_3D_VIEWER_FRAME::Process_Special_Functions(), PANEL_COMMON_SETTINGS::ResetPanel(), and PANEL_MOUSE_SETTINGS::ResetPanel().

◆ SaveToFile()

bool JSON_SETTINGS::SaveToFile ( const wxString &  aDirectory = "",
bool  aForce = false 
)
virtualinherited
   Calls Store() and then writes the contents of the JSON document to a file
   @param aDirectory is the directory to save to, including trailing separator

c *

Returns
true if the file was saved

Reimplemented in PROJECT_FILE, PROJECT_LOCAL_SETTINGS, and NESTED_SETTINGS.

Definition at line 374 of file json_settings.cpp.

375{
376 if( !m_writeFile )
377 return false;
378
379 // Default PROJECT won't have a filename set
380 if( m_filename.IsEmpty() )
381 return false;
382
383 wxFileName path;
384
385 if( aDirectory.empty() )
386 {
387 path.Assign( m_filename );
388 path.SetExt( getFileExt() );
389 }
390 else
391 {
392 wxString dir( aDirectory );
393 path.Assign( dir, m_filename, getFileExt() );
394 }
395
396 if( !m_createIfMissing && !path.FileExists() )
397 {
398 wxLogTrace( traceSettings,
399 wxT( "File for %s doesn't exist and m_createIfMissing == false; not saving" ),
400 GetFullFilename() );
401 return false;
402 }
403
404 // Ensure the path exists, and create it if not.
405 if( !path.DirExists() && !path.Mkdir() )
406 {
407 wxLogTrace( traceSettings, wxT( "Warning: could not create path %s, can't save %s" ),
408 path.GetPath(), GetFullFilename() );
409 return false;
410 }
411
412 if( ( path.FileExists() && !path.IsFileWritable() ) ||
413 ( !path.FileExists() && !path.IsDirWritable() ) )
414 {
415 wxLogTrace( traceSettings, wxT( "File for %s is read-only; not saving" ), GetFullFilename() );
416 return false;
417 }
418
419 bool modified = false;
420
421 for( auto settings : m_nested_settings )
422 modified |= settings->SaveToFile();
423
424 modified |= Store();
425
426 if( !modified && !aForce && path.FileExists() )
427 {
428 wxLogTrace( traceSettings, wxT( "%s contents not modified, skipping save" ), GetFullFilename() );
429 return false;
430 }
431 else if( !modified && !aForce && !m_createIfDefault )
432 {
433 wxLogTrace( traceSettings,
434 wxT( "%s contents still default and m_createIfDefault == false; not saving" ),
435 GetFullFilename() );
436 return false;
437 }
438
439 wxLogTrace( traceSettings, wxT( "Saving %s" ), GetFullFilename() );
440
442 bool success = true;
443
444 try
445 {
446 std::stringstream buffer;
447 buffer << std::setw( 2 ) << *m_internals << std::endl;
448
449 wxFFileOutputStream fileStream( path.GetFullPath(), "wb" );
450
451 if( !fileStream.IsOk()
452 || !fileStream.WriteAll( buffer.str().c_str(), buffer.str().size() ) )
453 {
454 wxLogTrace( traceSettings, wxT( "Warning: could not save %s" ), GetFullFilename() );
455 success = false;
456 }
457 }
458 catch( nlohmann::json::exception& error )
459 {
460 wxLogTrace( traceSettings, wxT( "Catch error: could not save %s. Json error %s" ),
461 GetFullFilename(), error.what() );
462 success = false;
463 }
464 catch( ... )
465 {
466 wxLogTrace( traceSettings, wxT( "Error: could not save %s." ) );
467 success = false;
468 }
469
470 return success;
471}
bool m_createIfDefault
Whether or not the backing store file should be created if all parameters are still at their default ...
bool m_createIfMissing
Whether or not the backing store file should be created it if doesn't exist.
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74

References dummy(), JSON_SETTINGS::getFileExt(), JSON_SETTINGS::GetFullFilename(), JSON_SETTINGS::m_createIfDefault, JSON_SETTINGS::m_createIfMissing, JSON_SETTINGS::m_filename, JSON_SETTINGS::m_internals, JSON_SETTINGS::m_nested_settings, JSON_SETTINGS::m_writeFile, path, JSON_SETTINGS::Store(), and traceSettings.

Referenced by JSON_SETTINGS::LoadFromFile(), SETTINGS_MANAGER::MigrateIfNeeded(), PANEL_COLOR_SETTINGS::OnThemeChanged(), PROJECT::PinLibrary(), PROJECT_FILE::SaveAs(), PROJECT_LOCAL_SETTINGS::SaveAs(), SETTINGS_MANAGER::SaveColorSettings(), PROJECT_FILE::SaveToFile(), PROJECT_LOCAL_SETTINGS::SaveToFile(), PGM_BASE::SetLanguage(), and PROJECT::UnpinLibrary().

◆ Set() [1/3]

template<typename ValueType >
template void JSON_SETTINGS::Set< const char * > ( const std::string &  aPath,
ValueType  aVal 
)
inherited

Stores a value into the JSON document Will throw an exception if ValueType isn't something that the library can handle.

Template Parameters
ValueTypeis the type to store
Parameters
aPathis a path to store in the form "key1.key2.key3"
aValis the value to store

Definition at line 524 of file json_settings.cpp.

525{
526 m_internals->SetFromString( aPath, aVal );
527}

References JSON_SETTINGS::m_internals.

Referenced by COLOR_SETTINGS::COLOR_SETTINGS(), EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS(), EESCHEMA_SETTINGS::EESCHEMA_SETTINGS(), BOARD_DESIGN_SETTINGS::LoadFromFile(), APP_SETTINGS_BASE::migrateFindReplace(), PROJECT_FILE::MigrateFromLegacy(), APP_SETTINGS_BASE::MigrateFromLegacy(), EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy(), EESCHEMA_SETTINGS::MigrateFromLegacy(), SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy(), GERBVIEW_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), COMMON_SETTINGS::MigrateFromLegacy(), KICAD_SETTINGS::MigrateFromLegacy(), MigrateFromLegacy(), BOARD_DESIGN_SETTINGS::migrateSchema0to1(), FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1(), COLOR_SETTINGS::migrateSchema0to1(), PCBNEW_SETTINGS(), PROJECT_FILE::SaveAs(), PROJECT_LOCAL_SETTINGS::SaveAs(), PROJECT_FILE::SaveToFile(), PROJECT_LOCAL_SETTINGS::SaveToFile(), SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS(), COLOR_MAP_PARAM::Store(), PARAM< ValueType >::Store(), PARAM_PATH::Store(), PARAM_ENUM< EnumType >::Store(), PARAM_LAMBDA< ValueType >::Store(), PARAM_SCALED< ValueType >::Store(), PARAM_LIST< Type >::Store(), PARAM_SET< Type >::Store(), PARAM_PATH_LIST::Store(), and PARAM_MAP< Value >::Store().

◆ Set() [2/3]

template<>
void JSON_SETTINGS::Set ( const std::string &  aPath,
wxString  aVal 
)
inherited

Definition at line 782 of file json_settings.cpp.

783{
784 ( *m_internals )[aPath] = aVal.ToUTF8();
785}

◆ Set() [3/3]

template<>
void JSON_SETTINGS::Set ( const std::string &  aPath,
wxString  aVal 
)
inherited

◆ SetFilename()

void JSON_SETTINGS::SetFilename ( const wxString &  aFilename)
inlineinherited

◆ SetIfPresent() [1/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
bool &  aTarget 
)
staticinherited

Sets the given bool if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 609 of file json_settings.cpp.

611{
612 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
613
614 if( aObj.contains( ptr ) && aObj.at( ptr ).is_boolean() )
615 {
616 aTarget = aObj.at( ptr ).get<bool>();
617 return true;
618 }
619
620 return false;
621}

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [2/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
int &  aTarget 
)
staticinherited

Sets the given int if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 624 of file json_settings.cpp.

626{
627 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
628
629 if( aObj.contains( ptr ) && aObj.at( ptr ).is_number_integer() )
630 {
631 aTarget = aObj.at( ptr ).get<int>();
632 return true;
633 }
634
635 return false;
636}

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [3/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
unsigned int &  aTarget 
)
staticinherited

Sets the given unsigned int if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 639 of file json_settings.cpp.

641{
642 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
643
644 if( aObj.contains( ptr ) && aObj.at( ptr ).is_number_unsigned() )
645 {
646 aTarget = aObj.at( ptr ).get<unsigned int>();
647 return true;
648 }
649
650 return false;
651}

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [4/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
wxString &  aTarget 
)
staticinherited

Sets the given string if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 594 of file json_settings.cpp.

596{
597 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
598
599 if( aObj.contains( ptr ) && aObj.at( ptr ).is_string() )
600 {
601 aTarget = aObj.at( ptr ).get<wxString>();
602 return true;
603 }
604
605 return false;
606}

References JSON_SETTINGS_INTERNALS::PointerFromString().

Referenced by FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS(), and PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS().

◆ SetLegacyFilename()

void JSON_SETTINGS::SetLegacyFilename ( const wxString &  aFilename)
inlineinherited

Definition at line 82 of file json_settings.h.

82{ m_legacy_filename = aFilename; }

References JSON_SETTINGS::m_legacy_filename.

Referenced by SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS().

◆ SetLocation()

void JSON_SETTINGS::SetLocation ( SETTINGS_LOC  aLocation)
inlineinherited

Definition at line 79 of file json_settings.h.

79{ m_location = aLocation; }

References JSON_SETTINGS::m_location.

Referenced by COLOR_SETTINGS::COLOR_SETTINGS().

◆ SetManager()

void JSON_SETTINGS::SetManager ( SETTINGS_MANAGER aManager)
inlineinherited

Definition at line 192 of file json_settings.h.

193 {
194 m_manager = aManager;
195 }

References JSON_SETTINGS::m_manager.

◆ SetReadOnly()

◆ Store()

bool JSON_SETTINGS::Store ( )
virtualinherited

Stores the current parameters into the JSON document represented by this object Note: this doesn't do any writing to disk; that's handled by SETTINGS_MANAGER.

Returns
true if any part of the JSON document was updated

Definition at line 353 of file json_settings.cpp.

354{
355 bool modified = false;
356
357 for( auto param : m_params )
358 {
359 modified |= !param->MatchesFile( this );
360 param->Store( this );
361 }
362
363 return modified;
364}

References JSON_SETTINGS::m_params.

Referenced by PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), SETTINGS_MANAGER::SaveColorSettings(), JSON_SETTINGS::SaveToFile(), and NESTED_SETTINGS::SaveToFile().

Member Data Documentation

◆ m_AllowFreePads

◆ m_appSettingsSchemaVersion

int APP_SETTINGS_BASE::m_appSettingsSchemaVersion
inherited

! Local schema version for common app settings

Definition at line 190 of file app_settings.h.

◆ m_AuiPanels

◆ m_AutoRefillZones

bool PCBNEW_SETTINGS::m_AutoRefillZones

◆ m_Cleanup

DIALOG_CLEANUP PCBNEW_SETTINGS::m_Cleanup

◆ m_ColorPicker

◆ m_ColorTheme

◆ m_createIfDefault

bool JSON_SETTINGS::m_createIfDefault
protectedinherited

Whether or not the backing store file should be created if all parameters are still at their default values.

Ignored if m_createIfMissing is false or m_writeFile is false.

Definition at line 303 of file json_settings.h.

Referenced by JSON_SETTINGS::SaveToFile().

◆ m_createIfMissing

bool JSON_SETTINGS::m_createIfMissing
protectedinherited

Whether or not the backing store file should be created it if doesn't exist.

Definition at line 297 of file json_settings.h.

Referenced by JSON_SETTINGS::SaveToFile().

◆ m_CrossProbing

◆ m_CtrlClickHighlight

◆ m_deleteLegacyAfterMigration

bool JSON_SETTINGS::m_deleteLegacyAfterMigration
protectedinherited

Whether or not to delete legacy file after migration.

Definition at line 309 of file json_settings.h.

Referenced by JSON_SETTINGS::LoadFromFile(), PROJECT_FILE::PROJECT_FILE(), and PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS().

◆ m_Display

◆ m_DrcDialog

DIALOG_DRC PCBNEW_SETTINGS::m_DrcDialog

◆ m_ESCClearsNetHighlight

bool PCBNEW_SETTINGS::m_ESCClearsNetHighlight

◆ m_ExportIdf

DIALOG_EXPORT_IDF PCBNEW_SETTINGS::m_ExportIdf

Definition at line 325 of file pcbnew_settings.h.

Referenced by PCBNEW_SETTINGS(), and DIALOG_EXPORT_IDF3::~DIALOG_EXPORT_IDF3().

◆ m_ExportStep

◆ m_ExportSvg

◆ m_ExportVrml

◆ m_filename

◆ m_FindReplace

FIND_REPLACE APP_SETTINGS_BASE::m_FindReplace
inherited

◆ m_FlipLeftRight

◆ m_FootprintChooser

◆ m_FootprintTextShownColumns

wxString PCBNEW_SETTINGS::m_FootprintTextShownColumns

◆ m_FootprintViewer

◆ m_FootprintViewerAutoZoomOnSelect

bool PCBNEW_SETTINGS::m_FootprintViewerAutoZoomOnSelect

true to use automatic zoom on fp selection

Definition at line 387 of file pcbnew_settings.h.

Referenced by PCBNEW_SETTINGS(), and FOOTPRINT_VIEWER_FRAME::SaveSettings().

◆ m_FootprintViewerFPListWidth

int PCBNEW_SETTINGS::m_FootprintViewerFPListWidth

◆ m_FootprintViewerLibListWidth

int PCBNEW_SETTINGS::m_FootprintViewerLibListWidth

◆ m_FootprintViewerZoom

double PCBNEW_SETTINGS::m_FootprintViewerZoom

The last zoom level used (0 for auto)

Definition at line 386 of file pcbnew_settings.h.

Referenced by PCBNEW_SETTINGS(), and FOOTPRINT_VIEWER_FRAME::SaveSettings().

◆ m_FootprintWizard

WINDOW_SETTINGS PCBNEW_SETTINGS::m_FootprintWizard

Definition at line 353 of file pcbnew_settings.h.

Referenced by PCBNEW_SETTINGS().

◆ m_FootprintWizardList

◆ m_GenDrill

DIALOG_GENERATE_DRILL PCBNEW_SETTINGS::m_GenDrill

Definition at line 335 of file pcbnew_settings.h.

Referenced by PCBNEW_SETTINGS(), and DIALOG_GENDRILL::UpdateConfig().

◆ m_Graphics

◆ m_ImportGraphics

◆ m_internals

◆ m_lastFootprint3dDir

wxString PCBNEW_SETTINGS::m_lastFootprint3dDir

◆ m_lastFootprintLibDir

wxString PCBNEW_SETTINGS::m_lastFootprintLibDir

◆ m_legacy_filename

wxString JSON_SETTINGS::m_legacy_filename
protectedinherited

The filename of the wxConfig legacy file (if different from m_filename)

Definition at line 285 of file json_settings.h.

Referenced by JSON_SETTINGS::LoadFromFile(), and JSON_SETTINGS::SetLegacyFilename().

◆ m_LibTree

◆ m_location

SETTINGS_LOC JSON_SETTINGS::m_location
protectedinherited

The location of this settings file (.

See also
SETTINGS_LOC)

Definition at line 288 of file json_settings.h.

Referenced by JSON_SETTINGS::GetLocation(), and JSON_SETTINGS::SetLocation().

◆ m_MagneticItems

◆ m_manager

SETTINGS_MANAGER* JSON_SETTINGS::m_manager
protectedinherited

A pointer to the settings manager managing this file (may be null)

Definition at line 318 of file json_settings.h.

Referenced by FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1(), COLOR_SETTINGS::migrateSchema0to1(), JSON_SETTINGS::ReleaseNestedSettings(), and JSON_SETTINGS::SetManager().

◆ m_migrators

std::map<int, std::pair<int, std::function<bool()> > > JSON_SETTINGS::m_migrators
protectedinherited

A map of starting schema version to a pair of <ending version, migrator function>

Definition at line 321 of file json_settings.h.

Referenced by JSON_SETTINGS::Migrate(), and JSON_SETTINGS::registerMigration().

◆ m_nested_settings

std::vector<NESTED_SETTINGS*> JSON_SETTINGS::m_nested_settings
protectedinherited

Nested settings files that live inside this one, if any.

Definition at line 294 of file json_settings.h.

Referenced by JSON_SETTINGS::AddNestedSettings(), JSON_SETTINGS::LoadFromFile(), JSON_SETTINGS::ReleaseNestedSettings(), and JSON_SETTINGS::SaveToFile().

◆ m_NetlistDialog

◆ m_params

◆ m_PlaceFile

DIALOG_PLACE_FILE PCBNEW_SETTINGS::m_PlaceFile

◆ m_Plot

DIALOG_PLOT PCBNEW_SETTINGS::m_Plot

Definition at line 343 of file pcbnew_settings.h.

Referenced by DIALOG_PLOT::applyPlotSettings(), and PCBNEW_SETTINGS().

◆ m_PnsSettings

std::unique_ptr<PNS::ROUTING_SETTINGS> PCBNEW_SETTINGS::m_PnsSettings

Definition at line 384 of file pcbnew_settings.h.

Referenced by PNS::TOOL_BASE::Reset().

◆ m_PolarCoords

bool PCBNEW_SETTINGS::m_PolarCoords

◆ m_Printing

◆ m_Reannotate

◆ m_resetParamsIfMissing

bool JSON_SETTINGS::m_resetParamsIfMissing
protectedinherited

Whether or not to set parameters to their default value if missing from JSON on Load()

Definition at line 312 of file json_settings.h.

Referenced by BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS(), and JSON_SETTINGS::Load().

◆ m_RotationAngle

◆ m_schemaVersion

int JSON_SETTINGS::m_schemaVersion
protectedinherited

◆ m_ShowPageLimits

bool PCBNEW_SETTINGS::m_ShowPageLimits
Todo:
Implement real auto zone filling (not just after zone properties are edited)

Definition at line 373 of file pcbnew_settings.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetShowPageLimits(), PANEL_EDIT_OPTIONS::loadPCBSettings(), PCBNEW_SETTINGS(), and PANEL_EDIT_OPTIONS::TransferDataFromWindow().

◆ m_System

◆ m_TrackDragAction

◆ m_Use45DegreeLimit

◆ m_ViewersDisplay

◆ m_VisibleActionPlugins

◆ m_Window

◆ m_writeFile

bool JSON_SETTINGS::m_writeFile
protectedinherited

◆ m_Zones


The documentation for this class was generated from the following files: