QgsAdvancedDigitizingDockWidget class
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of a selection of map tools.
Contents
It handles both the UI and the constraints. Constraints are applied by implementing filters called from QgsMapToolAdvancedDigitizing.
Base classes
- class QgsDockWidget
- QgsDockWidget subclass with more fine-grained control over how the widget is closed or opened.
Public types
- class CadConstraint
- The CadConstraint is an abstract class for all basic constraints (angle/distance/x/y).
- enum AdditionalConstraint { NoConstraint, Perpendicular, Parallel }
- Additional constraints which can be enabled.
- enum CadCapacity { AbsoluteAngle = 1, RelativeAngle = 2, RelativeCoordinates = 4 }
- The CadCapacity enum defines the possible constraints to be set depending on the number of points in the CAD point list (the list of points currently digitized)
Constructors, destructors, conversion operators
- QgsAdvancedDigitizingDockWidget(QgsMapCanvas* canvas, QWidget* parent = nullptr) explicit
- Create an advanced digitizing dock widget.
Public functions
- auto additionalConstraint() const -> AdditionalConstraint
- Returns the additional constraints which are used to place perpendicular/parallel segments to snapped segments on the canvas.
- void addPoint(const QgsPointXY& point)
- Adds point to the CAD point list.
-
auto alignToSegment(QgsMapMouseEvent* e,
QgsAdvancedDigitizingDockWidget::
CadConstraint:: LockMode lockMode = QgsAdvancedDigitizingDockWidget:: CadConstraint:: HardLock) -> bool - align to segment for additional constraint.
- auto applyConstraints(QgsMapMouseEvent* e) -> bool
- apply the CAD constraints.
- auto cadEnabled() const -> bool
- determines if CAD tools are enabled or if map tools behaves "nomally"
- auto canvasKeyPressEventFilter(QKeyEvent* e) -> bool
- Filter key events to e.g.
- void clear()
- Clear any cached previous clicks and helper lines.
- void clearPoints()
- Removes all points from the CAD point list.
- auto commonAngleConstraint() const -> bool
- Returns true if a constraint on a common angle is active.
- auto constraintAngle() const -> const CadConstraint*
- Returns the CadConstraint on the angle.
- auto constraintDistance() const -> const CadConstraint*
- Returns the CadConstraint on the distance.
- auto constraintX() const -> const CadConstraint*
- Returns the CadConstraint on the X coordinate.
- auto constraintY() const -> const CadConstraint*
- Returns the CadConstraint on the Y coordinate.
- auto constructionMode() const -> bool
- construction mode is used to draw intermediate points. These points won't be given any further (i.e. to the map tools)
- auto currentPoint(bool* exists = nullptr) const -> QgsPointXY
- The last point.
- void disable()
- Disable the widget.
- void 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. - auto enableAction() -> QAction*
- Returns the action used to enable/disable the tools.
- void hideEvent(QHideEvent*) override
- Disables the CAD tools when hiding the dock.
-
auto mapPointMatch() const -> QgsPointLocator::
Match - Returns the point locator match.
- auto penultimatePoint(bool* exists = nullptr) const -> QgsPointXY
- The penultimate point.
- auto pointsCount() const -> int
- The number of points in the CAD point helper list.
- auto previousPoint(bool* exists = nullptr) const -> QgsPointXY
- The previous point.
- void releaseLocks(bool releaseRepeatingLocks = true)
- unlock all constraints
- void setPoints(const QList<QgsPointXY>& points)
- Configures list of current CAD points.
- auto snappedSegment() const -> QList<QgsPointXY>
- Snapped to a segment.
- auto snappedToVertex() const -> bool
- Is it snapped to a vertex.
- void updateCadPaintItem()
- Updates canvas item that displays constraints on the ma.
Signals
- void pointChanged(const QgsPointXY& point)
- Sometimes a constraint may change the current point out of a mouse event.
- void popWarning()
- Remove any previously emitted warnings (if any)
- void pushWarning(const QString& message)
- Push a warning.
Enum documentation
enum QgsAdvancedDigitizingDockWidget:: AdditionalConstraint
Additional constraints which can be enabled.
| Enumerators | |
|---|---|
| NoConstraint |
No additional constraint. |
| Perpendicular |
Perpendicular. |
| Parallel |
Parallel. |
enum QgsAdvancedDigitizingDockWidget:: CadCapacity
The CadCapacity enum defines the possible constraints to be set depending on the number of points in the CAD point list (the list of points currently digitized)
| Enumerators | |
|---|---|
| AbsoluteAngle |
Azimuth. |
| RelativeAngle |
Also for parallel and perpendicular. |
| RelativeCoordinates |
This corresponds to distance and relative coordinates. |
Function documentation
QgsAdvancedDigitizingDockWidget:: QgsAdvancedDigitizingDockWidget(QgsMapCanvas* canvas,
QWidget* parent = nullptr) explicit
Create an advanced digitizing dock widget.
| Parameters | |
|---|---|
| canvas | The map canvas on which the widget operates |
| parent | The parent |
void QgsAdvancedDigitizingDockWidget:: addPoint(const QgsPointXY& point)
Adds point to the CAD point list.
bool QgsAdvancedDigitizingDockWidget:: alignToSegment(QgsMapMouseEvent* e,
QgsAdvancedDigitizingDockWidget:: CadConstraint:: LockMode lockMode = QgsAdvancedDigitizingDockWidget:: CadConstraint:: HardLock)
align to segment for additional constraint.
If additional constraints are used, this will determine the angle to be locked depending on the snapped segment.
bool QgsAdvancedDigitizingDockWidget:: applyConstraints(QgsMapMouseEvent* e)
apply the CAD constraints.
| Returns | false if no solution was found (invalid constraints) |
|---|
The will modify the position of the map event in map coordinates by applying the CAD constraints.
bool QgsAdvancedDigitizingDockWidget:: canvasKeyPressEventFilter(QKeyEvent* e)
Filter key events to e.g.
| Parameters | |
|---|---|
| e | A mouse event (may be modified) |
| Returns | If the event is hidden (construction mode hides events from the maptool) |
toggle construction mode or adapt constraints
void QgsAdvancedDigitizingDockWidget:: clearPoints()
Removes all points from the CAD point list.
QgsPointXY QgsAdvancedDigitizingDockWidget:: currentPoint(bool* exists = nullptr) const
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).
void QgsAdvancedDigitizingDockWidget:: disable()
Disable the widget.
Normally done automatically from QgsMapToolAdvancedDigitizing::
QgsPointLocator:: Match QgsAdvancedDigitizingDockWidget:: mapPointMatch() const
Returns the point locator match.
QgsPointXY QgsAdvancedDigitizingDockWidget:: penultimatePoint(bool* exists = nullptr) const
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).
QgsPointXY QgsAdvancedDigitizingDockWidget:: previousPoint(bool* exists = nullptr) const
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).
void QgsAdvancedDigitizingDockWidget:: releaseLocks(bool releaseRepeatingLocks = true)
unlock all constraints
| Parameters | |
|---|---|
| releaseRepeatingLocks | set to false to preserve the lock for any constraints set to repeating lock mode |
void QgsAdvancedDigitizingDockWidget:: setPoints(const QList<QgsPointXY>& points)
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.
void QgsAdvancedDigitizingDockWidget:: updateCadPaintItem()
Updates canvas item that displays constraints on the ma.
void QgsAdvancedDigitizingDockWidget:: pointChanged(const QgsPointXY& point) signal
Sometimes a constraint may change the current point out of a mouse event.
| Parameters | |
|---|---|
| point | The last known digitizing point. Can be used to emulate a mouse event. |
This happens normally when a constraint is toggled.
void QgsAdvancedDigitizingDockWidget:: pushWarning(const QString& message) signal
Push a warning.
| Parameters | |
|---|---|
| message | An informative message |