KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_constraints.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
20#include <algorithm>
21#include <functional>
22#include <map>
23
25#include <board.h>
26#include <math/util.h>
29#include <pcb_edit_frame.h>
36#include <wx/hyperlink.h>
37#include <wx/popupwin.h>
38#include <wx/scrolwin.h>
39#include <wx/settings.h>
40#include <wx/textctrl.h>
41#include <wx/tooltip.h>
42#include <wx/treebook.h>
43#include <bitmaps.h>
44#include <advanced_config.h>
45#include <netclass.h>
46#include <project.h>
49
50
51namespace
52{
53
55constexpr int MAX_POPUP_HEIGHT = 360;
56
58constexpr int MAX_POPUP_WIDTH = 720;
59
61constexpr size_t MAX_NAME_LENGTH = 60;
62
64constexpr int NAME_GAP = 8;
65
66
70class OVERRIDING_RULES_POPUP : public wxPopupTransientWindow
71{
72public:
73 explicit OVERRIDING_RULES_POPUP( wxWindow* aParent ) :
74 wxPopupTransientWindow( aParent, wxBORDER_SIMPLE )
75 {
76 m_panel = new wxPanel( this, wxID_ANY );
77 m_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
78
79 m_scrolled = new wxScrolledWindow( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
80 m_scrolled->SetScrollRate( 0, 10 );
81 m_scrolled->SetBackgroundColour( m_panel->GetBackgroundColour() );
82
83 m_rows = new wxBoxSizer( wxVERTICAL );
84 m_scrolled->SetSizer( m_rows );
85
86 m_outer = new wxBoxSizer( wxVERTICAL );
87 m_outer->Add( m_scrolled, 1, wxEXPAND | wxALL, FromDIP( 8 ) );
88 m_panel->SetSizer( m_outer );
89 }
90
91 void AddHeading( const wxString& aText )
92 {
93 wxStaticText* heading = new wxStaticText( m_scrolled, wxID_ANY, aText );
94
95 heading->SetFont( heading->GetFont().Bold() );
96 m_naturalWidth = std::max( m_naturalWidth, heading->GetTextExtent( aText ).x );
97 m_rows->Add( heading, 0, wxTOP, m_rows->GetItemCount() ? FromDIP( 10 ) : 0 );
98 }
99
101 void AddEntry( const wxString& aName, const wxString& aDetail, std::function<void()> aOpen )
102 {
103 wxBoxSizer* row = new wxBoxSizer( wxHORIZONTAL );
104 wxString name = aName;
105
106 if( name.length() > MAX_NAME_LENGTH )
107 name = name.Left( MAX_NAME_LENGTH ) + wxS( "..." );
108
109 wxHyperlinkCtrl* link = new wxHyperlinkCtrl( m_scrolled, wxID_ANY, name, wxEmptyString );
110
111 if( name != aName )
112 link->SetToolTip( aName );
113
114 link->Bind( wxEVT_HYPERLINK,
115 [this, aOpen]( wxHyperlinkEvent& )
116 {
117 // Dismiss alone skips OnDismiss and would leave the popup alive
118 std::function<void()> open = aOpen;
119 DismissAndNotify();
120 open();
121 } );
122
123 row->Add( link, 0, wxALIGN_CENTER_VERTICAL );
124 row->Add( shortenable( aDetail, link->GetBestSize().x + FromDIP( NAME_GAP ) ), 1,
125 wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP( NAME_GAP ) );
126
127 m_rows->Add( row, 0, wxEXPAND | wxTOP, FromDIP( 3 ) );
128 }
129
131 void AddLink( const wxString& aText, std::function<void()> aOpen )
132 {
133 wxHyperlinkCtrl* link = new wxHyperlinkCtrl( m_scrolled, wxID_ANY, aText, wxEmptyString );
134
135 link->Bind( wxEVT_HYPERLINK,
136 [this, aOpen]( wxHyperlinkEvent& )
137 {
138 std::function<void()> open = aOpen;
139 DismissAndNotify();
140 open();
141 } );
142
143 m_naturalWidth = std::max( m_naturalWidth, link->GetBestSize().x );
144 m_rows->Add( link, 0, wxTOP, m_rows->GetItemCount() ? FromDIP( 10 ) : 0 );
145 }
146
148 void SetOnDismiss( std::function<void()> aFn ) { m_onDismiss = std::move( aFn ); }
149
151 void CloseNow() { DismissAndNotify(); }
152
154 void OnDismiss() override
155 {
156 if( m_onDismiss )
157 m_onDismiss();
158
159 Destroy();
160 }
161
162 void PopupUnder( wxWindow* aAnchor )
163 {
164 int contentHeight = m_rows->GetMinSize().y;
165 int width = std::min( m_naturalWidth, FromDIP( MAX_POPUP_WIDTH ) );
166 int height = contentHeight;
167
168 if( height > FromDIP( MAX_POPUP_HEIGHT ) )
169 {
170 height = FromDIP( MAX_POPUP_HEIGHT );
171 width += wxSystemSettings::GetMetric( wxSYS_VSCROLL_X, m_scrolled );
172 }
173
174 m_scrolled->SetMinSize( wxSize( width, height ) );
175
176 m_outer->Fit( m_panel );
177 SetClientSize( m_panel->GetSize() );
178
179 // Only the list scrolls, and only downwards, so the rows are laid out at the width they
180 // were given and shorten themselves to it.
181 m_scrolled->SetVirtualSize( wxSize( m_scrolled->GetClientSize().x, contentHeight ) );
182 m_scrolled->Layout();
183
184 Position( aAnchor->GetScreenPosition(), wxSize( 0, aAnchor->GetSize().y ) );
185 Popup();
186 }
187
188private:
190 wxStaticText* shortenable( const wxString& aText, int aLeading = 0 )
191 {
192 wxStaticText* line =
193 new wxStaticText( m_scrolled, wxID_ANY, aText, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END );
194
195 // A line that may shorten reports almost no width of its own, so the width it would like
196 // is remembered here and the popup is sized from that instead.
197 m_naturalWidth = std::max( m_naturalWidth, aLeading + line->GetTextExtent( aText ).x );
198
199 line->SetMinSize( wxSize( 1, -1 ) );
200 line->SetToolTip( aText );
201
202 return line;
203 }
204
205 wxPanel* m_panel;
206 wxScrolledWindow* m_scrolled;
207 wxBoxSizer* m_rows;
208 wxBoxSizer* m_outer;
209 int m_naturalWidth = 0;
210
211 std::function<void()> m_onDismiss;
212};
213
214
218void openRuleInEditor( wxWindow* aContext, const wxString& aTitle, DRC_RULE_EDITOR_CONSTRAINT_NAME aType, int aIndex )
219{
220 PAGED_DIALOG* dialog = PAGED_DIALOG::GetDialog( aContext );
221
222 if( !dialog )
223 return;
224
225 if( auto* page = dynamic_cast<PANEL_SETUP_CONSTRAINT_RULES*>( dialog->ShowPage( aTitle ) ) )
226 page->ShowRule( aType, aIndex );
227}
228
229} // namespace
230
231
233 DRC_RULE_DOCUMENT* aDocument, BOARD_DESIGN_SETTINGS& aSettings ) :
234 PANEL_SETUP_CONSTRAINTS_BASE( aParentWindow ),
251 m_document( aDocument ),
252 m_validationTimer( this ),
253 m_hoverTimer( this ),
254 m_closeTimer( this )
255{
256 m_Frame = aFrame;
257 m_BrdSettings = &aSettings;
258
272
273 m_stCircleToPolyWarning->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
274
275 // The spoke count is a spin control, so it is not one of the bound fields below
277
278 wxSize ctrlSize = m_minResolvedSpokeCountCtrl->GetSize();
279 ctrlSize.x = KIUI::GetTextSize( wxT( "XXX" ), m_minResolvedSpokeCountCtrl ).x;
280
281 // The link sits inside the field, and this one is otherwise only as wide as its count
282 if( !m_spokeCountPage.IsEmpty() )
283 ctrlSize.x = m_minResolvedSpokeCountCtrl->GetBestSize().x + FromDIP( 24 );
284
285 m_minResolvedSpokeCountCtrl->SetMinSize( ctrlSize );
286 m_minResolvedSpokeCountCtrl->SetSize( ctrlSize );
287
288 if( !ADVANCED_CFG::GetCfg().m_EnableCreepageSlot )
289 {
290 m_bitmapMinGrooveWidth->Show( false );
291 m_minGrooveWidthLabel->Show( false );
292 m_minGrooveWidthCtrl->Show( false );
293 m_minGrooveWidthUnits->Show( false );
294 }
295
296 using BDS = BOARD_DESIGN_SETTINGS;
297
298 m_fields = {
299 { wxS( "min_clearance" ), m_clearanceCtrl, &m_minClearance, &BDS::m_MinClearance },
300 { wxS( "min_connection" ), m_MinConnCtrl, &m_minConn, &BDS::m_MinConn },
301 { wxS( "min_track_width" ), m_TrackMinWidthCtrl, &m_trackMinWidth, &BDS::m_TrackMinWidth },
302 { wxS( "min_via_annular_width" ), m_ViaMinAnnulusCtrl, &m_viaMinAnnulus, &BDS::m_ViasMinAnnularWidth },
303 { wxS( "min_via_diameter" ), m_SetViasMinSizeCtrl, &m_viaMinSize, &BDS::m_ViasMinSize },
304 { wxS( "min_through_hole_diameter" ), m_MinDrillCtrl, &m_throughHoleMin, &BDS::m_MinThroughDrill },
305 { wxS( "min_microvia_diameter" ), m_uviaMinSizeCtrl, &m_uviaMinSize, &BDS::m_MicroViasMinSize },
306 { wxS( "min_microvia_drill" ), m_uviaMinDrillCtrl, &m_uviaMinDrill, &BDS::m_MicroViasMinDrill },
307 { wxS( "min_hole_to_hole" ), m_SetHoleToHoleCtrl, &m_holeToHoleMin, &BDS::m_HoleToHoleMin },
308 { wxS( "min_hole_clearance" ), m_HoleClearanceCtrl, &m_holeClearance, &BDS::m_HoleClearance },
309 { wxS( "min_silk_clearance" ), m_silkClearanceCtrl, &m_silkClearance, &BDS::m_SilkClearance },
310 { wxS( "min_groove_width" ), m_minGrooveWidthCtrl, &m_minGrooveWidth, &BDS::m_MinGrooveWidth },
311 { wxS( "min_text_height" ), m_textHeightCtrl, &m_minTextHeight, &BDS::m_MinSilkTextHeight },
312 { wxS( "min_silk_line_width" ), m_lineWidthCtrl, &m_minLineWidth, &BDS::m_MinSilkLineWidth },
313 { wxS( "min_copper_edge_clearance" ), m_EdgeClearanceCtrl, &m_edgeClearance, &BDS::m_CopperEdgeClearance },
314 { wxS( "max_error" ), m_maxErrorCtrl, &m_maxError, &BDS::m_MaxError }
315 };
316
317 for( CONSTRAINT_FIELD& field : m_fields )
318 {
319 // Debounced so a half-typed value does not flash a warning
320 field.m_Ctrl->Bind( wxEVT_TEXT,
321 [this]( wxCommandEvent& aEvent )
322 {
323 m_validationTimer.StartOnce( 250 );
324 aEvent.Skip();
325 } );
326
327 // The value stays editable here, so one icon gathers everywhere else it is read from:
328 // the rules written against it, the net classes setting their own, and the rule page
329 bool readElsewhere = !PANEL_SETUP_CONSTRAINT_RULES::PageEditingDefault( field.m_Setting ).IsEmpty()
330 || PANEL_SETUP_CONSTRAINT_RULES::RulesCanOverride( field.m_Setting, nullptr );
331
332 // The icon that is always there holds the field's edge, so it sits clear of the value, and
333 // a warning, which comes and goes, takes the slot beside it
334 field.m_Warning = new FIELD_WARNING_ICON( field.m_Ctrl, BITMAPS::small_warning, readElsewhere ? 1 : 0 );
335
336 if( !readElsewhere )
337 continue;
338
339 field.m_Override = new FIELD_WARNING_ICON( field.m_Ctrl, BITMAPS::small_new_window, 0 );
340 field.m_Override->ShowAsBadge();
341 field.m_Override->SetCursor( wxCURSOR_HAND );
342
343 field.m_Override->Bind( wxEVT_LEFT_DOWN,
344 [this, setting = field.m_Setting, icon = field.m_Override]( wxMouseEvent& )
345 {
346 m_hoverTimer.Stop();
347 showOverridingRules( setting, icon, false );
348 } );
349
350 // Opening on hover as well makes the icon read as a hint rather than a button
351 field.m_Override->Bind( wxEVT_ENTER_WINDOW,
352 [this, setting = field.m_Setting, icon = field.m_Override]( wxMouseEvent& aEvent )
353 {
354 aEvent.Skip();
355
356 if( m_popup && m_popupAnchor == icon )
357 return;
358
359 // The field's own help would otherwise appear over the popup
360 wxToolTip::Enable( false );
361
362 m_hoverSetting = setting;
363 m_hoverAnchor = icon;
364 m_hoverTimer.StartOnce( 400 );
365 } );
366
367 field.m_Override->Bind( wxEVT_LEAVE_WINDOW,
368 [this]( wxMouseEvent& aEvent )
369 {
370 aEvent.Skip();
371 m_hoverTimer.Stop();
372
373 if( !m_popup )
374 wxToolTip::Enable( true );
375 } );
376 }
377
378 if( !m_spokeCountPage.IsEmpty() )
380
381 Bind( wxEVT_TIMER,
382 [this]( wxTimerEvent& )
383 {
385 },
386 m_validationTimer.GetId() );
387
388 Bind(
389 wxEVT_TIMER,
390 [this]( wxTimerEvent& )
391 {
392 if( m_hoverAnchor )
394 },
395 m_hoverTimer.GetId() );
396
397 Bind(
398 wxEVT_TIMER,
399 [this]( wxTimerEvent& )
400 {
402 },
403 m_closeTimer.GetId() );
404}
405
406
408{
409 if( !m_popup || !m_popupFromHover )
410 return;
411
412 // Entering a link inside the popup leaves the popup itself, so ask what is under the pointer
413 // rather than tracking enter and leave across its children
414 wxWindow* under = wxFindWindowAtPoint( wxGetMousePosition() );
415
416 for( wxWindow* w = under; w; w = w->GetParent() )
417 {
418 if( w == m_popup || w == m_popupAnchor )
419 return;
420 }
421
422 static_cast<OVERRIDING_RULES_POPUP*>( m_popup )->CloseNow();
423}
424
425
427{
428 wxString msg;
429 msg.Printf( m_stCircleToPolyWarning->GetLabel(), m_Frame->StringFromValue( ARC_HIGH_DEF, true ) );
430 m_stCircleToPolyWarning->SetLabel( msg );
431
432 m_useHeightForLengthCalcs->SetValue( m_BrdSettings->m_UseHeightForLengthCalcs );
433 m_allowExternalFilletsOpt->SetValue( m_BrdSettings->m_ZoneKeepExternalFillets );
434
435 // Every bound field is read there, which also records what was read
437
438 return true;
439}
440
441
443{
444 // These are all stored in project file, not board, so no need for OnModify()
445
447
448 applyValues( temp );
449
450 std::map<wxString, wxWindow*> fieldToControl = { { wxS( "min_resolved_spokes" ), m_minResolvedSpokeCountCtrl } };
451
452 for( const CONSTRAINT_FIELD& field : m_fields )
453 fieldToControl[field.m_Setting] = field.m_Ctrl;
454
455 for( const BOARD_DESIGN_SETTINGS::VALIDATION_ERROR& error : temp.ValidateDesignRules( m_Frame->GetUserUnits() ) )
456 {
457 auto it = fieldToControl.find( error.setting_name );
458
459 if( it == fieldToControl.end() )
460 continue;
461
462 PAGED_DIALOG::GetDialog( this )->SetError( error.error_message, this, it->second );
463 return false;
464 }
465
466 m_BrdSettings->m_UseHeightForLengthCalcs = m_useHeightForLengthCalcs->GetValue();
467 m_BrdSettings->m_ZoneKeepExternalFillets = m_allowExternalFilletsOpt->GetValue();
468
469 // A constraint can also be set with the rules read against it, so a field the user did not
470 // touch here must not write back over an edit made on that page
472 {
474 m_BrdSettings->m_MinResolvedSpokes = m_spokeCountLoaded;
475 }
476
477 for( CONSTRAINT_FIELD& field : m_fields )
478 {
479 int value = field.m_Binder->GetValue();
480
481 if( value != field.m_Loaded )
482 {
483 field.m_Loaded = value;
484 m_BrdSettings->*( field.m_Member ) = value;
485 }
486 }
487
488 return true;
489}
490
491
493{
496
497 aSettings.m_MinResolvedSpokes = m_minResolvedSpokeCountCtrl->GetValue();
498
499 for( const CONSTRAINT_FIELD& field : m_fields )
500 aSettings.*( field.m_Member ) = field.m_Binder->GetValue();
501}
502
503
505{
506 for( CONSTRAINT_FIELD& field : m_fields )
507 {
508 field.m_Loaded = m_BrdSettings->*( field.m_Member );
509 field.m_Binder->SetValue( field.m_Loaded );
510 }
511
512 m_spokeCountLoaded = m_BrdSettings->m_MinResolvedSpokes;
514
516}
517
518
519void PANEL_SETUP_CONSTRAINTS::showOverridingRules( const wxString& aSetting, wxWindow* aAnchor, bool aFromHover )
520{
521 if( m_popup )
522 static_cast<OVERRIDING_RULES_POPUP*>( m_popup )->CloseNow();
523
525 std::vector<int> indices;
526
527 if( PANEL_SETUP_CONSTRAINT_RULES::RulesCanOverride( aSetting, &constraint ) )
528 indices = m_document->IndicesSetting( constraint );
529
530 const NET_SETTINGS& netSettings = *m_Frame->Prj().GetProjectFile().NetSettings();
531 const std::map<int, std::vector<wxString>> netclasses =
533 const wxString defaultsPage = PANEL_SETUP_CONSTRAINT_RULES::PageEditingDefault( aSetting );
534
535 if( indices.empty() && netclasses.empty() && defaultsPage.IsEmpty() )
536 return;
537
538 OVERRIDING_RULES_POPUP* popup = new OVERRIDING_RULES_POPUP( this );
539
540 if( !indices.empty() && constraint == CLEARANCE_CONSTRAINT )
541 popup->AddHeading( _( "User clearance rules" ) );
542 else if( !indices.empty() )
543 popup->AddHeading( _( "Overridden by user rules" ) );
544
545 static DRC_PANEL_MATCHER matcher;
546
547 for( int index : indices )
548 {
549 const DRC_RE_LOADED_PANEL_ENTRY& entry = m_document->Entries()[index];
550
551 // A rule kept as text is listed on the page of the constraint it sets
553 entry.panelType == CUSTOM_RULE ? matcher.GetHomePanel( constraint ) : entry.panelType;
554 wxString page = PANEL_SETUP_CONSTRAINT_RULES::PageTitleFor( type );
555 wxString value = CONSTRAINT_RULES_LIST::ConstraintText( entry, type, m_Frame );
556 wxString detail;
557
558 if( entry.condition.IsEmpty() && entry.layerSource.IsEmpty() )
559 detail = wxString::Format( _( "%s, everywhere" ), value );
560 else if( entry.condition.IsEmpty() )
561 detail = wxString::Format( _( "%s, on %s" ), value, entry.layerSource );
562 else if( entry.layerSource.IsEmpty() )
563 detail = wxString::Format( _( "%s, where %s" ), value, entry.condition );
564 else
565 detail = wxString::Format( _( "%s, on %s where %s" ), value, entry.layerSource, entry.condition );
566
567 popup->AddEntry( entry.ruleName, detail,
568 [this, page, type, index]()
569 {
570 openRuleInEditor( this, page, type, index );
571 } );
572 }
573
574 // A net class sets its own value instead of displacing the board one, which stays the
575 // minimum, so these are listed apart from the rules. They are all set in one place, so each
576 // row opens that page rather than a class of its own.
577 if( !netclasses.empty() )
578 {
579 popup->AddHeading( _( "Net class values" ) );
580
581 for( const auto& [value, names] : netclasses )
582 {
583 wxString classes;
584
585 for( const wxString& name : names )
586 {
587 if( !classes.IsEmpty() )
588 classes << wxS( ", " );
589
590 classes << name;
591 }
592
593 popup->AddEntry( classes, m_Frame->StringFromValue( value, true ),
594 [this]()
595 {
596 if( PAGED_DIALOG* dialog = PAGED_DIALOG::GetDialog( this ) )
597 dialog->ShowPage( _( "Net Classes" ) );
598 } );
599 }
600 }
601
602 // The same value is set on that page too, so the popup is also the way to reach it
603 if( !defaultsPage.IsEmpty() )
604 {
605 popup->AddLink( wxString::Format( _( "Edit on the %s page" ), defaultsPage ),
606 [this, defaultsPage]()
607 {
608 if( PAGED_DIALOG* dialog = PAGED_DIALOG::GetDialog( this ) )
609 dialog->ShowPage( defaultsPage );
610 } );
611 }
612
613 // Neither the icon nor the field may raise its own help over the popup. The icon's is blank
614 // and only there to stop the field's showing through it, so it is simply put back.
615 aAnchor->UnsetToolTip();
616
617 for( const CONSTRAINT_FIELD& field : m_fields )
618 {
619 if( field.m_Setting == aSetting && field.m_Ctrl->GetToolTip() )
620 {
621 m_mutedField = field.m_Ctrl;
622 m_mutedTip = field.m_Ctrl->GetToolTipText();
623 field.m_Ctrl->UnsetToolTip();
624 break;
625 }
626 }
627
628 popup->SetOnDismiss(
629 [this, aAnchor]()
630 {
631 aAnchor->SetToolTip( wxS( " " ) );
632
633 if( m_mutedField )
634 m_mutedField->SetToolTip( m_mutedTip );
635
636 m_mutedField = nullptr;
637 wxToolTip::Enable( true );
638 m_popup = nullptr;
639 m_popupAnchor = nullptr;
640 m_closeTimer.Stop();
641 } );
642
643 m_popup = popup;
644 m_popupAnchor = aAnchor;
645 m_popupFromHover = aFromHover;
646
647 popup->PopupUnder( aAnchor );
648
649 // A popup a click opened stays until it is dismissed; one a hover opened follows the pointer
650 if( aFromHover )
651 m_closeTimer.Start( 250 );
652}
653
654
656{
657 m_validationTimer.Stop();
658
660 applyValues( candidate );
661
662 EDA_UNITS units = m_Frame->GetUserUnits();
663 std::map<wxString, wxString> messages;
664
665 for( const std::vector<BOARD_DESIGN_SETTINGS::VALIDATION_ERROR>& issues :
666 { candidate.ValidateDesignRules( units ), candidate.GetDesignRuleWarnings( units ) } )
667 {
668 for( const BOARD_DESIGN_SETTINGS::VALIDATION_ERROR& issue : issues )
669 {
670 wxString& msg = messages[issue.setting_name];
671
672 if( !msg.IsEmpty() )
673 msg += wxS( "\n" );
674
675 msg += issue.error_message;
676 }
677 }
678
679 for( const CONSTRAINT_FIELD& field : m_fields )
680 {
681 auto it = messages.find( field.m_Setting );
682 bool show = it != messages.end() && field.m_Ctrl->IsShown();
683
684 field.m_Warning->SetWarning( show ? it->second : wxString() );
685 }
686}
687
688
690{
691 using BDS = BOARD_DESIGN_SETTINGS;
692
693 // Must cover every m_fields member or an import or OK drops it
694 for( int BDS::* member :
695 { &BDS::m_MinClearance, &BDS::m_MinConn, &BDS::m_TrackMinWidth, &BDS::m_ViasMinAnnularWidth,
696 &BDS::m_ViasMinSize, &BDS::m_MinThroughDrill, &BDS::m_MicroViasMinSize, &BDS::m_MicroViasMinDrill,
697 &BDS::m_HoleToHoleMin, &BDS::m_HoleClearance, &BDS::m_SilkClearance, &BDS::m_MinGrooveWidth,
698 &BDS::m_MinSilkTextHeight, &BDS::m_MinSilkLineWidth, &BDS::m_CopperEdgeClearance, &BDS::m_MaxError,
699 &BDS::m_MinResolvedSpokes } )
700 {
701 aTo.*member = aFrom.*member;
702 }
703
706}
int index
const char * name
constexpr int ARC_HIGH_DEF
Definition base_units.h:144
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
@ via_hole_diameter
@ small_new_window
@ hole_to_hole_clearance
@ edge_to_copper_clearance
@ hole_to_copper_clearance
@ ps_diff_pair_gap
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.
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.
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
static wxString ConstraintText(const DRC_RE_LOADED_PANEL_ENTRY &aEntry, DRC_RULE_EDITOR_CONSTRAINT_NAME aType, UNITS_PROVIDER *aUnits)
The constraint a rule sets, written the way the rule table shows it.
Maps DRC rule constraints to appropriate editor panels.
DRC_RULE_EDITOR_CONSTRAINT_NAME GetHomePanel(DRC_CONSTRAINT_T aConstraintType)
The panel whose page lists a text rule that sets this constraint, or CUSTOM_RULE when no panel edits ...
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,...
NET_SETTINGS stores various net-related settings in a project context.
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
wxWindow * ShowPage(const wxString &aTitle)
Select the page with the given title.
PANEL_SETUP_CONSTRAINTS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
PANEL_SETUP_CONSTRAINTS(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame, DRC_RULE_DOCUMENT *aDocument, BOARD_DESIGN_SETTINGS &aSettings)
wxPopupTransientWindow * m_popup
The popup a hover or a click opened, while it is up.
void RefreshDefaults()
Reads the values a rule page edits back into their fields.
wxString m_hoverSetting
The field a hover is waiting to open, and the icon it would hang under.
static void CopySettings(const BOARD_DESIGN_SETTINGS &aFrom, BOARD_DESIGN_SETTINGS &aTo)
Copies every value this page edits, which is what the Constraints import group carries.
void closeHoveredPopup()
Close a popup opened by hovering once the pointer has left both it and its icon.
std::vector< CONSTRAINT_FIELD > m_fields
int m_spokeCountLoaded
The spoke count as this page last read it.
BOARD_DESIGN_SETTINGS * m_BrdSettings
wxString m_spokeCountPage
The rule page that also holds the spoke count, a spin control rather than a bound field.
void showOverridingRules(const wxString &aSetting, wxWindow *aAnchor, bool aFromHover)
Pop up what a board constraint is read with, each entry a link to where it is set.
wxWindow * m_popupAnchor
The icon that popup belongs to, which the pointer may return to without closing it.
bool m_popupFromHover
A popup a click opened stays until it is dismissed; one a hover opened follows the pointer.
void applyValues(BOARD_DESIGN_SETTINGS &aSettings) const
wxWindow * m_mutedField
The field whose own help is held back while a popup covers it, and the text to give back.
void updateWarnings()
Show a warning icon, with the reason as its tooltip, over each field whose value has an issue.
static wxString PageEditingDefault(const wxString &aSetting)
The title of the page that edits a board default, or empty where no rule page edits one.
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::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.
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.
The main frame for Pcbnew.
@ CLEARANCE_CONSTRAINT
@ NULL_CONSTRAINT
DRC_RULE_EDITOR_CONSTRAINT_NAME
#define _(s)
EDA_UNITS
Definition eda_units.h:45
KICOMMON_API wxFont GetSmallInfoFont(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
Represents a rule loaded from a .kicad_dru file and mapped to a panel.
wxString ruleName
wxString condition
wxString layerSource
Original layer text: "inner", "outer", or layer name.
DRC_RULE_EDITOR_CONSTRAINT_NAME panelType