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 (C) 2019-2022 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PL_SELECTION_TOOL_H
26#define PL_SELECTION_TOOL_H
27
28#include <tool/selection_tool.h>
30#include <tool/tool_menu.h>
31#include "tools/pl_selection.h"
32
33class PL_EDITOR_FRAME;
34class SCH_ITEM;
35class COLLECTOR;
36
37namespace KIGFX
38{
39 class GAL;
40}
41
42
44{
45public:
47 ~PL_SELECTION_TOOL() override { }
48
50 bool Init() override;
51
53 void Reset( RESET_REASON aReason ) override;
54
58 int Main( const TOOL_EVENT& aEvent );
59
64
70
80 void SelectPoint( const VECTOR2I& aWhere, bool* aSelectionCancelledFlag = nullptr );
81
82 int ClearSelection( const TOOL_EVENT& aEvent );
83 void ClearSelection();
84
89 void RebuildSelection();
90
91protected:
92 SELECTION& selection() override { return m_selection; }
93
94private:
100 bool selectMultiple();
101
106 void guessSelectionCandidates( COLLECTOR& collector, const VECTOR2I& aWhere );
107
111 int disambiguateCursor( const TOOL_EVENT& aEvent );
112
118 void select( EDA_ITEM* aItem ) override;
119
125 void unselect( EDA_ITEM* aItem ) override;
126
134 void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
135
143 void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
144
148 bool selectionContains( const VECTOR2I& aPoint ) const;
149
151 void setTransitions() override;
152
153private:
154 PL_EDITOR_FRAME* m_frame; // Pointer to the parent frame
155 PL_SELECTION m_selection; // Current state of selection
156};
157
158#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:48
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
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.
PL_SELECTION m_selection
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:166
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