Compare commits

...

3 Commits

Author SHA1 Message Date
Stefanos Natsis
03506d5680
Merge 5b86bec5e868d825131eab171f9a8040de44a9c2 into 5f320b436969edf5b21b3583747d406a05a6f949 2025-09-30 22:19:40 +02:00
uclaros
5b86bec5e8 Change 3d sip split parts 2025-09-30 16:35:10 +03:00
uclaros
47c1a0ad60 expose 3d map tools to python 2025-09-30 12:08:09 +03:00
11 changed files with 252 additions and 16 deletions

View File

@ -3,6 +3,7 @@
%Include auto_generated/qgs3d.sip
%Include auto_generated/qgs3dmapscene.sip
%Include auto_generated/qgs3dmapsettings.sip
%Include auto_generated/qgs3dmaptool.sip
%Include auto_generated/qgs3dtypes.sip
%Include auto_generated/qgs3dmapcanvas.sip
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip

View File

@ -0,0 +1,5 @@
# The following has been generated automatically from src/3d/qgs3dmaptool.h
try:
Qgs3DMapTool.__virtual_methods__ = ['mousePressEvent', 'mouseReleaseEvent', 'mouseMoveEvent', 'keyPressEvent', 'keyReleaseEvent', 'mouseWheelEvent', 'activate', 'deactivate', 'cursor']
except (NameError, AttributeError):
pass

View File

@ -58,6 +58,23 @@ scene has not been initialized yet with
:py:func:`~Qgs3DMapCanvas.setMapSettings`
%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.
.. versionadded:: 4.0
%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.
.. versionadded:: 4.0
%End
protected:
virtual void showEvent( QShowEvent *e );

View File

@ -0,0 +1,95 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgs3dmaptool.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class Qgs3DMapTool : QObject
{
%Docstring(signature="appended")
Base class for map tools operating on 3D map canvas.
.. note::
Not available in Python bindings
.. versionadded:: 4.0
%End
%TypeHeaderCode
#include "qgs3dmaptool.h"
%End
public:
Qgs3DMapTool( Qgs3DMapCanvas *canvas );
%Docstring
Base constructor for a Qgs3DMapTool for the specified ``canvas``
%End
virtual void mousePressEvent( QMouseEvent *event );
%Docstring
Reimplement to handle mouse ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void mouseReleaseEvent( QMouseEvent *event );
%Docstring
Reimplement to handle mouse release ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void mouseMoveEvent( QMouseEvent *event );
%Docstring
Reimplement to handle mouse move ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void keyPressEvent( QKeyEvent *event );
%Docstring
Reimplement to handle key press ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void keyReleaseEvent( QKeyEvent *event );
%Docstring
Reimplement to handle key release ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void mouseWheelEvent( QWheelEvent *event );
%Docstring
Reimplement to handle mouse wheel ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
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
Qgs3DMapCanvas *canvas();
%Docstring
Returns the parent Qgs3DMapCanvas
%End
protected:
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgs3dmaptool.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/

View File

@ -262,7 +262,7 @@ if (WITH_3D)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/3d/project.py.in ${CMAKE_CURRENT_BINARY_DIR}/3d/project.py @ONLY)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/3d/pyproject.toml.temp" "${toml}")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/3d/pyproject.toml.temp ${CMAKE_CURRENT_BINARY_DIR}/3d/pyproject.toml)
SET(SIP_CONCAT_PARTS 10) # 3D doesn't have enough .sip files to fill 15+ .cpp files
SET(SIP_CONCAT_PARTS 9) # 3D doesn't have enough .sip files to fill 15+ .cpp files
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._3d_p 3d/3d.sip "${sip_files_3d}" cpp_files)
BUILD_SIP_PYTHON_MODULE(qgis._3d_p 3d/3d.sip ${cpp_files} "" qgis_core qgis_3d)
endif()

View File

@ -3,6 +3,7 @@
%Include auto_generated/qgs3d.sip
%Include auto_generated/qgs3dmapscene.sip
%Include auto_generated/qgs3dmapsettings.sip
%Include auto_generated/qgs3dmaptool.sip
%Include auto_generated/qgs3dtypes.sip
%Include auto_generated/qgs3dmapcanvas.sip
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip

