QGIS API Documentation 3.43.0-Master (0bee5d6404c)
qgscamerapose.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscamerapose.h
3 --------------------------------------
4 Date : July 2018
5 Copyright : (C) 2018 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCAMERAPOSE_H
17#define QGSCAMERAPOSE_H
18
19#include "qgis_3d.h"
20
21#include "qgsvector3d.h"
22
23#ifndef SIP_RUN
24namespace Qt3DRender
25{
26 class QCamera;
27}
28#endif
29
30class QDomDocument;
31class QDomElement;
32
46class _3D_EXPORT QgsCameraPose
47{
48 public:
50 QgsVector3D centerPoint() const { return mCenterPoint; }
52 void setCenterPoint( const QgsVector3D &point );
53
55 float distanceFromCenterPoint() const { return mDistanceFromCenterPoint; }
57 void setDistanceFromCenterPoint( float distance );
58
60 float pitchAngle() const { return mPitchAngle; }
62 void setPitchAngle( float pitch );
63
65 float headingAngle() const { return mHeadingAngle; }
67 void setHeadingAngle( float heading ) { mHeadingAngle = heading; }
68
70 void updateCamera( Qt3DRender::QCamera *camera ) SIP_SKIP;
71
76 void updateCameraGlobe( Qt3DRender::QCamera *camera, double lat, double lon ) SIP_SKIP;
77
79 QDomElement writeXml( QDomDocument &doc ) const;
81 void readXml( const QDomElement &elem );
82
83 // TODO c++20 - replace with = default
84 bool operator==( const QgsCameraPose &other ) const
85 {
86 return mCenterPoint == other.mCenterPoint && mDistanceFromCenterPoint == other.mDistanceFromCenterPoint && mPitchAngle == other.mPitchAngle && mHeadingAngle == other.mHeadingAngle;
87 }
88 bool operator!=( const QgsCameraPose &other ) const
89 {
90 return !operator==( other );
91 }
92
93 private:
95 QgsVector3D mCenterPoint;
97 float mDistanceFromCenterPoint = 1000;
99 // prevent bug in QgsCameraPose::updateCamera when updating camera rotation.
100 // With a mPitchAngle < 0.2 or > 179.8, QQuaternion::fromEulerAngles( mPitchAngle, mHeadingAngle, 0 )
101 // will return bad rotation angle.
102 // See https://bugreports.qt.io/browse/QTBUG-72103
103#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
104 float mPitchAngle = 0.2f;
105#else
106 float mPitchAngle = 0.0f;
107#endif
108
110 float mHeadingAngle = 0;
111};
112
113
114#endif // QGSCAMERAPOSE_H
Encapsulates camera pose in a 3D scene.
float headingAngle() const
Returns heading (yaw) angle in degrees.
bool operator==(const QgsCameraPose &other) const
QgsVector3D centerPoint() const
Returns center point (towards which point the camera is looking)
float pitchAngle() const
Returns pitch angle in degrees.
bool operator!=(const QgsCameraPose &other) const
float distanceFromCenterPoint() const
Returns distance of the camera from the center point.
void setHeadingAngle(float heading)
Sets heading (yaw) angle in degrees.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:30
#define SIP_SKIP
Definition qgis_sip.h:126
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)