QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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 {
107 cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed );
108 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mAngleLineEdit->text(), Qgis::CadConstraintType::Angle ) };
109 whileBlocking( mAngleLineEdit )->setText( cleanedInputValue );
110 } );
111 connect( mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]()
112 {
113 cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed );
114 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mDistanceLineEdit->text(), Qgis::CadConstraintType::Distance ) };
115 whileBlocking( mDistanceLineEdit )->setText( cleanedInputValue );
116 } );
117
118 connect( mXLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
119 connect( mYLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
120 connect( mZLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
121 connect( mMLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
122 connect( mAngleLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
123 connect( mDistanceLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
124
125 QgsFocusWatcher *xWatcher = new QgsFocusWatcher( mXLineEdit );
126 connect( xWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
127 QgsFocusWatcher *yWatcher = new QgsFocusWatcher( mYLineEdit );
128 connect( yWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
129 QgsFocusWatcher *zWatcher = new QgsFocusWatcher( mZLineEdit );
130 connect( zWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
131 QgsFocusWatcher *mWatcher = new QgsFocusWatcher( mYLineEdit );
132 connect( mWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
133 QgsFocusWatcher *angleWatcher = new QgsFocusWatcher( mAngleLineEdit );
134 connect( angleWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]()
135 {
136 cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut );
137 whileBlocking( mAngleLineEdit )->setText( mCadDockWidget->constraintAngle()->displayValue() );
138 } );
139 connect( angleWatcher, &QgsFocusWatcher::focusIn, this, [ = ]()
140 {
141 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mAngleLineEdit->text(), Qgis::CadConstraintType::Angle ) };
142 whileBlocking( mAngleLineEdit )->setText( cleanedInputValue );
143 } );
144 QgsFocusWatcher *distanceWatcher = new QgsFocusWatcher( mDistanceLineEdit );
145 connect( distanceWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]()
146 {
147 cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut );
148 whileBlocking( mDistanceLineEdit )->setText( mCadDockWidget->constraintDistance()->displayValue() );
149 } );
150 connect( distanceWatcher, &QgsFocusWatcher::focusIn, this, [ = ]()
151 {
152 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mDistanceLineEdit->text(), Qgis::CadConstraintType::Distance ) };
153 whileBlocking( mDistanceLineEdit )->setText( cleanedInputValue );
154 } );
155 changeCommonAngleSnapping( mCadDockWidget->commonAngleConstraint() );
156
157
158
159}
160
161bool QgsAdvancedDigitizingFloater::eventFilter( QObject *obj, QEvent *event )
162{
163 if ( mCadDockWidget && mCadDockWidget->cadEnabled() && mActive )
164 {
165 if ( event->type() == QEvent::MouseMove )
166 {
167 // We update the position when mouse moves
168 QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *>( event );
169 updatePos( mouseEvent->pos() );
170 }
171 else if ( event->type() == QEvent::Enter )
172 {
173 // We show the widget when mouse enters
174 QEnterEvent *enterEvent = dynamic_cast<QEnterEvent *>( event );
175 updatePos( enterEvent->pos() );
176 setVisible( true );
177 }
178 else if ( event->type() == QEvent::Leave )
179 {
180 // We hide the widget when mouse leaves
181 setVisible( false );
182 }
183 }
184 return QWidget::eventFilter( obj, event );
185}
186
188{
189 return mActive;
190}
191
193{
194 return mItemsVisibility.testFlag( item );
195}
196
198{
199 QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), active );
200
201 mActive = active;
202
203 hideIfDisabled();
204}
205
207{
208 const QMetaEnum enumData { QMetaEnum::fromType<QgsAdvancedDigitizingFloater::FloaterItem>() };
209 QgsSettings().setValue( QStringLiteral( "/Cad/%1ShowInFloater" ).arg( enumData.valueToKey( static_cast<int>( item ) ) ), visible );
210 mItemsVisibility.setFlag( item, visible );
211 switch ( item )
212 {
214 enabledChangedX( visible );
215 break;
217 enabledChangedY( visible );
218 break;
220 enabledChangedM( visible );
221 break;
223 enabledChangedZ( visible );
224 break;
226 enabledChangedAngle( visible );
227 break;
229 enabledChangedDistance( visible );
230 break;
232 enabledCommonAngleSnapping( visible );
233 break;
235 enabledChangedBearing( visible );
236 break;
237 }
238}
239
240void QgsAdvancedDigitizingFloater::updatePos( const QPoint &pos )
241{
242 // We hardcode a small delta between the mouse position and the widget's position
243 move( pos + QPoint( 15, 5 ) );
244}
245
246void QgsAdvancedDigitizingFloater::hideIfDisabled()
247{
248 if ( !mCadDockWidget || ! mCadDockWidget->cadEnabled() || ! mActive )
249 {
250 setVisible( false );
251 }
252}
253
254void QgsAdvancedDigitizingFloater::changeX( const QString &text )
255{
256 mXLineEdit->setText( text );
257}
258
259void QgsAdvancedDigitizingFloater::changeY( const QString &text )
260{
261 mYLineEdit->setText( text );
262}
263
264void QgsAdvancedDigitizingFloater::changeZ( const QString &text )
265{
266 mZLineEdit->setText( text );
267}
268
269void QgsAdvancedDigitizingFloater::changeM( const QString &text )
270{
271 mMLineEdit->setText( text );
272}
273
274void QgsAdvancedDigitizingFloater::changeCommonAngleSnapping( double angle )
275{
276 mCommonAngleSnappingLineEdit->setText( qgsDoubleNear( angle, 0.0 ) ? tr( "disabled" ) : QLocale().toString( angle ).append( tr( " °" ) ) );
277}
278
279void QgsAdvancedDigitizingFloater::changeDistance( const QString &text )
280{
281 mDistanceLineEdit->setText( text );
282}
283
284void QgsAdvancedDigitizingFloater::changeAngle( const QString &text )
285{
286 mAngleLineEdit->setText( text );
287}
288
289void QgsAdvancedDigitizingFloater::changeBearing( const QString &text )
290{
291 mBearingLineEdit->setText( text );
292}
293
294void QgsAdvancedDigitizingFloater::changeLockX( bool locked )
295{
296 if ( !locked )
297 {
298 mXLineEdit->setStyleSheet( QString() );
299 mXLabel->setStyleSheet( QString() );
300 }
301 else
302 {
303 mXLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
304 mXLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
305 }
306}
307
308void QgsAdvancedDigitizingFloater::changeLockY( bool locked )
309{
310 if ( !locked )
311 {
312 mYLineEdit->setStyleSheet( QString() );
313 mYLabel->setStyleSheet( QString() );
314 }
315 else
316 {
317 mYLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
318 mYLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
319 }
320}
321
322void QgsAdvancedDigitizingFloater::changeLockZ( bool locked )
323{
324 if ( !locked )
325 {
326 mZLineEdit->setStyleSheet( QString() );
327 mZLabel->setStyleSheet( QString() );
328 }
329 else
330 {
331 mZLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
332 mZLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
333 }
334}
335
336void QgsAdvancedDigitizingFloater::changeLockM( bool locked )
337{
338 if ( !locked )
339 {
340 mMLineEdit->setStyleSheet( QString() );
341 mMLabel->setStyleSheet( QString() );
342 }
343 else
344 {
345 mMLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
346 mMLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
347 }
348}
349
350void QgsAdvancedDigitizingFloater::changeLockDistance( bool locked )
351{
352 if ( !locked )
353 {
354 mDistanceLineEdit->setStyleSheet( QString() );
355 mDistanceLabel->setStyleSheet( QString() );
356 }
357 else
358 {
359 mDistanceLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
360 mDistanceLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
361 }
362}
363
364void QgsAdvancedDigitizingFloater::changeLockAngle( bool locked )
365{
366 if ( !locked )
367 {
368 mAngleLineEdit->setStyleSheet( QString() );
369 mAngleLabel->setStyleSheet( QString() );
370 }
371 else
372 {
373 mAngleLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
374 mAngleLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) );
375 }
376}
377
378
379void QgsAdvancedDigitizingFloater::changeRelativeX( bool relative )
380{
381 if ( !relative )
382 {
383 mXLabel->setText( "x" );
384 }
385 else
386 {
387 mXLabel->setText( "Δx" );
388 }
389 adjustSize();
390}
391
392void QgsAdvancedDigitizingFloater::changeRelativeY( bool relative )
393{
394 if ( !relative )
395 {
396 mYLabel->setText( "y" );
397 }
398 else
399 {
400 mYLabel->setText( "Δy" );
401 }
402 adjustSize();
403}
404
405void QgsAdvancedDigitizingFloater::changeRelativeZ( bool relative )
406{
407 if ( !relative )
408 {
409 mZLabel->setText( "z" );
410 }
411 else
412 {
413 mZLabel->setText( "Δz" );
414 }
415 adjustSize();
416}
417
418void QgsAdvancedDigitizingFloater::changeRelativeM( bool relative )
419{
420 if ( !relative )
421 {
422 mMLabel->setText( "m" );
423 }
424 else
425 {
426 mMLabel->setText( "Δm" );
427 }
428 adjustSize();
429}
430
431// distance is always relative
432
433void QgsAdvancedDigitizingFloater::changeRelativeAngle( bool relative )
434{
435 if ( !relative )
436 {
437 mAngleLabel->setText( "a" );
438 }
439 else
440 {
441 mAngleLabel->setText( "Δa" );
442 }
443 adjustSize();
444}
445
446void QgsAdvancedDigitizingFloater::focusOnX()
447{
448 if ( mActive )
449 {
450 mXLineEdit->setFocus();
451 mXLineEdit->selectAll();
452 }
453}
454
455void QgsAdvancedDigitizingFloater::focusOnY()
456{
457 if ( mActive )
458 {
459 mYLineEdit->setFocus();
460 mYLineEdit->selectAll();
461 }
462}
463
464void QgsAdvancedDigitizingFloater::focusOnZ()
465{
466 if ( mActive )
467 {
468 mZLineEdit->setFocus();
469 mZLineEdit->selectAll();
470 }
471}
472
473void QgsAdvancedDigitizingFloater::focusOnM()
474{
475 if ( mActive )
476 {
477 mMLineEdit->setFocus();
478 mMLineEdit->selectAll();
479 }
480}
481
482void QgsAdvancedDigitizingFloater::focusOnDistance()
483{
484 if ( mActive )
485 {
486 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mDistanceLineEdit->text(), Qgis::CadConstraintType::Distance ) };
487 mDistanceLineEdit->setText( cleanedInputValue );
488 mDistanceLineEdit->setFocus();
489 mDistanceLineEdit->selectAll();
490 }
491}
492
493void QgsAdvancedDigitizingFloater::focusOnAngle()
494{
495 if ( mActive )
496 {
497 const QString cleanedInputValue { QgsAdvancedDigitizingDockWidget::CadConstraint::removeSuffix( mAngleLineEdit->text(), Qgis::CadConstraintType::Angle ) };
498 mAngleLineEdit->setText( cleanedInputValue );
499 mAngleLineEdit->setFocus();
500 mAngleLineEdit->selectAll();
501 }
502}
503
504
505void QgsAdvancedDigitizingFloater::enabledChangedX( bool enabled )
506{
507 mXLineEdit->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
508 mXLabel->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
509 adjustSize();
510}
511
512void QgsAdvancedDigitizingFloater::enabledChangedY( bool enabled )
513{
514 mYLineEdit->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
515 mYLabel->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
516 adjustSize();
517}
518
519void QgsAdvancedDigitizingFloater::enabledChangedZ( bool enabled )
520{
521 mZLineEdit->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
522 mZLabel->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
523 adjustSize();
524}
525
526void QgsAdvancedDigitizingFloater::enabledChangedM( bool enabled )
527{
528 mMLineEdit->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
529 mMLabel->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
530 adjustSize();
531}
532
533void QgsAdvancedDigitizingFloater::enabledChangedDistance( bool enabled )
534{
535 mDistanceLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
536 mDistanceLabel->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
537 adjustSize();
538}
539
540void QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping( bool enabled )
541{
542 mCommonAngleSnappingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
543 mCommonAngleSnappingLabel->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
544 adjustSize();
545}
546
547void QgsAdvancedDigitizingFloater::enabledChangedAngle( bool enabled )
548{
549 mAngleLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
550 mAngleLabel->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
551 adjustSize();
552}
553
554void QgsAdvancedDigitizingFloater::enabledChangedBearing( bool enabled )
555{
556 mBearingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
557 mBearingLabel->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
558 adjustSize();
559}
@ 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:5917
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:5821