Skip to content

Class RubberbandModel

ClassList > RubberbandModel

More...

  • #include <rubberbandmodel.h>

Inherits the following classes: QObject

Public Properties

Type Name
property QgsCoordinateReferenceSystem crs
Coordinate reference system.
property QgsPoint currentCoordinate
Current vertex point.
property int currentCoordinateIndex
Current vertex index.
property QDateTime currentPositionTimestamp
currentPositionTimestamp is used externally by tracking, not (yet) stored in the coordinates (m) by the rubberbandmodel itself
property QgsPoint firstCoordinate
First vertex point.
property bool frozen
Freeze the rubberband so it doesn't get modified while panning map.
property Qgis::GeometryType geometryType
Geometry type of the model.
property QgsPoint lastCoordinate
Last vertex point.
property double measureValue
measureValue defines the M value of the coordinates
property QgsPoint penultimateCoordinate
Penultimate (last but one) vertex point.
property QgsVectorLayer * vectorLayer
The vector layer the model is for.
property int vertexCount
Total count of vertices.
property QVector< QgsPoint > vertices
All vertex points.

Public Signals

Type Name
signal void crsChanged
signal void currentCoordinateChanged
signal void currentCoordinateIndexChanged
signal void currentPositionTimestampChanged
signal void frozenChanged
Freeze the rubberband so it doesn't get modified while panning map.
signal void geometryTypeChanged
signal void measureValueChanged
signal void vectorLayerChanged
signal void vertexChanged (int index)
signal void vertexCountChanged
signal void verticesInserted (int index, int count)
signal void verticesRemoved (int index, int count)

Public Functions

Type Name
RubberbandModel (QObject * parent=nullptr)
Q_INVOKABLE void addVertex ()
Add vertex from the current position.
Q_INVOKABLE void addVertexFromPoint (const QgsPoint & point)
Add vertex with a given point.
QgsCoordinateReferenceSystem crs () const
Coordinate reference system.
QgsPoint currentCoordinate () const
Current vertex point.
int currentCoordinateIndex () const
Current vertex index.
QgsPoint currentPoint (const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem(), Qgis::WkbType wkbType=Qgis::WkbType::PointZ) const
Returns the current vertex point transformed to the given crs .
QDateTime currentPositionTimestamp () const
currentPositionTimestamp is used externally by tracking, not (yet) stored in the coordinates (m) by the rubberbandmodel itself
QgsPoint firstCoordinate () const
First vertex point.
QVector< QgsPointXY > flatPointSequence (const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem()) const
Returns all vertices points keeping only X and Y coordinates and transformed to the given crs .
bool frozen () const
Freeze the rubberband so it doesn't get modified while panning map.
Qgis::GeometryType geometryType () const
Geometry type of the model.
void insertVertices (int index, int count)
Inserts vertices.
bool isEmpty () const
Returns whether there is at least one vertex in the model.
QgsPoint lastCoordinate () const
Last vertex point.
double measureValue () const
measureValue defines the M value of the coordinates
QgsPoint penultimateCoordinate () const
Penultimate (last but one) vertex point.
Q_INVOKABLE QgsPointSequence pointSequence (const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem(), Qgis::WkbType wkbType=Qgis::WkbType::Point, bool closeLine=false) const
Q_INVOKABLE void removeVertex ()
Remove the vertex at the current index.
void removeVertices (int index, int count, bool keepLast=true)
Remove count vertices starting at__index .
Q_INVOKABLE void reset (bool keepLast=true)
Reset the model, remove all vertices and restart the vertex index.
void setCrs (const QgsCoordinateReferenceSystem & crs)
Coordinate reference system.
void setCurrentCoordinate (const QgsPoint & currentCoordinate)
Current vertex point.
void setCurrentCoordinateIndex (int currentCoordinateIndex)
Current vertex index.
void setCurrentPositionTimestamp (const QDateTime & currentPositionTimestamp)
currentPositionTimestamp is used externally by tracking, not (yet) stored in the coordinates (m) by the rubberbandmodel itself
void setDataFromGeometry (QgsGeometry geometry, const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem())
void setFrozen (const bool & frozen)
Freeze the rubberband so it doesn't get modified while panning map.
void setGeometryType (const Qgis::GeometryType & geometryType)
Geometry type of the model.
void setMeasureValue (const double measureValue)
measureValue defines the M value of the coordinates
void setVectorLayer (QgsVectorLayer * vectorLayer)
The vector layer the model is for.
void setVertex (int index, QgsPoint coordinate)
Sets a vertex point at given index.
QgsVectorLayer * vectorLayer () const
The vector layer the model is for.
QgsPoint vertexAt (int index, const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem()) const
Returns the vertex point at a given index transformed to the given__crs .
int vertexCount () const
Total count of vertices.
QVector< QgsPoint > vertices () const
All vertex points.
QVector< QgsPoint > verticesCopy (bool skipCurrentPoint=false) const
Returns a copy of all vertice points in the model, with the option to skip the current vertex.

