Eneboo - Documentación para desarrolladores
Clases | Tipos públicos | Métodos públicos | Amigas
Referencia de la Clase QRegion

The QRegion class specifies a clip region for a painter. Más...

#include <qregion.h>

Lista de todos los miembros.

Clases

struct  QRegionData

Tipos públicos

enum  RegionType { Rectangle, Ellipse, Rectangle, Ellipse }
enum  RegionType { Rectangle, Ellipse, Rectangle, Ellipse }

Métodos públicos

 QRegion ()
 QRegion (int x, int y, int w, int h, RegionType=Rectangle)
 QRegion (const QRect &, RegionType=Rectangle)
 QRegion (const QPointArray &, bool winding=FALSE)
 QRegion (const QRegion &)
 QRegion (const QBitmap &)
 ~QRegion ()
QRegionoperator= (const QRegion &)
bool isNull () const
bool isEmpty () const
bool contains (const QPoint &p) const
bool contains (const QRect &r) const
void translate (int dx, int dy)
QRegion unite (const QRegion &) const
QRegion intersect (const QRegion &) const
QRegion subtract (const QRegion &) const
QRegion eor (const QRegion &) const
QRect boundingRect () const
QMemArray< QRectrects () const
void setRects (const QRect *, int)
const QRegion operator| (const QRegion &) const
const QRegion operator+ (const QRegion &) const
const QRegion operator& (const QRegion &) const
const QRegion operator- (const QRegion &) const
const QRegion operator^ (const QRegion &) const
QRegionoperator|= (const QRegion &)
QRegionoperator+= (const QRegion &)
QRegionoperator&= (const QRegion &)
QRegionoperator-= (const QRegion &)
QRegionoperator^= (const QRegion &)
bool operator== (const QRegion &) const
bool operator!= (const QRegion &r) const
 QRegion ()
 QRegion (int x, int y, int w, int h, RegionType=Rectangle)
 QRegion (const QRect &, RegionType=Rectangle)
 QRegion (const QPointArray &, bool winding=FALSE)
 QRegion (const QRegion &)
 QRegion (const QBitmap &)
 ~QRegion ()
QRegionoperator= (const QRegion &)
bool isNull () const
bool isEmpty () const
bool contains (const QPoint &p) const
bool contains (const QRect &r) const
void translate (int dx, int dy)
QRegion unite (const QRegion &) const
QRegion intersect (const QRegion &) const
QRegion subtract (const QRegion &) const
QRegion eor (const QRegion &) const
QRect boundingRect () const
QMemArray< QRectrects () const
void setRects (const QRect *, int)
const QRegion operator| (const QRegion &) const
const QRegion operator+ (const QRegion &) const
const QRegion operator& (const QRegion &) const
const QRegion operator- (const QRegion &) const
const QRegion operator^ (const QRegion &) const
QRegionoperator|= (const QRegion &)
QRegionoperator+= (const QRegion &)
QRegionoperator&= (const QRegion &)
QRegionoperator-= (const QRegion &)
QRegionoperator^= (const QRegion &)
bool operator== (const QRegion &) const
bool operator!= (const QRegion &r) const

Amigas

Q_EXPORT QDataStreamoperator<< (QDataStream &, const QRegion &)
Q_EXPORT QDataStreamoperator>> (QDataStream &, QRegion &)
Q_EXPORT QDataStreamoperator<< (QDataStream &, const QRegion &)
Q_EXPORT QDataStreamoperator>> (QDataStream &, QRegion &)

Descripción detallada

The QRegion class specifies a clip region for a painter.

QRegion is used with QPainter::setClipRegion() to limit the paint area to what needs to be painted. There is also a QWidget::repaint() that takes a QRegion parameter. QRegion is the best tool for reducing flicker.

A region can be created from a rectangle, an ellipse, a polygon or a bitmap. Complex regions may be created by combining simple regions using unite(), intersect(), subtract() or eor() (exclusive or). You can move a region using translate().

You can test whether a region isNull(), isEmpty() or if it contains() a QPoint or QRect. The bounding rectangle is given by boundingRect().

The function rects() gives a decomposition of the region into rectangles.

Example of using complex regions:

        void MyWidget::paintEvent( QPaintEvent * )
        {
            QPainter p;                         // our painter
            QRegion r1( QRect(100,100,200,80),  // r1 = elliptic region
                        QRegion::Ellipse );
            QRegion r2( QRect(100,120,90,30) ); // r2 = rectangular region
            QRegion r3 = r1.intersect( r2 );    // r3 = intersection
            p.begin( this );                    // start painting widget
            p.setClipRegion( r3 );              // set clip region
            ...                                 // paint clipped graphics
            p.end();                            // painting done
        }

QRegion is an implicitly shared class.

Atención:
Due to window system limitations, the whole coordinate space for a region is limited to the points between -32767 and 32767 on Mac OS X and Windows 95/98/ME.
Ver también:
QPainter::setClipRegion(), QPainter::setClipRect()

Documentación de las enumeraciones miembro de la clase

