KiCad PCB EDA Suite
Loading...
Searching...
No Matches
svg_import_plugin.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) 2016 CERN
5 * @author Janito V. Ferreira Filho <[email protected]>
6 * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef SVG_IMPORT_PLUGIN_H
27#define SVG_IMPORT_PLUGIN_H
28
32
33#include <vector>
34#include <stroke_params.h>
35
36
38{
39public:
42 m_parsedImage( nullptr )
43 {
44 }
45
46 const wxString GetName() const override
47 {
48 return "Scalable Vector Graphics";
49 }
50
51 const std::vector<std::string> GetFileExtensions() const override
52 {
53 static std::vector<std::string> exts = { "svg" };
54 return exts;
55 }
56
60 const wxString& GetMessages() const override
61 {
62 return m_messages;
63 }
64
65 void ReportMsg( const wxString& aMessage ) override;
66
67 bool Import() override;
68 bool Load( const wxString& aFileName ) override;
69 bool LoadFromMemory( const wxMemoryBuffer& aMemBuffer ) override;
70
71 virtual double GetImageHeight() const override;
72 virtual double GetImageWidth() const override;
73 virtual BOX2D GetImageBBox() const override;
74
75private:
76 void DrawPath( const float* aPoints, int aNumPoints, bool aClosedPath,
77 const IMPORTED_STROKE& aStroke, bool aFilled, const COLOR4D& aFillColor );
78
79 void DrawCubicBezierPath( const float* aPoints, int aNumPoints,
80 std::vector<VECTOR2D>& aGeneratedPoints );
81
82 void DrawCubicBezierCurve( const float* aPoints, std::vector<VECTOR2D>& aGeneratedPoints );
83
84 void DrawPolygon( const std::vector<VECTOR2D>& aPoints, const IMPORTED_STROKE& aStroke,
85 bool aFilled, const COLOR4D& aFillColor );
86
87 void DrawLineSegments( const std::vector<VECTOR2D>& aPoints, const IMPORTED_STROKE& aStroke );
88
89 struct NSVGimage* m_parsedImage;
90
91 wxString m_messages; // messages generated during svg file parsing.
92 // Each message ends by '\n'
93
95};
96
97#endif /* SVG_IMPORT_PLUGIN_H */
Interface for vector graphics import plugins.
A clone of IMPORTED_STROKE, but with floating-point width.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
const wxString & GetMessages() const override
void DrawCubicBezierPath(const float *aPoints, int aNumPoints, std::vector< VECTOR2D > &aGeneratedPoints)
void DrawPolygon(const std::vector< VECTOR2D > &aPoints, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor)
virtual BOX2D GetImageBBox() const override
Return image bounding box from original imported file.
GRAPHICS_IMPORTER_BUFFER m_internalImporter
struct NSVGimage * m_parsedImage
void DrawLineSegments(const std::vector< VECTOR2D > &aPoints, const IMPORTED_STROKE &aStroke)
bool Import() override
Actually imports the file.
const std::vector< std::string > GetFileExtensions() const override
Return a vector of the file extensions handled by this plugin.
virtual double GetImageWidth() const override
Return image width from original imported file.
bool LoadFromMemory(const wxMemoryBuffer &aMemBuffer) override
Set memory buffer with content for import.
bool Load(const wxString &aFileName) override
Load file for import.
const wxString GetName() const override
Return the plugin name.
void DrawCubicBezierCurve(const float *aPoints, std::vector< VECTOR2D > &aGeneratedPoints)
virtual double GetImageHeight() const override
Return image height from original imported file.
void DrawPath(const float *aPoints, int aNumPoints, bool aClosedPath, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor)
void ReportMsg(const wxString &aMessage) override
Definition of file extensions used in Kicad.