KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_vias_under_smd_constraint_data.h
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
20#ifndef DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA_H_
21#define DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA_H_
22
24#include <drc/drc_rule.h>
25
26
28{
29public:
31
36
37 explicit DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA( int aId, int aParentId, const wxString& aRuleName,
38 bool aDisallowThroughVias = false, bool aDisallowMicroVias = false,
39 bool aDisallowBlindVias = false,
40 bool aDisallowBuriedVias = false ) :
41 DRC_RE_BASE_CONSTRAINT_DATA( aId, aParentId, aRuleName ),
42 m_disallowThroughVias( aDisallowThroughVias ),
43 m_disallowMicroVias( aDisallowMicroVias ),
44 m_disallowBlindVias( aDisallowBlindVias ),
45 m_disallowBuriedVias( aDisallowBuriedVias )
46 {
47 }
48
50
52
53 std::vector<DRC_RE_FIELD_POSITION> GetFieldPositions() const override
54 {
55 return {
56 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 40 + DRC_RE_OVERLAY_YO, 1, wxS( "Disallow Through Via" ), LABEL_POSITION::RIGHT },
57 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 80 + DRC_RE_OVERLAY_YO, 2, wxS( "Disallow Micro Via" ), LABEL_POSITION::RIGHT },
58 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 120 + DRC_RE_OVERLAY_YO, 3, wxS( "Disallow Blind Via" ), LABEL_POSITION::RIGHT },
59 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 160 + DRC_RE_OVERLAY_YO, 4, wxS( "Disallow Buried Via" ), LABEL_POSITION::RIGHT },
60 };
61 }
62
63 VALIDATION_RESULT Validate() const override
64 {
66
68 {
69 result.AddError( _( "At least one via type must be selected" ) );
70 }
71
72 return result;
73 }
74
75 std::vector<wxString> GetConstraintClauses( const RULE_GENERATION_CONTEXT& aContext ) const override
76 {
78 return {};
79
81 {
82 return { wxS( "(constraint disallow via)" ) };
83 }
84
85 wxString items;
86
88 items += wxS( " through_via" );
90 items += wxS( " micro_via" );
92 items += wxS( " blind_via" );
94 items += wxS( " buried_via" );
95
96 items.Trim( false );
97 return { wxString::Format( wxS( "(constraint disallow %s)" ), items ) };
98 }
99
100 wxString GenerateRule( const RULE_GENERATION_CONTEXT& aContext ) override
101 {
102 RULE_GENERATION_CONTEXT ctx = aContext;
103
104 wxString padTypeCondition = wxS( "A.Pad_Type == 'SMD'" );
105
106 if( ctx.conditionExpression.IsEmpty() )
107 ctx.conditionExpression = padTypeCondition;
108 else
109 ctx.conditionExpression = padTypeCondition + wxS( " && " ) + ctx.conditionExpression;
110
111 return buildRule( ctx, GetConstraintClauses( ctx ) );
112 }
113
115 void SetDisallowThroughVias( bool aValue ) { m_disallowThroughVias = aValue; }
116
118 void SetDisallowMicroVias( bool aValue ) { m_disallowMicroVias = aValue; }
119
121 void SetDisallowBlindVias( bool aValue ) { m_disallowBlindVias = aValue; }
122
124 void SetDisallowBuriedVias( bool aValue ) { m_disallowBuriedVias = aValue; }
125
126 void CopyFrom( const ICopyable& aSource ) override
127 {
128 const auto& source = dynamic_cast<const DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA&>( aSource );
129
131
132 m_disallowThroughVias = source.m_disallowThroughVias;
133 m_disallowMicroVias = source.m_disallowMicroVias;
134 m_disallowBlindVias = source.m_disallowBlindVias;
135 m_disallowBuriedVias = source.m_disallowBuriedVias;
136 }
137
138private:
143};
144
145#endif // DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA_H_
BITMAPS
A list of all bitmap identifiers.
@ constraint_vias_under_smd
wxString buildRule(const RULE_GENERATION_CONTEXT &aContext, const std::vector< wxString > &aConstraintClauses) const
void CopyFrom(const ICopyable &aSource) override
virtual ~DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA()=default
VALIDATION_RESULT Validate() const override
Validates the constraint data.
DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA(int aId, int aParentId, const wxString &aRuleName, bool aDisallowThroughVias=false, bool aDisallowMicroVias=false, bool aDisallowBlindVias=false, bool aDisallowBuriedVias=false)
BITMAPS GetOverlayBitmap() const override
Returns the bitmap to use for the overlay panel background.
std::vector< wxString > GetConstraintClauses(const RULE_GENERATION_CONTEXT &aContext) const override
Returns just the constraint clauses without the rule wrapper.
wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext) override
DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA(const DRC_RE_BASE_CONSTRAINT_DATA &aBaseData)
std::vector< DRC_RE_FIELD_POSITION > GetFieldPositions() const override
Returns the field positions for controls overlaid on the constraint bitmap.
Abstract interface class to enable polymorphic copying between objects.
constexpr int DRC_RE_OVERLAY_XO
constexpr int DRC_RE_OVERLAY_YO
@ RIGHT
Label to the right of the field.
#define _(s)
Result of a validation operation.
wxString result
Test unit parsing edge cases and error handling.