QCustomDataArray ClassThe QCustomDataArray class is a polymorphic array of data values suitable for use in 3D applications. More... #include <QCustomDataArray> This class was introduced in Qt 4.8. Public Types
Public Functions
Detailed DescriptionThe QCustomDataArray class is a polymorphic array of data values suitable for use in 3D applications. QArray is an efficient storage mechanism for vertex attributes. However, there are some situations where the element type of a custom vertex attribute is not known until runtime. QCustomDataArray is intended for use in those situations. It has a small performance penalty compared to QArray to achieve polymorphism. The elements that may be stored in a QCustomDataArray are limited to a few types: float, QVector2D, QVector3D, QVector4D, and QColor4ub. This provides a reasonable range of efficient use cases without overloading the API. QArray can be used on any type, but is restricted to types that are known at compile time. Like QArray, QCustomDataArray uses implicit sharing and copy-on-write semantics to support passing large arrays around an application with little overhead. See also QArray. Member Type Documentation
|
Constant | Value | Description |
---|---|---|
QCustomDataArray::Float | 0 | The elements are of type float. |
QCustomDataArray::Vector2D | 1 | The elements are of type QVector2D. |
QCustomDataArray::Vector3D | 2 | The elements are of type QVector3D. |
QCustomDataArray::Vector4D | 3 | The elements are of type QVector4D. |
QCustomDataArray::Color | 4 | The elements are of type QColor4ub, which consists of four unsigned bytes. To represent colors as four floating-point values, use Vector4D as the element type. |
Constructs an empty custom data array. The elementType() will initially be QCustomDataArray::Float, which can be changed with a call to setElementType() before the elements are appended.
See also setElementType() and append().
Constructs an empty custom data array with elements represented by the specified type.
See also setElementType().
Constructs an empty custom data array with elements represented by the specified type. The array is initially resized to size; filling all elements with zeroes.
See also setElementType() and resize().
Constructs a copy of other.
Constructs a copy of the floating-point QArray other.
The elementType() will be set to QCustomDataArray::Float.
See also toFloatArray().
Constructs a copy of the 2D vector QArray other.
The elementType() will be set to QCustomDataArray::Vector2D.
This constructor needs to make a complete copy of the data in other so it may be expensive performance-wise.
See also toVector2DArray().
Constructs a copy of the 3D vector QArray other.
The elementType() will be set to QCustomDataArray::Vector3D.
This constructor needs to make a complete copy of the data in other so it may be expensive performance-wise.
See also toVector3DArray().
Constructs a copy of the 4D vector QArray other.
The elementType() will be set to QCustomDataArray::Vector4D.
This constructor needs to make a complete copy of the data in other so it may be expensive performance-wise.
See also toVector3DArray().
Constructs a copy of the color QArray other.
The elementType() will be set to QCustomDataArray::Color.
This constructor needs to make a complete copy of the data in other so it may be expensive performance-wise.
See also toColorArray().
Destroys this custom data array.
Appends value to this custom data array.
The type of value must be consistent with elementType(). The two exceptions to this are that a Float value can be specified by either a float or double QVariant, and a Color value can be specified as either a QColor4ub or QColor QVariant.
See also at(), setAt(), and elementType().
This is an overloaded function.
Appends the floating-point value x to this custom data array. The elementType() must be QCustomDataArray::Float.
See also setAt() and floatAt().
This is an overloaded function.
Appends the 2D vector value (x, y) to this custom data array. The elementType() must be QCustomDataArray::Vector2D.
See also setAt() and vector2DAt().
This is an overloaded function.
Appends the 3D vector value (x, y, z) to this custom data array. The elementType() must be QCustomDataArray::Vector3D.
See also setAt() and vector3DAt().
This is an overloaded function.
Appends the 4D vector value (x, y, z, w) to this custom data array. The elementType() must be QCustomDataArray::Vector4D.
See also setAt() and vector4DAt().
This is an overloaded function.
Appends the 2D vector value to this custom data array. The elementType() must be QCustomDataArray::Vector2D.
See also setAt() and vector2DAt().
This is an overloaded function.
Appends the 3D vector value to this custom data array. The elementType() must be QCustomDataArray::Vector3D.
See also setAt() and vector3DAt().
This is an overloaded function.
Appends the 4D vector value to this custom data array. The elementType() must be QCustomDataArray::Vector4D.
See also setAt() and vector4DAt().
This is an overloaded function.
Appends the color value to this custom data array. The elementType() must be QCustomDataArray::Color.
See also setAt() and colorAt().
This is an overloaded function.
Appends the color value to this custom data array. The elementType() must be QCustomDataArray::Color.
See also setAt() and colorAt().
This is an overloaded function.
Appends the values in array to this custom data array. This custom data array must have the same element type as array, unless this custom data array is empty - in which case the element type and data of array will be assigned to this.
Returns the value of the element at index in this custom data array as a QVariant.
Color elements are returned as a QVariant containing a QColor4ub, not a QColor.
See also setAt(), append(), floatAt(), vector2DAt(), vector3DAt(), vector4DAt(), and colorAt().
Returns the number of elements that can be stored in this custom data array before reallocation.
See also reserve() and size().
Clears all elements from this custom data array and sets the size to zero.
This function will deallocate any memory that is used on the heap to store the custom data array's elements. To reuse the same memory as before, call resize() with an argument of zero.
See also resize() and isEmpty().
Returns the color element at index in this custom data array. The elementType() must be QCustomDataArray::Color.
See also at(), setAt(), and elementType().
Same as size(); provided for convenience.
Returns a const pointer to the data stored in the custom data array. The pointer can be used to access the items in the custom data array. The pointer remains valid as long as the custom data array isn't reallocated.
This function is mostly useful to pass a custom data array to a function that accepts a plain C++ array.
Returns the size of individual elements in this custom data array, in bytes. For example, the element size of an array containing QVector3D values will be 3 * sizeof(float), normally 12.
See also setElementType().
Returns the representation type of elements in this custom data array.
See also setElementType().
Returns the floating-point element at index in this custom data array. The elementType() must be QCustomDataArray::Float.
See also at(), setAt(), and elementType().
Returns true if this data array is empty; false otherwise.
Increases the capacity of this custom data array to reserve space for at least size elements. If the capacity is already larger than size, this function does nothing; in particular, it does not remove elements from the array like resize() does.
This function can be useful when you know how roughly many elements will be appended ahead of time. Reserving the space once can avoid unnecessary realloc operations later.
See also capacity(), resize(), and squeeze().
Sets the size of the custom data array to size. If size is greater than the current size, elements are added to the end; the new elements are initialized with all-zeroes. If size is less than the current size, elements are removed from the end.
See also size(), reserve(), and squeeze().
Sets the element at index in this custom data array to value.
The type of value must be consistent with elementType(). The two exceptions to this are that a Float value can be specified by either a float or double QVariant, and a Color value can be specified as either a QColor4ub or QColor QVariant.
See also at() and elementType().
This is an overloaded function.
Sets the floating-point element at index in this custom data array to x. The elementType() must be QCustomDataArray::Float.
See also at(), elementType(), and floatAt().
This is an overloaded function.
Sets the 2D vector element at index in this custom data array to (x, y). The elementType() must be QCustomDataArray::Vector2D.
See also at(), elementType(), and vector2DAt().
This is an overloaded function.
Sets the 3D vector element at index in this custom data array to (x, y, z). The elementType() must be QCustomDataArray::Vector3D.
See also at(), elementType(), and vector3DAt().
This is an overloaded function.
Sets the 4D vector element at index in this custom data array to (x, y, z, w). The elementType() must be QCustomDataArray::Vector4D.
See also at(), elementType(), and vector4DAt().
This is an overloaded function.
Sets the 2D vector element at index in this custom data array to value. The elementType() must be QCustomDataArray::Vector2D.
See also at(), elementType(), and vector2DAt().
This is an overloaded function.
Sets the 3D vector element at index in this custom data array to value. The elementType() must be QCustomDataArray::Vector3D.
See also at(), elementType(), and vector3DAt().
This is an overloaded function.
Sets the 4D vector element at index in this custom data array to value. The elementType() must be QCustomDataArray::Vector4D.
See also at(), elementType(), and vector4DAt().
This is an overloaded function.
Sets the color element at index in this custom data array to value. The elementType() must be QCustomDataArray::Color.
See also at(), elementType(), and colorAt().
This is an overloaded function.
Sets the color element at index in this custom data array to value. The elementType() must be QCustomDataArray::Color.
See also at(), elementType(), and colorAt().
Sets the representation type of elements in this custom data array. The array must be empty to change the element type.
See also elementType() and append().
Returns the number of elements in this custom data array.
See also resize(), capacity(), and isEmpty().
Releases any memory not required to store the custom data array's elements by reducing its capacity() to size().
This function is intended for reclaiming memory in a custom data array that is being used over and over with different contents. As elements are added to a custom data array, it will be constantly expanded in size. This function can realloc the custom data array to a smaller size to reclaim unused memory.
See also reserve() and capacity().
Returns the contents of this custom data array as a QArray of QColor4ub values.
The elementType() must be QCustomDataArray::Color.
This function needs to make a complete copy of the data in this array so it may be expensive performance-wise.
Returns the contents of this custom data array as a QArray of float values.
The elementType() must be QCustomDataArray::Float.
Returns the contents of this custom data array as a QArray of QVector2D values.
The elementType() must be QCustomDataArray::Vector2D.
This function needs to make a complete copy of the data in this array so it may be expensive performance-wise.
Returns the contents of this custom data array as a QArray of QVector3D values.
The elementType() must be QCustomDataArray::Vector3D.
This function needs to make a complete copy of the data in this array so it may be expensive performance-wise.
Returns the contents of this custom data array as a QArray of QVector4D values.
The elementType() must be QCustomDataArray::Vector4D.
This function needs to make a complete copy of the data in this array so it may be expensive performance-wise.
Returns the 2D vector element at index in this custom data array. The elementType() must be QCustomDataArray::Vector2D.
See also at(), setAt(), and elementType().
Returns the 3D vector element at index in this custom data array. The elementType() must be QCustomDataArray::Vector3D.
See also at(), setAt(), and elementType().
Returns the 4D vector element at index in this custom data array. The elementType() must be QCustomDataArray::Vector4D.
See also at(), setAt(), and elementType().
Assigns other to this custom data array and returns a reference to this custom data array.
The previous elementType() for this custom data array will be replaced with the type from other. The element data is assigned directly without conversion.