KiCad PCB EDA Suite
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 (C) 2020 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 <class_board.h>
28 #include <tool/tool_interactive.h>
29 
30 class PCB_BASE_FRAME;
31 
40 {
41 public:
43  TOOL_INTERACTIVE( "pcbnew.PCBViewerTools" ),
44  m_footprintFrame( false )
45  {}
46 
47  ~PCB_VIEWER_TOOLS() override {}
48 
49  bool Init() override;
50 
52  void Reset( RESET_REASON aReason ) override;
53 
55  int MeasureTool( const TOOL_EVENT& aEvent );
56 
57  // Display modes
58  int ShowPadNumbers( const TOOL_EVENT& aEvent );
59  int PadDisplayMode( const TOOL_EVENT& aEvent );
60  int GraphicOutlines( const TOOL_EVENT& aEvent );
61  int TextOutlines( const TOOL_EVENT& aEvent );
62  int ZoomAutomatically( const TOOL_EVENT& aEvent );
63 
65  int Show3DViewer( const TOOL_EVENT& aEvent );
66 
68  void setTransitions() override;
69 
75  void SetFootprintFrame( bool aIsFrame )
76  {
77  m_footprintFrame = aIsFrame;
78  }
79 
80  bool IsFootprintFrame() const
81  {
82  return m_footprintFrame;
83  }
84 
85 protected:
87 
89  {
90  return getEditFrame<PCB_BASE_FRAME>();
91  }
92 
94  {
95  return static_cast<KIGFX::PCB_VIEW*>( getView() );
96  }
97 
99  {
100  return frame()->GetDisplayOptions();
101  }
102 
104  {
105  return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetCanvas() );
106  }
107 
108  BOARD* board() const
109  {
110  return getModel<BOARD>();
111  }
112 
113  MODULE* module() const
114  {
115  return board()->GetFirstModule();
116  }
117 };
118 
119 #endif
int ShowPadNumbers(const TOOL_EVENT &aEvent)
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
~PCB_VIEWER_TOOLS() override
PCB_BASE_FRAME * frame() const
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
KIGFX::PCB_VIEW * view() const
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
int Show3DViewer(const TOOL_EVENT &aEvent)
Show the 3D viewer.
void setTransitions() override
Sets up handlers for various events.
bool m_footprintFrame
Is this tool associated with a footprint frame.
TOOL_EVENT.
Definition: tool_event.h:171
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:330
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
int ZoomAutomatically(const TOOL_EVENT &aEvent)
bool IsFootprintFrame() const
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
const PCB_DISPLAY_OPTIONS & displayOptions() const
int GraphicOutlines(const TOOL_EVENT &aEvent)
BOARD * board() const
PCB_DRAW_PANEL_GAL * canvas() const
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
PCB_VIEWER_TOOLS.
int TextOutlines(const TOOL_EVENT &aEvent)
void SetFootprintFrame(bool aIsFrame)
Toggles edit module mode.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
MODULE * module() const
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
int PadDisplayMode(const TOOL_EVENT &aEvent)
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.