QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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 "moc_qgsadvanceddigitizingfloater.cpp"
22#include "qgsmapcanvas.h"
23#include "qgssettings.h"
24#include "qgsfocuswatcher.h"
25#include "qgsunittypes.h"
26
28 : QWidget( canvas->viewport() )
29 , mMapCanvas( canvas )
30 , mCadDockWidget( cadDockWidget )
31{
32 setupUi( this );
33
34 setAttribute( Qt::WA_TransparentForMouseEvents );
35 adjustSize();
36
37 setActive( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() );
38
39 hideIfDisabled();
40
41 enabledCommonAngleSnapping( cadDockWidget->commonAngleConstraint() );
42
43 // This is required to be able to track mouse move events
44 mMapCanvas->viewport()->installEventFilter( this );
45 mMapCanvas->viewport()->setMouseTracking( true );
46
47 // We reuse cadDockWidget's eventFilter for the CAD specific shortcuts
48 mAngleLineEdit->installEventFilter( cadDockWidget );
49 mDistanceLineEdit->installEventFilter( cadDockWidget );
50 mXLineEdit->installEventFilter( cadDockWidget );
51 mYLineEdit->installEventFilter( cadDockWidget );
52 mZLineEdit->installEventFilter( cadDockWidget );
53 mMLineEdit->installEventFilter( cadDockWidget );
54
55 // Connect all cadDockWidget's signals to update the widget's display
56 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::cadEnabledChanged, this, &QgsAdvancedDigitizingFloater::hideIfDisabled );
57
58 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueXChanged, this, &QgsAdvancedDigitizingFloater::changeX );
59 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueYChanged, this, &QgsAdvancedDigitizingFloater::changeY );
60 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueZChanged, this, &QgsAdvancedDigitizingFloater::changeZ );
61 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueMChanged, this, &QgsAdvancedDigitizingFloater::changeM );
62 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle );
63 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueBearingChanged, this, &QgsAdvancedDigitizingFloater::changeBearing );
64 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueCommonAngleSnappingChanged, this, &QgsAdvancedDigitizingFloater::changeCommonAngleSnapping );
65 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::commonAngleSnappingShowInFloaterChanged, this, &QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping );
66 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeDistance );
67
68 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockXChanged, this, &QgsAdvancedDigitizingFloater::changeLockX );
69 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockYChanged, this, &QgsAdvancedDigitizingFloater::changeLockY );
70 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockZChanged, this, &QgsAdvancedDigitizingFloater::changeLockZ );
71 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockMChanged, this, &QgsAdvancedDigitizingFloater::changeLockM );
72 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockAngleChanged, this, &QgsAdvancedDigitizingFloater::changeLockAngle );
73 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeLockDistance );
74
75 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeXChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeX );
76 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeYChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeY );
77 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeZChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeZ );
78 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeMChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeM );
79 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeAngleChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeAngle );
80 // distance is always relative
81
82 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnXRequested, this, &QgsAdvancedDigitizingFloater::focusOnX );
83 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnYRequested, this, &QgsAdvancedDigitizingFloater::focusOnY );
84 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnZRequested, this, &QgsAdvancedDigitizingFloater::focusOnZ );
85 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnMRequested, this, &QgsAdvancedDigitizingFloater::focusOnM );
86 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngleRequested, this, &QgsAdvancedDigitizingFloater::focusOnAngle );
87 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnDistanceRequested, this, &QgsAdvancedDigitizingFloater::focusOnDistance );
88
89 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedX, this, &QgsAdvancedDigitizingFloater::enabledChangedX );
90 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedY, this, &QgsAdvancedDigitizingFloater::enabledChangedY );
91 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedZ, this, &QgsAdvancedDigitizingFloater::enabledChangedZ );
92 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedM, this, &QgsAdvancedDigitizingFloater::enabledChangedM );
93 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle );
94 // Bearing capability is the same an angle, connect to the same signal:
95 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedBearing );
96 // Common angle snapping capbility is also linked to angle, connect to the same signal:
97 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping );
98 connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance );
99
100 // Connect our line edits signals to update cadDockWidget's state (implementation copied from QgsAdvancedDigitizingDockWidget)
101 connect( mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
102 connect( mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
103 connect( mZLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
104 connect( mMLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
105 connect( mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() {
106 cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed );
107 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mAngleLineEdit->text(), Qgis::CadConstraintType::Angle ) };
108 whileBlocking( mAngleLineEdit )->setText( cleanedInputValue );
109 } );
110 connect( mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() {
111 cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed );
112 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mDistanceLineEdit->text(), Qgis::CadConstraintType::Distance ) };
113 whileBlocking( mDistanceLineEdit )->setText( cleanedInputValue );
114 } );
115
116 connect( mXLineEdit, &QLineEdit::textEdited, cadDockWidget, [=]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
117 connect( mYLineEdit, &QLineEdit::textEdited, cadDockWidget, [=]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
118 connect( mZLineEdit, &QLineEdit::textEdited, cadDockWidget, [=]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
119 connect( mMLineEdit, &QLineEdit::textEdited, cadDockWidget, [=]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
120 connect( mAngleLineEdit, &QLineEdit::textEdited, cadDockWidget, [=]() { cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
121 connect( mDistanceLineEdit, &QLineEdit::textEdited, cadDockWidget, [=]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
122
123 QgsFocusWatcher *xWatcher = new QgsFocusWatcher( mXLineEdit );
124 connect( xWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
125 QgsFocusWatcher *yWatcher = new QgsFocusWatcher( mYLineEdit );
126 connect( yWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
127 QgsFocusWatcher *zWatcher = new QgsFocusWatcher( mZLineEdit );
128 connect( zWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
129 QgsFocusWatcher *mWatcher = new QgsFocusWatcher( mYLineEdit );
130 connect( mWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
131 QgsFocusWatcher *angleWatcher = new QgsFocusWatcher( mAngleLineEdit );
132 connect( angleWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=]() {
133 cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut );
134 whileBlocking( mAngleLineEdit )->setText( mCadDockWidget->constraintAngle()->displayValue() );
135 } );
136 connect( angleWatcher, &QgsFocusWatcher::focusIn, this, [=]() {
137 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mAngleLineEdit->text(), Qgis::CadConstraintType::Angle ) };
138 whileBlocking( mAngleLineEdit )->setText( cleanedInputValue );
139 } );
140 QgsFocusWatcher *distanceWatcher = new QgsFocusWatcher( mDistanceLineEdit );
141 connect( distanceWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=]() {
142 cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut );
143 whileBlocking( mDistanceLineEdit )->setText( mCadDockWidget->constraintDistance()->displayValue() );
144 } );
145 connect( distanceWatcher, &QgsFocusWatcher::focusIn, this, [=]() {
146 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mDistanceLineEdit->text(), Qgis::CadConstraintType::Distance ) };
147 whileBlocking( mDistanceLineEdit )->setText( cleanedInputValue );
148 } );
149 changeCommonAngleSnapping( mCadDockWidget->commonAngleConstraint() );
150}
151
152bool QgsAdvancedDigitizingFloater::eventFilter( QObject *obj, QEvent *event )
153{
154 if ( mCadDockWidget && mCadDockWidget->cadEnabled() && mActive )
155 {
156 if ( event->type() == QEvent::MouseMove )
157 {
158 // We update the position when mouse moves
159 QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *>( event );
160 updatePos( mouseEvent->pos() );
161 }
162 else if ( event->type() == QEvent::Enter )
163 {
164 // We show the widget when mouse enters
165 QEnterEvent *enterEvent = dynamic_cast<QEnterEvent *>( event );
166 updatePos( enterEvent->pos() );
167 setVisible( true );
168 }
169 else if ( event->type() == QEvent::Leave )
170 {
171 // We hide the widget when mouse leaves
172 setVisible( false );
173 }
174 }
175 return QWidget::eventFilter( obj, event );
176}
177
179{
180 return mActive;
181}
182
184{
185 return mItemsVisibility.testFlag( item );
186}
187
189{
190 QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), active );
191
192 mActive = active;
193
194 hideIfDisabled();
195}
196
198{
199 const QMetaEnum enumData { QMetaEnum::fromType<QgsAdvancedDigitizingFloater::FloaterItem>() };
200 QgsSettings().setValue( QStringLiteral( "/Cad/%1ShowInFloater" ).arg( enumData.valueToKey( static_cast<int>( item ) ) ), visible );
201 mItemsVisibility.setFlag( item, visible );
202 switch ( item )
203 {
205 enabledChangedX( visible );
206 break;
208 enabledChangedY( visible );
209 break;
211 enabledChangedM( visible );
212 break;
214 enabledChangedZ( visible );
215 break;
217 enabledChangedAngle( visible );
218 break;
220 enabledChangedDistance( visible );
221 break;
223 enabledCommonAngleSnapping( visible );
224 break;
226 enabledChangedBearing( visible );
227 break;
228 }
229}
230
231void QgsAdvancedDigitizingFloater::updatePos( const QPoint &pos )
232{
233 // We hardcode a small delta between the mouse position and the widget's position
234 move( pos + QPoint( 15, 5 ) );
235}
236
237void QgsAdvancedDigitizingFloater::hideIfDisabled()
238{
239 if ( !mCadDockWidget || !mCadDockWidget->cadEnabled() || !mActive )
240 {
241 setVisible( false );
242 }
243}
244
245void QgsAdvancedDigitizingFloater::changeX( const QString &text )
246{
247 mXLineEdit->setText( text );
248}
249
250void QgsAdvancedDigitizingFloater::changeY( const QString &text )
251{
252 mYLineEdit->setText( text );
253}
254
255void QgsAdvancedDigitizingFloater::changeZ( const QString &text )
256{
257 mZLineEdit->setText( text );
258}
259
260void QgsAdvancedDigitizingFloater::changeM( const QString &text )
261{
262 mMLineEdit->setText( text );
263}
264
265void QgsAdvancedDigitizingFloater::changeCommonAngleSnapping( double angle )
266{
267 mCommonAngleSnappingLineEdit->setText( qgsDoubleNear( angle, 0.0 ) ? tr( "disabled" ) : QLocale().toString( angle ).append( tr( " °" ) ) );
268}
269
270void QgsAdvancedDigitizingFloater::changeDistance( const QString &text )
271{
272 mDistanceLineEdit->setText( text );
273}
274
275void QgsAdvancedDigitizingFloater::changeAngle( const QString &text )
276{
277 mAngleLineEdit->setText( text );
278}
279
280void QgsAdvancedDigitizingFloater::changeBearing( const QString &text )
281{
282 mBearingLineEdit->setText( text );
283}
284
285void QgsAdvancedDigitizingFloater::changeLockX( bool locked )
286{
287 if ( !locked )
288 {
289 mXLineEdit->setStyleSheet( QString() );
290 mXLabel->setStyleSheet( QString() );
291 }
292 else
293 {
294 mXLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
295 mXLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
296 }
297}
298
299void QgsAdvancedDigitizingFloater::changeLockY( bool locked )
300{
301 if ( !locked )
302 {
303 mYLineEdit->setStyleSheet( QString() );
304 mYLabel->setStyleSheet( QString() );
305 }
306 else
307 {
308 mYLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
309 mYLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
310 }
311}
312
313void QgsAdvancedDigitizingFloater::changeLockZ( bool locked )
314{
315 if ( !locked )
316 {
317 mZLineEdit->setStyleSheet( QString() );
318 mZLabel->setStyleSheet( QString() );
319 }
320 else
321 {
322 mZLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
323 mZLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
324 }
325}
326
327void QgsAdvancedDigitizingFloater::changeLockM( bool locked )
328{
329 if ( !locked )
330 {
331 mMLineEdit->setStyleSheet( QString() );
332 mMLabel->setStyleSheet( QString() );
333 }
334 else
335 {
336 mMLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
337 mMLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
338 }
339}
340
341void QgsAdvancedDigitizingFloater::changeLockDistance( bool locked )
342{
343 if ( !locked )
344 {
345 mDistanceLineEdit->setStyleSheet( QString() );
346 mDistanceLabel->setStyleSheet( QString() );
347 }
348 else
349 {
350 mDistanceLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
351 mDistanceLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
352 }
353}
354
355void QgsAdvancedDigitizingFloater::changeLockAngle( bool locked )
356{
357 if ( !locked )
358 {
359 mAngleLineEdit->setStyleSheet( QString() );
360 mAngleLabel->setStyleSheet( QString() );
361 }
362 else
363 {
364 mAngleLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
365 mAngleLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
366 }
367}
368
369
370void QgsAdvancedDigitizingFloater::changeRelativeX( bool relative )
371{
372 if ( !relative )
373 {
374 mXLabel->setText( "x" );
375 }
376 else
377 {
378 mXLabel->setText( "Δx" );
379 }
380 adjustSize();
381}
382
383void QgsAdvancedDigitizingFloater::changeRelativeY( bool relative )
384{
385 if ( !relative )
386 {
387 mYLabel->setText( "y" );
388 }
389 else
390 {
391 mYLabel->setText( "Δy" );
392 }
393 adjustSize();
394}
395
396void QgsAdvancedDigitizingFloater::changeRelativeZ( bool relative )
397{
398 if ( !relative )
399 {
400 mZLabel->setText( "z" );
401 }
402 else
403 {
404 mZLabel->setText( "Δz" );
405 }
406 adjustSize();
407}
408
409void QgsAdvancedDigitizingFloater::changeRelativeM( bool relative )
410{
411 if ( !relative )
412 {
413 mMLabel->setText( "m" );
414 }
415 else
416 {
417 mMLabel->setText( "Δm" );
418 }
419 adjustSize();
420}
421
422// distance is always relative
423
424void QgsAdvancedDigitizingFloater::changeRelativeAngle( bool relative )
425{
426 if ( !relative )
427 {
428 mAngleLabel->setText( "a" );
429 }
430 else
431 {
432 mAngleLabel->setText( "Δa" );
433 }
434 adjustSize();
435}
436
437void QgsAdvancedDigitizingFloater::focusOnX()
438{
439 if ( mActive )
440 {
441 mXLineEdit->setFocus();
442 mXLineEdit->selectAll();
443 }
444}
445
446void QgsAdvancedDigitizingFloater::focusOnY()
447{
448 if ( mActive )
449 {
450 mYLineEdit->setFocus();
451 mYLineEdit->selectAll();
452 }
453}
454
455void QgsAdvancedDigitizingFloater::focusOnZ()
456{
457 if ( mActive )
458 {
459 mZLineEdit->setFocus();
460 mZLineEdit->selectAll();
461 }
462}
463
464void QgsAdvancedDigitizingFloater::focusOnM()
465{
466 if ( mActive )
467 {
468 mMLineEdit->setFocus();
469 mMLineEdit->selectAll();
470 }
471}
472
473void QgsAdvancedDigitizingFloater::focusOnDistance()
474{
475 if ( mActive )
476 {
477 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mDistanceLineEdit->text(), Qgis::CadConstraintType::Distance ) };
478 mDistanceLineEdit->setText( cleanedInputValue );
479 mDistanceLineEdit->setFocus();
480 mDistanceLineEdit->selectAll();
481 }
482}
483
484void QgsAdvancedDigitizingFloater::focusOnAngle()
485{
486 if ( mActive )
487 {
488 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mAngleLineEdit->text(), Qgis::CadConstraintType::Angle ) };
489 mAngleLineEdit->setText( cleanedInputValue );
490 mAngleLineEdit->setFocus();
491 mAngleLineEdit->selectAll();
492 }
493}
494
495
496void QgsAdvancedDigitizingFloater::enabledChangedX( bool enabled )
497{
498 mXLineEdit->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
499 mXLabel->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
500 adjustSize();
501}
502
503void QgsAdvancedDigitizingFloater::enabledChangedY( bool enabled )
504{
505 mYLineEdit->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
506 mYLabel->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
507 adjustSize();
508}
509
510void QgsAdvancedDigitizingFloater::enabledChangedZ( bool enabled )
511{
512 mZLineEdit->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
513 mZLabel->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
514 adjustSize();
515}
516
517void QgsAdvancedDigitizingFloater::enabledChangedM( bool enabled )
518{
519 mMLineEdit->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
520 mMLabel->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
521 adjustSize();
522}
523
524void QgsAdvancedDigitizingFloater::enabledChangedDistance( bool enabled )
525{
526 mDistanceLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
527 mDistanceLabel->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
528 adjustSize();
529}
530
531void QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping( bool enabled )
532{
533 mCommonAngleSnappingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
534 mCommonAngleSnappingLabel->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
535 adjustSize();
536}
537
538void QgsAdvancedDigitizingFloater::enabledChangedAngle( bool enabled )
539{
540 mAngleLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
541 mAngleLabel->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
542 adjustSize();
543}
544
545void QgsAdvancedDigitizingFloater::enabledChangedBearing( bool enabled )
546{
547 mBearingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
548 mBearingLabel->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
549 adjustSize();
550}
@ Distance
Distance value.
static QString removeSuffix(const QString &text, Qgis::CadConstraintType constraintType)
Removes unit suffix from the constraint text.
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 focusIn()
Emitted when parent object gains focus.
void focusOut()
Emitted when parent object loses focus.
Map canvas is a class for displaying all GIS data types on a canvas.
This class is a composition of two QSettings instances:
Definition qgssettings.h:64
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)
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition qgis.h:6024
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:5928