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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QLogicalVertex Class

The QLogicalVertex class references QGeometryData at a single vertex. More...

 #include <QLogicalVertex>

This class was introduced in Qt 4.8.

Public Functions

QLogicalVertex()
QLogicalVertex(QGeometryData data, int index)
QLogicalVertex(const QVector3D & a)
QLogicalVertex(const QVector3D & a, const QVector3D & n)
QLogicalVertex(const QVector3D & a, const QVector3D & n, const QVector2D & t)
QLogicalVertex(const QVector3D & a, QColor4ub color)
~QLogicalVertex()
QVariant attribute(QGL::VertexAttribute field = QGL::CustomVertex0) const
QCustomDataArray::ElementType attributeType(QGL::VertexAttribute field = QGL::CustomVertex0)
const QColor4ub & color() const
QColor4ub & colorRef()
QGeometryData data() const
quint32 fields() const
float & floatAttribute(QGL::VertexAttribute field = QGL::CustomVertex0)
float floatAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const
bool hasField(QGL::VertexAttribute type) const
int index() const
bool isNull() const
const QVector3D & normal() const
QVector3D & normal()
void setAttribute(float value, QGL::VertexAttribute field)
void setAttribute(const QVector2D & v, QGL::VertexAttribute field = QGL::CustomVertex0)
void setAttribute(const QVector3D & v, QGL::VertexAttribute field = QGL::CustomVertex0)
void setColor(const QColor4ub & c)
void setNormal(const QVector3D & n)
void setTexCoord(const QVector2D & t, QGL::VertexAttribute field = QGL::TextureCoord0)
void setVertex(const QVector3D & v)
const QVector2D & texCoord(QGL::VertexAttribute field = QGL::TextureCoord0) const
QVector2D & texCoordRef(QGL::VertexAttribute field = QGL::TextureCoord0)
QVector2D & vector2DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0)
QVector2D vector2DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const
QVector3D & vector3DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0)
QVector3D vector3DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const
const QVector3D & vertex() const
QVector3D & vertex()
operator QVector3D()
bool operator==(const QLogicalVertex & rhs) const

Detailed Description

The QLogicalVertex class references QGeometryData at a single vertex.

QLogicalVertex instances are a convenience class for use with QGeometryData. A QLogicalVertex simply references through to the data in a QGeometryData for a particular vertex, providing accessors to fetch position, texture coordinates, and other values.

Create a QLogicalVertex referring to a particular QGeometryData instance:

 QGeometryData data;
 data.appendVertex(QVector3D(1, 2, 3));

 // construct a QLogicalVertex referring to the first vertex in data
 // the QGeometryData is implicitly shared with lv
 QLogicalVertex lv(data, 0);
 //  lv.vertex() == QVector3D(1, 2, 3)

This is inexpensive and no new storage is allocated for the actual data, just the reference and index.

With logical vertices instances referencing large QGeometryData instances, avoid modifying the instance:

 // careful - assigning to a QLogicalVertex which refers to an external
 // QGeometryData will result in a possibly expensive copy-on-write
 lv.setVertex(3, 2, 1);

Create a QLogicalVertex with its own QGeometryData internally:

 QLogicalVertex lv;
 // no copy on write here - internal QGeometryData is not shared
 lv.setVertex(1, 2, 3);

Assign an instance of QLogicalVertex:

 QLogicalVertex lv2;
 lv2 = data.logicalVertexAt(0);

Although lv2 gets its own internal QGeometryData which is then immediately thrown away by the assignment, because of lazy initialization in QGeometryData the cost is negligible.

Use the fields() and hasField() functions to determine if a particular field is present in the vertex. Accessing non-existent data will cause an assert in debug mode (from the underlying QArray), and give undefined behaviour in release mode.

See also QGeometryData and QGLBuilder.

Member Function Documentation

QLogicalVertex::QLogicalVertex()

Constructs a new invalid QLogicalVertex which has no data.

QLogicalVertex::QLogicalVertex(QGeometryData data, int index)

Constructs a new QLogicalVertex referencing the data at index. Note that if this QLogicalVertex is modified, by calling vertex() or setNormal() for example, then a copy-on-write for data will be triggered.

QLogicalVertex::QLogicalVertex(const QVector3D & a)

Constructs a new QLogicalVertex with a vertex set to a.

QLogicalVertex::QLogicalVertex(const QVector3D & a, const QVector3D & n)

Constructs a new QLogicalVertex with a vertex set to a, and normal set to n.

QLogicalVertex::QLogicalVertex(const QVector3D & a, const QVector3D & n, const QVector2D & t)

Constructs a new QLogicalVertex with its vertex value set to a, normal set to n, and texture set to t. By default n is the null QVector3D, and t is the InvalidTexCoord. If n is null then hasType(QLogicalVertex::Normal) will return false. Likewise if t is the InvalidTexCoord then hasType(QLogicalVertex::Texture) will return false.

QLogicalVertex::QLogicalVertex(const QVector3D & a, QColor4ub color)

Constructs a new QLogicalVertex with its vertex value set to a, color value set to color.

QLogicalVertex::~QLogicalVertex()

Destroys this QLogicalVertex reclaiming any resources.

