Skip to content

Class VertexModel

ClassList > VertexModel

More...

  • #include <vertexmodel.h>

Inherits the following classes: QAbstractListModel

Classes

Type Name
struct Vertex
struct VertexChange

Public Types

Type Name
enum ColumnRole
enum EditingMode
enum PointType
enum VertexChangeType

Public Properties

Type Name
property bool canAddVertex
determines if one can add vertex
property bool canNextVertex
determines if one can go to next vertex
property bool canPreviousVertex
determines if one can go to previous vertex
property bool canRemoveVertex
determines if one can remove current vertex
property bool canUndo
returns TRUE if an undo operation is available
property QgsCoordinateReferenceSystem crs
property QgsPoint currentPoint
The current point being edited.
property int currentVertexIndex
property bool dirty
determines if the model has changes
property bool editingAllowed
determines if the model allows editing the geometry
property EditingMode editingMode
The current mode.
property QgsGeometry geometry
property bool isHovering
determines if the map is currently being hovered (then when moving the map, it will not move directly a vertex if the mode is AddVertex)
property QgsQuickMapSettings * mapSettings
Map settings is used to define the map canvas CRS and detect any extent change.
property int ringCount
number of rings in the model
property int vertexCount
number of vertices in the model

Public Signals

Type Name
signal void canAddVertexChanged
determines if one can add vertex
signal void canNextVertexChanged
determines if one can go to next vertex
signal void canPreviousVertexChanged
determines if one can go to previous vertex
signal void canRemoveVertexChanged
determines if one can remove current vertex
signal void crsChanged
Emitted when the coordinate reference system has changed.
signal void currentPointChanged
The current point being edited.
signal void currentVertexIndexChanged
signal void dirtyChanged
determines if the model has changes
signal void editingModeChanged
The current mode.
signal void geometryChanged
Emitted when the geometry has changed.
signal void geometryTypeChanged
Returns the geometry type.
signal void historyChanged
Emitted when the history has been modified.
signal void mapSettingsChanged
Map settings is used to define the map canvas CRS and detect any extent change.
signal void ringCountChanged
number of rings in the model
signal void vertexCountChanged
number of vertices in the model

Public Functions

Type Name
VertexModel (QObject * parent=nullptr)
void addToHistory (VertexChangeType type)
Q_INVOKABLE void addVertexNearestToPosition (const QgsPoint & mapPoint)
Adds a new vertex on the segment having its mid-point nearest to the mapPoint .
bool canAddVertex ()
determines if one can add vertex
bool canNextVertex ()
determines if one can go to next vertex
bool canPreviousVertex ()
determines if one can go to previous vertex
bool canRemoveVertex ()
determines if one can remove current vertex
bool canUndo ()
Q_INVOKABLE void clear ()
This will clear the data.
void clearHistory ()
int columnCount (const QModelIndex & parent) override const
QgsCoordinateReferenceSystem crs () const
QgsPoint currentPoint () const
The current point being edited.
int currentVertexIndex () const
QVariant data (const QModelIndex & index, int role) override const
bool dirty () const
determines if the model has changes
bool editingAllowed () const
determines if the model allows editing the geometry
EditingMode editingMode () const
The current mode.
QVector< QgsPoint > flatVertices (int ringId=-1) const
QgsGeometry geometry () const
Qgis::GeometryType geometryType () const
Returns the geometry type.
QModelIndex index (int row, int column, const QModelIndex & parent) override const
QgsQuickMapSettings * mapSettings ()
Map settings is used to define the map canvas CRS and detect any extent change.
Q_INVOKABLE void next ()
next vertex or segment
QModelIndex parent (const QModelIndex & child) override const
Q_INVOKABLE void previous ()
previous vertex or segment
Q_INVOKABLE void removeCurrentVertex ()
Q_INVOKABLE void reset ()
Reset the model to its original geometry.
int ringCount () const
number of rings in the model
QHash< int, QByteArray > roleNames () override const
int rowCount (const QModelIndex & parent) override const
Q_INVOKABLE void selectVertexAtPosition (const QPointF & point, double threshold, bool autoInsert=true)
Selects the vertex at the given screen point within a given__threshold .
void selectVertexAtPosition (const QgsPoint & mapPoint, double threshold, bool autoInsert=true)
Selects the vertex at the given mapPoint within a given__threshold .
void setCrs (const QgsCoordinateReferenceSystem & crs)
void setCurrentPoint (const QgsPoint & point)
The current point being edited.
void setCurrentVertexIndex (qsizetype currentIndex)
void setEditingMode (EditingMode mode)
The current mode.
void setGeometry (const QgsGeometry & geometry)
void setMapSettings (QgsQuickMapSettings * mapSettings)
Map settings is used to define the map canvas CRS and detect any extent change.
Q_INVOKABLE void undoHistory ()
Q_INVOKABLE void updateGeometry (const QgsGeometry & geometry)
Vertex vertex (int row) const
int vertexCount () const
number of vertices in the model
QList< Vertex > vertices () const
Returns a list of vertices.
QVector< QgsPoint > verticesAdded () const
Returns a list of added vertices not found in linked geometry.
QVector< QgsPoint > verticesDeleted () const
Returns a list of added vertices not found in linked geometry.
QVector< QPair< QgsPoint, QgsPoint > > verticesMoved () const
Returns a list of moved vertices found in linked geometry.
~VertexModel () override

