2018-10-13 18:37:28 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 CERN
|
|
|
|
* @author Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
|
2019-01-03 03:55:16 +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 GRAPHICS_IMPORTER_BUFFER_H
|
|
|
|
#define GRAPHICS_IMPORTER_BUFFER_H
|
|
|
|
|
|
|
|
#include "graphics_importer.h"
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
class IMPORTED_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
2019-01-03 03:55:16 +00:00
|
|
|
virtual ~IMPORTED_SHAPE() {}
|
2018-10-13 18:37:28 +00:00
|
|
|
virtual void ImportTo( GRAPHICS_IMPORTER& aImporter ) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class IMPORTED_LINE : public IMPORTED_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
2018-11-05 16:04:05 +00:00
|
|
|
IMPORTED_LINE( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth )
|
|
|
|
: m_start( aStart ), m_end( aEnd ), m_width( aWidth )
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
|
|
|
|
{
|
2018-11-05 16:04:05 +00:00
|
|
|
aImporter.AddLine( m_start, m_end, m_width );
|
2018-10-13 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const VECTOR2D m_start;
|
|
|
|
const VECTOR2D m_end;
|
2018-11-05 16:04:05 +00:00
|
|
|
double m_width;
|
2018-10-13 18:37:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class IMPORTED_CIRCLE : public IMPORTED_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
2018-11-05 16:04:05 +00:00
|
|
|
IMPORTED_CIRCLE( const VECTOR2D& aCenter, double aRadius, double aWidth )
|
|
|
|
: m_center( aCenter ), m_radius( aRadius ), m_width( aWidth )
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
|
|
|
|
{
|
2018-11-05 16:04:05 +00:00
|
|
|
aImporter.AddCircle( m_center, m_radius, m_width );
|
2018-10-13 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const VECTOR2D m_center;
|
|
|
|
double m_radius;
|
2018-11-05 16:04:05 +00:00
|
|
|
double m_width;
|
2018-10-13 18:37:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class IMPORTED_ARC : public IMPORTED_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
2018-11-05 16:04:05 +00:00
|
|
|
IMPORTED_ARC( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth )
|
|
|
|
: m_center( aCenter ), m_start( aStart ), m_angle( aAngle ), m_width( aWidth )
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
|
|
|
|
{
|
2018-11-05 16:04:05 +00:00
|
|
|
aImporter.AddArc( m_center, m_start, m_angle, m_width );
|
2018-10-13 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const VECTOR2D m_center;
|
|
|
|
const VECTOR2D m_start;
|
|
|
|
double m_angle;
|
2018-11-05 16:04:05 +00:00
|
|
|
double m_width;
|
2018-10-13 18:37:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class IMPORTED_POLYGON : public IMPORTED_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
2018-11-05 16:04:05 +00:00
|
|
|
IMPORTED_POLYGON( const std::vector< VECTOR2D >& aVertices, double aWidth )
|
|
|
|
: m_vertices( aVertices ), m_width( aWidth )
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
|
|
|
|
{
|
2018-11-05 16:04:05 +00:00
|
|
|
aImporter.AddPolygon( m_vertices, m_width );
|
2018-10-13 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::vector< VECTOR2D > m_vertices;
|
2018-11-05 16:04:05 +00:00
|
|
|
double m_width;
|
2018-10-13 18:37:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class IMPORTED_TEXT : public IMPORTED_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText,
|
2018-12-04 19:01:47 +00:00
|
|
|
double aHeight, double aWidth, double aThickness, double aOrientation,
|
2018-10-13 18:37:28 +00:00
|
|
|
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
|
|
|
|
: m_origin( aOrigin ), m_text( aText ),
|
2018-12-04 19:01:47 +00:00
|
|
|
m_height( aHeight ), m_width( aWidth ), m_thickness( aThickness ),
|
2018-10-13 18:37:28 +00:00
|
|
|
m_orientation( aOrientation ),
|
|
|
|
m_hJustify( aHJustify ), m_vJustify( aVJustify )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
|
|
|
|
{
|
2018-12-04 19:01:47 +00:00
|
|
|
aImporter.AddText( m_origin, m_text, m_height, m_width,
|
|
|
|
m_thickness, m_orientation, m_hJustify, m_vJustify );
|
2018-10-13 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-11-01 09:47:41 +00:00
|
|
|
const VECTOR2D m_origin;
|
|
|
|
const wxString m_text;
|
|
|
|
double m_height;
|
|
|
|
double m_width;
|
2018-12-04 19:01:47 +00:00
|
|
|
double m_thickness;
|
2018-10-13 18:37:28 +00:00
|
|
|
double m_orientation;
|
|
|
|
EDA_TEXT_HJUSTIFY_T m_hJustify;
|
|
|
|
EDA_TEXT_VJUSTIFY_T m_vJustify;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-11-01 09:47:41 +00:00
|
|
|
class IMPORTED_SPLINE : public IMPORTED_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IMPORTED_SPLINE( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
|
|
|
|
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, double aWidth )
|
|
|
|
: m_start( aStart ), m_bezierControl1( aBezierControl1 ),
|
|
|
|
m_bezierControl2( aBezierControl2 ), m_end( aEnd ), m_width( aWidth )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
|
|
|
|
{
|
|
|
|
aImporter.AddSpline( m_start, m_bezierControl1, m_bezierControl2, m_end, m_width );
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const VECTOR2D m_start;
|
|
|
|
const VECTOR2D m_bezierControl1;
|
|
|
|
const VECTOR2D m_bezierControl2;
|
|
|
|
const VECTOR2D m_end;
|
|
|
|
double m_width;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-10-13 18:37:28 +00:00
|
|
|
class GRAPHICS_IMPORTER_BUFFER : public GRAPHICS_IMPORTER
|
|
|
|
{
|
|
|
|
public:
|
2018-11-05 16:04:05 +00:00
|
|
|
void AddLine( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
void AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
void AddText( const VECTOR2D& aOrigin, const wxString& aText,
|
2018-12-04 19:01:47 +00:00
|
|
|
double aHeight, double aWidth, double aThickness, double aOrientation,
|
2018-10-13 18:37:28 +00:00
|
|
|
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
|
|
|
|
|
2018-11-01 09:47:41 +00:00
|
|
|
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& BezierControl1,
|
|
|
|
const VECTOR2D& BezierControl2, const VECTOR2D& aEnd , double aWidth ) override;
|
|
|
|
|
2018-10-13 18:37:28 +00:00
|
|
|
void ImportTo( GRAPHICS_IMPORTER& aImporter );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
///> List of imported shapes
|
|
|
|
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GRAPHICS_IMPORTER_BUFFER */
|