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>
27#include <kiface_base.h>
28#include <board_commit.h>
30#include <progress_reporter.h>
31#include <drc/drc_engine.h>
32#include <drc/drc_item.h>
33#include <macros.h>
35
36
38 PCB_TOOL_BASE( "pcbnew.DRETool" ), m_editFrame( nullptr ), m_pcb( nullptr ),
39 m_drcRuleEditorDlg( nullptr )
40{
41}
42
43
47
48
50{
52
53 if( m_pcb != m_editFrame->GetBoard() )
54 {
57
58 m_pcb = m_editFrame->GetBoard();
59 m_drcEngine = m_pcb->GetDesignSettings().m_DRCEngine;
60 }
61}
62
63
65{
67 return m_drcRuleEditorDlg->IsShownOnScreen();
68
69 return false;
70}
71
72
74{
75 // update my pointers, m_editFrame is the only unchangeable one
76 m_pcb = m_editFrame->GetBoard();
77
79 m_drcRuleEditorDlg->UpdateData();
80}
81
82
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();
99
100 if( !m_drcRuleEditorDlg )
101 {
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 {
113 m_drcRuleEditorDlg->Show( true );
114 }
115}
116
117
119{
120 ShowDRCRuleEditorDialog( nullptr );
121 return 0;
122}
123
124
126{
128 {
129 m_drcRuleEditorDlg->Destroy();
130 m_drcRuleEditorDlg = nullptr;
131 }
132}
133
134
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:224
std::shared_ptr< DRC_ENGINE > m_drcEngine
void updatePointers()
Update needed pointers from the one pointer which is known not to change.
void ShowDRCRuleEditorDialog(wxWindow *aParent)
Opens the DRC Rule Editor dialog.
bool IsDRCRuleEditorDialogShown()
Check to see if the DRC_TOOL dialog is currently shown.
PCB_EDIT_FRAME * m_editFrame
void DestroyDRCRuleEditorDialog()
Close and free the DRC dialog.
void setTransitions() override
< Set up handlers for various events.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
DIALOG_DRC_RULE_EDITOR * m_drcRuleEditorDlg
static TOOL_ACTION drcRuleEditor
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:186
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:78
Generic, UI-independent tool event.
Definition tool_event.h:171
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).
void Activate()
Run the tool.
This file contains miscellaneous commonly used macros and functions.