KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_allowed_orientation_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) 2024 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_ALLOWED_ORIENTATION_CONSTRAINT_DATA_H_
25#define DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA_H_
26
28
29
31{
32public:
34
40
42 int aId, int aParentId, bool aAllowZeroDegreess, bool aAllowNinetyDegreess,
43 bool aAllowOneEightyDegreess, bool aAllowTwoSeventyDegreess, bool aAllowAllDegreess,
44 wxString aRuleName ) :
45 DRC_RE_BASE_CONSTRAINT_DATA( aId, aParentId, aRuleName ),
46 m_allowZeroDegreess( aAllowZeroDegreess ), m_allowNinetyDegrees( aAllowNinetyDegreess ),
47 m_allowOneEightyDegrees( aAllowOneEightyDegreess ),
48 m_allowTwoSeventyDegrees( aAllowTwoSeventyDegreess ),
49 m_allowAllDegrees( aAllowAllDegreess )
50 {
51 }
52
54
55 VALIDATION_RESULT Validate() const override
56 {
58
59 // At least one orientation must be selected
62 {
63 result.AddError( "At least one orientation must be selected" );
64 }
65
66 return result;
67 }
68
70
71 void SetIsZeroDegreesAllowed( bool aAllowZeroDegreess )
72 {
73 m_allowZeroDegreess = aAllowZeroDegreess;
74 }
75
77
78 void SetIsNinetyDegreesAllowed( bool aAllowNinetyDegrees )
79 {
80 m_allowNinetyDegrees = aAllowNinetyDegrees ;
81 }
82
84
85 void SetIsOneEightyDegreesAllowed( bool aAllowOneEightyDegrees )
86 {
87 m_allowOneEightyDegrees = aAllowOneEightyDegrees;
88 }
89
91
92 void SetIsTwoSeventyDegreesAllowed( bool aAllowTwoSeventyDegrees )
93 {
94 m_allowTwoSeventyDegrees = aAllowTwoSeventyDegrees;
95 }
96
98
99 void SetIsAllDegreesAllowed( bool aAllowAllDegrees )
100 {
101 m_allowAllDegrees = aAllowAllDegrees;
102 }
103
104 void CopyFrom( const ICopyable& aSource ) override
105 {
106 const auto& source =
107 dynamic_cast<const DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA&>( aSource );
108
110
111 m_allowZeroDegreess = source.m_allowZeroDegreess;
112 m_allowNinetyDegrees = source.m_allowNinetyDegrees;
113 m_allowOneEightyDegrees = source.m_allowOneEightyDegrees;
114 m_allowTwoSeventyDegrees = source.m_allowTwoSeventyDegrees;
115 m_allowAllDegrees = source.m_allowAllDegrees;
116 }
117
118private:
119 bool m_allowZeroDegreess{ false };
120 bool m_allowNinetyDegrees{ false };
123 bool m_allowAllDegrees{ false };
124};
125
126#endif // DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA_H_
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA(const DRC_RE_BASE_CONSTRAINT_DATA &aBaseData)
virtual ~DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA()=default
VALIDATION_RESULT Validate() const override
Validates the constraint data.
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA(int aId, int aParentId, bool aAllowZeroDegreess, bool aAllowNinetyDegreess, bool aAllowOneEightyDegreess, bool aAllowTwoSeventyDegreess, bool aAllowAllDegreess, wxString aRuleName)
void CopyFrom(const ICopyable &aSource) override
Abstract interface class to enable polymorphic copying between objects.
Result of a validation operation.
wxString result
Test unit parsing edge cases and error handling.