Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquick3dorthographiccamera.cpp
Go to the documentation of this file.
1
// Copyright (C) 2019 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
6
#
include
"qquick3dorthographiccamera_p.h"
7
8
#
include
<
QtQuick3DRuntimeRender
/
private
/
qssgrendercamera_p
.
h
>
9
10
#
include
<
QtMath
>
11
#
include
<
QtQuick3DUtils
/
private
/
qssgutils_p
.
h
>
12
13
#
include
"qquick3dutils_p.h"
14
15
#
include
"qquick3dnode_p_p.h"
16
17
QT_BEGIN_NAMESPACE
18
19
/*!
20
\qmltype OrthographicCamera
21
\inherits Camera
22
\inqmlmodule QtQuick3D
23
\brief Defines an Camera with an orthographic projection matrix.
24
25
A \l Camera defines how the content of the 3D scene is projected onto a 2D surface,
26
such as a View3D. A scene needs at least one \l Camera in order to visualize its
27
contents.
28
29
It is possible to position and rotate the \l Camera like any other spatial \l{QtQuick3D::Node}{Node} in
30
the scene. The \l{QtQuick3D::Node}{Node}'s location and orientation determines where the \l Camera is in
31
the scene, and what direction it is facing. The default orientation of the \l Camera
32
has its forward vector pointing along the negative Z axis and its up vector along
33
the positive Y axis.
34
35
\image orthographiccamera.png {Orthographic camera projection diagram}
36
37
The OrthographicCamera is a parallel projection \l Camera, in which parallel lines remain
38
parallel and an object's perceived scale is unaffected by its distance from the \l Camera.
39
Typical use cases for this type of \l Camera are CAD (Computer-Assisted Design) applications
40
and cartography.
41
42
The following example creates a OrthographicCamera at position [0, 200, 300] in the scene, and
43
with a 30 degree downward pitch.
44
\code
45
OrthographicCamera {
46
position: Qt.vector3d(0, 200, 300)
47
eulerRotation.x: -30
48
}
49
\endcode
50
51
\sa {Qt Quick 3D - View3D Example}, PerspectiveCamera, FrustumCamera, CustomCamera
52
*/
53
54
/*!
55
* \internal
56
*/
57
QQuick3DOrthographicCamera::QQuick3DOrthographicCamera(QQuick3DNode *parent)
58
: QQuick3DCamera(*(
new
QQuick3DNodePrivate(QQuick3DNodePrivate::Type::OrthographicCamera)), parent) {}
59
60
/*!
61
\qmlproperty real OrthographicCamera::clipNear
62
63
This property defines the near clip plane of the OrthographicCamera's frustum. Geometry which
64
is closer to the \l Camera than the near clip plane will not be visible.
65
66
The default value is 10.0.
67
68
\sa clipFar
69
*/
70
float
QQuick3DOrthographicCamera::clipNear()
const
71
{
72
return
m_clipNear;
73
}
74
75
/*!
76
\qmlproperty real OrthographicCamera::clipFar
77
78
This property defines the far clip plane of the OrthographicCamera's frustum. Geometry which
79
is further away from the \l Camera than the far clip plane will not be visible.
80
81
The default value is 10000.0.
82
83
\sa clipNear
84
*/
85
float
QQuick3DOrthographicCamera::clipFar()
const
86
{
87
return
m_clipFar;
88
}
89
90
/*!
91
\qmlproperty real OrthographicCamera::horizontalMagnification
92
93
This property holds the horizontal magnification of the OrthographicCamera's frustum.
94
95
The default value is 1.0.
96
97
\sa verticalMagnification
98
*/
99
float
QQuick3DOrthographicCamera::horizontalMagnification()
const
100
{
101
return
m_horizontalMagnification;
102
}
103
104
/*!
105
\qmlproperty real OrthographicCamera::verticalMagnification
106
107
This property holds the vertical magnification of the OrthographicCamera's frustum.
108
109
The default value is 1.0.
110
111
\sa horizontalMagnification
112
*/
113
float
QQuick3DOrthographicCamera::verticalMagnification()
const
114
{
115
return
m_verticalMagnification;
116
}
117
118
void
QQuick3DOrthographicCamera::setClipNear(
float
clipNear)
119
{
120
if
(qFuzzyCompare(m_clipNear, clipNear))
121
return
;
122
123
m_clipNear = clipNear;
124
emit clipNearChanged();
125
update();
126
}
127
128
void
QQuick3DOrthographicCamera::setClipFar(
float
clipFar)
129
{
130
if
(qFuzzyCompare(m_clipFar, clipFar))
131
return
;
132
133
m_clipFar = clipFar;
134
emit clipFarChanged();
135
update();
136
}
137
138
void
QQuick3DOrthographicCamera::setHorizontalMagnification(
float
horizontalMagnification)
139
{
140
if
(horizontalMagnification <= 0.0) {
141
qWarning(
"OrthographicCamera: magnification must be greater than zero."
);
142
return
;
143
}
144
145
if
(qFuzzyCompare(m_horizontalMagnification, horizontalMagnification))
146
return
;
147
148
m_horizontalMagnification = horizontalMagnification;
149
emit horizontalMagnificationChanged();
150
update();
151
}
152
153
void
QQuick3DOrthographicCamera::setVerticalMagnification(
float
verticalMagnification)
154
{
155
if
(verticalMagnification <= 0.0) {
156
qWarning(
"OrthographicCamera: magnification must be greater than zero."
);
157
return
;
158
}
159
160
if
(qFuzzyCompare(m_verticalMagnification, verticalMagnification))
161
return
;
162
163
m_verticalMagnification = verticalMagnification;
164
emit verticalMagnificationChanged();
165
update();
166
}
167
168
QSSGRenderGraphObject *QQuick3DOrthographicCamera::updateSpatialNode(QSSGRenderGraphObject *node)
169
{
170
QSSGRenderCamera *camera =
static_cast
<QSSGRenderCamera *>(QQuick3DCamera::updateSpatialNode(node));
171
if
(camera) {
172
const
bool
changed = ((
int
(qUpdateIfNeeded(camera->clipPlanes, { m_clipNear, m_clipFar }))
173
|
int
(qUpdateIfNeeded(camera->magnification, { m_horizontalMagnification, m_verticalMagnification }))) != 0);
174
if
(changed)
175
camera->markDirty(QSSGRenderCamera::DirtyFlag::CameraDirty);
176
}
177
178
return
camera;
179
}
180
181
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtquick3d
src
quick3d
qquick3dorthographiccamera.cpp
Generated on
for Qt by
1.18.0