QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgs3dmapsceneentity.h
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dmapsceneentity.h
3 --------------------------------------
4 Date : May 2023
5 Copyright : (C) 2023 by Stefanos Natsis
6 Email : uclaros 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 QGS3DMAPSCENEENTITY_H
17#define QGS3DMAPSCENEENTITY_H
18
20
21//
22// W A R N I N G
23// -------------
24//
25// This file is not part of the QGIS API. It exists purely as an
26// implementation detail. This header file may change from version to
27// version without notice, or even be removed.
28//
29
30#include <Qt3DCore/QEntity>
31#include <QVector3D>
32#include <QMatrix4x4>
33
34#include "qgsrange.h"
35#include "qgssettings.h"
36
38
39#define SIP_NO_FILE
40
41
47class Qgs3DMapSceneEntity : public Qt3DCore::QEntity
48{
49 Q_OBJECT
50 public:
52 Qgs3DMapSceneEntity( Qgs3DMapSettings *mapSettings, Qt3DCore::QNode *parent = nullptr )
53 : Qt3DCore::QEntity( parent )
54 , mMapSettings( mapSettings )
55 {
56 const QgsSettings settings;
57 mGpuMemoryLimit = settings.value( QStringLiteral( "map3d/gpuMemoryLimit" ), 500.0, QgsSettings::App ).toDouble();
58 }
59
61 struct SceneContext
62 {
63 QVector3D cameraPos;
64 float cameraFov;
65 int screenSizePx;
66 QMatrix4x4 viewProjectionMatrix;
67 };
68
70 virtual void handleSceneUpdate( const SceneContext &sceneContext ) { Q_UNUSED( sceneContext ) }
71
73 virtual int pendingJobsCount() const { return 0; }
74
76 virtual bool needsUpdate() const { return false; }
77
79 virtual QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const { Q_UNUSED( viewMatrix ) return QgsRange<float>( 1e9, 0 ); }
80
86 Qgs3DMapSettings *mapSettings() { return mMapSettings; }
87
89 void setGpuMemoryLimit( double gpuMemoryLimit ) { mGpuMemoryLimit = gpuMemoryLimit; }
90
92 double gpuMemoryLimit() const { return mGpuMemoryLimit; }
93
95 bool hasReachedGpuMemoryLimit() const { return mHasReachedGpuMemoryLimit; }
96
97 protected:
99 void setHasReachedGpuMemoryLimit( bool reached ) { mHasReachedGpuMemoryLimit = reached; }
100
101 signals:
103 void pendingJobsCountChanged();
104
106 void newEntityCreated( Qt3DCore::QEntity *entity );
107
108 protected:
109 Qgs3DMapSettings *mMapSettings = nullptr;
110
112 double mGpuMemoryLimit = 500.0; // in megabytes
114 bool mHasReachedGpuMemoryLimit = false;
115};
116
118
119#endif // QGS3DMAPSCENEENTITY_H
A template based class for storing ranges (lower to upper values).
Definition qgsrange.h:46
This class is a composition of two QSettings instances:
Definition qgssettings.h:64
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.