KiCad PCB EDA Suite
Loading...
Searching...
No Matches
glyph_types.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) 2021 Ola Rinta-Koski
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <functional>
24#include <memory>
25
26#include <font/glyph.h>
28#include <geometry/eda_angle.h>
29
30
31#if defined( _MSC_VER )
32#pragma warning( push )
33#pragma warning( disable : 4275 )
34#endif
35
36
37namespace KIFONT
38{
39
41{
42public:
46
47 OUTLINE_GLYPH( const OUTLINE_GLYPH& aGlyph ) :
48 SHAPE_POLY_SET( aGlyph )
49 {}
50
51 OUTLINE_GLYPH( const SHAPE_POLY_SET& aPoly ) :
52 SHAPE_POLY_SET( aPoly )
53 {}
54
55 bool IsOutline() const override { return true; }
56
57 BOX2D BoundingBox() override;
58
59 void Triangulate( std::function<void( const VECTOR2I& aPt1,
60 const VECTOR2I& aPt2,
61 const VECTOR2I& aPt3 )> aCallback ) const;
62
63 void CacheTriangulation( bool aSimplify = false, const TASK_SUBMITTER& aSubmitter = {},
64 bool aBuildIndexes = false ) override;
65
70 std::vector<std::unique_ptr<SHAPE_POLY_SET::TRIANGULATED_POLYGON>> GetTriangulationData() const;
71
76 void CacheTriangulation( std::vector<std::unique_ptr<SHAPE_POLY_SET::TRIANGULATED_POLYGON>>& aHintData );
77};
78
79
80class GAL_API STROKE_GLYPH : public GLYPH, public std::vector<std::vector<VECTOR2D>>
81{
82public:
84 {}
85
86 STROKE_GLYPH( const STROKE_GLYPH& aGlyph );
87
88 bool IsStroke() const override { return true; }
89
90 void AddPoint( const VECTOR2D& aPoint );
91 void RaisePen();
92 void Finalize();
93
94 BOX2D BoundingBox() override { return m_boundingBox; }
95 void SetBoundingBox( const BOX2D& bbox ) { m_boundingBox = bbox; }
96
97 std::unique_ptr<GLYPH> Transform( const VECTOR2D& aGlyphSize, const VECTOR2I& aOffset,
98 double aTilt, const EDA_ANGLE& aAngle, bool aMirror,
99 const VECTOR2I& aOrigin );
100
101 void Move( const VECTOR2I& aOffset );
102
103private:
104 bool m_penIsDown = false;
106};
107
108} // namespace KIFONT
109
110#if defined( _MSC_VER )
111#pragma warning( pop )
112#endif
BOX2< VECTOR2D > BOX2D
Definition box2.h:915
OUTLINE_GLYPH(const OUTLINE_GLYPH &aGlyph)
Definition glyph_types.h:47
OUTLINE_GLYPH(const SHAPE_POLY_SET &aPoly)
Definition glyph_types.h:51
bool IsOutline() const override
Definition glyph_types.h:55
bool IsStroke() const override
Definition glyph_types.h:88
BOX2D BoundingBox() override
Definition glyph_types.h:94
void SetBoundingBox(const BOX2D &bbox)
Definition glyph_types.h:95
#define GAL_API
Definition gal.h:27
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707