|
26 | 26 | #include "qgs3dnavigationwidget.h"
|
27 | 27 |
|
28 | 28 |
|
29 |
| -Qgs3DNavigationWidget::Qgs3DNavigationWidget(Qgs3DMapCanvas *parent) : QWidget(parent) |
| 29 | +Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *parent ) : QWidget( parent ) |
30 | 30 | {
|
31 |
| - mParent3DMapCanvas = parent; |
32 |
| - // Zoom in button |
33 |
| - mZoomInButton = new QToolButton(this); |
34 |
| - mZoomInButton->setToolTip(tr("Zoom In")); |
35 |
| - mZoomInButton->setAutoRepeat(true); |
36 |
| - mZoomInButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ) ); |
37 |
| - mZoomInButton->setAutoRaise(true); |
38 |
| - |
39 |
| - QObject::connect( |
40 |
| - mZoomInButton, |
41 |
| - &QToolButton::clicked, |
42 |
| - parent, |
43 |
| - [ = ]{ |
44 |
| - parent->cameraController()->zoom(5); |
45 |
| - } |
46 |
| - ); |
47 |
| - |
48 |
| - // Zoom out button |
49 |
| - mZoomOutButton = new QToolButton(this); |
50 |
| - mZoomOutButton->setToolTip(tr("Zoom Out")); |
51 |
| - mZoomOutButton->setAutoRepeat(true); |
52 |
| - mZoomOutButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomOut.svg" ) ) ); |
53 |
| - mZoomOutButton->setAutoRaise(true); |
54 |
| - |
55 |
| - QObject::connect( |
56 |
| - mZoomOutButton, |
57 |
| - &QToolButton::clicked, |
58 |
| - parent, |
59 |
| - [ = ]{ |
60 |
| - parent->cameraController()->zoom(-5); |
61 |
| - } |
62 |
| - ); |
63 |
| - |
64 |
| - // Tilt up button |
65 |
| - mTiltUpButton = new QToolButton(this); |
66 |
| - mTiltUpButton->setToolTip(tr("Tilt Up")); |
67 |
| - mTiltUpButton->setAutoRepeat(true); |
68 |
| - mTiltUpButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionTiltUp.svg" ) ) ); |
69 |
| - mTiltUpButton->setAutoRaise(true); |
70 |
| - |
71 |
| - QObject::connect( |
72 |
| - mTiltUpButton, |
73 |
| - &QToolButton::clicked, |
74 |
| - parent, |
75 |
| - [ = ]{ |
76 |
| - parent->cameraController()->tiltUpAroundViewCenter(1); |
77 |
| - } |
78 |
| - ); |
79 |
| - |
80 |
| - // Tilt down button |
81 |
| - mTiltDownButton = new QToolButton(this); |
82 |
| - mTiltDownButton->setToolTip(tr("Tilt Down")); |
83 |
| - mTiltDownButton->setAutoRepeat(true); |
84 |
| - mTiltDownButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionTiltDown.svg" ) ) ); |
85 |
| - mTiltDownButton->setAutoRaise(true); |
86 |
| - |
87 |
| - QObject::connect( |
88 |
| - mTiltDownButton, |
89 |
| - &QToolButton::clicked, |
90 |
| - parent, |
91 |
| - [ = ]{ |
92 |
| - parent->cameraController()->tiltUpAroundViewCenter(-1); |
93 |
| - } |
94 |
| - ); |
95 |
| - |
96 |
| - // Compas |
97 |
| - QwtCompassMagnetNeedle *compasNeedle = new QwtCompassMagnetNeedle(); |
98 |
| - mCompas = new QwtCompass(this); |
99 |
| - mCompas->setToolTip(tr("Rotate view")); |
100 |
| - mCompas->setWrapping(true); |
101 |
| - mCompas->setNeedle(compasNeedle); |
102 |
| - |
103 |
| - QObject::connect( |
104 |
| - mCompas, |
105 |
| - &QwtDial::valueChanged, |
106 |
| - parent, |
107 |
| - [ = ]{ |
108 |
| - parent->cameraController()->setCameraHeadingAngle(float(mCompas->value())); |
109 |
| - } |
110 |
| - ); |
111 |
| - |
112 |
| - // Move up button |
113 |
| - mMoveUpButton = new QToolButton(this); |
114 |
| - mMoveUpButton->setToolTip(tr("Move up")); |
115 |
| - mMoveUpButton->setAutoRepeat(true); |
116 |
| - mMoveUpButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowUp.svg" ) ) ); |
117 |
| - mMoveUpButton->setAutoRaise(true); |
118 |
| - |
119 |
| - QObject::connect( |
120 |
| - mMoveUpButton, |
121 |
| - &QToolButton::clicked, |
122 |
| - parent, |
123 |
| - [ = ]{ |
124 |
| - parent->cameraController()->moveView(0, 1); |
125 |
| - } |
126 |
| - ); |
127 |
| - |
128 |
| - // Move right button |
129 |
| - mMoveRightButton = new QToolButton(this); |
130 |
| - mMoveRightButton->setToolTip(tr("Move right")); |
131 |
| - mMoveRightButton->setAutoRepeat(true); |
132 |
| - mMoveRightButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowRight.svg" ) ) ); |
133 |
| - mMoveRightButton->setAutoRaise(true); |
134 |
| - |
135 |
| - QObject::connect( |
136 |
| - mMoveRightButton, |
137 |
| - &QToolButton::clicked, |
138 |
| - parent, |
139 |
| - [ = ]{ |
140 |
| - parent->cameraController()->moveView(1, 0); |
141 |
| - } |
142 |
| - ); |
143 |
| - |
144 |
| - // Move down button |
145 |
| - mMoveDownButton = new QToolButton(this); |
146 |
| - mMoveDownButton->setToolTip(tr("Move down")); |
147 |
| - mMoveDownButton->setAutoRepeat(true); |
148 |
| - mMoveDownButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowDown.svg" ) ) ); |
149 |
| - mMoveDownButton->setAutoRaise(true); |
150 |
| - |
151 |
| - QObject::connect( |
152 |
| - mMoveDownButton, |
153 |
| - &QToolButton::clicked, |
154 |
| - parent, |
155 |
| - [ = ]{ |
156 |
| - parent->cameraController()->moveView(0, -1); |
157 |
| - } |
158 |
| - ); |
159 |
| - |
160 |
| - // Move left button |
161 |
| - mMoveLeftButton = new QToolButton(this); |
162 |
| - mMoveLeftButton->setToolTip(tr("Move left")); |
163 |
| - mMoveLeftButton->setAutoRepeat(true); |
164 |
| - mMoveLeftButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowLeft.svg" ) ) ); |
165 |
| - mMoveLeftButton->setAutoRaise(true); |
166 |
| - |
167 |
| - QObject::connect( |
168 |
| - mMoveLeftButton, |
169 |
| - &QToolButton::clicked, |
170 |
| - parent, |
171 |
| - [ = ]{ |
172 |
| - parent->cameraController()->moveView(-1, 0); |
173 |
| - } |
174 |
| - ); |
175 |
| - |
176 |
| - QGridLayout *gridLayout = new QGridLayout(this); |
177 |
| - gridLayout->addWidget(mTiltUpButton, 0, 0); |
178 |
| - gridLayout->addWidget(mTiltDownButton, 3, 0); |
179 |
| - gridLayout->addWidget(mZoomInButton, 0, 3); |
180 |
| - gridLayout->addWidget(mZoomOutButton, 3, 3); |
181 |
| - gridLayout->addWidget(mCompas, 1, 1, 2, 2); |
182 |
| - gridLayout->addWidget(mMoveUpButton, 0, 1, 1, 2, Qt::AlignCenter); |
183 |
| - gridLayout->addWidget(mMoveRightButton, 1, 3, 2, 1, Qt::AlignCenter); |
184 |
| - gridLayout->addWidget(mMoveDownButton, 3, 1, 1, 2, Qt::AlignCenter); |
185 |
| - gridLayout->addWidget(mMoveLeftButton, 1, 0, 2, 1, Qt::AlignCenter); |
186 |
| - gridLayout->setAlignment(Qt::AlignTop); |
| 31 | + mParent3DMapCanvas = parent; |
| 32 | + // Zoom in button |
| 33 | + mZoomInButton = new QToolButton( this ); |
| 34 | + mZoomInButton->setToolTip( tr( "Zoom In" ) ); |
| 35 | + mZoomInButton->setAutoRepeat( true ); |
| 36 | + mZoomInButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ) ); |
| 37 | + mZoomInButton->setAutoRaise( true ); |
| 38 | + |
| 39 | + QObject::connect( |
| 40 | + mZoomInButton, |
| 41 | + &QToolButton::clicked, |
| 42 | + parent, |
| 43 | + [ = ] |
| 44 | + { |
| 45 | + parent->cameraController()->zoom( 5 ); |
| 46 | + } |
| 47 | + ); |
| 48 | + |
| 49 | + // Zoom out button |
| 50 | + mZoomOutButton = new QToolButton( this ); |
| 51 | + mZoomOutButton->setToolTip( tr( "Zoom Out" ) ); |
| 52 | + mZoomOutButton->setAutoRepeat( true ); |
| 53 | + mZoomOutButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomOut.svg" ) ) ); |
| 54 | + mZoomOutButton->setAutoRaise( true ); |
| 55 | + |
| 56 | + QObject::connect( |
| 57 | + mZoomOutButton, |
| 58 | + &QToolButton::clicked, |
| 59 | + parent, |
| 60 | + [ = ] |
| 61 | + { |
| 62 | + parent->cameraController()->zoom( -5 ); |
| 63 | + } |
| 64 | + ); |
| 65 | + |
| 66 | + // Tilt up button |
| 67 | + mTiltUpButton = new QToolButton( this ); |
| 68 | + mTiltUpButton->setToolTip( tr( "Tilt Up" ) ); |
| 69 | + mTiltUpButton->setAutoRepeat( true ); |
| 70 | + mTiltUpButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionTiltUp.svg" ) ) ); |
| 71 | + mTiltUpButton->setAutoRaise( true ); |
| 72 | + |
| 73 | + QObject::connect( |
| 74 | + mTiltUpButton, |
| 75 | + &QToolButton::clicked, |
| 76 | + parent, |
| 77 | + [ = ] |
| 78 | + { |
| 79 | + parent->cameraController()->tiltUpAroundViewCenter( 1 ); |
| 80 | + } |
| 81 | + ); |
| 82 | + |
| 83 | + // Tilt down button |
| 84 | + mTiltDownButton = new QToolButton( this ); |
| 85 | + mTiltDownButton->setToolTip( tr( "Tilt Down" ) ); |
| 86 | + mTiltDownButton->setAutoRepeat( true ); |
| 87 | + mTiltDownButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionTiltDown.svg" ) ) ); |
| 88 | + mTiltDownButton->setAutoRaise( true ); |
| 89 | + |
| 90 | + QObject::connect( |
| 91 | + mTiltDownButton, |
| 92 | + &QToolButton::clicked, |
| 93 | + parent, |
| 94 | + [ = ] |
| 95 | + { |
| 96 | + parent->cameraController()->tiltUpAroundViewCenter( -1 ); |
| 97 | + } |
| 98 | + ); |
| 99 | + |
| 100 | + // Compas |
| 101 | + QwtCompassMagnetNeedle *compasNeedle = new QwtCompassMagnetNeedle(); |
| 102 | + mCompas = new QwtCompass( this ); |
| 103 | + mCompas->setToolTip( tr( "Rotate view" ) ); |
| 104 | + mCompas->setWrapping( true ); |
| 105 | + mCompas->setNeedle( compasNeedle ); |
| 106 | + |
| 107 | + QObject::connect( |
| 108 | + mCompas, |
| 109 | + &QwtDial::valueChanged, |
| 110 | + parent, |
| 111 | + [ = ] |
| 112 | + { |
| 113 | + parent->cameraController()->setCameraHeadingAngle( float( mCompas->value() ) ); |
| 114 | + } |
| 115 | + ); |
| 116 | + |
| 117 | + // Move up button |
| 118 | + mMoveUpButton = new QToolButton( this ); |
| 119 | + mMoveUpButton->setToolTip( tr( "Move up" ) ); |
| 120 | + mMoveUpButton->setAutoRepeat( true ); |
| 121 | + mMoveUpButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowUp.svg" ) ) ); |
| 122 | + mMoveUpButton->setAutoRaise( true ); |
| 123 | + |
| 124 | + QObject::connect( |
| 125 | + mMoveUpButton, |
| 126 | + &QToolButton::clicked, |
| 127 | + parent, |
| 128 | + [ = ] |
| 129 | + { |
| 130 | + parent->cameraController()->moveView( 0, 1 ); |
| 131 | + } |
| 132 | + ); |
| 133 | + |
| 134 | + // Move right button |
| 135 | + mMoveRightButton = new QToolButton( this ); |
| 136 | + mMoveRightButton->setToolTip( tr( "Move right" ) ); |
| 137 | + mMoveRightButton->setAutoRepeat( true ); |
| 138 | + mMoveRightButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowRight.svg" ) ) ); |
| 139 | + mMoveRightButton->setAutoRaise( true ); |
| 140 | + |
| 141 | + QObject::connect( |
| 142 | + mMoveRightButton, |
| 143 | + &QToolButton::clicked, |
| 144 | + parent, |
| 145 | + [ = ] |
| 146 | + { |
| 147 | + parent->cameraController()->moveView( 1, 0 ); |
| 148 | + } |
| 149 | + ); |
| 150 | + |
| 151 | + // Move down button |
| 152 | + mMoveDownButton = new QToolButton( this ); |
| 153 | + mMoveDownButton->setToolTip( tr( "Move down" ) ); |
| 154 | + mMoveDownButton->setAutoRepeat( true ); |
| 155 | + mMoveDownButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowDown.svg" ) ) ); |
| 156 | + mMoveDownButton->setAutoRaise( true ); |
| 157 | + |
| 158 | + QObject::connect( |
| 159 | + mMoveDownButton, |
| 160 | + &QToolButton::clicked, |
| 161 | + parent, |
| 162 | + [ = ] |
| 163 | + { |
| 164 | + parent->cameraController()->moveView( 0, -1 ); |
| 165 | + } |
| 166 | + ); |
| 167 | + |
| 168 | + // Move left button |
| 169 | + mMoveLeftButton = new QToolButton( this ); |
| 170 | + mMoveLeftButton->setToolTip( tr( "Move left" ) ); |
| 171 | + mMoveLeftButton->setAutoRepeat( true ); |
| 172 | + mMoveLeftButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionArrowLeft.svg" ) ) ); |
| 173 | + mMoveLeftButton->setAutoRaise( true ); |
| 174 | + |
| 175 | + QObject::connect( |
| 176 | + mMoveLeftButton, |
| 177 | + &QToolButton::clicked, |
| 178 | + parent, |
| 179 | + [ = ] |
| 180 | + { |
| 181 | + parent->cameraController()->moveView( -1, 0 ); |
| 182 | + } |
| 183 | + ); |
| 184 | + |
| 185 | + QGridLayout *gridLayout = new QGridLayout( this ); |
| 186 | + gridLayout->addWidget( mTiltUpButton, 0, 0 ); |
| 187 | + gridLayout->addWidget( mTiltDownButton, 3, 0 ); |
| 188 | + gridLayout->addWidget( mZoomInButton, 0, 3 ); |
| 189 | + gridLayout->addWidget( mZoomOutButton, 3, 3 ); |
| 190 | + gridLayout->addWidget( mCompas, 1, 1, 2, 2 ); |
| 191 | + gridLayout->addWidget( mMoveUpButton, 0, 1, 1, 2, Qt::AlignCenter ); |
| 192 | + gridLayout->addWidget( mMoveRightButton, 1, 3, 2, 1, Qt::AlignCenter ); |
| 193 | + gridLayout->addWidget( mMoveDownButton, 3, 1, 1, 2, Qt::AlignCenter ); |
| 194 | + gridLayout->addWidget( mMoveLeftButton, 1, 0, 2, 1, Qt::AlignCenter ); |
| 195 | + gridLayout->setAlignment( Qt::AlignTop ); |
187 | 196 | }
|
188 | 197 |
|
189 | 198 | Qgs3DNavigationWidget::~Qgs3DNavigationWidget()
|
190 | 199 | {
|
191 | 200 |
|
192 | 201 | }
|
193 | 202 |
|
194 |
| -void Qgs3DNavigationWidget::updateFromCamera(){ |
195 |
| - // Make sure the angle is between 0 - 359 |
196 |
| - mCompas->setValue((int(mParent3DMapCanvas->cameraController()->yaw()) % 360 + 360) % 360); |
| 203 | +void Qgs3DNavigationWidget::updateFromCamera() |
| 204 | +{ |
| 205 | + // Make sure the angle is between 0 - 359 |
| 206 | + mCompas->setValue( ( int( mParent3DMapCanvas->cameraController()->yaw() ) % 360 + 360 ) % 360 ); |
197 | 207 | }
|
0 commit comments