Q3CanvasEllipse Class Reference

#include <q3canvas.h>

Inheritance diagram for Q3CanvasEllipse:

Inheritance graph
[legend]
Collaboration diagram for Q3CanvasEllipse:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Q3CanvasEllipse class provides an ellipse or ellipse segment on a Q3Canvas.

A canvas item that paints an ellipse or ellipse segment with a QBrush. The ellipse's height, width, start angle and angle length can be set at construction time. The size can be changed at runtime with setSize(), and the angles can be changed (if you're displaying an ellipse segment rather than a whole ellipse) with setAngles().

Note that angles are specified in 16ths of a degree.

anglediagram qcanvasellipse.png Ellipse

If a start angle and length angle are set then an ellipse segment will be drawn. The start angle is the angle that goes from zero in a counter-clockwise direction (shown in green in the diagram). The length angle is the angle from the start angle in a counter-clockwise direction (shown in blue in the diagram). The blue segment is the segment of the ellipse that would be drawn. If no start angle and length angle are specified the entire ellipse is drawn.

The ellipse can be drawn on a painter with drawShape().

Like any other canvas item ellipses can be moved with move() and moveBy(), or by setting coordinates with setX(), setY() and setZ().

Note: Q3CanvasEllipse does not use the pen.

See also:
QtCanvas, {Porting to Graphics View}

Definition at line 667 of file q3canvas.h.

Public Member Functions

 Q3CanvasEllipse (Q3Canvas *canvas)
 Q3CanvasEllipse (int width, int height, Q3Canvas *canvas)
 Q3CanvasEllipse (int width, int height, int startangle, int angle, Q3Canvas *canvas)
 ~Q3CanvasEllipse ()
int width () const
int height () const
void setSize (int w, int h)
void setAngles (int start, int length)
int angleStart () const
int angleLength () const
Q3PointArray areaPoints () const
bool collidesWith (const Q3CanvasItem *) const
int rtti () const

Static Public Attributes

static int RTTI

Protected Member Functions

void drawShape (QPainter &)

Private Member Functions

bool collidesWith (const Q3CanvasSprite *, const Q3CanvasPolygonalItem *, const Q3CanvasRectangle *, const Q3CanvasEllipse *, const Q3CanvasText *) const

Private Attributes

int w
int h
int a1
int a2


Constructor & Destructor Documentation

Q3CanvasEllipse::Q3CanvasEllipse ( Q3Canvas canvas  ) 

Constructs a 32x32 ellipse, centered at (0, 0) on canvas.

Definition at line 4490 of file q3canvas.cpp.

04490                                                  :
04491     Q3CanvasPolygonalItem(canvas),
04492     w(32), h(32),
04493     a1(0), a2(360*16)
04494 {
04495 }

Q3CanvasEllipse::Q3CanvasEllipse ( int  width,
int  height,
Q3Canvas canvas 
)

Constructs a width by height pixel ellipse, centered at (0, 0) on canvas.

Definition at line 4501 of file q3canvas.cpp.

04501                                                                         :
04502     Q3CanvasPolygonalItem(canvas),
04503     w(width),h(height),
04504     a1(0),a2(360*16)
04505 {
04506 }

Q3CanvasEllipse::Q3CanvasEllipse ( int  width,
int  height,
int  startangle,
int  angle,
Q3Canvas canvas 
)

Constructs a width by height pixel ellipse, centered at (0, 0) on canvas. Only a segment of the ellipse is drawn, starting at angle startangle, and extending for angle angle (the angle length).

Note that angles are specified in sixteenths of a degree.

Definition at line 4519 of file q3canvas.cpp.

04520                                                  :
04521     Q3CanvasPolygonalItem(canvas),
04522     w(width),h(height),
04523     a1(startangle),a2(angle)
04524 {
04525 }

Q3CanvasEllipse::~Q3CanvasEllipse (  ) 

Destroys the ellipse.

Definition at line 4530 of file q3canvas.cpp.

References Q3CanvasItem::hide().

04531 {
04532     hide();
04533 }

Here is the call graph for this function:


Member Function Documentation

int Q3CanvasEllipse::width (  )  const

Returns the width of the ellipse.

Definition at line 4538 of file q3canvas.cpp.

References w.

Referenced by collision_double_dispatch().

04539 {
04540     return w;
04541 }

int Q3CanvasEllipse::height (  )  const

Returns the height of the ellipse.

Definition at line 4546 of file q3canvas.cpp.

References h.

Referenced by collision_double_dispatch().

04547 {
04548     return h;
04549 }

void Q3CanvasEllipse::setSize ( int  width,
int  height 
)

Sets the width and height of the ellipse.

Definition at line 4554 of file q3canvas.cpp.

References Q3CanvasItem::addToChunks(), h, Q3CanvasItem::removeFromChunks(), and w.

04555 {
04556     if (w != width || h != height) {
04557   removeFromChunks();
04558   w = width;
04559   h = height;
04560   addToChunks();
04561     }
04562 }

Here is the call graph for this function:

void Q3CanvasEllipse::setAngles ( int  start,
int  length 
)

