diff --git a/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.cpp b/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.cpp index 4de27187948..6a53f39d079 100644 --- a/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.cpp +++ b/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.cpp @@ -36,32 +36,26 @@ Qgs3DMapToolPointCloudChangeAttributePolygon::~Qgs3DMapToolPointCloudChangeAttri void Qgs3DMapToolPointCloudChangeAttributePolygon::mousePressEvent( QMouseEvent *event ) { - if ( !mIsMoving ) - { - mClickPoint = event->pos(); - } + mClickPoint = event->pos(); } void Qgs3DMapToolPointCloudChangeAttributePolygon::mouseMoveEvent( QMouseEvent *event ) { - if ( !mIsMoving ) + if ( mToolType != Polygon && mScreenPoints.size() == 2 ) + return; + const QgsPoint movedPoint = Qgs3DUtils::screenPointToMapCoordinates( event->pos(), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() ); + if ( mToolType == Polygon ) { - if ( mToolType != Polygon && mScreenPoints.size() == 2 ) - return; - const QgsPoint movedPoint = Qgs3DUtils::screenPointToMapCoordinates( event->pos(), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() ); - if ( mToolType == Polygon ) + mPolygonRubberBand->moveLastPoint( movedPoint ); + } + else + { + mLineRubberBand->moveLastPoint( movedPoint ); + if ( !mPolygonRubberBand->isEmpty() ) { - mPolygonRubberBand->moveLastPoint( movedPoint ); - } - else - { - mLineRubberBand->moveLastPoint( movedPoint ); - if ( !mPolygonRubberBand->isEmpty() ) - { - mPolygonRubberBand->removeLastPoint(); - mPolygonRubberBand->moveLastPoint( Qgs3DUtils::screenPointToMapCoordinates( QPoint( event->x(), mToolType == AboveLinePolygon ? 0 : mCanvas->height() ), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() ) ); - mPolygonRubberBand->addPoint( movedPoint ); - } + mPolygonRubberBand->removeLastPoint(); + mPolygonRubberBand->moveLastPoint( Qgs3DUtils::screenPointToMapCoordinates( QPoint( event->x(), mToolType == AboveLinePolygon ? 0 : mCanvas->height() ), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() ) ); + mPolygonRubberBand->addPoint( movedPoint ); } } } @@ -90,17 +84,11 @@ void Qgs3DMapToolPointCloudChangeAttributePolygon::keyPressEvent( QKeyEvent *eve { restart(); } - else if ( event->key() == Qt::Key_Space ) - { - const bool newState = !mCanvas->cameraController()->hasInputHandlersEnabled(); - mCanvas->cameraController()->setInputHandlersEnabled( newState ); - mIsMoving = newState; - } } void Qgs3DMapToolPointCloudChangeAttributePolygon::mouseReleaseEvent( QMouseEvent *event ) { - if ( ( event->pos() - mClickPoint ).manhattanLength() > QApplication::startDragDistance() || mIsMoving ) + if ( ( event->pos() - mClickPoint ).manhattanLength() > QApplication::startDragDistance() ) return; const QgsPoint newPoint = Qgs3DUtils::screenPointToMapCoordinates( event->pos(), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() ); diff --git a/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.h b/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.h index ceed648c65f..367c93586bc 100644 --- a/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.h +++ b/src/app/3d/qgs3dmaptoolpointcloudchangeattributepolygon.h @@ -28,19 +28,19 @@ class Qgs3DMapToolPointCloudChangeAttributePolygon : public Qgs3DMapToolPointClo Q_OBJECT public: - /** + /** * Tool types used by \a Qgs3DMapToolPolygon * \since QGIS 3.44 */ enum ToolType -{ - //! Polygon defined by vertices - Polygon, - //! Polygon defined by 2 vertices and canvas top edge - AboveLinePolygon, - //! Polygon defined by 2 vertices and canvas bottom edge - BelowLinePolygon, -}; + { + //! Polygon defined by vertices + Polygon, + //! Polygon defined by 2 vertices and canvas top edge + AboveLinePolygon, + //! Polygon defined by 2 vertices and canvas bottom edge + BelowLinePolygon, + }; Qgs3DMapToolPointCloudChangeAttributePolygon( Qgs3DMapCanvas *canvas, ToolType type ); ~Qgs3DMapToolPointCloudChangeAttributePolygon() override; @@ -61,7 +61,6 @@ class Qgs3DMapToolPointCloudChangeAttributePolygon : public Qgs3DMapToolPointClo QgsRubberBand3D *mPolygonRubberBand = nullptr; QgsRubberBand3D *mLineRubberBand = nullptr; QPoint mClickPoint; - bool mIsMoving = false; ToolType mToolType; };