KiCad PCB EDA Suite
pcb_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  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef PCB_EDITOR_CONTROL_H
26 #define PCB_EDITOR_CONTROL_H
27 
28 #include <tools/pcb_tool.h>
29 
30 namespace KIGFX {
31  class ORIGIN_VIEWITEM;
32 }
33 
34 class PCB_EDIT_FRAME;
35 
41 class PCB_EDITOR_CONTROL : public wxEvtHandler, public PCB_TOOL
42 {
43 public:
46 
48  void Reset( RESET_REASON aReason ) override;
49 
51  bool Init() override;
52 
53  // Track & via size control
54  int TrackWidthInc( const TOOL_EVENT& aEvent );
55  int TrackWidthDec( const TOOL_EVENT& aEvent );
56  int ViaSizeInc( const TOOL_EVENT& aEvent );
57  int ViaSizeDec( const TOOL_EVENT& aEvent );
58 
59  // Zone actions
60  int ZoneMerge( const TOOL_EVENT& aEvent );
61 
63  int ZoneDuplicate( const TOOL_EVENT& aEvent );
64 
69  int PlaceTarget( const TOOL_EVENT& aEvent );
70 
75  int PlaceModule( const TOOL_EVENT& aEvent );
76 
78  int ToggleLockSelected( const TOOL_EVENT& aEvent );
79 
81  int LockSelected( const TOOL_EVENT& aEvent );
82 
84  int UnlockSelected( const TOOL_EVENT& aEvent );
85 
87  int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
88 
90  int CrossProbeSchToPcb( const TOOL_EVENT& aEvent );
91 
93  int DrillOrigin( const TOOL_EVENT& aEvent );
94 
96  int HighlightNet( const TOOL_EVENT& aEvent );
97 
99  int HighlightNetCursor( const TOOL_EVENT& aEvent );
100 
102  int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
103 
105  int HideSelectionRatsnest( const TOOL_EVENT& aEvent );
106 
108  int ShowLocalRatsnest( const TOOL_EVENT& aEvent );
109 
110 private:
112  void ratsnestTimer( wxTimerEvent& aEvent );
113 
116 
118  void setTransitions() override;
119 
122 
124  std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_placeOrigin;
125 
128 
131 
134 
136  enum MODIFY_MODE { ON, OFF, TOGGLE };
137 
138  int modifyLockSelected( MODIFY_MODE aMode );
139 
140  // How does line width change after one -/+ key press.
141  static const int WIDTH_STEP;
142 };
143 
144 #endif
int ZoneMerge(const TOOL_EVENT &aEvent)
int PlaceModule(const TOOL_EVENT &aEvent)
Function PlaceModule() Displays a dialog to select a module to be added and allows the user to set it...
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
int TrackWidthDec(const TOOL_EVENT &aEvent)
int HideSelectionRatsnest(const TOOL_EVENT &aEvent)
Hides ratsnest for selected items. Called when there are no items selected.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
wxTimer m_ratsnestTimer
Timer that start ratsnest calculation when it is slow to compute.
MODIFY_MODE
How to modify a property for selected items.
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
int ShowLocalRatsnest(const TOOL_EVENT &aEvent)
Shows local ratsnest of a component
int ViaSizeDec(const TOOL_EVENT &aEvent)
int TrackWidthInc(const TOOL_EVENT &aEvent)
Class TOOL_EVENT.
Definition: tool_event.h:162
int DrillOrigin(const TOOL_EVENT &aEvent)
Places the origin point for drill and pick-and-place files.
void ratsnestTimer(wxTimerEvent &aEvent)
Event handler to recalculate dynamic ratsnest
int ViaSizeInc(const TOOL_EVENT &aEvent)
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlocks selected items.
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to pick the item whose net is going to be highlighted.
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
Class PCB_EDITOR_CONTROL.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int PlaceTarget(const TOOL_EVENT &aEvent)
Function PlaceTarget() Allows user to place a layer alignment target.
static const int WIDTH_STEP
int modifyLockSelected(MODIFY_MODE aMode)
bool m_probingSchToPcb
Flag to ignore a single crossprobe message from eeschema.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Notifies eeschema about the selected item.
int CrossProbeSchToPcb(const TOOL_EVENT &aEvent)
Reacts to selection change in eeschema.
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggles 'lock' property for selected items.
bool m_slowRatsnest
Flag to indicate whether the current selection ratsnest is slow to calculate.
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void calculateSelectionRatsnest()
Recalculates dynamic ratsnest for the current selection
void setTransitions() override
Sets up handlers for various events.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.