16#ifndef QGSADVANCEDDIGITIZINGDOCK
17#define QGSADVANCEDDIGITIZINGDOCK
24#include "ui_qgsadvanceddigitizingdockwidgetbase.h"
63 RelativeCoordinates = 4,
66 Q_DECLARE_FLAGS( CadCapacities, CadCapacity )
67 Q_FLAG( CadCapacities )
107 CadConstraint( QLineEdit *lineEdit, QToolButton *lockerButton, QToolButton *relativeButton =
nullptr, QToolButton *repeatingLockButton =
nullptr )
108 : mLineEdit( lineEdit )
109 , mLockerButton( lockerButton )
110 , mRelativeButton( relativeButton )
111 , mRepeatingLockButton( repeatingLockButton )
112 , mLockMode( NoLock )
113 , mRepeatingLock( false )
127 bool isLocked()
const {
return mLockMode != NoLock; }
145 double value()
const {
return mValue; }
155 void setLockMode( LockMode mode );
164 void setRepeatingLock(
bool repeating );
169 void setRelative(
bool relative );
176 void setValue(
double value,
bool updateWidget =
true );
182 QString displayValue()
const;
192 void toggleRelative();
229 QLineEdit *mLineEdit =
nullptr;
230 QToolButton *mLockerButton =
nullptr;
231 QToolButton *mRelativeButton =
nullptr;
232 QToolButton *mRepeatingLockButton =
nullptr;
255 bool canvasKeyPressEventFilter( QKeyEvent *e );
275 void releaseLocks(
bool releaseRepeatingLocks =
true );
282 void keyPressEvent( QKeyEvent *e )
override;
297 void setEnabledZ(
bool enable );
303 void setEnabledM(
bool enable );
368 void clearLockedSnapVertices(
bool force =
true );
386 void removePreviousPoint();
392 void updateCurrentPoint(
const QgsPoint &point );
401 void setPoints(
const QList<QgsPointXY> &points );
410 QgsPoint currentPointV2(
bool *exists =
nullptr )
const;
432 QgsPoint previousPointV2(
bool *exists =
nullptr )
const;
447 QgsPoint penultimatePointV2(
bool *exists =
nullptr )
const;
465 inline bool snappedToVertex()
const {
return ( mSnapMatch.isValid() && ( mSnapMatch.hasVertex() || mSnapMatch.hasLineEndpoint() ) ); }
492 void updateCadPaintItem();
502 void setX(
const QString &value, WidgetSetMode mode );
512 void setY(
const QString &value, WidgetSetMode mode );
522 void setZ(
const QString &value, WidgetSetMode mode );
532 void setM(
const QString &value, WidgetSetMode mode );
542 void setAngle(
const QString &value, WidgetSetMode mode );
552 void setDistance(
const QString &value, WidgetSetMode mode );
558 double getLineZ( )
const;
564 double getLineM( )
const;
576 QString formatCommonAngleSnapping(
double angle );
921 void betweenLineConstraintClicked(
bool activated );
924 void lockConstraint(
bool activate =
true );
927 void lockParameterlessConstraint(
bool activate =
true );
933 void constraintTextEdited(
const QString &textValue );
939 void constraintFocusOut();
942 void setConstraintRelative(
bool activate );
945 void setConstraintRepeatingLock(
bool activate );
951 void activateCad(
bool enabled );
954 void setConstructionMode(
bool enabled );
957 void settingsButtonTriggered( QAction *action );
967 void setCadEnabled(
bool enabled );
973 void updateCapacity(
bool updateUIwithoutChange =
false );
983 QList<QgsPointXY> snapSegmentToAllLayers(
const QgsPointXY &originalMapPoint,
bool *snapped =
nullptr )
const;
989 bool filterKeyPress( QKeyEvent *e );
995 bool eventFilter( QObject *obj, QEvent *event )
override SIP_SKIP;
998 void triggerMouseMoveEvent();
1001 CadConstraint *objectToConstraint(
const QObject *obj )
const;
1012 void updateConstraintValue(
CadConstraint *constraint,
const QString &textValue,
bool convertExpression =
false );
1015 void updateUnlockedConstraintValues(
const QgsPoint &point );
1028 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
1030 CadCapacities mCapacities = CadCapacities();
1032 bool mCurrentMapToolSupportsCad =
false;
1039 bool mCadEnabled =
false;
1040 bool mConstructionMode =
false;
1043 std::unique_ptr< CadConstraint > mAngleConstraint;
1044 std::unique_ptr< CadConstraint > mDistanceConstraint;
1045 std::unique_ptr< CadConstraint > mXConstraint;
1046 std::unique_ptr< CadConstraint > mYConstraint;
1047 std::unique_ptr< CadConstraint > mZConstraint;
1048 std::unique_ptr< CadConstraint > mMConstraint;
1049 std::unique_ptr< CadConstraint > mLineExtensionConstraint;
1050 std::unique_ptr< CadConstraint > mXyVertexConstraint;
1052 double mCommonAngleConstraint;
1055 bool mSnappingPrioritizeFeatures =
false;
1058 QList<QgsPoint> mCadPointList;
1059 QList<QgsPointXY> mSnappedSegment;
1061 bool mSessionActive =
false;
1064 std::unique_ptr<QgsMessageBarItem> mErrorMessage;
1067 QMap< QAction *, double > mCommonAngleActions;
1068 QAction *mLineExtensionAction;
1069 QAction *mXyVertexAction;
1079 QQueue< QgsPointLocator::Match > mLockedSnapVertices;
1083 bool eventFilter( QObject *obj, QEvent *event );
1088 QMenu *mCommonAngleActionsMenu =
nullptr;
1089 QMenu *mFloaterActionsMenu =
nullptr;
1093 friend class TestQgsAdvancedDigitizing;
1094 friend class TestQgsAdvancedDigitizingDockWidget;
CadConstraintType
Advanced digitizing constraint type.
BetweenLineConstraint
Between line constraints which can be enabled.
LineExtensionSide
Designates whether the line extension constraint is currently soft locked with the previous or next v...
The QgsAdvancedDigitizingCanvasItem class draws the graphical elements of the CAD tools (.
The QgsAdvancedDigitizingFloater class is widget that floats next to the mouse pointer,...
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
A boolean settings entry.
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)
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.