KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_design_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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
22
23#include <algorithm>
24#include <cmath>
25
28#include <magic_enum.hpp>
29#include <pcb_dimension.h>
30#include <pcb_track.h>
31#include <layer_ids.h>
32#include <lset.h>
33#include <kiface_base.h>
34#include <pad.h>
36#include <drc/drc_item.h>
37#include <drc/drc_engine.h>
39#include <settings/parameters.h>
41#include <advanced_config.h>
42#include <wx/debug.h>
43
44const int bdsSchemaVersion = 4;
45
46
47BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
48 NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aParent, aPath )
49{
50 // We want to leave alone parameters that aren't found in the project JSON as they may be
51 // initialized by the board file parser before NESTED_SETTINGS::LoadFromFile is called.
53
54 // Create a default NET_SETTINGS so that things don't break horribly if there's no project
55 // loaded. This also is used during file load for legacy boards that have netclasses stored
56 // in the file. After load, this information will be moved to the project and the pointer
57 // updated.
58 m_NetSettings = std::make_shared<NET_SETTINGS>( nullptr, "" );
59
60 m_HasStackup = false; // no stackup defined by default
61
62 LSET all_set = LSET().set();
63 m_enabledLayers = all_set; // All layers enabled at first.
64 // SetCopperLayerCount() will adjust this.
65
66 // Default design is a double layer board with 4 user defined layers
69
71
72 // if true, when creating a new track starting on an existing track, use this track width
75
76 // First is always the reference designator
77 m_DefaultFPTextItems.emplace_back( wxT( "REF**" ), true, F_SilkS );
78 // Second is always the value
79 m_DefaultFPTextItems.emplace_back( wxT( "" ), true, F_Fab );
80 // Any following ones are freebies
81 m_DefaultFPTextItems.emplace_back( wxT( "${REFERENCE}" ), true, F_Fab );
82
89
96
97 // Edges & Courtyards; text properties aren't used but better to have them holding
98 // reasonable values than not.
101 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ) );
105
108 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ) );
112
115 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ) );
117 m_TextItalic[ LAYER_CLASS_FAB ] = false;
119
122 pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ) );
126
127 m_StyleFPFields = false;
128 m_StyleFPText = false;
129 m_StyleFPShapes = false;
130 m_StyleFPDimensions = false;
131 m_StyleFPBarcodes = false;
132
141
142 m_useCustomTrackVia = false;
144 m_customViaSize.m_Diameter = pcbIUScale.mmToIU( DEFAULT_VIASMINSIZE );
146
147 m_useCustomDiffPair = false;
151
168
169 for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode )
170 m_DRCSeverities[ errorCode ] = RPT_SEVERITY_ERROR;
171
174
178
182
186
189
192
200
206
208
211
213
216
219
221
225
226 m_BomExportFileName = wxS( "${PROJECTNAME}.csv" );
227 m_BomSettings = BOM_PRESET::DefaultEditing();
229
230 // Global mask margins:
234
235 // Solder paste margin absolute value
237 // Solder paste margin as a ratio of pad size
238 // The final margin is the sum of these 2 values
239 // Usually < 0 because the mask is smaller than pad
241
243 m_TentViasFront = true;
244 m_TentViasBack = true;
245
246 m_CoverViasFront = false;
247 m_CoverViasBack = false;
248
249 m_PlugViasFront = false;
250 m_PlugViasBack = false;
251
252 m_CapVias = false;
253
254 m_FillVias = false;
255
256 // Layer thickness for 3D viewer
258
259 // Default spacing for meanders
263
264 m_viaSizeIndex = 0;
265 m_viaStackIndex = 0;
267 m_diffPairIndex = 0;
268
269 // Parameters stored in JSON in the project file
270
271 // NOTE: Previously, BOARD_DESIGN_SETTINGS stored the basic board layer information (layer
272 // names and enable/disable state) in the project file even though this information is also
273 // stored in the board file. This was implemented for importing these settings from another
274 // project. Going forward, the import feature will just import from other board files (since
275 // we could have multi-board projects in the future anyway) so this functionality is dropped.
276
277 m_params.emplace_back( new PARAM<wxString>( "bom_export_filename",
278 &m_BomExportFileName, "${PROJECTNAME}.csv" ) );
279
280 m_params.emplace_back( new PARAM<BOM_PRESET>( "bom_settings",
281 &m_BomSettings, BOM_PRESET::DefaultEditing() ) );
282 m_params.emplace_back( new PARAM_LIST<BOM_PRESET>( "bom_presets",
283 &m_BomPresets, {} ) );
284
285 m_params.emplace_back( new PARAM<BOM_FMT_PRESET>( "bom_fmt_settings",
287 m_params.emplace_back( new PARAM_LIST<BOM_FMT_PRESET>( "bom_fmt_presets",
288 &m_BomFmtPresets, {} ) );
289
290 m_params.emplace_back( new PARAM<bool>( "rules.use_height_for_length_calcs",
291 &m_UseHeightForLengthCalcs, true ) );
292
293 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_clearance",
295 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
296
297 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_connection",
299 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
300
301 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_track_width",
303 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
304
305 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_annular_width",
307 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
308
309 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_diameter",
311 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
312
313 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_through_hole_diameter",
315 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
316
317 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_diameter",
319 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 10.0 ), pcbIUScale.MM_PER_IU ) );
320
321 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_drill",
323 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 10.0 ), pcbIUScale.MM_PER_IU ) );
324
325 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_to_hole",
327 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 10.0 ), pcbIUScale.MM_PER_IU ) );
328
329 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_clearance",
331 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
332
333 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_silk_clearance",
335 pcbIUScale.mmToIU( -10.0 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
336
337 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_groove_width",
339 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
340
341 // While the maximum *effective* value is 4, we've had users interpret this as the count on
342 // all layers, and enter something like 10. They'll figure it out soon enough *unless* we
343 // enforce a max of 4 (and therefore reset it back to the default of 2), at which point it
344 // just looks buggy.
345 m_params.emplace_back( new PARAM<int>( "rules.min_resolved_spokes",
347
348 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_text_height",
350 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
351
352 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_silk_line_width",
354 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
355
356 // Note: a clearance of -0.01 is a flag indicating we should use the legacy (pre-6.0) method
357 // based on the edge cut thicknesses.
358 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_copper_edge_clearance",
360 pcbIUScale.mmToIU( -0.01 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
361
362 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities",
363 [&]() -> nlohmann::json
364 {
365 nlohmann::json ret = {};
366
367 for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
368 {
369 wxString name = item.GetSettingsKey();
370 int code = item.GetErrorCode();
371
372 if( name.IsEmpty() || m_DRCSeverities.count( code ) == 0 )
373 continue;
374
375 ret[std::string( name.ToUTF8() )] = SeverityToString( m_DRCSeverities[code] );
376 }
377
378 return ret;
379 },
380 [&]( const nlohmann::json& aJson )
381 {
382 if( !aJson.is_object() )
383 return;
384
385 // Load V8 'hole_near_hole' token first (if present). Any current 'hole_to_hole' token
386 // found will then overwrite it.
387 // We can't use the migration architecture because we forgot to bump the version number
388 // when the change was made. But this is a one-off as any future deprecations should
389 // bump the version number and use registerMigration().
390 if( aJson.contains( "hole_near_hole" ) )
392
393 for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
394 {
395 wxString name = item.GetSettingsKey();
396 std::string key( name.ToUTF8() );
397
398 if( aJson.contains( key ) )
399 m_DRCSeverities[item.GetErrorCode()] = SeverityFromString( aJson[key] );
400 }
401 }, {} ) );
402
403 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "drc_exclusions",
404 [&]() -> nlohmann::json
405 {
406 nlohmann::json js = nlohmann::json::array();
407
408 for( const DRC_EXCLUSION& exclusion : m_DrcExclusions )
409 js.push_back( exclusion );
410
411 return js;
412 },
413 [&]( const nlohmann::json& aObj )
414 {
415 m_DrcExclusions.clear();
416
417 if( !aObj.is_array() )
418 return;
419
420 for( const nlohmann::json& entry : aObj )
421 {
422 if( entry.is_object() )
423 {
424 DRC_EXCLUSION exclusion = entry.get<DRC_EXCLUSION>();
425
426 if( !exclusion.GetSortKey().empty() )
427 m_DrcExclusions.insert( exclusion );
428 }
429 }
430 },
431 {} ) );
432
433 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "track_widths",
434 [&]() -> nlohmann::json
435 {
436 nlohmann::json js = nlohmann::json::array();
437
438 for( const int& width : m_TrackWidthList )
439 js.push_back( pcbIUScale.IUTomm( width ) );
440
441 return js;
442 },
443 [&]( const nlohmann::json& aJson )
444 {
445 if( !aJson.is_array() )
446 return;
447
448 m_TrackWidthList.clear();
449
450 for( const nlohmann::json& entry : aJson )
451 {
452 if( entry.empty() )
453 continue;
454
455 m_TrackWidthList.emplace_back( pcbIUScale.mmToIU( entry.get<double>() ) );
456 }
457 },
458 {} ) );
459
460 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "via_dimensions",
461 [&]() -> nlohmann::json
462 {
463 nlohmann::json js = nlohmann::json::array();
464
465 for( const auto& via : m_ViasDimensionsList )
466 {
467 nlohmann::json entry = {};
468
469 entry["diameter"] = pcbIUScale.IUTomm( via.m_Diameter );
470 entry["drill"] = pcbIUScale.IUTomm( via.m_Drill );
471
472 js.push_back( entry );
473 }
474
475 return js;
476 },
477 [&]( const nlohmann::json& aObj )
478 {
479 if( !aObj.is_array() )
480 return;
481
482 m_ViasDimensionsList.clear();
483
484 for( const nlohmann::json& entry : aObj )
485 {
486 if( entry.empty() || !entry.is_object() )
487 continue;
488
489 if( !entry.contains( "diameter" ) || !entry.contains( "drill" ) )
490 continue;
491
492 int diameter = pcbIUScale.mmToIU( entry["diameter"].get<double>() );
493 int drill = pcbIUScale.mmToIU( entry["drill"].get<double>() );
494
495 m_ViasDimensionsList.emplace_back( VIA_DIMENSION( diameter, drill ) );
496 }
497 },
498 {} ) );
499
500 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
501 "via_stack_presets",
502 [&]() -> nlohmann::json
503 {
504 nlohmann::json js = nlohmann::json::array();
505
506 for( const VIA_STACK_PRESET& preset : m_ViaStackPresets )
507 {
508 nlohmann::json entry = {};
509
510 entry["name"] = preset.m_Name.ToUTF8();
511 entry["start_layer"] = LSET::Name( preset.m_StartLayer );
512 entry["end_layer"] = LSET::Name( preset.m_EndLayer );
513 entry["staggered"] = preset.m_Staggered;
514 entry["via_size"] = pcbIUScale.IUTomm( preset.m_ViaSize );
515 entry["via_drill"] = pcbIUScale.IUTomm( preset.m_ViaDrill );
516 entry["use_netclass"] = preset.m_UseNetclass;
517 entry["filled"] = preset.m_Filled;
518 entry["capped"] = preset.m_Capped;
519 entry["pitch"] = pcbIUScale.IUTomm( preset.m_Pitch );
520
521 js.push_back( entry );
522 }
523
524 return js;
525 },
526 [&]( const nlohmann::json& aObj )
527 {
528 if( !aObj.is_array() )
529 return;
530
531 m_ViaStackPresets.clear();
532
533 // An odd or non-copper layer from a hand-edited file would make every
534 // LAYER_RANGE built from the preset throw or never terminate.
535 auto copperLayer = []( const nlohmann::json& aEntry, const char* aKey,
536 PCB_LAYER_ID aFallback ) -> PCB_LAYER_ID
537 {
538 if( !aEntry.contains( aKey ) || !aEntry[aKey].is_string() )
539 return aFallback;
540
541 wxString name = wxString::FromUTF8( aEntry[aKey].get<std::string>() );
542 int layer = LSET::NameToLayer( name );
543
544 if( layer >= 0 && layer < PCB_LAYER_ID_COUNT && !( layer & 1 ) && IsCopperLayer( layer ) )
545 return ToLAYER_ID( layer );
546
547 return aFallback;
548 };
549
550 auto boolOr = []( const nlohmann::json& aEntry, const char* aKey, bool aFallback )
551 {
552 return aEntry.contains( aKey ) && aEntry[aKey].is_boolean() ? aEntry[aKey].get<bool>() : aFallback;
553 };
554
555 auto mmOr = []( const nlohmann::json& aEntry, const char* aKey )
556 {
557 if( !aEntry.contains( aKey ) || !aEntry[aKey].is_number() )
558 return 0;
559
560 double mm = aEntry[aKey].get<double>();
561
562 if( mm < 0.0 || mm > pcbIUScale.IUTomm( std::numeric_limits<int>::max() ) )
563 return 0;
564
565 return pcbIUScale.mmToIU( mm );
566 };
567
568 // Bound in mm, before the conversion to IU, because an absurd hand-edited
569 // value overflows int on the way in and lands past the limit as a negative
570 auto boundedMmOr = []( const nlohmann::json& aEntry, const char* aKey, double aMaxMM )
571 {
572 if( !aEntry.contains( aKey ) || !aEntry[aKey].is_number() )
573 return 0;
574
575 return pcbIUScale.mmToIU( std::clamp( aEntry[aKey].get<double>(), 0.0, aMaxMM ) );
576 };
577
578 for( const nlohmann::json& entry : aObj )
579 {
580 if( entry.empty() || !entry.is_object() || !entry.contains( "name" ) || !entry["name"].is_string() )
581 {
582 continue;
583 }
584
585 VIA_STACK_PRESET preset;
586
587 preset.m_Name = wxString::FromUTF8( entry["name"].get<std::string>() );
588 preset.m_StartLayer = copperLayer( entry, "start_layer", F_Cu );
589 preset.m_EndLayer = copperLayer( entry, "end_layer", In1_Cu );
590 preset.m_Staggered = boolOr( entry, "staggered", false );
591 preset.m_ViaSize = mmOr( entry, "via_size" );
592 preset.m_ViaDrill = mmOr( entry, "via_drill" );
593 preset.m_UseNetclass = boolOr( entry, "use_netclass", false );
594 preset.m_Filled = boolOr( entry, "filled", true );
595 preset.m_Capped = boolOr( entry, "capped", false );
596 preset.m_Pitch = boundedMmOr( entry, "pitch", MAX_MICROVIA_STACK_PITCH_MM );
597
598 // Presets are referenced by name, so a duplicate would be ambiguous.
599 auto sameName = [&]( const VIA_STACK_PRESET& aOther )
600 {
601 return aOther.m_Name.CmpNoCase( preset.m_Name ) == 0;
602 };
603
604 if( std::none_of( m_ViaStackPresets.begin(), m_ViaStackPresets.end(), sameName ) )
605 m_ViaStackPresets.push_back( preset );
606 }
607 },
608 {} ) );
609
610 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "diff_pair_dimensions",
611 [&]() -> nlohmann::json
612 {
613 nlohmann::json js = nlohmann::json::array();
614
615 for( const auto& pair : m_DiffPairDimensionsList )
616 {
617 nlohmann::json entry = {};
618
619 entry["width"] = pcbIUScale.IUTomm( pair.m_Width );
620 entry["gap"] = pcbIUScale.IUTomm( pair.m_Gap );
621 entry["via_gap"] = pcbIUScale.IUTomm( pair.m_ViaGap );
622
623 js.push_back( entry );
624 }
625
626 return js;
627 },
628 [&]( const nlohmann::json& aObj )
629 {
630 if( !aObj.is_array() )
631 return;
632
634
635 for( const nlohmann::json& entry : aObj )
636 {
637 if( entry.empty() || !entry.is_object() )
638 continue;
639
640 if( !entry.contains( "width" )
641 || !entry.contains( "gap" )
642 || !entry.contains( "via_gap" ) )
643 {
644 continue;
645 }
646
647 int width = pcbIUScale.mmToIU( entry["width"].get<double>() );
648 int gap = pcbIUScale.mmToIU( entry["gap"].get<double>() );
649 int via_gap = pcbIUScale.mmToIU( entry["via_gap"].get<double>() );
650
651 m_DiffPairDimensionsList.emplace_back( DIFF_PAIR_DIMENSION( width, gap, via_gap ) );
652 }
653 },
654 {} ) );
655
656 // Handle options for teardrops (targets and some others):
657 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "teardrop_options",
658 [&]() -> nlohmann::json
659 {
660 nlohmann::json js = nlohmann::json::array();
661 nlohmann::json entry = {};
662
663 entry["td_onvia"] = m_TeardropParamsList.m_TargetVias;
664 entry["td_onpthpad"] = m_TeardropParamsList.m_TargetPTHPads;
665 entry["td_onsmdpad"] = m_TeardropParamsList.m_TargetSMDPads;
666 entry["td_ontrackend"] = m_TeardropParamsList.m_TargetTrack2Track;
667 entry["td_onroundshapesonly"] = m_TeardropParamsList.m_UseRoundShapesOnly;
668
669 js.push_back( entry );
670
671 return js;
672 },
673 [&]( const nlohmann::json& aObj )
674 {
675 if( !aObj.is_array() )
676 return;
677
678 for( const nlohmann::json& entry : aObj )
679 {
680 if( entry.empty() || !entry.is_object() )
681 continue;
682
683 if( entry.contains( "td_onvia" ) )
684 m_TeardropParamsList.m_TargetVias = entry["td_onvia"].get<bool>();
685
686 if( entry.contains( "td_onpthpad" ) )
687 m_TeardropParamsList.m_TargetPTHPads = entry["td_onpthpad"].get<bool>();
688
689 if( entry.contains( "td_onsmdpad" ) )
690 m_TeardropParamsList.m_TargetSMDPads = entry["td_onsmdpad"].get<bool>();
691
692 if( entry.contains( "td_ontrackend" ) )
693 m_TeardropParamsList.m_TargetTrack2Track = entry["td_ontrackend"].get<bool>();
694
695 if( entry.contains( "td_onroundshapesonly" ) )
696 m_TeardropParamsList.m_UseRoundShapesOnly = entry["td_onroundshapesonly"].get<bool>();
697
698 // Legacy settings
699 for( int ii = 0; ii < 3; ++ii )
700 {
701 TEARDROP_PARAMETERS* td_prm = m_TeardropParamsList.GetParameters( (TARGET_TD)ii );
702
703 if( entry.contains( "td_allow_use_two_tracks" ) )
704 td_prm->m_AllowUseTwoTracks = entry["td_allow_use_two_tracks"].get<bool>();
705
706 if( entry.contains( "td_curve_segcount" ) )
707 {
708 if( entry["td_curve_segcount"].get<int>() > 0 )
709 td_prm->m_CurvedEdges = true;
710 }
711
712 if( entry.contains( "td_on_pad_in_zone" ) )
713 td_prm->m_TdOnPadsInZones = entry["td_on_pad_in_zone"].get<bool>();
714 }
715 }
716 },
717 {} ) );
718
719 // Handle parameters (sizes, shape) for each type of teardrop:
720 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "teardrop_parameters",
721 [&]() -> nlohmann::json
722 {
723 nlohmann::json js = nlohmann::json::array();
724
725 for( size_t ii = 0; ii < m_TeardropParamsList.GetParametersCount(); ii++ )
726 {
727 nlohmann::json entry = {};
728 TEARDROP_PARAMETERS* td_prm = m_TeardropParamsList.GetParameters( (TARGET_TD)ii );
729
730 entry["td_target_name"] = GetTeardropTargetCanonicalName( (TARGET_TD)ii );
731 entry["td_enabled"] = td_prm->m_Enabled;
732 entry["td_maxlen"] = pcbIUScale.IUTomm( td_prm->m_TdMaxLen );
733 entry["td_maxheight"] = pcbIUScale.IUTomm( td_prm->m_TdMaxWidth );
734 entry["td_length_ratio"] = td_prm->m_BestLengthRatio;
735 entry["td_height_ratio"] = td_prm->m_BestWidthRatio;
736 entry["td_curve_segcount"] = td_prm->m_CurvedEdges ? 1 : 0;
737 entry["td_width_to_size_filter_ratio"] = td_prm->m_WidthtoSizeFilterRatio;
738 entry["td_allow_use_two_tracks"] = td_prm->m_AllowUseTwoTracks;
739 entry["td_on_pad_in_zone"] = td_prm->m_TdOnPadsInZones;
740
741 js.push_back( entry );
742 }
743
744 return js;
745 },
746 [&]( const nlohmann::json& aObj )
747 {
748 if( !aObj.is_array() )
749 return;
750
751 for( const nlohmann::json& entry : aObj )
752 {
753 if( entry.empty() || !entry.is_object() )
754 continue;
755
756 if( !entry.contains( "td_target_name" ) )
757 continue;
758
759 int idx = GetTeardropTargetTypeFromCanonicalName( entry["td_target_name"].get<std::string>() );
760
761 if( idx >= 0 && idx < 3 )
762 {
763 TEARDROP_PARAMETERS* td_prm = m_TeardropParamsList.GetParameters( (TARGET_TD)idx );
764
765 // Pads and vias carry their enable in the board file; this one has
766 // nowhere else to live.
767 if( entry.contains( "td_enabled" ) )
768 td_prm->m_Enabled = entry["td_enabled"].get<bool>();
769
770 if( entry.contains( "td_maxlen" ) )
771 td_prm->m_TdMaxLen = pcbIUScale.mmToIU( entry["td_maxlen"].get<double>() );
772
773 if( entry.contains( "td_maxheight" ) )
774 td_prm->m_TdMaxWidth = pcbIUScale.mmToIU( entry["td_maxheight"].get<double>() );
775
776 if( entry.contains( "td_length_ratio" ) )
777 td_prm->m_BestLengthRatio = entry["td_length_ratio"].get<double>();
778
779 if( entry.contains( "td_height_ratio" ) )
780 td_prm->m_BestWidthRatio = entry["td_height_ratio"].get<double>();
781
782 if( entry.contains( "td_curve_segcount" ) )
783 {
784 if( entry["td_curve_segcount"].get<int>() > 0 )
785 td_prm->m_CurvedEdges = true;
786 }
787
788 if( entry.contains( "td_width_to_size_filter_ratio" ) )
789 td_prm->m_WidthtoSizeFilterRatio = entry["td_width_to_size_filter_ratio"].get<double>();
790
791 if( entry.contains( "td_allow_use_two_tracks" ) )
792 td_prm->m_AllowUseTwoTracks = entry["td_allow_use_two_tracks"].get<bool>();
793
794 if( entry.contains( "td_on_pad_in_zone" ) )
795 td_prm->m_TdOnPadsInZones = entry["td_on_pad_in_zone"].get<bool>();
796 }
797 }
798 },
799 {} ) );
800
801 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "tuning_pattern_settings",
802 [&]() -> nlohmann::json
803 {
804 nlohmann::json js = {};
805
806 auto make_settings =
807 []( const PNS::MEANDER_SETTINGS& aSettings )
808 {
809 nlohmann::json entry = {};
810
811 entry["min_amplitude"] = pcbIUScale.IUTomm( aSettings.m_minAmplitude );
812 entry["max_amplitude"] = pcbIUScale.IUTomm( aSettings.m_maxAmplitude );
813 entry["spacing"] = pcbIUScale.IUTomm( aSettings.m_spacing );
814 entry["corner_style"] = aSettings.m_cornerStyle == PNS::MEANDER_STYLE_CHAMFER ? 0 : 1;
815 entry["corner_radius_percentage"] = aSettings.m_cornerRadiusPercentage;
816 entry["single_sided"] = aSettings.m_singleSided;
817
818 return entry;
819 };
820
821 js["single_track_defaults"] = make_settings( m_SingleTrackMeanderSettings );
822 js["diff_pair_defaults"] = make_settings( m_DiffPairMeanderSettings );
823 js["diff_pair_skew_defaults"] = make_settings( m_SkewMeanderSettings );
824
825 return js;
826 },
827 [&]( const nlohmann::json& aObj )
828 {
829 auto read_settings =
830 []( const nlohmann::json& entry ) -> PNS::MEANDER_SETTINGS
831 {
832 PNS::MEANDER_SETTINGS settings;
833
834 if( entry.contains( "min_amplitude" ) )
835 settings.m_minAmplitude = pcbIUScale.mmToIU( entry["min_amplitude"].get<double>() );
836
837 if( entry.contains( "max_amplitude" ) )
838 settings.m_maxAmplitude = pcbIUScale.mmToIU( entry["max_amplitude"].get<double>() );
839
840 if( entry.contains( "spacing" ) )
841 settings.m_spacing = pcbIUScale.mmToIU( entry["spacing"].get<double>() );
842
843 if( entry.contains( "corner_style" ) )
844 {
845 settings.m_cornerStyle = entry["corner_style"] == 0 ? PNS::MEANDER_STYLE_CHAMFER
847 }
848
849 if( entry.contains( "corner_radius_percentage" ) )
850 settings.m_cornerRadiusPercentage = entry["corner_radius_percentage"].get<int>();
851
852 if( entry.contains( "single_sided" ) )
853 settings.m_singleSided = entry["single_sided"].get<bool>();
854
855 return settings;
856 };
857
858 if( aObj.contains( "single_track_defaults" ) )
859 m_SingleTrackMeanderSettings = read_settings( aObj["single_track_defaults"] );
860
861 if( aObj.contains( "diff_pair_defaults" ) )
862 m_DiffPairMeanderSettings = read_settings( aObj["diff_pair_defaults"] );
863
864 if( aObj.contains( "diff_pair_skew_defaults" ) )
865 m_SkewMeanderSettings = read_settings( aObj["diff_pair_skew_defaults"] );
866 },
867 {} ) );
868
869 int minTextSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
870 int maxTextSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
871 int minStroke = 1;
872 int maxStroke = pcbIUScale.mmToIU( 100 );
873
874 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_line_width",
876 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
877
878 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_v",
880 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
881
882 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_h",
884 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
885
886 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_thickness",
888 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
889
890 m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_italic",
891 &m_TextItalic[LAYER_CLASS_SILK], false ) );
892
893 m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_upright",
894 &m_TextUpright[ LAYER_CLASS_SILK ], true ) );
895
896 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_line_width",
898 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
899
900 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_v",
902 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
903
904 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_h",
906 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
907
908 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_thickness",
910 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
911
912 m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_italic",
913 &m_TextItalic[LAYER_CLASS_COPPER], false ) );
914
915 m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_upright",
917
918 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.board_outline_line_width",
920 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
921
922 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.courtyard_line_width",
924 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
925
926 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_line_width",
928 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
929
930 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_v",
932 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
933
934 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_h",
936 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
937
938 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_thickness",
940 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
941
942 m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_italic",
943 &m_TextItalic[LAYER_CLASS_FAB], false ) );
944
945 m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_upright",
946 &m_TextUpright[LAYER_CLASS_FAB], true ) );
947
948 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_line_width",
950 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
951
952 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_v",
954 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
955
956 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_h",
958 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
959
960 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_thickness",
962 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
963
964 m_params.emplace_back( new PARAM<bool>( "defaults.other_text_italic",
965 &m_TextItalic[LAYER_CLASS_OTHERS], false ) );
966
967 m_params.emplace_back( new PARAM<bool>( "defaults.other_text_upright",
969
970 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_MODE>( "defaults.dimension_units",
973
974 m_params.emplace_back( new PARAM_ENUM<DIM_PRECISION>( "defaults.dimension_precision",
976
977 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_FORMAT>( "defaults.dimensions.units_format",
980
981 m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.suppress_zeroes",
982 &m_DimensionSuppressZeroes, true ) );
983
984 // NOTE: excluding DIM_TEXT_POSITION::MANUAL from the valid range here
985 m_params.emplace_back( new PARAM_ENUM<DIM_TEXT_POSITION>( "defaults.dimensions.text_position",
988
989 m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.keep_text_aligned",
991
992 m_params.emplace_back( new PARAM<int>( "defaults.dimensions.arrow_length",
995
996 m_params.emplace_back( new PARAM<int>( "defaults.dimensions.extension_offset",
999
1000 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_fields",
1001 &m_StyleFPFields, false ) );
1002 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_text",
1003 &m_StyleFPText, false ) );
1004 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_shapes",
1005 &m_StyleFPShapes, false ) );
1006 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_dimensions",
1007 &m_StyleFPDimensions, false ) );
1008 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_barcodes",
1009 &m_StyleFPBarcodes, false ) );
1010
1011 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.zones.min_clearance",
1012 &m_defaultZoneSettings.m_ZoneClearance, pcbIUScale.mmToIU( ZONE_CLEARANCE_MM ),
1013 pcbIUScale.mmToIU( 0.0 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
1014
1015 m_params.emplace_back( new PARAM_SCALED<int>(
1016 "defaults.zones.min_thickness", &m_defaultZoneSettings.m_ZoneMinThickness,
1018 pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
1019
1020 m_params.emplace_back( new PARAM_ENUM<ZONE_FILL_MODE>( "defaults.zones.fill_mode",
1024
1025 m_params.emplace_back(
1026 new PARAM_SCALED<int>( "defaults.zones.hatch_thickness", &m_defaultZoneSettings.m_HatchThickness,
1027 std::max( pcbIUScale.mmToIU( ZONE_THICKNESS_MM ) * 4, pcbIUScale.mmToIU( 1.0 ) ),
1028 pcbIUScale.mmToIU( 0.0 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
1029
1030 m_params.emplace_back(
1031 new PARAM_SCALED<int>( "defaults.zones.hatch_gap", &m_defaultZoneSettings.m_HatchGap,
1032 std::max( pcbIUScale.mmToIU( ZONE_THICKNESS_MM ) * 6, pcbIUScale.mmToIU( 1.5 ) ),
1033 pcbIUScale.mmToIU( 0.0 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
1034
1035 m_params.emplace_back( new PARAM_LAMBDA<double>(
1036 "defaults.zones.hatch_orientation",
1037 [&]() -> double
1038 {
1039 return m_defaultZoneSettings.m_HatchOrientation.AsDegrees();
1040 },
1041 [&]( double aVal )
1042 {
1043 m_defaultZoneSettings.m_HatchOrientation = EDA_ANGLE( aVal, DEGREES_T );
1044 },
1045 0.0 ) );
1046
1047 m_params.emplace_back( new PARAM<int>( "defaults.zones.hatch_smoothing_level",
1048 &m_defaultZoneSettings.m_HatchSmoothingLevel, 0, 0, 3 ) );
1049
1050 m_params.emplace_back( new PARAM<double>( "defaults.zones.hatch_smoothing_value",
1051 &m_defaultZoneSettings.m_HatchSmoothingValue, 0.1, 0.0, 1.0 ) );
1052
1054 "defaults.zones.border_display_style", &m_defaultZoneSettings.m_ZoneBorderDisplayStyle,
1057
1058 m_params.emplace_back( new PARAM_SCALED<int>(
1059 "defaults.zones.border_hatch_pitch", &m_defaultZoneSettings.m_BorderHatchPitch,
1061 pcbIUScale.mmToIU( ZONE_BORDER_HATCH_MAXDIST_MM ), pcbIUScale.MM_PER_IU ) );
1062
1063 m_params.emplace_back(
1064 new PARAM_SCALED<long>( "defaults.zones.thermal_relief_gap", &m_defaultZoneSettings.m_ThermalReliefGap,
1065 pcbIUScale.mmToIU( ZONE_THERMAL_RELIEF_GAP_MM ), pcbIUScale.mmToIU( 0.0 ),
1066 pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
1067
1068 m_params.emplace_back( new PARAM_SCALED<long>(
1069 "defaults.zones.thermal_relief_spoke_width", &m_defaultZoneSettings.m_ThermalReliefSpokeWidth,
1071 pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
1072
1073 m_params.emplace_back( new PARAM_LAMBDA<int>(
1074 "defaults.zones.pad_connection",
1075 [&]() -> int
1076 {
1077 return static_cast<int>( m_defaultZoneSettings.GetPadConnection() );
1078 },
1079 [&]( int aVal )
1080 {
1081 m_defaultZoneSettings.SetPadConnection( static_cast<ZONE_CONNECTION>( aVal ) );
1082 },
1083 static_cast<int>( ZONE_CONNECTION::THERMAL ) ) );
1084
1085 m_params.emplace_back( new PARAM_LAMBDA<int>(
1086 "defaults.zones.corner_smoothing",
1087 [&]() -> int
1088 {
1089 return static_cast<int>( m_defaultZoneSettings.GetCornerSmoothingType() );
1090 },
1091 [&]( int aVal )
1092 {
1093 m_defaultZoneSettings.SetCornerSmoothingType(
1094 magic_enum::enum_cast<ZONE_SETTINGS::CORNER_SMOOTHING>( aVal ).value_or(
1096 },
1097 static_cast<int>( ZONE_SETTINGS::CORNER_SMOOTHING::NO_SMOOTHING ) ) );
1098
1099 m_params.emplace_back( new PARAM_LAMBDA<double>(
1100 "defaults.zones.corner_radius",
1101 [&]() -> double
1102 {
1103 return pcbIUScale.IUTomm( m_defaultZoneSettings.GetCornerRadius() );
1104 },
1105 [&]( double aVal )
1106 {
1107 m_defaultZoneSettings.SetCornerRadius( pcbIUScale.mmToIU( aVal ) );
1108 },
1109 0.0 ) );
1110
1111 m_params.emplace_back( new PARAM_LAMBDA<int>(
1112 "defaults.zones.remove_islands",
1113 [&]() -> int
1114 {
1115 return static_cast<int>( m_defaultZoneSettings.GetIslandRemovalMode() );
1116 },
1117 [&]( int aVal )
1118 {
1119 m_defaultZoneSettings.SetIslandRemovalMode( static_cast<ISLAND_REMOVAL_MODE>( aVal ) );
1120 },
1121 static_cast<int>( ISLAND_REMOVAL_MODE::ALWAYS ) ) );
1122
1123 m_params.emplace_back( new PARAM_LAMBDA<double>(
1124 "defaults.zones.min_island_area",
1125 [&]() -> double
1126 {
1127 const double iuPerMm2 = pcbIUScale.IU_PER_MM * pcbIUScale.IU_PER_MM;
1128 return static_cast<double>( m_defaultZoneSettings.GetMinIslandArea() ) / iuPerMm2;
1129 },
1130 [&]( double aVal )
1131 {
1132 const double iuPerMm2 = pcbIUScale.IU_PER_MM * pcbIUScale.IU_PER_MM;
1133 m_defaultZoneSettings.SetMinIslandArea( static_cast<long long int>( aVal * iuPerMm2 ) );
1134 },
1135 10.0 ) );
1136
1137 m_params.emplace_back( new PARAM_SCALED<int>( "rules.max_error",
1139 pcbIUScale.mmToIU( 0.0001 ), pcbIUScale.mmToIU( 1.0 ), pcbIUScale.MM_PER_IU ) );
1140
1141 m_params.emplace_back( new PARAM_SCALED<int>( "rules.solder_mask_to_copper_clearance",
1143 pcbIUScale.mmToIU( 0.0 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
1144
1145 m_params.emplace_back( new PARAM<bool>( "zones_allow_external_fillets",
1146 &m_ZoneKeepExternalFillets, false ) );
1147
1148
1150
1151 registerMigration( 1, 2,
1152 [&]() -> bool
1153 {
1154 // Schema 1 to 2: move mask and paste margin settings back to board.
1155 // The parameters are removed, so we just have to manually load them here and
1156 // they will get saved with the board
1157 if( std::optional<double> optval = Get<double>( "rules.solder_mask_clearance" ) )
1158 m_SolderMaskExpansion = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
1159
1160 if( std::optional<double> optval = Get<double>( "rules.solder_mask_min_width" ) )
1161 m_SolderMaskMinWidth = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
1162
1163 if( std::optional<double> optval = Get<double>( "rules.solder_paste_clearance" ) )
1164 m_SolderPasteMargin = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
1165
1166 if( std::optional<double> optval = Get<double>( "rules.solder_paste_margin_ratio" ) )
1167 m_SolderPasteMarginRatio = *optval;
1168
1169 try
1170 {
1171 At( "rules" ).erase( "solder_mask_clearance" );
1172 At( "rules" ).erase( "solder_mask_min_width" );
1173 At( "rules" ).erase( "solder_paste_clearance" );
1174 At( "rules" ).erase( "solder_paste_margin_ratio" );
1175 }
1176 catch( ... )
1177 {}
1178
1179 return true;
1180 } );
1181
1183
1185}
1186
1187
1189{
1190 if( m_parent )
1191 {
1192 m_parent->ReleaseNestedSettings( this );
1193 m_parent = nullptr;
1194 }
1195}
1196
1197
1198// Detached so a discarded copy cannot flush its values into the project file
1200 NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, nullptr, aOther.m_path )
1201{
1202 initFromOther( aOther );
1203}
1204
1205
1207{
1208 initFromOther( aOther );
1209 return *this;
1210}
1211
1212
1214{
1215 // Copy of NESTED_SETTINGS around is not allowed, so let's just update the params.
1225 m_MinConn = aOther.m_MinConn;
1242 m_MaxError = aOther.m_MaxError;
1255 m_CapVias = aOther.m_CapVias;
1256 m_FillVias = aOther.m_FillVias;
1259
1260 std::copy( std::begin( aOther.m_LineThickness ), std::end( aOther.m_LineThickness ),
1261 std::begin( m_LineThickness ) );
1262
1263 std::copy( std::begin( aOther.m_TextSize ), std::end( aOther.m_TextSize ),
1264 std::begin( m_TextSize ) );
1265
1266 std::copy( std::begin( aOther.m_TextThickness ), std::end( aOther.m_TextThickness ),
1267 std::begin( m_TextThickness ) );
1268
1269 std::copy( std::begin( aOther.m_TextItalic ), std::end( aOther.m_TextItalic ),
1270 std::begin( m_TextItalic ) );
1271
1272 std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ),
1273 std::begin( m_TextUpright ) );
1274
1283
1284 m_auxOrigin = aOther.m_auxOrigin;
1285 m_gridOrigin = aOther.m_gridOrigin;
1286 m_HasStackup = aOther.m_HasStackup;
1290 m_BomPresets = aOther.m_BomPresets;
1293
1308 m_stackup = aOther.m_stackup;
1311
1317}
1318
1319
1321{
1322 if( m_TrackWidthList != aOther.m_TrackWidthList ) return false;
1323 if( m_ViasDimensionsList != aOther.m_ViasDimensionsList ) return false;
1324 if( m_ViaStackPresets != aOther.m_ViaStackPresets )
1325 return false;
1326 if( m_DiffPairDimensionsList != aOther.m_DiffPairDimensionsList ) return false;
1327 if( m_CurrentViaType != aOther.m_CurrentViaType ) return false;
1328 if( m_UseConnectedTrackWidth != aOther.m_UseConnectedTrackWidth ) return false;
1329 if( m_TempOverrideTrackWidth != aOther.m_TempOverrideTrackWidth ) return false;
1330 if( m_MinClearance != aOther.m_MinClearance ) return false;
1331 if( m_MinGrooveWidth != aOther.m_MinGrooveWidth ) return false;
1332 if( m_MinConn != aOther.m_MinConn ) return false;
1333 if( m_TrackMinWidth != aOther.m_TrackMinWidth ) return false;
1334 if( m_ViasMinAnnularWidth != aOther.m_ViasMinAnnularWidth ) return false;
1335 if( m_ViasMinSize != aOther.m_ViasMinSize ) return false;
1336 if( m_MinThroughDrill != aOther.m_MinThroughDrill ) return false;
1338 return false;
1339 if( m_MicroViasMinDrill != aOther.m_MicroViasMinDrill ) return false;
1340 if( m_CopperEdgeClearance != aOther.m_CopperEdgeClearance ) return false;
1341 if( m_HoleClearance != aOther.m_HoleClearance ) return false;
1342 if( m_HoleToHoleMin != aOther.m_HoleToHoleMin ) return false;
1343 if( m_SilkClearance != aOther.m_SilkClearance ) return false;
1344 if( m_MinResolvedSpokes != aOther.m_MinResolvedSpokes ) return false;
1345 if( m_MinSilkTextHeight != aOther.m_MinSilkTextHeight ) return false;
1346 if( m_MinSilkLineWidth != aOther.m_MinSilkLineWidth ) return false;
1347 if( m_DRCSeverities != aOther.m_DRCSeverities ) return false;
1348 if( m_DrcExclusions != aOther.m_DrcExclusions ) return false;
1349 if( m_ZoneKeepExternalFillets != aOther.m_ZoneKeepExternalFillets ) return false;
1350 if( m_MaxError != aOther.m_MaxError ) return false;
1351 if( m_SolderMaskExpansion != aOther.m_SolderMaskExpansion ) return false;
1352 if( m_SolderMaskMinWidth != aOther.m_SolderMaskMinWidth ) return false;
1354 if( m_SolderPasteMargin != aOther.m_SolderPasteMargin ) return false;
1355 if( m_SolderPasteMarginRatio != aOther.m_SolderPasteMarginRatio ) return false;
1357 if( m_TentViasFront != aOther.m_TentViasFront ) return false;
1358 if( m_TentViasBack != aOther.m_TentViasBack ) return false;
1359 if( m_CoverViasFront != aOther.m_CoverViasFront ) return false;
1360 if( m_CoverViasBack != aOther.m_CoverViasBack ) return false;
1361 if( m_PlugViasFront != aOther.m_PlugViasFront ) return false;
1362 if( m_PlugViasBack != aOther.m_PlugViasBack ) return false;
1363 if( m_CapVias != aOther.m_CapVias ) return false;
1364 if( m_FillVias != aOther.m_FillVias ) return false;
1365 if( m_DefaultFPTextItems != aOther.m_DefaultFPTextItems ) return false;
1366 if( m_UserLayerNames != aOther.m_UserLayerNames ) return false;
1367
1368 if( !std::equal( std::begin( m_LineThickness ), std::end( m_LineThickness ),
1369 std::begin( aOther.m_LineThickness ) ) )
1370 return false;
1371
1372 if( !std::equal( std::begin( m_TextSize ), std::end( m_TextSize ),
1373 std::begin( aOther.m_TextSize ) ) )
1374 return false;
1375
1376 if( !std::equal( std::begin( m_TextThickness ), std::end( m_TextThickness ),
1377 std::begin( aOther.m_TextThickness ) ) )
1378 return false;
1379
1380 if( !std::equal( std::begin( m_TextItalic ), std::end( m_TextItalic ),
1381 std::begin( aOther.m_TextItalic ) ) )
1382 return false;
1383
1384 if( !std::equal( std::begin( m_TextUpright ), std::end( m_TextUpright ),
1385 std::begin( aOther.m_TextUpright ) ) )
1386 return false;
1387
1388 if( m_DimensionUnitsMode != aOther.m_DimensionUnitsMode ) return false;
1389 if( m_DimensionPrecision != aOther.m_DimensionPrecision ) return false;
1390 if( m_DimensionUnitsFormat != aOther.m_DimensionUnitsFormat ) return false;
1391 if( m_DimensionSuppressZeroes != aOther.m_DimensionSuppressZeroes ) return false;
1392 if( m_DimensionTextPosition != aOther.m_DimensionTextPosition ) return false;
1393 if( m_DimensionKeepTextAligned != aOther.m_DimensionKeepTextAligned ) return false;
1394 if( m_DimensionArrowLength != aOther.m_DimensionArrowLength ) return false;
1395 if( m_DimensionExtensionOffset != aOther.m_DimensionExtensionOffset ) return false;
1396 if( m_auxOrigin != aOther.m_auxOrigin ) return false;
1397 if( m_gridOrigin != aOther.m_gridOrigin ) return false;
1398 if( m_HasStackup != aOther.m_HasStackup ) return false;
1399 if( m_UseHeightForLengthCalcs != aOther.m_UseHeightForLengthCalcs ) return false;
1400 if( m_BomExportFileName != aOther.m_BomExportFileName ) return false;
1401 if( m_BomSettings != aOther.m_BomSettings ) return false;
1402 if( m_BomPresets != aOther.m_BomPresets ) return false;
1403 if( m_BomFmtSettings != aOther.m_BomFmtSettings ) return false;
1404 if( m_BomFmtPresets != aOther.m_BomFmtPresets ) return false;
1405 if( m_trackWidthIndex != aOther.m_trackWidthIndex ) return false;
1406 if( m_viaSizeIndex != aOther.m_viaSizeIndex ) return false;
1407 if( m_viaStackIndex != aOther.m_viaStackIndex )
1408 return false;
1409 if( m_diffPairIndex != aOther.m_diffPairIndex ) return false;
1410 if( m_useCustomTrackVia != aOther.m_useCustomTrackVia ) return false;
1411 if( m_customTrackWidth != aOther.m_customTrackWidth ) return false;
1412 if( m_customViaSize != aOther.m_customViaSize ) return false;
1413 if( m_useCustomDiffPair != aOther.m_useCustomDiffPair ) return false;
1414 if( m_customDiffPair != aOther.m_customDiffPair ) return false;
1415 if( m_copperLayerCount != aOther.m_copperLayerCount ) return false;
1416 if( m_userDefinedLayerCount != aOther.m_userDefinedLayerCount ) return false;
1417 if( m_enabledLayers != aOther.m_enabledLayers ) return false;
1418 if( m_boardThickness != aOther.m_boardThickness ) return false;
1419 if( m_currentNetClassName != aOther.m_currentNetClassName ) return false;
1420 if( m_stackup != aOther.m_stackup ) return false;
1421 if( *m_NetSettings != *aOther.m_NetSettings ) return false;
1422 if( m_defaultZoneSettings != aOther.m_defaultZoneSettings ) return false;
1423
1424 if( m_StyleFPFields != aOther.m_StyleFPFields ) return false;
1425 if( m_StyleFPText != aOther.m_StyleFPText ) return false;
1426 if( m_StyleFPShapes != aOther.m_StyleFPShapes ) return false;
1427 if( m_StyleFPDimensions != aOther.m_StyleFPDimensions ) return false;
1428 if( m_StyleFPBarcodes != aOther.m_StyleFPBarcodes ) return false;
1429
1430 return true;
1431}
1432
1433
1435{
1453 std::string units_ptr( "defaults.dimension_units" );
1454 std::string precision_ptr( "defaults.dimension_precision" );
1455
1456 if( !( Contains( units_ptr )
1457 && Contains( precision_ptr )
1458 && At( units_ptr ).is_number_integer()
1459 && At( precision_ptr ).is_number_integer() ) )
1460 {
1461 // if either is missing or invalid, migration doesn't make sense
1462 return true;
1463 }
1464
1465 int units = *Get<int>( units_ptr );
1466 int precision = *Get<int>( precision_ptr );
1467
1468 // The enum maps directly to precision if the units is mils
1469 int extraDigits = 0;
1470
1471 switch( units )
1472 {
1473 case 0: extraDigits = 3; break;
1474 case 2: extraDigits = 2; break;
1475 default: break;
1476 }
1477
1478 precision += extraDigits;
1479
1480 Set( precision_ptr, precision );
1481
1482 return true;
1483}
1484
1485
1487{
1488 // Schema 2 to 3: convert DRC exclusions from legacy pipe-delimited strings to ProtoJSON
1489 std::optional<nlohmann::json> opt = Get<nlohmann::json>( "drc_exclusions" );
1490
1491 if( !opt )
1492 return true;
1493
1494 nlohmann::json migrated = nlohmann::json::array();
1495
1496 for( const nlohmann::json& entry : *opt )
1497 {
1498 if( entry.is_object() )
1499 {
1500 migrated.push_back( entry );
1501 }
1502 else if( entry.is_array() && entry.size() > 0 )
1503 {
1504 wxString markerData = entry[0].get<wxString>();
1505 wxString comment = entry.size() > 1 ? entry[1].get<wxString>() : wxString();
1506
1507 DRC_EXCLUSION ex = DRC_EXCLUSION::FromLegacyStrings( markerData, comment );
1508
1509 if( !ex.GetSortKey().empty() )
1510 migrated.push_back( ex );
1511 }
1512 else if( entry.is_string() )
1513 {
1514 DRC_EXCLUSION ex = DRC_EXCLUSION::FromLegacyStrings( entry.get<wxString>(), wxString() );
1515
1516 if( !ex.GetSortKey().empty() )
1517 migrated.push_back( ex );
1518 }
1519 }
1520
1521 Set( "drc_exclusions", migrated );
1522
1523 return true;
1524}
1525
1526
1528{
1529 // Schema 4 renamed text_thickness to line_width, which also checks silkscreen graphics
1530 auto renameKey =
1531 [&]( const std::string& aParent, const std::string& aOld, const std::string& aNew )
1532 {
1533 if( !Contains( aParent ) || !At( aParent ).is_object() )
1534 return;
1535
1536 nlohmann::json& parent = At( aParent );
1537
1538 if( !parent.contains( aOld ) )
1539 return;
1540
1541 // A key already written by a newer build wins
1542 if( !parent.contains( aNew ) )
1543 parent[aNew] = parent[aOld];
1544
1545 parent.erase( aOld );
1546 };
1547
1548 renameKey( "rule_severities", "text_thickness", "line_width" );
1549 renameKey( "rules", "min_text_thickness", "min_silk_line_width" );
1550
1551 return true;
1552}
1553
1554bool BOARD_DESIGN_SETTINGS::LoadFromFile( const wxString& aDirectory )
1555{
1556 bool ret = NESTED_SETTINGS::LoadFromFile( aDirectory );
1557
1558 // A number of things won't have been translated by the PROJECT_FILE migration because of
1559 // descoped objects required to decode this data. So, it will be in the legacy.pcbnew
1560 // section and needs to be pulled out here
1561
1562 PROJECT_FILE* project = dynamic_cast<PROJECT_FILE*>( GetParent() );
1563
1564 if( !project )
1565 return ret;
1566
1567 bool migrated = false;
1568
1569 auto drcName =
1570 []( int aCode ) -> std::string
1571 {
1572 return std::string( DRC_ITEM::Create( aCode )->GetSettingsKey().ToUTF8() );
1573 };
1574
1575 const std::string rs = "rule_severities.";
1576 const std::string no_courtyard_key = "legacy_no_courtyard_defined";
1577 const std::string courtyard_overlap_key = "legacy_courtyards_overlap";
1578
1579 try
1580 {
1581 nlohmann::json& severities =
1582 project->Internals()->at( "/board/design_settings/rule_severities"_json_pointer );
1583
1584 if( severities.contains( no_courtyard_key ) )
1585 {
1586 if( severities[no_courtyard_key].get<bool>() )
1587 Set( rs + drcName( DRCE_MISSING_COURTYARD ), "error" );
1588 else
1589 Set( rs + drcName( DRCE_MISSING_COURTYARD ), "ignore" );
1590
1591 severities.erase( no_courtyard_key );
1592 migrated = true;
1593 }
1594
1595 if( severities.contains( courtyard_overlap_key ) )
1596 {
1597 if( severities[courtyard_overlap_key].get<bool>() )
1598 Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "error" );
1599 else
1600 Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "ignore" );
1601
1602 severities.erase( courtyard_overlap_key );
1603 migrated = true;
1604 }
1605 }
1606 catch( ... )
1607 {
1608 }
1609
1610 if( Contains( "legacy" ) )
1611 {
1612 // This defaults to false for new boards, but version 5.1.x and prior kept the fillets
1613 // so we do the same for legacy boards.
1615
1616 project->At( "legacy" ).erase( "pcbnew" );
1617 }
1618
1619 // Now that we have everything, we need to load again
1620 if( migrated )
1621 Load();
1622
1623 return ret;
1624}
1625
1626
1628{
1629 auto it = m_DRCSeverities.find( aDRCErrorCode );
1630
1631 // If not found, return the default severity for unrecognized error codes.
1632 // As constructed, the default severity for unrecognized error codes is RPT_SEVERITY_ERROR.
1633 wxCHECK_MSG( it != m_DRCSeverities.end(), RPT_SEVERITY_ERROR,
1634 wxString::Format( wxT( "DRC error code %d not found" ), aDRCErrorCode ) );
1635
1636 return it->second;
1637}
1638
1639
1640bool BOARD_DESIGN_SETTINGS::Ignore( int aDRCErrorCode ) const
1641{
1642 return GetSeverity( aDRCErrorCode ) == RPT_SEVERITY_IGNORE;
1643}
1644
1645
1646std::vector<BOARD_DESIGN_SETTINGS::VALIDATION_ERROR>
1647BOARD_DESIGN_SETTINGS::ValidateDesignRules( std::optional<EDA_UNITS> aUnits ) const
1648{
1649 std::vector<VALIDATION_ERROR> errors;
1650 EDA_UNITS units = aUnits.value_or( EDA_UNITS::MM );
1651
1652 auto addRangeError =
1653 [&]( const wxString& aField, int aValue, int aMin, int aMax )
1654 {
1655 if( aValue < aMin || aValue > aMax )
1656 {
1657 wxString min = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, aMin, true );
1658 wxString max = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, aMax, true );
1659
1660 errors.push_back( { aField,
1661 wxString::Format( _( "Value must be between %s and %s." ), min, max ) } );
1662 }
1663 };
1664
1665 auto addRatioRangeError =
1666 [&]( const wxString& aField, double aValue, double aMin, double aMax )
1667 {
1668 if( !std::isfinite( aValue ) || aValue < aMin || aValue > aMax )
1669 {
1670 errors.push_back( { aField,
1671 wxString::Format( _( "Value must be between %.3f and %.3f." ), aMin, aMax ) } );
1672 }
1673 };
1674
1675 addRangeError( wxS( "min_clearance" ), m_MinClearance,
1676 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ) );
1677 addRangeError( wxS( "min_connection" ), m_MinConn,
1678 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ) );
1679 addRangeError( wxS( "min_track_width" ), m_TrackMinWidth,
1680 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ) );
1681 addRangeError( wxS( "min_via_annular_width" ), m_ViasMinAnnularWidth,
1682 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ) );
1683 addRangeError( wxS( "min_via_diameter" ), m_ViasMinSize,
1684 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ) );
1685 addRangeError( wxS( "min_through_hole_diameter" ), m_MinThroughDrill,
1686 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ) );
1687 addRangeError( wxS( "min_microvia_diameter" ), m_MicroViasMinSize,
1688 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 10.0 ) );
1689 addRangeError( wxS( "min_microvia_drill" ), m_MicroViasMinDrill,
1690 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 10.0 ) );
1691 addRangeError( wxS( "min_hole_to_hole" ), m_HoleToHoleMin,
1692 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 10.0 ) );
1693 addRangeError( wxS( "min_hole_clearance" ), m_HoleClearance,
1694 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ) );
1695 addRangeError( wxS( "min_silk_clearance" ), m_SilkClearance,
1696 pcbIUScale.mmToIU( -10.0 ), pcbIUScale.mmToIU( 100.0 ) );
1697 addRangeError( wxS( "min_groove_width" ), m_MinGrooveWidth,
1698 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ) );
1699 addRangeError( wxS( "min_text_height" ), m_MinSilkTextHeight,
1700 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ) );
1701 addRangeError( wxS( "min_silk_line_width" ), m_MinSilkLineWidth,
1702 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 25.0 ) );
1703 addRangeError( wxS( "min_copper_edge_clearance" ), m_CopperEdgeClearance,
1704 pcbIUScale.mmToIU( -0.01 ), pcbIUScale.mmToIU( 25.0 ) );
1705
1707 {
1708 errors.push_back( { wxS( "min_resolved_spokes" ),
1709 _( "Value must be between 0 and 99." ) } );
1710 }
1711
1712 addRangeError( wxS( "max_error" ), m_MaxError,
1715
1716 addRangeError( wxS( "solder_mask_expansion" ), m_SolderMaskExpansion,
1717 pcbIUScale.mmToIU( -25.0 ), pcbIUScale.mmToIU( 25.0 ) );
1718 addRangeError( wxS( "solder_mask_min_width" ), m_SolderMaskMinWidth,
1719 pcbIUScale.mmToIU( 0.0 ), pcbIUScale.mmToIU( 25.0 ) );
1720 addRangeError( wxS( "solder_mask_to_copper_clearance" ), m_SolderMaskToCopperClearance,
1721 pcbIUScale.mmToIU( 0.0 ), pcbIUScale.mmToIU( 25.0 ) );
1722 addRangeError( wxS( "solder_paste_margin" ), m_SolderPasteMargin,
1723 pcbIUScale.mmToIU( -25.0 ), pcbIUScale.mmToIU( 25.0 ) );
1724 addRatioRangeError( wxS( "solder_paste_margin_ratio" ), m_SolderPasteMarginRatio,
1725 -1.0, 1.0 );
1726
1727 TEARDROP_PARAMETERS_LIST& teardropParamsList = const_cast<TEARDROP_PARAMETERS_LIST&>( m_TeardropParamsList );
1728
1729 for( size_t ii = 0; ii < teardropParamsList.GetParametersCount(); ++ii )
1730 {
1731 const TEARDROP_PARAMETERS* params = teardropParamsList.GetParameters( static_cast<TARGET_TD>( ii ) );
1732 std::string target = GetTeardropTargetCanonicalName( static_cast<TARGET_TD>( ii ) );
1733
1734 addRatioRangeError( wxString::Format( wxS( "teardrop_parameters[%s].best_length_ratio" ), target ),
1735 params->m_BestLengthRatio, 0.0, 1.0 );
1736 addRatioRangeError( wxString::Format( wxS( "teardrop_parameters[%s].best_width_ratio" ), target ),
1737 params->m_BestWidthRatio, 0.0, 1.0 );
1738 addRatioRangeError( wxString::Format( wxS( "teardrop_parameters[%s].width_to_size_filter_ratio" ), target ),
1739 params->m_WidthtoSizeFilterRatio, 0.0, 1.0 );
1740 }
1741
1742 for( size_t ii = 1; ii < m_DiffPairDimensionsList.size(); ++ii )
1743 {
1744 const DIFF_PAIR_DIMENSION& diffPair = m_DiffPairDimensionsList[ii];
1745
1746 if( diffPair.m_Width > 0 && diffPair.m_Gap <= 0 )
1747 {
1748 errors.push_back( { wxString::Format( wxS( "diff_pair_dimensions_list[%zu].gap" ), ii ),
1749 _( "No differential pair gap defined." ) } );
1750 }
1751 }
1752
1753 for( size_t ii = 1; ii < m_ViasDimensionsList.size(); ++ii )
1754 {
1755 const VIA_DIMENSION& viaDim = m_ViasDimensionsList[ii];
1756
1757 std::optional<int> viaDiameter;
1758 std::optional<int> viaDrill;
1759
1760 if( viaDim.m_Diameter > 0 )
1761 viaDiameter = viaDim.m_Diameter;
1762
1763 if( viaDim.m_Drill > 0 )
1764 viaDrill = viaDim.m_Drill;
1765
1766 if( std::optional<PCB_VIA::VIA_PARAMETER_ERROR> error = PCB_VIA::ValidateViaParameters( viaDiameter,
1767 viaDrill ) )
1768 {
1769 errors.push_back( { wxString::Format( wxS( "via_dimensions_list[%zu]" ), ii ),
1770 error->m_Message } );
1771 }
1772 }
1773
1774 return errors;
1775}
1776
1777
1778std::vector<BOARD_DESIGN_SETTINGS::VALIDATION_ERROR>
1779BOARD_DESIGN_SETTINGS::GetDesignRuleWarnings( std::optional<EDA_UNITS> aUnits ) const
1780{
1781 std::vector<VALIDATION_ERROR> warnings;
1782 EDA_UNITS units = aUnits.value_or( EDA_UNITS::MM );
1783
1784 auto str =
1785 [&]( int aValue )
1786 {
1787 return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, aValue, true );
1788 };
1789
1790 // Microvias are excluded because their default drill plus annulus already exceeds their default diameter
1791 int impliedViaMin = m_MinThroughDrill + 2 * m_ViasMinAnnularWidth;
1792
1793 if( m_ViasMinSize < impliedViaMin )
1794 {
1795 warnings.push_back( { wxS( "min_via_diameter" ),
1796 wxString::Format( _( "Minimum via diameter (%s) is smaller than the minimum drill "
1797 "size (%s) plus twice the minimum annular width (%s), so it "
1798 "has no effect. The effective minimum via diameter is %s." ),
1799 str( m_ViasMinSize ),
1800 str( m_MinThroughDrill ),
1801 str( m_ViasMinAnnularWidth ),
1802 str( impliedViaMin ) ) } );
1803 }
1804
1805 return warnings;
1806}
1807
1808
1810{
1811 int biggest = std::max( m_MinClearance, m_HoleClearance );
1812 DRC_CONSTRAINT constraint;
1813
1814 biggest = std::max( biggest, m_HoleToHoleMin );
1815 biggest = std::max( biggest, m_CopperEdgeClearance );
1816
1817 if( m_DRCEngine )
1818 {
1819 m_DRCEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, constraint );
1820 biggest = std::max( biggest, constraint.Value().Min() );
1821
1822 m_DRCEngine->QueryWorstConstraint( PHYSICAL_CLEARANCE_CONSTRAINT, constraint );
1823 biggest = std::max( biggest, constraint.Value().Min() );
1824
1825 m_DRCEngine->QueryWorstConstraint( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, constraint );
1826 biggest = std::max( biggest, constraint.Value().Min() );
1827
1828 m_DRCEngine->QueryWorstConstraint( HOLE_CLEARANCE_CONSTRAINT, constraint );
1829 biggest = std::max( biggest, constraint.Value().Min() );
1830
1831 m_DRCEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, constraint );
1832 biggest = std::max( biggest, constraint.Value().Min() );
1833
1834 m_DRCEngine->QueryWorstConstraint( HOLE_TO_HOLE_CONSTRAINT, constraint );
1835 biggest = std::max( biggest, constraint.Value().Min() );
1836 }
1837
1838 // Clip to avoid integer overflows in subsequent calculations
1839 return std::min( biggest, MAXIMUM_CLEARANCE );
1840}
1841
1842
1844{
1845 int clearance = m_NetSettings->GetDefaultNetclass()->GetClearance();
1846
1847 for( const auto& [name, netclass] : m_NetSettings->GetNetclasses() )
1848 {
1849 if( netclass->HasClearance() )
1850 clearance = std::min( clearance, netclass->GetClearance() );
1851 }
1852
1853 return clearance;
1854}
1855
1856
1857// Compute the next index when cycling a predefined-size list whose index 0 is the synthetic
1858// "use netclass" placeholder. Roll-over skips that placeholder when real sizes exist so the
1859// cycle stays monotonic.
1860static int nextPredefinedIndex( int aIndex, bool aForward, int aListSize )
1861{
1862 // Nothing to cycle when the list holds only the netclass placeholder (or is empty).
1863 if( aListSize <= 1 )
1864 return 0;
1865
1866 constexpr int lowestRealIndex = 1;
1867 int next = aIndex + ( aForward ? 1 : -1 );
1868
1869 if( next >= aListSize )
1870 next = lowestRealIndex;
1871 else if( next < lowestRealIndex )
1872 next = aListSize - 1;
1873
1874 return next;
1875}
1876
1877
1879{
1881 ? 0
1882 : std::clamp( aIndex, 0, (int) m_ViasDimensionsList.size() - 1 );
1883 m_useCustomTrackVia = false;
1884}
1885
1886
1887int BOARD_DESIGN_SETTINGS::GetNextViaSizeIndex( int aIndex, bool aForward ) const
1888{
1889 return nextPredefinedIndex( aIndex, aForward, (int) m_ViasDimensionsList.size() );
1890}
1891
1892
1894{
1896 return m_customViaSize.m_Diameter;
1898 return m_NetSettings->GetDefaultNetclass()->GetViaDiameter();
1899 else
1900 return m_ViasDimensionsList[ m_viaSizeIndex ].m_Diameter;
1901}
1902
1903
1905{
1906 int drill;
1907
1909 drill = m_customViaSize.m_Drill;
1911 drill = m_NetSettings->GetDefaultNetclass()->GetViaDrill();
1912 else
1913 drill = m_ViasDimensionsList[ m_viaSizeIndex ].m_Drill;
1914
1915 return drill > 0 ? drill : -1;
1916}
1917
1918
1920{
1922 ? 0
1923 : std::clamp( aIndex, 0, (int) m_TrackWidthList.size() - 1 );
1924 m_useCustomTrackVia = false;
1925}
1926
1927
1928int BOARD_DESIGN_SETTINGS::GetNextTrackWidthIndex( int aIndex, bool aForward ) const
1929{
1930 return nextPredefinedIndex( aIndex, aForward, (int) m_TrackWidthList.size() );
1931}
1932
1933
1935{
1937 return m_customTrackWidth;
1939 return m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
1940 else
1942}
1943
1944
1946{
1948 ? 0
1949 : std::clamp( aIndex, 0, (int) m_DiffPairDimensionsList.size() - 1 );
1950 m_useCustomDiffPair = false;
1951}
1952
1953
1954int BOARD_DESIGN_SETTINGS::GetNextDiffPairIndex( int aIndex, bool aForward ) const
1955{
1956 return nextPredefinedIndex( aIndex, aForward, (int) m_DiffPairDimensionsList.size() );
1957}
1958
1959
1961{
1963 {
1964 return m_customDiffPair.m_Width;
1965 }
1967 {
1968 if( m_NetSettings->GetDefaultNetclass()->HasDiffPairWidth() )
1969 return m_NetSettings->GetDefaultNetclass()->GetDiffPairWidth();
1970 else
1971 return m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
1972 }
1973 else
1974 {
1976 }
1977}
1978
1979
1981{
1983 {
1984 return m_customDiffPair.m_Gap;
1985 }
1987 {
1988 if( m_NetSettings->GetDefaultNetclass()->HasDiffPairGap() )
1989 return m_NetSettings->GetDefaultNetclass()->GetDiffPairGap();
1990 else
1991 return m_NetSettings->GetDefaultNetclass()->GetClearance();
1992 }
1993 else
1994 {
1996 }
1997}
1998
1999
2001{
2003 {
2004 return m_customDiffPair.m_ViaGap;
2005 }
2007 {
2008 if( m_NetSettings->GetDefaultNetclass()->HasDiffPairViaGap() )
2009 return m_NetSettings->GetDefaultNetclass()->GetDiffPairViaGap();
2010 else
2011 return GetCurrentDiffPairGap();
2012 }
2013 else
2014 {
2016 }
2017}
2018
2019
2021{
2022 m_copperLayerCount = aNewLayerCount;
2023
2024 // Update only enabled copper layers mask
2025 m_enabledLayers.ClearCopperLayers();
2026
2027 if( aNewLayerCount > 0 )
2028 m_enabledLayers |= LSET::AllCuMask( aNewLayerCount );
2029}
2030
2031
2033{
2034 m_userDefinedLayerCount = aNewLayerCount;
2035
2036 m_enabledLayers.ClearUserDefinedLayers();
2037
2038 if( aNewLayerCount > 0 )
2039 m_enabledLayers |= LSET::UserDefinedLayersMask( aNewLayerCount );
2040}
2041
2042
2044{
2045 m_enabledLayers = aMask;
2046
2047 // Ensures mandatory back and front layers are always enabled regardless of board file
2048 // configuration.
2049 m_enabledLayers.set( B_Cu ).set( F_Cu )
2050 .set( B_CrtYd ).set( F_CrtYd )
2051 .set( Edge_Cuts )
2052 .set( Margin );
2053
2054 // update layer counts to ensure their consistency with m_EnabledLayers
2055 LSET copperLayers = aMask;
2056 copperLayers.ClearNonCopperLayers();
2057
2058 LSET userLayers = aMask & LSET::UserDefinedLayersMask();
2059
2060 m_copperLayerCount = (int) copperLayers.count();
2061 m_userDefinedLayerCount = (int) userLayers.count();
2062}
2063
2064
2065// Return the layer class index { silk, copper, edges & courtyards, fab, others } of the
2066// given layer.
2068{
2069 if( aLayer == F_SilkS || aLayer == B_SilkS )
2070 return LAYER_CLASS_SILK;
2071 else if( IsCopperLayer( aLayer ) )
2072 return LAYER_CLASS_COPPER;
2073 else if( aLayer == Edge_Cuts )
2074 return LAYER_CLASS_EDGES;
2075 else if( aLayer == F_CrtYd || aLayer == B_CrtYd )
2076 return LAYER_CLASS_COURTYARD;
2077 else if( aLayer == F_Fab || aLayer == B_Fab )
2078 return LAYER_CLASS_FAB;
2079 else
2080 return LAYER_CLASS_OTHERS;
2081}
2082
2083
2085{
2086 return pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_DRCEpsilon );
2087}
2088
2089
2091{
2092 return pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_HoleWallThickness );
2093}
2094
2095
2097{
2098 return m_LineThickness[ GetLayerClass( aLayer ) ];
2099}
2100
2101
2103{
2104 return m_TextSize[ GetLayerClass( aLayer ) ];
2105}
2106
2107
2109{
2110 return m_TextThickness[ GetLayerClass( aLayer ) ];
2111}
2112
2113
2115{
2116 return m_TextItalic[ GetLayerClass( aLayer ) ];
2117}
2118
2119
2121{
2122 return m_TextUpright[ GetLayerClass( aLayer ) ];
2123}
const char * name
constexpr int ARC_HIGH_DEF
Definition base_units.h:144
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
const int bdsSchemaVersion
static int nextPredefinedIndex(int aIndex, bool aForward, int aListSize)
@ LAYER_CLASS_OTHERS
@ LAYER_CLASS_FAB
@ LAYER_CLASS_COURTYARD
@ LAYER_CLASS_SILK
@ LAYER_CLASS_COPPER
@ LAYER_CLASS_EDGES
#define DEFAULT_MICROVIASMINDRILL
#define DEFAULT_SOLDERPASTE_CLEARANCE
#define DEFAULT_SOLDERPASTE_RATIO
#define DEFAULT_CUSTOMDPAIRWIDTH
#define DEFAULT_DP_MEANDER_SPACING
#define DEFAULT_VIASMINSIZE
#define DEFAULT_TEXT_WIDTH
#define DEFAULT_COPPER_TEXT_WIDTH
#define DEFAULT_CUSTOMDPAIRGAP
#define DEFAULT_MINCLEARANCE
#define MAXIMUM_ERROR_SIZE_MM
#define DEFAULT_HOLECLEARANCE
#define DEFAULT_SOLDERMASK_EXPANSION
#define DEFAULT_SOLDERMASK_MIN_WIDTH
#define MINIMUM_ERROR_SIZE_MM
#define DEFAULT_DIMENSION_EXTENSION_OFFSET
#define DEFAULT_COPPEREDGECLEARANCE
#define DEFAULT_DIMENSION_ARROW_LENGTH
#define DEFAULT_TRACKMINWIDTH
#define DEFAULT_MINTHROUGHDRILL
#define DEFAULT_SILK_TEXT_SIZE
#define MAXIMUM_CLEARANCE
#define DEFAULT_HOLETOHOLEMIN
#define MAX_MICROVIA_STACK_PITCH_MM
#define DEFAULT_MINCONNECTION
#define DEFAULT_COPPER_LINE_WIDTH
#define DEFAULT_SILK_LINE_WIDTH
#define DEFAULT_SILKCLEARANCE
#define DEFAULT_MICROVIASMINSIZE
#define DEFAULT_SILK_TEXT_WIDTH
#define DEFAULT_MINGROOVEWIDTH
#define DEFAULT_EDGE_WIDTH
#define DEFAULT_CUSTOMTRACKWIDTH
#define DEFAULT_CUSTOMDPAIRVIAGAP
#define DEFAULT_COPPER_TEXT_SIZE
#define DEFAULT_SOLDERMASK_TO_COPPER_CLEARANCE
#define DEFAULT_LINE_WIDTH
#define DEFAULT_MEANDER_SPACING
#define DEFAULT_COURTYARD_WIDTH
#define DEFAULT_BOARD_THICKNESS_MM
#define DEFAULT_MINRESOLVEDSPOKES
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
BASE_SET & set(size_t pos)
Definition base_set.h:126
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
std::vector< VALIDATION_ERROR > GetDesignRuleWarnings(std::optional< EDA_UNITS > aUnits=std::nullopt) const
Find design rule values that are legal but have no effect because other rules imply a stricter limit.
int GetHolePlatingThickness() const
Pad & via drills are finish size.
VIATYPE m_CurrentViaType
(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
void SetEnabledLayers(const LSET &aMask)
Change the bit-mask of enabled layers to aMask.
std::shared_ptr< NET_SETTINGS > m_NetSettings
bool Ignore(int aDRCErrorCode) const
Return true if the DRC error code's severity is RPT_SEVERITY_ERROR.
bool operator==(const BOARD_DESIGN_SETTINGS &aOther) const
DIM_UNITS_FORMAT m_DimensionUnitsFormat
void initFromOther(const BOARD_DESIGN_SETTINGS &aOther)
bool GetTextUpright(PCB_LAYER_ID aLayer) const
std::map< int, SEVERITY > m_DRCSeverities
VECTOR2I m_gridOrigin
origin for grid offsets
int GetTextThickness(PCB_LAYER_ID aLayer) const
Return the default text thickness from the layer class for the given layer.
VECTOR2I m_auxOrigin
origin for plot exports
bool m_TextUpright[LAYER_CLASS_COUNT]
BOARD_DESIGN_SETTINGS(JSON_SETTINGS *aParent, const std::string &aPath)
bool GetTextItalic(PCB_LAYER_ID aLayer) const
int GetNextDiffPairIndex(int aIndex, bool aForward) const
Compute the next diff pair dimensions list index when cycling predefined sizes, skipping the index-0 ...
wxString m_currentNetClassName
Current net class name used to display netclass info.
void SetViaSizeIndex(int aIndex)
Set the current via size list index to aIndex.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
std::map< std::string, wxString > m_UserLayerNames
SEVERITY GetSeverity(int aDRCErrorCode) const
Return the severity of a given DRC error code.
int GetNextTrackWidthIndex(int aIndex, bool aForward) const
Compute the next track width list index when cycling predefined sizes, skipping the index-0 netclass ...
TEARDROP_PARAMETERS_LIST m_TeardropParamsList
The parameters of teardrops for the different teardrop targets (via/pad, track end).
void SetUserDefinedLayerCount(int aNewLayerCount)
Set the number of user defined layers to aNewLayerCount.
int GetDRCEpsilon() const
Return an epsilon which accounts for rounding errors, etc.
int GetLayerClass(PCB_LAYER_ID aLayer) const
PNS::MEANDER_SETTINGS m_DiffPairMeanderSettings
int m_boardThickness
Board thickness for 3D viewer.
int m_copperLayerCount
Number of copper layers for this design.
int m_userDefinedLayerCount
Number of user defined layers for this design.
bool LoadFromFile(const wxString &aDirectory="") override
Loads the backing file from disk and then calls Load()
PNS::MEANDER_SETTINGS m_SingleTrackMeanderSettings
void SetTrackWidthIndex(int aIndex)
Set the current track width list index to aIndex.
int m_TextThickness[LAYER_CLASS_COUNT]
ZONE_SETTINGS m_defaultZoneSettings
The default settings that will be used for new zones.
int GetNextViaSizeIndex(int aIndex, bool aForward) const
Compute the next via size list index when cycling predefined sizes, skipping the index-0 netclass pla...
std::vector< int > m_TrackWidthList
DIFF_PAIR_DIMENSION m_customDiffPair
std::vector< VALIDATION_ERROR > ValidateDesignRules(std::optional< EDA_UNITS > aUnits=std::nullopt) const
Validate design settings values and return per-field errors.
int m_LineThickness[LAYER_CLASS_COUNT]
VECTOR2I GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
VECTOR2I m_TextSize[LAYER_CLASS_COUNT]
PNS::MEANDER_SETTINGS m_SkewMeanderSettings
LSET m_enabledLayers
Bit-mask for layer enabling.
bool m_TextItalic[LAYER_CLASS_COUNT]
std::vector< VIA_STACK_PRESET > m_ViaStackPresets
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
DIM_TEXT_POSITION m_DimensionTextPosition
BOARD_STACKUP m_stackup
The description of layers stackup, for board fabrication only physical layers are in layers stackup.
std::vector< VIA_DIMENSION > m_ViasDimensionsList
BOARD_DESIGN_SETTINGS & operator=(const BOARD_DESIGN_SETTINGS &aOther)
std::set< DRC_EXCLUSION, DRC_EXCLUSION_COMPARE > m_DrcExclusions
MINOPTMAX< int > & Value()
Definition drc_rule.h:130
Container for an DRC exclusion, which is a PCB_MARKER plus an optional comment.
static DRC_EXCLUSION FromLegacyStrings(const wxString &aMarkerData, const wxString &aComment)
std::string GetSortKey() const
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
Definition drc_item.h:173
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition drc_item.cpp:505
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...
bool Contains(const std::string &aPath) const
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
std::optional< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
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...
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
bool m_resetParamsIfMissing
Whether or not to set parameters to their default value if missing from JSON on Load()
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
LSET & ClearNonCopperLayers()
Clear the non-copper layers in this set.
Definition lset.cpp:949
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
Definition lset.cpp:113
static LSET UserDefinedLayersMask(int aUserDefinedLayerCount=MAX_USER_DEFINED_LAYERS)
Return a mask with the requested number of user defined layers.
Definition lset.cpp:700
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition lset.cpp:184
T Min() const
Definition minoptmax.h:29
std::string m_path
The path (in pointer format) of where to store this document in the parent.
JSON_SETTINGS * GetParent()
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.
NESTED_SETTINGS(const std::string &aName, int aSchemaVersion, JSON_SETTINGS *aParent, const std::string &aPath, bool aLoadFromFile=true)
bool LoadFromFile(const wxString &aDirectory="") override
Loads the JSON document from the parent and then calls Load()
Stores an enum as an integer.
Definition parameters.h:232
Like a normal param, but with custom getter and setter functions.
Definition parameters.h:299
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition parameters.h:410
static std::optional< VIA_PARAMETER_ERROR > ValidateViaParameters(std::optional< int > aDiameter, std::optional< int > aPrimaryDrill, std::optional< PCB_LAYER_ID > aPrimaryStartLayer=std::nullopt, std::optional< PCB_LAYER_ID > aPrimaryEndLayer=std::nullopt, std::optional< int > aSecondaryDrill=std::nullopt, std::optional< PCB_LAYER_ID > aSecondaryStartLayer=std::nullopt, std::optional< PCB_LAYER_ID > aSecondaryEndLayer=std::nullopt, std::optional< int > aTertiaryDrill=std::nullopt, std::optional< PCB_LAYER_ID > aTertiaryStartLayer=std::nullopt, std::optional< PCB_LAYER_ID > aTertiaryEndLayer=std::nullopt, int aCopperLayerCount=0)
Dimensions for the meandering algorithm.
Definition pns_meander.h:70
int m_minAmplitude
Minimum meandering amplitude.
int m_cornerRadiusPercentage
Rounding percentage (0 - 100).
bool m_singleSided
Place meanders on one side.
MEANDER_STYLE m_cornerStyle
Type of corners for the meandered line.
int m_maxAmplitude
Maximum meandering amplitude.
int m_spacing
Meandering period/spacing (see dialog picture for explanation).
The backing store for a PROJECT, in JSON format.
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition rc_item.h:138
TEARDROP_PARAMETERS_LIST is a helper class to handle the list of TEARDROP_PARAMETERS needed to build ...
TEARDROP_PARAMETERS * GetParameters(TARGET_TD aTdType)
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
bool m_Enabled
Flag to enable teardrops.
bool m_CurvedEdges
True if the teardrop should be curved.
#define DEFAULT_TEXT_SIZE
The default text size in mils. (can be changed in preference menu)
@ EDGE_CLEARANCE_CONSTRAINT
@ PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
@ CLEARANCE_CONSTRAINT
@ HOLE_CLEARANCE_CONSTRAINT
@ PHYSICAL_CLEARANCE_CONSTRAINT
@ HOLE_TO_HOLE_CONSTRAINT
@ DRCE_FOOTPRINT_SCALED_WITH_PADS
Definition drc_item.h:101
@ DRCE_TUNING_PROFILE_IMPLICIT_RULES
Definition drc_item.h:132
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:114
@ DRCE_FOOTPRINT_FILTERS
Definition drc_item.h:94
@ DRCE_SILK_MASK_CLEARANCE
Definition drc_item.h:112
@ DRCE_PADSTACK
Definition drc_item.h:71
@ DRCE_MIRRORED_TEXT_ON_FRONT_LAYER
Definition drc_item.h:128
@ DRCE_LIB_FOOTPRINT_ISSUES
Definition drc_item.h:97
@ DRCE_MICROVIA_CROSSES_CORE
Definition drc_item.h:78
@ DRCE_OVERLAPPING_FOOTPRINTS
Definition drc_item.h:80
@ DRCE_SCHEMATIC_FIELDS_PARITY
Definition drc_item.h:138
@ DRCE_MISSING_COURTYARD
Definition drc_item.h:81
@ DRCE_MICROVIA_STACK_NOT_FILLED
Definition drc_item.h:75
@ DRCE_TRACK_NOT_CENTERED_ON_VIA
Definition drc_item.h:136
@ DRCE_COPPER_OUTSIDE_BOARD
Definition drc_item.h:143
@ DRCE_ISOLATED_COPPER
Definition drc_item.h:57
@ DRCE_MISSING_TUNING_PROFILE
Definition drc_item.h:131
@ DRCE_DRILLED_HOLES_TOO_CLOSE
Definition drc_item.h:61
@ DRCE_COPPER_SLIVER
Definition drc_item.h:108
@ DRCE_PTH_IN_COURTYARD
Definition drc_item.h:84
@ DRCE_FIRST
Definition drc_item.h:47
@ DRCE_DANGLING_VIA
Definition drc_item.h:59
@ DRCE_FOOTPRINT_TYPE_MISMATCH
Definition drc_item.h:96
@ DRCE_DUPLICATE_FOOTPRINT
Definition drc_item.h:90
@ DRCE_DANGLING_TRACK
Definition drc_item.h:60
@ DRCE_TEXT_HEIGHT
Definition drc_item.h:116
@ DRCE_DRILLED_HOLES_COLOCATED
Definition drc_item.h:62
@ DRCE_EXTRA_FOOTPRINT
Definition drc_item.h:91
@ DRCE_SILK_CLEARANCE
Definition drc_item.h:115
@ DRCE_LAST
Definition drc_item.h:145
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition drc_item.h:98
@ DRCE_NET_CONFLICT
Definition drc_item.h:92
@ DRCE_MISSING_FOOTPRINT
Definition drc_item.h:89
@ DRCE_UNMIRRORED_TEXT_ON_BACK_LAYER
Definition drc_item.h:129
@ DRCE_LINE_WIDTH
Definition drc_item.h:117
@ DRCE_NPTH_IN_COURTYARD
Definition drc_item.h:85
@ DRCE_CONNECTION_WIDTH
Definition drc_item.h:68
@ DRCE_SCHEMATIC_PARITY
Definition drc_item.h:93
@ DRCE_MICROVIA_SPANS_DIELECTRICS
Definition drc_item.h:79
#define _(s)
@ DEGREES_T
Definition eda_angle.h:30
#define TEXT_MIN_SIZE_MM
Minimum text size (1 micron).
Definition eda_text.h:61
#define TEXT_MAX_SIZE_MM
Maximum text size in mm (~10 inches)
Definition eda_text.h:62
EDA_UNITS
Definition eda_units.h:45
template KICOMMON_API std::optional< nlohmann::json > JSON_SETTINGS::Get< nlohmann::json >(const std::string &aPath) const
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:744
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_CrtYd
Definition layer_ids.h:112
@ Edge_Cuts
Definition layer_ids.h:108
@ B_Cu
Definition layer_ids.h:61
@ F_Fab
Definition layer_ids.h:115
@ Margin
Definition layer_ids.h:109
@ F_SilkS
Definition layer_ids.h:96
@ B_CrtYd
Definition layer_ids.h:111
@ In1_Cu
Definition layer_ids.h:62
@ B_SilkS
Definition layer_ids.h:97
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
@ F_Cu
Definition layer_ids.h:60
@ B_Fab
Definition layer_ids.h:114
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition lset.cpp:750
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.
@ MEANDER_STYLE_ROUND
Definition pns_meander.h:54
@ MEANDER_STYLE_CHAMFER
Definition pns_meander.h:55
@ OUTSIDE
Text appears outside the dimension line (default)
@ INLINE
Text appears in line with the dimension line.
CITER next(CITER it)
Definition ptree.cpp:120
SEVERITY
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE
static BOM_FMT_PRESET CSV()
Container to handle a stock of specific differential pairs each with unique track width,...
BOM_FMT_PRESET m_BomFmtSettings
List of stored BOM format presets.
BOM_PRESET m_BomSettings
List of stored BOM presets.
std::vector< BOM_PRESET > m_BomPresets
std::vector< BOM_FMT_PRESET > m_BomFmtPresets
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
A named microvia stack definition, chosen while routing instead of entering the values each time.
std::string GetTeardropTargetCanonicalName(TARGET_TD aTdType)
TARGET_TD GetTeardropTargetTypeFromCanonicalName(const std::string &aTargetName)
int clearance
SEVERITY SeverityFromString(const wxString &aSeverity)
Definition ui_common.cpp:58
wxString SeverityToString(const SEVERITY &aSeverity)
Definition ui_common.cpp:69
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
#define ZONE_THERMAL_RELIEF_GAP_MM
Definition zones.h:28
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:43
@ THERMAL
Use thermal relief for pads.
Definition zones.h:46
#define ZONE_BORDER_HATCH_DIST_MM
Definition zones.h:34
#define ZONE_BORDER_HATCH_MINDIST_MM
Definition zones.h:35
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MM
Definition zones.h:29
#define ZONE_CLEARANCE_MM
Definition zones.h:32
#define ZONE_THICKNESS_MIN_VALUE_MM
Definition zones.h:31
#define ZONE_THICKNESS_MM
Definition zones.h:30
#define ZONE_BORDER_HATCH_MAXDIST_MM
Definition zones.h:36