KiCad PCB EDA Suite
pcbnew/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) 2013-2017 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  * Copyright (C) 2017 KiCad Developers, see CHANGELOG.TXT for contributors.
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 __SELECTION_TOOL_H
28 #define __SELECTION_TOOL_H
29 
30 #include <memory>
31 
32 #include <math/vector2d.h>
33 #include <tools/pcb_tool.h>
34 #include <tool/context_menu.h>
35 #include <tool/selection.h>
36 
38 #include <tool/tool_menu.h>
39 
40 class PCB_BASE_FRAME;
41 class BOARD_ITEM;
42 class GENERAL_COLLECTOR;
43 
44 namespace KIGFX
45 {
46  class GAL;
47 }
48 
49 
51 
52 
64 class SELECTION_TOOL : public PCB_TOOL
65 {
66 public:
68  ~SELECTION_TOOL();
69 
71  bool Init() override;
72 
74  void Reset( RESET_REASON aReason ) override;
75 
81  int Main( const TOOL_EVENT& aEvent );
82 
88  SELECTION& GetSelection();
89 
97  SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter );
98 
99 
101  {
102  return m_menu;
103  }
104 
106  SELECTION_LOCK_FLAGS CheckLock();
107 
109  int CursorSelection( const TOOL_EVENT& aEvent );
110 
112  int ClearSelection( const TOOL_EVENT& aEvent );
113 
115  int SelectItem( const TOOL_EVENT& aEvent );
116 
118  int SelectItems( const TOOL_EVENT& aEvent );
119 
121  int UnselectItem( const TOOL_EVENT& aEvent );
122 
124  int UnselectItems( const TOOL_EVENT& aEvent );
125 
131  int SelectionMenu( const TOOL_EVENT& aEvent );
132 
134  static const TOOL_EVENT SelectedEvent;
135 
138 
140  static const TOOL_EVENT ClearedEvent;
141 
143  void setTransitions() override;
144 
146  void zoomFitSelection();
147 
148 private:
161  bool selectPoint( const VECTOR2I& aWhere, bool aOnDrag = false,
162  bool* aSelectionCancelledFlag = NULL,
163  CLIENT_SELECTION_FILTER aClientFilter = NULL );
164 
173  bool selectCursor( bool aSelectAlways = false,
174  CLIENT_SELECTION_FILTER aClientFilter = NULL );
175 
183  bool selectMultiple();
184 
190  BOARD_ITEM* doSelectionMenu( GENERAL_COLLECTOR* aItems, const wxString& aTitle );
191 
193  int selectConnection( const TOOL_EVENT& aEvent );
194 
196  int expandSelectedConnection( const TOOL_EVENT& aEvent );
197 
199  int selectCopper( const TOOL_EVENT& aEvent );
200 
205  int selectNet( const TOOL_EVENT& aEvent );
206 
210  void selectAllItemsConnectedToTrack( TRACK& aSourceTrack );
211 
215  void selectAllItemsConnectedToItem( BOARD_CONNECTED_ITEM& aSourceItem );
216 
220  void selectAllItemsOnNet( int aNetCode );
221 
226  void selectAllItemsOnSheet( wxString& aSheetpath );
227 
230  int selectOnSheetFromEeschema( const TOOL_EVENT& aEvent );
231 
234  int selectSameSheet( const TOOL_EVENT& aEvent );
235 
237  void findCallback( BOARD_ITEM* aItem );
238 
240  int find( const TOOL_EVENT& aEvent );
241 
243  int findMove( const TOOL_EVENT& aEvent );
244 
246  int filterSelection( const TOOL_EVENT& aEvent );
247 
252  void clearSelection();
253 
260  BOARD_ITEM* pickSmallestComponent( GENERAL_COLLECTOR* aCollector );
261 
268  void toggleSelection( BOARD_ITEM* aItem );
269 
276  bool selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly = false ) const;
277 
284  void select( BOARD_ITEM* aItem );
285 
292  void unselect( BOARD_ITEM* aItem );
293 
301  void highlight( BOARD_ITEM* aItem, int aHighlightMode, SELECTION& aGroup );
302 
310  void unhighlight( BOARD_ITEM* aItem, int aHighlightMode, SELECTION& aGroup );
311 
318  bool selectionContains( const VECTOR2I& aPoint ) const;
319 
327  void guessSelectionCandidates( GENERAL_COLLECTOR& aCollector, const VECTOR2I& aWhere ) const;
328 
332  int updateSelection( const TOOL_EVENT& aEvent );
333 
334  const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const;
335 
338 
341 
344 
347 
350 
353 
355  bool m_locked;
356 
359 
361  class PRIV;
362  std::unique_ptr<PRIV> m_priv;
363 };
364 
365 #endif
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
std::unique_ptr< PRIV > m_priv
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
bool m_multiple
Flag saying if multiple selection mode is active.
Class SELECTION_TOOL.
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
Class TOOL_MENU.
Definition: tool_menu.h:47
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
Private implementation of firewalled private data.
void(* CLIENT_SELECTION_FILTER)(const VECTOR2I &, GENERAL_COLLECTOR &)
SELECTION_LOCK_FLAGS
Definition: selection.h:229
Class TOOL_EVENT.
Definition: tool_event.h:168
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
TOOL_MENU m_menu
Menu model displayed by the tool.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
bool m_subtractive
Flag saying if items should be removed from the current selection.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:245
bool m_skip_heuristics
Flag saying that heuristics should be skipped while choosing selection.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
bool m_locked
Can other tools modify locked items.
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:391
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...