mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Qgs3DMapCanvas + Qgs3DWindow = <3
This commit is contained in:
parent
7d45d29891
commit
75607c05f8
@ -1,10 +1,11 @@
|
||||
// Include auto-generated SIP files
|
||||
%Include auto_generated/processing/qgs3dalgorithms.sip
|
||||
%Include auto_generated/qgs3d.sip
|
||||
%Include auto_generated/qgs3dmapcanvas.sip
|
||||
%Include auto_generated/qgs3dmapscene.sip
|
||||
%Include auto_generated/qgs3dmapsettings.sip
|
||||
%Include auto_generated/qgs3dmaptool.sip
|
||||
%Include auto_generated/qgs3dtypes.sip
|
||||
%Include auto_generated/qgs3dwindow.sip
|
||||
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip
|
||||
%Include auto_generated/qgscameracontroller.sip
|
||||
%Include auto_generated/qgscamerapose.sip
|
||||
|
191
python/3d/auto_generated/qgs3dmapcanvas.sip.in
Normal file
191
python/3d/auto_generated/qgs3dmapcanvas.sip.in
Normal file
@ -0,0 +1,191 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmapcanvas.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Qgs3DMapCanvas : QWindow
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
Qgs3DMapCanvas is a convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.
|
||||
|
||||
.. note::
|
||||
|
||||
This is a port of qtwindow3d which does not set the default surface when initialized.
|
||||
|
||||
.. note::
|
||||
|
||||
The default surface must be set before the construction of the QApplication when using shared OpenGL context.
|
||||
|
||||
.. note::
|
||||
|
||||
This is required in order to use QT3d and QtWebEngine at the same time.
|
||||
|
||||
.. versionadded:: 3.36
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgs3dmapcanvas.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
Qgs3DMapCanvas();
|
||||
%Docstring
|
||||
Constructor for Qgs3DMapCanvas.
|
||||
%End
|
||||
|
||||
~Qgs3DMapCanvas();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void setMap( Qgs3DMapSettings *map );
|
||||
%Docstring
|
||||
Configure map scene being displayed. Takes ownership.
|
||||
%End
|
||||
|
||||
Qgs3DMapSettings *map();
|
||||
%Docstring
|
||||
Returns access to the 3D scene configuration
|
||||
%End
|
||||
|
||||
Qgs3DMapScene *scene();
|
||||
%Docstring
|
||||
Returns access to the 3D scene (root 3D entity)
|
||||
%End
|
||||
|
||||
QgsCameraController *cameraController();
|
||||
%Docstring
|
||||
Returns access to the view's camera controller. Returns ``None`` if the scene has not been initialized yet with :py:func:`~Qgs3DMapCanvas.setMap`
|
||||
%End
|
||||
|
||||
void resetView();
|
||||
%Docstring
|
||||
Resets camera position to the default: looking down at the origin of world coordinates
|
||||
%End
|
||||
|
||||
void setViewFromTop( const QgsPointXY ¢er, float distance, float rotation = 0 );
|
||||
%Docstring
|
||||
Sets camera position to look down at the given point (in map coordinates) in given distance from plane with zero elevation
|
||||
%End
|
||||
|
||||
void saveAsImage( const QString &fileName, const QString &fileFormat );
|
||||
%Docstring
|
||||
Saves the current scene as an image
|
||||
%End
|
||||
|
||||
void setMapTool( Qgs3DMapTool *tool );
|
||||
%Docstring
|
||||
Sets the active map tool that will receive events from the 3D canvas. Does not transfer ownership.
|
||||
If the tool is ``None``, events will be used for camera manipulation.
|
||||
%End
|
||||
|
||||
Qgs3DMapTool *mapTool() const;
|
||||
%Docstring
|
||||
Returns the active map tool that will receive events from the 3D canvas.
|
||||
If the tool is ``None``, events will be used for camera manipulation.
|
||||
%End
|
||||
|
||||
|
||||
void setTemporalController( QgsTemporalController *temporalController );
|
||||
%Docstring
|
||||
Sets the temporal controller
|
||||
%End
|
||||
|
||||
QSize windowSize() const;
|
||||
%Docstring
|
||||
Returns the size of the 3D canvas window
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setViewFrom2DExtent( const QgsRectangle &extent );
|
||||
%Docstring
|
||||
Resets camera view to show the extent ``extent`` (top view)
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
QVector<QgsPointXY> viewFrustum2DExtent();
|
||||
%Docstring
|
||||
Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
signals:
|
||||
void savedAsImage( const QString &fileName );
|
||||
%Docstring
|
||||
Emitted when the 3D map canvas was successfully saved as image
|
||||
%End
|
||||
|
||||
void mapSettingsChanged();
|
||||
%Docstring
|
||||
Emitted when the the map setting is changed
|
||||
%End
|
||||
|
||||
void fpsCountChanged( float fpsCount );
|
||||
%Docstring
|
||||
Emitted when the FPS count changes (at most every frame)
|
||||
%End
|
||||
void fpsCounterEnabledChanged( bool enabled );
|
||||
%Docstring
|
||||
Emitted when the FPS counter is enabled or disabeld
|
||||
%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 cameraNavigationSpeedChanged( double speed );
|
||||
%Docstring
|
||||
Emitted when the camera navigation ``speed`` is changed.
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
public slots:
|
||||
void captureDepthBuffer();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void showEvent( QShowEvent *e );
|
||||
|
||||
%Docstring
|
||||
Manages the display events specified in e.
|
||||
%End
|
||||
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
|
||||
%Docstring
|
||||
Resets the aspect ratio of the 3D window.
|
||||
%End
|
||||
|
||||
|
||||
|
||||
virtual bool eventFilter( QObject *watched, QEvent *event );
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmapcanvas.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
64
python/3d/auto_generated/qgs3dmaptool.sip.in
Normal file
64
python/3d/auto_generated/qgs3dmaptool.sip.in
Normal file
@ -0,0 +1,64 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmaptool.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Qgs3DMapTool : QObject
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
Base class for map tools operating on 3D map canvas.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgs3dmaptool.h"
|
||||
%End
|
||||
public:
|
||||
Qgs3DMapTool( Qgs3DMapCanvas *canvas );
|
||||
|
||||
virtual void mousePressEvent( QMouseEvent *event );
|
||||
virtual void mouseReleaseEvent( QMouseEvent *event );
|
||||
virtual void mouseMoveEvent( QMouseEvent *event );
|
||||
virtual void keyPressEvent( QKeyEvent *event );
|
||||
|
||||
virtual void activate();
|
||||
%Docstring
|
||||
Called when set as currently active map tool
|
||||
%End
|
||||
|
||||
virtual void deactivate();
|
||||
%Docstring
|
||||
Called when map tool is being deactivated
|
||||
%End
|
||||
|
||||
virtual QCursor cursor() const;
|
||||
%Docstring
|
||||
Mouse cursor to be used when the tool is active
|
||||
%End
|
||||
|
||||
virtual bool allowsCameraControls() const;
|
||||
%Docstring
|
||||
Whether the default mouse controls to zoom/pan/rotate camera can stay enabled
|
||||
while the tool is active. This may be useful for some basic tools using just
|
||||
mouse clicks (e.g. identify, measure), but it could be creating conflicts when used
|
||||
with more advanced tools. Default implementation returns ``True``.
|
||||
%End
|
||||
|
||||
Qgs3DMapCanvas *canvas();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmaptool.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -1,69 +0,0 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dwindow.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Qgs3DWindow : QWindow
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
qgs3dWindow is a convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.
|
||||
|
||||
.. note::
|
||||
|
||||
This is a port of qtwindow3d which does not set the default surface when initialized.
|
||||
|
||||
.. note::
|
||||
|
||||
The default surface must be set before the construction of the QApplication when using shared OpenGL context.
|
||||
|
||||
.. note::
|
||||
|
||||
This is required in order to use QT3d and QtWebEngine at the same time.
|
||||
|
||||
.. versionadded:: 3.36
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgs3dwindow.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
Qgs3DWindow();
|
||||
%Docstring
|
||||
Constructor for Qgs3DWindow.
|
||||
%End
|
||||
|
||||
~Qgs3DWindow();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void showEvent( QShowEvent *e );
|
||||
|
||||
%Docstring
|
||||
Manages the display events specified in e.
|
||||
%End
|
||||
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
|
||||
%Docstring
|
||||
Resets the aspect ratio of the 3D window.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dwindow.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -1,10 +1,11 @@
|
||||
// Include auto-generated SIP files
|
||||
%Include auto_generated/processing/qgs3dalgorithms.sip
|
||||
%Include auto_generated/qgs3d.sip
|
||||
%Include auto_generated/qgs3dmapcanvas.sip
|
||||
%Include auto_generated/qgs3dmapscene.sip
|
||||
%Include auto_generated/qgs3dmapsettings.sip
|
||||
%Include auto_generated/qgs3dmaptool.sip
|
||||
%Include auto_generated/qgs3dtypes.sip
|
||||
%Include auto_generated/qgs3dwindow.sip
|
||||
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip
|
||||
%Include auto_generated/qgscameracontroller.sip
|
||||
%Include auto_generated/qgscamerapose.sip
|
||||
|
191
python/PyQt6/3d/auto_generated/qgs3dmapcanvas.sip.in
Normal file
191
python/PyQt6/3d/auto_generated/qgs3dmapcanvas.sip.in
Normal file
@ -0,0 +1,191 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmapcanvas.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Qgs3DMapCanvas : QWindow
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
Qgs3DMapCanvas is a convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.
|
||||
|
||||
.. note::
|
||||
|
||||
This is a port of qtwindow3d which does not set the default surface when initialized.
|
||||
|
||||
.. note::
|
||||
|
||||
The default surface must be set before the construction of the QApplication when using shared OpenGL context.
|
||||
|
||||
.. note::
|
||||
|
||||
This is required in order to use QT3d and QtWebEngine at the same time.
|
||||
|
||||
.. versionadded:: 3.36
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgs3dmapcanvas.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
Qgs3DMapCanvas();
|
||||
%Docstring
|
||||
Constructor for Qgs3DMapCanvas.
|
||||
%End
|
||||
|
||||
~Qgs3DMapCanvas();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void setMap( Qgs3DMapSettings *map );
|
||||
%Docstring
|
||||
Configure map scene being displayed. Takes ownership.
|
||||
%End
|
||||
|
||||
Qgs3DMapSettings *map();
|
||||
%Docstring
|
||||
Returns access to the 3D scene configuration
|
||||
%End
|
||||
|
||||
Qgs3DMapScene *scene();
|
||||
%Docstring
|
||||
Returns access to the 3D scene (root 3D entity)
|
||||
%End
|
||||
|
||||
QgsCameraController *cameraController();
|
||||
%Docstring
|
||||
Returns access to the view's camera controller. Returns ``None`` if the scene has not been initialized yet with :py:func:`~Qgs3DMapCanvas.setMap`
|
||||
%End
|
||||
|
||||
void resetView();
|
||||
%Docstring
|
||||
Resets camera position to the default: looking down at the origin of world coordinates
|
||||
%End
|
||||
|
||||
void setViewFromTop( const QgsPointXY ¢er, float distance, float rotation = 0 );
|
||||
%Docstring
|
||||
Sets camera position to look down at the given point (in map coordinates) in given distance from plane with zero elevation
|
||||
%End
|
||||
|
||||
void saveAsImage( const QString &fileName, const QString &fileFormat );
|
||||
%Docstring
|
||||
Saves the current scene as an image
|
||||
%End
|
||||
|
||||
void setMapTool( Qgs3DMapTool *tool );
|
||||
%Docstring
|
||||
Sets the active map tool that will receive events from the 3D canvas. Does not transfer ownership.
|
||||
If the tool is ``None``, events will be used for camera manipulation.
|
||||
%End
|
||||
|
||||
Qgs3DMapTool *mapTool() const;
|
||||
%Docstring
|
||||
Returns the active map tool that will receive events from the 3D canvas.
|
||||
If the tool is ``None``, events will be used for camera manipulation.
|
||||
%End
|
||||
|
||||
|
||||
void setTemporalController( QgsTemporalController *temporalController );
|
||||
%Docstring
|
||||
Sets the temporal controller
|
||||
%End
|
||||
|
||||
QSize windowSize() const;
|
||||
%Docstring
|
||||
Returns the size of the 3D canvas window
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setViewFrom2DExtent( const QgsRectangle &extent );
|
||||
%Docstring
|
||||
Resets camera view to show the extent ``extent`` (top view)
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
QVector<QgsPointXY> viewFrustum2DExtent();
|
||||
%Docstring
|
||||
Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
signals:
|
||||
void savedAsImage( const QString &fileName );
|
||||
%Docstring
|
||||
Emitted when the 3D map canvas was successfully saved as image
|
||||
%End
|
||||
|
||||
void mapSettingsChanged();
|
||||
%Docstring
|
||||
Emitted when the the map setting is changed
|
||||
%End
|
||||
|
||||
void fpsCountChanged( float fpsCount );
|
||||
%Docstring
|
||||
Emitted when the FPS count changes (at most every frame)
|
||||
%End
|
||||
void fpsCounterEnabledChanged( bool enabled );
|
||||
%Docstring
|
||||
Emitted when the FPS counter is enabled or disabeld
|
||||
%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 cameraNavigationSpeedChanged( double speed );
|
||||
%Docstring
|
||||
Emitted when the camera navigation ``speed`` is changed.
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
public slots:
|
||||
void captureDepthBuffer();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void showEvent( QShowEvent *e );
|
||||
|
||||
%Docstring
|
||||
Manages the display events specified in e.
|
||||
%End
|
||||
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
|
||||
%Docstring
|
||||
Resets the aspect ratio of the 3D window.
|
||||
%End
|
||||
|
||||
|
||||
|
||||
virtual bool eventFilter( QObject *watched, QEvent *event );
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmapcanvas.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
64
python/PyQt6/3d/auto_generated/qgs3dmaptool.sip.in
Normal file
64
python/PyQt6/3d/auto_generated/qgs3dmaptool.sip.in
Normal file
@ -0,0 +1,64 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmaptool.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Qgs3DMapTool : QObject
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
Base class for map tools operating on 3D map canvas.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgs3dmaptool.h"
|
||||
%End
|
||||
public:
|
||||
Qgs3DMapTool( Qgs3DMapCanvas *canvas );
|
||||
|
||||
virtual void mousePressEvent( QMouseEvent *event );
|
||||
virtual void mouseReleaseEvent( QMouseEvent *event );
|
||||
virtual void mouseMoveEvent( QMouseEvent *event );
|
||||
virtual void keyPressEvent( QKeyEvent *event );
|
||||
|
||||
virtual void activate();
|
||||
%Docstring
|
||||
Called when set as currently active map tool
|
||||
%End
|
||||
|
||||
virtual void deactivate();
|
||||
%Docstring
|
||||
Called when map tool is being deactivated
|
||||
%End
|
||||
|
||||
virtual QCursor cursor() const;
|
||||
%Docstring
|
||||
Mouse cursor to be used when the tool is active
|
||||
%End
|
||||
|
||||
virtual bool allowsCameraControls() const;
|
||||
%Docstring
|
||||
Whether the default mouse controls to zoom/pan/rotate camera can stay enabled
|
||||
while the tool is active. This may be useful for some basic tools using just
|
||||
mouse clicks (e.g. identify, measure), but it could be creating conflicts when used
|
||||
with more advanced tools. Default implementation returns ``True``.
|
||||
%End
|
||||
|
||||
Qgs3DMapCanvas *canvas();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dmaptool.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -1,69 +0,0 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dwindow.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Qgs3DWindow : QWindow
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
qgs3dWindow is a convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.
|
||||
|
||||
.. note::
|
||||
|
||||
This is a port of qtwindow3d which does not set the default surface when initialized.
|
||||
|
||||
.. note::
|
||||
|
||||
The default surface must be set before the construction of the QApplication when using shared OpenGL context.
|
||||
|
||||
.. note::
|
||||
|
||||
This is required in order to use QT3d and QtWebEngine at the same time.
|
||||
|
||||
.. versionadded:: 3.36
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgs3dwindow.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
Qgs3DWindow();
|
||||
%Docstring
|
||||
Constructor for Qgs3DWindow.
|
||||
%End
|
||||
|
||||
~Qgs3DWindow();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void showEvent( QShowEvent *e );
|
||||
|
||||
%Docstring
|
||||
Manages the display events specified in e.
|
||||
%End
|
||||
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
|
||||
%Docstring
|
||||
Resets the aspect ratio of the 3D window.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dwindow.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -11,13 +11,12 @@ set(QGIS_3D_SRCS
|
||||
qgs3danimationsettings.cpp
|
||||
qgs3dexportobject.cpp
|
||||
qgs3dmapexportsettings.cpp
|
||||
qgs3dmapcanvas.cpp
|
||||
qgs3dmapscene.cpp
|
||||
qgs3dmapsettings.cpp
|
||||
qgs3dmaptool.cpp
|
||||
qgs3dmapcanvas.cpp
|
||||
qgs3dsceneexporter.cpp
|
||||
qgs3dutils.cpp
|
||||
qgs3dwindow.cpp
|
||||
qgscameracontroller.cpp
|
||||
qgscamerapose.cpp
|
||||
qgsfeature3dhandler_p.cpp
|
||||
@ -115,14 +114,13 @@ set(QGIS_3D_HDRS
|
||||
qgs3danimationsettings.h
|
||||
qgs3daxis.h
|
||||
qgs3daxissettings.h
|
||||
qgs3dmapcanvas.h
|
||||
qgs3dmapscene.h
|
||||
qgs3dmapsettings.h
|
||||
qgs3dmaptool.h
|
||||
qgs3dsceneexporter.h
|
||||
qgs3dtypes.h
|
||||
qgs3dutils.h
|
||||
qgs3dwindow.h
|
||||
qgs3dmapcanvas.h
|
||||
qgsaabb.h
|
||||
qgsabstract3dengine.h
|
||||
qgsabstractvectorlayer3drenderer.h
|
||||
|
@ -55,7 +55,7 @@ typedef Qt3DCore::QBuffer Qt3DQBuffer;
|
||||
#include "qgswindow3dengine.h"
|
||||
#include "qgsraycastingutils_p.h"
|
||||
|
||||
Qgs3DAxis::Qgs3DAxis( Qgs3DWindow *parentWindow,
|
||||
Qgs3DAxis::Qgs3DAxis( Qgs3DMapCanvas *parentWindow,
|
||||
Qt3DCore::QEntity *parent3DScene,
|
||||
Qgs3DMapScene *mapScene,
|
||||
QgsCameraController *cameraCtrl,
|
||||
@ -74,8 +74,8 @@ Qgs3DAxis::Qgs3DAxis( Qgs3DWindow *parentWindow,
|
||||
mTwoDLabelViewport->setParent( mParentWindow->activeFrameGraph() );
|
||||
|
||||
connect( cameraCtrl, &QgsCameraController::cameraChanged, this, &Qgs3DAxis::onCameraUpdate );
|
||||
connect( mParentWindow, &Qgs3DWindow::widthChanged, this, &Qgs3DAxis::onAxisViewportSizeUpdate );
|
||||
connect( mParentWindow, &Qgs3DWindow::heightChanged, this, &Qgs3DAxis::onAxisViewportSizeUpdate );
|
||||
connect( mParentWindow, &Qgs3DMapCanvas::widthChanged, this, &Qgs3DAxis::onAxisViewportSizeUpdate );
|
||||
connect( mParentWindow, &Qgs3DMapCanvas::heightChanged, this, &Qgs3DAxis::onAxisViewportSizeUpdate );
|
||||
|
||||
createAxisScene();
|
||||
onAxisViewportSizeUpdate();
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define QGS3DAXIS_H
|
||||
|
||||
#include "qgis_3d.h"
|
||||
#include "qgs3dwindow.h"
|
||||
#include "qgs3dmapcanvas.h"
|
||||
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include <Qt3DCore/QEntity>
|
||||
@ -70,7 +70,7 @@ class _3D_EXPORT Qgs3DAxis : public QObject
|
||||
* @param camera camera controller used to track camera movements
|
||||
* @param map 3D map settings
|
||||
*/
|
||||
Qgs3DAxis( Qgs3DWindow *parentWindow, Qt3DCore::QEntity *parent3DScene,
|
||||
Qgs3DAxis( Qgs3DMapCanvas *parentWindow, Qt3DCore::QEntity *parent3DScene,
|
||||
Qgs3DMapScene *mapScene, QgsCameraController *camera, Qgs3DMapSettings *map );
|
||||
~Qgs3DAxis() override;
|
||||
|
||||
@ -143,7 +143,7 @@ class _3D_EXPORT Qgs3DAxis : public QObject
|
||||
void displayMenuAt( const QPoint &position );
|
||||
|
||||
Qgs3DMapSettings *mMapSettings = nullptr;
|
||||
Qgs3DWindow *mParentWindow = nullptr;
|
||||
Qgs3DMapCanvas *mParentWindow = nullptr;
|
||||
Qgs3DMapScene *mMapScene = nullptr;
|
||||
QgsCameraController *mCameraController = nullptr;
|
||||
|
||||
|
@ -13,24 +13,60 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <Qt3DCore/QAspectEngine>
|
||||
#include <Qt3DCore/QEntity>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <Qt3DCore/QCoreAspect>
|
||||
#endif
|
||||
#include <Qt3DExtras/QForwardRenderer>
|
||||
#include <Qt3DRender/QRenderSettings>
|
||||
#include <Qt3DRender/QRenderAspect>
|
||||
#include <Qt3DInput/QInputAspect>
|
||||
#include <Qt3DInput/QInputSettings>
|
||||
#include <Qt3DLogic/QLogicAspect>
|
||||
#include <Qt3DRender/QCamera>
|
||||
|
||||
#include "qgs3dmapcanvas.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <Qt3DRender/QRenderCapture>
|
||||
#include <Qt3DLogic/QFrameAction>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "qgscameracontroller.h"
|
||||
#include "qgs3dmapsettings.h"
|
||||
#include "qgs3dmapscene.h"
|
||||
#include "qgs3dmaptool.h"
|
||||
#include "qgswindow3dengine.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgs3dmapsettings.h"
|
||||
#include "qgs3dmaptool.h"
|
||||
#include "qgstemporalcontroller.h"
|
||||
|
||||
Qgs3DMapCanvas::Qgs3DMapCanvas( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
Qgs3DMapCanvas::Qgs3DMapCanvas()
|
||||
: m_aspectEngine( new Qt3DCore::QAspectEngine )
|
||||
, m_renderAspect( new Qt3DRender::QRenderAspect )
|
||||
, m_inputAspect( new Qt3DInput::QInputAspect )
|
||||
, m_logicAspect( new Qt3DLogic::QLogicAspect )
|
||||
, m_renderSettings( new Qt3DRender::QRenderSettings )
|
||||
, m_forwardRenderer( new Qt3DExtras::QForwardRenderer )
|
||||
, m_defaultCamera( new Qt3DRender::QCamera )
|
||||
, m_inputSettings( new Qt3DInput::QInputSettings )
|
||||
, m_root( new Qt3DCore::QEntity )
|
||||
, m_userRoot( nullptr )
|
||||
, m_initialized( false )
|
||||
{
|
||||
setSurfaceType( QSurface::OpenGLSurface );
|
||||
|
||||
// register aspects
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
m_aspectEngine->registerAspect( new Qt3DCore::QCoreAspect );
|
||||
#endif
|
||||
m_aspectEngine->registerAspect( m_renderAspect );
|
||||
m_aspectEngine->registerAspect( m_inputAspect );
|
||||
m_aspectEngine->registerAspect( m_logicAspect );
|
||||
|
||||
m_defaultCamera->setParent( m_root );
|
||||
m_forwardRenderer->setCamera( m_defaultCamera );
|
||||
m_forwardRenderer->setSurface( this );
|
||||
m_renderSettings->setActiveFrameGraph( m_forwardRenderer );
|
||||
m_inputSettings->setEventSource( this );
|
||||
|
||||
|
||||
|
||||
|
||||
const QgsSettings setting;
|
||||
mEngine = new QgsWindow3DEngine( this );
|
||||
|
||||
@ -41,8 +77,8 @@ Qgs3DMapCanvas::Qgs3DMapCanvas( QWidget *parent )
|
||||
emit savedAsImage( mCaptureFileName );
|
||||
} );
|
||||
|
||||
mEngine->window()->setCursor( Qt::OpenHandCursor );
|
||||
mEngine->window()->installEventFilter( this );
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
installEventFilter( this );
|
||||
}
|
||||
|
||||
Qgs3DMapCanvas::~Qgs3DMapCanvas()
|
||||
@ -54,18 +90,77 @@ Qgs3DMapCanvas::~Qgs3DMapCanvas()
|
||||
mScene = nullptr;
|
||||
mMap->deleteLater();
|
||||
mMap = nullptr;
|
||||
|
||||
|
||||
delete m_aspectEngine;
|
||||
}
|
||||
|
||||
void Qgs3DMapCanvas::resizeEvent( QResizeEvent *ev )
|
||||
void Qgs3DMapCanvas::setRootEntity( Qt3DCore::QEntity *root )
|
||||
{
|
||||
QWidget::resizeEvent( ev );
|
||||
if ( m_userRoot != root )
|
||||
{
|
||||
if ( m_userRoot != nullptr )
|
||||
m_userRoot->setParent( static_cast<Qt3DCore::QNode *>( nullptr ) );
|
||||
if ( root != nullptr )
|
||||
root->setParent( m_root );
|
||||
m_userRoot = root;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mScene )
|
||||
return;
|
||||
void Qgs3DMapCanvas::setActiveFrameGraph( Qt3DRender::QFrameGraphNode *activeFrameGraph )
|
||||
{
|
||||
m_renderSettings->setActiveFrameGraph( activeFrameGraph );
|
||||
}
|
||||
|
||||
Qt3DRender::QFrameGraphNode *Qgs3DMapCanvas::activeFrameGraph() const
|
||||
{
|
||||
return m_renderSettings->activeFrameGraph();
|
||||
}
|
||||
|
||||
Qt3DExtras::QForwardRenderer *Qgs3DMapCanvas::defaultFrameGraph() const
|
||||
{
|
||||
return m_forwardRenderer;
|
||||
}
|
||||
|
||||
Qt3DRender::QCamera *Qgs3DMapCanvas::camera() const
|
||||
{
|
||||
return m_defaultCamera;
|
||||
}
|
||||
|
||||
Qt3DRender::QRenderSettings *Qgs3DMapCanvas::renderSettings() const
|
||||
{
|
||||
return m_renderSettings;
|
||||
}
|
||||
|
||||
void Qgs3DMapCanvas::showEvent( QShowEvent *e )
|
||||
{
|
||||
if ( !m_initialized )
|
||||
{
|
||||
m_root->addComponent( m_renderSettings );
|
||||
m_root->addComponent( m_inputSettings );
|
||||
m_aspectEngine->setRootEntity( Qt3DCore::QEntityPtr( m_root ) );
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
QWindow::showEvent( e );
|
||||
}
|
||||
|
||||
void Qgs3DMapCanvas::resizeEvent( QResizeEvent * )
|
||||
{
|
||||
m_defaultCamera->setAspectRatio( float( width() ) / std::max( 1.f, static_cast<float>( height() ) ) );
|
||||
|
||||
mEngine->setSize( size() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Qgs3DMapCanvas::setMap( Qgs3DMapSettings *map )
|
||||
{
|
||||
// TODO: eventually we want to get rid of this
|
||||
@ -177,7 +272,7 @@ void Qgs3DMapCanvas::setMapTool( Qgs3DMapTool *tool )
|
||||
if ( mMapTool && !tool )
|
||||
{
|
||||
mScene->cameraController()->setEnabled( true );
|
||||
mEngine->window()->setCursor( Qt::OpenHandCursor );
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
}
|
||||
else if ( !mMapTool && tool )
|
||||
{
|
||||
@ -192,14 +287,14 @@ void Qgs3DMapCanvas::setMapTool( Qgs3DMapTool *tool )
|
||||
if ( mMapTool )
|
||||
{
|
||||
mMapTool->activate();
|
||||
mEngine->window()->setCursor( mMapTool->cursor() );
|
||||
setCursor( mMapTool->cursor() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool Qgs3DMapCanvas::eventFilter( QObject *watched, QEvent *event )
|
||||
{
|
||||
if ( watched != mEngine->window() )
|
||||
if ( watched != this )
|
||||
return false;
|
||||
|
||||
if ( event->type() == QEvent::ShortcutOverride )
|
||||
|
@ -16,34 +16,118 @@
|
||||
#ifndef QGS3DMAPCANVAS_H
|
||||
#define QGS3DMAPCANVAS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <Qt3DRender/QRenderCapture>
|
||||
|
||||
#include "qgis_3d.h"
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgsrange.h"
|
||||
#include "qgscameracontroller.h"
|
||||
#include "qgsrectangle.h"
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
#ifndef SIP_RUN
|
||||
namespace Qt3DCore
|
||||
{
|
||||
class QAspectEngine;
|
||||
class QAbstractAspect;
|
||||
class QEntity;
|
||||
}
|
||||
|
||||
namespace Qt3DRender
|
||||
{
|
||||
class QCamera;
|
||||
class QFrameGraphNode;
|
||||
class QRenderAspect;
|
||||
class QRenderSettings;
|
||||
}
|
||||
|
||||
namespace Qt3DExtras
|
||||
{
|
||||
class QForwardRenderer;
|
||||
}
|
||||
|
||||
namespace Qt3DInput
|
||||
{
|
||||
class QInputAspect;
|
||||
class QInputSettings;
|
||||
}
|
||||
|
||||
namespace Qt3DLogic
|
||||
{
|
||||
class QFrameAction;
|
||||
class QLogicAspect;
|
||||
}
|
||||
#endif
|
||||
|
||||
class Qgs3DMapSettings;
|
||||
class Qgs3DMapScene;
|
||||
class Qgs3DMapTool;
|
||||
class QgsRectangle;
|
||||
class QgsWindow3DEngine;
|
||||
class Qgs3DMapTool;
|
||||
class QgsPointXY;
|
||||
class QgsCameraController;
|
||||
class QgsTemporalController;
|
||||
class QgsRubberBand;
|
||||
class Qgs3DMapScene;
|
||||
class Qgs3DMapSettings;
|
||||
|
||||
class _3D_EXPORT Qgs3DMapCanvas : public QWidget
|
||||
|
||||
/**
|
||||
* \ingroup 3d
|
||||
* \brief Qgs3DMapCanvas is a convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.
|
||||
*
|
||||
* \note This is a port of qtwindow3d which does not set the default surface when initialized.
|
||||
* \note The default surface must be set before the construction of the QApplication when using shared OpenGL context.
|
||||
* \note This is required in order to use QT3d and QtWebEngine at the same time.
|
||||
*
|
||||
* \since QGIS 3.36
|
||||
*/
|
||||
class _3D_EXPORT Qgs3DMapCanvas : public QWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Qgs3DMapCanvas( QWidget *parent = nullptr );
|
||||
~Qgs3DMapCanvas() override;
|
||||
|
||||
/**
|
||||
* Constructor for Qgs3DMapCanvas.
|
||||
*/
|
||||
Qgs3DMapCanvas();
|
||||
|
||||
/**
|
||||
* Destructor for Qgs3DMapCanvas.
|
||||
*/
|
||||
~Qgs3DMapCanvas();
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
/**
|
||||
* Sets the specified root entity of the scene.
|
||||
*/
|
||||
void setRootEntity( Qt3DCore::QEntity *root );
|
||||
|
||||
/**
|
||||
* Activates the specified activeFrameGraph.
|
||||
*/
|
||||
void setActiveFrameGraph( Qt3DRender::QFrameGraphNode *activeFrameGraph );
|
||||
|
||||
/**
|
||||
* Returns the node of the active frame graph.
|
||||
*/
|
||||
Qt3DRender::QFrameGraphNode *activeFrameGraph() const;
|
||||
|
||||
/**
|
||||
* Returns the node of the default framegraph
|
||||
*/
|
||||
Qt3DExtras::QForwardRenderer *defaultFrameGraph() const;
|
||||
|
||||
/**
|
||||
* Returns the default camera of the 3D Window.
|
||||
*/
|
||||
Qt3DRender::QCamera *camera() const;
|
||||
|
||||
/**
|
||||
* Returns the render settings of the 3D Window.
|
||||
*/
|
||||
Qt3DRender::QRenderSettings *renderSettings() const;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//! Configure map scene being displayed. Takes ownership.
|
||||
void setMap( Qgs3DMapSettings *map );
|
||||
@ -81,7 +165,7 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWidget
|
||||
/**
|
||||
* Returns the 3D engine.
|
||||
*/
|
||||
QgsWindow3DEngine *engine() const { return mEngine; }
|
||||
QgsWindow3DEngine *engine() const SIP_SKIP { return mEngine; }
|
||||
|
||||
/**
|
||||
* Sets the temporal controller
|
||||
@ -142,10 +226,47 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWidget
|
||||
void onNavigationModeChanged( Qgis::NavigationMode mode );
|
||||
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent *ev ) override;
|
||||
|
||||
/**
|
||||
* Manages the display events specified in e.
|
||||
*/
|
||||
void showEvent( QShowEvent *e ) override;
|
||||
|
||||
/**
|
||||
* Resets the aspect ratio of the 3D window.
|
||||
*/
|
||||
void resizeEvent( QResizeEvent * ) override;
|
||||
|
||||
|
||||
|
||||
bool eventFilter( QObject *watched, QEvent *event ) override;
|
||||
|
||||
private:
|
||||
|
||||
Qt3DCore::QAspectEngine *m_aspectEngine;
|
||||
|
||||
// Aspects
|
||||
Qt3DRender::QRenderAspect *m_renderAspect;
|
||||
Qt3DInput::QInputAspect *m_inputAspect;
|
||||
Qt3DLogic::QLogicAspect *m_logicAspect;
|
||||
|
||||
// Renderer configuration
|
||||
Qt3DRender::QRenderSettings *m_renderSettings;
|
||||
Qt3DExtras::QForwardRenderer *m_forwardRenderer;
|
||||
Qt3DRender::QCamera *m_defaultCamera;
|
||||
|
||||
// Input configuration
|
||||
Qt3DInput::QInputSettings *m_inputSettings;
|
||||
|
||||
// Scene
|
||||
Qt3DCore::QEntity *m_root;
|
||||
Qt3DCore::QEntity *m_userRoot;
|
||||
|
||||
bool m_initialized;
|
||||
|
||||
|
||||
|
||||
|
||||
QgsWindow3DEngine *mEngine = nullptr;
|
||||
|
||||
//! Description of the 3D scene
|
||||
@ -162,4 +283,4 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWidget
|
||||
QgsTemporalController *mTemporalController = nullptr;
|
||||
};
|
||||
|
||||
#endif // QGS3DMAPCANVAS_H
|
||||
#endif //QGS3DMAPCANVAS_H
|
||||
|
@ -1193,7 +1193,7 @@ void Qgs3DMapScene::on3DAxisSettingsChanged()
|
||||
{
|
||||
if ( QgsWindow3DEngine *engine = dynamic_cast<QgsWindow3DEngine *>( mEngine ) )
|
||||
{
|
||||
m3DAxis = new Qgs3DAxis( static_cast<Qgs3DWindow *>( engine->window() ),
|
||||
m3DAxis = new Qgs3DAxis( static_cast<Qgs3DMapCanvas *>( engine->window() ),
|
||||
engine->root(),
|
||||
this,
|
||||
mCameraController,
|
||||
|
@ -1,119 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgs3dwindow.cpp
|
||||
--------------------------------------
|
||||
Date : May 2023
|
||||
Copyright : (C) 2023 by Jean-Baptiste Peter
|
||||
Email : jbpeter at outlook dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <Qt3DCore/QAspectEngine>
|
||||
#include <Qt3DCore/QEntity>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <Qt3DCore/QCoreAspect>
|
||||
#endif
|
||||
#include <Qt3DExtras/QForwardRenderer>
|
||||
#include <Qt3DRender/QRenderSettings>
|
||||
#include <Qt3DRender/QRenderAspect>
|
||||
#include <Qt3DInput/QInputAspect>
|
||||
#include <Qt3DInput/QInputSettings>
|
||||
#include <Qt3DLogic/QLogicAspect>
|
||||
#include <Qt3DRender/QCamera>
|
||||
|
||||
#include "qgs3dwindow.h"
|
||||
|
||||
Qgs3DWindow::Qgs3DWindow()
|
||||
: m_aspectEngine( new Qt3DCore::QAspectEngine )
|
||||
, m_renderAspect( new Qt3DRender::QRenderAspect )
|
||||
, m_inputAspect( new Qt3DInput::QInputAspect )
|
||||
, m_logicAspect( new Qt3DLogic::QLogicAspect )
|
||||
, m_renderSettings( new Qt3DRender::QRenderSettings )
|
||||
, m_forwardRenderer( new Qt3DExtras::QForwardRenderer )
|
||||
, m_defaultCamera( new Qt3DRender::QCamera )
|
||||
, m_inputSettings( new Qt3DInput::QInputSettings )
|
||||
, m_root( new Qt3DCore::QEntity )
|
||||
, m_userRoot( nullptr )
|
||||
, m_initialized( false )
|
||||
{
|
||||
setSurfaceType( QSurface::OpenGLSurface );
|
||||
|
||||
// register aspects
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
m_aspectEngine->registerAspect( new Qt3DCore::QCoreAspect );
|
||||
#endif
|
||||
m_aspectEngine->registerAspect( m_renderAspect );
|
||||
m_aspectEngine->registerAspect( m_inputAspect );
|
||||
m_aspectEngine->registerAspect( m_logicAspect );
|
||||
|
||||
m_defaultCamera->setParent( m_root );
|
||||
m_forwardRenderer->setCamera( m_defaultCamera );
|
||||
m_forwardRenderer->setSurface( this );
|
||||
m_renderSettings->setActiveFrameGraph( m_forwardRenderer );
|
||||
m_inputSettings->setEventSource( this );
|
||||
}
|
||||
|
||||
Qgs3DWindow::~Qgs3DWindow()
|
||||
{
|
||||
delete m_aspectEngine;
|
||||
}
|
||||
|
||||
void Qgs3DWindow::setRootEntity( Qt3DCore::QEntity *root )
|
||||
{
|
||||
if ( m_userRoot != root )
|
||||
{
|
||||
if ( m_userRoot != nullptr )
|
||||
m_userRoot->setParent( static_cast<Qt3DCore::QNode *>( nullptr ) );
|
||||
if ( root != nullptr )
|
||||
root->setParent( m_root );
|
||||
m_userRoot = root;
|
||||
}
|
||||
}
|
||||
|
||||
void Qgs3DWindow::setActiveFrameGraph( Qt3DRender::QFrameGraphNode *activeFrameGraph )
|
||||
{
|
||||
m_renderSettings->setActiveFrameGraph( activeFrameGraph );
|
||||
}
|
||||
|
||||
Qt3DRender::QFrameGraphNode *Qgs3DWindow::activeFrameGraph() const
|
||||
{
|
||||
return m_renderSettings->activeFrameGraph();
|
||||
}
|
||||
|
||||
Qt3DExtras::QForwardRenderer *Qgs3DWindow::defaultFrameGraph() const
|
||||
{
|
||||
return m_forwardRenderer;
|
||||
}
|
||||
|
||||
Qt3DRender::QCamera *Qgs3DWindow::camera() const
|
||||
{
|
||||
return m_defaultCamera;
|
||||
}
|
||||
|
||||
Qt3DRender::QRenderSettings *Qgs3DWindow::renderSettings() const
|
||||
{
|
||||
return m_renderSettings;
|
||||
}
|
||||
|
||||
void Qgs3DWindow::showEvent( QShowEvent *e )
|
||||
{
|
||||
if ( !m_initialized )
|
||||
{
|
||||
m_root->addComponent( m_renderSettings );
|
||||
m_root->addComponent( m_inputSettings );
|
||||
m_aspectEngine->setRootEntity( Qt3DCore::QEntityPtr( m_root ) );
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
QWindow::showEvent( e );
|
||||
}
|
||||
|
||||
void Qgs3DWindow::resizeEvent( QResizeEvent * )
|
||||
{
|
||||
m_defaultCamera->setAspectRatio( float( width() ) / std::max( 1.f, static_cast<float>( height() ) ) );
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgs3dwindow.h
|
||||
--------------------------------------
|
||||
Date : May 2023
|
||||
Copyright : (C) 2023 by Jean-Baptiste Peter
|
||||
Email : jbpeter at outlook dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGS3DWINDOW_H
|
||||
#define QGS3DWINDOW_H
|
||||
|
||||
#include "qgis_3d.h"
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
#ifndef SIP_RUN
|
||||
namespace Qt3DCore
|
||||
{
|
||||
class QAspectEngine;
|
||||
class QAbstractAspect;
|
||||
class QEntity;
|
||||
}
|
||||
|
||||
namespace Qt3DRender
|
||||
{
|
||||
class QCamera;
|
||||
class QFrameGraphNode;
|
||||
class QRenderAspect;
|
||||
class QRenderSettings;
|
||||
}
|
||||
|
||||
namespace Qt3DExtras
|
||||
{
|
||||
class QForwardRenderer;
|
||||
}
|
||||
|
||||
namespace Qt3DInput
|
||||
{
|
||||
class QInputAspect;
|
||||
class QInputSettings;
|
||||
}
|
||||
|
||||
namespace Qt3DLogic
|
||||
{
|
||||
class QLogicAspect;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup 3d
|
||||
* \brief qgs3dWindow is a convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.
|
||||
*
|
||||
* \note This is a port of qtwindow3d which does not set the default surface when initialized.
|
||||
* \note The default surface must be set before the construction of the QApplication when using shared OpenGL context.
|
||||
* \note This is required in order to use QT3d and QtWebEngine at the same time.
|
||||
*
|
||||
* \since QGIS 3.36
|
||||
*/
|
||||
class _3D_EXPORT Qgs3DWindow : public QWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for Qgs3DWindow.
|
||||
*/
|
||||
Qgs3DWindow();
|
||||
|
||||
/**
|
||||
* Destructor for Qgs3DWindow.
|
||||
*/
|
||||
~Qgs3DWindow();
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
/**
|
||||
* Sets the specified root entity of the scene.
|
||||
*/
|
||||
void setRootEntity( Qt3DCore::QEntity *root );
|
||||
|
||||
/**
|
||||
* Activates the specified activeFrameGraph.
|
||||
*/
|
||||
void setActiveFrameGraph( Qt3DRender::QFrameGraphNode *activeFrameGraph );
|
||||
|
||||
/**
|
||||
* Returns the node of the active frame graph.
|
||||
*/
|
||||
Qt3DRender::QFrameGraphNode *activeFrameGraph() const;
|
||||
|
||||
/**
|
||||
* Returns the node of the default framegraph
|
||||
*/
|
||||
Qt3DExtras::QForwardRenderer *defaultFrameGraph() const;
|
||||
|
||||
/**
|
||||
* Returns the default camera of the 3D Window.
|
||||
*/
|
||||
Qt3DRender::QCamera *camera() const;
|
||||
|
||||
/**
|
||||
* Returns the render settings of the 3D Window.
|
||||
*/
|
||||
Qt3DRender::QRenderSettings *renderSettings() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Manages the display events specified in e.
|
||||
*/
|
||||
void showEvent( QShowEvent *e ) override;
|
||||
|
||||
/**
|
||||
* Resets the aspect ratio of the 3D window.
|
||||
*/
|
||||
void resizeEvent( QResizeEvent * ) override;
|
||||
|
||||
private:
|
||||
|
||||
Qt3DCore::QAspectEngine *m_aspectEngine;
|
||||
|
||||
// Aspects
|
||||
Qt3DRender::QRenderAspect *m_renderAspect;
|
||||
Qt3DInput::QInputAspect *m_inputAspect;
|
||||
Qt3DLogic::QLogicAspect *m_logicAspect;
|
||||
|
||||
// Renderer configuration
|
||||
Qt3DRender::QRenderSettings *m_renderSettings;
|
||||
Qt3DExtras::QForwardRenderer *m_forwardRenderer;
|
||||
Qt3DRender::QCamera *m_defaultCamera;
|
||||
|
||||
// Input configuration
|
||||
Qt3DInput::QInputSettings *m_inputSettings;
|
||||
|
||||
// Scene
|
||||
Qt3DCore::QEntity *m_root;
|
||||
Qt3DCore::QEntity *m_userRoot;
|
||||
|
||||
bool m_initialized;
|
||||
};
|
||||
|
||||
#endif //QGS3DWINDOW_H
|
@ -20,12 +20,12 @@
|
||||
#include <Qt3DRender/QRenderSettings>
|
||||
|
||||
#include "qgspreviewquad.h"
|
||||
#include "qgs3dwindow.h"
|
||||
#include "qgs3dmapcanvas.h"
|
||||
|
||||
QgsWindow3DEngine::QgsWindow3DEngine( QObject *parent )
|
||||
QgsWindow3DEngine::QgsWindow3DEngine( Qgs3DMapCanvas *parent )
|
||||
: QgsAbstract3DEngine( parent )
|
||||
{
|
||||
mWindow3D = new Qgs3DWindow;
|
||||
mWindow3D = parent;
|
||||
|
||||
mRoot = new Qt3DCore::QEntity;
|
||||
mWindow3D->setRootEntity( mRoot );
|
||||
|
@ -32,7 +32,7 @@ namespace Qt3DExtras
|
||||
}
|
||||
|
||||
|
||||
class Qgs3DWindow;
|
||||
class Qgs3DMapCanvas;
|
||||
class QWindow;
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ class _3D_EXPORT QgsWindow3DEngine : public QgsAbstract3DEngine
|
||||
/**
|
||||
* Constructor for QgsWindow3DEngine with the specified \a parent object.
|
||||
*/
|
||||
QgsWindow3DEngine( QObject *parent = nullptr );
|
||||
QgsWindow3DEngine( Qgs3DMapCanvas *parent = nullptr );
|
||||
|
||||
//! Returns the internal 3D window where all the rendered output is displayed
|
||||
QWindow *window();
|
||||
@ -80,7 +80,7 @@ class _3D_EXPORT QgsWindow3DEngine : public QgsAbstract3DEngine
|
||||
void setSize( QSize s ) override;
|
||||
private:
|
||||
//! 3D window with all the 3D magic inside
|
||||
Qgs3DWindow *mWindow3D = nullptr;
|
||||
Qgs3DMapCanvas *mWindow3D = nullptr;
|
||||
//! Frame graph node for render capture
|
||||
bool mShadowRenderingEnabled = false;
|
||||
Qt3DCore::QEntity *mRoot = nullptr;
|
||||
|
@ -208,9 +208,8 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
connect( configureAction, &QAction::triggered, this, &Qgs3DMapCanvasWidget::configure );
|
||||
mOptionsMenu->addAction( configureAction );
|
||||
|
||||
mCanvas = new Qgs3DMapCanvas( this );
|
||||
mCanvas = new Qgs3DMapCanvas;
|
||||
mCanvas->setMinimumSize( QSize( 200, 200 ) );
|
||||
mCanvas->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
|
||||
connect( mCanvas, &Qgs3DMapCanvas::savedAsImage, this, [ = ]( const QString & fileName )
|
||||
{
|
||||
@ -263,7 +262,8 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
layout->addLayout( topLayout );
|
||||
layout->addWidget( mMessageBar );
|
||||
|
||||
mContainer = QWidget::createWindowContainer( mCanvas->engine()->window() );
|
||||
// mContainer takes ownership of Qgs3DMapCanvas
|
||||
mContainer = QWidget::createWindowContainer( mCanvas );
|
||||
mContainer->setMinimumSize( QSize( 200, 200 ) );
|
||||
mContainer->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
mNavigationWidget = new Qgs3DNavigationWidget( mCanvas );
|
||||
@ -277,17 +277,6 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
QRect viewportRect( QPoint( 0, 0 ), mContainer->size() );
|
||||
mCanvas->engine()->setSize( viewportRect.size() );
|
||||
|
||||
// Connect the camera to the navigation widget.
|
||||
connect( mCanvas->cameraController(), &QgsCameraController::cameraChanged, mNavigationWidget, &Qgs3DNavigationWidget::updateFromCamera );
|
||||
|
||||
connect( mNavigationWidget, &Qgs3DNavigationWidget::sizeChanged, this, [&]( const QSize & newSize )
|
||||
{
|
||||
QSize widgetSize = size();
|
||||
QRect viewportRect( QPoint( 0, 0 ), QSize( widgetSize.width() - newSize.width(), widgetSize.height() ) );
|
||||
mCanvas->engine()->setSize( viewportRect.size() );
|
||||
} );
|
||||
|
||||
|
||||
toggleNavigationWidget(
|
||||
setting.value( QStringLiteral( "/3D/navigationWidget/visibility" ), false, QgsSettings::Gui ).toBool()
|
||||
);
|
||||
@ -402,6 +391,8 @@ void Qgs3DMapCanvasWidget::setMapSettings( Qgs3DMapSettings *map )
|
||||
|
||||
mCanvas->setMap( map );
|
||||
|
||||
// Connect the camera to the navigation widget.
|
||||
connect( mCanvas->cameraController(), &QgsCameraController::cameraChanged, mNavigationWidget, &Qgs3DNavigationWidget::updateFromCamera );
|
||||
connect( mCanvas->scene(), &Qgs3DMapScene::totalPendingJobsCountChanged, this, &Qgs3DMapCanvasWidget::onTotalPendingJobsCountChanged );
|
||||
connect( mCanvas->scene(), &Qgs3DMapScene::gpuMemoryLimitReached, this, &Qgs3DMapCanvasWidget::onGpuMemoryLimitReached );
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "qgs3dmaptoolidentify.h"
|
||||
|
||||
#include <QScreen>
|
||||
|
||||
#include "qgsapplication.h"
|
||||
#include "qgs3dmapcanvas.h"
|
||||
#include "qgs3dmapscene.h"
|
||||
@ -107,7 +109,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event )
|
||||
// estimate search radius
|
||||
Qgs3DMapScene *scene = mCanvas->scene();
|
||||
const double searchRadiusMM = QgsMapTool::searchRadiusMM();
|
||||
const double pixelsPerMM = mCanvas->logicalDpiX() / 25.4;
|
||||
const double pixelsPerMM = mCanvas->screen()->logicalDotsPerInchX(); // mCanvas->logicalDpiX() / 25.4;
|
||||
const double searchRadiusPx = searchRadiusMM * pixelsPerMM;
|
||||
const double searchRadiusMapUnits = scene->worldSpaceError( searchRadiusPx, hit.distance );
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "qgshelp.h"
|
||||
|
||||
Qgs3DMeasureDialog::Qgs3DMeasureDialog( Qgs3DMapToolMeasureLine *tool, Qt::WindowFlags f )
|
||||
: QDialog( tool->canvas()->topLevelWidget(), f )
|
||||
: QDialog( nullptr, f ) //TODO: parent?
|
||||
, mTool( tool )
|
||||
{
|
||||
setupUi( this );
|
||||
|
@ -171,23 +171,3 @@ void Qgs3DNavigationWidget::updateFromCamera()
|
||||
mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 6, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->lookingAtPoint().y() ) );
|
||||
mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 7, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->lookingAtPoint().z() ) );
|
||||
}
|
||||
|
||||
void Qgs3DNavigationWidget::resizeEvent( QResizeEvent *ev )
|
||||
{
|
||||
QWidget::resizeEvent( ev );
|
||||
|
||||
QSize size = ev->size();
|
||||
emit sizeChanged( size );
|
||||
}
|
||||
|
||||
void Qgs3DNavigationWidget::hideEvent( QHideEvent *ev )
|
||||
{
|
||||
QWidget::hideEvent( ev );
|
||||
emit sizeChanged( QSize( 0, 0 ) );
|
||||
}
|
||||
|
||||
void Qgs3DNavigationWidget::showEvent( QShowEvent *ev )
|
||||
{
|
||||
QWidget::showEvent( ev );
|
||||
emit sizeChanged( size() );
|
||||
}
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef QGS3DNAVIGATIONWIDGET_H
|
||||
#define QGS3DNAVIGATIONWIDGET_H
|
||||
|
||||
class QHideEvent;
|
||||
class QResizeEvent;
|
||||
class QShowEvent;
|
||||
class QSize;
|
||||
class QStandardItemModel;
|
||||
|
||||
class Qgs3DMapCanvas;
|
||||
@ -40,14 +36,6 @@ class Qgs3DNavigationWidget : public QWidget, private Ui::Q3DNavigationWidget
|
||||
*/
|
||||
void updateFromCamera();
|
||||
|
||||
signals:
|
||||
void sizeChanged( const QSize &newSize );
|
||||
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent *event ) override;
|
||||
void hideEvent( QHideEvent *event ) override;
|
||||
void showEvent( QShowEvent *event ) override;
|
||||
|
||||
private:
|
||||
Qgs3DMapCanvas *m3DMapCanvas = nullptr;
|
||||
QStandardItemModel *mCameraInfoItemModel = nullptr;
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "qgisapp.h"
|
||||
#include "qgsnewnamedialog.h"
|
||||
#include "qgs3dmapcanvas.h"
|
||||
#include "qgsmapviewsmanager.h"
|
||||
#include "qgs3dmapcanvaswidget.h"
|
||||
#include "qgsdockablewidgethelper.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user