Class: QgsAdvancedDigitizingDockWidget

class qgis.gui.QgsAdvancedDigitizingDockWidget(canvas: QgsMapCanvas, parent: QWidget = None)

Bases: QgsDockWidget

Create an advanced digitizing dock widget

Parameters
  • canvas (QgsMapCanvas) – The map canvas on which the widget operates

  • parent (QWidget = None) – 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.

Methods

actionEvent

addPoint

Adds point to the CAD point list

additionalConstraint

Returns the additional constraints which are used to place perpendicular/parallel segments to snapped segments on the canvas

alignToSegment

align to segment for additional constraint.

applyConstraints

apply the CAD constraints.

cadEnabled

determines if CAD tools are enabled or if map tools behaves “nomally”

canvasKeyPressEventFilter

Filter key events to e.g.

changeEvent

childEvent

clear

Clear any cached previous clicks and helper lines

clearPoints

Removes all points from the CAD point list

closeEvent

commonAngleConstraint

Returns true if a constraint on a common angle is active

connectNotify

constraintAngle

Returns the CadConstraint on the angle

constraintDistance

Returns the CadConstraint on the distance

constraintX

Returns the CadConstraint on the X coordinate

constraintY

Returns the CadConstraint on the Y coordinate

constructionMode

construction mode is used to draw intermediate points.

contextMenuEvent

create

currentPoint

The last point.

customEvent

destroy

disable

Disable the widget.

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enable

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

Returns the action used to enable/disable the tools

enterEvent

event

eventFilter

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

Disables the CAD tools when hiding the dock

initPainter

initStyleOption

inputMethodEvent

isSignalConnected

keyPressEvent

param e

keyReleaseEvent

leaveEvent

mapPointMatch

Returns the point locator match

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

penultimatePoint

The penultimate point.

pointsCount

The number of points in the CAD point helper list

previousPoint

The previous point.

receivers

releaseLocks

unlock all constraints

removePreviousPoint

Remove previous point in the CAD point list

resizeEvent

sender

senderSignalIndex

setPoints

Configures list of current CAD points

sharedPainter

showEvent

snappedSegment

Snapped to a segment

snappedToVertex

Is it snapped to a vertex

tabletEvent

timerEvent

updateCadPaintItem

Updates canvas item that displays constraints on the ma

updateMicroFocus

wheelEvent

Signals

pointChanged

Sometimes a constraint may change the current point out of a mouse event.

popWarning

Remove any previously emitted warnings (if any) [signal]

pushWarning

Push a warning

Attributes

AbsoluteAngle

NoConstraint

Parallel

Perpendicular

RelativeAngle

RelativeCoordinates

AbsoluteAngle = 1
class AdditionalConstraint

Bases: int

class CadCapacities

Bases: sip.wrapper

QgsAdvancedDigitizingDockWidget.CadCapacities(Union[QgsAdvancedDigitizingDockWidget.CadCapacities, QgsAdvancedDigitizingDockWidget.CadCapacity]) QgsAdvancedDigitizingDockWidget.CadCapacities(QgsAdvancedDigitizingDockWidget.CadCapacities)

baseClass

alias of QgsAdvancedDigitizingDockWidget

class CadCapacity

Bases: int

class CadConstraint(lineEdit: QLineEdit, lockerButton: QToolButton, relativeButton: QToolButton = None, repeatingLockButton: QToolButton = None)

Bases: sip.wrapper

Constructor for CadConstraint.

Parameters
  • lineEdit (QLineEdit) – associated line edit for constraint value

  • lockerButton (QToolButton) – associated button for locking constraint

  • relativeButton (QToolButton = None) – optional button for toggling relative constraint mode

  • repeatingLockButton (QToolButton = None) – 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.

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

QgsAdvancedDigitizingDockWidget.CadConstraint.LockMode

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

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
actionEvent()
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

Return type

QgsAdvancedDigitizingDockWidget.AdditionalConstraint

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

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()
childEvent()
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()
commonAngleConstraint(self) → bool

Returns true if a constraint on a common angle is active

Return type

bool

connectNotify()
constraintAngle(self) → QgsAdvancedDigitizingDockWidget.CadConstraint

Returns the CadConstraint on the angle

Return type

QgsAdvancedDigitizingDockWidget.CadConstraint

constraintDistance(self) → QgsAdvancedDigitizingDockWidget.CadConstraint

Returns the CadConstraint on the distance

Return type

QgsAdvancedDigitizingDockWidget.CadConstraint

constraintX(self) → QgsAdvancedDigitizingDockWidget.CadConstraint

Returns the CadConstraint on the X coordinate

Return type

QgsAdvancedDigitizingDockWidget.CadConstraint

constraintY(self) → QgsAdvancedDigitizingDockWidget.CadConstraint

Returns the CadConstraint on the Y coordinate

Return type

QgsAdvancedDigitizingDockWidget.CadConstraint

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()
create()
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()
destroy()
disable(self)

Disable the widget. Normally done automatically from QgsMapToolAdvancedDigitizing.deactivate()

disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
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

enterEvent()
event()
eventFilter()
focusInEvent()
focusNextChild()
focusNextPrevChild()
focusOutEvent()
focusPreviousChild()
hideEvent(self, QHideEvent)

Disables the CAD tools when hiding the dock

initPainter()
initStyleOption()
inputMethodEvent()
isSignalConnected()
keyPressEvent(self, e: QKeyEvent)
Parameters

e (QKeyEvent) –

keyReleaseEvent()
leaveEvent()
mapPointMatch(self) → QgsPointLocator.Match

Returns the point locator match

New in version 3.4.

Return type

QgsPointLocator.Match

metric()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveEvent()
nativeEvent()
paintEvent()
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 – 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 – An informative message [signal]

receivers()
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()
sender()
senderSignalIndex()
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]) –

sharedPainter()
showEvent()
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()
timerEvent()
updateCadPaintItem(self)

Updates canvas item that displays constraints on the ma

New in version 3.0.

updateMicroFocus()
wheelEvent()