KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_allowed_orientation_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) 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, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#include "
drc_re_allowed_orientation_overlay_panel.h
"
21
#include "
drc_re_allowed_orientation_constraint_data.h
"
22
#include "
drc_rule_editor_utils.h
"
23
24
#include <wx/checkbox.h>
25
26
27
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL
(
28
wxWindow* aParent,
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA
* aData ) :
29
DRC_RE_BITMAP_OVERLAY_PANEL
( aParent ),
30
m_data
( aData ),
31
m_zeroDegreesCheckbox
( nullptr ),
32
m_ninetyDegreesCheckbox
( nullptr ),
33
m_oneEightyDegreesCheckbox
( nullptr ),
34
m_twoSeventyDegreesCheckbox
( nullptr ),
35
m_allDegreesCheckbox
( nullptr )
36
{
37
SetBackgroundBitmap
(
m_data
->GetOverlayBitmap() );
38
39
std::vector<DRC_RE_FIELD_POSITION> positions =
m_data
->GetFieldPositions();
40
41
DRC_RE_OVERLAY_FIELD
* field =
AddCheckbox
( wxS(
"zero_degrees"
), positions[0] );
42
m_zeroDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
43
44
field =
AddCheckbox
( wxS(
"ninety_degrees"
), positions[1] );
45
m_ninetyDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
46
47
field =
AddCheckbox
( wxS(
"one_eighty_degrees"
), positions[2] );
48
m_oneEightyDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
49
50
field =
AddCheckbox
( wxS(
"two_seventy_degrees"
), positions[3] );
51
m_twoSeventyDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
52
53
field =
AddCheckbox
( wxS(
"all_degrees"
), positions[4] );
54
m_allDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
55
56
auto
onIndividualCheckbox = [
this
]( wxCommandEvent& evt )
57
{
58
bool
allChecked =
m_zeroDegreesCheckbox
->GetValue() &&
m_ninetyDegreesCheckbox
->GetValue()
59
&&
m_oneEightyDegreesCheckbox
->GetValue() &&
m_twoSeventyDegreesCheckbox
->GetValue();
60
m_allDegreesCheckbox
->SetValue( allChecked );
61
evt.Skip();
62
};
63
64
auto
onAllDegreesCheckbox = [
this
]( wxCommandEvent& evt )
65
{
66
bool
checked =
m_allDegreesCheckbox
->GetValue();
67
m_zeroDegreesCheckbox
->SetValue( checked );
68
m_ninetyDegreesCheckbox
->SetValue( checked );
69
m_oneEightyDegreesCheckbox
->SetValue( checked );
70
m_twoSeventyDegreesCheckbox
->SetValue( checked );
71
evt.Skip();
72
};
73
74
m_zeroDegreesCheckbox
->Bind( wxEVT_CHECKBOX, onIndividualCheckbox );
75
m_ninetyDegreesCheckbox
->Bind( wxEVT_CHECKBOX, onIndividualCheckbox );
76
m_oneEightyDegreesCheckbox
->Bind( wxEVT_CHECKBOX, onIndividualCheckbox );
77
m_twoSeventyDegreesCheckbox
->Bind( wxEVT_CHECKBOX, onIndividualCheckbox );
78
m_allDegreesCheckbox
->Bind( wxEVT_CHECKBOX, onAllDegreesCheckbox );
79
80
TransferDataToWindow
();
81
PositionFields
();
82
}
83
84
85
bool
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataToWindow
()
86
{
87
if
( !
m_data
|| !
m_zeroDegreesCheckbox
|| !
m_ninetyDegreesCheckbox
|| !
m_oneEightyDegreesCheckbox
88
|| !
m_twoSeventyDegreesCheckbox
|| !
m_allDegreesCheckbox
)
89
{
90
return
false
;
91
}
92
93
m_zeroDegreesCheckbox
->SetValue(
m_data
->GetIsZeroDegreesAllowed() );
94
m_ninetyDegreesCheckbox
->SetValue(
m_data
->GetIsNinetyDegreesAllowed() );
95
m_oneEightyDegreesCheckbox
->SetValue(
m_data
->GetIsOneEightyDegreesAllowed() );
96
m_twoSeventyDegreesCheckbox
->SetValue(
m_data
->GetIsTwoSeventyDegreesAllowed() );
97
m_allDegreesCheckbox
->SetValue(
m_data
->GetIsAllDegreesAllowed() );
98
99
return
true
;
100
}
101
102
103
bool
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataFromWindow
()
104
{
105
if
( !
m_data
|| !
m_zeroDegreesCheckbox
|| !
m_ninetyDegreesCheckbox
|| !
m_oneEightyDegreesCheckbox
106
|| !
m_twoSeventyDegreesCheckbox
|| !
m_allDegreesCheckbox
)
107
{
108
return
false
;
109
}
110
111
m_data
->SetIsZeroDegreesAllowed(
m_zeroDegreesCheckbox
->GetValue() );
112
m_data
->SetIsNinetyDegreesAllowed(
m_ninetyDegreesCheckbox
->GetValue() );
113
m_data
->SetIsOneEightyDegreesAllowed(
m_oneEightyDegreesCheckbox
->GetValue() );
114
m_data
->SetIsTwoSeventyDegreesAllowed(
m_twoSeventyDegreesCheckbox
->GetValue() );
115
m_data
->SetIsAllDegreesAllowed(
m_zeroDegreesCheckbox
->GetValue() &&
m_ninetyDegreesCheckbox
->GetValue()
116
&&
m_oneEightyDegreesCheckbox
->GetValue()
117
&&
m_twoSeventyDegreesCheckbox
->GetValue() );
118
119
return
true
;
120
}
121
122
123
bool
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::ValidateInputs
(
int
* aErrorCount,
124
wxString* aValidationMessage )
125
{
126
TransferDataFromWindow
();
127
128
VALIDATION_RESULT
result
=
m_data
->Validate();
129
130
if
( !
result
.isValid )
131
{
132
*aErrorCount =
result
.errors.size();
133
134
for
(
size_t
i = 0; i <
result
.errors.size(); i++ )
135
*aValidationMessage +=
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
( i + 1,
result
.errors[i] );
136
137
return
false
;
138
}
139
140
return
true
;
141
}
142
143
144
wxString
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::GenerateRule
(
const
RULE_GENERATION_CONTEXT
& aContext )
145
{
146
if
( !
m_data
)
147
return
wxEmptyString;
148
149
return
m_data
->GenerateRule( aContext );
150
}
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA
Definition
drc_re_allowed_orientation_constraint_data.h:27
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_zeroDegreesCheckbox
wxCheckBox * m_zeroDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:50
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_twoSeventyDegreesCheckbox
wxCheckBox * m_twoSeventyDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:53
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_oneEightyDegreesCheckbox
wxCheckBox * m_oneEightyDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:52
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:103
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL(wxWindow *aParent, DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA *aData)
Definition
drc_re_allowed_orientation_overlay_panel.cpp:27
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::GenerateRule
wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext) override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:144
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::ValidateInputs
bool ValidateInputs(int *aErrorCount, wxString *aValidationMessage) override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:123
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataToWindow
bool TransferDataToWindow() override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:85
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_ninetyDegreesCheckbox
wxCheckBox * m_ninetyDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:51
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_data
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA * m_data
Definition
drc_re_allowed_orientation_overlay_panel.h:48
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_allDegreesCheckbox
wxCheckBox * m_allDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:54
DRC_RE_BITMAP_OVERLAY_PANEL::AddCheckbox
DRC_RE_OVERLAY_FIELD * AddCheckbox(const wxString &aId, const DRC_RE_FIELD_POSITION &aPosition)
Create and position a checkbox control on the bitmap overlay.
Definition
drc_re_bitmap_overlay_panel.cpp:365
DRC_RE_BITMAP_OVERLAY_PANEL::SetBackgroundBitmap
void SetBackgroundBitmap(BITMAPS aBitmap)
Set the background bitmap for this panel.
Definition
drc_re_bitmap_overlay_panel.cpp:152
DRC_RE_BITMAP_OVERLAY_PANEL::DRC_RE_BITMAP_OVERLAY_PANEL
DRC_RE_BITMAP_OVERLAY_PANEL(wxWindow *aParent, wxWindowID aId=wxID_ANY)
Definition
drc_re_bitmap_overlay_panel.cpp:41
DRC_RE_BITMAP_OVERLAY_PANEL::PositionFields
void PositionFields()
Position all fields based on the current scale factor.
Definition
drc_re_bitmap_overlay_panel.cpp:162
DRC_RE_OVERLAY_FIELD
Wraps a wxControl positioned over a bitmap overlay panel.
Definition
drc_re_overlay_field.h:43
DRC_RE_OVERLAY_FIELD::GetControl
wxControl * GetControl() const
Definition
drc_re_overlay_field.h:64
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
static wxString FormatErrorMessage(int aErrorCount, const wxString &aErrorMessage)
Definition
drc_rule_editor_utils.cpp:540
drc_re_allowed_orientation_constraint_data.h
drc_re_allowed_orientation_overlay_panel.h
drc_rule_editor_utils.h
RULE_GENERATION_CONTEXT
Definition
drc_rule_editor_enums.h:54
VALIDATION_RESULT
Result of a validation operation.
Definition
drc_rule_editor_enums.h:32
result
wxString result
Test unit parsing edge cases and error handling.
Definition
test_text_eval_numeric_compat.cpp:602
src
pcbnew
drc
rule_editor
drc_re_allowed_orientation_overlay_panel.cpp
Generated on Tue Nov 17 2026 00:06:21 for KiCad PCB EDA Suite by
1.13.2