KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_editor_settings.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22
23#include <common.h>
24#include <layer_ids.h>
25#include <lset.h>
26#include <pgm_base.h>
27#include <eda_text.h>
28#include <pcb_dimension.h>
31#include <settings/parameters.h>
33#include <base_units.h>
34
35#include <wx/config.h>
36#include <wx/log.h>
37
38
40const int fpEditSchemaVersion = 4;
41
42
45 m_DesignSettings( nullptr, "fpedit.settings" ),
46 m_MagneticItems(),
47 m_Display(),
48 m_UserGrid(),
49 m_PolarCoords( false ),
50 m_DisplayInvertXAxis( false ),
51 m_DisplayInvertYAxis( false ),
52 m_RotationAngle( ANGLE_90 ),
53 m_Use45Limit( true ),
55 m_LibWidth( 250 ),
56 m_LastExportPath(),
57 m_FootprintTextShownColumns()
58{
59 m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
60 m_MagneticItems.tracks = MAGNETIC_OPTIONS::NO_EFFECT;
63
67
68 m_params.emplace_back( new PARAM<int>( "window.lib_width",
69 &m_LibWidth, 250 ) );
70
71 m_params.emplace_back( new PARAM<bool>( "aui.show_layer_manager",
73
74 m_params.emplace_back( new PARAM<int>( "aui.right_panel_width",
76
77 m_params.emplace_back( new PARAM<int>( "aui.appearance_panel_tab",
79
80 m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
82
83 m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
85
86 m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
87 &m_AuiPanels.show_properties, false ) );
88
89 m_params.emplace_back( new PARAM<int>( "library.sort_mode",
90 &m_LibrarySortMode, 0 ) );
91
92 m_params.emplace_back( new PARAM<wxString>( "system.last_import_export_path",
93 &m_LastExportPath, "" ) );
94
95 m_params.emplace_back( new PARAM<bool>( "pcb_display.graphics_fill",
97
98 m_params.emplace_back( new PARAM<bool>( "pcb_display.text_fill",
100
101 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_fill",
103
104 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_numbers",
106
107 m_params.emplace_back( new PARAM<wxString>( "window.footprint_text_shown_columns",
108 &m_FootprintTextShownColumns, "0 1 2 3 4 5 7" ) );
109
110 m_params.emplace_back( new PARAM<int>( "editing.magnetic_pads",
111 reinterpret_cast<int*>( &m_MagneticItems.pads ),
112 static_cast<int>( MAGNETIC_OPTIONS::CAPTURE_ALWAYS ) ) );
113
114 m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics",
115 &m_MagneticItems.graphics, true ) );
116
117 m_params.emplace_back( new PARAM<bool>( "editing.magnetic_all_layers",
118 &m_MagneticItems.allLayers, false ) );
119
120 m_params.emplace_back( new PARAM<bool>( "editing.polar_coords",
121 &m_PolarCoords, false ) );
122
123 m_params.emplace_back( new PARAM<bool>( "origin_invert_x_axis",
124 &m_DisplayInvertXAxis, false ) );
125
126 m_params.emplace_back( new PARAM<bool>( "origin_invert_y_axis",
127 &m_DisplayInvertYAxis, false ) );
128
129 m_params.emplace_back( new PARAM_LAMBDA<int>( "editing.rotation_angle",
130 [this] () -> int
131 {
133 },
134 [this] ( int aVal )
135 {
136 if( aVal )
138 },
139 900 ) );
140
141 m_params.emplace_back( new PARAM<bool>( "editing.fp_use_45_degree_limit",
142 &m_Use45Limit, false ) );
143
144 m_params.emplace_back( new PARAM_LAYER_PRESET( "pcb_display.layer_presets", &m_LayerPresets ) );
145
146 m_params.emplace_back( new PARAM<wxString>( "pcb_display.active_layer_preset",
147 &m_ActiveLayerPreset, "" ) );
148
149 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
150 "design_settings.default_footprint_text_items",
151 [&] () -> nlohmann::json
152 {
153 nlohmann::json js = nlohmann::json::array();
154
156 {
157 js.push_back( nlohmann::json( { item.m_Text.ToUTF8(),
158 item.m_Visible,
159 item.m_Layer } ) );
160 }
161
162 return js;
163 },
164 [&] ( const nlohmann::json& aObj )
165 {
167
168 if( !aObj.is_array() )
169 return;
170
171 for( const nlohmann::json& entry : aObj )
172 {
173 if( entry.empty() || !entry.is_array() )
174 continue;
175
176 TEXT_ITEM_INFO textInfo( wxT( "" ), true, F_SilkS );
177
178 textInfo.m_Text = entry.at(0).get<wxString>();
179 textInfo.m_Visible = entry.at(1).get<bool>();
180 textInfo.m_Layer = entry.at(2).get<int>();
181
182 m_DesignSettings.m_DefaultFPTextItems.push_back( std::move( textInfo ) );
183 }
184 },
185 nlohmann::json::array( {
186 { "REF**", true, F_SilkS },
187 { "", true, F_Fab },
188 { "${REFERENCE}", true, F_Fab }
189 } ) ) );
190
191 int minTextSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
192 int maxTextSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
193 int minStroke = 1;
194 int maxStroke = pcbIUScale.mmToIU( 100 );
195
196 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_line_width",
198 pcbIUScale.mmToIU( DEFAULT_SILK_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
199
200 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_text_size_h",
202 pcbIUScale.mmToIU( DEFAULT_SILK_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
203
204 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_text_size_v",
206 pcbIUScale.mmToIU( DEFAULT_SILK_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
207
208 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_text_thickness",
211
212 m_params.emplace_back( new PARAM<bool>( "design_settings.silk_text_italic",
214
215 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_line_width",
217 pcbIUScale.mmToIU( DEFAULT_COPPER_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
218
219 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_text_size_h",
221 pcbIUScale.mmToIU( DEFAULT_COPPER_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
222
223 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_text_size_v",
225 pcbIUScale.mmToIU( DEFAULT_COPPER_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
226
227 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_text_thickness",
229 pcbIUScale.mmToIU( DEFAULT_COPPER_TEXT_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
230
231 m_params.emplace_back( new PARAM<bool>( "design_settings.copper_text_italic",
233
234 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.edge_line_width",
236 pcbIUScale.mmToIU( DEFAULT_EDGE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
237
238 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.courtyard_line_width",
240 pcbIUScale.mmToIU( DEFAULT_COURTYARD_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
241
242 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_line_width",
244 pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
245
246 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_text_size_h",
248 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
249
250 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_text_size_v",
252 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
253
254 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_text_thickness",
257
258 m_params.emplace_back( new PARAM<bool>( "design_settings.fab_text_italic",
260
261 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_line_width",
263 pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
264
265 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_text_size_h",
267 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
268
269 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_text_size_v",
271 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
272
273 m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_text_thickness",
276
277 m_params.emplace_back( new PARAM<bool>( "design_settings.others_text_italic",
279
280
281 // ---------------------------------------------------------------------------------------------
282 // Dimension settings
283
284 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_MODE>( "design_settings.dimensions.units",
285 &m_DesignSettings.m_DimensionUnitsMode, DIM_UNITS_MODE::AUTOMATIC, DIM_UNITS_MODE::INCHES,
286 DIM_UNITS_MODE::AUTOMATIC ) );
287
288 m_params.emplace_back( new PARAM_ENUM<DIM_PRECISION>( "design_settings.dimensions.precision",
289 &m_DesignSettings.m_DimensionPrecision, DIM_PRECISION::X_XXXX, DIM_PRECISION::X, DIM_PRECISION::V_VVVVV ) );
290
291 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_FORMAT>( "design_settings.dimensions.units_format",
292 &m_DesignSettings.m_DimensionUnitsFormat, DIM_UNITS_FORMAT::NO_SUFFIX, DIM_UNITS_FORMAT::NO_SUFFIX,
293 DIM_UNITS_FORMAT::PAREN_SUFFIX ) );
294
295 m_params.emplace_back( new PARAM<bool>( "design_settings.dimensions.suppress_zeroes",
297
298 // NOTE: excluding DIM_TEXT_POSITION::MANUAL from the valid range here
299 m_params.emplace_back( new PARAM_ENUM<DIM_TEXT_POSITION>( "design_settings.dimensions.text_position",
300 &m_DesignSettings.m_DimensionTextPosition, DIM_TEXT_POSITION::OUTSIDE, DIM_TEXT_POSITION::OUTSIDE,
301 DIM_TEXT_POSITION::INLINE ) );
302
303 m_params.emplace_back( new PARAM<bool>( "design_settings.dimensions.keep_text_aligned",
305
306 m_params.emplace_back( new PARAM<int>( "design_settings.dimensions.arrow_length",
309
310 m_params.emplace_back( new PARAM<int>( "design_settings.dimensions.extension_offset",
313
314 // ---------------------------------------------------------------------------------------------
315
316 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "editing.selection_filter",
317 [&]() -> nlohmann::json
318 {
319 nlohmann::json ret;
320
321 ret["lockedItems"] = m_SelectionFilter.lockedItems;
322 ret["footprints"] = m_SelectionFilter.footprints;
323 ret["text"] = m_SelectionFilter.text;
324 ret["tracks"] = m_SelectionFilter.tracks;
325 ret["vias"] = m_SelectionFilter.vias;
326 ret["pads"] = m_SelectionFilter.pads;
327 ret["graphics"] = m_SelectionFilter.graphics;
328 ret["zones"] = m_SelectionFilter.zones;
329 ret["keepouts"] = m_SelectionFilter.keepouts;
330 ret["dimensions"] = m_SelectionFilter.dimensions;
331 ret["otherItems"] = m_SelectionFilter.otherItems;
332
333 return ret;
334 },
335 [&]( const nlohmann::json& aVal )
336 {
337 if( aVal.empty() || !aVal.is_object() )
338 return;
339
340 SetIfPresent( aVal, "lockedItems", m_SelectionFilter.lockedItems );
341 SetIfPresent( aVal, "footprints", m_SelectionFilter.footprints );
342 SetIfPresent( aVal, "text", m_SelectionFilter.text );
343 SetIfPresent( aVal, "tracks", m_SelectionFilter.tracks );
344 SetIfPresent( aVal, "vias", m_SelectionFilter.vias );
345 SetIfPresent( aVal, "pads", m_SelectionFilter.pads );
346 SetIfPresent( aVal, "graphics", m_SelectionFilter.graphics );
347 SetIfPresent( aVal, "zones", m_SelectionFilter.zones );
348 SetIfPresent( aVal, "keepouts", m_SelectionFilter.keepouts );
349 SetIfPresent( aVal, "dimensions", m_SelectionFilter.dimensions );
350 SetIfPresent( aVal, "otherItems", m_SelectionFilter.otherItems );
351 },
352 {
353 { "lockedItems", false },
354 { "footprints", true },
355 { "text", true },
356 { "tracks", true },
357 { "vias", true },
358 { "pads", true },
359 { "graphics", true },
360 { "zones", true },
361 { "keepouts", true },
362 { "dimensions", true },
363 { "otherItems", true }
364 } ) );
365
367
368 registerMigration( 1, 2,
369 [&]() -> bool
370 {
371 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
372 return migrateLibTreeWidth();
373 } );
374
377}
378
379
381{
382 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
383
384 //
385 // NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
386 //
387 ret &= fromLegacy<int>( aCfg, "ModeditLibWidth", "window.lib_width" );
388 ret &= fromLegacyString( aCfg, "import_last_path", "system.last_import_export_path" );
389 ret &= fromLegacyString( aCfg, "LibFootprintTextShownColumns", "window.footprint_text_shown_columns" );
390
391 ret &= fromLegacy<int>( aCfg, "FpEditorMagneticPads", "editing.magnetic_pads" );
392 ret &= fromLegacy<bool>( aCfg, "FpEditorDisplayPolarCoords", "editing.polar_coords" );
393 ret &= fromLegacy<int>( aCfg, "FpEditorUse45DegreeGraphicSegments", "editing.use_45_degree_graphic_segments" );
394
395 ret &= fromLegacy<bool>( aCfg, "FpEditorGraphicLinesDisplayMode", "pcb_display.graphic_items_fill" );
396 ret &= fromLegacy<bool>( aCfg, "FpEditorPadDisplayMode", "pcb_display.pad_fill" );
397 ret &= fromLegacy<bool>( aCfg, "FpEditorTextsDisplayMode", "pcb_display.footprint_text" );
398
399 ret &= fromLegacy<double>( aCfg, "FpEditorSilkLineWidth", "design_settings.silk_line_width" );
400 ret &= fromLegacy<double>( aCfg, "FpEditorSilkTextSizeH", "design_settings.silk_text_size_h" );
401 ret &= fromLegacy<double>( aCfg, "FpEditorSilkTextSizeV", "design_settings.silk_text_size_v" );
402 ret &= fromLegacy<double>( aCfg, "FpEditorSilkTextThickness", "design_settings.silk_text_thickness" );
403 ret &= fromLegacy<bool>( aCfg, "FpEditorSilkTextItalic", "design_settings.silk_text_italic" );
404 ret &= fromLegacy<double>( aCfg, "FpEditorCopperLineWidth", "design_settings.copper_line_width" );
405 ret &= fromLegacy<double>( aCfg, "FpEditorCopperTextSizeH", "design_settings.copper_text_size_h" );
406 ret &= fromLegacy<double>( aCfg, "FpEditorCopperTextSizeV", "design_settings.copper_text_size_v" );
407 ret &= fromLegacy<double>( aCfg, "FpEditorCopperTextThickness", "design_settings.copper_text_thickness" );
408 ret &= fromLegacy<bool>( aCfg, "FpEditorCopperTextItalic", "design_settings.copper_text_italic" );
409 ret &= fromLegacy<double>( aCfg, "FpEditorEdgeCutLineWidth", "design_settings.edge_line_width" );
410 ret &= fromLegacy<double>( aCfg, "FpEditorCourtyardLineWidth", "design_settings.courtyard_line_width" );
411 ret &= fromLegacy<double>( aCfg, "FpEditorOthersLineWidth", "design_settings.others_line_width" );
412 ret &= fromLegacy<double>( aCfg, "FpEditorOthersTextSizeH", "design_settings.others_text_size_h" );
413 ret &= fromLegacy<double>( aCfg, "FpEditorOthersTextSizeV", "design_settings.others_text_size_v" );
414 ret &= fromLegacy<double>( aCfg, "FpEditorOthersTextThickness", "design_settings.others_text_thickness" );
415 ret &= fromLegacy<bool>( aCfg, "FpEditorOthersTextItalic", "design_settings.others_text_italic" );
416
417 nlohmann::json textItems = nlohmann::json::array( {
418 { "REF**", true, F_SilkS },
419 { "", true, F_Fab }
420 } );
421
422 Set( "design_settings.default_footprint_text_items", std::move( textItems ) );
423
424 ret &= fromLegacyString( aCfg, "FpEditorRefDefaultText", "design_settings.default_footprint_text_items.0.0" );
425 ret &= fromLegacy<bool>( aCfg, "FpEditorRefDefaultVisibility", "design_settings.default_footprint_text_items.0.1" );
426 ret &= fromLegacy<int>( aCfg, "FpEditorRefDefaultLayer", "design_settings.default_footprint_text_items.0.2" );
427 ret &= fromLegacyString( aCfg, "FpEditorValueDefaultText", "design_settings.default_footprint_text_items.1.0" );
428 ret &= fromLegacy<bool>( aCfg, "FpEditorValueDefaultVisibility", "design_settings.default_footprint_text_items.1.1" );
429 ret &= fromLegacy<int>( aCfg, "FpEditorValueDefaultLayer", "design_settings.default_footprint_text_items.1.2" );
430
431
432 std::string f = "ModEdit";
433
434 // Migrate color settings that were stored in the pcbnew config file
435 // We create a copy of the user scheme for the footprint editor context
436
438 COLOR_SETTINGS* cs = manager.AddNewColorSettings( "user_footprints" );
439
440 cs->SetName( wxT( "User (Footprints)" ) );
441 manager.Save( cs );
442
443 auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId )
444 {
445 wxString str;
446
447 if( aCfg->Read( aKey, &str ) )
448 cs->SetColor( aLayerId, COLOR4D( str ) );
449 };
450
451 for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
452 {
453 wxString layer = LSET::Name( PCB_LAYER_ID( i ) );
454 migrateLegacyColor( f + "Color4DPCBLayer_" + layer.ToStdString(), PCB_LAYER_ID( i ) );
455 }
456
457 migrateLegacyColor( f + "Color4DAnchorEx", LAYER_ANCHOR );
458 migrateLegacyColor( f + "Color4DAuxItems", LAYER_AUX_ITEMS );
459 migrateLegacyColor( f + "Color4DGrid", LAYER_GRID );
460 migrateLegacyColor( f + "Color4DNonPlatedEx", LAYER_NON_PLATEDHOLES );
461 migrateLegacyColor( f + "Color4DPCBBackground", LAYER_PCB_BACKGROUND );
462 migrateLegacyColor( f + "Color4DPCBCursor", LAYER_CURSOR );
463 migrateLegacyColor( f + "Color4DRatsEx", LAYER_RATSNEST );
464 migrateLegacyColor( f + "Color4DViaBBlindEx", LAYER_VIA_BBLIND );
465 migrateLegacyColor( f + "Color4DViaMicroEx", LAYER_VIA_MICROVIA );
466 migrateLegacyColor( f + "Color4DViaThruEx", LAYER_VIA_THROUGH );
467 migrateLegacyColor( f + "Color4DWorksheet", LAYER_DRAWINGSHEET );
468
469 manager.SaveColorSettings( cs, "board" );
470
471 ( *m_internals )[m_internals->PointerFromString( "appearance.color_theme" )] = "user_footprints";
472
473 double x = 0, y = 0;
474 f = "ModEditFrame";
475
476 if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) )
477 {
478 EDA_UNITS u = static_cast<EDA_UNITS>( aCfg->ReadLong( f + "PcbUserGrid_Unit",
479 static_cast<long>( EDA_UNITS::INCHES ) ) );
480
481 // Convert to internal units
484
485 Set( "window.grid.user_grid_x", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, x ) );
486 Set( "window.grid.user_grid_y", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, y ) );
487 }
488
489 return ret;
490}
491
492
494{
502 if( !m_manager )
503 {
504 wxLogTrace( traceSettings,
505 wxT( "Error: FOOTPRINT_EDITOR_SETTINGS migration cannot run unmanaged!" ) );
506 return false;
507 }
508
509 std::string theme_ptr( "appearance.color_theme" );
510
511 if( !Contains( theme_ptr ) )
512 return true;
513
514 wxString selected = At( theme_ptr ).get<wxString>();
515 wxString search = selected + wxT( "_footprints" );
516
517 for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
518 {
519 if( settings->GetFilename() == search )
520 {
521 wxLogTrace( traceSettings, wxT( "Updating footprint editor theme from %s to %s" ),
522 selected, search );
523 Set( theme_ptr, search );
524 return true;
525 }
526 }
527
528 return true;
529}
530
531
537{
538 auto p( "/pcb_display/layer_presets"_json_pointer );
539
540 if( !m_internals->contains( p ) || !m_internals->at( p ).is_array() )
541 return true;
542
543 nlohmann::json& presets = m_internals->at( p );
544
545 for( nlohmann::json& entry : presets )
547
548 return true;
549}
550
551
556{
557 auto p( "/pcb_display/layer_presets"_json_pointer );
558
559 if( !m_internals->contains( p ) || !m_internals->at( p ).is_array() )
560 return true;
561
562 nlohmann::json& presets = m_internals->at( p );
563
564 for( nlohmann::json& entry : presets )
566
567 return true;
568}
ARC_EDIT_MODE
Settings for arc editing.
Definition: app_settings.h:52
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
#define DEFAULT_TEXT_WIDTH
#define DEFAULT_COPPER_TEXT_WIDTH
#define DEFAULT_DIMENSION_EXTENSION_OFFSET
#define DEFAULT_DIMENSION_ARROW_LENGTH
#define DEFAULT_SILK_TEXT_SIZE
#define DEFAULT_COPPER_LINE_WIDTH
#define DEFAULT_SILK_LINE_WIDTH
@ LAYER_CLASS_OTHERS
@ LAYER_CLASS_FAB
@ LAYER_CLASS_COURTYARD
@ LAYER_CLASS_SILK
@ LAYER_CLASS_COPPER
@ LAYER_CLASS_EDGES
#define DEFAULT_SILK_TEXT_WIDTH
#define DEFAULT_EDGE_WIDTH
#define DEFAULT_COPPER_TEXT_SIZE
#define DEFAULT_LINE_WIDTH
#define DEFAULT_COURTYARD_WIDTH
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool migrateLibTreeWidth()
Migrate the library tree width setting from a single column (Item) to multi-column.
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
DIM_UNITS_FORMAT m_DimensionUnitsFormat
int m_TextThickness[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
VECTOR2I m_TextSize[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetName(const wxString &aName)
void SetColor(int aLayer, const COLOR4D &aColor)
int AsTenthsOfADegree() const
Definition: eda_angle.h:115
bool migrateSchema3To4()
Schema version 4: move layer presets to use named render layers.
BOARD_DESIGN_SETTINGS m_DesignSettings
Only some of these settings are actually used for footprint editing.
bool migrateSchema2To3()
Schema version 2: Bump for KiCad 9 layer numbering changes Migrate layer presets to use new enum valu...
std::vector< LAYER_PRESET > m_LayerPresets
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
PCB_SELECTION_FILTER_OPTIONS m_SelectionFilter
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
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...
SETTINGS_MANAGER * m_manager
A pointer to the settings manager managing this file (may be null)
bool Contains(const std::string &aPath) const
static bool SetIfPresent(const nlohmann::json &aObj, const std::string &aPath, wxString &aTarget)
Sets the given string if the given key/path is present.
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...
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:188
Stores an enum as an integer.
Definition: parameters.h:228
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:295
static void MigrateToV9Layers(nlohmann::json &aJson)
static void MigrateToNamedRenderLayers(nlohmann::json &aJson)
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:392
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
COLOR_SETTINGS * AddNewColorSettings(const wxString &aFilename)
Register a new color settings object with the given filename.
The common library.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
@ TENTHS_OF_A_DEGREE_T
Definition: eda_angle.h:30
#define TEXT_MIN_SIZE_MM
Minimum text size (1 micron).
Definition: eda_text.h:47
#define TEXT_MAX_SIZE_MM
Maximum text size in mm (~10 inches)
Definition: eda_text.h:48
EDA_UNITS
Definition: eda_units.h:46
const int fpEditSchemaVersion
! Update the schema version whenever a migration is required
#define traceSettings
Definition: json_settings.h:52
@ LAYER_GRID
Definition: layer_ids.h:216
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
Definition: layer_ids.h:201
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition: layer_ids.h:240
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:243
@ LAYER_CURSOR
PCB cursor.
Definition: layer_ids.h:244
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc).
Definition: layer_ids.h:245
@ LAYER_RATSNEST
Definition: layer_ids.h:215
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition: layer_ids.h:210
@ LAYER_VIA_MICROVIA
Definition: layer_ids.h:196
@ LAYER_VIA_THROUGH
Draw blind/buried vias.
Definition: layer_ids.h:198
@ LAYER_VIA_BBLIND
Draw micro vias.
Definition: layer_ids.h:197
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_Fab
Definition: layer_ids.h:119
@ F_SilkS
Definition: layer_ids.h:100
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:135
KICOMMON_API double FromUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Return in internal units the value aValue given in a real unit such as "in", "mm",...
Definition: eda_units.cpp:487
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Return the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:290
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1073
see class PGM_BASE
const double MM_PER_IU
Definition: base_units.h:78
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads
bool otherItems
Anything not fitting one of the above categories.
bool graphics
Graphic lines, shapes, polygons.
bool footprints
Allow selecting entire footprints.
bool text
Text (free or attached to a footprint)
bool lockedItems
Allow selecting locked items.