KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2022 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>
27#include <tool/action_menu.h>
29#include <tool/selection_tool.h>
30#include <tool/tool_menu.h>
32#include <gerbview_frame.h>
33
34class SELECTION_AREA;
36
37namespace KIGFX
38{
39 class GAL;
40}
41
42
47{
48public:
51
53 bool Init() override;
54
56 void Reset( RESET_REASON aReason ) override;
57
61 int Main( const TOOL_EVENT& aEvent );
62
67
68 int ClearSelection( const TOOL_EVENT& aEvent );
69
70 int SelectItem( const TOOL_EVENT& aEvent );
71 int SelectItems( const TOOL_EVENT& aEvent );
72
73 int UnselectItem( const TOOL_EVENT& aEvent );
74 int UnselectItems( const TOOL_EVENT& aEvent );
75
77 void setTransitions() override;
78
79protected:
80 SELECTION& selection() override { return m_selection; }
81
82private:
90 bool selectPoint( const VECTOR2I& aWhere );
91
95 void clearSelection();
96
102 bool selectable( const EDA_ITEM* aItem ) const;
103
109 void select( EDA_ITEM* aItem ) override;
110
116 void unselect( EDA_ITEM* aItem ) override;
117
123 void selectVisually( EDA_ITEM* aItem );
124
130 void unselectVisually( EDA_ITEM* aItem );
131
139 void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override
140 {
141 // Currently not used in GerbView
142 };
143
151 void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override
152 {
153 // Currently not used in GerbView
154 };
155
156private:
157 GERBVIEW_FRAME* m_frame; // Pointer to the parent frame.
158 GERBVIEW_SELECTION m_selection; // Current state of selection.
159};
160
161#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
Use when the right click button is pressed or when the select tool is in effect.
Selection tool for GerbView, based on the one in Pcbnew.
int SelectItem(const TOOL_EVENT &aEvent)
bool selectable(const EDA_ITEM *aItem) const
Check conditions for an item to be selected.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
bool Init() override
Init() is called once upon a registration of the tool.
int Main(const TOOL_EVENT &aEvent)
The main loop.
int SelectItems(const TOOL_EVENT &aEvent)
int UnselectItems(const TOOL_EVENT &aEvent)
Sets up handlers for various events.
void clearSelection()
Clear the current selection.
void unselect(EDA_ITEM *aItem) override
Take necessary action mark an item as unselected.
void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Highlight the item visually.
void unselectVisually(EDA_ITEM *aItem)
Mark item as selected, but does not add it to the #ITEMS_PICKED_LIST.
bool selectPoint(const VECTOR2I &aWhere)
Select an item pointed by the parameter aWhere.
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Unhighlight the item visually.
int UnselectItem(const TOOL_EVENT &aEvent)
int ClearSelection(const TOOL_EVENT &aEvent)
void selectVisually(EDA_ITEM *aItem)
Mark item as selected, but does not add it to the #ITEMS_PICKED_LIST.
SELECTION & selection() override
Return a reference to the selection.
GERBVIEW_SELECTION & GetSelection()
Return the set of currently selected items.
void select(EDA_ITEM *aItem) override
Take necessary action mark an item as selected.
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:167
void Reset() override
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247