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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef SVG_IMPORT_PLUGIN_H
23#define SVG_IMPORT_PLUGIN_H
24
28
29#include <vector>
30#include <stroke_params.h>
31
32
34{
35public:
38 m_parsedImage( nullptr )
39 {
40 }
41
42 const wxString GetName() const override
43 {
44 return "Scalable Vector Graphics";
45 }
46
47 const std::vector<std::string> GetFileExtensions() const override
48 {
49 static std::vector<std::string> exts = { "svg" };
50 return exts;
51 }
52
56 const wxString& GetMessages() const override
57 {
58 return m_messages;
59 }
60
61 void ReportMsg( const wxString& aMessage ) override;
62
63 bool Import() override;
64 bool Load( const wxString& aFileName ) override;
65 bool LoadFromMemory( const wxMemoryBuffer& aMemBuffer ) override;
66
67 virtual double GetImageHeight() const override;
68 virtual double GetImageWidth() const override;
69 virtual BOX2D GetImageBBox() const override;
70
71private:
72 void DrawPath( const float* aPoints, int aNumPoints, bool aClosedPath,
73 const IMPORTED_STROKE& aStroke, bool aFilled, const COLOR4D& aFillColor );
74
75 void DrawPolygon( const std::vector<VECTOR2D>& aPoints, const IMPORTED_STROKE& aStroke,
76 bool aFilled, const COLOR4D& aFillColor );
77
78 void DrawLineSegments( const std::vector<VECTOR2D>& aPoints, const IMPORTED_STROKE& aStroke );
79
83 void DrawSplinePath( const float* aPoints, int aNumPoints, const IMPORTED_STROKE& aStroke );
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 */
BOX2< VECTOR2D > BOX2D
Definition box2.h:919
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:101
const wxString & GetMessages() const override
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.
virtual double GetImageHeight() const override
Return image height from original imported file.
void DrawSplinePath(const float *aPoints, int aNumPoints, const IMPORTED_STROKE &aStroke)
Draw a path made up of cubic Bezier curves, adding them as real bezier curves.
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.