KiCad PCB EDA Suite
callback_gal.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) 2022 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#ifndef CALLBACK_GAL_H
25#define CALLBACK_GAL_H
26
28
30{
31public:
33 std::function<void( const VECTOR2I& aPt1,
34 const VECTOR2I& aPt2 )> aStrokeCallback,
35 std::function<void( const VECTOR2I& aPt1,
36 const VECTOR2I& aPt2,
37 const VECTOR2I& aPt3 )> aTriangleCallback ) :
38 GAL( aDisplayOptions )
39 {
40 m_strokeCallback = aStrokeCallback;
41 m_triangleCallback = aTriangleCallback;
42 m_outlineCallback = []( const SHAPE_LINE_CHAIN& ) {};
43 m_stroke = true;
44 m_triangulate = true;
45 }
46
48 std::function<void( const VECTOR2I& aPt1,
49 const VECTOR2I& aPt2 )> aStrokeCallback,
50 std::function<void( const SHAPE_LINE_CHAIN& aPoly )> aOutlineCallback ) :
51 GAL( aDisplayOptions )
52 {
53 m_strokeCallback = aStrokeCallback;
54 m_triangleCallback = []( const VECTOR2I&, const VECTOR2I&, const VECTOR2I& ) {};
55 m_outlineCallback = aOutlineCallback;
56 m_stroke = true;
57 m_triangulate = false;
58 }
59
61 std::function<void( const SHAPE_LINE_CHAIN& aPoly )> aOutlineCallback ) :
62 GAL( aDisplayOptions )
63 {
64 m_strokeCallback = []( const VECTOR2I& aPt1, const VECTOR2I& aPt2 ) {};
65 m_triangleCallback = []( const VECTOR2I&, const VECTOR2I&, const VECTOR2I& ) {};
66 m_outlineCallback = aOutlineCallback;
67 m_stroke = false;
68 m_triangulate = false;
69 }
70
74 void DrawGlyph( const KIFONT::GLYPH& aGlyph, int aNth, int aTotal ) override;
75
76private:
77 std::function<void( const VECTOR2I& aPt1,
78 const VECTOR2I& aPt2 )> m_strokeCallback;
79
80 std::function<void( const VECTOR2I& aPt1,
81 const VECTOR2I& aPt2,
83
84 std::function<void( const SHAPE_LINE_CHAIN& aPoly )> m_outlineCallback;
85
88};
89
90
91#endif // define CALLBACK_GAL_H
CALLBACK_GAL(KIGFX::GAL_DISPLAY_OPTIONS &aDisplayOptions, std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2)> aStrokeCallback, std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const VECTOR2I &aPt3)> aTriangleCallback)
Definition: callback_gal.h:32
std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const VECTOR2I &aPt3)> m_triangleCallback
Definition: callback_gal.h:82
CALLBACK_GAL(KIGFX::GAL_DISPLAY_OPTIONS &aDisplayOptions, std::function< void(const SHAPE_LINE_CHAIN &aPoly)> aOutlineCallback)
Definition: callback_gal.h:60
void DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth, int aTotal) override
Draw a polygon representing an outline font glyph.
CALLBACK_GAL(KIGFX::GAL_DISPLAY_OPTIONS &aDisplayOptions, std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2)> aStrokeCallback, std::function< void(const SHAPE_LINE_CHAIN &aPoly)> aOutlineCallback)
Definition: callback_gal.h:47
bool m_triangulate
Definition: callback_gal.h:87
std::function< void(const SHAPE_LINE_CHAIN &aPoly)> m_outlineCallback
Definition: callback_gal.h:84
std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2)> m_strokeCallback
Definition: callback_gal.h:78
Abstract interface for drawing on a 2D-surface.
GAL(GAL_DISPLAY_OPTIONS &aOptions)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...