View File

@ -0,0 +1,5 @@
# The following has been generated automatically from src/3d/qgs3dmaptool.h
try:
Qgs3DMapTool.__virtual_methods__ = ['mousePressEvent', 'mouseReleaseEvent', 'mouseMoveEvent', 'keyPressEvent', 'keyReleaseEvent', 'mouseWheelEvent', 'activate', 'deactivate', 'cursor']
except (NameError, AttributeError):
pass

View File

@ -58,6 +58,23 @@ scene has not been initialized yet with
:py:func:`~Qgs3DMapCanvas.setMapSettings`
%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.
.. versionadded:: 4.0
%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.
.. versionadded:: 4.0
%End
protected:
virtual void showEvent( QShowEvent *e );

View File

@ -0,0 +1,95 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgs3dmaptool.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class Qgs3DMapTool : QObject
{
%Docstring(signature="appended")
Base class for map tools operating on 3D map canvas.
.. note::
Not available in Python bindings
.. versionadded:: 4.0
%End
%TypeHeaderCode
#include "qgs3dmaptool.h"
%End
public:
Qgs3DMapTool( Qgs3DMapCanvas *canvas );
%Docstring
Base constructor for a Qgs3DMapTool for the specified ``canvas``
%End
virtual void mousePressEvent( QMouseEvent *event );
%Docstring
Reimplement to handle mouse ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void mouseReleaseEvent( QMouseEvent *event );
%Docstring
Reimplement to handle mouse release ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void mouseMoveEvent( QMouseEvent *event );
%Docstring
Reimplement to handle mouse move ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void keyPressEvent( QKeyEvent *event );
%Docstring
Reimplement to handle key press ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void keyReleaseEvent( QKeyEvent *event );
%Docstring
Reimplement to handle key release ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
virtual void mouseWheelEvent( QWheelEvent *event );
%Docstring
Reimplement to handle mouse wheel ``event`` forwarded by the parent
Qgs3DMapCanvas
%End
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
Qgs3DMapCanvas *canvas();
%Docstring
Returns the parent Qgs3DMapCanvas
%End
protected:
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgs3dmaptool.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/

View File

@ -95,6 +95,20 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWindow
//! Returns access to the view's camera controller. Returns NULLPTR if the scene has not been initialized yet with setMapSettings()
QgsCameraController *cameraController();
/**
* Sets the active map \a tool that will receive events from the 3D canvas. Does not transfer ownership.
* If the tool is NULLPTR, events will be used for camera manipulation.
* \since QGIS 4.0
*/
void setMapTool( Qgs3DMapTool *tool );
/**
* Returns the active map tool that will receive events from the 3D canvas.
* If the tool is NULLPTR, events will be used for camera manipulation.
* \since QGIS 4.0
*/
Qgs3DMapTool *mapTool() const { return mMapTool; }
#ifndef SIP_RUN
/**
@ -134,18 +148,6 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWindow
//! Saves the current scene as an image
void saveAsImage( const QString &fileName, const QString &fileFormat );
/**
* Sets the active map \a tool that will receive events from the 3D canvas. Does not transfer ownership.
* If the tool is NULLPTR, events will be used for camera manipulation.
*/
void setMapTool( Qgs3DMapTool *tool );
/**
* Returns the active map tool that will receive events from the 3D canvas.
* If the tool is NULLPTR, events will be used for camera manipulation.
*/
Qgs3DMapTool *mapTool() const { return mMapTool; }
/**
* Returns the 3D engine.
*/

View File

@ -25,14 +25,12 @@ class QMouseEvent;
class QKeyEvent;
class QWheelEvent;
#define SIP_NO_FILE
/**
* \ingroup qgis_3d
* \brief Base class for map tools operating on 3D map canvas.
* \note Not available in Python bindings
* \since QGIS 3.36 (since QGIS 3.4 in QGIS_APP library)
* \since QGIS 4.0 (since QGIS 3.36 in QGIS_3D library, since QGIS 3.4 in QGIS_APP library)
*/
class _3D_EXPORT Qgs3DMapTool : public QObject
{