KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_tool_base.h
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) 2019 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
24#include <string>
25
26class EDA_ITEM;
27class SCH_BASE_FRAME;
28class SCH_EDIT_FRAME;
31enum class UNDO_REDO;
32
33namespace KIGFX
34{
35class SCH_VIEW;
36}
37
38class SCH_SELECTION;
39
43
44
45template <class T>
47{
48public:
52 SCH_TOOL_BASE( const std::string& aName );
53
54 ~SCH_TOOL_BASE() override;
55
57 bool Init() override;
58
60 void Reset( RESET_REASON aReason ) override;
61
65 bool IsSymbolEditor() const;
66
67 int Increment( const TOOL_EVENT& aEvent );
68
69 int InteractiveDelete( const TOOL_EVENT& aEvent );
70
71protected:
72 template <class F = SCH_BASE_FRAME>
73 F* frame() const
74 {
75 return getEditFrame<F>();
76 }
77
84 EDA_ITEM* getDrawParent() const;
85
89 void updateItem( EDA_ITEM* aItem, bool aUpdateRTree ) const;
90
92 void saveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aType, bool aAppend = false, bool aDirtyConnectivity = true );
93
94protected:
100};
101
102extern template class SCH_TOOL_BASE<SCH_BASE_FRAME>;
103extern template class SCH_TOOL_BASE<SCH_EDIT_FRAME>;
104extern template class SCH_TOOL_BASE<SYMBOL_EDIT_FRAME>;
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Schematic editor (Eeschema) main window.
A foundation class for a tool operating on a schematic or symbol.
void updateItem(EDA_ITEM *aItem, bool aUpdateRTree) const
Similar to getView()->Update(), but also updates the SCH_SCREEN's RTree.
int Increment(const TOOL_EVENT &aEvent)
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false, bool aDirtyConnectivity=true)
Similar to m_frame->SaveCopyInUndoList(), but also handles connectivity.
int InteractiveDelete(const TOOL_EVENT &aEvent)
bool IsSymbolEditor() const
Returns true if the tool is running in the symbol editor.
KIGFX::SCH_VIEW * m_view
bool Init() override
Init() is called once upon a registration of the tool.
EDA_ITEM * getDrawParent() const
Return the parent container for new draw-items in the active editor.
EDA_ITEM * m_pickerItem
F * frame() const
~SCH_TOOL_BASE() override
SCH_TOOL_BASE(const std::string &aName)
Create a tool with given name.
SCH_SELECTION_TOOL * m_selectionTool
The symbol library editor main window.
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:182
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
Generic, UI-independent tool event.
Definition tool_event.h:167
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
void Reset() override
#define F(x, y, z)
Definition md5_hash.cpp:15
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...