Detailed Description

The VertexModel class is a model to highlight and edit vertices. The model is used in map coordinates. There are different modes: no editing, edit (move/remove) nodes, add nodes (to be implemented)

The model holds all vertices and the candidates for new vertices. If you need the existing nodes, use flatVertices().

Public Types Documentation

enum ColumnRole

enum VertexModel::ColumnRole {
    PointRole = Qt::UserRole + 1,
    CurrentVertexRole,
    OriginalPointRole,
    ExistingVertexRole,
    RingIdRole
};

enum EditingMode

enum VertexModel::EditingMode {
    NoEditing,
    EditVertex,
    AddVertex
};

enum PointType

enum VertexModel::PointType {
    ExistingVertex,
    NewVertexSegment,
    NewVertexExtending
};

enum VertexChangeType

enum VertexModel::VertexChangeType {
    NoChange,
    VertexMove,
    VertexAddition,
    VertexDeletion
};

Public Properties Documentation

property canAddVertex [1/2]

determines if one can add vertex

bool VertexModel::canAddVertex;

property canNextVertex [1/2]

determines if one can go to next vertex

bool VertexModel::canNextVertex;

property canPreviousVertex [1/2]

determines if one can go to previous vertex

bool VertexModel::canPreviousVertex;

property canRemoveVertex [1/2]

determines if one can remove current vertex

bool VertexModel::canRemoveVertex;

property canUndo [1/2]

returns TRUE if an undo operation is available

bool VertexModel::canUndo;

property crs [1/2]

QgsCoordinateReferenceSystem VertexModel::crs;

The coordinate reference system in which the geometry is


property currentPoint [1/2]

The current point being edited.

QgsPoint VertexModel::currentPoint;

See also: editingMode. The expected CRS to read/write is the map canvas CRS


property currentVertexIndex [1/2]

int VertexModel::currentVertexIndex;

The index of the currently active vertex. If no vertex is selected, this is -1.


property dirty [1/2]

determines if the model has changes

bool VertexModel::dirty;

property editingAllowed [1/2]

determines if the model allows editing the geometry

bool VertexModel::editingAllowed;

property editingMode [1/2]

The current mode.

EditingMode VertexModel::editingMode;

property geometry [1/2]

QgsGeometry VertexModel::geometry;

The geometry in layer coordinates


property isHovering

determines if the map is currently being hovered (then when moving the map, it will not move directly a vertex if the mode is AddVertex)

bool VertexModel::isHovering;

property mapSettings [1/2]

Map settings is used to define the map canvas CRS and detect any extent change.

QgsQuickMapSettings * VertexModel::mapSettings;

property ringCount [1/2]

number of rings in the model

int VertexModel::ringCount;

property vertexCount [1/2]

number of vertices in the model

int VertexModel::vertexCount;

Public Signals Documentation

signal canAddVertexChanged

determines if one can add vertex

void VertexModel::canAddVertexChanged;

signal canNextVertexChanged

determines if one can go to next vertex

void VertexModel::canNextVertexChanged;

signal canPreviousVertexChanged

determines if one can go to previous vertex

void VertexModel::canPreviousVertexChanged;

signal canRemoveVertexChanged

determines if one can remove current vertex

void VertexModel::canRemoveVertexChanged;

signal crsChanged

Emitted when the coordinate reference system has changed.

void VertexModel::crsChanged;

signal currentPointChanged

The current point being edited.

void VertexModel::currentPointChanged;

See also: editingMode. The expected CRS to read/write is the map canvas CRS


signal currentVertexIndexChanged

void VertexModel::currentVertexIndexChanged;

signal dirtyChanged

determines if the model has changes

void VertexModel::dirtyChanged;

signal editingModeChanged

The current mode.

void VertexModel::editingModeChanged;

signal geometryChanged

Emitted when the geometry has changed.

void VertexModel::geometryChanged;

signal geometryTypeChanged

Returns the geometry type.

void VertexModel::geometryTypeChanged;

signal historyChanged

Emitted when the history has been modified.

void VertexModel::historyChanged;

signal mapSettingsChanged

Map settings is used to define the map canvas CRS and detect any extent change.

void VertexModel::mapSettingsChanged;

signal ringCountChanged

number of rings in the model

void VertexModel::ringCountChanged;

signal vertexCountChanged

number of vertices in the model

void VertexModel::vertexCountChanged;

Public Functions Documentation

function VertexModel

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

function addToHistory

void VertexModel::addToHistory (
    VertexChangeType type
) 

function addVertexNearestToPosition

Adds a new vertex on the segment having its mid-point nearest to the mapPoint .

Q_INVOKABLE void VertexModel::addVertexNearestToPosition (
    const QgsPoint & mapPoint
) 

function canAddVertex [2/2]

determines if one can add vertex

bool VertexModel::canAddVertex () 

function canNextVertex [2/2]

determines if one can go to next vertex

