KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_vias_under_smd_overlay_panel.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) 2026 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
23
25#include <wx/checkbox.h>
26
27
29 wxWindow* aParent, DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA* aData ) :
31 m_data( aData ),
32 m_throughViasCheckbox( nullptr ),
33 m_microViasCheckbox( nullptr ),
34 m_blindViasCheckbox( nullptr ),
35 m_buriedViasCheckbox( nullptr )
36{
37 SetBackgroundBitmap( m_data->GetOverlayBitmap() );
38
39 std::vector<DRC_RE_FIELD_POSITION> positions = m_data->GetFieldPositions();
40
42
43 field = AddCheckbox( wxS( "through_vias" ), positions[0] );
44 m_throughViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
45
46 field = AddCheckbox( wxS( "micro_vias" ), positions[1] );
47 m_microViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
48
49 field = AddCheckbox( wxS( "blind_vias" ), positions[2] );
50 m_blindViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
51
52 field = AddCheckbox( wxS( "buried_vias" ), positions[3] );
53 m_buriedViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
54
55 auto notifyModified = [this]( wxCommandEvent& )
56 {
58 if( dlg )
59 dlg->SetModified();
60 };
61
62 m_throughViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
63 m_microViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
64 m_blindViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
65 m_buriedViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
66
69}
70
71
73{
75 {
76 return false;
77 }
78
79 m_throughViasCheckbox->SetValue( m_data->GetDisallowThroughVias() );
80 m_microViasCheckbox->SetValue( m_data->GetDisallowMicroVias() );
81 m_blindViasCheckbox->SetValue( m_data->GetDisallowBlindVias() );
82 m_buriedViasCheckbox->SetValue( m_data->GetDisallowBuriedVias() );
83
84 return true;
85}
86
87
89{
91 {
92 return false;
93 }
94
95 m_data->SetDisallowThroughVias( m_throughViasCheckbox->GetValue() );
96 m_data->SetDisallowMicroVias( m_microViasCheckbox->GetValue() );
97 m_data->SetDisallowBlindVias( m_blindViasCheckbox->GetValue() );
98 m_data->SetDisallowBuriedVias( m_buriedViasCheckbox->GetValue() );
99
100 return true;
101}
102
103
104bool DRC_RE_VIAS_UNDER_SMD_OVERLAY_PANEL::ValidateInputs( int* aErrorCount, wxString* aValidationMessage )
105{
107
108 VALIDATION_RESULT result = m_data->Validate();
109
110 if( !result.isValid )
111 {
112 *aErrorCount = result.errors.size();
113
114 for( size_t i = 0; i < result.errors.size(); i++ )
115 *aValidationMessage += DRC_RULE_EDITOR_UTILS::FormatErrorMessage( i + 1, result.errors[i] );
116
117 return false;
118 }
119
120 return true;
121}
122
123
125{
126 if( !m_data )
127 return wxEmptyString;
128
129 return m_data->GenerateRule( aContext );
130}
DRC_RE_OVERLAY_FIELD * AddCheckbox(const wxString &aId, const DRC_RE_FIELD_POSITION &aPosition)
Create and position a checkbox control on the bitmap overlay.
void SetBackgroundBitmap(BITMAPS aBitmap)
Set the background bitmap for this panel.
DRC_RE_BITMAP_OVERLAY_PANEL(wxWindow *aParent, wxWindowID aId=wxID_ANY)
void PositionFields()
Position all fields based on the current scale factor.
Wraps a wxControl positioned over a bitmap overlay panel.
wxControl * GetControl() const
DRC_RE_VIAS_UNDER_SMD_OVERLAY_PANEL(wxWindow *aParent, DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA *aData)
wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext) override
bool ValidateInputs(int *aErrorCount, wxString *aValidationMessage) override
DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA * m_data
static wxString FormatErrorMessage(int aErrorCount, const wxString &aErrorMessage)
void SetModified()
Marks the dialog as modified, indicating unsaved changes.
static RULE_EDITOR_DIALOG_BASE * GetDialog(wxWindow *aWindow)
Static method to retrieve the rule editor dialog instance associated with a given window.
Result of a validation operation.
wxString result
Test unit parsing edge cases and error handling.