KiCad PCB EDA Suite
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-2019 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
29#include "nanosvg.h"
30
33#include <math/vector2d.h>
35
36#include <vector>
37
38
40{
41public:
44 m_parsedImage( nullptr )
45 {
46 }
47
48 const wxString GetName() const override
49 {
50 return "Scalable Vector Graphics";
51 }
52
53 const std::vector<std::string> GetFileExtensions() const override
54 {
55 static std::vector<std::string> exts = { "svg" };
56 return exts;
57 }
58
62 const wxString& GetMessages() const override
63 {
64 return m_messages;
65 }
66
67 bool Import() override;
68 bool Load( const wxString& aFileName ) override;
69
70 virtual double GetImageHeight() const override;
71 virtual double GetImageWidth() const override;
72
73private:
74 void DrawPath( const float* aPoints, int aNumPoints, bool aClosedPath, bool aFilled, double aLineWidth );
75
76 void DrawCubicBezierPath( const float* aPoints, int aNumPoints,
77 std::vector< VECTOR2D >& aGeneratedPoints );
78
79 void DrawCubicBezierCurve( const float* aPoints,
80 std::vector< VECTOR2D >& aGeneratedPoints );
81
82 void DrawPolygon( const std::vector< VECTOR2D >& aPoints, double aWidth );
83 void DrawLineSegments( const std::vector< VECTOR2D >& aPoints, double aWidth );
84
85 struct NSVGimage* m_parsedImage;
86
87 wxString m_messages; // messages generated during svg file parsing.
88 // Each message ends by '\n'
89
91};
92
93#endif /* SVG_IMPORT_PLUGIN_H */
Interface for vector graphics import plugins.
const wxString & GetMessages() const override
void DrawCubicBezierPath(const float *aPoints, int aNumPoints, std::vector< VECTOR2D > &aGeneratedPoints)
void DrawLineSegments(const std::vector< VECTOR2D > &aPoints, double aWidth)
GRAPHICS_IMPORTER_BUFFER m_internalImporter
struct NSVGimage * m_parsedImage
void DrawPath(const float *aPoints, int aNumPoints, bool aClosedPath, bool aFilled, double aLineWidth)
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 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 DrawPolygon(const std::vector< VECTOR2D > &aPoints, double aWidth)
Definition of file extensions used in Kicad.