From fa7e3d4f7d0ea054e88a3cc53619c4da67d0b18a Mon Sep 17 00:00:00 2001 From: Belgacem Date: Tue, 12 Jan 2021 02:58:54 +0100 Subject: [PATCH] fix sip and add Nyall suggestions --- .../auto_generated/geometry/qgsray3d.sip.in | 74 +++++++++++++++++++ python/core/core_auto.sip | 1 + .../auto_generated/qgsmaptoolidentify.sip.in | 10 --- src/3d/qgs3dmapscene.cpp | 4 +- src/app/3d/qgs3dmaptoolidentify.cpp | 2 +- src/core/geometry/qgsray3d.h | 1 + .../pointcloud/qgspointclouddataprovider.cpp | 2 +- src/gui/qgsmaptoolidentify.h | 2 +- 8 files changed, 81 insertions(+), 15 deletions(-) create mode 100644 python/core/auto_generated/geometry/qgsray3d.sip.in diff --git a/python/core/auto_generated/geometry/qgsray3d.sip.in b/python/core/auto_generated/geometry/qgsray3d.sip.in new file mode 100644 index 00000000000..edbed25523a --- /dev/null +++ b/python/core/auto_generated/geometry/qgsray3d.sip.in @@ -0,0 +1,74 @@ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/geometry/qgsray3d.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + +class QgsRay3D +{ +%Docstring +A representation of a ray in 3D. + +A ray is composed of an origin point (the start of the ray) and a direction vector. + +.. versionadded:: 3.18 +%End + +%TypeHeaderCode +#include "qgsray3d.h" +%End + public: + QgsRay3D( const QVector3D &origin, const QVector3D &direction ); +%Docstring +Constructor +%End + + QVector3D origin() const; +%Docstring +Returns the origin of the ray +%End + QVector3D direction() const; +%Docstring +Returns the direction of the ray +%End + + void setOrigin( const QVector3D &origin ); +%Docstring +Sets the origin of the ray +%End + void setDirection( const QVector3D direction ); +%Docstring +Sets the direction of the ray +%End + + QVector3D projectedPoint( const QVector3D &point ) const; +%Docstring +Returns the projection of the point on the ray +(which is the closest point of the ray to ``point``) +%End + bool intersectsWith( const QgsBox3d &box ) const; +%Docstring +Checks whether the ray intersects with ``box`` +%End + bool isInFront( const QVector3D &point ) const; +%Docstring +Checks whether the point is in front of the ray +%End + double angleToPoint( const QVector3D &point ) const; +%Docstring +Returns the angle between the ray and the vector from the ray's origin and the point ``point`` +%End + +}; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/geometry/qgsray3d.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/python/core/core_auto.sip b/python/core/core_auto.sip index 9ba71572e93..1d641e575cd 100644 --- a/python/core/core_auto.sip +++ b/python/core/core_auto.sip @@ -316,6 +316,7 @@ %Include auto_generated/geometry/qgstriangle.sip %Include auto_generated/geometry/qgswkbptr.sip %Include auto_generated/geometry/qgswkbtypes.sip +%Include auto_generated/geometry/qgsray3d.sip %Include auto_generated/gps/qgsgpsconnection.sip %Include auto_generated/gps/qgsgpsdconnection.sip %Include auto_generated/gps/qgsgpsdetector.sip diff --git a/python/gui/auto_generated/qgsmaptoolidentify.sip.in b/python/gui/auto_generated/qgsmaptoolidentify.sip.in index 430fd571d83..c5c3d1e4182 100644 --- a/python/gui/auto_generated/qgsmaptoolidentify.sip.in +++ b/python/gui/auto_generated/qgsmaptoolidentify.sip.in @@ -130,16 +130,6 @@ Returns a pointer to the identify menu which will be used in layer selection mod this menu can also be customized %End - static void fromPointCloudIdentificationToIdentifyResults( QgsPointCloudLayer *layer, const QVector &identified, QList &results ); -%Docstring -Converts point cloud identification results from variant maps to QgsMapToolIdentify.IdentifyResult and apply some formatting - -.. note:: - - : the converted variant maps are pushed at the back of ``results`` without cleaning what's in it previously - -.. versionadded:: 3.18 -%End public slots: void formatChanged( QgsRasterLayer *layer ); diff --git a/src/3d/qgs3dmapscene.cpp b/src/3d/qgs3dmapscene.cpp index 2d8f689e333..0197cbfa2d2 100644 --- a/src/3d/qgs3dmapscene.cpp +++ b/src/3d/qgs3dmapscene.cpp @@ -1120,12 +1120,12 @@ void Qgs3DMapScene::identifyPointCloudOnRay( QVectortype() != QgsMapLayerType::PointCloudLayer ) continue; - if ( QgsPointCloudLayer *pc = dynamic_cast( layer ) ) + if ( QgsPointCloudLayer *pc = qobject_cast( layer ) ) { QgsPointCloudLayer3DRenderer *renderer = dynamic_cast( pc->renderer3D() ); const QgsPointCloud3DSymbol *symbol = renderer->symbol(); // Symbol can be null in case of no rendering enabled - if ( symbol == nullptr ) + if ( !symbol ) continue; double maxScreenError = renderer->maximumScreenError(); double pointSize = symbol->pointSize(); diff --git a/src/app/3d/qgs3dmaptoolidentify.cpp b/src/app/3d/qgs3dmaptoolidentify.cpp index 328c94a7e74..0af1f667faa 100644 --- a/src/app/3d/qgs3dmaptoolidentify.cpp +++ b/src/app/3d/qgs3dmaptoolidentify.cpp @@ -98,7 +98,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event ) QList identifyResults; for ( int i = 0; i < layerPoints.size(); ++i ) { - QgsPointCloudLayer *pcLayer = dynamic_cast< QgsPointCloudLayer * >( layerPoints[i].first ); + QgsPointCloudLayer *pcLayer = qobject_cast< QgsPointCloudLayer * >( layerPoints[i].first ); QgsMapToolIdentify::fromPointCloudIdentificationToIdentifyResults( pcLayer, layerPoints[i].second, identifyResults ); } diff --git a/src/core/geometry/qgsray3d.h b/src/core/geometry/qgsray3d.h index 9d1d76a37de..0802b8a4643 100644 --- a/src/core/geometry/qgsray3d.h +++ b/src/core/geometry/qgsray3d.h @@ -30,6 +30,7 @@ class CORE_EXPORT QgsRay3D { public: + //! Constructor QgsRay3D( const QVector3D &origin, const QVector3D &direction ); //! Returns the origin of the ray diff --git a/src/core/pointcloud/qgspointclouddataprovider.cpp b/src/core/pointcloud/qgspointclouddataprovider.cpp index 99a68342dc0..4f114c7447d 100644 --- a/src/core/pointcloud/qgspointclouddataprovider.cpp +++ b/src/core/pointcloud/qgspointclouddataprovider.cpp @@ -457,7 +457,7 @@ QVector QgsPointCloudDataProvider::getPointsOnRay( const QgsRay3D & pointAttr[ QStringLiteral( "X" ) ] = x; pointAttr[ QStringLiteral( "Y" ) ] = y; pointAttr[ QStringLiteral( "Z" ) ] = z; - pointAttr[ QStringLiteral( "Distance to camera" ) ] = ( point - ray.origin() ).length(); + pointAttr[ tr( "Distance to camera" ) ] = ( point - ray.origin() ).length(); points.push_back( pointAttr ); } } diff --git a/src/gui/qgsmaptoolidentify.h b/src/gui/qgsmaptoolidentify.h index 2177aa0501d..b69b0da3e57 100644 --- a/src/gui/qgsmaptoolidentify.h +++ b/src/gui/qgsmaptoolidentify.h @@ -152,7 +152,7 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool * \note : the converted variant maps are pushed at the back of \a results without cleaning what's in it previously * \since QGIS 3.18 */ - static void fromPointCloudIdentificationToIdentifyResults( QgsPointCloudLayer *layer, const QVector &identified, QList &results ); + static void fromPointCloudIdentificationToIdentifyResults( QgsPointCloudLayer *layer, const QVector &identified, QList &results ) SIP_SKIP; public slots: void formatChanged( QgsRasterLayer *layer );