2018-10-13 18:37:28 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 CERN
|
|
|
|
* @author Janito V. Ferreira Filho <janito.vff@gmail.com>
|
2019-06-15 03:27:36 +00:00
|
|
|
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-10-13 18:37:28 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SVG_IMPORT_PLUGIN_H
|
|
|
|
#define SVG_IMPORT_PLUGIN_H
|
|
|
|
|
|
|
|
#include "nanosvg.h"
|
|
|
|
|
|
|
|
#include "graphics_import_plugin.h"
|
|
|
|
#include <math/vector2d.h>
|
2019-06-15 03:27:36 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
|
|
|
|
#include <vector>
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SVG_IMPORT_PLUGIN : public GRAPHICS_IMPORT_PLUGIN
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const wxString GetName() const override
|
|
|
|
{
|
|
|
|
return "Scalable Vector Graphics";
|
|
|
|
}
|
|
|
|
|
|
|
|
const wxArrayString GetFileExtensions() const override
|
|
|
|
{
|
2019-06-16 00:06:18 +00:00
|
|
|
static wxString wildcardExt = formatWildcardExt( "svg" );
|
|
|
|
return wxArrayString( 1, &wildcardExt );
|
2018-10-13 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
/**
|
|
|
|
* @return the list of messages in one string. Each message ends by '\n'
|
|
|
|
*/
|
|
|
|
const std::string& GetMessages() const override
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
2018-11-05 16:04:05 +00:00
|
|
|
return m_messages;
|
2018-10-13 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
bool Import() override;
|
|
|
|
bool Load( const wxString& aFileName ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
virtual double GetImageHeight() const override;
|
|
|
|
virtual double GetImageWidth() const override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
private:
|
2018-11-05 16:04:05 +00:00
|
|
|
void DrawPath( const float* aPoints, int aNumPoints, bool aClosedPath, bool aFilled, double aLineWidth );
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
void DrawCubicBezierPath( const float* aPoints, int aNumPoints,
|
|
|
|
std::vector< VECTOR2D >& aGeneratedPoints );
|
|
|
|
|
|
|
|
void DrawCubicBezierCurve( const float* aPoints,
|
|
|
|
std::vector< VECTOR2D >& aGeneratedPoints );
|
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
void DrawPolygon( const std::vector< VECTOR2D >& aPoints, double aWidth );
|
|
|
|
void DrawLineSegments( const std::vector< VECTOR2D >& aPoints, double aWidth );
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
struct NSVGimage* m_parsedImage;
|
2018-11-05 16:04:05 +00:00
|
|
|
|
|
|
|
std::string m_messages; // messages generated during svg file parsing.
|
|
|
|
// Each message ends by '\n'
|
2018-10-13 18:37:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SVG_IMPORT_PLUGIN_H */
|