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