QGIS API Documentation 3.41.0-Master (af5edcb665c)
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
80 {
81 Q_UNUSED( viewMatrix )
82 return QgsRange<float>( 1e9, 0 );
83 }
84
90 Qgs3DMapSettings *mapSettings() { return mMapSettings; }
91
93 void setGpuMemoryLimit( double gpuMemoryLimit ) { mGpuMemoryLimit = gpuMemoryLimit; }
94
96 double gpuMemoryLimit() const { return mGpuMemoryLimit; }
97
99 bool hasReachedGpuMemoryLimit() const { return mHasReachedGpuMemoryLimit; }
100
101 protected:
103 void setHasReachedGpuMemoryLimit( bool reached ) { mHasReachedGpuMemoryLimit = reached; }
104
105 signals:
107 void pendingJobsCountChanged();
108
110 void newEntityCreated( Qt3DCore::QEntity *entity );
111
112 protected:
113 Qgs3DMapSettings *mMapSettings = nullptr;
114
116 double mGpuMemoryLimit = 500.0; // in megabytes
118 bool mHasReachedGpuMemoryLimit = false;
119};
120
122
123#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.