Q3DScene Class

Q3DScene class provides description of the 3D scene being visualized. More...

Header: #include <Q3DScene>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
In QML: Scene3D
Inherits: QObject

Properties

Public Functions

Q3DScene(QObject *parent = nullptr)
virtual ~Q3DScene() override
qreal devicePixelRatio() const
QPoint graphPositionQuery() const
QPoint invalidSelectionPoint() const
bool isPointInPrimarySubView(QPoint point)
bool isPointInSecondarySubView(QPoint point)
bool isSecondarySubviewOnTop() const
bool isSlicingActive() const
QRect primarySubViewport() const
QRect secondarySubViewport() const
QPoint selectionQueryPosition() const
void setDevicePixelRatio(qreal pixelRatio)
void setGraphPositionQuery(QPoint point)
void setPrimarySubViewport(QRect primarySubViewport)
void setSecondarySubViewport(QRect secondarySubViewport)
void setSecondarySubviewOnTop(bool isSecondaryOnTop)
void setSelectionQueryPosition(QPoint point)
void setSlicingActive(bool isSlicing)
QRect viewport() const

Signals

void devicePixelRatioChanged(qreal pixelRatio)
void graphPositionQueryChanged(QPoint position)
void primarySubViewportChanged(QRect subViewport)
void secondarySubViewportChanged(QRect subViewport)
void secondarySubviewOnTopChanged(bool isSecondaryOnTop)
void selectionQueryPositionChanged(QPoint position)
void slicingActiveChanged(bool isSlicingActive)
void viewportChanged(QRect viewport)

Detailed Description

The 3D scene contains a single active camera and a single active light source. Visualized data is assumed to be at a fixed location.

The 3D scene also keeps track of the viewport in which graph rendering is done, the primary subviewport inside the viewport where the main 3D graphs view resides and the secondary subviewport where the 2D sliced view of the data resides. The subviewports are by default resized by the Q3DScene. To override the resize behavior you need to listen to both viewportChanged() and slicingActiveChanged() signals and recalculate the subviewports accordingly.

Also the scene has flag for tracking if the secondary 2D slicing view is currently active or not.

Note: Not all graphs support the secondary 2D slicing view.

Property Documentation

devicePixelRatio : qreal

This property holds the device pixel ratio that is used when mapping input coordinates to pixel coordinates.

Access functions:

qreal devicePixelRatio() const
void setDevicePixelRatio(qreal pixelRatio)

Notifier signal:

void devicePixelRatioChanged(qreal pixelRatio)

graphPositionQuery : QPoint

This property holds the coordinates for the user input that should be processed by the scene as a graph position query.

If this property is set to a value other than invalidSelectionPoint(), the graph tries to match a graph position to the specified coordinates within the primary viewport. After the rendering pass, this property is returned to its default state of invalidSelectionPoint(). The queried graph position can be read from the Q3DGraphsWidgetItem::queriedGraphPosition property after the next render pass.

There is no single correct 3D coordinate to match a particular screen position, so to be consistent, the queries are always done against the inner sides of an invisible box surrounding the graph.

Note: Bar graphs allow graph position queries only at the graph floor level.

Access functions:

QPoint graphPositionQuery() const
void setGraphPositionQuery(QPoint point)

Notifier signal:

void graphPositionQueryChanged(QPoint position)

See also Q3DGraphsWidgetItem::queriedGraphPosition.

primarySubViewport : QRect

This property holds the current subviewport rectangle inside the viewport where the primary view of the graphs is targeted.

If the primary sub viewport has not been explicitly set, it will be one fifth of viewport().

Note: Setting primarySubViewport larger than or outside of the viewport resizes the viewport accordingly.

Access functions:

QRect primarySubViewport() const
void setPrimarySubViewport(QRect primarySubViewport)

Notifier signal:

void primarySubViewportChanged(QRect subViewport)

secondarySubViewport : QRect

This property holds the secondary viewport rectangle inside the viewport.

The secondary viewport is used for drawing the 2D slice view in some graphs. If it has not been explicitly set, it will be equal to the size of the viewport.

Note: If the secondary sub viewport is larger than or outside of the viewport, the viewport is resized accordingly.

Access functions:

QRect secondarySubViewport() const
void setSecondarySubViewport(QRect secondarySubViewport)

Notifier signal:

void secondarySubViewportChanged(QRect subViewport)

secondarySubviewOnTop : bool

This property holds whether the 2D slicing view or the 3D view is drawn on top.

Access functions:

bool isSecondarySubviewOnTop() const
void setSecondarySubviewOnTop(bool isSecondaryOnTop)

Notifier signal:

void secondarySubviewOnTopChanged(bool isSecondaryOnTop)

selectionQueryPosition : QPoint

This property holds the coordinates for the user input that should be processed by the scene as a selection.

If this property is set to a value other than invalidSelectionPoint(), the graph tries to select a data item, axis label, or a custom item at the specified coordinates within the primary viewport. After the rendering pass, the property is returned to its default state of invalidSelectionPoint().

Access functions:

QPoint selectionQueryPosition() const
void setSelectionQueryPosition(QPoint point)

Notifier signal:

void selectionQueryPositionChanged(QPoint position)

See also Q3DGraphsWidgetItem::selectedElement.

slicingActive : bool

This property holds whether the 2D slicing view is currently active.

If true, Q3DGraphsWidgetItem::selectionMode must have either QtGraphs3D::SelectionFlag::Row or QtGraphs3D::SelectionFlag::Column set to a valid selection.

Note: Not all graphs support the 2D slicing view.

Access functions:

bool isSlicingActive() const
void setSlicingActive(bool isSlicing)

Notifier signal:

void slicingActiveChanged(bool isSlicingActive)

[read-only] viewport : const QRect

This property holds a read only property that contains the current viewport rectangle where all the 3D rendering is targeted.

Access functions:

QRect viewport() const

Notifier signal:

void viewportChanged(QRect viewport)

Member Function Documentation

[explicit] Q3DScene::Q3DScene(QObject *parent = nullptr)

Constructs a basic scene with one light and one camera in it. An optional parent parameter can be given and is then passed to QObject constructor.

[override virtual noexcept] Q3DScene::~Q3DScene()

Destroys the 3D scene and all the objects contained within it.

QPoint Q3DScene::invalidSelectionPoint() const

Returns a QPoint signifying an invalid selection position.

Note: Getter function for property invalidSelectionPoint.

bool Q3DScene::isPointInPrimarySubView(QPoint point)

Returns whether the given point resides inside the primary subview or not. Returns true if the point is inside the primary subview.

Note: If subviews are superimposed, and the given point resides inside both, result is true only when the primary subview is on top.

bool Q3DScene::isPointInSecondarySubView(QPoint point)

Returns whether the given point resides inside the secondary subview or not. Returns true if the point is inside the secondary subview.

Note: If subviews are superimposed, and the given point resides inside both, result is true only when the secondary subview is on top.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.