Sets the angles for the ellipse. The start angle is start and the extent of the segment is length (the angle length) from the start. The angles are specified in 16ths of a degree. By default the ellipse will start at 0 and have an angle length of 360 * 16 (a complete ellipse).

See also:
angleStart(), angleLength()

Definition at line 4592 of file q3canvas.cpp.

References a1, a2, Q3CanvasItem::addToChunks(), and Q3CanvasItem::removeFromChunks().

04593 {
04594     if (a1 != start || a2 != length) {
04595   removeFromChunks();
04596   a1 = start;
04597   a2 = length;
04598   addToChunks();
04599     }
04600 }

Here is the call graph for this function:

int Q3CanvasEllipse::angleStart (  )  const [inline]

Returns the start angle in 16ths of a degree. Initially this will be 0.

See also:
setAngles(), angleLength()

Definition at line 682 of file q3canvas.h.

00683   { return a1; }

int Q3CanvasEllipse::angleLength (  )  const [inline]

Returns the length angle (the extent of the ellipse segment) in 16ths of a degree. Initially this will be 360 * 16 (a complete ellipse).

See also:
setAngles(), angleStart()

Definition at line 684 of file q3canvas.h.

Referenced by collision_double_dispatch().

00685   { return a2; }

Q3PointArray Q3CanvasEllipse::areaPoints (  )  const [virtual]

Implements Q3CanvasPolygonalItem.

Definition at line 4605 of file q3canvas.cpp.

References a1, a2, h, int, Q3PointArray::makeArc(), QVector< T >::resize(), QPolygon::setPoint(), QVector< T >::size(), w, Q3CanvasItem::x(), and Q3CanvasItem::y().

04606 {
04607     Q3PointArray r;
04608     // makeArc at 0,0, then translate so that fixed point math doesn't overflow
04609     r.makeArc(int(x()-w/2.0+0.5)-1, int(y()-h/2.0+0.5)-1, w+3, h+3, a1, a2);
04610     r.resize(r.size()+1);
04611     r.setPoint(r.size()-1,int(x()),int(y()));
04612     return r;
04613 }

Here is the call graph for this function:

bool Q3CanvasEllipse::collidesWith ( const Q3CanvasItem i  )  const [virtual]

Reimplemented from Q3CanvasPolygonalItem.

Definition at line 2442 of file q3canvas.cpp.

References i.

02443 {
02444     return i->collidesWith(0,this,0,this,0);
02445 }

int Q3CanvasEllipse::rtti (  )  const [virtual]

Returns 6 (Q3CanvasItem::Rtti_Ellipse).

See also:
Q3CanvasItem::rtti()

Reimplemented from Q3CanvasPolygonalItem.

Definition at line 4956 of file q3canvas.cpp.

References RTTI.

04956 { return RTTI; }

void Q3CanvasEllipse::drawShape ( QPainter p  )  [protected, virtual]

Draws the ellipse, centered at x(), y() using the painter p.

Note that Q3CanvasEllipse does not support an outline (the pen is always NoPen).

Implements Q3CanvasPolygonalItem.

Definition at line 4623 of file q3canvas.cpp.

References a1, a2, h, Qt::NoPen, p, w, Q3CanvasItem::x(), and Q3CanvasItem::y().

04624 {
04625     p.setPen(NoPen); // since QRegion(Q3PointArray) excludes outline :-()-:
04626     if (!a1 && a2 == 360*16) {
04627   p.drawEllipse(int(x()-w/2.0+0.5), int(y()-h/2.0+0.5), w, h);
04628     } else {
04629   p.drawPie(int(x()-w/2.0+0.5), int(y()-h/2.0+0.5), w, h, a1, a2);
04630     }
04631 }

Here is the call graph for this function:

bool Q3CanvasEllipse::collidesWith ( const Q3CanvasSprite ,
const Q3CanvasPolygonalItem ,
const Q3CanvasRectangle ,
const Q3CanvasEllipse ,
const Q3CanvasText  
) const [private, virtual]

Reimplemented from Q3CanvasPolygonalItem.

Definition at line 2447 of file q3canvas.cpp.

References collision_double_dispatch(), p, s, and t.

02452 {
02453     return collision_double_dispatch(s,p,r,e,t,0,this,0,this,0);
02454 }

Here is the call graph for this function:


Member Data Documentation

int Q3CanvasEllipse::RTTI [static]

Reimplemented from Q3CanvasPolygonalItem.

Definition at line 691 of file q3canvas.h.

Referenced by rtti().

int Q3CanvasEllipse::w [private]

Definition at line 702 of file q3canvas.h.

Referenced by areaPoints(), drawShape(), setSize(), and width().

int Q3CanvasEllipse::h [private]

Definition at line 702 of file q3canvas.h.

Referenced by areaPoints(), drawShape(), height(), and setSize().

int Q3CanvasEllipse::a1 [private]

Definition at line 703 of file q3canvas.h.

Referenced by areaPoints(), drawShape(), and setAngles().

int Q3CanvasEllipse::a2 [private]

Definition at line 703 of file q3canvas.h.

Referenced by areaPoints(), drawShape(), and setAngles().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 15:42:53 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1