Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Q3CanvasPolygonalItem Class Reference

The Q3CanvasPolygonalItem class provides a polygonal canvas item on a Q3Canvas. More...

 #include <Q3CanvasPolygonalItem>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits: Q3CanvasItem.

Inherited by: Q3CanvasEllipse, Q3CanvasLine, Q3CanvasPolygon, and Q3CanvasRectangle.

Public Functions

Q3CanvasPolygonalItem ( Q3Canvas * canvas )
virtual ~Q3CanvasPolygonalItem ()
virtual Q3PointArray areaPoints () const = 0
virtual Q3PointArray areaPointsAdvanced () const
QBrush brush () const
QPen pen () const
virtual void setBrush ( QBrush b )
virtual void setPen ( QPen p )

Reimplemented Public Functions

virtual QRect boundingRect () const
virtual bool collidesWith ( const Q3CanvasItem * i ) const
virtual int rtti () const

Protected Functions

virtual void drawShape ( QPainter & p ) = 0
void invalidate ()
bool isValid () const
void setWinding ( bool enable )
bool winding () const

Reimplemented Protected Functions

virtual void draw ( QPainter & p )

Detailed Description

The Q3CanvasPolygonalItem class provides a polygonal canvas item on a Q3Canvas.

The mostly rectangular classes, such as Q3CanvasSprite and Q3CanvasText, use the object's bounding rectangle for movement, repainting and collision calculations. For most other items, the bounding rectangle can be far too large -- a diagonal line being the worst case, and there are many other cases which are also bad. Q3CanvasPolygonalItem provides polygon-based bounding rectangle handling, etc., which is much faster for non-rectangular items.

Derived classes should try to define as small an area as possible to maximize efficiency, but the polygon must definitely be contained completely within the polygonal area. Calculating the exact requirements is usually difficult, but if you allow a small overestimate it can be easy and quick, while still getting almost all of Q3CanvasPolygonalItem's speed.

Note that all subclasses must call hide() in their destructor since hide() needs to be able to access areaPoints().

Normally, Q3CanvasPolygonalItem uses the odd-even algorithm for determining whether an object intersects this object. You can change this to the winding algorithm using setWinding().

The bounding rectangle is available using boundingRect(). The points bounding the polygonal item are retrieved with areaPoints(). Use areaPointsAdvanced() to retrieve the bounding points the polygonal item will have after Q3CanvasItem::advance(1) has been called.

If the shape of the polygonal item is about to change while the item is visible, call invalidate() before updating with a different result from areaPoints().

By default, Q3CanvasPolygonalItem objects have a black pen and no brush (the default QPen and QBrush constructors). You can change this with setPen() and setBrush(), but note that some Q3CanvasPolygonalItem subclasses only use the brush, ignoring the pen setting.

The polygonal item can be drawn on a painter with draw(). Subclasses must reimplement drawShape() to draw themselves.

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

See also QtCanvas and Porting to Graphics View.

Member Function Documentation

Q3CanvasPolygonalItem::Q3CanvasPolygonalItem ( Q3Canvas * canvas )

Constructs a Q3CanvasPolygonalItem on the canvas canvas.

Q3CanvasPolygonalItem::~Q3CanvasPolygonalItem () [virtual]

Note that all subclasses must call hide() in their destructor since hide() needs to be able to access areaPoints().

Q3PointArray Q3CanvasPolygonalItem::areaPoints () const [pure virtual]

This function must be reimplemented by subclasses. It must return the points bounding (i.e. outside and not touching) the shape or drawing errors will occur.

Q3PointArray Q3CanvasPolygonalItem::areaPointsAdvanced () const [virtual]

Returns the points the polygonal item will have after Q3CanvasItem::advance(1) is called, i.e. what the points are when advanced by the current xVelocity() and yVelocity().

QRect Q3CanvasPolygonalItem::boundingRect () const [virtual]

Reimplemented from Q3CanvasItem::boundingRect().

Returns the bounding rectangle of the polygonal item, based on areaPoints().

QBrush Q3CanvasPolygonalItem::brush () const

Returns the QBrush used to fill the item, if filled.

See also setBrush().

bool Q3CanvasPolygonalItem::collidesWith ( const Q3CanvasItem * i ) const [virtual]

Reimplemented from Q3CanvasItem::collidesWith().

void Q3CanvasPolygonalItem::draw ( QPainter & p ) [virtual protected]

Reimplemented from Q3CanvasItem::draw().

Reimplemented from Q3CanvasItem, this draws the polygonal item by setting the pen and brush for the item on the painter p and calling drawShape().

void Q3CanvasPolygonalItem::drawShape ( QPainter & p ) [pure virtual protected]

Subclasses must reimplement this function to draw their shape. The pen and brush of p are already set to pen() and brush() prior to calling this function.

See also draw().

void Q3CanvasPolygonalItem::invalidate () [protected]

Invalidates all information about the area covered by the canvas item. The item will be updated automatically on the next call that changes the item's status, for example, move() or update(). Call this function if you are going to change the shape of the item (as returned by areaPoints()) while the item is visible.

bool Q3CanvasPolygonalItem::isValid () const [protected]

Returns true if the polygonal item's area information has not been invalidated; otherwise returns false.

See also invalidate().

QPen Q3CanvasPolygonalItem::pen () const

Returns the QPen used to draw the outline of the item, if any.

See also setPen().

int Q3CanvasPolygonalItem::rtti () const [virtual]

Reimplemented from Q3CanvasItem::rtti().

Returns 2 (Q3CanvasItem::Rtti_PolygonalItem).

See also Q3CanvasItem::rtti().

void Q3CanvasPolygonalItem::setBrush ( QBrush b ) [virtual]

Sets the QBrush used when drawing the polygonal item to the brush b.

See also setPen(), brush(), and drawShape().

void Q3CanvasPolygonalItem::setPen ( QPen p ) [virtual]

Sets the QPen used when drawing the item to the pen p. Note that many Q3CanvasPolygonalItems do not use the pen value.

See also setBrush(), pen(), and drawShape().

void Q3CanvasPolygonalItem::setWinding ( bool enable ) [protected]

If enable is true, the polygonal item will use the winding algorithm to determine the "inside" of the polygon; otherwise the odd-even algorithm will be used.

The default is to use the odd-even algorithm.

See also winding().

bool Q3CanvasPolygonalItem::winding () const [protected]

Returns true if the polygonal item uses the winding algorithm to determine the "inside" of the polygon. Returns false if it uses the odd-even algorithm.

The default is to use the odd-even algorithm.

See also setWinding().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 43
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web