- Qt 6.12
- Qt Graphs
- QML Types
- QtGraphs
- Custom3DVolume
- Qt Graphs | Commercial or GPLv3

# Custom3DVolume QML Type

Adds a volume rendered object to a graph. More...

Import Statement: | `import QtGraphs`
In C++: | QCustom3DVolume
Inherits: | Custom3DItem

- List of all members, including inherited members
- Custom3DVolume is part of Qt Graphs QML Types for 3D.

## Properties

- alphaMultiplier : real
- drawSliceFrames : bool
- drawSlices : bool
- preserveOpacity : bool
- sliceFrameColor : color
- sliceFrameGaps : vector3d
- sliceFrameThicknesses : vector3d
- sliceFrameWidths : vector3d
- sliceIndexX : int
- sliceIndexY : int
- sliceIndexZ : int
- textureDepth : int
- textureHeight : int
- textureWidth : int
- useHighDefShader : bool

## Signals

- alphaMultiplierChanged(float mult)
- drawSliceFramesChanged(bool enabled)
- drawSlicesChanged(bool enabled)
- preserveOpacityChanged(bool enabled)
- sliceFrameColorChanged(color color)
- sliceFrameGapsChanged(vector3d values)
- sliceFrameThicknessesChanged(vector3d values)
- sliceFrameWidthsChanged(vector3d values)
- sliceIndexXChanged(int value)
- sliceIndexYChanged(int value)
- sliceIndexZChanged(int value)
- textureDepthChanged(int value)
- textureHeightChanged(int value)
- textureWidthChanged(int value)
- useHighDefShaderChanged(bool enabled)

## Detailed Description

A volume rendered object is a box with a 3D texture. Three slice planes are supported for the volume, one along each main axis of the volume.

Rendering volume objects is very performance intensive, especially when the volume is largely transparent, as the contents of the volume are ray-traced. The performance scales nearly linearly with the amount of pixels that the volume occupies on the screen, so showing the volume in a smaller view or limiting the zoom level of the graph are easy ways to improve performance. Similarly, the volume texture dimensions have a large impact on performance. If the frame rate is more important than pixel-perfect rendering of the volume contents, consider turning the high definition shader off by setting the useHighDefShader property to `false`.

Note: Filling in the volume data would not typically be efficient or practical from pure QML, so properties directly related to that are not fully supported from QML. Create a hybrid QML/C++ application if you want to use volume objects with a Qt Quick UI.

Note: Volumetric objects utilize 3D textures, which are not supported in OpenGL ES2 environments.

See also useHighDefShader.

## Property Documentation

### alphaMultiplier : real

The alpha value of every texel of the volume texture is multiplied with this value at the render time. This can be used to introduce uniform transparency to the volume. If preserveOpacity is `true`, only texels with at least some transparency to begin with are affected, and fully opaque texels are not affected. The value must not be negative. Defaults to `1.0`.

See also preserveOpacity.

### drawSliceFrames : bool

If this property value is `true`, the frames of slices indicated by slice index properties will be drawn around the volume. If it is `false`, no slice frames will be drawn. Drawing slice frames is independent of drawing slices, so you can show the full volume and still draw the slice frames around it. Defaults to `false`.

See also sliceIndexX, sliceIndexY, sliceIndexZ, and drawSlices.

### drawSlices : bool

If this property value is `true`, the slices indicated by slice index properties will be drawn instead of the full volume. If it is `false`, the full volume will always be drawn. Defaults to `false`.

Note: The slices are always drawn along the item axes, so if the item is rotated, the slices are rotated as well.

See also sliceIndexX, sliceIndexY, and sliceIndexZ.

### preserveOpacity : bool

If this property value is `true`, alphaMultiplier is only applied to texels that already have some transparency. If it is `false`, the multiplier is applied to the alpha value of all texels. Defaults to `true`.

See also alphaMultiplier.

### sliceFrameColor : color

The color of the slice frame. Transparent slice frame color is not supported.

Defaults to black.

See also drawSliceFrames.

### sliceFrameGaps : vector3d

The size of the air gap left between the volume itself and the frame in each dimension. The gap can be different on different dimensions. The values are fractions of the volume thickness in the same dimension. The values cannot be negative.

Defaults to `vector3d(0.01, 0.01, 0.01)`.

See also drawSliceFrames.

### sliceFrameThicknesses : vector3d

The thickness of the slice frames for each dimension. The values are fractions of the volume thickness in the same dimension. The values cannot be negative.

Defaults to `vector3d(0.01, 0.01, 0.01)`.

See also drawSliceFrames.

### sliceFrameWidths : vector3d

