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 <wx/checkbox.h>
25
26
27
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL
(
28
wxWindow* aParent,
DRC_RE_PERMITTED_LAYERS_CONSTRAINT_DATA
* aData ) :
29
DRC_RE_BITMAP_OVERLAY_PANEL
( aParent ),
30
m_data
( aData ),
31
m_topLayerCheckbox
( nullptr ),
32
m_bottomLayerCheckbox
( nullptr )
33
{
34
SetBackgroundBitmap
(
m_data
->GetOverlayBitmap() );
35
36
std::vector<DRC_RE_FIELD_POSITION> positions =
m_data
->GetFieldPositions();
37
38
DRC_RE_OVERLAY_FIELD
* topField =
AddCheckbox
( wxS(
"top_layer"
), positions[0] );
39
m_topLayerCheckbox
=
static_cast<
wxCheckBox*
>
( topField->
GetControl
() );
40
41
DRC_RE_OVERLAY_FIELD
* bottomField =
AddCheckbox
( wxS(
"bottom_layer"
), positions[1] );
42
m_bottomLayerCheckbox
=
static_cast<
wxCheckBox*
>
( bottomField->
GetControl
() );
43
44
TransferDataToWindow
();
45
PositionFields
();
46
}
47
48
49
bool
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::TransferDataToWindow
()
50
{
51
if
( !
m_data
|| !
m_topLayerCheckbox
|| !
m_bottomLayerCheckbox
)
52
return
false
;
53
54
m_topLayerCheckbox
->SetValue(
m_data
->GetTopLayerEnabled() );
55
m_bottomLayerCheckbox
->SetValue(
m_data
->GetBottomLayerEnabled() );
56
57
return
true
;
58
}
59
60
61
bool
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::TransferDataFromWindow
()
62
{
63
if
( !
m_data
|| !
m_topLayerCheckbox
|| !
m_bottomLayerCheckbox
)
64
return
false
;
65
66
m_data
->SetTopLayerEnabled(
m_topLayerCheckbox
->GetValue() );
67
m_data
->SetBottomLayerEnabled(
m_bottomLayerCheckbox
->GetValue() );
68
69
return
true
;
70
}
71
72
73
bool
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::ValidateInputs
(
int
* aErrorCount,
74
wxString* aValidationMessage )
75
{
76
TransferDataFromWindow
();
77
78
VALIDATION_RESULT
result
=
m_data
->Validate();
79
80
if
( !
result
.isValid )
81
{
82
*aErrorCount =
result
.errors.size();
83
84
for
(
size_t
i = 0; i <
result
.errors.size(); i++ )
85
*aValidationMessage +=
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
( i + 1,
result
.errors[i] );
86
87
return
false
;
88
}
89
90
return
true
;
91
}
92
93
94
wxString
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::GenerateRule
(
const
RULE_GENERATION_CONTEXT
& aContext )
95
{
96
if
( !
m_data
)
97
return
wxEmptyString;
98
99
return
m_data
->GenerateRule( aContext );
100
}
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_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:49
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:61
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:27
DRC_RE_PERMITTED_LAYERS_OVERLAY_PANEL::GenerateRule
wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext) override
Definition
drc_re_permitted_layers_overlay_panel.cpp:94
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:73
DRC_RULE_EDITOR_UTILS::FormatErrorMessage
static wxString FormatErrorMessage(int aErrorCount, const wxString &aErrorMessage)
Definition
drc_rule_editor_utils.cpp:540
drc_re_permitted_layers_constraint_data.h
drc_re_permitted_layers_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_permitted_layers_overlay_panel.cpp
Generated on Tue Nov 17 2026 00:06:21 for KiCad PCB EDA Suite by
1.13.2