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, 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
27
29#include <wx/checkbox.h>
30
31
33 wxWindow* aParent, DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA* aData ) :
35 m_data( aData ),
36 m_throughViasCheckbox( nullptr ),
37 m_microViasCheckbox( nullptr ),
38 m_blindViasCheckbox( nullptr ),
39 m_buriedViasCheckbox( nullptr )
40{
41 SetBackgroundBitmap( m_data->GetOverlayBitmap() );
42
43 std::vector<DRC_RE_FIELD_POSITION> positions = m_data->GetFieldPositions();
44
46
47 field = AddCheckbox( wxS( "through_vias" ), positions[0] );
48 m_throughViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
49
50 field = AddCheckbox( wxS( "micro_vias" ), positions[1] );
51 m_microViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
52
53 field = AddCheckbox( wxS( "blind_vias" ), positions[2] );
54 m_blindViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
55
56 field = AddCheckbox( wxS( "buried_vias" ), positions[3] );
57 m_buriedViasCheckbox = static_cast<wxCheckBox*>( field->GetControl() );
58
59 auto notifyModified = [this]( wxCommandEvent& )
60 {
62 if( dlg )
63 dlg->SetModified();
64 };
65
66 m_throughViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
67 m_microViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
68 m_blindViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
69 m_buriedViasCheckbox->Bind( wxEVT_CHECKBOX, notifyModified );
70
73}
74
75
77{
79 {
80 return false;
81 }
82
83 m_throughViasCheckbox->SetValue( m_data->GetDisallowThroughVias() );
84 m_microViasCheckbox->SetValue( m_data->GetDisallowMicroVias() );
85 m_blindViasCheckbox->SetValue( m_data->GetDisallowBlindVias() );
86 m_buriedViasCheckbox->SetValue( m_data->GetDisallowBuriedVias() );
87
88 return true;
89}
90
91
93{
95 {
96 return false;
97 }
98
99 m_data->SetDisallowThroughVias( m_throughViasCheckbox->GetValue() );
100 m_data->SetDisallowMicroVias( m_microViasCheckbox->GetValue() );
101 m_data->SetDisallowBlindVias( m_blindViasCheckbox->GetValue() );
102 m_data->SetDisallowBuriedVias( m_buriedViasCheckbox->GetValue() );
103
104 return true;
105}
106
107
108bool DRC_RE_VIAS_UNDER_SMD_OVERLAY_PANEL::ValidateInputs( int* aErrorCount, wxString* aValidationMessage )
109{
111
112 VALIDATION_RESULT result = m_data->Validate();
113
114 if( !result.isValid )
115 {
116 *aErrorCount = result.errors.size();
117
118 for( size_t i = 0; i < result.errors.size(); i++ )
119 *aValidationMessage += DRC_RULE_EDITOR_UTILS::FormatErrorMessage( i + 1, result.errors[i] );
120
121 return false;
122 }
123
124 return true;
125}
126
127
129{
130 if( !m_data )
131 return wxEmptyString;
132
133 return m_data->GenerateRule( aContext );
134}
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.