KiCad PCB EDA Suite
board_editor_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 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 BOARD_EDITOR_CONTROL_H
28 #define BOARD_EDITOR_CONTROL_H
29 
30 #include <tools/pcb_tool_base.h>
31 #include <tool/tool_menu.h>
32 
33 namespace KIGFX {
34  class ORIGIN_VIEWITEM;
35 }
36 
37 class PCB_EDIT_FRAME;
38 
43 {
44 public:
47 
49  void Reset( RESET_REASON aReason ) override;
50 
52  bool Init() override;
53 
54  int New( const TOOL_EVENT& aEvent );
55  int Open( const TOOL_EVENT& aEvent );
56  int Save( const TOOL_EVENT& aEvent );
57  int SaveAs( const TOOL_EVENT& aEvent );
58  int SaveCopyAs( const TOOL_EVENT& aEvent );
59  int PageSettings( const TOOL_EVENT& aEvent );
60  int Plot( const TOOL_EVENT& aEvent );
61 
62  int BoardSetup( const TOOL_EVENT& aEvent );
63  int ImportNetlist( const TOOL_EVENT& aEvent );
64  int ImportSpecctraSession( const TOOL_EVENT& aEvent );
65  int ExportSpecctraDSN( const TOOL_EVENT& aEvent );
66  int GenerateDrillFiles( const TOOL_EVENT& aEvent );
67  int GeneratePosFile( const TOOL_EVENT& aEvent );
68  int GenerateFabFiles( const TOOL_EVENT& aEvent );
69  int RepairBoard( const TOOL_EVENT& aEvent );
70 
71  int UpdatePCBFromSchematic( const TOOL_EVENT& aEvent );
72  int UpdateSchematicFromPCB( const TOOL_EVENT& aEvent );
73  int ShowEeschema( const TOOL_EVENT& aEvent );
74  int ToggleLayersManager( const TOOL_EVENT& aEvent );
75  int TogglePythonConsole( const TOOL_EVENT& aEvent );
76 
77  // Track & via size control
78  int TrackWidthInc( const TOOL_EVENT& aEvent );
79  int TrackWidthDec( const TOOL_EVENT& aEvent );
80  int ViaSizeInc( const TOOL_EVENT& aEvent );
81  int ViaSizeDec( const TOOL_EVENT& aEvent );
82 
83  // Zone actions
84  int ZoneMerge( const TOOL_EVENT& aEvent );
85 
87  int ZoneDuplicate( const TOOL_EVENT& aEvent );
88 
89  int EditFpInFpEditor( const TOOL_EVENT& aEvent );
90 
94  int PlaceTarget( const TOOL_EVENT& aEvent );
95 
99  int PlaceFootprint( const TOOL_EVENT& aEvent );
100 
102  int ToggleLockSelected( const TOOL_EVENT& aEvent );
103 
105  int LockSelected( const TOOL_EVENT& aEvent );
106 
108  int UnlockSelected( const TOOL_EVENT& aEvent );
109 
111  int DrillOrigin( const TOOL_EVENT& aEvent );
112 
114  static void DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
115  EDA_ITEM* aItem, const VECTOR2D& aPoint );
116 
117 private:
119  enum MODIFY_MODE { ON, OFF, TOGGLE };
120 
121  int modifyLockSelected( MODIFY_MODE aMode );
122 
124  void setTransitions() override;
125 
127 
128  std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_placeOrigin;
129 
130  static const int WIDTH_STEP;
131 };
132 
133 #endif
int Open(const TOOL_EVENT &aEvent)
int LockSelected(const TOOL_EVENT &aEvent)
Unlock selected items.
int New(const TOOL_EVENT &aEvent)
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
int TrackWidthInc(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
int Plot(const TOOL_EVENT &aEvent)
int GeneratePosFile(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int ImportNetlist(const TOOL_EVENT &aEvent)
int PageSettings(const TOOL_EVENT &aEvent)
int modifyLockSelected(MODIFY_MODE aMode)
Set up handlers for various events.
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
int DrillOrigin(const TOOL_EVENT &aEvent)
Low-level access (below undo) to setting the drill origin.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
int ViaSizeInc(const TOOL_EVENT &aEvent)
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
int UnlockSelected(const TOOL_EVENT &aEvent)
Run the drill origin tool for setting the origin for drill and pick-and-place files.
static const int WIDTH_STEP
How does line width change after one -/+ key press.
Generic, UI-independent tool event.
Definition: tool_event.h:173
int BoardSetup(const TOOL_EVENT &aEvent)
Handle actions specific to the board editor in PcbNew.
int SaveAs(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
int RepairBoard(const TOOL_EVENT &aEvent)
MODIFY_MODE
< How to modify a property for selected items.
int ShowEeschema(const TOOL_EVENT &aEvent)
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int ZoneMerge(const TOOL_EVENT &aEvent)
Duplicate a zone onto a layer (prompts for new layer)
int PlaceFootprint(const TOOL_EVENT &aEvent)
Display a dialog to select a footprint to be added and allows the user to set its position.
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Lock selected items.
The main frame for Pcbnew.
int TogglePythonConsole(const TOOL_EVENT &aEvent)
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 GenerateDrillFiles(const TOOL_EVENT &aEvent)
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int ViaSizeDec(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 GenerateFabFiles(const TOOL_EVENT &aEvent)
int TrackWidthDec(const TOOL_EVENT &aEvent)
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
int PlaceTarget(const TOOL_EVENT &aEvent)
Allow user to place a layer alignment target.
int SaveCopyAs(const TOOL_EVENT &aEvent)