Specifies the shape of the region to be created.

Rectangle the region covers the entire rectangle. Ellipse the region is an ellipse inside the rectangle.

Valores de enumeraciones:
Rectangle 
Ellipse 
Rectangle 
Ellipse 
Valores de enumeraciones:
Rectangle 
Ellipse 
Rectangle 
Ellipse 

Documentación del constructor y destructor

QRegion::QRegion ( )

Constructs a null region.

Ver también:
isNull()
QRegion::QRegion ( int  x,
int  y,
int  w,
int  h,
RegionType  t = Rectangle 
)

Constructs a rectangular or elliptic region.

If t is Rectangle, the region is the filled rectangle (x, y, w, h). If t is Ellipse, the region is the filled ellipse with center at (x + w / 2, y + h / 2) and size (w ,h ).

QRegion::QRegion ( const QRect r,
RegionType  t = Rectangle 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. If the rectangle is invalid, the rectangle will be normalized() before the region is created. This semantics will change in Qt-3 and an invalid rectangle will construct an empty region.

Ver también:
QRect::isValid() QRect::normalize()

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Create a region based on the rectange r with region type t.

If the rectangle is invalid a null region will be created.

Ver también:
QRegion::RegionType
QRegion::QRegion ( const QPointArray a,
bool  winding = FALSE 
)

Constructs a polygon region from the point array a.

If winding is TRUE, the polygon region is filled using the winding algorithm, otherwise the default even-odd fill algorithm is used.

This constructor may create complex regions that will slow down painting when used.

QRegion::QRegion ( const QRegion r)

Constructs a new region which is equal to r.

Constructs a new region which is equal to region r.

QRegion::QRegion ( const QBitmap bm)

Constructs a region from the bitmap bm.

The resulting region consists of the pixels in bm that are color1, as if each pixel was a 1 by 1 rectangle.

This constructor may create complex regions that will slow down painting when used. Note that drawing masked pixmaps can be done much faster using QPixmap::setMask().

Constructs a region from the bitmap bm.

The resulting region consists of the pixels in bitmap bm that are color1, as if each pixel was a 1 by 1 rectangle.

This constructor may create complex regions that will slow down painting when used. Note that drawing masked pixmaps can be done much faster using QPixmap::setMask().

QRegion::~QRegion ( )

Destructs the region.

Destroys the region.

QRegion::QRegion ( )
QRegion::QRegion ( int  x,
int  y,
int  w,
int  h,
RegionType  = Rectangle 
)
QRegion::QRegion ( const QRect ,
RegionType  = Rectangle 
)
QRegion::QRegion ( const QPointArray ,
bool  winding = FALSE 
)
QRegion::QRegion ( const QRegion )
QRegion::QRegion ( const QBitmap )
QRegion::~QRegion ( )

Documentación de las funciones miembro

QRect QRegion::boundingRect ( ) const

Returns the bounding rectangle of this region. An empty region gives a rectangle that is QRect::isNull().

QRect QRegion::boundingRect ( ) const
bool QRegion::contains ( const QPoint p) const

Returns TRUE if the region contains the point p; otherwise returns FALSE.

bool QRegion::contains ( const QRect r) const

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns TRUE if the region overlaps the rectangle r; otherwise returns FALSE.

bool QRegion::contains ( const QPoint p) const
bool QRegion::contains ( const QRect r) const
QRegion QRegion::eor ( const QRegion ) const
QRegion QRegion::eor ( const QRegion r) const

Returns a region which is the exclusive or (XOR) of this region and r.

rxor.png Region XORed

The figure shows the exclusive or of two elliptical regions.

QRegion QRegion::intersect ( const QRegion r) const

Returns a region which is the intersection of this region and r.

rintersect.png Region Intersection

The figure shows the intersection of two elliptical regions.

QRegion QRegion::intersect ( const QRegion ) const
bool QRegion::isEmpty ( void  ) const

Returns TRUE if the region is empty; otherwise returns FALSE. An empty region is a region that contains no points.

Example:

        QRegion r1( 10, 10, 20, 20 );
        QRegion r2( 40, 40, 20, 20 );
        QRegion r3;
        r1.isNull();             // FALSE
        r1.isEmpty();            // FALSE
        r3.isNull();             // TRUE
        r3.isEmpty();            // TRUE
        r3 = r1.intersect( r2 ); // r3 = intersection of r1 and r2
        r3.isNull();             // FALSE
        r3.isEmpty();            // TRUE
        r3 = r1.unite( r2 );     // r3 = union of r1 and r2
        r3.isNull();             // FALSE
        r3.isEmpty();            // FALSE
Ver también:
isNull()
bool QRegion::isEmpty ( ) const
bool QRegion::isNull ( ) const
bool QRegion::isNull ( ) const

Returns TRUE if the region is a null region; otherwise returns FALSE.

A null region is a region that has not been initialized. A null region is always empty.

Ver también:
isEmpty()
bool QRegion::operator!= ( const QRegion r) const [inline]
bool QRegion::operator!= ( const QRegion r) const [inline]

Returns TRUE if the region is different from r; otherwise returns FALSE.

const QRegion QRegion::operator& ( const QRegion r) const

Applies the intersect() function to this region and r. r1&r2 is equivalent to r1.intersect(r2)

Ver también:
intersect()
const QRegion QRegion::operator& ( const QRegion ) const
QRegion & QRegion::operator&= ( const QRegion r)

Applies the intersect() function to this region and r and assigns the result to this region. r1&=r2 is equivalent to r1=r1.intersect(r2)

Ver también:
intersect()
QRegion& QRegion::operator&= ( const QRegion )
const QRegion QRegion::operator+ ( const QRegion ) const
const QRegion QRegion::operator+ ( const QRegion r) const

Applies the unite() function to this region and r. r1+r2 is equivalent to r1.unite(r2)

Ver también:
unite(), operator|()
QRegion& QRegion::operator+= ( const QRegion )
QRegion & QRegion::operator+= ( const QRegion r)

Applies the unite() function to this region and r and assigns the result to this region. r1+=r2 is equivalent to r1=r1.unite(r2)

Ver también:
intersect()
const QRegion QRegion::operator- ( const QRegion r) const

Applies the subtract() function to this region and r. r1-r2 is equivalent to r1.subtract(r2)

Ver también:
subtract()
const QRegion QRegion::operator- ( const QRegion ) const
QRegion & QRegion::operator-= ( const QRegion r)

Applies the subtract() function to this region and r and assigns the result to this region. r1-=r2 is equivalent to r1=r1.subtract(r2)

Ver también:
subtract()
QRegion& QRegion::operator-= ( const QRegion )
QRegion & QRegion::operator= ( const QRegion r)

Assigns r to this region and returns a reference to the region.

QRegion& QRegion::operator= ( const QRegion )
bool QRegion::operator== ( const QRegion ) const
bool QRegion::operator== ( const QRegion r) const

Returns TRUE if the region is equal to r; otherwise returns FALSE.

const QRegion QRegion::operator^ ( const QRegion ) const
const QRegion QRegion::operator^ ( const QRegion r) const

Applies the eor() function to this region and r. r1^r2 is equivalent to r1.eor(r2)

Ver también:
eor()
QRegion & QRegion::operator^= ( const QRegion r)

Applies the eor() function to this region and r and assigns the result to this region. r1^=r2 is equivalent to r1=r1.eor(r2)

Ver también:
eor()
QRegion& QRegion::operator^= ( const QRegion )
const QRegion QRegion::operator| ( const QRegion ) const
const QRegion QRegion::operator| ( const QRegion r) const

Applies the unite() function to this region and r. r1|r2 is equivalent to r1.unite(r2)

Ver también:
unite(), operator+()
QRegion& QRegion::operator|= ( const QRegion )
QRegion & QRegion::operator|= ( const QRegion r)

Applies the unite() function to this region and r and assigns the result to this region. r1|=r2 is equivalent to r1=r1.unite(r2)

Ver también:
unite()
QMemArray<QRect> QRegion::rects ( ) const
QMemArray< QRect > QRegion::rects ( ) const

Returns an array of non-overlapping rectangles that make up the region.

The union of all the rectangles is equal to the original region.

void QRegion::setRects ( const QRect rects,
int  num 
)

Sets the region to be the given set of rectangles. The rectangles must be optimal Y-X sorted bands as follows:

  • The rectangles must not intersect
  • All rectangles with a given top coordinate must have the same height.
  • No two rectangles may abut horizontally (they should be combined into a single wider rectangle in that case).
  • The rectangles must be sorted ascendingly by Y as the major sort key and X as the minor sort key.
void QRegion::setRects ( const QRect ,
int   
)
QRegion QRegion::subtract ( const QRegion ) const
QRegion QRegion::subtract ( const QRegion r) const

Returns a region which is r subtracted from this region.

rsubtract.png Region Subtraction

The figure shows the result when the ellipse on the right is subtracted from the ellipse on the left. (left-right )

void QRegion::translate ( int  dx,
int  dy 
)
void QRegion::translate ( int  dx,
int  dy 
)

Translates (moves) the region dx along the X axis and dy along the Y axis.

QRegion QRegion::unite ( const QRegion ) const
QRegion QRegion::unite ( const QRegion r) const

Returns a region which is the union of this region and r.

runion.png Region Union

The figure shows the union of two elliptical regions.


Documentación de las funciones relacionadas y clases amigas

QDataStream & operator<< ( QDataStream s,
const QRegion r 
) [friend]

Writes the region r to the stream s and returns a reference to the stream.

Ver también:
Format of the QDataStream operators
Q_EXPORT QDataStream& operator<< ( QDataStream ,
const QRegion  
) [friend]
Q_EXPORT QDataStream& operator>> ( QDataStream ,
QRegion  
) [friend]
QDataStream & operator>> ( QDataStream s,
QRegion r 
) [friend]

Reads a region from the stream s into r and returns a reference to the stream.

Ver también:
Format of the QDataStream operators

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'