40 , mMapCanvas( canvas )
42 , mCommonAngleConstraint(
QgsSettings().value( QStringLiteral(
"/Cad/CommonAngle" ), 90 ).toDouble() )
48 mAngleConstraint.reset(
new CadConstraint( mAngleLineEdit, mLockAngleButton, mRelativeAngleButton, mRepeatingLockAngleButton ) );
49 mDistanceConstraint.reset(
new CadConstraint( mDistanceLineEdit, mLockDistanceButton,
nullptr, mRepeatingLockDistanceButton ) );
50 mXConstraint.reset(
new CadConstraint( mXLineEdit, mLockXButton, mRelativeXButton, mRepeatingLockXButton ) );
51 mYConstraint.reset(
new CadConstraint( mYLineEdit, mLockYButton, mRelativeYButton, mRepeatingLockYButton ) );
54 mMapCanvas->installEventFilter(
this );
55 mAngleLineEdit->installEventFilter(
this );
56 mDistanceLineEdit->installEventFilter(
this );
57 mXLineEdit->installEventFilter(
this );
58 mYLineEdit->installEventFilter(
this );
61 connect( mEnableAction, &QAction::triggered,
this, &QgsAdvancedDigitizingDockWidget::activateCad );
62 connect( mConstructionModeAction, &QAction::triggered,
this, &QgsAdvancedDigitizingDockWidget::setConstructionMode );
63 connect( mParallelAction, &QAction::triggered,
this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked );
64 connect( mPerpendicularAction, &QAction::triggered,
this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked );
65 connect( mLockAngleButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
66 connect( mLockDistanceButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
67 connect( mLockXButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
68 connect( mLockYButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
69 connect( mRelativeAngleButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::setConstraintRelative );
70 connect( mRelativeXButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::setConstraintRelative );
71 connect( mRelativeYButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::setConstraintRelative );
72 connect( mRepeatingLockDistanceButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
73 connect( mRepeatingLockAngleButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
74 connect( mRepeatingLockXButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
75 connect( mRepeatingLockYButton, &QAbstractButton::clicked,
this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
76 connect( mAngleLineEdit, &QLineEdit::returnPressed,
this, [ = ]() { lockConstraint(); } );
77 connect( mDistanceLineEdit, &QLineEdit::returnPressed,
this, [ = ]() { lockConstraint(); } );
78 connect( mXLineEdit, &QLineEdit::returnPressed,
this, [ = ]() { lockConstraint(); } );
79 connect( mYLineEdit, &QLineEdit::returnPressed,
this, [ = ]() { lockConstraint(); } );
80 connect( mAngleLineEdit, &QLineEdit::textEdited,
this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
81 connect( mDistanceLineEdit, &QLineEdit::textEdited,
this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
82 connect( mXLineEdit, &QLineEdit::textEdited,
this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
83 connect( mYLineEdit, &QLineEdit::textEdited,
this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
95 QMenu *menu =
new QMenu(
this );
97 QActionGroup *angleButtonGroup =
new QActionGroup( menu );
98 mCommonAngleActions = QMap<QAction *, double>();
99 QList< QPair< double, QString > > commonAngles;
101 QList<double> anglesDouble( { 0.0, 5.0, 10.0, 15.0, 18.0, 22.5, 30.0, 45.0, 90.0} );
102 for ( QList<double>::const_iterator it = anglesDouble.constBegin(); it != anglesDouble.constEnd(); ++it )
105 menuText = tr(
"Do Not Snap to Common Angles" );
107 menuText = QString( tr(
"%1, %2, %3, %4°…" ) ).arg( *it, 0,
'f', 1 ).arg( *it * 2, 0,
'f', 1 ).arg( *it * 3, 0,
'f', 1 ).arg( *it * 4, 0,
'f', 1 );
108 commonAngles << QPair<double, QString>( *it, menuText );
110 for ( QList< QPair<double, QString > >::const_iterator it = commonAngles.constBegin(); it != commonAngles.constEnd(); ++it )
112 QAction *action =
new QAction( it->second, menu );
113 action->setCheckable(
true );
114 action->setChecked( it->first == mCommonAngleConstraint );
115 menu->addAction( action );
116 angleButtonGroup->addAction( action );
117 mCommonAngleActions.insert( action, it->first );
120 qobject_cast< QToolButton *>( mToolbar->widgetForAction( mSettingsAction ) )->setPopupMode( QToolButton::InstantPopup );
121 mSettingsAction->setMenu( menu );
122 connect( menu, &QMenu::triggered,
this, &QgsAdvancedDigitizingDockWidget::settingsButtonTriggered );
125 mConstructionModeAction->setToolTip(
"<b>" + tr(
"Construction mode" ) +
"</b><br>(" + tr(
"press c to toggle on/off" ) +
")" );
126 mDistanceLineEdit->setToolTip(
"<b>" + tr(
"Distance" ) +
"</b><br>(" + tr(
"press d for quick access" ) +
")" );
127 mLockDistanceButton->setToolTip(
"<b>" + tr(
"Lock distance" ) +
"</b><br>(" + tr(
"press Ctrl + d for quick access" ) +
")" );
128 mRepeatingLockDistanceButton->setToolTip(
"<b>" + tr(
"Continuously lock distance" ) +
"</b>" );
130 mRelativeAngleButton->setToolTip(
"<b>" + tr(
"Toggles relative angle to previous segment" ) +
"</b><br>(" + tr(
"press Shift + a for quick access" ) +
")" );
131 mAngleLineEdit->setToolTip(
"<b>" + tr(
"Angle" ) +
"</b><br>(" + tr(
"press a for quick access" ) +
")" );
132 mLockAngleButton->setToolTip(
"<b>" + tr(
"Lock angle" ) +
"</b><br>(" + tr(
"press Ctrl + a for quick access" ) +
")" );
133 mRepeatingLockAngleButton->setToolTip(
"<b>" + tr(
"Continuously lock angle" ) +
"</b>" );
135 mRelativeXButton->setToolTip(
"<b>" + tr(
"Toggles relative x to previous node" ) +
"</b><br>(" + tr(
"press Shift + x for quick access" ) +
")" );
136 mXLineEdit->setToolTip(
"<b>" + tr(
"X coordinate" ) +
"</b><br>(" + tr(
"press x for quick access" ) +
")" );
137 mLockXButton->setToolTip(
"<b>" + tr(
"Lock x coordinate" ) +
"</b><br>(" + tr(
"press Ctrl + x for quick access" ) +
")" );
138 mRepeatingLockXButton->setToolTip(
"<b>" + tr(
"Continuously lock x coordinate" ) +
"</b>" );
140 mRelativeYButton->setToolTip(
"<b>" + tr(
"Toggles relative y to previous node" ) +
"</b><br>(" + tr(
"press Shift + y for quick access" ) +
")" );
141 mYLineEdit->setToolTip(
"<b>" + tr(
"Y coordinate" ) +
"</b><br>(" + tr(
"press y for quick access" ) +
")" );
142 mLockYButton->setToolTip(
"<b>" + tr(
"Lock y coordinate" ) +
"</b><br>(" + tr(
"press Ctrl + y for quick access" ) +
")" );
143 mRepeatingLockYButton->setToolTip(
"<b>" + tr(
"Continuously lock y coordinate" ) +
"</b>" );
146 updateCapacity(
true );
156 setCadEnabled(
false );
159 void QgsAdvancedDigitizingDockWidget::setCadEnabled(
bool enabled )
161 mCadEnabled = enabled;
162 mEnableAction->setChecked( enabled );
163 mConstructionModeAction->setEnabled( enabled );
164 mParallelAction->setEnabled( enabled );
165 mPerpendicularAction->setEnabled( enabled );
166 mSettingsAction->setEnabled( enabled );
167 mInputWidgets->setEnabled( enabled );
170 setConstructionMode(
false );
173 void QgsAdvancedDigitizingDockWidget::activateCad(
bool enabled )
175 enabled &= mCurrentMapToolSupportsCad;
177 mSessionActive = enabled;
179 if ( enabled && !isVisible() )
184 setCadEnabled( enabled );
187 void QgsAdvancedDigitizingDockWidget::additionalConstraintClicked(
bool activated )
193 if ( sender() == mParallelAction )
195 lockAdditionalConstraint(
Parallel );
197 else if ( sender() == mPerpendicularAction )
203 void QgsAdvancedDigitizingDockWidget::setConstraintRelative(
bool activate )
205 if ( sender() == mRelativeAngleButton )
207 mAngleConstraint->setRelative( activate );
209 else if ( sender() == mRelativeXButton )
211 mXConstraint->setRelative( activate );
213 else if ( sender() == mRelativeYButton )
215 mYConstraint->setRelative( activate );
219 void QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock(
bool activate )
221 if ( sender() == mRepeatingLockDistanceButton )
223 mDistanceConstraint->setRepeatingLock( activate );
225 else if ( sender() == mRepeatingLockAngleButton )
227 mAngleConstraint->setRepeatingLock( activate );
229 else if ( sender() == mRepeatingLockXButton )
231 mXConstraint->setRepeatingLock( activate );
233 else if ( sender() == mRepeatingLockYButton )
235 mYConstraint->setRepeatingLock( activate );
239 void QgsAdvancedDigitizingDockWidget::setConstructionMode(
bool enabled )
241 mConstructionMode = enabled;
242 mConstructionModeAction->setChecked( enabled );
245 void QgsAdvancedDigitizingDockWidget::settingsButtonTriggered( QAction *action )
248 QMap<QAction *, double>::const_iterator ica = mCommonAngleActions.constFind( action );
249 if ( ica != mCommonAngleActions.constEnd() )
251 ica.key()->setChecked(
true );
252 mCommonAngleConstraint = ica.value();
264 if ( releaseRepeatingLocks || !mAngleConstraint->isRepeatingLock() )
266 if ( releaseRepeatingLocks || !mDistanceConstraint->isRepeatingLock() )
268 if ( releaseRepeatingLocks || !mXConstraint->isRepeatingLock() )
270 if ( releaseRepeatingLocks || !mYConstraint->isRepeatingLock() )
275 void QgsAdvancedDigitizingDockWidget::emit
pointChanged()
278 QPoint globalPos = mMapCanvas->cursor().pos();
279 QPoint pos = mMapCanvas->mapFromGlobal( globalPos );
280 QMouseEvent *e =
new QMouseEvent( QEvent::MouseMove, pos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier );
281 mCurrentMapTool->canvasMoveEvent( e );
288 if ( obj == mAngleLineEdit || obj == mLockAngleButton )
290 constraint = mAngleConstraint.get();
292 else if ( obj == mDistanceLineEdit || obj == mLockDistanceButton )
294 constraint = mDistanceConstraint.get();
296 else if ( obj == mXLineEdit || obj == mLockXButton )
298 constraint = mXConstraint.get();
300 else if ( obj == mYLineEdit || obj == mLockYButton )
302 constraint = mYConstraint.get();
307 double QgsAdvancedDigitizingDockWidget::parseUserInput(
const QString &inputValue,
bool &ok )
const 323 value = result.toDouble( &ok );
328 void QgsAdvancedDigitizingDockWidget::updateConstraintValue(
CadConstraint *constraint,
const QString &textValue,
bool convertExpression )
330 if ( !constraint || textValue.isEmpty() )
339 double value = parseUserInput( textValue, ok );
343 constraint->
setValue( value, convertExpression );
348 void QgsAdvancedDigitizingDockWidget::lockConstraint(
bool activate )
358 QString textValue = constraint->
lineEdit()->text();
359 if ( !textValue.isEmpty() )
362 double value = parseUserInput( textValue, ok );
382 if ( constraint == mAngleConstraint.get() )
392 void QgsAdvancedDigitizingDockWidget::constraintTextEdited(
const QString &textValue )
400 updateConstraintValue( constraint, textValue,
false );
403 void QgsAdvancedDigitizingDockWidget::constraintFocusOut()
405 QLineEdit *lineEdit = qobject_cast< QLineEdit * >( sender()->parent() );
415 updateConstraintValue( constraint, lineEdit->text(), true );
418 void QgsAdvancedDigitizingDockWidget::lockAdditionalConstraint(
AdditionalConstraint constraint )
420 mAdditionalConstraint = constraint;
421 mPerpendicularAction->setChecked( constraint ==
Perpendicular );
422 mParallelAction->setChecked( constraint ==
Parallel );
425 void QgsAdvancedDigitizingDockWidget::updateCapacity(
bool updateUIwithoutChange )
427 CadCapacities newCapacities =
nullptr;
429 if ( mCadPointList.count() > 1 )
433 if ( mCadPointList.count() > 2 )
437 if ( !updateUIwithoutChange && newCapacities == mCapacities )
447 bool relativeAngle = mCadEnabled && newCapacities.testFlag(
RelativeAngle );
448 bool absoluteAngle = mCadEnabled && newCapacities.testFlag(
AbsoluteAngle );
451 mPerpendicularAction->setEnabled( absoluteAngle && snappingEnabled );
452 mParallelAction->setEnabled( absoluteAngle && snappingEnabled );
455 if ( !snappingEnabled )
457 mPerpendicularAction->setToolTip( tr(
"Snapping must be enabled to utilize perpendicular mode" ) );
458 mParallelAction->setToolTip( tr(
"Snapping must be enabled to utilize parallel mode" ) );
462 mPerpendicularAction->setToolTip(
"<b>" + tr(
"Perpendicular" ) +
"</b><br>(" + tr(
"press p to switch between perpendicular, parallel and normal mode" ) +
")" );
463 mParallelAction->setToolTip(
"<b>" + tr(
"Parallel" ) +
"</b><br>(" + tr(
"press p to switch between perpendicular, parallel and normal mode" ) +
")" );
467 if ( !absoluteAngle )
473 mLockAngleButton->setEnabled( absoluteAngle );
474 mRelativeAngleButton->setEnabled( relativeAngle );
475 mAngleLineEdit->setEnabled( absoluteAngle );
476 if ( !absoluteAngle )
480 if ( !relativeAngle )
482 mAngleConstraint->setRelative(
false );
484 else if ( relativeAngle && !mCapacities.testFlag(
RelativeAngle ) )
487 mAngleConstraint->setRelative(
true );
491 mLockDistanceButton->setEnabled( relativeCoordinates );
492 mDistanceLineEdit->setEnabled( relativeCoordinates );
493 if ( !relativeCoordinates )
498 mRelativeXButton->setEnabled( relativeCoordinates );
499 mRelativeYButton->setEnabled( relativeCoordinates );
502 mCapacities = newCapacities;
520 context.
xConstraint = _constraint( mXConstraint.get() );
521 context.
yConstraint = _constraint( mYConstraint.get() );
532 bool res = output.
valid;
534 mSnappedSegment.clear();
539 mSnappedSegment << edgePt0 << edgePt1;
561 mSnapIndicator->setMatch( mSnapMatch );
562 mSnapIndicator->setVisible(
true );
566 mSnapIndicator->setVisible(
false );
581 updateCurrentPoint( point );
583 updateUnlockedConstraintValues( point );
591 emit
pushWarning( tr(
"Some constraints are incompatible. Resulting point might be incorrect." ) );
598 void QgsAdvancedDigitizingDockWidget::updateUnlockedConstraintValues(
const QgsPointXY &point )
600 bool previousPointExist, penulPointExist;
605 if ( !mAngleConstraint->isLocked() && previousPointExist )
608 if ( penulPointExist && mAngleConstraint->relative() )
611 angle = std::atan2( previousPt.
y() - penultimatePt.
y(),
612 previousPt.
x() - penultimatePt.
x() );
614 angle = ( std::atan2( point.
y() - previousPt.
y(),
615 point.
x() - previousPt.
x()
616 ) - angle ) * 180 / M_PI;
618 angle = std::fmod( angle, 360.0 );
619 mAngleConstraint->setValue( angle );
622 if ( !mDistanceConstraint->isLocked() && previousPointExist )
624 mDistanceConstraint->setValue( std::sqrt( previousPt.
sqrDist( point ) ) );
627 if ( !mXConstraint->isLocked() )
629 if ( previousPointExist && mXConstraint->relative() )
631 mXConstraint->setValue( point.
x() - previousPt.
x() );
635 mXConstraint->setValue( point.
x() );
639 if ( !mYConstraint->isLocked() )
641 if ( previousPointExist && mYConstraint->relative() )
643 mYConstraint->setValue( point.
y() - previousPt.
y() );
647 mYConstraint->setValue( point.
y() );
653 QList<QgsPointXY> QgsAdvancedDigitizingDockWidget::snapSegmentToAllLayers(
const QgsPointXY &originalMapPoint,
bool *snapped )
const 655 QList<QgsPointXY> segment;
668 match = snappingUtils->
snapToMap( originalMapPoint );
670 snappingUtils->
setConfig( canvasConfig );
675 segment << pt1 << pt2;
680 *snapped = segment.count() == 2;
693 bool previousPointExist, penulPointExist, snappedSegmentExist;
696 mSnappedSegment = snapSegmentToAllLayers( e->
originalMapPoint(), &snappedSegmentExist );
698 if ( !previousPointExist || !snappedSegmentExist )
703 double angle = std::atan2( mSnappedSegment[0].y() - mSnappedSegment[1].y(), mSnappedSegment[0].x() - mSnappedSegment[1].x() );
705 if ( mAngleConstraint->relative() && penulPointExist )
707 angle -= std::atan2( previousPt.
y() - penultimatePt.
y(), previousPt.
x() - penultimatePt.
x() );
717 mAngleConstraint->setValue( angle );
718 mAngleConstraint->setLockMode( lockMode );
736 case Qt::Key_Backspace:
773 case Qt::Key_Backspace:
802 bool QgsAdvancedDigitizingDockWidget::eventFilter( QObject *obj, QEvent *event )
806 return QgsDockWidget::eventFilter( obj, event );
814 if ( event->type() == QEvent::ShortcutOverride ||
event->type() == QEvent::KeyPress )
816 if ( QKeyEvent *keyEvent = dynamic_cast<QKeyEvent *>( event ) )
818 return filterKeyPress( keyEvent );
821 return QgsDockWidget::eventFilter( obj, event );
824 bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
830 QEvent::Type type = e->type();
836 if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) )
838 mXConstraint->toggleLocked();
842 else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier )
846 mXConstraint->toggleRelative();
852 else if ( type == QEvent::KeyPress )
854 mXLineEdit->setFocus();
855 mXLineEdit->selectAll();
863 if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) )
865 mYConstraint->toggleLocked();
869 else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier )
873 mYConstraint->toggleRelative();
879 else if ( type == QEvent::KeyPress )
881 mYLineEdit->setFocus();
882 mYLineEdit->selectAll();
890 if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) )
894 mAngleConstraint->toggleLocked();
899 else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier )
903 mAngleConstraint->toggleRelative();
909 else if ( type == QEvent::KeyPress )
911 mAngleLineEdit->setFocus();
912 mAngleLineEdit->selectAll();
920 if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) )
924 mDistanceConstraint->toggleLocked();
930 else if ( type == QEvent::KeyPress )
932 mDistanceLineEdit->setFocus();
933 mDistanceLineEdit->selectAll();
940 if ( type == QEvent::KeyPress )
942 setConstructionMode( !mConstructionMode );
949 if ( type == QEvent::KeyPress )
951 bool parallel = mParallelAction->isChecked();
952 bool perpendicular = mPerpendicularAction->isChecked();
954 if ( !parallel && !perpendicular )
958 else if ( perpendicular )
960 lockAdditionalConstraint(
Parallel );
975 return e->isAccepted();
983 mErrorLabel->setText( tr(
"CAD tools can not be used on geographic coordinates. Change the coordinates system in the project properties." ) );
985 mEnableAction->setEnabled(
false );
986 setCadEnabled(
false );
990 mEnableAction->setEnabled(
true );
994 mCurrentMapToolSupportsCad =
true;
996 if ( mSessionActive && !isVisible() )
1000 setCadEnabled( mSessionActive );
1008 mEnableAction->setEnabled(
false );
1009 mErrorLabel->setText( tr(
"CAD tools are not enabled for the current map tool" ) );
1010 mErrorLabel->show();
1013 mCurrentMapToolSupportsCad =
false;
1015 setCadEnabled(
false );
1020 mCadPaintItem->update();
1027 mCadPointList << point;
1031 mCadPointList.insert( 0, point );
1044 mCadPointList.removeAt( i );
1051 mCadPointList.clear();
1052 mSnappedSegment.clear();
1058 void QgsAdvancedDigitizingDockWidget::updateCurrentPoint(
const QgsPointXY &point )
1062 mCadPointList << point;
1067 mCadPointList[0] = point;
1076 mLockerButton->setChecked( mode == HardLock );
1077 if ( mRepeatingLockButton )
1079 if ( mode == HardLock )
1081 mRepeatingLockButton->setEnabled(
true );
1085 mRepeatingLockButton->setChecked(
false );
1086 mRepeatingLockButton->setEnabled(
false );
1090 if ( mode == NoLock )
1098 mRepeatingLock = repeating;
1099 if ( mRepeatingLockButton )
1100 mRepeatingLockButton->setChecked( repeating );
1105 mRelative = relative;
1106 if ( mRelativeButton )
1108 mRelativeButton->setChecked( relative );
1116 mLineEdit->setText( QLocale().toString( value,
'f', 6 ) );
1121 setLockMode( mLockMode == HardLock ? NoLock : HardLock );
1126 setRelative( !mRelative );
1134 return mCadPointList.value( 0 );
1144 return mCadPointList.value( 1 );
1154 return mCadPointList.value( 2 );
Class for parsing and evaluation of expressions (formerly called "search strings").
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords...
QgsCadUtils::AlignMapPointConstraint yConstraint
Constraint for Y coordinate.
void snappingConfigChanged(const QgsSnappingConfig &config)
Emitted whenever the configuration for snapping has changed.
void focusOut()
Emitted when parent object loses focus.
A event filter for watching for focus events on a parent object.
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
This class is a composition of two QSettings instances:
Structure with details of one constraint.
A class to represent a 2D point.
double qgsPermissiveToDouble(QString string, bool &ok)
Converts a string to a double in a permissive way, e.g., allowing for incorrect numbers of digits bet...
QVariant evaluate()
Evaluate the feature and return the result.
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
void setMapPoint(const QgsPointXY &point)
Set the (snapped) point this event points to in map coordinates.
Map canvas is a class for displaying all GIS data types on a canvas.
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)
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
QgsPointLocator::Match edgeMatch
Snapped segment - only valid if actually used for something.
bool locked
Whether the constraint is active, i.e. should be considered.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QgsSnappingUtils * snappingUtils() const
Returns snapping utility class that is associated with map canvas.
QgsCadUtils::AlignMapPointConstraint distanceConstraint
Constraint for distance.
void edgePoints(QgsPointXY &pt1, QgsPointXY &pt2) const
Only for a valid edge match - obtain endpoints of the edge.
Structure defining all constraints for alignMapPoint() method.
QgsCadUtils::AlignMapPointConstraint commonAngleConstraint
Constraint for soft lock to a common angle.
void destinationCrsChanged()
Emitted when map CRS has changed.
bool enabled() const
Returns if snapping is enabled.
QgsPointXY finalMapPoint
map point aligned according to the constraints
double value
Numeric value of the constraint (coordinate/distance in map units or angle in degrees) ...
double softLockCommonAngle
Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1)
Structure returned from alignMapPoint() method.
double mapUnitsPerPixel
Map units/pixel ratio from map canvas. Needed for.
void setMode(SnappingMode mode)
define the mode of snapping
QgsCadUtils::AlignMapPointConstraint xConstraint
Constraint for X coordinate.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsCadUtils::AlignMapPointConstraint angleConstraint
Constraint for angle.
bool valid
Whether the combination of constraints is actually valid.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setType(SnappingType type)
define the type of snapping
This class has all the configuration of snapping and can return answers to snapping queries...
Class that shows snapping marker on map canvas for the current snapping match.
QgsSnappingUtils * snappingUtils
Snapping utils that will be used to snap point to map. Must not be null.
QgsPointXY originalMapPoint() const
Returns the original, unmodified map point of the mouse cursor.
This is a container for configuration of the snapping of the project.
static QgsCadUtils::AlignMapPointOutput alignMapPoint(const QgsPointXY &originalMapPoint, const QgsCadUtils::AlignMapPointContext &ctx)
Applies X/Y/angle/distance constraints from the given context to a map point.
QgsPointLocator::Match snapToMap(QPoint point, QgsPointLocator::MatchFilter *filter=nullptr)
Snap to map according to the current configuration. Optional filter allows discarding unwanted matche...
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
bool relative
Whether the value is relative to previous value.
bool isGeographic() const
Returns whether the CRS is a geographic CRS (using lat/lon coordinates)
QgsSnappingConfig snappingConfig
void setConfig(const QgsSnappingConfig &snappingConfig)
The snapping configuration controls the behavior of this object.
The QgsAdvancedDigitizingCanvasItem class draws the graphical elements of the CAD tools (...
QList< QgsPointXY > cadPointList
List of recent CAD points in map coordinates.