KiCad PCB EDA Suite
Loading...
Searching...
No Matches
graphics_importer_pl_editor.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef GRAPHICS_IMPORTER_PL_EDITOR_H
21#define GRAPHICS_IMPORTER_PL_EDITOR_H
22
23#include <memory>
24#include <vector>
25
28
29
38{
39public:
41
47 std::vector<std::unique_ptr<DS_DATA_ITEM>>& GetDataItems() { return m_dataItems; }
48
49 void AddLine( const VECTOR2D& aOrigin, const VECTOR2D& aEnd, const IMPORTED_STROKE& aStroke ) override;
50
51 void AddCircle( const VECTOR2D& aCenter, double aRadius, const IMPORTED_STROKE& aStroke, bool aFilled,
52 const COLOR4D& aFillColor ) override;
53
54 void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle,
55 const IMPORTED_STROKE& aStroke ) override;
56
57 void AddPolygon( const std::vector<VECTOR2D>& aVertices, const IMPORTED_STROKE& aStroke, bool aFilled,
58 const COLOR4D& aFillColor ) override;
59
60 void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth, double aThickness,
61 double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify,
62 const COLOR4D& aColor ) override;
63
64 void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1, const VECTOR2D& aBezierControl2,
65 const VECTOR2D& aEnd, const IMPORTED_STROKE& aStroke ) override;
66
67 void AddEllipse( const VECTOR2D& aCenter, double aMajorRadius, double aMinorRadius, const EDA_ANGLE& aRotation,
68 const IMPORTED_STROKE& aStroke, bool aFilled,
69 const COLOR4D& aFillColor = COLOR4D::UNSPECIFIED ) override;
70
71 void AddEllipseArc( const VECTOR2D& aCenter, double aMajorRadius, double aMinorRadius, const EDA_ANGLE& aRotation,
72 const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle,
73 const IMPORTED_STROKE& aStroke ) override;
74
75private:
77 VECTOR2D mapPoint( const VECTOR2D& aPoint ) const;
78
80 double mapLineWidth( const IMPORTED_STROKE& aStroke ) const;
81
82 void addSegment( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth );
83
85 void addPolyline( const std::vector<VECTOR2D>& aPoints, double aWidth, bool aClose );
86
88 void addFilledPolygon( const std::vector<VECTOR2D>& aPoints );
89
93 std::vector<VECTOR2D> flattenEllipseArc( const VECTOR2D& aCenter, double aMajorRadius, double aMinorRadius,
94 const EDA_ANGLE& aRotation, double aStartRadians,
95 double aSweepRadians ) const;
96
97 std::vector<std::unique_ptr<DS_DATA_ITEM>> m_dataItems;
98
101};
102
103#endif // GRAPHICS_IMPORTER_PL_EDITOR_H
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
void addPolyline(const std::vector< VECTOR2D > &aPoints, double aWidth, bool aClose)
Add a run of points as segments, closing back to the first point when asked.
std::vector< VECTOR2D > flattenEllipseArc(const VECTOR2D &aCenter, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation, double aStartRadians, double aSweepRadians) const
Walk an elliptical arc, which covers circles and arcs as well.
double mapLineWidth(const IMPORTED_STROKE &aStroke) const
The line width to draw a stroke with, in millimetres.
void AddEllipseArc(const VECTOR2D &aCenter, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, const IMPORTED_STROKE &aStroke) override
Create an object representing an elliptical arc.
void AddText(const VECTOR2D &aOrigin, const wxString &aText, double aHeight, double aWidth, double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify, const COLOR4D &aColor) override
Create an object representing a text.
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, const EDA_ANGLE &aAngle, const IMPORTED_STROKE &aStroke) override
Create an object representing an arc.
void addSegment(const VECTOR2D &aStart, const VECTOR2D &aEnd, double aWidth)
DS_DATA_ITEM_POLYGONS * m_polygons
All filled areas go into one item, the way a traced logo is one object.
VECTOR2D mapPoint(const VECTOR2D &aPoint) const
Scale and offset an imported point into the drawing sheet's millimetres.
std::vector< std::unique_ptr< DS_DATA_ITEM > > m_dataItems
void AddSpline(const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, const IMPORTED_STROKE &aStroke) override
Create an object representing an arc.
std::vector< std::unique_ptr< DS_DATA_ITEM > > & GetDataItems()
The imported items, which the caller takes over.
void AddLine(const VECTOR2D &aOrigin, const VECTOR2D &aEnd, const IMPORTED_STROKE &aStroke) override
Create an object representing a line segment.
void AddPolygon(const std::vector< VECTOR2D > &aVertices, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor) override
Create an object representing a polygon.
void addFilledPolygon(const std::vector< VECTOR2D > &aPoints)
Add a run of points as one contour of the filled polygon item.
void AddCircle(const VECTOR2D &aCenter, double aRadius, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor) override
Create an object representing a circle.
void AddEllipse(const VECTOR2D &aCenter, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor=COLOR4D::UNSPECIFIED) override
Create an object representing a closed ellipse.
A clone of IMPORTED_STROKE, but with floating-point width.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< double > VECTOR2D
Definition vector2d.h:707