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, 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
#include "
drc_re_allowed_orientation_overlay_panel.h
"
25
#include "
drc_re_allowed_orientation_constraint_data.h
"
26
#include "
drc_rule_editor_utils.h
"
27
28
#include <
dialogs/rule_editor_dialog_base.h
>
29
#include <wx/checkbox.h>
30
31
32
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL
(
33
wxWindow* aParent,
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA
* aData ) :
34
DRC_RE_BITMAP_OVERLAY_PANEL
( aParent ),
35
m_data
( aData ),
36
m_zeroDegreesCheckbox
( nullptr ),
37
m_ninetyDegreesCheckbox
( nullptr ),
38
m_oneEightyDegreesCheckbox
( nullptr ),
39
m_twoSeventyDegreesCheckbox
( nullptr ),
40
m_allDegreesCheckbox
( nullptr )
41
{
42
SetBackgroundBitmap
(
m_data
->GetOverlayBitmap() );
43
44
std::vector<DRC_RE_FIELD_POSITION> positions =
m_data
->GetFieldPositions();
45
46
DRC_RE_OVERLAY_FIELD
* field =
AddCheckbox
( wxS(
"zero_degrees"
), positions[0] );
47
m_zeroDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
48
49
field =
AddCheckbox
( wxS(
"ninety_degrees"
), positions[1] );
50
m_ninetyDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
51
52
field =
AddCheckbox
( wxS(
"one_eighty_degrees"
), positions[2] );
53
m_oneEightyDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
54
55
field =
AddCheckbox
( wxS(
"two_seventy_degrees"
), positions[3] );
56
m_twoSeventyDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
57
58
field =
AddCheckbox
( wxS(
"all_degrees"
), positions[4] );
59
m_allDegreesCheckbox
=
static_cast<
wxCheckBox*
>
( field->
GetControl
() );
60
61
auto
notifyModified = [
this
]( wxCommandEvent& )
62
{
63
RULE_EDITOR_DIALOG_BASE
* dlg =
RULE_EDITOR_DIALOG_BASE::GetDialog
(
this
);
64
if
( dlg )
65
dlg->
SetModified
();
66
};
67
68
m_zeroDegreesCheckbox
->Bind( wxEVT_CHECKBOX, notifyModified );
69
m_ninetyDegreesCheckbox
->Bind( wxEVT_CHECKBOX, notifyModified );
70
m_oneEightyDegreesCheckbox
->Bind( wxEVT_CHECKBOX, notifyModified );
71
m_twoSeventyDegreesCheckbox
->Bind( wxEVT_CHECKBOX, notifyModified );
72
m_allDegreesCheckbox
->Bind( wxEVT_CHECKBOX, notifyModified );
73
74
PositionFields
();
75
TransferDataToWindow
();
76
}
77
78
79
bool
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataToWindow
()
80
{
81
if
( !
m_data
|| !
m_zeroDegreesCheckbox
|| !
m_ninetyDegreesCheckbox
|| !
m_oneEightyDegreesCheckbox
82
|| !
m_twoSeventyDegreesCheckbox
|| !
m_allDegreesCheckbox
)
83
{
84
return
false
;
85
}
86
87
m_zeroDegreesCheckbox
->SetValue(
m_data
->GetIsZeroDegreesAllowed() );
88
m_ninetyDegreesCheckbox
->SetValue(
m_data
->GetIsNinetyDegreesAllowed() );
89
m_oneEightyDegreesCheckbox
->SetValue(
m_data
->GetIsOneEightyDegreesAllowed() );
90
m_twoSeventyDegreesCheckbox
->SetValue(
m_data
->GetIsTwoSeventyDegreesAllowed() );
91
m_allDegreesCheckbox
->SetValue(
m_data
->GetIsAllDegreesAllowed() );
92
93
return
true
;
94
}
95
96
97
bool
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataFromWindow
()
98
{
99
if
( !
m_data
|| !
m_zeroDegreesCheckbox
|| !
m_ninetyDegreesCheckbox
|| !
m_oneEightyDegreesCheckbox
100
|| !
m_twoSeventyDegreesCheckbox
|| !
m_allDegreesCheckbox
)
101
{
102
return
false
;
103
}
104
105
m_data
->SetIsZeroDegreesAllowed(
m_zeroDegreesCheckbox
->GetValue() );
106
m_data
->SetIsNinetyDegreesAllowed(
m_ninetyDegreesCheckbox
->GetValue() );
107
m_data
->SetIsOneEightyDegreesAllowed(
m_oneEightyDegreesCheckbox
->GetValue() );
108
m_data
->SetIsTwoSeventyDegreesAllowed(
m_twoSeventyDegreesCheckbox
->GetValue() );
109
m_data
->SetIsAllDegreesAllowed(
m_allDegreesCheckbox
->GetValue() );
110
111
return
true
;
112
}
113
114
115
bool
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::ValidateInputs
(
int
* aErrorCount,
116
wxString* aValidationMessage )
117
{
118
TransferDataFromWindow
();
119
120
VALIDATION_RESULT
result
=
m_data
->Validate();
121
122
if
( !
result
.isValid )
123
{
124
*aErrorCount =
result
.errors.size();
125
126
for
(
size_t
i = 0; i <
result
.errors.size(); i++ )
127
*aValidationMessage +=
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
( i + 1,
result
.errors[i] );
128
129
return
false
;
130
}
131
132
return
true
;
133
}
134
135
136
wxString
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::GenerateRule
(
const
RULE_GENERATION_CONTEXT
& aContext )
137
{
138
if
( !
m_data
)
139
return
wxEmptyString;
140
141
return
m_data
->GenerateRule( aContext );
142
}
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA
Definition
drc_re_allowed_orientation_constraint_data.h:31
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_zeroDegreesCheckbox
wxCheckBox * m_zeroDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:54
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_twoSeventyDegreesCheckbox
wxCheckBox * m_twoSeventyDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:57
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_oneEightyDegreesCheckbox
wxCheckBox * m_oneEightyDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:56
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:97
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:32
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::GenerateRule
wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext) override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:136
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::ValidateInputs
bool ValidateInputs(int *aErrorCount, wxString *aValidationMessage) override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:115
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::TransferDataToWindow
bool TransferDataToWindow() override
Definition
drc_re_allowed_orientation_overlay_panel.cpp:79
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_ninetyDegreesCheckbox
wxCheckBox * m_ninetyDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:55
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_data
DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA * m_data
Definition
drc_re_allowed_orientation_overlay_panel.h:52
DRC_RE_ALLOWED_ORIENTATION_OVERLAY_PANEL::m_allDegreesCheckbox
wxCheckBox * m_allDegreesCheckbox
Definition
drc_re_allowed_orientation_overlay_panel.h:58
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:248
DRC_RE_BITMAP_OVERLAY_PANEL::SetBackgroundBitmap
void SetBackgroundBitmap(BITMAPS aBitmap)
Set the background bitmap for this panel.
Definition
drc_re_bitmap_overlay_panel.cpp:124
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:36
DRC_RE_BITMAP_OVERLAY_PANEL::PositionFields
void PositionFields()
Position all fields based on the current scale factor.
Definition
drc_re_bitmap_overlay_panel.cpp:134
DRC_RE_OVERLAY_FIELD
Wraps a wxControl positioned over a bitmap overlay panel.
Definition
drc_re_overlay_field.h:47
DRC_RE_OVERLAY_FIELD::GetControl
wxControl * GetControl() const
Definition
drc_re_overlay_field.h:68
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
static wxString FormatErrorMessage(int aErrorCount, const wxString &aErrorMessage)
Definition
drc_rule_editor_utils.cpp:538
RULE_EDITOR_DIALOG_BASE
Definition
rule_editor_dialog_base.h:103
RULE_EDITOR_DIALOG_BASE::SetModified
void SetModified()
Marks the dialog as modified, indicating unsaved changes.
Definition
rule_editor_dialog_base.cpp:491
RULE_EDITOR_DIALOG_BASE::GetDialog
static RULE_EDITOR_DIALOG_BASE * GetDialog(wxWindow *aWindow)
Static method to retrieve the rule editor dialog instance associated with a given window.
Definition
rule_editor_dialog_base.cpp:357
drc_re_allowed_orientation_constraint_data.h
drc_re_allowed_orientation_overlay_panel.h
drc_rule_editor_utils.h
rule_editor_dialog_base.h
RULE_GENERATION_CONTEXT
Definition
drc_rule_editor_enums.h:58
VALIDATION_RESULT
Result of a validation operation.
Definition
drc_rule_editor_enums.h:36
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 Sat Feb 21 2026 00:08:05 for KiCad PCB EDA Suite by
1.13.2