bool VertexModel::canNextVertex () 

function canPreviousVertex [2/2]

determines if one can go to previous vertex

bool VertexModel::canPreviousVertex () 

function canRemoveVertex [2/2]

determines if one can remove current vertex

bool VertexModel::canRemoveVertex () 

function canUndo [2/2]

bool VertexModel::canUndo () 

function clear

This will clear the data.

Q_INVOKABLE void VertexModel::clear () 

function clearHistory

void VertexModel::clearHistory () 

function columnCount

int VertexModel::columnCount (
    const QModelIndex & parent
) override const

function crs [2/2]

QgsCoordinateReferenceSystem VertexModel::crs () const

The coordinate reference system in which the geometry is


function currentPoint [2/2]

The current point being edited.

QgsPoint VertexModel::currentPoint () const

See also: editingMode. The expected CRS to read/write is the map canvas CRS


function currentVertexIndex [2/2]

int VertexModel::currentVertexIndex () const

function data

QVariant VertexModel::data (
    const QModelIndex & index,
    int role
) override const

function dirty [2/2]

determines if the model has changes

bool VertexModel::dirty () const

function editingAllowed [2/2]

determines if the model allows editing the geometry

bool VertexModel::editingAllowed () const

function editingMode [2/2]

The current mode.

EditingMode VertexModel::editingMode () const

function flatVertices

QVector< QgsPoint > VertexModel::flatVertices (
    int ringId=-1
) const

Returns a list of point (segment vertex, if any, will be skipped) For a polygon, if ringId is not given the current ring will be returned


function geometry [2/2]

QgsGeometry VertexModel::geometry () const

The geometry in layer coordinates


function geometryType

Returns the geometry type.

Qgis::GeometryType VertexModel::geometryType () const

function index

QModelIndex VertexModel::index (
    int row,
    int column,
    const QModelIndex & parent
) override const

function mapSettings [2/2]

Map settings is used to define the map canvas CRS and detect any extent change.

QgsQuickMapSettings * VertexModel::mapSettings () 

function next

next vertex or segment

Q_INVOKABLE void VertexModel::next () 

function parent

QModelIndex VertexModel::parent (
    const QModelIndex & child
) override const

function previous

previous vertex or segment

Q_INVOKABLE void VertexModel::previous () 

function removeCurrentVertex

Q_INVOKABLE void VertexModel::removeCurrentVertex () 

function reset

Reset the model to its original geometry.

Q_INVOKABLE void VertexModel::reset () 

function ringCount [2/2]

number of rings in the model

int VertexModel::ringCount () const

function roleNames

QHash< int, QByteArray > VertexModel::roleNames () override const

function rowCount

int VertexModel::rowCount (
    const QModelIndex & parent
) override const

function selectVertexAtPosition [1/2]

Selects the vertex at the given screen point within a given__threshold .

Q_INVOKABLE void VertexModel::selectVertexAtPosition (
    const QPointF & point,
    double threshold,
    bool autoInsert=true
) 

function selectVertexAtPosition [2/2]

Selects the vertex at the given mapPoint within a given__threshold .

void VertexModel::selectVertexAtPosition (
    const QgsPoint & mapPoint,
    double threshold,
    bool autoInsert=true
) 

function setCrs

void VertexModel::setCrs (
    const QgsCoordinateReferenceSystem & crs
) 

The coorinate reference system in which the geometry is


function setCurrentPoint

The current point being edited.

void VertexModel::setCurrentPoint (
    const QgsPoint & point
) 

See also: editingMode. The expected CRS to read/write is the map canvas CRS


function setCurrentVertexIndex

void VertexModel::setCurrentVertexIndex (
    qsizetype currentIndex
) 

function setEditingMode

The current mode.

void VertexModel::setEditingMode (
    EditingMode mode
) 

function setGeometry

void VertexModel::setGeometry (
    const QgsGeometry & geometry
) 

The geometry in layer coordinates


function setMapSettings

Map settings is used to define the map canvas CRS and detect any extent change.

void VertexModel::setMapSettings (
    QgsQuickMapSettings * mapSettings
) 

function undoHistory

Q_INVOKABLE void VertexModel::undoHistory () 

function updateGeometry

Q_INVOKABLE void VertexModel::updateGeometry (
    const QgsGeometry & geometry
) 

sets the geometry to the given geometry but preserves the index of the current vertex this is used to update the original geometry while still editing the model

See also: geometry property


function vertex

Vertex VertexModel::vertex (
    int row
) const

function vertexCount [2/2]

number of vertices in the model

int VertexModel::vertexCount () const

function vertices

Returns a list of vertices.

QList< Vertex > VertexModel::vertices () const

function verticesAdded

Returns a list of added vertices not found in linked geometry.

QVector< QgsPoint > VertexModel::verticesAdded () const

function verticesDeleted

Returns a list of added vertices not found in linked geometry.

QVector< QgsPoint > VertexModel::verticesDeleted () const

function verticesMoved

Returns a list of moved vertices found in linked geometry.

QVector< QPair< QgsPoint, QgsPoint > > VertexModel::verticesMoved () const

function ~VertexModel

VertexModel::~VertexModel () override


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