QVariant QLogicalVertex::attribute(QGL::VertexAttribute field = QGL::CustomVertex0) const

Returns the attribute value for field. The field defaults to QGL::CustomVertex0.

See also setAttribute().

QCustomDataArray::ElementType QLogicalVertex::attributeType(QGL::VertexAttribute field = QGL::CustomVertex0)

Returns the element type for the attribute field.

const QColor4ub & QLogicalVertex::color() const

Returns a const reference to the color value for this vertex.

See also setColor().

QColor4ub & QLogicalVertex::colorRef()

Returns a modifiable reference to the color value for this vertex.

QGeometryData QLogicalVertex::data() const

Returns a copy of the QGeometryData underlying this vertex. Note that the copy is not expensive in terms of performance due to implicit sharing unless the copy is modified (causing a copy-on-write).

See also QLogicalVertex::index().

quint32 QLogicalVertex::fields() const

Returns a bit-mask of the fields in this logical vertex. Test the fields like this:

 if (vertex.fields() & QGL::fieldMask(QGL::TextureCoord0))
     tex = vertex.texCoord();

See also QGeometryData::fields().

float & QLogicalVertex::floatAttribute(QGL::VertexAttribute field = QGL::CustomVertex0)

Returns a modifiable reference to the attribute at field, which must be a float. The field defaults to QGL::CustomVertex0.

float QLogicalVertex::floatAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const

Returns the attribute at field. The field defaults to QGL::CustomVertex0. The attribute must be a float value.

bool QLogicalVertex::hasField(QGL::VertexAttribute type) const

Returns true if this vertex has data field type, and false otherwise.

In general check to see if a logical vertex has a particular field type before attempting to access it. In debug mode accessing a non-existent field will cause an assert; but in release mode the behaviour is undefined.

int QLogicalVertex::index() const

Returns the index at which this logical vertex's data is located in its associated QGeometryData; or -1 if this vertex is null.

bool QLogicalVertex::isNull() const

Returns true if this vertex is null.

See also QLogicalVertex().

const QVector3D & QLogicalVertex::normal() const

Returns a const reference to the normal value for this vertex.

See also setNormal().

QVector3D & QLogicalVertex::normal()

Returns a modifiable reference to the normal value for this vertex.

void QLogicalVertex::setAttribute(float value, QGL::VertexAttribute field)

Sets the float attribute value at field. The field defaults to QGL::CustomVertex0.

See also attribute().

void QLogicalVertex::setAttribute(const QVector2D & v, QGL::VertexAttribute field = QGL::CustomVertex0)

Sets the QVector2D attribute v at field. The field defaults to QGL::CustomVertex0.

void QLogicalVertex::setAttribute(const QVector3D & v, QGL::VertexAttribute field = QGL::CustomVertex0)

Sets the QVector3D attribute v at field. The field defaults to QGL::CustomVertex0.

void QLogicalVertex::setColor(const QColor4ub & c)

Sets the color value for this vertex to c.

See also color().

void QLogicalVertex::setNormal(const QVector3D & n)

Sets the normal value for this vertex to n.

See also normal().

void QLogicalVertex::setTexCoord(const QVector2D & t, QGL::VertexAttribute field = QGL::TextureCoord0)

Sets the texture coordinate at field for this vertex to t. The field defaults to QGL::TextureCoord0.

See also texCoord().

void QLogicalVertex::setVertex(const QVector3D & v)

Sets the vertex value for this vertex to v.

See also vertex().

const QVector2D & QLogicalVertex::texCoord(QGL::VertexAttribute field = QGL::TextureCoord0) const

Returns a copy of the texture coordinate value at field for this vertex. The field defaults to QGL::TextureCoord0.

See also setTexCoord().

QVector2D & QLogicalVertex::texCoordRef(QGL::VertexAttribute field = QGL::TextureCoord0)

Returns a modifiable reference to the texture coordinate for this vertex. The field defaults to QGL::TextureCoord0.

QVector2D & QLogicalVertex::vector2DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0)

Returns a modifiable reference to the attribute at field, which must be a QVector2D. The field defaults to QGL::CustomVertex0.

QVector2D QLogicalVertex::vector2DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const

Returns the attribute at field. The field defaults to QGL::CustomVertex0. The attribute must be a QVector2D value.

QVector3D & QLogicalVertex::vector3DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0)

Returns a modifiable reference to the attribute at field, which must be a QVector3D. The field defaults to QGL::CustomVertex0.

QVector3D QLogicalVertex::vector3DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const

Returns the attribute at field. The field defaults to QGL::CustomVertex0. The attribute must be a QVector3D value.

const QVector3D & QLogicalVertex::vertex() const

Returns a const reference to the vertex value for this vertex.

See also setVertex().

QVector3D & QLogicalVertex::vertex()

Returns a modifiable reference to the vertex value.

QLogicalVertex::operator QVector3D()

Returns a copy of the vertex value, by casting as a QVector3D. This allows passing of a QLogicalVertex to functions that expect a QVector3D.

bool QLogicalVertex::operator==(const QLogicalVertex & rhs) const

Returns true if rhs has exactly the same fields as this logical vertex, and each of those are equal to the corresponding field of the rhs.

If either are null, then false is returned.

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 5.0-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