KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_rule_editor_tool.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 modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include <
pcb_edit_frame.h
>
21
#include <
tool/tool_manager.h
>
22
#include <
tools/pcb_actions.h
>
23
#include <
tools/pcb_tool_base.h
>
24
#include <
tools/zone_filler_tool.h
>
25
#include <
tools/pcb_selection_tool.h
>
26
#include <
tools/drc_rule_editor_tool.h
>
27
#include <
kiface_base.h
>
28
#include <
board_commit.h
>
29
#include <
board_design_settings.h
>
30
#include <
progress_reporter.h
>
31
#include <
drc/drc_engine.h
>
32
#include <
drc/drc_item.h
>
33
#include <
macros.h
>
34
#include <
drc/rule_editor/dialog_drc_rule_editor.h
>
35
36
37
DRC_RULE_EDITOR_TOOL::DRC_RULE_EDITOR_TOOL
() :
38
PCB_TOOL_BASE
(
"pcbnew.DRETool"
),
m_editFrame
( nullptr ),
m_pcb
( nullptr ),
39
m_drcRuleEditorDlg
( nullptr )
40
{
41
}
42
43
44
DRC_RULE_EDITOR_TOOL::~DRC_RULE_EDITOR_TOOL
()
45
{
46
}
47
48
49
void
DRC_RULE_EDITOR_TOOL::Reset
(
RESET_REASON
aReason )
50
{
51
m_editFrame
=
getEditFrame<PCB_EDIT_FRAME>
();
52
53
if
(
m_pcb
!=
m_editFrame
->GetBoard() )
54
{
55
if
(
m_drcRuleEditorDlg
)
56
DestroyDRCRuleEditorDialog
();
57
58
m_pcb
=
m_editFrame
->GetBoard();
59
m_drcEngine
=
m_pcb
->GetDesignSettings().m_DRCEngine;
60
}
61
}
62
63
64
bool
DRC_RULE_EDITOR_TOOL::IsDRCRuleEditorDialogShown
()
65
{
66
if
(
m_drcRuleEditorDlg
)
67
return
m_drcRuleEditorDlg
->IsShownOnScreen();
68
69
return
false
;
70
}
71
72
73
void
DRC_RULE_EDITOR_TOOL::updatePointers
()
74
{
75
// update my pointers, m_editFrame is the only unchangeable one
76
m_pcb
=
m_editFrame
->GetBoard();
77
78
if
(
m_drcRuleEditorDlg
)
79
m_drcRuleEditorDlg
->UpdateData();
80
}
81
82
83
void
DRC_RULE_EDITOR_TOOL::ShowDRCRuleEditorDialog
( wxWindow* aParent )
84
{
85
bool
show_dlg_modal =
true
;
86
87
// the dialog needs a parent frame. if it is not specified, this is the PCB editor frame
88
// specified in DRC_RULE_EDITOR_TOOL class.
89
if
( !aParent )
90
{
91
// if any parent is specified, the dialog is modal.
92
// if this is the default PCB editor frame, it is not modal
93
show_dlg_modal =
false
;
94
aParent =
m_editFrame
;
95
}
96
97
Activate
();
98
m_toolMgr
->RunAction(
PCB_ACTIONS::selectionClear
);
99
100
if
( !
m_drcRuleEditorDlg
)
101
{
102
m_drcRuleEditorDlg
=
new
DIALOG_DRC_RULE_EDITOR
(
m_editFrame
, aParent );
103
updatePointers
();
104
105
if
( show_dlg_modal )
106
m_drcRuleEditorDlg
->ShowModal();
107
else
108
m_drcRuleEditorDlg
->Show(
true
);
109
}
110
else
// The dialog is just not visible (because the user has double clicked on an error item)
111
{
112
updatePointers
();
113
m_drcRuleEditorDlg
->Show(
true
);
114
}
115
}
116
117
118
int
DRC_RULE_EDITOR_TOOL::ShowDRCRuleEditorDialog
(
const
TOOL_EVENT
& aEvent )
119
{
120
ShowDRCRuleEditorDialog
(
nullptr
);
121
return
0;
122
}
123
124
125
void
DRC_RULE_EDITOR_TOOL::DestroyDRCRuleEditorDialog
()
126
{
127
if
(
m_drcRuleEditorDlg
)
128
{
129
m_drcRuleEditorDlg
->Destroy();
130
m_drcRuleEditorDlg
=
nullptr
;
131
}
132
}
133
134
135
void
DRC_RULE_EDITOR_TOOL::setTransitions
()
136
{
137
Go
( &
DRC_RULE_EDITOR_TOOL::ShowDRCRuleEditorDialog
,
PCB_ACTIONS::drcRuleEditor
.MakeEvent() );
138
}
board_commit.h
board_design_settings.h
ACTIONS::selectionClear
static TOOL_ACTION selectionClear
Clear the current selection.
Definition
actions.h:224
DIALOG_DRC_RULE_EDITOR
Definition
dialog_drc_rule_editor.h:46
DRC_RULE_EDITOR_TOOL::m_drcEngine
std::shared_ptr< DRC_ENGINE > m_drcEngine
Definition
drc_rule_editor_tool.h:82
DRC_RULE_EDITOR_TOOL::m_pcb
BOARD * m_pcb
Definition
drc_rule_editor_tool.h:80
DRC_RULE_EDITOR_TOOL::~DRC_RULE_EDITOR_TOOL
~DRC_RULE_EDITOR_TOOL()
Definition
drc_rule_editor_tool.cpp:44
DRC_RULE_EDITOR_TOOL::updatePointers
void updatePointers()
Update needed pointers from the one pointer which is known not to change.
Definition
drc_rule_editor_tool.cpp:73
DRC_RULE_EDITOR_TOOL::DRC_RULE_EDITOR_TOOL
DRC_RULE_EDITOR_TOOL()
Definition
drc_rule_editor_tool.cpp:37
DRC_RULE_EDITOR_TOOL::ShowDRCRuleEditorDialog
void ShowDRCRuleEditorDialog(wxWindow *aParent)
Opens the DRC Rule Editor dialog.
Definition
drc_rule_editor_tool.cpp:83
DRC_RULE_EDITOR_TOOL::IsDRCRuleEditorDialogShown
bool IsDRCRuleEditorDialogShown()
Check to see if the DRC_TOOL dialog is currently shown.
Definition
drc_rule_editor_tool.cpp:64
DRC_RULE_EDITOR_TOOL::m_editFrame
PCB_EDIT_FRAME * m_editFrame
Definition
drc_rule_editor_tool.h:79
DRC_RULE_EDITOR_TOOL::DestroyDRCRuleEditorDialog
void DestroyDRCRuleEditorDialog()
Close and free the DRC dialog.
Definition
drc_rule_editor_tool.cpp:125
DRC_RULE_EDITOR_TOOL::setTransitions
void setTransitions() override
< Set up handlers for various events.
Definition
drc_rule_editor_tool.cpp:135
DRC_RULE_EDITOR_TOOL::Reset
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition
drc_rule_editor_tool.cpp:49
DRC_RULE_EDITOR_TOOL::m_drcRuleEditorDlg
DIALOG_DRC_RULE_EDITOR * m_drcRuleEditorDlg
Definition
drc_rule_editor_tool.h:81
PCB_ACTIONS::drcRuleEditor
static TOOL_ACTION drcRuleEditor
Definition
pcb_actions.h:463
PCB_TOOL_BASE::PCB_TOOL_BASE
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition
pcb_tool_base.h:78
TOOL_BASE::getEditFrame
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition
tool_base.h:186
TOOL_BASE::m_toolMgr
TOOL_MANAGER * m_toolMgr
Definition
tool_base.h:220
TOOL_BASE::RESET_REASON
RESET_REASON
Determine the reason of reset for a tool.
Definition
tool_base.h:78
TOOL_EVENT
Generic, UI-independent tool event.
Definition
tool_event.h:171
TOOL_INTERACTIVE::Go
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
Definition
tool_interactive.h:147
TOOL_INTERACTIVE::Activate
void Activate()
Run the tool.
Definition
tool_interactive.cpp:65
dialog_drc_rule_editor.h
drc_engine.h
drc_item.h
drc_rule_editor_tool.h
kiface_base.h
macros.h
This file contains miscellaneous commonly used macros and functions.
pcb_actions.h
pcb_edit_frame.h
pcb_selection_tool.h
pcb_tool_base.h
progress_reporter.h
tool_manager.h
zone_filler_tool.h
src
pcbnew
tools
drc_rule_editor_tool.cpp
Generated on Sun Feb 1 2026 00:08:34 for KiCad PCB EDA Suite by
1.13.2