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 <jon@craftyjon.com>
5  * Copyright (C) 2017-2019 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/tool_menu.h>
31 #include <gerbview_frame.h>
32 
33 class SELECTION_AREA;
34 class GERBER_COLLECTOR;
35 
36 namespace KIGFX
37 {
38  class GAL;
39 }
40 
41 
48 {
49 public:
52 
54  bool Init() override;
55 
57  void Reset( RESET_REASON aReason ) override;
58 
59  // called to rebuild a CONDITIONAL_MENU before opening it:
60  int UpdateMenu( const TOOL_EVENT& aEvent );
61 
67  int Main( const TOOL_EVENT& aEvent );
68 
75 
76  int ClearSelection( const TOOL_EVENT& aEvent );
77 
78  int SelectItem( const TOOL_EVENT& aEvent );
79  int SelectItems( const TOOL_EVENT& aEvent );
80 
81  int UnselectItem( const TOOL_EVENT& aEvent );
82  int UnselectItems( const TOOL_EVENT& aEvent );
83 
85  int MeasureTool( const TOOL_EVENT& aEvent );
86 
88  void setTransitions() override;
89 
90 private:
101  bool selectPoint( const VECTOR2I& aWhere, bool aOnDrag = false );
102 
110  bool selectCursor( bool aSelectAlways = false );
111 
116  void clearSelection();
117 
126 
133  bool selectable( const EDA_ITEM* aItem ) const;
134 
141  void select( EDA_ITEM* aItem );
142 
149  void unselect( EDA_ITEM* aItem );
150 
156  void selectVisually( EDA_ITEM* aItem );
157 
163  void unselectVisually( EDA_ITEM* aItem );
164 
165  GERBVIEW_FRAME* m_frame; // Pointer to the parent frame.
166  GERBVIEW_SELECTION m_selection; // Current state of selection.
167 
168  bool m_additive; // Items should be added to selection (instead of replacing)
169  bool m_subtractive; // Items should be removed from selection
170  bool m_exclusive_or; // Items' selection state should be toggled
171  bool m_preliminary; // Determines if the selection is preliminary or final.
172 };
173 
174 #endif
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
bool selectable(const EDA_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
Class GERBER_COLLECTOR is intended for use when the right click button is pressed,...
EDA_ITEM * disambiguationMenu(GERBER_COLLECTOR *aItems)
Function disambiguationMenu() Handles the menu that allows one to select one of many items in case th...
void selectVisually(EDA_ITEM *aItem)
Function selectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
int Main(const TOOL_EVENT &aEvent)
Function Main()
int UnselectItem(const TOOL_EVENT &aEvent)
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.
Class TOOL_EVENT.
Definition: tool_event.h:168
void unselect(EDA_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
int UpdateMenu(const TOOL_EVENT &aEvent)
void unselectVisually(EDA_ITEM *aItem)
Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
GERBVIEW_SELECTION & GetSelection()
Function GetSelection()
int SelectItems(const TOOL_EVENT &aEvent)
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
int SelectItem(const TOOL_EVENT &aEvent)
Class GERBVIEW_SELECTION_TOOL.
int UnselectItems(const TOOL_EVENT &aEvent)
bool selectCursor(bool aSelectAlways=false)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
void select(EDA_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
void clearSelection()
Function clearSelection() Clears the current selection.
int ClearSelection(const TOOL_EVENT &aEvent)