KiCad PCB EDA Suite
gerbview/tools/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 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 
27 #include <tool/tool_interactive.h>
28 #include <tool/context_menu.h>
29 #include <tool/selection.h>
31 #include <tool/tool_menu.h>
32 
33 #include <gerbview_frame.h>
34 
35 class SELECTION_AREA;
36 class GERBER_COLLECTOR;
37 
38 namespace KIGFX
39 {
40  class GAL;
41 }
42 
43 
50 {
51 public:
54 
56  bool Init() override;
57 
59  void Reset( RESET_REASON aReason ) override;
60 
66  int Main( const TOOL_EVENT& aEvent );
67 
73  SELECTION& GetSelection();
74 
76  {
77  return m_menu;
78  }
79 
81  int CursorSelection( const TOOL_EVENT& aEvent );
82 
84  int ClearSelection( const TOOL_EVENT& aEvent );
85 
87  int SelectItem( const TOOL_EVENT& aEvent );
88 
90  int SelectItems( const TOOL_EVENT& aEvent );
91 
93  int UnselectItem( const TOOL_EVENT& aEvent );
94 
96  int UnselectItems( const TOOL_EVENT& aEvent );
97 
99  int MeasureTool( const TOOL_EVENT& aEvent );
100 
102  static const TOOL_EVENT SelectedEvent;
103 
106 
108  static const TOOL_EVENT ClearedEvent;
109 
111  void setTransitions() override;
112 
114  void zoomFitSelection( void );
115 
116 private:
128  bool selectPoint( const VECTOR2I& aWhere, bool aOnDrag = false );
129 
137  bool selectCursor( bool aSelectAlways = false );
138 
146  bool selectMultiple();
147 
152  void clearSelection();
153 
161  EDA_ITEM* disambiguationMenu( GERBER_COLLECTOR* aItems );
162 
169  void toggleSelection( EDA_ITEM* aItem );
170 
177  bool selectable( const EDA_ITEM* aItem ) const;
178 
185  void select( EDA_ITEM* aItem );
186 
193  void unselect( EDA_ITEM* aItem );
194 
200  void selectVisually( EDA_ITEM* aItem );
201 
207  void unselectVisually( EDA_ITEM* aItem );
208 
215  bool selectionContains( const VECTOR2I& aPoint ) const;
216 
223  void guessSelectionCandidates( GERBER_COLLECTOR& aCollector ) const;
224 
227 
230 
233 
236 
239 
242 
245 };
246 
247 #endif
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
Class GERBER_COLLECTOR is intended for use when the right click button is pressed, or when the plain "arrow" tool is in effect.
bool m_preliminary
Determines if the selection is preliminary or final.
SELECTION m_selection
Current state of selection.
Class TOOL_MENU.
Definition: tool_menu.h:47
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
Class TOOL_EVENT.
Definition: tool_event.h:168
GERBVIEW_FRAME * m_frame
Pointer to the parent frame.
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
Class GERBVIEW_SELECTION_TOOL.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
TOOL_MENU m_menu
Menu model displayed by the tool.
bool m_multiple
Flag saying if multiple selection mode is active.
bool m_subtractive
Flag saying if items should be removed from the current selection.