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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef EE_GRID_HELPER_H
23#define EE_GRID_HELPER_H
24
25#include <math/vector2d.h>
26#include <origin_viewitem.h>
28#include <tool/grid_helper.h>
29#include <snap/snap_resolver.h>
30#include "sch_selection.h"
31
32class SCH_ITEM;
33class SCH_PIN;
34
35
37{
39
40public:
41
43 EE_GRID_HELPER( TOOL_MANAGER* aToolMgr );
44 ~EE_GRID_HELPER() override;
45
53 SCH_ITEM* GetSnapped() const;
54
55 VECTOR2D GetGridSize( GRID_HELPER_GRIDS aGrid ) const override;
57
58 GRID_HELPER_GRIDS GetItemGrid( const EDA_ITEM* aItem ) const override;
59
60 VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, GRID_HELPER_GRIDS aGrid,
61 const SCH_SELECTION& aItems );
62
63 SNAP_RESULT ResolveSnap( const VECTOR2I& aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM* aSkip );
64 SNAP_RESULT ResolveSnap( const VECTOR2I& aOrigin, GRID_HELPER_GRIDS aGrid, const SCH_SELECTION& aSkip = {},
65 std::optional<VECTOR2I> aMovingReferencePoint = std::nullopt );
66
67 void AddConstructionItems( std::vector<SCH_ITEM*> aItems, bool aExtensionOnly,
68 bool aIsPersistent );
69
70private:
77 static BOX2I layoutBounds( const SCH_ITEM& aItem );
78
80 static std::vector<std::pair<const SCH_PIN*, VECTOR2I>> layoutPins( SCH_ITEM& aItem );
81
84
85 std::set<SCH_ITEM*> queryVisible( const BOX2I& aArea, const SCH_SELECTION& aSkipList ) const;
86
87 ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, GRID_HELPER_GRIDS aGrid );
88
98 void computeAnchors( SCH_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom = false,
99 bool aIncludeText = false );
100};
101
102#endif
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
static std::vector< std::pair< const SCH_PIN *, VECTOR2I > > layoutPins(SCH_ITEM &aItem)
Pin connection points the item offers as alignment anchors.
~EE_GRID_HELPER() override
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Get the coarsest grid that applies to an item.
friend class EEGridHelperTestFixture
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, GRID_HELPER_GRIDS aGrid, const SCH_SELECTION &aItems)
std::set< SCH_ITEM * > queryVisible(const BOX2I &aArea, const SCH_SELECTION &aSkipList) const
void AddConstructionItems(std::vector< SCH_ITEM * > aItems, bool aExtensionOnly, bool aIsPersistent)
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),...
SNAP_RESULT ResolveSnap(const VECTOR2I &aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM *aSkip)
SNAP_INFERENCE_SETTINGS snapInferenceSettings() const
Snap inference settings for whichever editor owns this helper.
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,...
static BOX2I layoutBounds(const SCH_ITEM &aItem)
Bounds a layout relation should align to.
VECTOR2I GetGrid() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
Master controller class:
GRID_HELPER_GRIDS
Definition grid_helper.h:55
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
VECTOR2< double > VECTOR2D
Definition vector2d.h:682