Fix paintbrush editing tool movement

This commit is contained in:
Withalion 2025-03-07 20:26:06 +01:00 committed by Martin Dobias
parent 9b4abd4bf1
commit 9c2020c703
6 changed files with 24 additions and 4 deletions

View File

@ -300,6 +300,9 @@ bool Qgs3DMapCanvas::eventFilter( QObject *watched, QEvent *event )
case QEvent::KeyPress:
mMapTool->keyPressEvent( static_cast<QKeyEvent *>( event ) );
break;
case QEvent::KeyRelease:
mMapTool->keyReleaseEvent( static_cast<QKeyEvent *>( event ) );
break;
case QEvent::Wheel:
mMapTool->mouseWheelEvent( static_cast<QWheelEvent *>( event ) );
break;

View File

@ -44,6 +44,11 @@ void Qgs3DMapTool::keyPressEvent( QKeyEvent *event )
Q_UNUSED( event )
}
void Qgs3DMapTool::keyReleaseEvent( QKeyEvent *event )
{
Q_UNUSED( event )
}
void Qgs3DMapTool::mouseWheelEvent( QWheelEvent *event )
{
Q_UNUSED( event )

View File

@ -50,6 +50,8 @@ class _3D_EXPORT Qgs3DMapTool : public QObject
virtual void mouseMoveEvent( QMouseEvent *event );
//! Reimplement to handle key press \a event forwarded by the parent Qgs3DMapCanvas
virtual void keyPressEvent( QKeyEvent *event );
//! Reimplement to handle key release \a event forwarded by the parent Qgs3DMapCanvas
virtual void keyReleaseEvent( QKeyEvent *event );
//! Reimplement to handle mouse wheel \a event forwarded by the parent Qgs3DMapCanvas
virtual void mouseWheelEvent( QWheelEvent *event );

View File

@ -490,6 +490,7 @@ void Qgs3DMapCanvasWidget::changePointCloudAttributeByPaintbrush()
if ( !action )
return;
mCanvas->requestActivate();
mCanvas->setMapTool( nullptr );
mMapToolChangeAttribute.reset( new Qgs3DMapToolPointCloudChangeAttributePaintbrush( mCanvas ) );
onPointCloudChangeAttributeSettingsChanged();

View File

@ -157,10 +157,18 @@ void Qgs3DMapToolPointCloudChangeAttributePaintbrush::keyPressEvent( QKeyEvent *
restart();
}
if ( !mIsClicked && event->key() == Qt::Key_Space )
if ( event->key() == Qt::Key_Space && !event->isAutoRepeat() )
{
const bool newState = !mCanvas->cameraController()->hasInputHandlersEnabled();
mCanvas->cameraController()->setInputHandlersEnabled( newState );
mIsMoving = newState;
mCanvas->cameraController()->setInputHandlersEnabled( true );
mIsMoving = true;
}
}
void Qgs3DMapToolPointCloudChangeAttributePaintbrush::keyReleaseEvent( QKeyEvent *event )
{
if ( event->key() == Qt::Key_Space && !event->isAutoRepeat() )
{
mCanvas->cameraController()->setInputHandlersEnabled( false );
mIsMoving = false;
}
}

View File

@ -42,6 +42,7 @@ class Qgs3DMapToolPointCloudChangeAttributePaintbrush : public Qgs3DMapToolPoint
void mouseMoveEvent( QMouseEvent *event ) override;
void mouseWheelEvent( QWheelEvent *event ) override;
void keyPressEvent( QKeyEvent *event ) override;
void keyReleaseEvent( QKeyEvent *event ) override;
private:
void run() override;