27 : QWidget( canvas->viewport() )
28 , mMapCanvas( canvas )
29 , mCadDockWidget( cadDockWidget )
33 setAttribute( Qt::WA_TransparentForMouseEvents );
41 mMapCanvas->viewport()->installEventFilter(
this );
42 mMapCanvas->viewport()->setMouseTracking(
true );
45 mAngleLineEdit->installEventFilter( cadDockWidget );
46 mDistanceLineEdit->installEventFilter( cadDockWidget );
47 mXLineEdit->installEventFilter( cadDockWidget );
48 mYLineEdit->installEventFilter( cadDockWidget );
49 mZLineEdit->installEventFilter( cadDockWidget );
50 mMLineEdit->installEventFilter( cadDockWidget );
91 connect( mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->
setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
92 connect( mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->
setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
93 connect( mZLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->
setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
94 connect( mMLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->
setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
95 connect( mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->
setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
96 connect( mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->
setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::ReturnPressed ); } );
98 connect( mXLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->
setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
99 connect( mYLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->
setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
100 connect( mZLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->
setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
101 connect( mMLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->
setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
102 connect( mAngleLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->
setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
103 connect( mDistanceLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->
setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );
106 connect( xWatcher, &
QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->
setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
108 connect( yWatcher, &
QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->
setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
110 connect( zWatcher, &
QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->
setZ( mZLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
112 connect( mWatcher, &
QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->
setM( mMLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
114 connect( angleWatcher, &
QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->
setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
116 connect( distanceWatcher, &
QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->
setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
120bool QgsAdvancedDigitizingFloater::eventFilter( QObject *obj, QEvent *event )
122 if ( mCadDockWidget && mCadDockWidget->cadEnabled() && mActive )
124 if ( event->type() == QEvent::MouseMove )
127 QMouseEvent *mouseEvent =
dynamic_cast<QMouseEvent *
>( event );
128 updatePos( mouseEvent->pos() );
130 else if ( event->type() == QEvent::Enter )
133 QEnterEvent *enterEvent =
dynamic_cast<QEnterEvent *
>( event );
134 updatePos( enterEvent->pos() );
137 else if ( event->type() == QEvent::Leave )
143 return QWidget::eventFilter( obj, event );
160void QgsAdvancedDigitizingFloater::updatePos(
const QPoint &pos )
163 move( pos + QPoint( 15, 5 ) );
166void QgsAdvancedDigitizingFloater::hideIfDisabled()
168 if ( !mCadDockWidget || ! mCadDockWidget->cadEnabled() || ! mActive )
174void QgsAdvancedDigitizingFloater::changeX(
const QString &text )
176 mXLineEdit->setText( text );
179void QgsAdvancedDigitizingFloater::changeY(
const QString &text )
181 mYLineEdit->setText( text );
184void QgsAdvancedDigitizingFloater::changeZ(
const QString &text )
186 mZLineEdit->setText( text );
189void QgsAdvancedDigitizingFloater::changeM(
const QString &text )
191 mMLineEdit->setText( text );
194void QgsAdvancedDigitizingFloater::changeDistance(
const QString &text )
196 mDistanceLineEdit->setText( text );
199void QgsAdvancedDigitizingFloater::changeAngle(
const QString &text )
201 mAngleLineEdit->setText( text );
204void QgsAdvancedDigitizingFloater::changeLockX(
bool locked )
208 mXLineEdit->setStyleSheet( QString() );
209 mXLabel->setStyleSheet( QString() );
213 mXLineEdit->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
214 mXLabel->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
218void QgsAdvancedDigitizingFloater::changeLockY(
bool locked )
222 mYLineEdit->setStyleSheet( QString() );
223 mYLabel->setStyleSheet( QString() );
227 mYLineEdit->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
228 mYLabel->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
232void QgsAdvancedDigitizingFloater::changeLockZ(
bool locked )
236 mZLineEdit->setStyleSheet( QString() );
237 mZLabel->setStyleSheet( QString() );
241 mZLineEdit->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
242 mZLabel->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
246void QgsAdvancedDigitizingFloater::changeLockM(
bool locked )
250 mMLineEdit->setStyleSheet( QString() );
251 mMLabel->setStyleSheet( QString() );
255 mMLineEdit->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
256 mMLabel->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
260void QgsAdvancedDigitizingFloater::changeLockDistance(
bool locked )
264 mDistanceLineEdit->setStyleSheet( QString() );
265 mDistanceLabel->setStyleSheet( QString() );
269 mDistanceLineEdit->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
270 mDistanceLabel->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
274void QgsAdvancedDigitizingFloater::changeLockAngle(
bool locked )
278 mAngleLineEdit->setStyleSheet( QString() );
279 mAngleLabel->setStyleSheet( QString() );
283 mAngleLineEdit->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
284 mAngleLabel->setStyleSheet( QStringLiteral(
"font-weight: bold" ) );
289void QgsAdvancedDigitizingFloater::changeRelativeX(
bool relative )
293 mXLabel->setText(
"x" );
297 mXLabel->setText(
"Δx" );
302void QgsAdvancedDigitizingFloater::changeRelativeY(
bool relative )
306 mYLabel->setText(
"y" );
310 mYLabel->setText(
"Δy" );
315void QgsAdvancedDigitizingFloater::changeRelativeZ(
bool relative )
319 mZLabel->setText(
"z" );
323 mZLabel->setText(
"Δz" );
328void QgsAdvancedDigitizingFloater::changeRelativeM(
bool relative )
332 mMLabel->setText(
"m" );
336 mMLabel->setText(
"Δm" );
343void QgsAdvancedDigitizingFloater::changeRelativeAngle(
bool relative )
347 mAngleLabel->setText(
"a" );
351 mAngleLabel->setText(
"Δa" );
356void QgsAdvancedDigitizingFloater::focusOnX()
360 mXLineEdit->setFocus();
361 mXLineEdit->selectAll();
365void QgsAdvancedDigitizingFloater::focusOnY()
369 mYLineEdit->setFocus();
370 mYLineEdit->selectAll();
374void QgsAdvancedDigitizingFloater::focusOnZ()
378 mZLineEdit->setFocus();
379 mZLineEdit->selectAll();
383void QgsAdvancedDigitizingFloater::focusOnM()
387 mMLineEdit->setFocus();
388 mMLineEdit->selectAll();
392void QgsAdvancedDigitizingFloater::focusOnDistance()
396 mDistanceLineEdit->setFocus();
397 mDistanceLineEdit->selectAll();
401void QgsAdvancedDigitizingFloater::focusOnAngle()
405 mAngleLineEdit->setFocus();
406 mAngleLineEdit->selectAll();
411void QgsAdvancedDigitizingFloater::enabledChangedX(
bool enabled )
413 mXLineEdit->setVisible( enabled );
414 mXLabel->setVisible( enabled );
418void QgsAdvancedDigitizingFloater::enabledChangedY(
bool enabled )
420 mYLineEdit->setVisible( enabled );
421 mYLabel->setVisible( enabled );
425void QgsAdvancedDigitizingFloater::enabledChangedZ(
bool enabled )
427 mZLineEdit->setVisible( enabled );
428 mZLabel->setVisible( enabled );
432void QgsAdvancedDigitizingFloater::enabledChangedM(
bool enabled )
434 mMLineEdit->setVisible( enabled );
435 mMLabel->setVisible( enabled );
439void QgsAdvancedDigitizingFloater::enabledChangedDistance(
bool enabled )
441 mDistanceLineEdit->setVisible( enabled );
442 mDistanceLabel->setVisible( enabled );
446void QgsAdvancedDigitizingFloater::enabledChangedAngle(
bool enabled )
448 mAngleLineEdit->setVisible( enabled );
449 mAngleLabel->setVisible( enabled );
QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Create an advanced digitizing floater widget.
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.
This class is a composition of two QSettings instances:
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.