Skip to content

Commit

Permalink
Add API to temporarily disable updates in 3D map scene
Browse files Browse the repository at this point in the history
This is useful for debugging 3D views, to pause scene updates and
inspect some parts of the scene in detail.
  • Loading branch information
wonder-sk authored and nyalldawson committed Oct 2, 2024
1 parent 4cf5f43 commit b02813e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/3d/auto_generated/qgs3dmapscene.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ Returns the scene's elevation range
Returns the 3D map settings.

.. versionadded:: 3.30
%End

bool hasSceneUpdatesEnabled() const;
%Docstring
Returns whether updates of the 3D scene's entities are allowed.
Normally, scene updates are enabled. But for debugging purposes,
it may be useful to temporarily disable scene updates.

.. versionadded:: 3.40
%End

void setSceneUpdatesEnabled( bool enabled );
%Docstring
Sets whether updates of the 3D scene's entities are allowed.
Normally, scene updates are enabled. But for debugging purposes,
it may be useful to temporarily disable scene updates.

.. versionadded:: 3.40
%End

static QMap< QString, Qgs3DMapScene * > openScenes() /Deprecated/;
Expand Down
18 changes: 18 additions & 0 deletions python/PyQt6/3d/auto_generated/qgs3dmapscene.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ Returns the scene's elevation range
Returns the 3D map settings.

.. versionadded:: 3.30
%End

bool hasSceneUpdatesEnabled() const;
%Docstring
Returns whether updates of the 3D scene's entities are allowed.
Normally, scene updates are enabled. But for debugging purposes,
it may be useful to temporarily disable scene updates.

.. versionadded:: 3.40
%End

void setSceneUpdatesEnabled( bool enabled );
%Docstring
Sets whether updates of the 3D scene's entities are allowed.
Normally, scene updates are enabled. But for debugging purposes,
it may be useful to temporarily disable scene updates.

.. versionadded:: 3.40
%End

static QMap< QString, Qgs3DMapScene * > openScenes() /Deprecated/;
Expand Down
6 changes: 6 additions & 0 deletions src/3d/qgs3dmapscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ void Qgs3DMapScene::onCameraChanged()

void Qgs3DMapScene::updateScene( bool forceUpdate )
{
if ( !mSceneUpdatesEnabled )
{
QgsDebugMsgLevel( "Scene update skipped", 2 );
return;
}

if ( forceUpdate )
QgsEventTracing::addEvent( QgsEventTracing::Instant, QStringLiteral( "3D" ), QStringLiteral( "Update Scene" ) );

Expand Down
20 changes: 20 additions & 0 deletions src/3d/qgs3dmapscene.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,24 @@ class _3D_EXPORT Qgs3DMapScene : public QObject
*/
Qgs3DMapSettings *mapSettings() const { return &mMap; }

/**
* Returns whether updates of the 3D scene's entities are allowed.
* Normally, scene updates are enabled. But for debugging purposes,
* it may be useful to temporarily disable scene updates.
*
* \since QGIS 3.40
*/
bool hasSceneUpdatesEnabled() const { return mSceneUpdatesEnabled; }

/**
* Sets whether updates of the 3D scene's entities are allowed.
* Normally, scene updates are enabled. But for debugging purposes,
* it may be useful to temporarily disable scene updates.
*
* \since QGIS 3.40
*/
void setSceneUpdatesEnabled( bool enabled ) { mSceneUpdatesEnabled = enabled; }

/**
* Returns a map of 3D map scenes (by name) open in the QGIS application.
*
Expand Down Expand Up @@ -302,5 +320,7 @@ class _3D_EXPORT Qgs3DMapScene : public QObject
//! 3d axis visualization
Qgs3DAxis *m3DAxis = nullptr;

bool mSceneUpdatesEnabled = true;

};
#endif // QGS3DMAPSCENE_H

0 comments on commit b02813e

Please sign in to comment.