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 (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <pcb_dimension.h>
25#include <pcb_track.h>
26#include <layer_ids.h>
27#include <kiface_base.h>
28#include <pad.h>
30#include <drc/drc_item.h>
31#include <drc/drc_engine.h>
33#include <settings/parameters.h>
35#include <advanced_config.h>
36
37const int bdsSchemaVersion = 2;
38
39
40BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
41 NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aParent, aPath )
42{
43 // We want to leave alone parameters that aren't found in the project JSON as they may be
44 // initialized by the board file parser before NESTED_SETTINGS::LoadFromFile is called.
46
47 // Create a default NET_SETTINGS so that things don't break horribly if there's no project
48 // loaded. This also is used during file load for legacy boards that have netclasses stored
49 // in the file. After load, this information will be moved to the project and the pointer
50 // updated.
51 m_NetSettings = std::make_shared<NET_SETTINGS>( nullptr, "" );
52
53 m_HasStackup = false; // no stackup defined by default
54
55 m_Pad_Master = std::make_unique<PAD>( nullptr );
57
58 LSET all_set = LSET().set();
59 m_enabledLayers = all_set; // All layers enabled at first.
60 // SetCopperLayerCount() will adjust this.
61
62 SetCopperLayerCount( 2 ); // Default design is a double sided board
63 m_CurrentViaType = VIATYPE::THROUGH;
64
65 // if true, when creating a new track starting on an existing track, use this track width
68
69 // First is always the reference designator
70 m_DefaultFPTextItems.emplace_back( wxT( "REF**" ), true, F_SilkS );
71 // Second is always the value
72 m_DefaultFPTextItems.emplace_back( wxT( "" ), true, F_Fab );
73 // Any following ones are freebies
74 m_DefaultFPTextItems.emplace_back( wxT( "${REFERENCE}" ), true, F_Fab );
75
82
89
90 // Edges & Courtyards; text properties aren't used but better to have them holding
91 // reasonable values than not.
98
105
110 m_TextItalic[ LAYER_CLASS_FAB ] = false;
112
119
120 m_StyleFPFields = false;
121 m_StyleFPText = false;
122 m_StyleFPShapes = false;
123
124 m_DimensionPrecision = DIM_PRECISION::X_XXXX;
125 m_DimensionUnitsMode = DIM_UNITS_MODE::AUTOMATIC;
126 m_DimensionUnitsFormat = DIM_UNITS_FORMAT::BARE_SUFFIX;
128 m_DimensionTextPosition = DIM_TEXT_POSITION::OUTSIDE;
132
133 m_useCustomTrackVia = false;
137
138 m_useCustomDiffPair = false;
142
158
159 for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode )
160 m_DRCSeverities[ errorCode ] = RPT_SEVERITY_ERROR;
161
163
167
170
173
175
181
187
189
192
194
198
199 // Global mask margins:
203
204 // Solder paste margin absolute value
206 // Solder paste margin as a ratio of pad size
207 // The final margin is the sum of these 2 values
208 // Usually < 0 because the mask is smaller than pad
210
212
213 // Layer thickness for 3D viewer
215
216 // Default spacing for meanders
220
221 m_viaSizeIndex = 0;
223 m_diffPairIndex = 0;
224
225 // Parameters stored in JSON in the project file
226
227 // NOTE: Previously, BOARD_DESIGN_SETTINGS stored the basic board layer information (layer
228 // names and enable/disable state) in the project file even though this information is also
229 // stored in the board file. This was implemented for importing these settings from another
230 // project. Going forward, the import feature will just import from other board files (since
231 // we could have multi-board projects in the future anyway) so this functionality is dropped.
232
233
234 m_params.emplace_back( new PARAM<bool>( "rules.use_height_for_length_calcs",
235 &m_UseHeightForLengthCalcs, true ) );
236
237 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_clearance",
240
241 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_connection",
243 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
244
245 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_track_width",
248
249 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_annular_width",
252
253 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_diameter",
256
257 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_through_hole_diameter",
260
261 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_diameter",
264
265 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_drill",
268
269 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_to_hole",
272
273 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_clearance",
275 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
276
277 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_silk_clearance",
279 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
280
281 // While the maximum *effective* value is 4, we've had users interpret this as the count on
282 // all layers, and enter something like 10. They'll figure it out soon enough *unless* we
283 // enforce a max of 4 (and therefore reset it back to the default of 2), at which point it
284 // just looks buggy.
285 m_params.emplace_back( new PARAM<int>( "rules.min_resolved_spokes",
287
288 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_text_height",
290 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
291
292 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_text_thickness",
295
296 // Note: a clearance of -0.01 is a flag indicating we should use the legacy (pre-6.0) method
297 // based on the edge cut thicknesses.
298 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_copper_edge_clearance",
300 pcbIUScale.mmToIU( -0.01 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
301
302 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities",
303 [&]() -> nlohmann::json
304 {
305 nlohmann::json ret = {};
306
307 for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
308 {
309 wxString name = item.GetSettingsKey();
310 int code = item.GetErrorCode();
311
312 if( name.IsEmpty() || m_DRCSeverities.count( code ) == 0 )
313 continue;
314
315 ret[std::string( name.ToUTF8() )] = SeverityToString( m_DRCSeverities[code] );
316 }
317
318 return ret;
319 },
320 [&]( const nlohmann::json& aJson )
321 {
322 if( !aJson.is_object() )
323 return;
324
325 for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
326 {
327 wxString name = item.GetSettingsKey();
328 std::string key( name.ToUTF8() );
329
330 if( aJson.contains( key ) )
331 m_DRCSeverities[item.GetErrorCode()] = SeverityFromString( aJson[key] );
332 }
333 }, {} ) );
334
335 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "drc_exclusions",
336 [&]() -> nlohmann::json
337 {
338 nlohmann::json js = nlohmann::json::array();
339
340 for( const wxString& entry : m_DrcExclusions )
341 js.push_back( { entry, m_DrcExclusionComments[ entry ] } );
342
343 return js;
344 },
345 [&]( const nlohmann::json& aObj )
346 {
347 m_DrcExclusions.clear();
348
349 if( !aObj.is_array() )
350 return;
351
352 for( const nlohmann::json& entry : aObj )
353 {
354 if( entry.is_array() )
355 {
356 wxString serialized = entry[0].get<wxString>();
357 m_DrcExclusions.insert( serialized );
358 m_DrcExclusionComments[ serialized ] = entry[1].get<wxString>();
359 }
360 else if( entry.is_string() )
361 {
362 m_DrcExclusions.insert( entry.get<wxString>() );
363 }
364 }
365 },
366 {} ) );
367
368 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "track_widths",
369 [&]() -> nlohmann::json
370 {
371 nlohmann::json js = nlohmann::json::array();
372
373 for( const int& width : m_TrackWidthList )
374 js.push_back( pcbIUScale.IUTomm( width ) );
375
376 return js;
377 },
378 [&]( const nlohmann::json& aJson )
379 {
380 if( !aJson.is_array() )
381 return;
382
383 m_TrackWidthList.clear();
384
385 for( const nlohmann::json& entry : aJson )
386 {
387 if( entry.empty() )
388 continue;
389
390 m_TrackWidthList.emplace_back( pcbIUScale.mmToIU( entry.get<double>() ) );
391 }
392 },
393 {} ) );
394
395 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "via_dimensions",
396 [&]() -> nlohmann::json
397 {
398 nlohmann::json js = nlohmann::json::array();
399
400 for( const auto& via : m_ViasDimensionsList )
401 {
402 nlohmann::json entry = {};
403
404 entry["diameter"] = pcbIUScale.IUTomm( via.m_Diameter );
405 entry["drill"] = pcbIUScale.IUTomm( via.m_Drill );
406
407 js.push_back( entry );
408 }
409
410 return js;
411 },
412 [&]( const nlohmann::json& aObj )
413 {
414 if( !aObj.is_array() )
415 return;
416
417 m_ViasDimensionsList.clear();
418
419 for( const nlohmann::json& entry : aObj )
420 {
421 if( entry.empty() || !entry.is_object() )
422 continue;
423
424 if( !entry.contains( "diameter" ) || !entry.contains( "drill" ) )
425 continue;
426
427 int diameter = pcbIUScale.mmToIU( entry["diameter"].get<double>() );
428 int drill = pcbIUScale.mmToIU( entry["drill"].get<double>() );
429
430 m_ViasDimensionsList.emplace_back( VIA_DIMENSION( diameter, drill ) );
431 }
432 },
433 {} ) );
434
435 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "diff_pair_dimensions",
436 [&]() -> nlohmann::json
437 {
438 nlohmann::json js = nlohmann::json::array();
439
440 for( const auto& pair : m_DiffPairDimensionsList )
441 {
442 nlohmann::json entry = {};
443
444 entry["width"] = pcbIUScale.IUTomm( pair.m_Width );
445 entry["gap"] = pcbIUScale.IUTomm( pair.m_Gap );
446 entry["via_gap"] = pcbIUScale.IUTomm( pair.m_ViaGap );
447
448 js.push_back( entry );
449 }
450
451 return js;
452 },
453 [&]( const nlohmann::json& aObj )
454 {
455 if( !aObj.is_array() )
456 return;
457
459
460 for( const nlohmann::json& entry : aObj )
461 {
462 if( entry.empty() || !entry.is_object() )
463 continue;
464
465 if( !entry.contains( "width" ) || !entry.contains( "gap" )
466 || !entry.contains( "via_gap" ) )
467 continue;
468
469 int width = pcbIUScale.mmToIU( entry["width"].get<double>() );
470 int gap = pcbIUScale.mmToIU( entry["gap"].get<double>() );
471 int via_gap = pcbIUScale.mmToIU( entry["via_gap"].get<double>() );
472
473 m_DiffPairDimensionsList.emplace_back(
474 DIFF_PAIR_DIMENSION( width, gap, via_gap ) );
475 }
476 },
477 {} ) );
478
479 // Handle options for teardrops (targets and some others):
480 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "teardrop_options",
481 [&]() -> nlohmann::json
482 {
483 nlohmann::json js = nlohmann::json::array();
484 nlohmann::json entry = {};
485
486 entry["td_onviapad"] = m_TeardropParamsList.m_TargetViasPads;
487 entry["td_onpadsmd"] = m_TeardropParamsList.m_TargetPadsWithNoHole;
488 entry["td_ontrackend"] = m_TeardropParamsList.m_TargetTrack2Track;
489 entry["td_onroundshapesonly"] = m_TeardropParamsList.m_UseRoundShapesOnly;
490
491 js.push_back( entry );
492
493 return js;
494 },
495 [&]( const nlohmann::json& aObj )
496 {
497 if( !aObj.is_array() )
498 return;
499
500 for( const nlohmann::json& entry : aObj )
501 {
502 if( entry.empty() || !entry.is_object() )
503 continue;
504
505 if( entry.contains( "td_onviapad" ) )
506 m_TeardropParamsList.m_TargetViasPads = entry["td_onviapad"].get<bool>();
507
508 if( entry.contains( "td_onpadsmd" ) )
509 m_TeardropParamsList.m_TargetPadsWithNoHole = entry["td_onpadsmd"].get<bool>();
510
511 if( entry.contains( "td_ontrackend" ) )
512 m_TeardropParamsList.m_TargetTrack2Track = entry["td_ontrackend"].get<bool>();
513
514 if( entry.contains( "td_onroundshapesonly" ) )
515 m_TeardropParamsList.m_UseRoundShapesOnly = entry["td_onroundshapesonly"].get<bool>();
516
517 // Legacy settings
518 for( int ii = 0; ii < 3; ++ii )
519 {
521
522 if( entry.contains( "td_allow_use_two_tracks" ) )
523 td_prm->m_AllowUseTwoTracks = entry["td_allow_use_two_tracks"].get<bool>();
524
525 if( entry.contains( "td_curve_segcount" ) )
526 td_prm->m_CurveSegCount = entry["td_curve_segcount"].get<int>();
527
528 if( entry.contains( "td_on_pad_in_zone" ) )
529 td_prm->m_TdOnPadsInZones = entry["td_on_pad_in_zone"].get<bool>();
530 }
531 }
532 },
533 {} ) );
534
535 // Handle parameters (sizes, shape) for each type of teardrop:
536 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "teardrop_parameters",
537 [&]() -> nlohmann::json
538 {
539 nlohmann::json js = nlohmann::json::array();
540
541 for( size_t ii = 0; ii < m_TeardropParamsList.GetParametersCount(); ii++ )
542 {
543 nlohmann::json entry = {};
545
546 entry["td_target_name"] = GetTeardropTargetCanonicalName( (TARGET_TD)ii );
547 entry["td_maxlen"] = pcbIUScale.IUTomm( td_prm->m_TdMaxLen );
548 entry["td_maxheight"] = pcbIUScale.IUTomm( td_prm->m_TdMaxWidth );
549 entry["td_length_ratio"] = td_prm->m_BestLengthRatio;
550 entry["td_height_ratio"] = td_prm->m_BestWidthRatio;
551 entry["td_curve_segcount"] = td_prm->m_CurveSegCount;
552 entry["td_width_to_size_filter_ratio"] = td_prm->m_WidthtoSizeFilterRatio;
553 entry["td_allow_use_two_tracks"] = td_prm->m_AllowUseTwoTracks;
554 entry["td_curve_segcount"] = td_prm->m_CurveSegCount;
555 entry["td_on_pad_in_zone"] = td_prm->m_TdOnPadsInZones;
556
557 js.push_back( entry );
558 }
559
560 return js;
561 },
562 [&]( const nlohmann::json& aObj )
563 {
564 if( !aObj.is_array() )
565 return;
566
567 for( const nlohmann::json& entry : aObj )
568 {
569 if( entry.empty() || !entry.is_object() )
570 continue;
571
572 if( !entry.contains( "td_target_name" ) )
573 continue;
574
575 int idx = GetTeardropTargetTypeFromCanonicalName( entry["td_target_name"].get<std::string>() );
576
577 if( idx >= 0 && idx < 3 )
578 {
580
581 if( entry.contains( "td_maxlen" ) )
582 td_prm->m_TdMaxLen = pcbIUScale.mmToIU( entry["td_maxlen"].get<double>() );
583
584 if( entry.contains( "td_maxheight" ) )
585 td_prm->m_TdMaxWidth = pcbIUScale.mmToIU( entry["td_maxheight"].get<double>() );
586
587 if( entry.contains( "td_length_ratio" ) )
588 td_prm->m_BestLengthRatio = entry["td_length_ratio"].get<double>();
589
590 if( entry.contains( "td_height_ratio" ) )
591 td_prm->m_BestWidthRatio = entry["td_height_ratio"].get<double>();
592
593 if( entry.contains( "td_curve_segcount" ) )
594 td_prm->m_CurveSegCount = entry["td_curve_segcount"].get<int>();
595
596 if( entry.contains( "td_width_to_size_filter_ratio" ) )
597 td_prm->m_WidthtoSizeFilterRatio = entry["td_width_to_size_filter_ratio"].get<double>();
598
599 if( entry.contains( "td_allow_use_two_tracks" ) )
600 td_prm->m_AllowUseTwoTracks = entry["td_allow_use_two_tracks"].get<bool>();
601
602 if( entry.contains( "td_curve_segcount" ) )
603 td_prm->m_CurveSegCount = entry["td_curve_segcount"].get<int>();
604
605 if( entry.contains( "td_on_pad_in_zone" ) )
606 td_prm->m_TdOnPadsInZones = entry["td_on_pad_in_zone"].get<bool>();
607 }
608 }
609 },
610 {} ) );
611
612 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "tuning_pattern_settings",
613 [&]() -> nlohmann::json
614 {
615 nlohmann::json js = {};
616
617 auto make_settings =
618 []( const PNS::MEANDER_SETTINGS& aSettings )
619 {
620 nlohmann::json entry = {};
621
622 entry["min_amplitude"] = pcbIUScale.IUTomm( aSettings.m_minAmplitude );
623 entry["max_amplitude"] = pcbIUScale.IUTomm( aSettings.m_maxAmplitude );
624 entry["spacing"] = pcbIUScale.IUTomm( aSettings.m_spacing );
625 entry["corner_style"] = aSettings.m_cornerStyle == PNS::MEANDER_STYLE_CHAMFER ? 0 : 1;
626 entry["corner_radius_percentage"] = aSettings.m_cornerRadiusPercentage;
627 entry["single_sided"] = aSettings.m_singleSided;
628
629 return entry;
630 };
631
632 js["single_track_defaults"] = make_settings( m_SingleTrackMeanderSettings );
633 js["diff_pair_defaults"] = make_settings( m_DiffPairMeanderSettings );
634 js["diff_pair_skew_defaults"] = make_settings( m_SkewMeanderSettings );
635
636 return js;
637 },
638 [&]( const nlohmann::json& aObj )
639 {
640 auto read_settings =
641 []( const nlohmann::json& entry ) -> PNS::MEANDER_SETTINGS
642 {
643 PNS::MEANDER_SETTINGS settings;
644
645 if( entry.contains( "min_amplitude" ) )
646 settings.m_minAmplitude = pcbIUScale.mmToIU( entry["min_amplitude"].get<double>() );
647
648 if( entry.contains( "max_amplitude" ) )
649 settings.m_maxAmplitude = pcbIUScale.mmToIU( entry["max_amplitude"].get<double>() );
650
651 if( entry.contains( "spacing" ) )
652 settings.m_spacing = pcbIUScale.mmToIU( entry["spacing"].get<double>() );
653
654 if( entry.contains( "corner_style" ) )
655 {
656 settings.m_cornerStyle = entry["corner_style"] == 0 ? PNS::MEANDER_STYLE_CHAMFER
658 }
659
660 if( entry.contains( "corner_radius_percentage" ) )
661 settings.m_cornerRadiusPercentage = entry["corner_radius_percentage"].get<int>();
662
663 if( entry.contains( "single_sided" ) )
664 settings.m_singleSided = entry["single_sided"].get<bool>();
665
666 return settings;
667 };
668
669 if( aObj.contains( "single_track_defaults" ) )
670 m_SingleTrackMeanderSettings = read_settings( aObj["single_track_defaults"] );
671
672 if( aObj.contains( "diff_pair_defaults" ) )
673 m_DiffPairMeanderSettings = read_settings( aObj["diff_pair_defaults"] );
674
675 if( aObj.contains( "diff_pair_skew_defaults" ) )
676 m_SkewMeanderSettings = read_settings( aObj["diff_pair_skew_defaults"] );
677 },
678 {} ) );
679
680 int minTextSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
681 int maxTextSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
682 int minStroke = 1;
683 int maxStroke = pcbIUScale.mmToIU( 100 );
684
685 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_line_width",
687 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
688
689 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_v",
691 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
692
693 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_h",
695 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
696
697 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_thickness",
699 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
700
701 m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_italic",
702 &m_TextItalic[LAYER_CLASS_SILK], false ) );
703
704 m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_upright",
705 &m_TextUpright[ LAYER_CLASS_SILK ], true ) );
706
707 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_line_width",
709 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
710
711 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_v",
713 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
714
715 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_h",
717 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
718
719 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_thickness",
721 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
722
723 m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_italic",
724 &m_TextItalic[LAYER_CLASS_COPPER], false ) );
725
726 m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_upright",
728
729 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.board_outline_line_width",
731 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
732
733 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.courtyard_line_width",
735 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
736
737 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_line_width",
739 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
740
741 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_v",
743 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
744
745 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_h",
747 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
748
749 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_thickness",
751 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
752
753 m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_italic",
754 &m_TextItalic[LAYER_CLASS_FAB], false ) );
755
756 m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_upright",
757 &m_TextUpright[LAYER_CLASS_FAB], true ) );
758
759 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_line_width",
761 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
762
763 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_v",
765 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
766
767 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_h",
769 minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
770
771 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_thickness",
773 minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
774
775 m_params.emplace_back( new PARAM<bool>( "defaults.other_text_italic",
776 &m_TextItalic[LAYER_CLASS_OTHERS], false ) );
777
778 m_params.emplace_back( new PARAM<bool>( "defaults.other_text_upright",
780
781 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_MODE>( "defaults.dimension_units",
782 &m_DimensionUnitsMode, DIM_UNITS_MODE::AUTOMATIC, DIM_UNITS_MODE::INCHES,
783 DIM_UNITS_MODE::AUTOMATIC ) );
784
785 m_params.emplace_back( new PARAM_ENUM<DIM_PRECISION>( "defaults.dimension_precision",
786 &m_DimensionPrecision, DIM_PRECISION::X_XXXX, DIM_PRECISION::X, DIM_PRECISION::V_VVVVV ) );
787
788 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_FORMAT>( "defaults.dimensions.units_format",
789 &m_DimensionUnitsFormat, DIM_UNITS_FORMAT::BARE_SUFFIX, DIM_UNITS_FORMAT::NO_SUFFIX,
790 DIM_UNITS_FORMAT::PAREN_SUFFIX ) );
791
792 m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.suppress_zeroes",
793 &m_DimensionSuppressZeroes, false ) );
794
795 // NOTE: excluding DIM_TEXT_POSITION::MANUAL from the valid range here
796 m_params.emplace_back( new PARAM_ENUM<DIM_TEXT_POSITION>( "defaults.dimensions.text_position",
797 &m_DimensionTextPosition, DIM_TEXT_POSITION::OUTSIDE, DIM_TEXT_POSITION::OUTSIDE,
798 DIM_TEXT_POSITION::INLINE ) );
799
800 m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.keep_text_aligned",
802
803 m_params.emplace_back( new PARAM<int>( "defaults.dimensions.arrow_length",
806
807 m_params.emplace_back( new PARAM<int>( "defaults.dimensions.extension_offset",
810
811 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_fields",
812 &m_StyleFPFields, false ) );
813 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_text",
814 &m_StyleFPText, false ) );
815 m_params.emplace_back( new PARAM<bool>( "defaults.apply_defaults_to_fp_shapes",
816 &m_StyleFPShapes, false ) );
817
818 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.zones.min_clearance",
821
822 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "defaults.pads",
823 [&]() -> nlohmann::json
824 {
825 nlohmann::json ret =
826 {
827 { "width", pcbIUScale.IUTomm( m_Pad_Master->GetSize().x ) },
828 { "height", pcbIUScale.IUTomm( m_Pad_Master->GetSize().y ) },
829 { "drill", pcbIUScale.IUTomm( m_Pad_Master->GetDrillSize().x ) }
830 };
831
832 return ret;
833 },
834 [&]( const nlohmann::json& aJson )
835 {
836 if( aJson.contains( "width" ) && aJson.contains( "height" )
837 && aJson.contains( "drill" ) )
838 {
839 VECTOR2I sz;
840 sz.x = pcbIUScale.mmToIU( aJson["width"].get<double>() );
841 sz.y = pcbIUScale.mmToIU( aJson["height"].get<double>() );
842
843 m_Pad_Master->SetSize( sz );
844
845 int drill = pcbIUScale.mmToIU( aJson["drill"].get<double>() );
846
847 m_Pad_Master->SetDrillSize( VECTOR2I( drill, drill ) );
848 }
849 }, {} ) );
850
851 m_params.emplace_back( new PARAM_SCALED<int>( "rules.max_error",
853
854 m_params.emplace_back( new PARAM_SCALED<int>( "rules.solder_mask_to_copper_clearance",
857
858 m_params.emplace_back( new PARAM<bool>( "zones_allow_external_fillets",
859 &m_ZoneKeepExternalFillets, false ) );
860
862
863 registerMigration( 1, 2,
864 [&]() -> bool
865 {
866 // Schema 1 to 2: move mask and paste margin settings back to board.
867 // The parameters are removed, so we just have to manually load them here and
868 // they will get saved with the board
869 if( std::optional<double> optval = Get<double>( "rules.solder_mask_clearance" ) )
870 m_SolderMaskExpansion = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
871
872 if( std::optional<double> optval = Get<double>( "rules.solder_mask_min_width" ) )
873 m_SolderMaskMinWidth = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
874
875 if( std::optional<double> optval = Get<double>( "rules.solder_paste_clearance" ) )
876 m_SolderPasteMargin = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
877
878 if( std::optional<double> optval = Get<double>( "rules.solder_paste_margin_ratio" ) )
879 m_SolderPasteMarginRatio = *optval;
880
881 try
882 {
883 At( "rules" ).erase( "solder_mask_clearance" );
884 At( "rules" ).erase( "solder_mask_min_width" );
885 At( "rules" ).erase( "solder_paste_clearance" );
886 At( "rules" ).erase( "solder_paste_margin_ratio" );
887 }
888 catch( ... )
889 {}
890
891 return true;
892 } );
893}
894
895
897{
898 if( m_parent )
899 {
901 m_parent = nullptr;
902 }
903}
904
905
907 NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aOther.m_parent,
908 aOther.m_path ),
909 m_Pad_Master( nullptr )
910{
911 initFromOther( aOther );
912}
913
914
916{
917 initFromOther( aOther );
918 return *this;
919}
920
921
923{
924 // Copy of NESTED_SETTINGS around is not allowed, so let's just update the params.
932 m_MinConn = aOther.m_MinConn;
950 m_MaxError = aOther.m_MaxError;
958
959 std::copy( std::begin( aOther.m_LineThickness ), std::end( aOther.m_LineThickness ),
960 std::begin( m_LineThickness ) );
961
962 std::copy( std::begin( aOther.m_TextSize ), std::end( aOther.m_TextSize ),
963 std::begin( m_TextSize ) );
964
965 std::copy( std::begin( aOther.m_TextThickness ), std::end( aOther.m_TextThickness ),
966 std::begin( m_TextThickness ) );
967
968 std::copy( std::begin( aOther.m_TextItalic ), std::end( aOther.m_TextItalic ),
969 std::begin( m_TextItalic ) );
970
971 std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ),
972 std::begin( m_TextUpright ) );
973
982
983 m_auxOrigin = aOther.m_auxOrigin;
984 m_gridOrigin = aOther.m_gridOrigin;
985 m_HasStackup = aOther.m_HasStackup;
987
1000 m_stackup = aOther.m_stackup;
1002 m_Pad_Master = std::make_unique<PAD>( *aOther.m_Pad_Master );
1004
1008}
1009
1010
1012{
1013 if( m_TrackWidthList != aOther.m_TrackWidthList ) return false;
1014 if( m_ViasDimensionsList != aOther.m_ViasDimensionsList ) return false;
1015 if( m_DiffPairDimensionsList != aOther.m_DiffPairDimensionsList ) return false;
1016 if( m_CurrentViaType != aOther.m_CurrentViaType ) return false;
1017 if( m_UseConnectedTrackWidth != aOther.m_UseConnectedTrackWidth ) return false;
1018 if( m_TempOverrideTrackWidth != aOther.m_TempOverrideTrackWidth ) return false;
1019 if( m_MinClearance != aOther.m_MinClearance ) return false;
1020 if( m_MinConn != aOther.m_MinConn ) return false;
1021 if( m_TrackMinWidth != aOther.m_TrackMinWidth ) return false;
1022 if( m_ViasMinAnnularWidth != aOther.m_ViasMinAnnularWidth ) return false;
1023 if( m_ViasMinSize != aOther.m_ViasMinSize ) return false;
1024 if( m_MinThroughDrill != aOther.m_MinThroughDrill ) return false;
1025 if( m_MicroViasMinSize != aOther.m_MicroViasMinSize ) return false;
1026 if( m_MicroViasMinDrill != aOther.m_MicroViasMinDrill ) return false;
1027 if( m_CopperEdgeClearance != aOther.m_CopperEdgeClearance ) return false;
1028 if( m_HoleClearance != aOther.m_HoleClearance ) return false;
1029 if( m_HoleToHoleMin != aOther.m_HoleToHoleMin ) return false;
1030 if( m_SilkClearance != aOther.m_SilkClearance ) return false;
1031 if( m_MinResolvedSpokes != aOther.m_MinResolvedSpokes ) return false;
1032 if( m_MinSilkTextHeight != aOther.m_MinSilkTextHeight ) return false;
1033 if( m_MinSilkTextThickness != aOther.m_MinSilkTextThickness ) return false;
1034 if( m_DRCSeverities != aOther.m_DRCSeverities ) return false;
1035 if( m_DrcExclusions != aOther.m_DrcExclusions ) return false;
1036 if( m_DrcExclusionComments != aOther.m_DrcExclusionComments ) return false;
1037 if( m_ZoneKeepExternalFillets != aOther.m_ZoneKeepExternalFillets ) return false;
1038 if( m_MaxError != aOther.m_MaxError ) return false;
1039 if( m_SolderMaskExpansion != aOther.m_SolderMaskExpansion ) return false;
1040 if( m_SolderMaskMinWidth != aOther.m_SolderMaskMinWidth ) return false;
1042 if( m_SolderPasteMargin != aOther.m_SolderPasteMargin ) return false;
1043 if( m_SolderPasteMarginRatio != aOther.m_SolderPasteMarginRatio ) return false;
1045 if( m_DefaultFPTextItems != aOther.m_DefaultFPTextItems ) return false;
1046
1047 if( !std::equal( std::begin( m_LineThickness ), std::end( m_LineThickness ),
1048 std::begin( aOther.m_LineThickness ) ) )
1049 return false;
1050
1051 if( !std::equal( std::begin( m_TextSize ), std::end( m_TextSize ),
1052 std::begin( aOther.m_TextSize ) ) )
1053 return false;
1054
1055 if( !std::equal( std::begin( m_TextThickness ), std::end( m_TextThickness ),
1056 std::begin( aOther.m_TextThickness ) ) )
1057 return false;
1058
1059 if( !std::equal( std::begin( m_TextItalic ), std::end( m_TextItalic ),
1060 std::begin( aOther.m_TextItalic ) ) )
1061 return false;
1062
1063 if( !std::equal( std::begin( m_TextUpright ), std::end( m_TextUpright ),
1064 std::begin( aOther.m_TextUpright ) ) )
1065 return false;
1066
1067 if( m_DimensionUnitsMode != aOther.m_DimensionUnitsMode ) return false;
1068 if( m_DimensionPrecision != aOther.m_DimensionPrecision ) return false;
1069 if( m_DimensionUnitsFormat != aOther.m_DimensionUnitsFormat ) return false;
1070 if( m_DimensionSuppressZeroes != aOther.m_DimensionSuppressZeroes ) return false;
1071 if( m_DimensionTextPosition != aOther.m_DimensionTextPosition ) return false;
1072 if( m_DimensionKeepTextAligned != aOther.m_DimensionKeepTextAligned ) return false;
1073 if( m_DimensionArrowLength != aOther.m_DimensionArrowLength ) return false;
1074 if( m_DimensionExtensionOffset != aOther.m_DimensionExtensionOffset ) return false;
1075 if( m_auxOrigin != aOther.m_auxOrigin ) return false;
1076 if( m_gridOrigin != aOther.m_gridOrigin ) return false;
1077 if( m_HasStackup != aOther.m_HasStackup ) return false;
1078 if( m_UseHeightForLengthCalcs != aOther.m_UseHeightForLengthCalcs ) return false;
1079 if( m_trackWidthIndex != aOther.m_trackWidthIndex ) return false;
1080 if( m_viaSizeIndex != aOther.m_viaSizeIndex ) return false;
1081 if( m_diffPairIndex != aOther.m_diffPairIndex ) return false;
1082 if( m_useCustomTrackVia != aOther.m_useCustomTrackVia ) return false;
1083 if( m_customTrackWidth != aOther.m_customTrackWidth ) return false;
1084 if( m_customViaSize != aOther.m_customViaSize ) return false;
1085 if( m_useCustomDiffPair != aOther.m_useCustomDiffPair ) return false;
1086 if( m_customDiffPair != aOther.m_customDiffPair ) return false;
1087 if( m_copperLayerCount != aOther.m_copperLayerCount ) return false;
1088 if( m_enabledLayers != aOther.m_enabledLayers ) return false;
1089 if( m_boardThickness != aOther.m_boardThickness ) return false;
1090 if( m_currentNetClassName != aOther.m_currentNetClassName ) return false;
1091 if( m_stackup != aOther.m_stackup ) return false;
1092 if( *m_NetSettings != *aOther.m_NetSettings ) return false;
1093 if( *m_Pad_Master != *aOther.m_Pad_Master ) return false;
1094 if( m_defaultZoneSettings != aOther.m_defaultZoneSettings ) return false;
1095
1096 if( m_StyleFPFields != aOther.m_StyleFPFields ) return false;
1097 if( m_StyleFPText != aOther.m_StyleFPText ) return false;
1098 if( m_StyleFPShapes != aOther.m_StyleFPShapes ) return false;
1099
1100 return true;
1101}
1102
1103
1105{
1123 std::string units_ptr( "defaults.dimension_units" );
1124 std::string precision_ptr( "defaults.dimension_precision" );
1125
1126 if( !( Contains( units_ptr ) && Contains( precision_ptr ) &&
1127 At( units_ptr ).is_number_integer() &&
1128 At( precision_ptr ).is_number_integer() ) )
1129 {
1130 // if either is missing or invalid, migration doesn't make sense
1131 return true;
1132 }
1133
1134 int units = *Get<int>( units_ptr );
1135 int precision = *Get<int>( precision_ptr );
1136
1137 // The enum maps directly to precision if the units is mils
1138 int extraDigits = 0;
1139
1140 switch( units )
1141 {
1142 case 0: extraDigits = 3; break;
1143 case 2: extraDigits = 2; break;
1144 default: break;
1145 }
1146
1147 precision += extraDigits;
1148
1149 Set( precision_ptr, precision );
1150
1151 return true;
1152}
1153
1154
1155bool BOARD_DESIGN_SETTINGS::LoadFromFile( const wxString& aDirectory )
1156{
1157 bool ret = NESTED_SETTINGS::LoadFromFile( aDirectory );
1158
1159 // A number of things won't have been translated by the PROJECT_FILE migration because of
1160 // descoped objects required to decode this data. So, it will be in the legacy.pcbnew
1161 // section and needs to be pulled out here
1162
1163 PROJECT_FILE* project = dynamic_cast<PROJECT_FILE*>( GetParent() );
1164
1165 if( !project )
1166 return ret;
1167
1168 bool migrated = false;
1169
1170 auto drcName =
1171 []( int aCode ) -> std::string
1172 {
1173 std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( aCode );
1174 wxString name = item->GetSettingsKey();
1175 return std::string( name.ToUTF8() );
1176 };
1177
1178 const std::string rs = "rule_severities.";
1179 const std::string no_courtyard_key = "legacy_no_courtyard_defined";
1180 const std::string courtyard_overlap_key = "legacy_courtyards_overlap";
1181
1182 try
1183 {
1184 nlohmann::json& severities =
1185 project->Internals()->at( "/board/design_settings/rule_severities"_json_pointer );
1186
1187 if( severities.contains( no_courtyard_key ) )
1188 {
1189 if( severities[no_courtyard_key].get<bool>() )
1190 Set( rs + drcName( DRCE_MISSING_COURTYARD ), "error" );
1191 else
1192 Set( rs + drcName( DRCE_MISSING_COURTYARD ), "ignore" );
1193
1194 severities.erase( no_courtyard_key );
1195 migrated = true;
1196 }
1197
1198 if( severities.contains( courtyard_overlap_key ) )
1199 {
1200 if( severities[courtyard_overlap_key].get<bool>() )
1201 Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "error" );
1202 else
1203 Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "ignore" );
1204
1205 severities.erase( courtyard_overlap_key );
1206 migrated = true;
1207 }
1208 }
1209 catch( ... )
1210 {
1211 }
1212 if( Contains( "legacy" ) )
1213 {
1214 // This defaults to false for new boards, but version 5.1.x and prior kept the fillets
1215 // so we do the same for legacy boards.
1217
1218 project->At( "legacy" ).erase( "pcbnew" );
1219 }
1220
1221 // Now that we have everything, we need to load again
1222 if( migrated )
1223 Load();
1224
1225 return ret;
1226}
1227
1228
1230{
1231 return m_DRCSeverities[ aDRCErrorCode ];
1232}
1233
1234
1235bool BOARD_DESIGN_SETTINGS::Ignore( int aDRCErrorCode )
1236{
1237 return m_DRCSeverities[ aDRCErrorCode ] == RPT_SEVERITY_IGNORE;
1238}
1239
1240
1242{
1243 int biggest = std::max( m_MinClearance, m_HoleClearance );
1244 DRC_CONSTRAINT constraint;
1245
1246 biggest = std::max( biggest, m_HoleToHoleMin );
1247 biggest = std::max( biggest, m_CopperEdgeClearance );
1248
1249 if( m_DRCEngine )
1250 {
1251 m_DRCEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, constraint );
1252 biggest = std::max( biggest, constraint.Value().Min() );
1253
1254 m_DRCEngine->QueryWorstConstraint( HOLE_CLEARANCE_CONSTRAINT, constraint );
1255 biggest = std::max( biggest, constraint.Value().Min() );
1256
1257 m_DRCEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, constraint );
1258 biggest = std::max( biggest, constraint.Value().Min() );
1259
1260 m_DRCEngine->QueryWorstConstraint( HOLE_TO_HOLE_CONSTRAINT, constraint );
1261 biggest = std::max( biggest, constraint.Value().Min() );
1262 }
1263
1264 return biggest;
1265}
1266
1267
1269{
1270 int clearance = m_NetSettings->m_DefaultNetClass->GetClearance();
1271
1272 for( const auto& [ name, netclass ] : m_NetSettings->m_NetClasses )
1273 clearance = std::min( clearance, netclass->GetClearance() );
1274
1275 return clearance;
1276}
1277
1278
1280{
1281 m_viaSizeIndex = std::min( aIndex, (unsigned) m_ViasDimensionsList.size() );
1282 m_useCustomTrackVia = false;
1283}
1284
1285
1287{
1290 else if( m_viaSizeIndex == 0 )
1291 return m_NetSettings->m_DefaultNetClass->GetViaDiameter();
1292 else
1293 return m_ViasDimensionsList[ m_viaSizeIndex ].m_Diameter;
1294}
1295
1296
1298{
1299 int drill;
1300
1302 drill = m_customViaSize.m_Drill;
1303 else if( m_viaSizeIndex == 0 )
1304 drill = m_NetSettings->m_DefaultNetClass->GetViaDrill();
1305 else
1306 drill = m_ViasDimensionsList[ m_viaSizeIndex ].m_Drill;
1307
1308 return drill > 0 ? drill : -1;
1309}
1310
1311
1313{
1314 m_trackWidthIndex = std::min( aIndex, (unsigned) m_TrackWidthList.size() );
1315 m_useCustomTrackVia = false;
1316}
1317
1318
1320{
1322 return m_customTrackWidth;
1323 else if( m_trackWidthIndex == 0 )
1324 return m_NetSettings->m_DefaultNetClass->GetTrackWidth();
1325 else
1327}
1328
1329
1331{
1332 if( !m_DiffPairDimensionsList.empty() )
1333 {
1334 m_diffPairIndex = std::min( aIndex,
1335 static_cast<unsigned>( m_DiffPairDimensionsList.size() ) - 1 );
1336 }
1337
1338 m_useCustomDiffPair = false;
1339}
1340
1341
1343{
1345 {
1347 }
1348 else if( m_diffPairIndex == 0 )
1349 {
1350 if( m_NetSettings->m_DefaultNetClass->HasDiffPairWidth() )
1351 return m_NetSettings->m_DefaultNetClass->GetDiffPairWidth();
1352 else
1353 return m_NetSettings->m_DefaultNetClass->GetTrackWidth();
1354 }
1355 else
1356 {
1358 }
1359}
1360
1361
1363{
1365 {
1366 return m_customDiffPair.m_Gap;
1367 }
1368 else if( m_diffPairIndex == 0 )
1369 {
1370 if( m_NetSettings->m_DefaultNetClass->HasDiffPairGap() )
1371 return m_NetSettings->m_DefaultNetClass->GetDiffPairGap();
1372 else
1373 return m_NetSettings->m_DefaultNetClass->GetClearance();
1374 }
1375 else
1376 {
1378 }
1379}
1380
1381
1383{
1385 {
1387 }
1388 else if( m_diffPairIndex == 0 )
1389 {
1390 if( m_NetSettings->m_DefaultNetClass->HasDiffPairViaGap() )
1391 return m_NetSettings->m_DefaultNetClass->GetDiffPairViaGap();
1392 else
1393 return GetCurrentDiffPairGap();
1394 }
1395 else
1396 {
1398 }
1399}
1400
1401
1403{
1404 m_copperLayerCount = aNewLayerCount;
1405
1406 // Update only enabled copper layers mask
1407 m_enabledLayers &= ~LSET::AllCuMask();
1408
1409 if( aNewLayerCount > 0 )
1410 m_enabledLayers |= LSET::AllCuMask( aNewLayerCount );
1411}
1412
1413
1415{
1416 // Back and front layers are always enabled.
1417 aMask.set( B_Cu ).set( F_Cu );
1418
1419 m_enabledLayers = aMask;
1420
1421 // update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
1422 m_copperLayerCount = ( aMask & LSET::AllCuMask() ).count();
1423}
1424
1425
1426// Return the layer class index { silk, copper, edges & courtyards, fab, others } of the
1427// given layer.
1429{
1430 if( aLayer == F_SilkS || aLayer == B_SilkS )
1431 return LAYER_CLASS_SILK;
1432 else if( IsCopperLayer( aLayer ) )
1433 return LAYER_CLASS_COPPER;
1434 else if( aLayer == Edge_Cuts )
1435 return LAYER_CLASS_EDGES;
1436 else if( aLayer == F_CrtYd || aLayer == B_CrtYd )
1437 return LAYER_CLASS_COURTYARD;
1438 else if( aLayer == F_Fab || aLayer == B_Fab )
1439 return LAYER_CLASS_FAB;
1440 else
1441 return LAYER_CLASS_OTHERS;
1442}
1443
1444
1446{
1447 return pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_DRCEpsilon );
1448}
1449
1450
1452{
1453 return pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_HoleWallThickness );
1454}
1455
1456
1458{
1459 return m_LineThickness[ GetLayerClass( aLayer ) ];
1460}
1461
1462
1464{
1465 return m_TextSize[ GetLayerClass( aLayer ) ];
1466}
1467
1468
1470{
1471 return m_TextThickness[ GetLayerClass( aLayer ) ];
1472}
1473
1474
1476{
1477 return m_TextItalic[ GetLayerClass( aLayer ) ];
1478}
1479
1480
1482{
1483 return m_TextUpright[ GetLayerClass( aLayer ) ];
1484}
1485
1487{
1488 m_Pad_Master.get()->SetSizeX( pcbIUScale.mmToIU( DEFAULT_PAD_WIDTH_MM ) );
1490 m_Pad_Master.get()->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
1491 m_Pad_Master.get()->SetDrillSize(
1493 m_Pad_Master.get()->SetShape( PAD_SHAPE::ROUNDRECT );
1494 m_Pad_Master.get()->SetRoundRectCornerRadius(
1496}
const char * name
Definition: DXF_plotter.cpp:57
constexpr int ARC_HIGH_DEF
Definition: base_units.h:120
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
const int bdsSchemaVersion
#define DEFAULT_MICROVIASMINDRILL
#define DEFAULT_SOLDERPASTE_CLEARANCE
#define DEFAULT_SOLDERPASTE_RATIO
#define DEFAULT_CUSTOMDPAIRWIDTH
#define DEFAULT_DP_MEANDER_SPACING
#define DEFAULT_PAD_WIDTH_MM
#define DEFAULT_VIASMINSIZE
#define DEFAULT_PAD_DRILL_DIAMETER_MM
#define DEFAULT_TEXT_WIDTH
#define DEFAULT_COPPER_TEXT_WIDTH
#define DEFAULT_CUSTOMDPAIRGAP
#define DEFAULT_MINCLEARANCE
#define DEFAULT_HOLECLEARANCE
#define DEFAULT_SOLDERMASK_EXPANSION
@ LAYER_CLASS_OTHERS
@ LAYER_CLASS_FAB
@ LAYER_CLASS_COURTYARD
@ LAYER_CLASS_SILK
@ LAYER_CLASS_COPPER
@ LAYER_CLASS_EDGES
#define DEFAULT_SOLDERMASK_MIN_WIDTH
#define DEFAULT_DIMENSION_EXTENSION_OFFSET
#define DEFAULT_PAD_REACT_RADIUS
#define DEFAULT_COPPEREDGECLEARANCE
#define DEFAULT_PAD_HEIGTH_MM
#define DEFAULT_DIMENSION_ARROW_LENGTH
#define DEFAULT_TRACKMINWIDTH
#define DEFAULT_MINTHROUGHDRILL
#define DEFAULT_SILK_TEXT_SIZE
#define DEFAULT_HOLETOHOLEMIN
#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_TEXT_SIZE
#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.
Container for design settings for a BOARD object.
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
int GetHolePlatingThickness() const
Pad & via drills are finish size.
VIATYPE m_CurrentViaType
(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
void SetDiffPairIndex(unsigned aIndex)
std::shared_ptr< NET_SETTINGS > m_NetSettings
bool operator==(const BOARD_DESIGN_SETTINGS &aOther) const
std::map< wxString, wxString > m_DrcExclusionComments
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
wxString m_currentNetClassName
Current net class name used to display netclass info.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
void SetEnabledLayers(LSET aMask)
Change the bit-mask of enabled layers to aMask.
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
std::set< wxString > m_DrcExclusions
bool Ignore(int aDRCErrorCode)
Return true if the DRC error code's severity is SEVERITY_IGNORE.
std::unique_ptr< PAD > m_Pad_Master
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
TEARDROP_PARAMETERS_LIST m_TeardropParamsList
The parameters of teardrops for the different teardrop targets (via/pad, track end) 3 set of paramete...
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
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.
bool LoadFromFile(const wxString &aDirectory="") override
Loads the backing file from disk and then calls Load()
PNS::MEANDER_SETTINGS m_SingleTrackMeanderSettings
int m_TextThickness[LAYER_CLASS_COUNT]
ZONE_SETTINGS m_defaultZoneSettings
The default settings that will be used for new zones.
SEVERITY GetSeverity(int aDRCErrorCode)
std::vector< int > m_TrackWidthList
DIFF_PAIR_DIMENSION m_customDiffPair
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]
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.
DIM_UNITS_MODE m_DimensionUnitsMode
std::vector< VIA_DIMENSION > m_ViasDimensionsList
BOARD_DESIGN_SETTINGS & operator=(const BOARD_DESIGN_SETTINGS &aOther)
MINOPTMAX< int > & Value()
Definition: drc_rule.h:142
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
Definition: drc_item.h:123
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:331
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::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
void ReleaseNestedSettings(NESTED_SETTINGS *aSettings)
Saves and frees a nested settings object, if it exists within this one.
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: layer_ids.h:574
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
T Min() const
Definition: minoptmax.h:33
NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS.
JSON_SETTINGS * GetParent()
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.
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:226
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:293
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:390
Dimensions for the meandering algorithm.
Definition: pns_meander.h:68
int m_minAmplitude
Maximum meandering amplitude.
Definition: pns_meander.h:82
int m_cornerRadiusPercentage
Place meanders on one side.
Definition: pns_meander.h:108
bool m_singleSided
Initial side when placing meanders at segment.
Definition: pns_meander.h:111
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
Definition: pns_meander.h:105
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
Definition: pns_meander.h:85
int m_spacing
Amplitude/spacing adjustment step.
Definition: pns_meander.h:88
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:70
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:79
bool m_TargetPadsWithNoHole
True to create teardrops for pads without holes (SMD and others.
bool m_TargetViasPads
True to create teardrops for vias and pads with holes.
bool m_UseRoundShapesOnly
True to create teardrops for round shapes only.
bool m_TargetTrack2Track
True to create teardrops at the end of a track connected to the end of another track having a differe...
TEARDROP_PARAMETERS * GetParameters(TARGET_TD aTdType)
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
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.
@ DRCE_SILK_EDGE_CLEARANCE
Definition: drc_item.h:91
@ DRCE_PADSTACK
Definition: drc_item.h:59
@ DRCE_LIB_FOOTPRINT_ISSUES
Definition: drc_item.h:77
@ DRCE_OVERLAPPING_FOOTPRINTS
Definition: drc_item.h:61
@ DRCE_OVERLAPPING_SILK
Definition: drc_item.h:94
@ DRCE_MISSING_COURTYARD
Definition: drc_item.h:62
@ DRCE_ISOLATED_COPPER
Definition: drc_item.h:47
@ DRCE_COPPER_SLIVER
Definition: drc_item.h:85
@ DRCE_PTH_IN_COURTYARD
Definition: drc_item.h:65
@ DRCE_FIRST
Definition: drc_item.h:38
@ DRCE_DANGLING_VIA
Definition: drc_item.h:49
@ DRCE_FOOTPRINT_TYPE_MISMATCH
Definition: drc_item.h:76
@ DRCE_DUPLICATE_FOOTPRINT
Definition: drc_item.h:71
@ DRCE_DANGLING_TRACK
Definition: drc_item.h:50
@ DRCE_TEXT_HEIGHT
Definition: drc_item.h:92
@ DRCE_DRILLED_HOLES_COLOCATED
Definition: drc_item.h:52
@ DRCE_EXTRA_FOOTPRINT
Definition: drc_item.h:72
@ DRCE_SILK_CLEARANCE
Definition: drc_item.h:89
@ DRCE_LAST
Definition: drc_item.h:102
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition: drc_item.h:78
@ DRCE_NET_CONFLICT
Definition: drc_item.h:73
@ DRCE_MISSING_FOOTPRINT
Definition: drc_item.h:70
@ DRCE_TEXT_THICKNESS
Definition: drc_item.h:93
@ DRCE_NPTH_IN_COURTYARD
Definition: drc_item.h:66
@ DRCE_CONNECTION_WIDTH
Definition: drc_item.h:56
@ DRCE_SCHEMATIC_PARITY_ISSUES
Definition: drc_item.h:74
@ EDGE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:50
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:47
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:48
@ HOLE_TO_HOLE_CONSTRAINT
Definition: drc_rule.h:49
#define TEXT_MIN_SIZE_MM
Minimum text size (1 micron).
Definition: eda_text.h:45
#define TEXT_MAX_SIZE_MM
Maximum text size in mm (~10 inches)
Definition: eda_text.h:46
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:880
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_CrtYd
Definition: layer_ids.h:117
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_Cu
Definition: layer_ids.h:95
@ F_Fab
Definition: layer_ids.h:120
@ F_SilkS
Definition: layer_ids.h:104
@ B_CrtYd
Definition: layer_ids.h:116
@ B_SilkS
Definition: layer_ids.h:103
@ F_Cu
Definition: layer_ids.h:64
@ B_Fab
Definition: layer_ids.h:119
@ MEANDER_STYLE_ROUND
Definition: pns_meander.h:52
@ MEANDER_STYLE_CHAMFER
Definition: pns_meander.h:53
@ PAD_DRILL_SHAPE_CIRCLE
Definition: pad_shapes.h:54
SEVERITY
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE
Container to handle a stock of specific differential pairs each with unique track width,...
constexpr double IUTomm(int iu) const
Definition: base_units.h:86
const double IU_PER_MM
Definition: base_units.h:76
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
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
std::string GetTeardropTargetCanonicalName(TARGET_TD aTdType)
TARGET_TD GetTeardropTargetTypeFromCanonicalName(const std::string &aTargetName)
wxString SeverityToString(const SEVERITY &aSeverity)
Definition: ui_common.cpp:63
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
#define ZONE_CLEARANCE_MM
Definition: zones.h:37