1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
5  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
23  */
24 
25 /**
26  * @file kicadcurve.h
27  * Declare the Curve (glyph) object.
28  */
29 
30 #ifndef KICADCURVE_H
31 #define KICADCURVE_H
32 
33 #include <string>
34 #include <vector>
35 #include "base.h"
36 
37 
38 class KICADCURVE
39 {
40 public:
41     KICADCURVE();
42     virtual ~KICADCURVE();
43 
44     bool Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType );
45 
GetLayer()46     LAYERS GetLayer()
47     {
48         return m_layer;
49     }
50 
51     ///< Return human-readable description of the curve.
52     std::string Describe() const;
53 
54     CURVE_TYPE m_form;          // form of curve: line, arc, circle
55     LAYERS     m_layer;         // layer of the glyph
56     DOUBLET    m_start;         // start point of line or center for arc and circle
57     DOUBLET    m_end;           // end point of line, first point on arc or circle
58     DOUBLET    m_middle;        // middle point on arc for recent files
59     DOUBLET    m_ep;            // actual endpoint, to be computed in the case of arcs
60     DOUBLET    m_bezierctrl1;   // for bezier curve only first control point
61     DOUBLET    m_bezierctrl2;   // for bezier curve only second control point
62     double     m_radius;        // radius; to be computed in the case of arcs and circles
63     double     m_angle;         // subtended angle of arc
64     double     m_startangle;
65     double     m_endangle;
66     bool       m_arcHasMiddlePoint; // true if an arc id defined by 3 points
67 
68     std::vector<DOUBLET> m_poly; // vector of polygon points
69 };
70 
71 #endif  // KICADCURVE_H
72