Q3DScene class provides description of the 3D scene being visualized. 更多...
头: | #include <Q3DScene> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
qmake: | QT += graphs |
实例化: | Scene3D |
继承: | QObject |
状态: | 技术预览 |
|
|
Q3DScene (QObject * parent = nullptr) | |
virtual | ~Q3DScene () override |
float | devicePixelRatio () const |
QPoint | graphPositionQuery () const |
QPoint | invalidSelectionPoint () const |
bool | isPointInPrimarySubView (const QPoint & point ) |
bool | isPointInSecondarySubView (const QPoint & point ) |
bool | isSecondarySubviewOnTop () const |
bool | isSlicingActive () const |
QRect | primarySubViewport () const |
QRect | secondarySubViewport () const |
const QPoint | selectionQueryPosition () const |
void | setDevicePixelRatio (float pixelRatio ) |
void | setGraphPositionQuery (const QPoint & point ) |
void | setPrimarySubViewport (const QRect & primarySubViewport ) |
void | setSecondarySubViewport (const QRect & secondarySubViewport ) |
void | setSecondarySubviewOnTop (bool isSecondaryOnTop ) |
void | setSelectionQueryPosition (const QPoint & point ) |
void | setSlicingActive (bool isSlicing ) |
QRect | viewport () const |
void | devicePixelRatioChanged (float pixelRatio ) |
void | graphPositionQueryChanged (const QPoint & position ) |
void | primarySubViewportChanged (const QRect & subViewport ) |
void | secondarySubViewportChanged (const QRect & subViewport ) |
void | secondarySubviewOnTopChanged (bool isSecondaryOnTop ) |
void | selectionQueryPositionChanged (const QPoint & position ) |
void | slicingActiveChanged (bool isSlicingActive ) |
void | viewportChanged (const QRect & viewport ) |
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 () 和 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.
注意: Not all graphs support the secondary 2D slicing view.
This property holds the device pixel ratio that is used when mapping input coordinates to pixel coordinates.
访问函数:
float | devicePixelRatio () const |
void | setDevicePixelRatio (float pixelRatio ) |
通知程序信号:
void | devicePixelRatioChanged (float pixelRatio ) |
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 QAbstract3DGraph::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.
注意: Bar graphs allow graph position queries only at the graph floor level.
访问函数:
QPoint | graphPositionQuery () const |
void | setGraphPositionQuery (const QPoint & point ) |
通知程序信号:
void | graphPositionQueryChanged (const QPoint & position ) |
另请参阅 QAbstract3DGraph::queriedGraphPosition .
This property holds the current subviewport rectangle inside the viewport where the primary view of the graphs is targeted.
若
isSlicingActive
() 是
false
, the primary sub viewport is equal to
viewport
()。若
isSlicingActive
() 是
true
and the primary sub viewport has not been explicitly set, it will be one fifth of
viewport
().
注意: Setting primarySubViewport larger than or outside of the viewport resizes the viewport accordingly.
访问函数:
QRect | primarySubViewport () const |
void | setPrimarySubViewport (const QRect & primarySubViewport ) |
通知程序信号:
void | primarySubViewportChanged (const QRect & subViewport ) |
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
QRect
。若
isSlicingActive
() 是
true
, it will be equal to
viewport
.
注意: If the secondary sub viewport is larger than or outside of the viewport, the viewport is resized accordingly.
访问函数:
QRect | secondarySubViewport () const |
void | setSecondarySubViewport (const QRect & secondarySubViewport ) |
通知程序信号:
void | secondarySubViewportChanged (const QRect & subViewport ) |
This property holds whether the 2D slicing view or the 3D view is drawn on top.
访问函数:
bool | isSecondarySubviewOnTop () const |
void | setSecondarySubviewOnTop (bool isSecondaryOnTop ) |
通知程序信号:
void | secondarySubviewOnTopChanged (bool isSecondaryOnTop ) |
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 ().
访问函数:
const QPoint | selectionQueryPosition () const |
void | setSelectionQueryPosition (const QPoint & point ) |
通知程序信号:
void | selectionQueryPositionChanged (const QPoint & position ) |
另请参阅 QAbstract3DGraph::selectedElement .
This property holds whether the 2D slicing view is currently active.
若
true
,
QAbstract3DGraph::selectionMode
must have either
QAbstract3DGraph::SelectionRow
or
QAbstract3DGraph::SelectionColumn
set to a valid selection.
注意: Not all graphs support the 2D slicing view.
访问函数:
bool | isSlicingActive () const |
void | setSlicingActive (bool isSlicing ) |
通知程序信号:
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.
访问函数:
QRect | viewport () const |
通知程序信号:
void | viewportChanged (const QRect & viewport ) |
[explicit]
Q3DScene::
Q3DScene
(
QObject
*
parent
= nullptr)
Constructs a basic scene with one light and one camera in it. An optional parent 参数可以给出,然后会被传递给 QObject 构造函数。
[override virtual noexcept]
Q3DScene::
~Q3DScene
()
Destroys the 3D scene and all the objects contained within it.
返回 QPoint signifying an invalid selection position.
注意: Getter function for property invalidSelectionPoint.
Returns whether the given
point
resides inside the primary subview or not. Returns
true
if the point is inside the primary subview.
注意:
If subviews are superimposed, and the given
point
resides inside both, result is
true
only when the primary subview is on top.
Returns whether the given
point
resides inside the secondary subview or not. Returns
true
if the point is inside the secondary subview.
注意:
If subviews are superimposed, and the given
point
resides inside both, result is
true
only when the secondary subview is on top.