Skip to content

Commit 1a61885

Browse files
committed
3D view: allow usual camera controls while the identify tool is active
A small usability improvement... until now one would need to disable identify tool before being able to move/zoom/rotate the camera in 3D view and then enable identify tool again. Now camera can be controlled while the tool is active and the tool is easier to use.
1 parent 68426d6 commit 1a61885

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/3d/qgs3dmapscene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void Qgs3DMapScene::registerPickHandler( Qgs3DMapScenePickHandler *pickHandler )
188188
{
189189
Qt3DRender::QObjectPicker *picker = new Qt3DRender::QObjectPicker( entity );
190190
entity->addComponent( picker );
191-
connect( picker, &Qt3DRender::QObjectPicker::pressed, this, &Qgs3DMapScene::onLayerEntityPickEvent );
191+
connect( picker, &Qt3DRender::QObjectPicker::clicked, this, &Qgs3DMapScene::onLayerEntityPickEvent );
192192
}
193193
}
194194

src/app/3d/qgs3dmapcanvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void Qgs3DMapCanvas::setMapTool( Qgs3DMapTool *tool )
124124
else if ( !mMapTool && tool )
125125
{
126126
mEngine->window()->installEventFilter( this );
127-
mScene->cameraController()->setEnabled( false );
127+
mScene->cameraController()->setEnabled( tool->allowsCameraControls() );
128128
mEngine->window()->setCursor( tool->cursor() );
129129
}
130130

src/app/3d/qgs3dmaptool.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class Qgs3DMapTool : public QObject
4444
//! Mouse cursor to be used when the tool is active
4545
virtual QCursor cursor() const;
4646

47+
/**
48+
* Whether the default mouse controls to zoom/pan/rotate camera can stay enabled
49+
* while the tool is active. This may be useful for some basic tools using just
50+
* mouse clicks (e.g. identify, measure), but it could be creating conflicts when used
51+
* with more advanced tools. Default implementation returns true.
52+
*/
53+
virtual bool allowsCameraControls() const { return true; }
54+
4755
protected:
4856
Qgs3DMapCanvas *mCanvas = nullptr;
4957
};

src/app/3d/qgs3dmaptoolidentify.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ void Qgs3DMapToolIdentify::mousePressEvent( QMouseEvent *event )
7575
void Qgs3DMapToolIdentify::activate()
7676
{
7777
Qt3DRender::QObjectPicker *picker = mCanvas->scene()->terrainEntity()->terrainPicker();
78-
connect( picker, &Qt3DRender::QObjectPicker::pressed, this, &Qgs3DMapToolIdentify::onTerrainPicked );
78+
connect( picker, &Qt3DRender::QObjectPicker::clicked, this, &Qgs3DMapToolIdentify::onTerrainPicked );
7979

8080
mCanvas->scene()->registerPickHandler( mPickHandler.get() );
8181
}
8282

8383
void Qgs3DMapToolIdentify::deactivate()
8484
{
8585
Qt3DRender::QObjectPicker *picker = mCanvas->scene()->terrainEntity()->terrainPicker();
86-
disconnect( picker, &Qt3DRender::QObjectPicker::pressed, this, &Qgs3DMapToolIdentify::onTerrainPicked );
86+
disconnect( picker, &Qt3DRender::QObjectPicker::clicked, this, &Qgs3DMapToolIdentify::onTerrainPicked );
8787

8888
mCanvas->scene()->unregisterPickHandler( mPickHandler.get() );
8989
}
@@ -132,5 +132,5 @@ void Qgs3DMapToolIdentify::onTerrainEntityChanged()
132132
// no need to disconnect from the previous entity: it has been destroyed
133133
// start listening to the new terrain entity
134134
Qt3DRender::QObjectPicker *picker = mCanvas->scene()->terrainEntity()->terrainPicker();
135-
connect( picker, &Qt3DRender::QObjectPicker::pressed, this, &Qgs3DMapToolIdentify::onTerrainPicked );
135+
connect( picker, &Qt3DRender::QObjectPicker::clicked, this, &Qgs3DMapToolIdentify::onTerrainPicked );
136136
}

0 commit comments

Comments
 (0)