KiCad PCB EDA Suite
Loading...
Searching...
No Matches
anchor_debug.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) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <cstddef>
27#include <map>
28#include <span>
29
30#include <origin_viewitem.h>
31
32#include <math/vector2d.h>
33#include <geometry/seg.h> // OPT_VECTOR2I
34
35namespace KIGFX
36{
37
43class ANCHOR_DEBUG : public EDA_ITEM
44{
45public:
47
48 ANCHOR_DEBUG* Clone() const override;
49
50 void ViewGetLayers( int aLayers[], int& aCount ) const override;
51
52 const BOX2I ViewBBox() const override;
53
54 void ViewDraw( int aLayer, VIEW* aView ) const override;
55
61 wxString GetClass() const override { return wxT( "ANCHOR_DEBUG" ); }
62
63 void ClearAnchors();
64
68 void AddAnchor( const VECTOR2I& aAnchor );
69
75 void SetNearest( const OPT_VECTOR2I& aNearest );
76
77private:
78 // Store the anchors by location and count
79 std::map<VECTOR2I, size_t> m_anchors;
81};
82
83} // namespace KIGFX
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
View item to draw debug items for anchors.
Definition: anchor_debug.h:44
wxString GetClass() const override
Get class name.
Definition: anchor_debug.h:61
std::map< VECTOR2I, size_t > m_anchors
Definition: anchor_debug.h:79
ANCHOR_DEBUG * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
OPT_VECTOR2I m_nearest
Definition: anchor_debug.h:80
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void SetNearest(const OPT_VECTOR2I &aNearest)
Set the nearest anchor to the given position.
void AddAnchor(const VECTOR2I &aAnchor)
Add an anchor at the given position.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
void ViewDraw(int aLayer, VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
std::optional< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:39