QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsadvanceddigitizingfloater.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsadvanceddigitizingfloater.cpp - floater for CAD tools
3 ----------------------
4 begin : May 2019
5 copyright : (C) Olivier Dalang
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include <QMouseEvent>
17#include <QEnterEvent>
18#include <QLocale>
19
21#include "qgsmapcanvas.h"
22#include "qgssettings.h"
23#include "qgsfocuswatcher.h"
24
26 : QWidget( canvas->viewport() )
27 , mMapCanvas( canvas )
28 , mCadDockWidget( cadDockWidget )
29{
30 setupUi( this );
31
32 setAttribute( Qt::WA_TransparentForMouseEvents );
33 adjustSize();
34
35 setActive( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() );
36
37 hideIfDisabled();
38
39 enabledCommonAngleSnapping( cadDockWidget->commonAngleConstraint() );
40
41 // This is required to be able to track mouse move events
42 mMapCanvas->viewport()->installEventFilter( this );
43 mMapCanvas->viewport()->setMouseTracking( true );
44
45 // We reuse cadDockWidget's eventFilter for the CAD specific shortcuts
46 mAngleLineEdit->installEventFilter( cadDockWidget );
47 mDistanceLineEdit->installEventFilter( cadDockWidget );
48 mXLineEdit->installEventFilter( cadDockWidget );
49 mYLineEdit->installEventFilter( cadDockWidget );
50 mZLineEdit->installEventFilter( cadDockWidget );
51 mMLineEdit->installEventFilter( cadDockWidget );
52
53 // Connect all cadDockWidget's signals to update the widget's display
54 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::cadEnabledChanged, this, &QgsAdvancedDigitizingFloater::hideIfDisabled );
55
56 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueXChanged, this, &QgsAdvancedDigitizingFloater::changeX );
57 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueYChanged, this, &QgsAdvancedDigitizingFloater::changeY );
58 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueZChanged, this, &QgsAdvancedDigitizingFloater::changeZ );
59 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueMChanged, this, &QgsAdvancedDigitizingFloater::changeM );
60 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle );
61 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueBearingChanged, this, &QgsAdvancedDigitizingFloater::changeBearing );
62 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueCommonAngleSnappingChanged, this, &QgsAdvancedDigitizingFloater::changeCommonAngleSnapping );
63 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::commonAngleSnappingShowInFloaterChanged, this, &QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping );
64 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeDistance );
65
66 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockXChanged, this, &QgsAdvancedDigitizingFloater::changeLockX );
67 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockYChanged, this, &QgsAdvancedDigitizingFloater::changeLockY );
68 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockZChanged, this, &QgsAdvancedDigitizingFloater::changeLockZ );
69 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockMChanged, this, &QgsAdvancedDigitizingFloater::changeLockM );
70 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockAngleChanged, this, &QgsAdvancedDigitizingFloater::changeLockAngle );
71 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeLockDistance );
72
73 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeXChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeX );
74 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeYChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeY );
75 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeZChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeZ );
76 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeMChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeM );
77 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeAngleChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeAngle );
78 // distance is always relative
79
80 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnXRequested, this, &QgsAdvancedDigitizingFloater::focusOnX );
81 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnYRequested, this, &QgsAdvancedDigitizingFloater::focusOnY );
82 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnZRequested, this, &QgsAdvancedDigitizingFloater::focusOnZ );
83 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnMRequested, this, &QgsAdvancedDigitizingFloater::focusOnM );
84 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngleRequested, this, &QgsAdvancedDigitizingFloater::focusOnAngle );
85 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnDistanceRequested, this, &QgsAdvancedDigitizingFloater::focusOnDistance );
86
87 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedX, this, &QgsAdvancedDigitizingFloater::enabledChangedX );
88 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedY, this, &QgsAdvancedDigitizingFloater::enabledChangedY );
89 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedZ, this, &QgsAdvancedDigitizingFloater::enabledChangedZ );
90 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedM, this, &QgsAdvancedDigitizingFloater::enabledChangedM );
91 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle );
92 // Bearing capability is the same an angle, connect to the same signal:
93 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedBearing );
94 // Common angle snapping capbility is also linked to angle, connect to the same signal:
95 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping );
96 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance );
97
98 // Connect our line edits signals to update cadDockWidget's state (implementation copied from QgsAdvancedDigitizingDockWidget)
99 connect( mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
100 connect( mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
101 connect( mZLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
102 connect( mMLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
103 connect( mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
104 connect( mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
105
106 connect( mXLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
107 connect( mYLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
108 connect( mZLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
109 connect( mMLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
110 connect( mAngleLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
111 connect( mDistanceLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
112
113 QgsFocusWatcher *xWatcher = new QgsFocusWatcher( mXLineEdit );
114 connect( xWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
115 QgsFocusWatcher *yWatcher = new QgsFocusWatcher( mYLineEdit );
116 connect( yWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
117 QgsFocusWatcher *zWatcher = new QgsFocusWatcher( mZLineEdit );
118 connect( zWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
119 QgsFocusWatcher *mWatcher = new QgsFocusWatcher( mYLineEdit );
120 connect( mWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
121 QgsFocusWatcher *angleWatcher = new QgsFocusWatcher( mAngleLineEdit );
122 connect( angleWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
123 QgsFocusWatcher *distanceWatcher = new QgsFocusWatcher( mDistanceLineEdit );
124 connect( distanceWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
125 changeCommonAngleSnapping( mCadDockWidget->commonAngleConstraint() );
126
127
128
129}
130
131bool QgsAdvancedDigitizingFloater::eventFilter( QObject *obj, QEvent *event )
132{
133 if ( mCadDockWidget && mCadDockWidget->cadEnabled() && mActive )
134 {
135 if ( event->type() == QEvent::MouseMove )
136 {
137 // We update the position when mouse moves
138 QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *>( event );
139 updatePos( mouseEvent->pos() );
140 }
141 else if ( event->type() == QEvent::Enter )
142 {
143 // We show the widget when mouse enters
144 QEnterEvent *enterEvent = dynamic_cast<QEnterEvent *>( event );
145 updatePos( enterEvent->pos() );
146 setVisible( true );
147 }
148 else if ( event->type() == QEvent::Leave )
149 {
150 // We hide the widget when mouse leaves
151 setVisible( false );
152 }
153 }
154 return QWidget::eventFilter( obj, event );
155}
156
158{
159 return mActive;
160}
161
163{
164 return mItemsVisibility.testFlag( item );
165}
166
168{
169 QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), active );
170
171 mActive = active;
172
173 hideIfDisabled();
174}
175
177{
178 const QMetaEnum enumData { QMetaEnum::fromType<QgsAdvancedDigitizingFloater::FloaterItem>() };
179 QgsSettings().setValue( QStringLiteral( "/Cad/%1ShowInFloater" ).arg( enumData.valueToKey( static_cast<int>( item ) ) ), visible );
180 mItemsVisibility.setFlag( item, visible );
181 switch ( item )
182 {
184 enabledChangedX( visible );
185 break;
187 enabledChangedY( visible );
188 break;
190 enabledChangedM( visible );
191 break;
193 enabledChangedZ( visible );
194 break;
196 enabledChangedAngle( visible );
197 break;
199 enabledChangedDistance( visible );
200 break;
202 enabledCommonAngleSnapping( visible );
203 break;
205 enabledChangedBearing( visible );
206 break;
207 }
208}
209
210void QgsAdvancedDigitizingFloater::updatePos( const QPoint &pos )
211{
212 // We hardcode a small delta between the mouse position and the widget's position
213 move( pos + QPoint( 15, 5 ) );
214}
215
216void QgsAdvancedDigitizingFloater::hideIfDisabled()
217{
218 if ( !mCadDockWidget || ! mCadDockWidget->cadEnabled() || ! mActive )
219 {
220 setVisible( false );
221 }
222}
223
224void QgsAdvancedDigitizingFloater::changeX( const QString &text )
225{
226 mXLineEdit->setText( text );
227}
228
229void QgsAdvancedDigitizingFloater::changeY( const QString &text )
230{
231 mYLineEdit->setText( text );
232}
233
234void QgsAdvancedDigitizingFloater::changeZ( const QString &text )
235{
236 mZLineEdit->setText( text );
237}
238
239void QgsAdvancedDigitizingFloater::changeM( const QString &text )
240{
241 mMLineEdit->setText( text );
242}
243
244void QgsAdvancedDigitizingFloater::changeCommonAngleSnapping( double angle )
245{
246 mCommonAngleSnappingLineEdit->setText( qgsDoubleNear( angle, 0.0 ) ? tr( "disabled" ) : QLocale().toString( angle ).append( tr( " °" ) ) );
247}
248
249void QgsAdvancedDigitizingFloater::changeDistance( const QString &text )
250{
251 mDistanceLineEdit->setText( text );
252}
253
254void QgsAdvancedDigitizingFloater::changeAngle( const QString &text )
255{
256 mAngleLineEdit->setText( text );
257}
258
259void QgsAdvancedDigitizingFloater::changeBearing( const QString &text )
260{
261 mBearingLineEdit->setText( text );
262}
263
264void QgsAdvancedDigitizingFloater::changeLockX( bool locked )
265{
266 if ( !locked )
267 {
268 mXLineEdit->setStyleSheet( QString() );
269 mXLabel->setStyleSheet( QString() );
270 }
271 else
272 {
273 mXLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
274 mXLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
275 }
276}
277
278void QgsAdvancedDigitizingFloater::changeLockY( bool locked )
279{
280 if ( !locked )
281 {
282 mYLineEdit->setStyleSheet( QString() );
283 mYLabel->setStyleSheet( QString() );
284 }
285 else
286 {
287 mYLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
288 mYLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
289 }
290}
291
292void QgsAdvancedDigitizingFloater::changeLockZ( bool locked )
293{
294 if ( !locked )
295 {
296 mZLineEdit->setStyleSheet( QString() );
297 mZLabel->setStyleSheet( QString() );
298 }
299 else
300 {
301 mZLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
302 mZLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
303 }
304}
305
306void QgsAdvancedDigitizingFloater::changeLockM( bool locked )
307{
308 if ( !locked )
309 {
310 mMLineEdit->setStyleSheet( QString() );
311 mMLabel->setStyleSheet( QString() );
312 }
313 else
314 {
315 mMLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
316 mMLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
317 }
318}
319
320void QgsAdvancedDigitizingFloater::changeLockDistance( bool locked )
321{
322 if ( !locked )
323 {
324 mDistanceLineEdit->setStyleSheet( QString() );
325 mDistanceLabel->setStyleSheet( QString() );
326 }
327 else
328 {
329 mDistanceLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
330 mDistanceLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
331 }
332}
333
334void QgsAdvancedDigitizingFloater::changeLockAngle( bool locked )
335{
336 if ( !locked )
337 {
338 mAngleLineEdit->setStyleSheet( QString() );
339 mAngleLabel->setStyleSheet( QString() );
340 }
341 else
342 {
343 mAngleLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
344 mAngleLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
345 }
346}
347
348
349void QgsAdvancedDigitizingFloater::changeRelativeX( bool relative )
350{
351 if ( !relative )
352 {
353 mXLabel->setText( "x" );
354 }
355 else
356 {
357 mXLabel->setText( "Δx" );
358 }
359 adjustSize();
360}
361
362void QgsAdvancedDigitizingFloater::changeRelativeY( bool relative )
363{
364 if ( !relative )
365 {
366 mYLabel->setText( "y" );
367 }
368 else
369 {
370 mYLabel->setText( "Δy" );
371 }
372 adjustSize();
373}
374
375void QgsAdvancedDigitizingFloater::changeRelativeZ( bool relative )
376{
377 if ( !relative )
378 {
379 mZLabel->setText( "z" );
380 }
381 else
382 {
383 mZLabel->setText( "Δz" );
384 }
385 adjustSize();
386}
387
388void QgsAdvancedDigitizingFloater::changeRelativeM( bool relative )
389{
390 if ( !relative )
391 {
392 mMLabel->setText( "m" );
393 }
394 else
395 {
396 mMLabel->setText( "Δm" );
397 }
398 adjustSize();
399}
400
401// distance is always relative
402
403void QgsAdvancedDigitizingFloater::changeRelativeAngle( bool relative )
404{
405 if ( !relative )
406 {
407 mAngleLabel->setText( "a" );
408 }
409 else
410 {
411 mAngleLabel->setText( "Δa" );
412 }
413 adjustSize();
414}
415
416void QgsAdvancedDigitizingFloater::focusOnX()
417{
418 if ( mActive )
419 {
420 mXLineEdit->setFocus();
421 mXLineEdit->selectAll();
422 }
423}
424
425void QgsAdvancedDigitizingFloater::focusOnY()
426{
427 if ( mActive )
428 {
429 mYLineEdit->setFocus();
430 mYLineEdit->selectAll();
431 }
432}
433
434void QgsAdvancedDigitizingFloater::focusOnZ()
435{
436 if ( mActive )
437 {
438 mZLineEdit->setFocus();
439 mZLineEdit->selectAll();
440 }
441}
442
443void QgsAdvancedDigitizingFloater::focusOnM()
444{
445 if ( mActive )
446 {
447 mMLineEdit->setFocus();
448 mMLineEdit->selectAll();
449 }
450}
451
452void QgsAdvancedDigitizingFloater::focusOnDistance()
453{
454 if ( mActive )
455 {
456 mDistanceLineEdit->setFocus();
457 mDistanceLineEdit->selectAll();
458 }
459}
460
461void QgsAdvancedDigitizingFloater::focusOnAngle()
462{
463 if ( mActive )
464 {
465 mAngleLineEdit->setFocus();
466 mAngleLineEdit->selectAll();
467 }
468}
469
470
471void QgsAdvancedDigitizingFloater::enabledChangedX( bool enabled )
472{
473 mXLineEdit->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
474 mXLabel->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
475 adjustSize();
476}
477
478void QgsAdvancedDigitizingFloater::enabledChangedY( bool enabled )
479{
480 mYLineEdit->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
481 mYLabel->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
482 adjustSize();
483}
484
485void QgsAdvancedDigitizingFloater::enabledChangedZ( bool enabled )
486{
487 mZLineEdit->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
488 mZLabel->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
489 adjustSize();
490}
491
492void QgsAdvancedDigitizingFloater::enabledChangedM( bool enabled )
493{
494 mMLineEdit->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
495 mMLabel->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
496 adjustSize();
497}
498
499void QgsAdvancedDigitizingFloater::enabledChangedDistance( bool enabled )
500{
501 mDistanceLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
502 mDistanceLabel->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
503 adjustSize();
504}
505
506void QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping( bool enabled )
507{
508 mCommonAngleSnappingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
509 mCommonAngleSnappingLabel->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
510 adjustSize();
511}
512
513void QgsAdvancedDigitizingFloater::enabledChangedAngle( bool enabled )
514{
515 mAngleLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
516 mAngleLabel->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
517 adjustSize();
518}
519
520void QgsAdvancedDigitizingFloater::enabledChangedBearing( bool enabled )
521{
522 mBearingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
523 mBearingLabel->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
524 adjustSize();
525}
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
void valueDistanceChanged(const QString &value)
Emitted whenever the distance value changes (either the mouse moved, or the user changed the input).
bool commonAngleConstraint() const
Returns true if a constraint on a common angle is active.
void lockZChanged(bool locked)
Emitted whenever the Z parameter is locked.
void setZ(const QString &value, WidgetSetMode mode)
Set the Z value on the widget.
void setY(const QString &value, WidgetSetMode mode)
Set the Y value on the widget.
void enabledChangedY(bool enabled)
Emitted whenever the Y field is enabled or disabled.
void relativeMChanged(bool relative)
Emitted whenever the M parameter is toggled between absolute and relative.
void lockXChanged(bool locked)
Emitted whenever the X parameter is locked.
void focusOnXRequested()
Emitted whenever the X field should get the focus using the shortcuts (X).
void enabledChangedX(bool enabled)
Emitted whenever the X field is enabled or disabled.
void valueYChanged(const QString &value)
Emitted whenever the Y value changes (either the mouse moved, or the user changed the input).
void focusOnYRequested()
Emitted whenever the Y field should get the focus using the shortcuts (Y).
void enabledChangedDistance(bool enabled)
Emitted whenever the distance field is enabled or disabled.
void valueZChanged(const QString &value)
Emitted whenever the Z value changes (either the mouse moved, or the user changed the input).
void lockAngleChanged(bool locked)
Emitted whenever the angle parameter is locked.
void commonAngleSnappingShowInFloaterChanged(bool enabled)
Emitted whenever the option to show common angle snapping in the floater changes.
void relativeXChanged(bool relative)
Emitted whenever the X parameter is toggled between absolute and relative.
void focusOnAngleRequested()
Emitted whenever the angle field should get the focus using the shortcuts (A).
void focusOnZRequested()
Emitted whenever the Z field should get the focus using the shortcuts (Z).
void focusOnMRequested()
Emitted whenever the M field should get the focus using the shortcuts (M).
void valueXChanged(const QString &value)
Emitted whenever the X value changes (either the mouse moved, or the user changed the input).
void lockMChanged(bool locked)
Emitted whenever the M parameter is locked.
void cadEnabledChanged(bool enabled)
Signals for external widgets that need to update according to current values.
void lockYChanged(bool locked)
Emitted whenever the Y parameter is locked.
void valueAngleChanged(const QString &value)
Emitted whenever the angle value changes (either the mouse moved, or the user changed the input).
void valueMChanged(const QString &value)
Emitted whenever the M value changes (either the mouse moved, or the user changed the input).
void relativeZChanged(bool relative)
Emitted whenever the Z parameter is toggled between absolute and relative.
void setAngle(const QString &value, WidgetSetMode mode)
Set the angle value on the widget.
void enabledChangedAngle(bool enabled)
Emitted whenever the angle field is enabled or disabled.
void enabledChangedZ(bool enabled)
Emitted whenever the Z field is enabled or disabled.
void lockDistanceChanged(bool locked)
Emitted whenever the distance parameter is locked.
void relativeAngleChanged(bool relative)
Emitted whenever the angleX parameter is toggled between absolute and relative.
void valueBearingChanged(const QString &value)
Emitted whenever the bearing value changes.
void enabledChangedM(bool enabled)
Emitted whenever the M field is enabled or disabled.
void setDistance(const QString &value, WidgetSetMode mode)
Set the distance value on the widget.
void setX(const QString &value, WidgetSetMode mode)
Set the X value on the widget.
void focusOnDistanceRequested()
Emitted whenever the distance field should get the focus using the shortcuts (D).
void valueCommonAngleSnappingChanged(double angle)
Emitted whenever the snapping to common angle option changes, angle = 0 means that the functionality ...
void setM(const QString &value, WidgetSetMode mode)
Set the M value on the widget.
void relativeYChanged(bool relative)
Emitted whenever the Y parameter is toggled between absolute and relative.
QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Create an advanced digitizing floater widget.
void setItemVisibility(const QgsAdvancedDigitizingFloater::FloaterItem &item, bool visible)
Set whether the floater item should be visible or not.
bool itemVisibility(const QgsAdvancedDigitizingFloater::FloaterItem &item) const
Returns true if the floater item visibility setting is enabled.
void setActive(bool active)
Set whether the floater should be active or not.
bool active()
Whether the floater is active or not.
A event filter for watching for focus events on a parent object.
void focusOut()
Emitted when parent object loses focus.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
This class is a composition of two QSettings instances:
Definition: qgssettings.h:63
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:3988