KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pl_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) 2019 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef PL_SELECTION_TOOL_H
22#define PL_SELECTION_TOOL_H
23
24#include <tool/selection_tool.h>
26#include <tool/tool_menu.h>
27#include "tools/pl_selection.h"
28
29class PL_EDITOR_FRAME;
30class SCH_ITEM;
31class COLLECTOR;
32
33namespace KIGFX
34{
35 class GAL;
36}
37
38
40{
41public:
43 ~PL_SELECTION_TOOL() override { }
44
46 bool Init() override;
47
49 void Reset( RESET_REASON aReason ) override;
50
54 int Main( const TOOL_EVENT& aEvent );
55
60
66
76 void SelectPoint( const VECTOR2I& aWhere, bool* aSelectionCancelledFlag = nullptr );
77
78 int ClearSelection( const TOOL_EVENT& aEvent );
79 void ClearSelection();
80
85 void RebuildSelection();
86
87protected:
88 SELECTION& selection() override { return m_selection; }
89
90private:
96 bool selectMultiple();
97
102 void guessSelectionCandidates( COLLECTOR& collector, const VECTOR2I& aWhere );
103
107 int disambiguateCursor( const TOOL_EVENT& aEvent );
108
114 void select( EDA_ITEM* aItem ) override;
115
121 void unselect( EDA_ITEM* aItem ) override;
122
130 void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
131
139 void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
140
144 bool selectionContains( const VECTOR2I& aPoint ) const;
145
147 void setTransitions() override;
148
149private:
150 PL_EDITOR_FRAME* m_frame; // Pointer to the parent frame
151 PL_SELECTION m_selection; // Current state of selection
152};
153
154#endif //PL_SELECTION_TOOL_H
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
Definition collector.h:45
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
Abstract interface for drawing on a 2D-surface.
The main window used in the drawing sheet editor.
void select(EDA_ITEM *aItem) override
Takes necessary action mark an item as 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 disambiguateCursor(const TOOL_EVENT &aEvent)
Handle disambiguation actions including displaying the menu.
void SelectPoint(const VECTOR2I &aWhere, bool *aSelectionCancelledFlag=nullptr)
Select an item pointed by the parameter aWhere.
void guessSelectionCandidates(COLLECTOR &collector, const VECTOR2I &aWhere)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
~PL_SELECTION_TOOL() override
bool selectionContains(const VECTOR2I &aPoint) const
Set up handlers for various events.
void unselect(EDA_ITEM *aItem) override
Take necessary action mark an item as unselected.
bool selectMultiple()
Handle drawing a selection box that allows one to select many items at the same time.
SELECTION & selection() override
Return a reference to the selection.
PL_SELECTION & GetSelection()
Return the set of currently selected items.
PL_SELECTION & RequestSelection()
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Highlight the item visually.
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Unhighlight the item visually.
PL_EDITOR_FRAME * m_frame
int Main(const TOOL_EVENT &aEvent)
The main loop.
void RebuildSelection()
Rebuild the selection from the flags in the view items.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
SELECTION_TOOL(const std::string &aName)
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
Generic, UI-independent tool event.
Definition tool_event.h:167
void Reset() override
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683