KiCad PCB EDA Suite
Loading...
Searching...
No Matches
construction_geom.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#pragma once
24
25#include <variant>
26#include <vector>
27
28#include <eda_item.h>
29#include <gal/color4d.h>
30
31#include <geometry/circle.h>
32#include <geometry/half_line.h>
33#include <geometry/line.h>
34#include <geometry/seg.h>
35#include <geometry/shape_arc.h>
36
37namespace KIGFX
38{
39
44{
45public:
46 // Supported items
47 using DRAWABLE = std::variant<SEG, LINE, HALF_LINE, CIRCLE, SHAPE_ARC, VECTOR2I>;
48
50
51 wxString GetClass() const override { return wxT( "CONSTRUCTION_GEOM" ); }
52
53 const BOX2I ViewBBox() const override;
54
55 void ViewDraw( int aLayer, VIEW* aView ) const override;
56
57 std::vector<int> ViewGetLayers() const override;
58
59 void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
60 void SetPersistentColor( const COLOR4D& aColor ) { m_persistentColor = aColor; }
61
62 void AddDrawable( const DRAWABLE& aItem, bool aIsPersistent );
63 void ClearDrawables();
64
65 void SetSnapLine( const SEG& aLine ) { m_snapLine = aLine; }
66 void ClearSnapLine() { m_snapLine.reset(); }
67
68private:
72 {
75 };
76
77 // The items to draw
78 std::vector<DRAWABLE_INFO> m_drawables;
79
80 // The snap line to draw
81 std::optional<SEG> m_snapLine;
82};
83
84} // namespace KIGFX
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Shows construction geometry for things like line extensions, arc centers, etc.
std::optional< SEG > m_snapLine
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void SetColor(const COLOR4D &aColor)
void SetPersistentColor(const COLOR4D &aColor)
std::vector< DRAWABLE_INFO > m_drawables
void AddDrawable(const DRAWABLE &aItem, bool aIsPersistent)
std::variant< SEG, LINE, HALF_LINE, CIRCLE, SHAPE_ARC, VECTOR2I > DRAWABLE
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void SetSnapLine(const SEG &aLine)
wxString GetClass() const override
Return the class name.
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
Definition: seg.h:42
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247