KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ee_grid_helper.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) 2014 CERN
5 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef EE_GRID_HELPER_H
27#define EE_GRID_HELPER_H
28
29#include <math/vector2d.h>
30#include <origin_viewitem.h>
31#include <tool/grid_helper.h>
32#include <ee_selection.h>
33
34class SCH_ITEM;
35
36
38{
39public:
40
41 EE_GRID_HELPER( TOOL_MANAGER* aToolMgr );
42 ~EE_GRID_HELPER() override;
43
51 SCH_ITEM* GetSnapped() const;
52
53 VECTOR2D GetGridSize( GRID_HELPER_GRIDS aGrid ) const override;
55
56 GRID_HELPER_GRIDS GetSelectionGrid( const SELECTION& aItem ) const override;
57 GRID_HELPER_GRIDS GetItemGrid( const EDA_ITEM* aItem ) const override;
58
59 VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, GRID_HELPER_GRIDS aGrid,
60 const EE_SELECTION& aItems );
61
62 VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM* aSkip );
64 const EE_SELECTION& aSkip = {} );
65
66private:
67 std::set<SCH_ITEM*> queryVisible( const BOX2I& aArea, const EE_SELECTION& aSkipList ) const;
68
69 ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, GRID_HELPER_GRIDS aGrid );
70
80 void computeAnchors( SCH_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom = false,
81 bool aIncludeText = false );
82};
83
84#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
GRID_HELPER_GRIDS GetSelectionGrid(const SELECTION &aItem) const override
Gets the coarsest grid that applies to a selecion of items.
~EE_GRID_HELPER() override
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Gets the coarsest grid that applies to an item.
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, GRID_HELPER_GRIDS aGrid, const EE_SELECTION &aItems)
std::set< SCH_ITEM * > queryVisible(const BOX2I &aArea, const EE_SELECTION &aSkipList) const
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM *aSkip)
ANCHOR * nearestAnchor(const VECTOR2I &aPos, int aFlags, GRID_HELPER_GRIDS aGrid)
VECTOR2D GetGridSize(GRID_HELPER_GRIDS aGrid) const override
Return the size of the specified grid.
SCH_ITEM * GetSnapped() const
Function GetSnapped If the EE_GRID_HELPER has highlighted a snap point (target shown),...
void computeAnchors(SCH_ITEM *aItem, const VECTOR2I &aRefPos, bool aFrom=false, bool aIncludeText=false)
Insert the local anchor points in to the grid helper for the specified schematic item,...
VECTOR2I GetGrid() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
Master controller class:
Definition: tool_manager.h:62
GRID_HELPER_GRIDS
Definition: grid_helper.h:42