1 // Copyright (C) 2003 Dominique Devriese <devriese@kde.org>
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 #ifndef KIG_OBJECTS_CIRCLE_IMP_H
19 #define KIG_OBJECTS_CIRCLE_IMP_H
21 #include "conic_imp.h"
24 * An ObjectImp representing a circle. This class is a subclass of
25 * ConicImp, ensuring that a circle can be used as a conic.
33 typedef ConicImp Parent
;
35 * Returns the ObjectImpType representing the CircleImp type..
37 static const ObjectImpType
* stype();
40 * Construct a Circle with a given center and radius.
42 CircleImp( const Coordinate
& center
, double radius
);
44 CircleImp
* copy() const;
46 ObjectImp
* transform( const Transformation
& ) const;
48 void draw( KigPainter
& p
) const;
49 bool contains( const Coordinate
& p
, int width
, const KigWidget
& ) const;
50 bool inRect( const Rect
& r
, int width
, const KigWidget
& ) const;
52 Rect
surroundingRect() const;
54 double getParam( const Coordinate
& point
, const KigDocument
& ) const;
55 const Coordinate
getPoint( double param
, const KigDocument
& ) const;
57 const uint
numberOfProperties() const;
58 const QCStringList
properties() const;
59 const QCStringList
propertiesInternalNames() const;
60 ObjectImp
* property( uint which
, const KigDocument
& w
) const;
61 const char* iconForProperty( uint which
) const;
62 const ObjectImpType
* impRequirementForProperty( uint which
) const;
63 bool isPropertyDefinedOnOrThroughThisImp( uint which
) const;
65 const ObjectImpType
* type() const;
66 void visit( ObjectImpVisitor
* vtor
) const;
69 * Return the center of this circle.
71 const Coordinate
center() const;
73 * Return the radius of this circle.
75 double radius() const;
77 * Return the square radius of this circle. Use this in preference
80 double squareRadius() const;
82 * Return the surface of this circle.
84 double surface() const;
86 * Return the circumference of this circle.
88 double circumference() const;
90 // trivial versions of the conic information functions..
92 * Always returns 1, since a circle always is an ellipse.
94 int conicType() const;
95 const ConicCartesianData
cartesianData() const;
96 const ConicPolarData
polarData() const;
98 * The first focus of a circle is simply its center.
100 Coordinate
focus1() const;
102 * The second focus of a circle is simply its center.
104 Coordinate
focus2() const;
107 * Return a string containing the cartesian equation of this circle.
108 * This will be of the form "x^2 + y^2 + a x + b y + c = 0"
110 QString
cartesianEquationString( const KigDocument
& w
) const;
112 * Return a string containing the cartesian equation of this circle.
113 * This will be of the form "( x - x0 )^2 + ( y - y0 )^2 = r^2"
115 QString
simplyCartesianEquationString( const KigDocument
& w
) const;
117 * Return a string containing the polar equation of this circle.
118 * This will be of the form "rho = r [centered at p]"
120 QString
polarEquationString( const KigDocument
& w
) const;
122 bool equals( const ObjectImp
& rhs
) const;