KiCad PCB EDA Suite
Loading...
Searching...
No Matches
common_tools.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) 2014-2016 CERN
5
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6
*
7
* @author Maciej Suminski <
[email protected]
>
8
*
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public License
11
* as published by the Free Software Foundation; either version 2
12
* of the License, or (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, you may find one here:
21
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22
* or you may search the http://www.gnu.org website for the version 2 license,
23
* or you may write to the Free Software Foundation, Inc.,
24
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25
*/
26
27
#ifndef _COMMON_TOOLS_H
28
#define _COMMON_TOOLS_H
29
30
#include <
tool/tool_interactive.h
>
31
32
class
EDA_DRAW_FRAME
;
33
37
class
COMMON_TOOLS
:
public
TOOL_INTERACTIVE
38
{
39
public
:
40
COMMON_TOOLS
();
41
42
~COMMON_TOOLS
()
override
{ }
43
45
void
Reset
(
RESET_REASON
aReason )
override
;
46
47
int
SelectionTool
(
const
TOOL_EVENT
& aEvent );
48
49
// View controls
50
int
ZoomRedraw
(
const
TOOL_EVENT
& aEvent );
51
int
ZoomInOut
(
const
TOOL_EVENT
& aEvent );
52
int
ZoomInOutCenter
(
const
TOOL_EVENT
& aEvent );
53
int
ZoomCenter
(
const
TOOL_EVENT
& aEvent );
54
int
ZoomFitScreen
(
const
TOOL_EVENT
& aEvent );
55
int
ZoomFitObjects
(
const
TOOL_EVENT
& aEvent );
56
int
ZoomFitSelection
(
const
TOOL_EVENT
& aEvent );
57
int
ZoomPreset
(
const
TOOL_EVENT
& aEvent );
58
59
int
CenterContents
(
const
TOOL_EVENT
& aEvent );
60
int
CenterSelection
(
const
TOOL_EVENT
& aEvent );
61
62
int
PanControl
(
const
TOOL_EVENT
& aEvent );
63
64
// Cursor control
65
int
CursorControl
(
const
TOOL_EVENT
& aEvent );
66
int
ToggleCursor
(
const
TOOL_EVENT
& aEvent );
67
int
CursorSmallCrosshairs
(
const
TOOL_EVENT
& aEvent );
68
int
CursorFullCrosshairs
(
const
TOOL_EVENT
& aEvent );
69
int
Cursor45Crosshairs
(
const
TOOL_EVENT
& aEvent );
70
71
int
ToggleBoundingBoxes
(
const
TOOL_EVENT
& aEvent );
72
73
// Units control
74
int
SwitchUnits
(
const
TOOL_EVENT
& aEvent );
75
int
ToggleUnits
(
const
TOOL_EVENT
& aEvent );
76
int
TogglePolarCoords
(
const
TOOL_EVENT
& aEvent );
77
int
ResetLocalCoords
(
const
TOOL_EVENT
& aEvent );
78
79
void
SetLastUnits
(
EDA_UNITS
aUnit );
80
EDA_UNITS
GetLastMetricUnits
() {
return
m_metricUnit
; }
81
EDA_UNITS
GetLastImperialUnits
() {
return
m_imperialUnit
; }
82
83
// Grid control
84
int
GridNext
(
const
TOOL_EVENT
& aEvent );
85
int
GridPrev
(
const
TOOL_EVENT
& aEvent );
86
int
GridPreset
(
const
TOOL_EVENT
& aEvent );
87
int
GridFast1
(
const
TOOL_EVENT
& aEvent );
88
int
GridFast2
(
const
TOOL_EVENT
& aEvent );
89
int
GridFastCycle
(
const
TOOL_EVENT
& aEvent );
90
int
ToggleGrid
(
const
TOOL_EVENT
& aEvent );
91
int
ToggleGridOverrides
(
const
TOOL_EVENT
& aEvent );
92
int
GridProperties
(
const
TOOL_EVENT
& aEvent );
93
int
GridPreset
(
int
idx,
bool
aFromHotkey );
94
int
GridOrigin
(
const
TOOL_EVENT
& aEvent );
95
int
OnGridChanged
(
bool
aFromHotkey );
96
97
const
std::vector<VECTOR2I>
Grids
()
const
{
return
m_grids
; }
98
99
private
:
103
enum
ZOOM_FIT_TYPE_T
104
{
105
ZOOM_FIT_ALL
,
106
ZOOM_FIT_OBJECTS
,
107
ZOOM_FIT_SELECTION
,
108
};
109
110
enum class
CENTER_TYPE
111
{
112
CENTER_CONTENTS
,
113
CENTER_SELECTION
,
114
};
115
117
void
setTransitions
()
override
;
118
120
EDA_DRAW_FRAME
*
m_frame
;
121
122
int
doZoomInOut
(
bool
aDirection,
bool
aCenterOnCursor );
123
125
int
doZoomToPreset
(
int
idx,
bool
aCenterOnCursor );
126
127
int
doZoomFit
(
ZOOM_FIT_TYPE_T
aFitType );
128
129
int
doCenter
(
CENTER_TYPE
aCenterType );
130
131
std::vector<VECTOR2I>
m_grids
;
133
134
// The last used units in each system (used for toggling between metric and imperial)
135
EDA_UNITS
m_imperialUnit
;
136
EDA_UNITS
m_metricUnit
;
137
};
138
139
#endif
COMMON_TOOLS::ZoomFitSelection
int ZoomFitSelection(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:309
COMMON_TOOLS::~COMMON_TOOLS
~COMMON_TOOLS() override
Definition
common_tools.h:42
COMMON_TOOLS::ZoomCenter
int ZoomCenter(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:287
COMMON_TOOLS::doCenter
int doCenter(CENTER_TYPE aCenterType)
Definition
common_tools.cpp:417
COMMON_TOOLS::GridProperties
int GridProperties(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:602
COMMON_TOOLS::GridFastCycle
int GridFastCycle(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:576
COMMON_TOOLS::GridOrigin
int GridOrigin(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:629
COMMON_TOOLS::doZoomToPreset
int doZoomToPreset(int idx, bool aCenterOnCursor)
Definition
common_tools.cpp:461
COMMON_TOOLS::PanControl
int PanControl(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:187
COMMON_TOOLS::m_metricUnit
EDA_UNITS m_metricUnit
Definition
common_tools.h:136
COMMON_TOOLS::m_imperialUnit
EDA_UNITS m_imperialUnit
Definition
common_tools.h:135
COMMON_TOOLS::SwitchUnits
int SwitchUnits(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:647
COMMON_TOOLS::CursorSmallCrosshairs
int CursorSmallCrosshairs(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:713
COMMON_TOOLS::ToggleGrid
int ToggleGrid(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:588
COMMON_TOOLS::GridFast1
int GridFast1(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:564
COMMON_TOOLS::Cursor45Crosshairs
int Cursor45Crosshairs(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:737
COMMON_TOOLS::SetLastUnits
void SetLastUnits(EDA_UNITS aUnit)
Definition
common_tools.cpp:87
COMMON_TOOLS::ToggleUnits
int ToggleUnits(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:663
COMMON_TOOLS::GridFast2
int GridFast2(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:570
COMMON_TOOLS::GridNext
int GridNext(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:495
COMMON_TOOLS::OnGridChanged
int OnGridChanged(bool aFromHotkey)
Definition
common_tools.cpp:537
COMMON_TOOLS::Grids
const std::vector< VECTOR2I > Grids() const
Definition
common_tools.h:97
COMMON_TOOLS::setTransitions
void setTransitions() override
Pointer to the currently used edit frame.
Definition
common_tools.cpp:767
COMMON_TOOLS::CenterSelection
int CenterSelection(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:405
COMMON_TOOLS::ZoomPreset
int ZoomPreset(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:453
COMMON_TOOLS::ZoomFitScreen
int ZoomFitScreen(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:297
COMMON_TOOLS::ToggleBoundingBoxes
int ToggleBoundingBoxes(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:749
COMMON_TOOLS::GetLastImperialUnits
EDA_UNITS GetLastImperialUnits()
Definition
common_tools.h:81
COMMON_TOOLS::ToggleGridOverrides
int ToggleGridOverrides(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:595
COMMON_TOOLS::m_grids
std::vector< VECTOR2I > m_grids
Grids from #APP_SETTINGS converted to internal units and with the user grid appended.
Definition
common_tools.h:131
COMMON_TOOLS::ToggleCursor
int ToggleCursor(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:701
COMMON_TOOLS::CursorFullCrosshairs
int CursorFullCrosshairs(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:725
COMMON_TOOLS::COMMON_TOOLS
COMMON_TOOLS()
Definition
common_tools.cpp:50
COMMON_TOOLS::ZoomFitObjects
int ZoomFitObjects(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:303
COMMON_TOOLS::CENTER_TYPE
CENTER_TYPE
Definition
common_tools.h:111
COMMON_TOOLS::CENTER_TYPE::CENTER_CONTENTS
@ CENTER_CONTENTS
Definition
common_tools.h:112
COMMON_TOOLS::CENTER_TYPE::CENTER_SELECTION
@ CENTER_SELECTION
Definition
common_tools.h:113
COMMON_TOOLS::CenterContents
int CenterContents(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:411
COMMON_TOOLS::TogglePolarCoords
int TogglePolarCoords(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:672
COMMON_TOOLS::GridPrev
int GridPrev(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:508
COMMON_TOOLS::ZoomInOutCenter
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:238
COMMON_TOOLS::ZoomRedraw
int ZoomRedraw(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:224
COMMON_TOOLS::ResetLocalCoords
int ResetLocalCoords(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:682
COMMON_TOOLS::m_frame
EDA_DRAW_FRAME * m_frame
Definition
common_tools.h:120
COMMON_TOOLS::doZoomFit
int doZoomFit(ZOOM_FIT_TYPE_T aFitType)
Definition
common_tools.cpp:315
COMMON_TOOLS::CursorControl
int CursorControl(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:108
COMMON_TOOLS::ZOOM_FIT_TYPE_T
ZOOM_FIT_TYPE_T
The set of "Zoom to Fit" types that can be performed.
Definition
common_tools.h:104
COMMON_TOOLS::ZOOM_FIT_SELECTION
@ ZOOM_FIT_SELECTION
Zoom to fit selected items in view.
Definition
common_tools.h:107
COMMON_TOOLS::ZOOM_FIT_ALL
@ ZOOM_FIT_ALL
Zoom to fall all items in view INCLUDING page and border.
Definition
common_tools.h:105
COMMON_TOOLS::ZOOM_FIT_OBJECTS
@ ZOOM_FIT_OBJECTS
Zoom to fit all items in view EXCLUDING page and border.
Definition
common_tools.h:106
COMMON_TOOLS::SelectionTool
int SelectionTool(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:98
COMMON_TOOLS::GetLastMetricUnits
EDA_UNITS GetLastMetricUnits()
Definition
common_tools.h:80
COMMON_TOOLS::GridPreset
int GridPreset(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:521
COMMON_TOOLS::ZoomInOut
int ZoomInOut(const TOOL_EVENT &aEvent)
Definition
common_tools.cpp:231
COMMON_TOOLS::doZoomInOut
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList.
Definition
common_tools.cpp:245
EDA_DRAW_FRAME
The base class for create windows for drawing purpose.
Definition
eda_draw_frame.h:85
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::TOOL_INTERACTIVE
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
Definition
tool_interactive.cpp:39
EDA_UNITS
EDA_UNITS
Definition
eda_units.h:48
Reset
void Reset() override
tool_interactive.h
src
include
tool
common_tools.h
Generated on Sun Sep 21 2025 01:05:26 for KiCad PCB EDA Suite by
1.13.2