mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	This adds two functions to setup clip planes on a 3d scene: - enableClipping() to enable opengl clipping - disableClipping() to disable opengl clipping The `enableClipping()` function achieves 3 things: - it stores the clipping plane equations - it adds clip planes to the framegraph - it enables the clipping on the material of the existing entities `disableClipping()` does the opposite things. The clip planes equations need to be stored to handle the dynamic addition of new entities. Indeed, when a new entity is added, clipping needs to be enabled on its material if necessary. This is achieved in `finalizeNewEntity` which is called on all new entities. However, this is not true for the terrain entity. That's why, `mTerrain` now listens to the `newEntityCreated` signal to call `handleClippingOnEntity()`.
		
			
				
	
	
		
			243 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			243 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/3d/qgs3dmapscene.h                                               *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
class Qgs3DMapScene : QObject
 | 
						|
{
 | 
						|
%Docstring(signature="appended")
 | 
						|
Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children.
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgs3dmapscene.h"
 | 
						|
%End
 | 
						|
  public:
 | 
						|
 | 
						|
    QgsCameraController *cameraController() const;
 | 
						|
%Docstring
 | 
						|
Returns camera controller
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
    void viewZoomFull();
 | 
						|
%Docstring
 | 
						|
Resets camera view to show the whole scene (top view)
 | 
						|
%End
 | 
						|
 | 
						|
    void setViewFrom2DExtent( const QgsRectangle &extent );
 | 
						|
%Docstring
 | 
						|
Resets camera view to show the extent ``extent`` (top view)
 | 
						|
 | 
						|
.. versionadded:: 3.26
 | 
						|
%End
 | 
						|
 | 
						|
    QVector<QgsPointXY> viewFrustum2DExtent() const;
 | 
						|
%Docstring
 | 
						|
Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid
 | 
						|
 | 
						|
.. versionadded:: 3.26
 | 
						|
%End
 | 
						|
 | 
						|
    int terrainPendingJobsCount() const;
 | 
						|
%Docstring
 | 
						|
Returns number of pending jobs of the terrain entity
 | 
						|
%End
 | 
						|
 | 
						|
    int totalPendingJobsCount() const;
 | 
						|
%Docstring
 | 
						|
Returns number of pending jobs for all chunked entities
 | 
						|
 | 
						|
.. versionadded:: 3.12
 | 
						|
%End
 | 
						|
 | 
						|
    enum SceneState
 | 
						|
    {
 | 
						|
      Ready,
 | 
						|
      Updating,
 | 
						|
    };
 | 
						|
 | 
						|
    SceneState sceneState() const;
 | 
						|
%Docstring
 | 
						|
Returns the current state of the scene
 | 
						|
%End
 | 
						|
 | 
						|
    float worldSpaceError( float epsilon, float distance ) const;
 | 
						|
%Docstring
 | 
						|
Given screen error (in pixels) and distance from camera (in 3D world coordinates), this function
 | 
						|
estimates the error in world space. Takes into account camera's field of view and the screen (3D view) size.
 | 
						|
%End
 | 
						|
 | 
						|
    void exportScene( const Qgs3DMapExportSettings &exportSettings );
 | 
						|
%Docstring
 | 
						|
Exports the scene according to the scene export settings
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    QgsRectangle sceneExtent() const;
 | 
						|
%Docstring
 | 
						|
Returns the scene extent in the map's CRS
 | 
						|
 | 
						|
.. versionadded:: 3.20
 | 
						|
%End
 | 
						|
 | 
						|
    QgsDoubleRange elevationRange() const;
 | 
						|
%Docstring
 | 
						|
Returns the scene's elevation range
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   Only some layer types are considered by this method (eg terrain, point cloud and mesh layers)
 | 
						|
 | 
						|
.. versionadded:: 3.30
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    Qgs3DMapSettings *mapSettings() const;
 | 
						|
%Docstring
 | 
						|
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/;
 | 
						|
%Docstring
 | 
						|
Returns a map of 3D map scenes (by name) open in the QGIS application.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   Only available from the QGIS desktop application.
 | 
						|
 | 
						|
.. deprecated:: 3.36
 | 
						|
 | 
						|
   Use QgisAppInterface.mapCanvases3D() instead.
 | 
						|
.. versionadded:: 3.30
 | 
						|
%End
 | 
						|
 | 
						|
    void enableClipping( const QList<QVector4D> &clipPlaneEquations );
 | 
						|
%Docstring
 | 
						|
Enables OpenGL clipping based on the planes equations defined in ``clipPlaneEquations``.
 | 
						|
The number of planes is equal to the size of ``clipPlaneEquations``.
 | 
						|
A plane equation contains 4 elements.
 | 
						|
A simple way to define a clip plane equation is to define a normalized normal to
 | 
						|
the plane and its distance from the origin of the scene.
 | 
						|
In that case, the first 3 elements are the coordinates of the normal of the plane as (X, Y, Z).
 | 
						|
They need to be normalized.
 | 
						|
The last element is the distance of the plane from the origin of the scene.
 | 
						|
In mathematical terms, a 3d plane can be defined with the equation ax+by+cz+d=0
 | 
						|
The normal is (a, b, c) with |a, b, c| = 1
 | 
						|
The distance is -d.
 | 
						|
 | 
						|
By default, OpenGL supports up to 8 additional clipping planes. If ``clipPlaneEquations``
 | 
						|
contains more than 8 planes, only the first 8 ones will be used.
 | 
						|
If ``clipPlaneEquations`` is empty, the clipping is disabled.
 | 
						|
 | 
						|
.. seealso:: :py:func:`disableClipping`
 | 
						|
 | 
						|
.. versionadded:: 3.40
 | 
						|
%End
 | 
						|
 | 
						|
    void disableClipping();
 | 
						|
%Docstring
 | 
						|
Disables OpenGL clipping.
 | 
						|
 | 
						|
.. seealso:: :py:func:`enableClipping`
 | 
						|
 | 
						|
.. versionadded:: 3.40
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
  signals:
 | 
						|
    void terrainEntityChanged();
 | 
						|
%Docstring
 | 
						|
Emitted when the current terrain entity is replaced by a new one
 | 
						|
%End
 | 
						|
    void terrainPendingJobsCountChanged();
 | 
						|
%Docstring
 | 
						|
Emitted when the number of terrain's pending jobs changes
 | 
						|
%End
 | 
						|
 | 
						|
    void totalPendingJobsCountChanged();
 | 
						|
%Docstring
 | 
						|
Emitted when the total number of pending jobs changes
 | 
						|
 | 
						|
.. versionadded:: 3.12
 | 
						|
%End
 | 
						|
    void sceneStateChanged();
 | 
						|
%Docstring
 | 
						|
Emitted when the scene's state has changed
 | 
						|
%End
 | 
						|
 | 
						|
    void fpsCountChanged( float fpsCount );
 | 
						|
%Docstring
 | 
						|
Emitted when the FPS count changes
 | 
						|
%End
 | 
						|
    void fpsCounterEnabledChanged( bool fpsCounterEnabled );
 | 
						|
%Docstring
 | 
						|
Emitted when the FPS counter is activated or deactivated
 | 
						|
%End
 | 
						|
 | 
						|
    void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
 | 
						|
%Docstring
 | 
						|
Emitted when the viewed 2D extent seen by the 3D camera has changed
 | 
						|
 | 
						|
.. versionadded:: 3.26
 | 
						|
%End
 | 
						|
 | 
						|
    void gpuMemoryLimitReached();
 | 
						|
%Docstring
 | 
						|
Emitted when one of the entities reaches its GPU memory limit
 | 
						|
and it is not possible to lower the GPU memory use by unloading
 | 
						|
data that's not currently needed.
 | 
						|
%End
 | 
						|
 | 
						|
  public slots:
 | 
						|
    void updateTemporal();
 | 
						|
%Docstring
 | 
						|
Updates the temporale entities
 | 
						|
%End
 | 
						|
 | 
						|
  private:
 | 
						|
    Qgs3DMapScene();
 | 
						|
    Qgs3DMapScene( const Qgs3DMapScene &other );
 | 
						|
};
 | 
						|
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/3d/qgs3dmapscene.h                                               *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 |