KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_permitted_layers_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_permitted_layers_overlay_panel.h
"
21
#include "
drc_re_permitted_layers_constraint_data.h
"
22
#include "
drc_rule_editor_utils.h
"
23
24
#include <
dialogs/rule_editor_dialog_base.h
>
25
#include <wx/checkbox.h>
26
27
28
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL
(
29
wxWindow* aParent,
DRC_RE_PERMITTED_LAYERS_CONSTRAINT_DATA
* aData ) :
30
DRC_RE_BITMAP_OVERLAY_PANEL
( aParent ),
31
m_data
( aData ),
32
m_topLayerCheckbox
( nullptr ),
33
m_bottomLayerCheckbox
( nullptr )
34
{
35
SetBackgroundBitmap
(
m_data
->GetOverlayBitmap() );
36
37
std::vector<DRC_RE_FIELD_POSITION> positions =
m_data
->GetFieldPositions();
38
39
DRC_RE_OVERLAY_FIELD
* topField =
AddCheckbox
( wxS(
"top_layer"
), positions[0] );
40
m_topLayerCheckbox
=
static_cast<
wxCheckBox*
>
( topField->
GetControl
() );
41
42
DRC_RE_OVERLAY_FIELD
* bottomField =
AddCheckbox
( wxS(
"bottom_layer"
), positions[1] );
43
m_bottomLayerCheckbox
=
static_cast<
wxCheckBox*
>
( bottomField->
GetControl
() );
44
45
auto
notifyModified = [
this
]( wxCommandEvent& )
46
{
47
RULE_EDITOR_DIALOG_BASE
* dlg =
RULE_EDITOR_DIALOG_BASE::GetDialog
(
this
);
48
if
( dlg )
49
dlg->
SetModified
();
50
};
51
52
m_topLayerCheckbox
->Bind( wxEVT_CHECKBOX, notifyModified );
53
m_bottomLayerCheckbox
->Bind( wxEVT_CHECKBOX, notifyModified );
54
55
PositionFields
();
56
TransferDataToWindow
();
57
}
58
59
60
bool
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::TransferDataToWindow
()
61
{
62
if
( !
m_data
|| !
m_topLayerCheckbox
|| !
m_bottomLayerCheckbox
)
63
return
false
;
64
65
m_topLayerCheckbox
->SetValue(
m_data
->GetTopLayerEnabled() );
66
m_bottomLayerCheckbox
->SetValue(
m_data
->GetBottomLayerEnabled() );
67
68
return
true
;
69
}
70
71
72
bool
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::TransferDataFromWindow
()
73
{
74
if
( !
m_data
|| !
m_topLayerCheckbox
|| !
m_bottomLayerCheckbox
)
75
return
false
;
76
77
m_data
->SetTopLayerEnabled(
m_topLayerCheckbox
->GetValue() );
78
m_data
->SetBottomLayerEnabled(
m_bottomLayerCheckbox
->GetValue() );
79
80
return
true
;
81
}
82
83
84
bool
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::ValidateInputs
(
int
* aErrorCount,
85
wxString* aValidationMessage )
86
{
87
TransferDataFromWindow
();
88
89
VALIDATION_RESULT
result
=
m_data
->Validate();
90
91
if
( !
result
.isValid )
92
{
93
*aErrorCount =
result
.errors.size();
94
95
for
(
size_t
i = 0; i <
result
.errors.size(); i++ )
96
*aValidationMessage +=
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
( i + 1,
result
.errors[i] );
97
98
return
false
;
99
}
100
101
return
true
;
102
}
103
104
105
wxString
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::GenerateRule
(
const
RULE_GENERATION_CONTEXT
& aContext )
106
{
107
if
( !
m_data
)
108
return
wxEmptyString;
109
110
return
m_data
->GenerateRule( aContext );
111
}
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:234
DRC_RE_BITMAP_OVERLAY_PANEL::SetBackgroundBitmap
void SetBackgroundBitmap(BITMAPS aBitmap)
Set the background bitmap for this panel.
Definition
drc_re_bitmap_overlay_panel.cpp:123
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:32
DRC_RE_BITMAP_OVERLAY_PANEL::PositionFields
void PositionFields()
Position all fields based on the current scale factor.
Definition
drc_re_bitmap_overlay_panel.cpp:133
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_RE_PERMITTED_LAYERS_CONSTRAINT_DATA
Definition
drc_re_permitted_layers_constraint_data.h:27
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::TransferDataToWindow
bool TransferDataToWindow() override
Definition
drc_re_permitted_layers_overlay_panel.cpp:60
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::m_data
DRC_RE_PERMITTED_LAYERS_CONSTRAINT_DATA * m_data
Definition
drc_re_permitted_layers_overlay_panel.h:48
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::m_bottomLayerCheckbox
wxCheckBox * m_bottomLayerCheckbox
Definition
drc_re_permitted_layers_overlay_panel.h:51
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition
drc_re_permitted_layers_overlay_panel.cpp:72
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL(wxWindow *aParent, DRC_RE_PERMITTED_LAYERS_CONSTRAINT_DATA *aData)
Definition
drc_re_permitted_layers_overlay_panel.cpp:28
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::GenerateRule
wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext) override
Definition
drc_re_permitted_layers_overlay_panel.cpp:105
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::m_topLayerCheckbox
wxCheckBox * m_topLayerCheckbox
Definition
drc_re_permitted_layers_overlay_panel.h:50
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::ValidateInputs
bool ValidateInputs(int *aErrorCount, wxString *aValidationMessage) override
Definition
drc_re_permitted_layers_overlay_panel.cpp:84
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
static wxString FormatErrorMessage(int aErrorCount, const wxString &aErrorMessage)
Definition
drc_rule_editor_utils.cpp:544
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:484
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:339
drc_re_permitted_layers_constraint_data.h
drc_re_permitted_layers_overlay_panel.h
drc_rule_editor_utils.h
rule_editor_dialog_base.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:598
src
pcbnew
drc
rule_editor
drc_re_permitted_layers_overlay_panel.cpp
Generated on Fri Jun 26 2026 00:05:39 for KiCad PCB EDA Suite by
1.13.2