KiCad PCB EDA Suite
Loading...
Searching...
No Matches
hover_picker.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef HOVER_PICKER_H
21#define HOVER_PICKER_H
22
23#include <kiid.h>
24#include <math/vector2d.h>
25
26#include <functional>
27#include <vector>
28
29class BOARD_ITEM;
31class TOOL_MANAGER;
32
35{
36public:
38 using ACCEPTS = std::function<bool( BOARD_ITEM& aItem )>;
39
41 using PROXIMITY = std::function<double( const BOARD_ITEM& aItem, const VECTOR2I& aPointer )>;
42
43 explicit HOVER_PICKER( TOOL_MANAGER* aToolMgr );
44
47
50 BOARD_ITEM* Pick( const VECTOR2I& aPointer, const ACCEPTS& aAccepts,
51 const PROXIMITY& aProximity = nullptr ) const;
52
53 void Brighten( BOARD_ITEM* aItem );
54
57 void BrightenOnly( const std::vector<BOARD_ITEM*>& aItems );
58
60 void ClearBrightening();
61
62private:
65 std::vector<KIID> m_brightened;
66};
67
68#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
PCB_SELECTION_TOOL * m_selectionTool
void Brighten(BOARD_ITEM *aItem)
HOVER_PICKER(TOOL_MANAGER *aToolMgr)
std::function< double(const BOARD_ITEM &aItem, const VECTOR2I &aPointer)> PROXIMITY
Optional tie-break among what the selection heuristics left. Nearest wins.
~HOVER_PICKER()
Puts back whatever is still lit, so an early exit cannot strand a highlight.
TOOL_MANAGER * m_toolMgr
std::function< bool(BOARD_ITEM &aItem)> ACCEPTS
Everything it sees is already selectable.
void BrightenOnly(const std::vector< BOARD_ITEM * > &aItems)
Light exactly these, leaving what is already lit alone.
void ClearBrightening()
Items go back by id, so a commit that replaced one still puts the original back.
BOARD_ITEM * Pick(const VECTOR2I &aPointer, const ACCEPTS &aAccepts, const PROXIMITY &aProximity=nullptr) const
The item a click would take, or null.
std::vector< KIID > m_brightened
The selection tool: currently supports:
Master controller class:
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683