Class: QgsAdvancedDigitizingDockWidget¶
- class qgis.gui.QgsAdvancedDigitizingDockWidget(canvas: QgsMapCanvas, parent: QWidget = None)¶
Bases:
QgsDockWidget
Create an advanced digitizing dock widget
- Parameters
canvas – The map canvas on which the widget operates
parent – The parent
The
QgsAdvancedDigitizingDockWidget
class is a dockable widget used to handle the CAD tools on top of a selection of map tools. It handles both the UI and the constraints. Constraints are applied by implementing filters called from QgsMapToolAdvancedDigitizing.Enums
Bases:
enum.IntEnum
Methods
Adds point to the CAD point list
Returns the additional constraints which are used to place perpendicular/parallel segments to snapped segments on the canvas
align to segment for additional constraint.
apply the CAD constraints.
determines if CAD tools are enabled or if map tools behaves "nomally"
Filter key events to e.g.
Clear any cached previous clicks and helper lines
Removes all points from the CAD point list
Returns
True
if a constraint on a common angle is activeReturns the
CadConstraint
on the angleReturns the
CadConstraint
on the distanceReturns the
CadConstraint
on the X coordinateReturns the
CadConstraint
on the Y coordinateconstruction mode is used to draw intermediate points.
The last point.
Disable the widget.
Enables the tool (call this when an appropriate map tool is set and in the condition to make use of cad digitizing) Normally done automatically from
QgsMapToolAdvancedDigitizing.activate()
but may need to be fine tuned if the map tool depends on preconditions like a feature selection.Returns the action used to enable/disable the tools
- param e
Returns the point locator match
The penultimate point.
The number of points in the CAD point helper list
The previous point.
unlock all constraints
Remove previous point in the CAD point list
Set the angle value on the widget.
Set the distance value on the widget.
Configures list of current CAD points
Set the X value on the widget.
Set the Y value on the widget.
Snapped to a segment
Is it snapped to a vertex
Updates canvas item that displays constraints on the ma
Signals
Emitted whenever CAD is enabled or disabled
Emitted whenever the angle field is enabled or disabled.
Emitted whenever the distance field is enabled or disabled.
Emitted whenever the X field is enabled or disabled.
Emitted whenever the Y field is enabled or disabled.
Emitted whenever the angle field should get the focus using the shortcuts (A).
Emitted whenever the distance field should get the focus using the shortcuts (D).
Emitted whenever the X field should get the focus using the shortcuts (X).
Emitted whenever the Y field should get the focus using the shortcuts (Y).
Emitted whenever the angle parameter is
locked
.Emitted whenever the distance parameter is
locked
.Emitted whenever the X parameter is
locked
.Emitted whenever the Y parameter is
locked
.Sometimes a constraint may change the current point out of a mouse event.
Remove any previously emitted warnings (if any) [signal]
Push a warning
Emitted whenever the angleX parameter is toggled between absolute and relative.
Emitted whenever the X parameter is toggled between absolute and relative.
Emitted whenever the Y parameter is toggled between absolute and relative.
Emitted whenever the angle
value
changes (either the mouse moved, or the user changed the input).Emitted whenever the distance
value
changes (either the mouse moved, or the user changed the input).Emitted whenever the X
value
changes (either the mouse moved, or the user changed the input).Emitted whenever the Y
value
changes (either the mouse moved, or the user changed the input).Attributes
- AbsoluteAngle = 1¶
- class AdditionalConstraint(value)¶
Bases:
enum.IntEnum
Additional constraints which can be enabled
NoConstraint
: No additional constraintPerpendicular
: PerpendicularParallel
: Parallel
- NoConstraint = 0¶
- Parallel = 2¶
- Perpendicular = 1¶
- class CadCapacities¶
- class CadCapacities(Union[QgsAdvancedDigitizingDockWidget.CadCapacities, QgsAdvancedDigitizingDockWidget.CadCapacity]) None
- class CadCapacities(QgsAdvancedDigitizingDockWidget.CadCapacities) None
Bases:
sip.wrapper
- baseClass¶
- class CadCapacity¶
Bases:
int
- class CadConstraint(lineEdit: QLineEdit, lockerButton: QToolButton, relativeButton: QToolButton = None, repeatingLockButton: QToolButton = None)¶
Bases:
sip.wrapper
Constructor for CadConstraint.
- Parameters
lineEdit – associated line edit for constraint value
lockerButton – associated button for locking constraint
relativeButton – optional button for toggling relative constraint mode
repeatingLockButton – optional button for toggling repeating lock mode
QgsAdvancedDigitizingDockWidget.CadConstraint(QgsAdvancedDigitizingDockWidget.CadConstraint)
The CadConstraint is an abstract class for all basic constraints (angle/distance/x/y). It contains all values (locked, value, relative) and pointers to corresponding widgets.
Note
Relative is not mandatory since it is not used for distance.
- HardLock = 2¶
- class LockMode¶
Bases:
int
- NoLock = 0¶
- SoftLock = 1¶
- isLocked(self) bool ¶
Is any kind of lock mode enabled
- Return type
bool
- isRepeatingLock(self) bool ¶
Returns
True
if a repeating lock is set for the constraint. Repeating locks are not automatically cleared after a new point is added.See also
New in version 2.16.
- Return type
bool
- lineEdit(self) QLineEdit ¶
The line edit that manages the value of the constraint
- Return type
QLineEdit
- lockMode(self) QgsAdvancedDigitizingDockWidget.CadConstraint.LockMode ¶
The current lock mode of this constraint
- Return type
- Returns
Lock mode
- relative(self) bool ¶
Is the constraint in relative mode
- Return type
bool
- setLockMode(self, mode: QgsAdvancedDigitizingDockWidget.CadConstraint.LockMode)¶
Set the lock mode
- Parameters
mode (QgsAdvancedDigitizingDockWidget.CadConstraint.LockMode) –
- setRelative(self, relative: bool)¶
Set if the constraint should be treated relative
- Parameters
relative (bool) –
- setRepeatingLock(self, repeating: bool)¶
Sets whether a repeating lock is set for the constraint. Repeating locks are not automatically cleared after a new point is added.
- Parameters
repeating (bool) – set to
True
to set the lock to repeat automatically
See also
New in version 2.16.
- setValue(self, value: float, updateWidget: bool = True)¶
Set the value of the constraint
- Parameters
value (float) – new value for constraint
updateWidget (bool = True) – set to
False
to prevent automatically updating the associated widget’s value
- toggleLocked(self)¶
Toggle lock mode
- toggleRelative(self)¶
Toggle relative mode
- value(self) float ¶
The value of the constraint
- Return type
float
- NoConstraint = 0¶
- Parallel = 2¶
- Perpendicular = 1¶
- RelativeAngle = 2¶
- RelativeCoordinates = 4¶
- ReturnPressed = 0¶
- class WidgetSetMode¶
Bases:
int
- actionEvent(self, QActionEvent)¶
- addPoint(self, point: QgsPointXY)¶
Adds point to the CAD point list
New in version 3.0.
- Parameters
point (QgsPointXY) –
- additionalConstraint(self) QgsAdvancedDigitizingDockWidget.AdditionalConstraint ¶
Returns the additional constraints which are used to place perpendicular/parallel segments to snapped segments on the canvas
- alignToSegment(self, e: QgsMapMouseEvent, lockMode: QgsAdvancedDigitizingDockWidget.CadConstraint.LockMode = QgsAdvancedDigitizingDockWidget.CadConstraint.HardLock) bool ¶
align to segment for additional constraint. If additional constraints are used, this will determine the angle to be locked depending on the snapped segment.
New in version 3.0.
- Parameters
e (QgsMapMouseEvent) –
lockMode (QgsAdvancedDigitizingDockWidget.CadConstraint.LockMode = QgsAdvancedDigitizingDockWidget.CadConstraint.HardLock) –
- Return type
bool
- applyConstraints(self, e: QgsMapMouseEvent) bool ¶
apply the CAD constraints. The will modify the position of the map event in map coordinates by applying the CAD constraints.
- Return type
bool
- Returns
False
if no solution was found (invalid constraints)- Parameters
e (QgsMapMouseEvent) –
- cadEnabled(self) bool ¶
determines if CAD tools are enabled or if map tools behaves “nomally”
- Return type
bool
- cadEnabledChanged¶
Emitted whenever CAD is enabled or disabled
- Parameters
enabled (bool) – Whether CAD is enabled or not
Note
unstable API (will likely change).
New in version 3.8: [signal]
- canvasKeyPressEventFilter(self, e: QKeyEvent) bool ¶
Filter key events to e.g. toggle construction mode or adapt constraints
- Parameters
e (QKeyEvent) – A mouse event (may be modified)
- Return type
bool
- Returns
If the event is hidden (construction mode hides events from the maptool)
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- clear(self)¶
Clear any cached previous clicks and helper lines
- clearPoints(self)¶
Removes all points from the CAD point list
New in version 3.0.
- closeEvent(self, QCloseEvent)¶
- commonAngleConstraint(self) bool ¶
Returns
True
if a constraint on a common angle is active- Return type
bool
- connectNotify(self, QMetaMethod)¶
- constraintAngle(self) QgsAdvancedDigitizingDockWidget.CadConstraint ¶
Returns the
CadConstraint
on the angle- Return type
- constraintDistance(self) QgsAdvancedDigitizingDockWidget.CadConstraint ¶
Returns the
CadConstraint
on the distance- Return type
- constraintX(self) QgsAdvancedDigitizingDockWidget.CadConstraint ¶
Returns the
CadConstraint
on the X coordinate- Return type
- constraintY(self) QgsAdvancedDigitizingDockWidget.CadConstraint ¶
Returns the
CadConstraint
on the Y coordinate- Return type
- constructionMode(self) bool ¶
construction mode is used to draw intermediate points. These points won’t be given any further (i.e. to the map tools)
- Return type
bool
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- currentPoint(self) Tuple[QgsPointXY, bool] ¶
The last point. Helper for the CAD point list. The CAD point list is the list of points currently digitized. It contains both “normal” points and intermediate points (construction mode).
- Return type
Tuple[
QgsPointXY
, bool]
- customEvent(self, QEvent)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disable(self)¶
Disable the widget. Normally done automatically from
QgsMapToolAdvancedDigitizing.deactivate()
.
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- enable(self)¶
Enables the tool (call this when an appropriate map tool is set and in the condition to make use of cad digitizing) Normally done automatically from
QgsMapToolAdvancedDigitizing.activate()
but may need to be fine tuned if the map tool depends on preconditions like a feature selection.
- enableAction(self) QAction ¶
Returns the action used to enable/disable the tools
- Return type
QAction
- enabledChangedAngle¶
Emitted whenever the angle field is enabled or disabled. Depending on the context, some parameters do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state.
- Parameters
enabled (bool) – Whether the angle parameter is enabled or not.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- enabledChangedDistance¶
Emitted whenever the distance field is enabled or disabled. Depending on the context, some parameters do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state.
- Parameters
enabled (bool) – Whether the distance parameter is enabled or not.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- enabledChangedX¶
Emitted whenever the X field is enabled or disabled. Depending on the context, some parameters do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state.
- Parameters
enabled (bool) – Whether the X parameter is enabled or not.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- enabledChangedY¶
Emitted whenever the Y field is enabled or disabled. Depending on the context, some parameters do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state.
- Parameters
enabled (bool) – Whether the Y parameter is enabled or not.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- eventFilter(self, QObject, QEvent) bool ¶
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOnAngleRequested¶
Emitted whenever the angle field should get the focus using the shortcuts (A). Could be used by widgets to capture the focus when a field is being edited.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- focusOnDistanceRequested¶
Emitted whenever the distance field should get the focus using the shortcuts (D). Could be used by widgets to capture the focus when a field is being edited.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- focusOnXRequested¶
Emitted whenever the X field should get the focus using the shortcuts (X). Could be used by widgets to capture the focus when a field is being edited.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- focusOnYRequested¶
Emitted whenever the Y field should get the focus using the shortcuts (Y). Could be used by widgets to capture the focus when a field is being edited.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionDockWidget)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, e: QKeyEvent)¶
- Parameters
e (QKeyEvent) –
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- lockAngleChanged¶
Emitted whenever the angle parameter is
locked
. Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
locked (bool) –
- lockDistanceChanged¶
Emitted whenever the distance parameter is
locked
. Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
locked (bool) –
- lockXChanged¶
Emitted whenever the X parameter is
locked
. Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
locked (bool) –
- lockYChanged¶
Emitted whenever the Y parameter is
locked
. Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
locked (bool) –
- mapPointMatch(self) QgsPointLocator.Match ¶
Returns the point locator match
New in version 3.4.
- Return type
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, QPaintEvent)¶
- penultimatePoint(self) Tuple[QgsPointXY, bool] ¶
The penultimate point. Helper for the CAD point list. The CAD point list is the list of points currently digitized. It contains both “normal” points and intermediate points (construction mode).
- Return type
Tuple[
QgsPointXY
, bool]
- pointChanged¶
Sometimes a constraint may change the current point out of a mouse event. This happens normally when a constraint is toggled.
- Parameters
point (QgsPointXY) – The last known digitizing point. Can be used to emulate a mouse event. [signal]
- pointsCount(self) int ¶
The number of points in the CAD point helper list
- Return type
int
- popWarning¶
Remove any previously emitted warnings (if any) [signal]
- previousPoint(self) Tuple[QgsPointXY, bool] ¶
The previous point. Helper for the CAD point list. The CAD point list is the list of points currently digitized. It contains both “normal” points and intermediate points (construction mode).
- Return type
Tuple[
QgsPointXY
, bool]
- pushWarning¶
Push a warning
- Parameters
message (str) – An informative message [signal]
- receivers(self, PYQT_SIGNAL) int ¶
- relativeAngleChanged¶
Emitted whenever the angleX parameter is toggled between absolute and relative. Could be used by widgets that must reflect the current advanced digitizing state.
- Parameters
relative (bool) – Whether the angle parameter is relative or not.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- relativeXChanged¶
Emitted whenever the X parameter is toggled between absolute and relative. Could be used by widgets that must reflect the current advanced digitizing state.
- Parameters
relative (bool) – Whether the X parameter is relative or not.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- relativeYChanged¶
Emitted whenever the Y parameter is toggled between absolute and relative. Could be used by widgets that must reflect the current advanced digitizing state.
- Parameters
relative (bool) – Whether the Y parameter is relative or not.
Note
unstable API (will likely change)
New in version 3.8: [signal]
- releaseLocks(self, releaseRepeatingLocks: bool = True)¶
unlock all constraints
- Parameters
releaseRepeatingLocks (bool = True) – set to
False
to preserve the lock for any constraints set to repeating lock mode
New in version 3.0.
- removePreviousPoint(self)¶
Remove previous point in the CAD point list
New in version 3.8.
- resizeEvent(self, QResizeEvent)¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setAngle(self, value: str, mode: QgsAdvancedDigitizingDockWidget.WidgetSetMode)¶
Set the angle value on the widget. Can be used to set constraints by external widgets.
- Parameters
mode (QgsAdvancedDigitizingDockWidget.WidgetSetMode) – What type of interaction to emulate
value (str) – The value (as a QString, as it could be an expression)
Note
unstable API (will likely change)
New in version 3.8.
- setDistance(self, value: str, mode: QgsAdvancedDigitizingDockWidget.WidgetSetMode)¶
Set the distance value on the widget. Can be used to set constraints by external widgets.
- Parameters
mode (QgsAdvancedDigitizingDockWidget.WidgetSetMode) – What type of interaction to emulate
value (str) – The value (as a QString, as it could be an expression)
Note
unstable API (will likely change)
New in version 3.8.
- setPoints(self, points: Iterable[QgsPointXY])¶
Configures list of current CAD points
Some map tools may find it useful to override list of CAD points that is otherwise automatically populated when user clicks with left mouse button on map canvas.
New in version 3.0.
- Parameters
points (Iterable[QgsPointXY]) –
- setX(self, value: str, mode: QgsAdvancedDigitizingDockWidget.WidgetSetMode)¶
Set the X value on the widget. Can be used to set constraints by external widgets.
- Parameters
mode (QgsAdvancedDigitizingDockWidget.WidgetSetMode) – What type of interaction to emulate
value (str) – The value (as a QString, as it could be an expression)
Note
unstable API (will likely change)
New in version 3.8.
- setY(self, value: str, mode: QgsAdvancedDigitizingDockWidget.WidgetSetMode)¶
Set the Y value on the widget. Can be used to set constraints by external widgets.
- Parameters
mode (QgsAdvancedDigitizingDockWidget.WidgetSetMode) – What type of interaction to emulate
value (str) – The value (as a QString, as it could be an expression)
Note
unstable API (will likely change)
New in version 3.8.
- showEvent(self, event: QShowEvent)¶
- snappedSegment(self) List[QgsPointXY] ¶
Snapped to a segment
- Return type
List[QgsPointXY]
- snappedToVertex(self) bool ¶
Is it snapped to a vertex
- Return type
bool
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateCadPaintItem(self)¶
Updates canvas item that displays constraints on the ma
New in version 3.0.
- updateMicroFocus(self)¶
- valueAngleChanged¶
Emitted whenever the angle
value
changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
value (str) –
- valueDistanceChanged¶
Emitted whenever the distance
value
changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
value (str) –
- valueXChanged¶
Emitted whenever the X
value
changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
value (str) –
- valueYChanged¶
Emitted whenever the Y
value
changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state.Note
unstable API (will likely change)
New in version 3.8: [signal]
- Parameters
value (str) –
- wheelEvent(self, QWheelEvent)¶