summaryrefslogtreecommitdiffstats
path: root/kig/objects/circle_imp.h
blob: 98fa391d7315d9de88d88b28dd826597d42e847e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright (C)  2003  Dominique Devriese <[email protected]>

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301, USA.

#ifndef KIG_OBJECTS_CIRCLE_IMP_H
#define KIG_OBJECTS_CIRCLE_IMP_H

#include "conic_imp.h"

/**
 * An ObjectImp representing a circle.  This class is a subclass of
 * ConicImp, ensuring that a circle can be used as a conic.
 */
class CircleImp
  : public ConicImp
{
  Coordinate mcenter;
  double mradius;
public:
  typedef ConicImp Parent;
  /**
   * Returns the ObjectImpType representing the CircleImp type..
   */
  static const ObjectImpType* stype();

  /**
   * Construct a Circle with a given center and radius.
   */
  CircleImp( const Coordinate& center, double radius );
  ~CircleImp();
  CircleImp* copy() const;

  ObjectImp* transform( const Transformation& ) const;

  void draw( KigPainter& p ) const;
  bool tqcontains( const Coordinate& p, int width, const KigWidget& ) const;
  bool inRect( const Rect& r, int width, const KigWidget& ) const;
  bool valid() const;
  Rect surroundingRect() const;

  double getParam( const Coordinate& point, const KigDocument& ) const;
  const Coordinate getPoint( double param, const KigDocument& ) const;

  const uint numberOfProperties() const;
  const QCStringList properties() const;
  const QCStringList propertiesInternalNames() const;
  ObjectImp* property( uint which, const KigDocument& w ) const;
  const char* iconForProperty( uint which ) const;
  const ObjectImpType* impRequirementForProperty( uint which ) const;
  bool isPropertyDefinedOnOrThroughThisImp( uint which ) const;

  const ObjectImpType* type() const;
  void visit( ObjectImpVisitor* vtor ) const;

  /**
   * Return the center of this circle.
   */
  const Coordinate center() const;
  /**
   * Return the radius of this circle.
   */
  double radius() const;
  /**
   * Return the square radius of this circle.  Use this in preference
   * to sqr( radius() ).
   */
  double squareRadius() const;
  /**
   * Return the surface of this circle.
   */
  double surface() const;
  /**
   * Return the circumference of this circle.
   */
  double circumference() const;

  // trivial versions of the conic information functions..
  /**
   * Always returns 1, since a circle always is an ellipse.
   */
  int conicType() const;
  const ConicCartesianData cartesianData() const;
  const ConicPolarData polarData() const;
  /**
   * The first focus of a circle is simply its center.
   */
  Coordinate focus1() const;
  /**
   * The second focus of a circle is simply its center.
   */
  Coordinate focus2() const;

  /**
   * Return a string containing the cartesian equation of this circle.
   * This will be of the form "x^2 + y^2 + a x + b y + c = 0"
   */
  TQString cartesianEquationString( const KigDocument& w ) const;
  /**
   * Return a string containing the cartesian equation of this circle.
   * This will be of the form "( x - x0 )^2 + ( y - y0 )^2 = r^2"
   */
  TQString simplyCartesianEquationString( const KigDocument& w ) const;
  /**
   * Return a string containing the polar equation of this circle.
   * This will be of the form "rho = r  [centered at p]"
   */
  TQString polarEquationString( const KigDocument& w ) const;

  bool equals( const ObjectImp& rhs ) const;
};

#endif