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 SelectAll( const TOOL_EVENT& aEvent );
79
80 int ClearSelection( const TOOL_EVENT& aEvent );
81 void ClearSelection();
82
87 void RebuildSelection();
88
89protected:
90 SELECTION& selection() override { return m_selection; }
91
92private:
98 bool selectMultiple();
99
104 void guessSelectionCandidates( COLLECTOR& collector, const VECTOR2I& aWhere );
105
109 int disambiguateCursor( const TOOL_EVENT& aEvent );
110
116 void select( EDA_ITEM* aItem ) override;
117
123 void unselect( EDA_ITEM* aItem ) override;
124
132 void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
133
141 void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
142
146 bool selectionContains( const VECTOR2I& aPoint ) const;
147
149 void setTransitions() override;
150
151private:
152 PL_EDITOR_FRAME* m_frame; // Pointer to the parent frame
153 PL_SELECTION m_selection; // Current state of selection
154};
155
156#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:98
Abstract interface for drawing on a 2D-surface.
The main window used in the drawing sheet editor.
int SelectAll(const TOOL_EVENT &aEvent)
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:165
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:30
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683