Code

Mnemonics in fill and stroke dialog and menu
[inkscape.git] / src / 2geom / circle.h
1 /**
2  * \file
3  * \brief Circle Curve
4  *
5  * Authors:
6  *      Marco Cecchetti <mrcekets at gmail.com>
7  *
8  * Copyright 2008  authors
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it either under the terms of the GNU Lesser General Public
12  * License version 2.1 as published by the Free Software Foundation
13  * (the "LGPL") or, at your option, under the terms of the Mozilla
14  * Public License Version 1.1 (the "MPL"). If you do not alter this
15  * notice, a recipient may use your version of this file under either
16  * the MPL or the LGPL.
17  *
18  * You should have received a copy of the LGPL along with this library
19  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  * You should have received a copy of the MPL along with this library
22  * in the file COPYING-MPL-1.1
23  *
24  * The contents of this file are subject to the Mozilla Public License
25  * Version 1.1 (the "License"); you may not use this file except in
26  * compliance with the License. You may obtain a copy of the License at
27  * http://www.mozilla.org/MPL/
28  *
29  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
30  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
31  * the specific language governing rights and limitations.
32  */
35 #ifndef _2GEOM_CIRCLE_H_
36 #define _2GEOM_CIRCLE_H_
39 #include <2geom/point.h>
40 #include <2geom/exception.h>
41 #include <2geom/path.h>
43 namespace Geom
44 {
46 class SVGEllipticalArc;
48 class Circle
49 {
50   public:
51     Circle()
52     {}
54     Circle(double cx, double cy, double r)
55         : m_centre(cx, cy), m_ray(r)
56     {
57     }
59     Circle(Point center, double r)
60         : m_centre(center), m_ray(r)
61     {
62     }
64     Circle(double A, double B, double C, double D)
65     {
66         set(A, B, C, D);
67     }
69     Circle(std::vector<Point> const& points)
70     {
71         set(points);
72     }
74     void set(double cx, double cy, double r)
75     {
76         m_centre[X] = cx;
77         m_centre[Y] = cy;
78         m_ray = r;
79     }
82     // build a circle by its implicit equation:
83     // Ax^2 + Ay^2 + Bx + Cy + D = 0
84     void set(double A, double B, double C, double D);
86     // build up the best fitting circle wrt the passed points
87     // prerequisite: at least 3 points must be passed
88     void set(std::vector<Point> const& points);
90     SVGEllipticalArc
91     arc(Point const& initial, Point const& inner, Point const& final,
92         bool _svg_compliant = true);
94     void
95     getPath(std::vector<Path> &path_out);
97     Point center() const
98     {
99         return m_centre;
100     }
102     Coord center(Dim2 d) const
103     {
104         return m_centre[d];
105     }
107     Coord ray() const
108     {
109         return m_ray;
110     }
113   private:
114     Point m_centre;
115     Coord m_ray;
116 };
119 } // end namespace Geom
123 #endif // _2GEOM_CIRCLE_H_
126 /*
127   Local Variables:
128   mode:c++
129   c-file-style:"stroustrup"
130   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
131   indent-tabs-mode:nil
132   fill-column:99
133   End:
134 */
135 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :