KiCad PCB EDA Suite
graphics_importer_buffer.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) 2017 CERN
5  * @author Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
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 GRAPHICS_IMPORTER_BUFFER_H
27 #define GRAPHICS_IMPORTER_BUFFER_H
28 
29 #include "graphics_importer.h"
30 
31 #include <list>
32 
34 {
35 public:
36  virtual ~IMPORTED_SHAPE() {}
37  virtual void ImportTo( GRAPHICS_IMPORTER& aImporter ) const = 0;
38 };
39 
40 
42 {
43 public:
44  IMPORTED_LINE( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth )
45  : m_start( aStart ), m_end( aEnd ), m_width( aWidth )
46  {
47  }
48 
49  void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
50  {
51  aImporter.AddLine( m_start, m_end, m_width );
52  }
53 
54 private:
56  const VECTOR2D m_end;
57  double m_width;
58 };
59 
60 
62 {
63 public:
64  IMPORTED_CIRCLE( const VECTOR2D& aCenter, double aRadius, double aWidth )
65  : m_center( aCenter ), m_radius( aRadius ), m_width( aWidth )
66  {
67  }
68 
69  void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
70  {
71  aImporter.AddCircle( m_center, m_radius, m_width );
72  }
73 
74 private:
76  double m_radius;
77  double m_width;
78 };
79 
80 
82 {
83 public:
84  IMPORTED_ARC( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth )
85  : m_center( aCenter ), m_start( aStart ), m_angle( aAngle ), m_width( aWidth )
86  {
87  }
88 
89  void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
90  {
91  aImporter.AddArc( m_center, m_start, m_angle, m_width );
92  }
93 
94 private:
97  double m_angle;
98  double m_width;
99 };
100 
101 
103 {
104 public:
105  IMPORTED_POLYGON( const std::vector< VECTOR2D >& aVertices, double aWidth )
106  : m_vertices( aVertices ), m_width( aWidth )
107  {
108  }
109 
110  void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
111  {
112  aImporter.AddPolygon( m_vertices, m_width );
113  }
114 
115 private:
116  const std::vector< VECTOR2D > m_vertices;
117  double m_width;
118 };
119 
120 
122 {
123 public:
124  IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText,
125  double aHeight, double aWidth, double aThickness, double aOrientation,
126  EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
127  : m_origin( aOrigin ), m_text( aText ),
128  m_height( aHeight ), m_width( aWidth ), m_thickness( aThickness ),
129  m_orientation( aOrientation ),
130  m_hJustify( aHJustify ), m_vJustify( aVJustify )
131  {
132  }
133 
134  void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
135  {
136  aImporter.AddText( m_origin, m_text, m_height, m_width,
138  }
139 
140 private:
142  const wxString m_text;
143  double m_height;
144  double m_width;
145  double m_thickness;
149 };
150 
151 
153 {
154 public:
155  IMPORTED_SPLINE( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
156  const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, double aWidth )
157  : m_start( aStart ), m_bezierControl1( aBezierControl1 ),
158  m_bezierControl2( aBezierControl2 ), m_end( aEnd ), m_width( aWidth )
159  {
160  }
161 
162  void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
163  {
165  }
166 
167 private:
172  double m_width;
173 };
174 
175 
177 {
178 public:
179  void AddLine( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth ) override;
180 
181  void AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth ) override;
182 
183  void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) override;
184 
185  void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
186 
187  void AddText( const VECTOR2D& aOrigin, const wxString& aText,
188  double aHeight, double aWidth, double aThickness, double aOrientation,
189  EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
190 
191  void AddSpline( const VECTOR2D& aStart, const VECTOR2D& BezierControl1,
192  const VECTOR2D& BezierControl2, const VECTOR2D& aEnd , double aWidth ) override;
193 
194  void ImportTo( GRAPHICS_IMPORTER& aImporter );
195 
196 protected:
198  std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes;
199 };
200 
201 #endif /* GRAPHICS_IMPORTER_BUFFER */
Interface that creates objects representing shapes for a given data model.
EDA_TEXT_HJUSTIFY_T m_hJustify
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:62
virtual void ImportTo(GRAPHICS_IMPORTER &aImporter) const =0
virtual void AddPolygon(const std::vector< VECTOR2D > &aVertices, double aWidth)=0
void AddLine(const VECTOR2D &aStart, const VECTOR2D &aEnd, double aWidth) override
Creates an object representing a line segment.
EDA_TEXT_VJUSTIFY_T m_vJustify
const VECTOR2D m_start
const VECTOR2D m_start
IMPORTED_POLYGON(const std::vector< VECTOR2D > &aVertices, double aWidth)
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, double aAngle, double aWidth) override
Creates an object representing an arc.
Class VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
virtual void AddSpline(const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, double aWidth)=0
Creates an object representing an arc.
IMPORTED_LINE(const VECTOR2D &aStart, const VECTOR2D &aEnd, double aWidth)
virtual void AddCircle(const VECTOR2D &aCenter, double aRadius, double aWidth)=0
Creates an object representing a circle.
void ImportTo(GRAPHICS_IMPORTER &aImporter) const override
void ImportTo(GRAPHICS_IMPORTER &aImporter) const override
void AddSpline(const VECTOR2D &aStart, const VECTOR2D &BezierControl1, const VECTOR2D &BezierControl2, const VECTOR2D &aEnd, double aWidth) override
Creates an object representing an arc.
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes
IMPORTED_SPLINE(const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, double aWidth)
void AddPolygon(const std::vector< VECTOR2D > &aVertices, double aWidth) override
virtual void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, double aAngle, double aWidth)=0
Creates an object representing an arc.
const std::vector< VECTOR2D > m_vertices
void ImportTo(GRAPHICS_IMPORTER &aImporter) const override
void AddCircle(const VECTOR2D &aCenter, double aRadius, double aWidth) override
Creates an object representing a circle.
const VECTOR2D m_center
virtual void AddText(const VECTOR2D &aOrigin, const wxString &aText, double aHeight, double aWidth, double aThickness, double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify)=0
Creates an object representing a text.
IMPORTED_CIRCLE(const VECTOR2D &aCenter, double aRadius, double aWidth)
IMPORTED_TEXT(const VECTOR2D &aOrigin, const wxString &aText, double aHeight, double aWidth, double aThickness, double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify)
void AddText(const VECTOR2D &aOrigin, const wxString &aText, double aHeight, double aWidth, double aThickness, double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify) override
Creates an object representing a text.
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:69
IMPORTED_ARC(const VECTOR2D &aCenter, const VECTOR2D &aStart, double aAngle, double aWidth)
void ImportTo(GRAPHICS_IMPORTER &aImporter) const override
void ImportTo(GRAPHICS_IMPORTER &aImporter) const override
virtual void AddLine(const VECTOR2D &aOrigin, const VECTOR2D &aEnd, double aWidth)=0
Creates an object representing a line segment.
void ImportTo(GRAPHICS_IMPORTER &aImporter)
const VECTOR2D m_bezierControl2
const VECTOR2D m_bezierControl1
void ImportTo(GRAPHICS_IMPORTER &aImporter) const override