The widths of the slice frame. The width can be different on different dimensions, so you can for example omit drawing the frames on certain sides of the volume by setting the value for that dimension to zero. The values are fractions of the volume thickness in the same dimension. The values cannot be negative.

Defaults to `vector3d(0.01, 0.01, 0.01)`.

See also drawSliceFrames.

### sliceIndexX : int

The x-dimension index into the texture data indicating which vertical slice to show. Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn. If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn normally. Defaults to `-1`.

See also QCustom3DVolume::textureData, drawSlices, and drawSliceFrames.

### sliceIndexY : int

The y-dimension index into the texture data indicating which horizontal slice to show. Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn. If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn normally. Defaults to `-1`.

See also QCustom3DVolume::textureData, drawSlices, and drawSliceFrames.

### sliceIndexZ : int

The z-dimension index into the texture data indicating which vertical slice to show. Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn. If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn normally. Defaults to `-1`.

See also QCustom3DVolume::textureData, drawSlices, and drawSliceFrames.

### textureDepth : int

The depth of the 3D texture defining the volume content in pixels. Defaults to `0`.

Note: Changing this property from QML is not supported, as the texture data cannot be resized accordingly.

### textureHeight : int

The height of the 3D texture defining the volume content in pixels. Defaults to `0`.

Note: Changing this property from QML is not supported, as the texture data cannot be resized accordingly.

### textureWidth : int

The width of the 3D texture defining the volume content in pixels. Defaults to `0`.

Note: Changing this property from QML is not supported, as the texture data cannot be resized accordingly.

### useHighDefShader : bool

If this property value is `true`, a high definition shader is used to render the volume. If it is `false`, a low definition shader is used.

The high definition shader guarantees that every visible texel of the volume texture is sampled when the volume is rendered. The low definition shader renders only a rough approximation of the volume contents, but at a much higher frame rate. The low definition shader does not guarantee every texel of the volume texture is sampled, so there may be flickering if the volume contains distinct thin features.

Note: This value does not affect the level of detail when rendering the slices of the volume.

Defaults to `true`.

## Signal Documentation

### alphaMultiplierChanged(float mult)

This signal is emitted when alphaMultiplier changes to mult.

Note: The corresponding handler is `onAlphaMultiplierChanged`.

### drawSliceFramesChanged(bool enabled)

This signal is emitted when drawSliceFrames changes to enabled.

Note: The corresponding handler is `onDrawSliceFramesChanged`.

### drawSlicesChanged(bool enabled)

This signal is emitted when drawSlices changes to enabled.

Note: The corresponding handler is `onDrawSlicesChanged`.

### preserveOpacityChanged(bool enabled)

This signal is emitted when preserveOpacity changes to enabled.

Note: The corresponding handler is `onPreserveOpacityChanged`.

### sliceFrameColorChanged(color color)

This signal is emitted when sliceFrameColor changes to color.

Note: The corresponding handler is `onSliceFrameColorChanged`.

### sliceFrameGapsChanged(vector3d values)

This signal is emitted when sliceFrameGaps changes to values.

Note: The corresponding handler is `onSliceFrameGapsChanged`.

### sliceFrameThicknessesChanged(vector3d values)

This signal is emitted when sliceFrameThicknesses changes to values.

Note: The corresponding handler is `onSliceFrameThicknessesChanged`.

### sliceFrameWidthsChanged(vector3d values)

This signal is emitted when sliceFrameWidths changes to values.

Note: The corresponding handler is `onSliceFrameWidthsChanged`.

### sliceIndexXChanged(int value)

This signal is emitted when sliceIndexX changes to value.

Note: The corresponding handler is `onSliceIndexXChanged`.

### sliceIndexYChanged(int value)

This signal is emitted when sliceIndexY changes to value.

Note: The corresponding handler is `onSliceIndexYChanged`.

### sliceIndexZChanged(int value)

This signal is emitted when sliceIndexZ changes to value.

Note: The corresponding handler is `onSliceIndexZChanged`.

### textureDepthChanged(int value)

This signal is emitted when textureDepth changes to value.

Note: The corresponding handler is `onTextureDepthChanged`.

### textureHeightChanged(int value)

This signal is emitted when textureHeight changes to value.

Note: The corresponding handler is `onTextureHeightChanged`.

### textureWidthChanged(int value)

This signal is emitted when textureWidth changes to value.

Note: The corresponding handler is `onTextureWidthChanged`.

### useHighDefShaderChanged(bool enabled)

This signal is emitted when useHighDefShader changes to enabled.

Note: The corresponding handler is `onUseHighDefShaderChanged`.