Detailed Description

This model manages a list of vertices. It can be used as a linestring or as a ring in a polygon.

Public Properties Documentation

property crs [1/2]

Coordinate reference system.

QgsCoordinateReferenceSystem RubberbandModel::crs;

property currentCoordinate [1/2]

Current vertex point.

QgsPoint RubberbandModel::currentCoordinate;

property currentCoordinateIndex [1/2]

Current vertex index.

int RubberbandModel::currentCoordinateIndex;

property currentPositionTimestamp [1/2]

currentPositionTimestamp is used externally by tracking, not (yet) stored in the coordinates (m) by the rubberbandmodel itself

QDateTime RubberbandModel::currentPositionTimestamp;

property firstCoordinate [1/2]

First vertex point.

QgsPoint RubberbandModel::firstCoordinate;

property frozen [1/2]

Freeze the rubberband so it doesn't get modified while panning map.

bool RubberbandModel::frozen;

property geometryType [1/2]

Geometry type of the model.

Qgis::GeometryType RubberbandModel::geometryType;

property lastCoordinate [1/2]

Last vertex point.

QgsPoint RubberbandModel::lastCoordinate;

property measureValue [1/2]

measureValue defines the M value of the coordinates

double RubberbandModel::measureValue;

property penultimateCoordinate [1/2]

Penultimate (last but one) vertex point.

QgsPoint RubberbandModel::penultimateCoordinate;

property vectorLayer [1/2]

The vector layer the model is for.

QgsVectorLayer * RubberbandModel::vectorLayer;

property vertexCount [1/2]

Total count of vertices.

int RubberbandModel::vertexCount;

property vertices [1/2]

All vertex points.

QVector<QgsPoint> RubberbandModel::vertices;

Public Signals Documentation

signal crsChanged

void RubberbandModel::crsChanged;

signal currentCoordinateChanged

void RubberbandModel::currentCoordinateChanged;

signal currentCoordinateIndexChanged

void RubberbandModel::currentCoordinateIndexChanged;

signal currentPositionTimestampChanged

void RubberbandModel::currentPositionTimestampChanged;

signal frozenChanged

Freeze the rubberband so it doesn't get modified while panning map.

void RubberbandModel::frozenChanged;

signal geometryTypeChanged

void RubberbandModel::geometryTypeChanged;

signal measureValueChanged

void RubberbandModel::measureValueChanged;

signal vectorLayerChanged

void RubberbandModel::vectorLayerChanged;

signal vertexChanged

void RubberbandModel::vertexChanged;

signal vertexCountChanged

void RubberbandModel::vertexCountChanged;

signal verticesInserted

void RubberbandModel::verticesInserted;

signal verticesRemoved

void RubberbandModel::verticesRemoved;

Public Functions Documentation

function RubberbandModel

explicit RubberbandModel::RubberbandModel (
    QObject * parent=nullptr
) 

function addVertex

Add vertex from the current position.

Q_INVOKABLE void RubberbandModel::addVertex () 

function addVertexFromPoint

Add vertex with a given point.

Q_INVOKABLE void RubberbandModel::addVertexFromPoint (
    const QgsPoint & point
) 

function crs [2/2]

Coordinate reference system.

QgsCoordinateReferenceSystem RubberbandModel::crs () const

function currentCoordinate [2/2]

Current vertex point.

QgsPoint RubberbandModel::currentCoordinate () const

function currentCoordinateIndex [2/2]

Current vertex index.

int RubberbandModel::currentCoordinateIndex () const

function currentPoint

Returns the current vertex point transformed to the given crs .

QgsPoint RubberbandModel::currentPoint (
    const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem(),
    Qgis::WkbType wkbType=Qgis::WkbType::PointZ
) const

function currentPositionTimestamp [2/2]

currentPositionTimestamp is used externally by tracking, not (yet) stored in the coordinates (m) by the rubberbandmodel itself

QDateTime RubberbandModel::currentPositionTimestamp () const

