KiCad PCB EDA Suite
pcb_control.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 (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
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 PCB_CONTROL_H
28 #define PCB_CONTROL_H
29 
30 #include <io_mgr.h>
31 #include <memory>
32 #include <tools/pcb_tool_base.h>
33 
34 namespace KIGFX {
35  class ORIGIN_VIEWITEM;
36 }
37 
38 class PCB_BASE_FRAME;
39 class BOARD_ITEM;
40 
45 class PCB_CONTROL : public PCB_TOOL_BASE
46 {
47 public:
48  PCB_CONTROL();
49  ~PCB_CONTROL();
50 
52  void Reset( RESET_REASON aReason ) override;
53 
54  int AddLibrary( const TOOL_EVENT& aEvent );
55  int Print( const TOOL_EVENT& aEvent );
56  int Quit( const TOOL_EVENT& aEvent );
57 
58  // Display modes
59  int ToggleRatsnest( const TOOL_EVENT& aEvent );
60  int ZoneDisplayMode( const TOOL_EVENT& aEvent );
61  int TrackDisplayMode( const TOOL_EVENT& aEvent );
62  int ViaDisplayMode( const TOOL_EVENT& aEvent );
63 
64  // Update the view with the new high-contrast mode from the display settings
65  int HighContrastMode( const TOOL_EVENT& aEvent );
66 
67  // Rotate through the available high-contrast modes
68  int HighContrastModeCycle( const TOOL_EVENT& aEvent );
69 
70  // Layer control
71  int LayerSwitch( const TOOL_EVENT& aEvent );
72  int LayerNext( const TOOL_EVENT& aEvent );
73  int LayerPrev( const TOOL_EVENT& aEvent );
74  int LayerToggle( const TOOL_EVENT& aEvent );
75  int LayerAlphaInc( const TOOL_EVENT& aEvent );
76  int LayerAlphaDec( const TOOL_EVENT& aEvent );
77 
78  // Grid control
79  int GridSetOrigin( const TOOL_EVENT& aEvent );
80  int GridResetOrigin( const TOOL_EVENT& aEvent );
81 
82  // Low-level access (below undo) to setting the grid origin
83  static void DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
84  EDA_ITEM* originViewItem, const VECTOR2D& aPoint );
85 
86  int Undo( const TOOL_EVENT& aEvent );
87  int Redo( const TOOL_EVENT& aEvent );
88 
89  // Miscellaneous
90  int DeleteItemCursor( const TOOL_EVENT& aEvent );
91  int Paste( const TOOL_EVENT& aEvent );
92  int AppendBoardFromFile( const TOOL_EVENT& aEvent );
93  int AppendBoard( PLUGIN& pi, wxString& fileName );
94  int UpdateMessagePanel( const TOOL_EVENT& aEvent );
95 
96  int FlipPcbView( const TOOL_EVENT& aEvent );
97 
98 private:
100  void setTransitions() override;
101 
111  int placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew, bool aAnchorAtOrigin );
112 
113  int placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin );
114 
117 
119  std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_gridOrigin;
120 
122 };
123 
124 #endif
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
int GridSetOrigin(const TOOL_EVENT &aEvent)
BOARD_ITEM * m_pickerItem
Definition: pcb_control.h:121
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
int LayerAlphaDec(const TOOL_EVENT &aEvent)
int Redo(const TOOL_EVENT &aEvent)
int LayerNext(const TOOL_EVENT &aEvent)
PCB_BASE_FRAME * m_frame
Grid origin marker.
Definition: pcb_control.h:116
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
int placeBoardItems(std::vector< BOARD_ITEM * > &aItems, bool aIsNew, bool aAnchorAtOrigin)
Add and select or just select for move/place command a list of board items.
int LayerAlphaInc(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: pcb_control.cpp:78
int Undo(const TOOL_EVENT &aEvent)
void setTransitions() override
< Sets up handlers for various events.
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:45
Generic, UI-independent tool event.
Definition: tool_event.h:173
int GridResetOrigin(const TOOL_EVENT &aEvent)
int DeleteItemCursor(const TOOL_EVENT &aEvent)
int HighContrastMode(const TOOL_EVENT &aEvent)
int Quit(const TOOL_EVENT &aEvent)
int LayerSwitch(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int AppendBoard(PLUGIN &pi, wxString &fileName)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
int FlipPcbView(const TOOL_EVENT &aEvent)
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
int HighContrastModeCycle(const TOOL_EVENT &aEvent)
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Definition: pcb_control.h:119
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
int AddLibrary(const TOOL_EVENT &aEvent)
Definition: pcb_control.cpp:92
int LayerPrev(const TOOL_EVENT &aEvent)
int ToggleRatsnest(const TOOL_EVENT &aEvent)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
int LayerToggle(const TOOL_EVENT &aEvent)
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
int TrackDisplayMode(const TOOL_EVENT &aEvent)
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
int ViaDisplayMode(const TOOL_EVENT &aEvent)