20
20
#include < Qt3DRender/QRenderCapture>
21
21
#include < QMouseEvent>
22
22
23
+
23
24
#include " qgscameracontroller.h"
24
25
#include " qgs3dmapsettings.h"
25
26
#include " qgs3dmapscene.h"
26
27
#include " qgs3dmaptool.h"
27
28
#include " qgswindow3dengine.h"
28
29
#include " qgs3dnavigationwidget.h"
29
-
30
+ # include " qgssettings.h "
30
31
31
32
Qgs3DMapCanvas::Qgs3DMapCanvas ( QWidget *parent )
32
33
: QWidget( parent )
33
34
{
35
+ QgsSettings setting;
34
36
mEngine = new QgsWindow3DEngine;
35
37
36
38
connect ( mEngine , &QgsAbstract3DEngine::imageCaptured, this , [ = ]( const QImage & image )
@@ -40,12 +42,15 @@ Qgs3DMapCanvas::Qgs3DMapCanvas( QWidget *parent )
40
42
} );
41
43
42
44
mContainer = QWidget::createWindowContainer ( mEngine ->window () );
43
- mNavigationWidget = new Qgs3DNavigationWidget (this );
45
+ mNavigationWidget = new Qgs3DNavigationWidget ( this );
44
46
45
47
QHBoxLayout *hLayout = new QHBoxLayout ( this );
46
48
hLayout->setMargin ( 0 );
47
49
hLayout->addWidget ( mContainer , 1 );
48
50
hLayout->addWidget ( mNavigationWidget );
51
+ this ->setOnScreenNavigationVisibility (
52
+ setting.value ( QStringLiteral ( " /3D/navigationWidget/visibility" ), true , QgsSettings::Gui ).toBool ()
53
+ );
49
54
50
55
mEngine ->window ()->setCursor ( Qt::OpenHandCursor );
51
56
}
@@ -88,13 +93,14 @@ void Qgs3DMapCanvas::setMap( Qgs3DMapSettings *map )
88
93
89
94
// Connect the camera to the navigation widget.
90
95
QObject::connect (
91
- this ->cameraController (),
92
- &QgsCameraController::cameraChanged,
93
- mNavigationWidget ,
94
- [ = ]{
95
- mNavigationWidget ->updateFromCamera ();
96
- }
97
- );
96
+ this ->cameraController (),
97
+ &QgsCameraController::cameraChanged,
98
+ mNavigationWidget ,
99
+ [ = ]
100
+ {
101
+ mNavigationWidget ->updateFromCamera ();
102
+ }
103
+ );
98
104
}
99
105
100
106
QgsCameraController *Qgs3DMapCanvas::cameraController ()
@@ -175,6 +181,9 @@ bool Qgs3DMapCanvas::eventFilter( QObject *watched, QEvent *event )
175
181
}
176
182
177
183
178
- void Qgs3DMapCanvas::setOnScreenNavigationVisibility (bool visibility){
179
- mNavigationWidget ->setVisible (visibility);
184
+ void Qgs3DMapCanvas::setOnScreenNavigationVisibility ( bool visibility )
185
+ {
186
+ mNavigationWidget ->setVisible ( visibility );
187
+ QgsSettings setting;
188
+ setting.setValue ( QStringLiteral ( " /3D/navigationWidget/visibility" ), visibility, QgsSettings::Gui );
180
189
}
0 commit comments