function firstCoordinate [2/2]

First vertex point.

QgsPoint RubberbandModel::firstCoordinate () const

function flatPointSequence

Returns all vertices points keeping only X and Y coordinates and transformed to the given crs .

QVector< QgsPointXY > RubberbandModel::flatPointSequence (
    const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem()
) const

function frozen [2/2]

Freeze the rubberband so it doesn't get modified while panning map.

bool RubberbandModel::frozen () const

function geometryType [2/2]

Geometry type of the model.

Qgis::GeometryType RubberbandModel::geometryType () const

function insertVertices

Inserts vertices.

void RubberbandModel::insertVertices (
    int index,
    int count
) 

function isEmpty

Returns whether there is at least one vertex in the model.

bool RubberbandModel::isEmpty () const

function lastCoordinate [2/2]

Last vertex point.

QgsPoint RubberbandModel::lastCoordinate () const

function measureValue [2/2]

measureValue defines the M value of the coordinates

double RubberbandModel::measureValue () const

function penultimateCoordinate [2/2]

Penultimate (last but one) vertex point.

QgsPoint RubberbandModel::penultimateCoordinate () const

function pointSequence

Q_INVOKABLE QgsPointSequence RubberbandModel::pointSequence (
    const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem(),
    Qgis::WkbType wkbType=Qgis::WkbType::Point,
    bool closeLine=false
) const

The target CRS into which points should be reprojected. To retrieve unprojected points pass an invalid QgsCoordinateReferenceSystem object.

By default coordinates will be returned unprojected.


function removeVertex

Remove the vertex at the current index.

Q_INVOKABLE void RubberbandModel::removeVertex () 

function removeVertices

Remove count vertices starting at__index .

void RubberbandModel::removeVertices (
    int index,
    int count,
    bool keepLast=true
) 

function reset

Reset the model, remove all vertices and restart the vertex index.

Q_INVOKABLE void RubberbandModel::reset (
    bool keepLast=true
) 

function setCrs

Coordinate reference system.

void RubberbandModel::setCrs (
    const QgsCoordinateReferenceSystem & crs
) 

function setCurrentCoordinate

Current vertex point.

void RubberbandModel::setCurrentCoordinate (
    const QgsPoint & currentCoordinate
) 

function setCurrentCoordinateIndex

Current vertex index.

void RubberbandModel::setCurrentCoordinateIndex (
    int currentCoordinateIndex
) 

function setCurrentPositionTimestamp

currentPositionTimestamp is used externally by tracking, not (yet) stored in the coordinates (m) by the rubberbandmodel itself

void RubberbandModel::setCurrentPositionTimestamp (
    const QDateTime & currentPositionTimestamp
) 

function setDataFromGeometry

void RubberbandModel::setDataFromGeometry (
    QgsGeometry geometry,
    const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem()
) 

Sets the model data to match a given geometry

Note:

rings and multiparts are discarded


function setFrozen

Freeze the rubberband so it doesn't get modified while panning map.

void RubberbandModel::setFrozen (
    const bool & frozen
) 

function setGeometryType

Geometry type of the model.

void RubberbandModel::setGeometryType (
    const Qgis::GeometryType & geometryType
) 

function setMeasureValue

measureValue defines the M value of the coordinates

void RubberbandModel::setMeasureValue (
    const double measureValue
) 

function setVectorLayer

The vector layer the model is for.

void RubberbandModel::setVectorLayer (
    QgsVectorLayer * vectorLayer
) 

function setVertex

Sets a vertex point at given index.

void RubberbandModel::setVertex (
    int index,
    QgsPoint coordinate
) 

function vectorLayer [2/2]

The vector layer the model is for.

QgsVectorLayer * RubberbandModel::vectorLayer () const

function vertexAt

Returns the vertex point at a given index transformed to the given__crs .

QgsPoint RubberbandModel::vertexAt (
    int index,
    const QgsCoordinateReferenceSystem & crs=QgsCoordinateReferenceSystem()
) const

function vertexCount [2/2]

Total count of vertices.

int RubberbandModel::vertexCount () const

function vertices [2/2]

All vertex points.

QVector< QgsPoint > RubberbandModel::vertices () const

function verticesCopy

Returns a copy of all vertice points in the model, with the option to skip the current vertex.

QVector< QgsPoint > RubberbandModel::verticesCopy (
    bool skipCurrentPoint=false
) const


The documentation for this class was generated from the following file src/core/rubberbandmodel.h