KiCad PCB EDA Suite
gerbview_selection_tool.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) 2017 Jon Evans <[email protected]>
5  * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef GERBVIEW_SELECTION_TOOL_H
22 #define GERBVIEW_SELECTION_TOOL_H
23 
24 #include <memory>
25 #include <math/vector2d.h>
26 #include <tool/tool_interactive.h>
27 #include <tool/action_menu.h>
29 #include <tool/selection_tool.h>
30 #include <tool/tool_menu.h>
32 #include <gerbview_frame.h>
33 
34 class SELECTION_AREA;
35 class GERBER_COLLECTOR;
36 
37 namespace KIGFX
38 {
39  class GAL;
40 }
41 
42 
47 {
48 public:
51 
53  bool Init() override;
54 
56  void Reset( RESET_REASON aReason ) override;
57 
58  // called to rebuild a CONDITIONAL_MENU before opening it:
59  int UpdateMenu( const TOOL_EVENT& aEvent );
60 
64  int Main( const TOOL_EVENT& aEvent );
65 
70 
71  int ClearSelection( const TOOL_EVENT& aEvent );
72 
73  int SelectItem( const TOOL_EVENT& aEvent );
74  int SelectItems( const TOOL_EVENT& aEvent );
75 
76  int UnselectItem( const TOOL_EVENT& aEvent );
77  int UnselectItems( const TOOL_EVENT& aEvent );
78 
80  void setTransitions() override;
81 
82 private:
92  bool selectPoint( const VECTOR2I& aWhere, bool aOnDrag = false );
93 
101  bool selectCursor( bool aSelectAlways = false );
102 
106  void clearSelection();
107 
115 
121  bool selectable( const EDA_ITEM* aItem ) const;
122 
128  void select( EDA_ITEM* aItem );
129 
135  void unselect( EDA_ITEM* aItem );
136 
142  void selectVisually( EDA_ITEM* aItem );
143 
149  void unselectVisually( EDA_ITEM* aItem );
150 
151  GERBVIEW_FRAME* m_frame; // Pointer to the parent frame.
152  GERBVIEW_SELECTION m_selection; // Current state of selection.
153 
154  bool m_preliminary; // Determines if the selection is preliminary or final.
155 };
156 
157 #endif
bool Init() override
Init() is called once upon a registration of the tool.
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false)
Select an item pointed by the parameter aWhere.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:243
bool selectable(const EDA_ITEM *aItem) const
Check conditions for an item to be selected.
Use when the right click button is pressed or when the select tool is in effect.
EDA_ITEM * disambiguationMenu(GERBER_COLLECTOR *aItems)
Handle the menu that allows one to select one of many items in case there is more than one item at th...
void selectVisually(EDA_ITEM *aItem)
Mark item as selected, but does not add it to the #ITEMS_PICKED_LIST.
int Main(const TOOL_EVENT &aEvent)
The main loop.
int UnselectItem(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void unselect(EDA_ITEM *aItem)
Take necessary action mark an item as unselected.
int UpdateMenu(const TOOL_EVENT &aEvent)
void unselectVisually(EDA_ITEM *aItem)
Mark item as selected, but does not add it to the #ITEMS_PICKED_LIST.
GERBVIEW_SELECTION & GetSelection()
Return the set of currently selected items.
int SelectItems(const TOOL_EVENT &aEvent)
int SelectItem(const TOOL_EVENT &aEvent)
Selection tool for GerbView, based on the one in Pcbnew.
int UnselectItems(const TOOL_EVENT &aEvent)
Sets up handlers for various events.
bool selectCursor(bool aSelectAlways=false)
Select an item under the cursor unless there is something already selected or aSelectAlways is true.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:77
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
void clearSelection()
Clear the current selection.
int ClearSelection(const TOOL_EVENT &aEvent)