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, 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
24#ifndef DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA_H_
25#define DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA_H_
26
28#include <drc/drc_rule.h>
29
30
32{
33public:
35
40
41 explicit DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA( int aId, int aParentId, const wxString& aRuleName,
42 bool aDisallowThroughVias = false, bool aDisallowMicroVias = false,
43 bool aDisallowBlindVias = false,
44 bool aDisallowBuriedVias = false ) :
45 DRC_RE_BASE_CONSTRAINT_DATA( aId, aParentId, aRuleName ),
46 m_disallowThroughVias( aDisallowThroughVias ),
47 m_disallowMicroVias( aDisallowMicroVias ),
48 m_disallowBlindVias( aDisallowBlindVias ),
49 m_disallowBuriedVias( aDisallowBuriedVias )
50 {
51 }
52
54
56
57 std::vector<DRC_RE_FIELD_POSITION> GetFieldPositions() const override
58 {
59 return {
60 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 40 + DRC_RE_OVERLAY_YO, 1, wxS( "Disallow Through Via" ), LABEL_POSITION::RIGHT },
61 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 80 + DRC_RE_OVERLAY_YO, 2, wxS( "Disallow Micro Via" ), LABEL_POSITION::RIGHT },
62 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 120 + DRC_RE_OVERLAY_YO, 3, wxS( "Disallow Blind Via" ), LABEL_POSITION::RIGHT },
63 { 400 + DRC_RE_OVERLAY_XO, 414 + DRC_RE_OVERLAY_XO, 160 + DRC_RE_OVERLAY_YO, 4, wxS( "Disallow Buried Via" ), LABEL_POSITION::RIGHT },
64 };
65 }
66
67 VALIDATION_RESULT Validate() const override
68 {
70
72 {
73 result.AddError( _( "At least one via type must be selected" ) );
74 }
75
76 return result;
77 }
78
79 std::vector<wxString> GetConstraintClauses( const RULE_GENERATION_CONTEXT& aContext ) const override
80 {
82 return {};
83
85 {
86 return { wxS( "(constraint disallow via)" ) };
87 }
88
89 wxString items;
90
92 items += wxS( " through_via" );
94 items += wxS( " micro_via" );
96 items += wxS( " blind_via" );
98 items += wxS( " buried_via" );
99
100 items.Trim( false );
101 return { wxString::Format( wxS( "(constraint disallow %s)" ), items ) };
102 }
103
104 wxString GenerateRule( const RULE_GENERATION_CONTEXT& aContext ) override
105 {
106 RULE_GENERATION_CONTEXT ctx = aContext;
107
108 wxString padTypeCondition = wxS( "A.Pad_Type == 'SMD'" );
109
110 if( ctx.conditionExpression.IsEmpty() )
111 ctx.conditionExpression = padTypeCondition;
112 else
113 ctx.conditionExpression = padTypeCondition + wxS( " && " ) + ctx.conditionExpression;
114
115 return buildRule( ctx, GetConstraintClauses( ctx ) );
116 }
117
119 void SetDisallowThroughVias( bool aValue ) { m_disallowThroughVias = aValue; }
120
122 void SetDisallowMicroVias( bool aValue ) { m_disallowMicroVias = aValue; }
123
125 void SetDisallowBlindVias( bool aValue ) { m_disallowBlindVias = aValue; }
126
128 void SetDisallowBuriedVias( bool aValue ) { m_disallowBuriedVias = aValue; }
129
130 void CopyFrom( const ICopyable& aSource ) override
131 {
132 const auto& source = dynamic_cast<const DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA&>( aSource );
133
135
136 m_disallowThroughVias = source.m_disallowThroughVias;
137 m_disallowMicroVias = source.m_disallowMicroVias;
138 m_disallowBlindVias = source.m_disallowBlindVias;
139 m_disallowBuriedVias = source.m_disallowBuriedVias;
140 }
141
142private:
147};
148
149#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.