KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_constraint_rules.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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
21
22#include <map>
23
25
26#include <board.h>
28#include <netclass.h>
29#include <pcb_edit_frame.h>
30#include <project.h>
33#include <bitmaps.h>
36#include <wx/hyperlink.h>
37#include <widgets/ui_common.h>
38#include <wx/scrolwin.h>
39#include <wx/sizer.h>
40#include <wx/statline.h>
41#include <wx/stattext.h>
42#include <wx/textctrl.h>
43
45
46
48 DRC_RULE_DOCUMENT* aDocument,
49 BOARD_DESIGN_SETTINGS& aSettings,
50 const CONSTRAINT_SECTION& aSection ) :
51 wxPanel( aParent, wxID_ANY ),
52 m_frame( aFrame ),
53 m_settings( &aSettings ),
54 m_document( aDocument ),
55 m_section( aSection ),
56 m_note( nullptr ),
57 m_defaultsNote( nullptr ),
58 m_validationTimer( this ),
59 m_list( nullptr )
60{
61 wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
62
63 m_scrolled = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
64 m_scrolled->SetScrollRate( 0, 10 );
65 m_scrolled->SetSizer( new wxBoxSizer( wxVERTICAL ) );
66
68
69 mainSizer->Add( m_scrolled, 1, wxEXPAND );
70 SetSizer( mainSizer );
71
72 m_scrolled->Bind( wxEVT_SIZE,
73 [this]( wxSizeEvent& aEvent )
74 {
75 wrapLabels();
76 aEvent.Skip();
77 } );
78
79 Bind(
80 wxEVT_TIMER,
81 [this]( wxTimerEvent& )
82 {
84 },
85 m_validationTimer.GetId() );
86}
87
88
90{
91 wxSizer* box = m_scrolled->GetSizer();
92 wxWindow* parent = m_scrolled;
93 wxStaticText* heading = new wxStaticText( parent, wxID_ANY, m_section.title );
94 wxBoxSizer* settings = new wxBoxSizer( wxVERTICAL );
95
96 heading->SetFont( heading->GetFont().Bold() );
97 box->Add( heading, 0, wxLEFT | wxTOP | wxBOTTOM, 8 );
98 box->Add( settings, 0, wxEXPAND | wxLEFT, 8 );
99
100 if( !m_section.defaults.empty() )
101 {
102 wxFlexGridSizer* grid = new wxFlexGridSizer( 0, 3, 4, 8 );
103
104 for( const CONSTRAINT_DEFAULT_FIELD& field : m_section.defaults )
105 {
106 wxStaticText* label = new wxStaticText( parent, wxID_ANY, field.label );
107 wxTextCtrl* value = new wxTextCtrl( parent, wxID_ANY );
108 wxStaticText* units = new wxStaticText( parent, wxID_ANY, wxEmptyString );
109
110 label->SetFont( KIUI::GetInfoFont( this ) );
111 units->SetFont( KIUI::GetInfoFont( this ) );
112
113 // Room for the longest value the field takes, in any of the units it can be shown in
114 value->SetMinSize( wxSize( KIUI::GetTextSize( wxT( "XXXXXXXXXX" ), value ).x, -1 ) );
115
116 grid->Add( label, 0, wxALIGN_CENTER_VERTICAL );
117 grid->Add( value, 0, wxALIGN_CENTER_VERTICAL );
118 grid->Add( units, 0, wxALIGN_CENTER_VERTICAL );
119
120 DEFAULT_FIELD entry;
121 entry.settingName = field.settingName;
122 entry.member = field.member;
123 entry.ctrl = value;
124 entry.warning = new FIELD_WARNING_ICON( value );
125 entry.binder = std::make_unique<UNIT_BINDER>( m_frame, label, value, units );
126
127 // UNIT_BINDER leaves an unscaled field alone through a change of units
128 if( field.value == CONSTRAINT_VALUE::COUNT )
130
131 // Debounced so a half-typed value does not flash a warning
132 value->Bind( wxEVT_TEXT,
133 [this]( wxCommandEvent& aEvent )
134 {
135 m_validationTimer.StartOnce( 250 );
136 aEvent.Skip();
137 } );
138
139 m_defaults.push_back( std::move( entry ) );
140 }
141
142 settings->Add( grid, 0, wxEXPAND | wxALL, 5 );
143
144 if( m_section.ruleType )
145 {
146 m_defaultsNoteText = _( "Used where no rule below matches. Kept with the board, not in the "
147 "rules file." );
148
149 m_defaultsNote = new wxStaticText( parent, wxID_ANY, m_defaultsNoteText );
150 m_defaultsNote->SetFont( KIUI::GetInfoFont( this ).Italic() );
151 settings->Add( m_defaultsNote, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
152 }
153 }
154
155 if( m_section.ruleType )
156 {
157 if( !m_section.defaults.empty() )
158 box->Add( new wxStaticLine( parent ), 0, wxEXPAND | wxLEFT | wxRIGHT, 5 );
159
160 if( !m_section.defaults.empty() || m_section.netclassValue )
161 {
162 wxBoxSizer* row = new wxBoxSizer( wxHORIZONTAL );
163
164 if( !m_section.defaults.empty() )
165 {
166 wxStaticText* rules = new wxStaticText( parent, wxID_ANY, _( "Rules" ) );
167
168 rules->SetFont( rules->GetFont().Bold() );
169 row->Add( rules, 0, wxALIGN_CENTER_VERTICAL );
170 }
171
172 row->AddStretchSpacer();
173
174 if( m_section.netclassValue )
175 {
176 wxHyperlinkCtrl* link = new wxHyperlinkCtrl( parent, wxID_ANY, _( "Edit net classes" ), wxEmptyString );
177
178 link->SetFont( KIUI::GetInfoFont( this ) );
179 link->Bind( wxEVT_HYPERLINK,
180 [this]( wxHyperlinkEvent& )
181 {
182 showPage( _( "Net Classes" ) );
183 } );
184
185 row->Add( link, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 12 );
186 }
187
188 box->Add( row, 0, wxEXPAND | wxLEFT | wxTOP, 8 );
189 }
190
191 m_noteText = _( "The rules below are read from top to bottom and the last one that matches "
192 "decides the value. A value a net class sets is read before any of them." );
193
194 m_note = new wxStaticText( parent, wxID_ANY, m_noteText );
195 m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
196 box->Add( m_note, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 8 );
197
199 new CONSTRAINT_RULES_LIST( parent, m_frame, m_document, *m_section.ruleType, m_section.title );
200 list->SetTitleWindow( heading );
201
202 if( !m_section.defaults.empty() )
203 {
204 std::vector<std::pair<wxString, std::function<wxString()>>> defaults;
205
206 for( size_t d = 0; d < m_section.defaults.size(); ++d )
207 {
208 // One default is named by its section; several each need their own name
209 wxString name = m_section.title;
210
211 if( m_section.defaults.size() > 1 )
212 {
213 name = m_section.defaults[d].label;
214
215 if( name.EndsWith( wxS( ":" ) ) )
216 name.RemoveLast();
217 }
218
219 // Read on demand, since a note quoting a default is rebuilt as the default is typed
220 defaults.emplace_back( name,
221 [this, d]()
222 {
223 return m_frame->StringFromValue( m_defaults[d].binder->GetValue(), true );
224 } );
225 }
226
227 list->SetDefaults( std::move( defaults ) );
228 }
229
230 if( m_section.netclassValue )
231 list->SetNetclasses( m_section.netclassValue, m_section.netclassPart );
232
233 list->SetChangeCallback(
234 [this]()
235 {
237 } );
238 box->Add( list, 1, wxEXPAND | wxALL, 8 );
239 m_list = list;
240 }
241}
242
243
244void PANEL_SETUP_CONSTRAINT_RULES::showPage( const wxString& aTitle )
245{
246 if( PAGED_DIALOG* dialog = PAGED_DIALOG::GetDialog( this ) )
247 dialog->ShowPage( aTitle );
248}
249
250
252{
253 // The page has not been laid out yet while it is this narrow
254 if( m_scrolled->GetClientSize().x - 180 < 200 )
255 return;
256
257 for( const auto& [label, text] :
258 { std::pair{ m_note, m_noteText }, std::pair{ m_defaultsNote, m_defaultsNoteText } } )
259 {
260 if( label )
261 {
262 label->SetLabel( text );
263 label->Wrap( GetClientSize().x - 32 );
264 }
265 }
266
267 m_scrolled->Layout();
268 m_scrolled->FitInside();
269 m_scrolled->Layout();
270}
271
272
274{
275 for( DEFAULT_FIELD& field : m_defaults )
276 {
277 field.loaded = m_settings->*( field.member );
278 field.binder->SetValue( field.loaded );
279 }
280
282}
283
284
286{
287 if( m_defaults.empty() )
288 return true;
289
290 BOARD_DESIGN_SETTINGS candidate( *m_settings );
291
292 writeDefaults( candidate );
293
294 // A page reports only the values it edits; the rest are reported where they are edited.
296 candidate.ValidateDesignRules( m_frame->GetUserUnits() ) )
297 {
298 for( const DEFAULT_FIELD& field : m_defaults )
299 {
300 if( field.settingName != error.setting_name )
301 continue;
302
303 if( PAGED_DIALOG* dialog = PAGED_DIALOG::GetDialog( this ) )
304 dialog->SetError( error.error_message, this, field.ctrl );
305
306 return false;
307 }
308 }
309
310 // The same value may be set on another page too, so a field the user did not touch here
311 // must not write back over an edit made there
312 for( DEFAULT_FIELD& field : m_defaults )
313 {
314 int value = field.binder->GetValue();
315
316 if( value != field.loaded )
317 {
318 m_settings->*( field.member ) = value;
319 field.loaded = value;
320 }
321 }
322
323 return true;
324}
325
326
328{
329 for( const DEFAULT_FIELD& field : m_defaults )
330 aSettings.*( field.member ) = field.binder->GetValue();
331}
332
333
335{
336 m_validationTimer.Stop();
337
338 if( m_defaults.empty() )
339 return;
340
341 // A warning can weigh two defaults against each other, and the page holding the other one
342 // wrote it to the board on its way out.
343 BOARD_DESIGN_SETTINGS candidate( *m_settings );
344
345 writeDefaults( candidate );
346
347 EDA_UNITS units = m_frame->GetUserUnits();
348 std::map<wxString, wxString> messages;
349
350 for( const std::vector<BOARD_DESIGN_SETTINGS::VALIDATION_ERROR>& issues :
351 { candidate.ValidateDesignRules( units ), candidate.GetDesignRuleWarnings( units ) } )
352 {
353 for( const BOARD_DESIGN_SETTINGS::VALIDATION_ERROR& issue : issues )
354 {
355 wxString& msg = messages[issue.setting_name];
356
357 if( !msg.IsEmpty() )
358 msg += wxS( "\n" );
359
360 msg += issue.error_message;
361 }
362 }
363
364 for( const DEFAULT_FIELD& field : m_defaults )
365 {
366 auto it = messages.find( field.settingName );
367
368 field.warning->SetWarning( it != messages.end() ? it->second : wxString() );
369 }
370
371 // A note on an open rule quotes the default, so it is rebuilt as the default is typed.
372 if( m_list )
373 m_list->RefreshOverrideNote();
374}
375
376
378{
379 return !m_list || m_list->ConfirmPendingRule();
380}
381
382
387
388
393
394
401
402
403static wxString importGroup( const CONSTRAINT_SECTION& aSection )
404{
405 return aSection.settingsPage.IsEmpty() ? _( "Constraints" ) : aSection.settingsPage;
406}
407
408
410{
411 return importGroup( m_section );
412}
413
414
416{
417 if( m_list )
418 m_list->RefreshRules();
419}
420
421
422std::vector<std::pair<wxString, CONSTRAINT_DEFAULT_FIELD>> PANEL_SETUP_CONSTRAINT_RULES::EditedDefaults()
423{
424 std::vector<std::pair<wxString, CONSTRAINT_DEFAULT_FIELD>> fields;
425
428 {
429 for( const CONSTRAINT_SECTION& section : SectionsFor( family ) )
430 {
431 wxString group = importGroup( section );
432
433 for( const CONSTRAINT_DEFAULT_FIELD& field : section.defaults )
434 fields.emplace_back( group, field );
435 }
436 }
437
438 return fields;
439}
440
441
442std::optional<CONSTRAINT_SECTION> PANEL_SETUP_CONSTRAINT_RULES::sectionForSetting( const wxString& aSetting )
443{
446 {
447 for( CONSTRAINT_SECTION& section : SectionsFor( family ) )
448 {
449 for( const CONSTRAINT_DEFAULT_FIELD& field : section.defaults )
450 {
451 if( field.settingName == aSetting )
452 return std::move( section );
453 }
454 }
455 }
456
457 return std::nullopt;
458}
459
460
461bool PANEL_SETUP_CONSTRAINT_RULES::RulesCanOverride( const wxString& aSetting, DRC_CONSTRAINT_T* aConstraint )
462{
463 static const std::map<wxString, DRC_CONSTRAINT_T> constraints = {
464 { wxS( "min_clearance" ), CLEARANCE_CONSTRAINT },
465 { wxS( "min_hole_clearance" ), HOLE_CLEARANCE_CONSTRAINT },
466 { wxS( "min_copper_edge_clearance" ), EDGE_CLEARANCE_CONSTRAINT },
467 { wxS( "min_track_width" ), TRACK_WIDTH_CONSTRAINT },
468 { wxS( "min_connection" ), CONNECTION_WIDTH_CONSTRAINT },
469 { wxS( "min_via_annular_width" ), ANNULAR_WIDTH_CONSTRAINT },
470 { wxS( "min_via_diameter" ), VIA_DIAMETER_CONSTRAINT },
471 { wxS( "min_through_hole_diameter" ), HOLE_SIZE_CONSTRAINT },
472 { wxS( "min_hole_to_hole" ), HOLE_TO_HOLE_CONSTRAINT },
473 { wxS( "min_silk_clearance" ), SILK_CLEARANCE_CONSTRAINT },
474 { wxS( "min_text_height" ), TEXT_HEIGHT_CONSTRAINT },
475 { wxS( "min_silk_line_width" ), LINE_WIDTH_CONSTRAINT },
476 { wxS( "solder_mask_expansion" ), SOLDER_MASK_EXPANSION_CONSTRAINT },
477 { wxS( "solder_mask_min_width" ), SOLDER_MASK_SLIVER_CONSTRAINT },
478 { wxS( "solder_paste_margin" ), SOLDER_PASTE_ABS_MARGIN_CONSTRAINT }
479 };
480
481 auto it = constraints.find( aSetting );
482
483 if( it == constraints.end() )
484 return false;
485
486 if( aConstraint )
487 *aConstraint = it->second;
488
489 return true;
490}
491
492
493wxString PANEL_SETUP_CONSTRAINT_RULES::PageEditingDefault( const wxString& aSetting )
494{
495 std::optional<CONSTRAINT_SECTION> section = sectionForSetting( aSetting );
496
497 return section ? section->title : wxString();
498}
499
500
501void PANEL_SETUP_CONSTRAINT_RULES::LinkToPage( wxWindow* aField, const wxString& aPage, int aSlot )
502{
503 // The link is a sibling of the field rather than a child, so it works whether or not the
504 // field itself is live
506
507 link->SetWarning( wxString::Format( _( "Also on the %s page. Click to open it." ), aPage ) );
508 link->SetCursor( wxCURSOR_HAND );
509 link->Bind( wxEVT_LEFT_DOWN,
510 [aField, aPage]( wxMouseEvent& )
511 {
512 if( PAGED_DIALOG* dialog = PAGED_DIALOG::GetDialog( aField ) )
513 dialog->ShowPage( aPage );
514 } );
515}
516
517
518namespace
519{
520
521std::map<int, std::vector<wxString>> groupByValue( const std::function<std::optional<int>( const NETCLASS& )>& aValue,
522 const NET_SETTINGS& aNetSettings )
523{
524 std::map<int, std::vector<wxString>> byValue;
525
526 auto collect = [&]( const std::shared_ptr<NETCLASS>& aNetclass )
527 {
528 if( !aNetclass )
529 return;
530
531 if( std::optional<int> value = aValue( *aNetclass ) )
532 byValue[*value].push_back( aNetclass->GetName() );
533 };
534
535 collect( aNetSettings.GetDefaultNetclass() );
536
537 for( const auto& [name, netclass] : aNetSettings.GetNetclasses() )
538 collect( netclass );
539
540 return byValue;
541}
542
543} // namespace
544
545
546std::map<int, std::vector<wxString>> PANEL_SETUP_CONSTRAINT_RULES::NetclassValuesFor( const wxString& aSetting,
547 const NET_SETTINGS& aNetSettings )
548{
549 std::optional<CONSTRAINT_SECTION> section = sectionForSetting( aSetting );
550
551 if( !section || !section->netclassValue )
552 return {};
553
554 return groupByValue( section->netclassValue, aNetSettings );
555}
556
557
559{
560 if( m_list && m_section.ruleType == aType )
561 m_list->EditRule( aIndex );
562}
563
564
566{
569 {
570 for( const CONSTRAINT_SECTION& section : SectionsFor( family ) )
571 {
572 if( section.ruleType == aType )
573 return section.title;
574 }
575 }
576
577 return wxEmptyString;
578}
579
580
581std::vector<CONSTRAINT_SECTION> PANEL_SETUP_CONSTRAINT_RULES::SectionsFor( FAMILY aFamily )
582{
583 using BDS = BOARD_DESIGN_SETTINGS;
584
585 auto clearance = []( const NETCLASS& aNetclass )
586 {
587 return aNetclass.GetClearanceOpt();
588 };
589 auto trackWidth = []( const NETCLASS& aNetclass )
590 {
591 return aNetclass.GetTrackWidthOpt();
592 };
593 auto viaDiameter = []( const NETCLASS& aNetclass )
594 {
595 return aNetclass.GetViaDiameterOpt();
596 };
597 auto viaDrill = []( const NETCLASS& aNetclass )
598 {
599 return aNetclass.GetViaDrillOpt();
600 };
601
602 switch( aFamily )
603 {
605 return { { _( "Minimum clearance" ),
606 { { _( "Board default:" ), &BDS::m_MinClearance, wxS( "min_clearance" ) } },
608 clearance },
609 { _( "Copper to hole clearance" ),
610 { { _( "Board default:" ), &BDS::m_HoleClearance, wxS( "min_hole_clearance" ) } },
612 {} },
613 { _( "Copper to edge clearance" ),
614 { { _( "Board default:" ), &BDS::m_CopperEdgeClearance, wxS( "min_copper_edge_clearance" ) } },
616 {} },
617 { _( "Physical clearance" ), {}, PHYSICAL_CLEARANCE, {} },
618 { _( "Creepage distance" ), {}, CREEPAGE_DISTANCE, {} },
619 { _( "Minimum thermal relief spoke count" ),
620 { { _( "Board default:" ), &BDS::m_MinResolvedSpokes, wxS( "min_resolved_spokes" ),
623 {} } };
624
626 return { { _( "Minimum track width" ),
627 { { _( "Board default:" ), &BDS::m_TrackMinWidth, wxS( "min_track_width" ) } },
629 trackWidth,
630 wxEmptyString,
632 { _( "Minimum connection width" ),
633 { { _( "Board default:" ), &BDS::m_MinConn, wxS( "min_connection" ) } },
635 {} },
636 { _( "Minimum annular width" ),
637 { { _( "Board default:" ), &BDS::m_ViasMinAnnularWidth, wxS( "min_via_annular_width" ) } },
639 {} },
640 { _( "Minimum via diameter" ),
641 { { _( "Board default:" ), &BDS::m_ViasMinSize, wxS( "min_via_diameter" ) },
642 { _( "Microvia default:" ), &BDS::m_MicroViasMinSize, wxS( "min_microvia_diameter" ) } },
644 viaDiameter,
645 wxEmptyString,
647 { _( "Via style" ), {}, VIA_STYLE, {} },
648 { _( "Maximum via count" ), {}, MAXIMUM_VIA_COUNT, {} } };
649
650 case FAMILY::HOLES:
651 return { { _( "Minimum drill size" ),
652 { { _( "Board default:" ), &BDS::m_MinThroughDrill, wxS( "min_through_hole_diameter" ) },
653 { _( "Microvia default:" ), &BDS::m_MicroViasMinDrill, wxS( "min_microvia_drill" ) } },
655 viaDrill,
656 wxEmptyString,
658 { _( "Hole size" ), {}, HOLE_SIZE, {} },
659 { _( "Hole to hole clearance" ),
660 { { _( "Board default:" ), &BDS::m_HoleToHoleMin, wxS( "min_hole_to_hole" ) } },
662 {} },
663 { _( "Microvia stack depth" ), {}, MICROVIA_STACK_DEPTH, {} },
664 { _( "Hole aspect ratio" ), {}, HOLE_ASPECT_RATIO, {} } };
665
667 return { { _( "Silk to silk clearance" ),
668 { { _( "Board default:" ), &BDS::m_SilkClearance, wxS( "min_silk_clearance" ) } },
670 {} },
671 { _( "Minimum text height and thickness" ),
672 { { _( "Minimum text height:" ), &BDS::m_MinSilkTextHeight, wxS( "min_text_height" ) },
673 { _( "Minimum line width:" ), &BDS::m_MinSilkLineWidth, wxS( "min_silk_line_width" ) } },
675 {} },
676 { _( "Silk to solder mask clearance" ), {}, SILK_TO_SOLDERMASK_CLEARANCE, {} } };
677
679 return { { _( "Matched length for differential pairs" ), {}, MATCHED_LENGTH_DIFF_PAIR, {} },
680 { _( "Absolute length" ), {}, ABSOLUTE_LENGTH, {} },
681 { _( "Differential pair routing" ), {}, ROUTING_DIFF_PAIR, {} } };
682
684 return { { _( "Solder mask expansion" ),
685 { { _( "Board default:" ), &BDS::m_SolderMaskExpansion, wxS( "solder_mask_expansion" ) } },
687 {},
688 _( "Solder Mask/Paste" ) },
689 { _( "Minimum solder mask sliver" ),
690 { { _( "Board default:" ), &BDS::m_SolderMaskMinWidth, wxS( "solder_mask_min_width" ) } },
692 {},
693 _( "Solder Mask/Paste" ) },
694 { _( "Solder paste expansion" ),
695 { { _( "Board default:" ), &BDS::m_SolderPasteMargin, wxS( "solder_paste_margin" ) } },
697 {},
698 _( "Solder Mask/Paste" ) } };
699
701 return { { _( "Permitted layers" ), {}, PERMITTED_LAYERS, {} },
702 { _( "Allowed orientation" ), {}, ALLOWED_ORIENTATION, {} },
703 { _( "Vias under SMD pads" ), {}, VIAS_UNDER_SMD, {} },
704 { _( "Courtyard clearance" ), {}, COURTYARD_CLEARANCE, {} } };
705 }
706
707 return {};
708}
const char * name
@ small_new_window
Container for design settings for a BOARD object.
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.
std::vector< VALIDATION_ERROR > ValidateDesignRules(std::optional< EDA_UNITS > aUnits=std::nullopt) const
Validate design settings values and return per-field errors.
The rules of one constraint type, in evaluation order, with an editor that opens in place.
The custom rules of one board, held in memory while Board Setup is open.
A warning icon drawn inside the right edge of a field, left of its dropdown button when it has one,...
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:44
NET_SETTINGS stores various net-related settings in a project context.
const std::map< wxString, std::shared_ptr< NETCLASS > > & GetNetclasses() const
Gets all netclasses.
std::shared_ptr< NETCLASS > GetDefaultNetclass() const
Gets the default netclass for the project.
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
PANEL_SETUP_CONSTRAINT_RULES(wxWindow *aParent, PCB_EDIT_FRAME *aFrame, DRC_RULE_DOCUMENT *aDocument, BOARD_DESIGN_SETTINGS &aSettings, const CONSTRAINT_SECTION &aSection)
static wxString PageEditingDefault(const wxString &aSetting)
The title of the page that edits a board default, or empty where no rule page edits one.
std::vector< DEFAULT_FIELD > m_defaults
static std::vector< CONSTRAINT_SECTION > SectionsFor(FAMILY aFamily)
The sections of one family, in the order they are shown in the tree.
bool Validate() override
The rule form is always on screen, so its fields are empty until a rule is being written.
static bool RulesCanOverride(const wxString &aSetting, DRC_CONSTRAINT_T *aConstraint)
Whether rules can set a value other than this board default, and the DRC constraint that does it.
static wxString PageTitleFor(DRC_RULE_EDITOR_CONSTRAINT_NAME aType)
The title of the page that edits rules of this type, or empty when no page does.
static std::vector< std::pair< wxString, CONSTRAINT_DEFAULT_FIELD > > EditedDefaults()
Every board default a rule page edits, each with the group it is imported with.
bool TransferDataFromWindow() override
Called when the dialog is accepted.
void updateWarnings()
Shows a warning icon, with the reason as its tooltip, over each default whose value has an issue.
wxString ImportGroup() const
The Import Settings group this page's defaults travel with.
static std::map< int, std::vector< wxString > > NetclassValuesFor(const wxString &aSetting, const NET_SETTINGS &aNetSettings)
The net class values set for a constraint, grouped by value so equal classes list together.
bool confirmPendingRule()
Offers what to do with a rule the form holds.
void RefreshDefaults()
Reads the board defaults back into their fields, after something other than this page changed them.
void writeDefaults(BOARD_DESIGN_SETTINGS &aSettings) const
Copies the defaults this page edits into aSettings.
bool applyDefaults()
Writes the default fields to the board, or reports the first value out of range.
static void LinkToPage(wxWindow *aField, const wxString &aPage, int aSlot=1)
Puts a link to another page holding the same value at the field's right edge.
CONSTRAINT_RULES_LIST * m_list
Null until the section is built, and where a section carries no rules of its own.
void ShowRule(DRC_RULE_EDITOR_CONSTRAINT_NAME aType, int aIndex)
Opens one of this page's rules in its editor, when the page holds that rule type.
static std::optional< CONSTRAINT_SECTION > sectionForSetting(const wxString &aSetting)
The section whose board defaults include a setting, where one holds it.
The main frame for Pcbnew.
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
@ ANNULAR_WIDTH_CONSTRAINT
@ VIA_DIAMETER_CONSTRAINT
@ SOLDER_MASK_SLIVER_CONSTRAINT
@ TRACK_WIDTH_CONSTRAINT
@ SILK_CLEARANCE_CONSTRAINT
@ EDGE_CLEARANCE_CONSTRAINT
@ CLEARANCE_CONSTRAINT
@ CONNECTION_WIDTH_CONSTRAINT
@ LINE_WIDTH_CONSTRAINT
@ HOLE_CLEARANCE_CONSTRAINT
@ SOLDER_PASTE_ABS_MARGIN_CONSTRAINT
@ SOLDER_MASK_EXPANSION_CONSTRAINT
@ HOLE_SIZE_CONSTRAINT
@ TEXT_HEIGHT_CONSTRAINT
@ HOLE_TO_HOLE_CONSTRAINT
DRC_RULE_EDITOR_CONSTRAINT_NAME
@ HOLE_ASPECT_RATIO
@ ALLOWED_ORIENTATION
@ SILK_TO_SILK_CLEARANCE
@ ROUTING_DIFF_PAIR
@ SOLDERPASTE_EXPANSION
@ SILK_TO_SOLDERMASK_CLEARANCE
@ VIAS_UNDER_SMD
@ COURTYARD_CLEARANCE
@ MINIMUM_CONNECTION_WIDTH
@ SOLDERMASK_EXPANSION
@ MAXIMUM_VIA_COUNT
@ MINIMUM_ANNULAR_WIDTH
@ PHYSICAL_CLEARANCE
@ CREEPAGE_DISTANCE
@ ABSOLUTE_LENGTH
@ MINIMUM_CLEARANCE
@ MINIMUM_THERMAL_RELIEF_SPOKE_COUNT
@ PERMITTED_LAYERS
@ MICROVIA_STACK_DEPTH
@ MINIMUM_TEXT_HEIGHT_AND_THICKNESS
@ COPPER_TO_HOLE_CLEARANCE
@ HOLE_TO_HOLE_DISTANCE
@ ROUTING_WIDTH
@ MINIMUM_DRILL_SIZE
@ MATCHED_LENGTH_DIFF_PAIR
@ COPPER_TO_EDGE_CLEARANCE
@ MINIMUM_SOLDERMASK_SLIVER
@ MINIMUM_VIA_DIAMETER
#define _(s)
EDA_UNITS
Definition eda_units.h:45
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition ui_common.cpp:80
static wxString importGroup(const CONSTRAINT_SECTION &aSection)
@ OPTIMUM
Asks for a value without raising the minimum, as a net class track width does.
@ COUNT
A plain number, which no change of units rescales.
int BOARD_DESIGN_SETTINGS::* member
One constraint on a Design Rules page: its board default, the net class values that apply to it,...
wxString settingsPage
The group this section's defaults are imported with.
One board default, as this page shows it.
int clearance
Functions to provide common constants and other functions to assist in making a consistent UI.