KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_viewer_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 The 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef PCB_VIEWER_TOOLS_H_
25#define PCB_VIEWER_TOOLS_H_
26
27#include <board.h>
29#include <pcbnew_settings.h>
30#include <pcb_base_frame.h>
31#include <pcb_view.h>
32
33
41{
42public:
44 TOOL_INTERACTIVE( "pcbnew.PCBViewerTools" ),
45 m_footprintFrame( false ),
46 m_isDefaultTool( false )
47 {}
48
49 ~PCB_VIEWER_TOOLS() override {}
50
51 bool Init() override;
52
54 void Reset( RESET_REASON aReason ) override;
55
57 int MeasureTool( const TOOL_EVENT& aEvent );
58 int ToggleHV45Mode( const TOOL_EVENT& aEvent );
59
60 // Display modes
61 int ShowPadNumbers( const TOOL_EVENT& aEvent );
62 int PadDisplayMode( const TOOL_EVENT& aEvent );
63 int GraphicOutlines( const TOOL_EVENT& aEvent );
64 int TextOutlines( const TOOL_EVENT& aEvent );
65
67 int FootprintAutoZoom( const TOOL_EVENT& aEvent );
68
70 int Show3DViewer( const TOOL_EVENT& aEvent );
71
73 void setTransitions() override;
74
83 void SetFootprintFrame( bool aIsFrame )
84 {
85 m_footprintFrame = aIsFrame;
86 }
87
88 void SetIsDefaultTool( bool aIsDefaultTool )
89 {
90 m_isDefaultTool = aIsDefaultTool;
91 }
92
93 bool IsFootprintFrame() const
94 {
95 return m_footprintFrame;
96 }
97
98protected:
100 {
101 return getEditFrame<PCB_BASE_FRAME>();
102 }
103
105 {
106 return static_cast<KIGFX::PCB_VIEW*>( getView() );
107 }
108
110 {
111 return frame()->GetPcbNewSettings()->m_Display;
112 }
113
115 {
116 return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetCanvas() );
117 }
118
119 BOARD* board() const
120 {
121 return getModel<BOARD>();
122 }
123
125 {
126 return board()->GetFirstFootprint();
127 }
128
129protected:
132};
133
134#endif
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:487
DISPLAY_OPTIONS m_Display
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Tool useful for viewing footprints.
bool Init() override
Init() is called once upon a registration of the tool.
void SetFootprintFrame(bool aIsFrame)
Toggle edit footprint mode.
bool m_isDefaultTool
Indicates no selection tool is present in the current toolset.
int FootprintAutoZoom(const TOOL_EVENT &aEvent)
Automatically zoom to fit on footprints.
PCBNEW_SETTINGS::DISPLAY_OPTIONS & displayOptions() const
~PCB_VIEWER_TOOLS() override
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
PCB_BASE_FRAME * frame() const
int PadDisplayMode(const TOOL_EVENT &aEvent)
int ToggleHV45Mode(const TOOL_EVENT &aEvent)
FOOTPRINT * footprint() const
BOARD * board() const
KIGFX::PCB_VIEW * view() const
int MeasureTool(const TOOL_EVENT &aEvent)
int TextOutlines(const TOOL_EVENT &aEvent)
PCB_DRAW_PANEL_GAL * canvas() const
bool IsFootprintFrame() const
int Show3DViewer(const TOOL_EVENT &aEvent)
Show the 3D viewer.
void SetIsDefaultTool(bool aIsDefaultTool)
int GraphicOutlines(const TOOL_EVENT &aEvent)
int ShowPadNumbers(const TOOL_EVENT &aEvent)
bool m_footprintFrame
Is this tool associated with a footprint frame.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:38
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:168
void Reset() override