Class QfVertexModel
#include <qfvertexmodel.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 |
|---|---|
| QfVertexModel (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. |
| QList< VertexChange > | history (bool transformPoints=false, bool includeAvailableRedos=false) const |
| 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. |
| ~QfVertexModel () override |
Detailed Description
The QfVertexModel 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 QfVertexModel::ColumnRole {
PointRole = Qt::UserRole + 1,
CurrentVertexRole,
OriginalPointRole,
ExistingVertexRole,
RingIdRole
};
enum EditingMode
enum QfVertexModel::EditingMode {
NoEditing,
EditVertex,
AddVertex
};
enum PointType
enum QfVertexModel::PointType {
ExistingVertex,
NewVertexSegment,
NewVertexExtending
};
enum VertexChangeType
enum QfVertexModel::VertexChangeType {
NoChange,
VertexMove,
VertexAddition,
VertexDeletion
};
Public Properties Documentation
property canAddVertex [1/2]
determines if one can add vertex
bool QfVertexModel::canAddVertex;
property canNextVertex [1/2]
determines if one can go to next vertex
bool QfVertexModel::canNextVertex;
property canPreviousVertex [1/2]
determines if one can go to previous vertex
bool QfVertexModel::canPreviousVertex;
property canRemoveVertex [1/2]
determines if one can remove current vertex
bool QfVertexModel::canRemoveVertex;
property canUndo [1/2]
returns TRUE if an undo operation is available
bool QfVertexModel::canUndo;
property crs [1/2]
QgsCoordinateReferenceSystem QfVertexModel::crs;
The coordinate reference system in which the geometry is
property currentPoint [1/2]
The current point being edited.
QgsPoint QfVertexModel::currentPoint;
See also: editingMode. The expected CRS to read/write is the map canvas CRS
property currentVertexIndex [1/2]
int QfVertexModel::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 QfVertexModel::dirty;
property editingAllowed [1/2]
determines if the model allows editing the geometry
bool QfVertexModel::editingAllowed;
property editingMode [1/2]
The current mode.
EditingMode QfVertexModel::editingMode;
property geometry [1/2]
QgsGeometry QfVertexModel::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 QfVertexModel::isHovering;
property mapSettings [1/2]
Map settings is used to define the map canvas CRS and detect any extent change.
QgsQuickMapSettings * QfVertexModel::mapSettings;
property ringCount [1/2]
number of rings in the model
int QfVertexModel::ringCount;
property vertexCount [1/2]
number of vertices in the model
int QfVertexModel::vertexCount;
Public Signals Documentation
signal canAddVertexChanged
determines if one can add vertex
void QfVertexModel::canAddVertexChanged;
signal canNextVertexChanged
determines if one can go to next vertex
void QfVertexModel::canNextVertexChanged;
signal canPreviousVertexChanged
determines if one can go to previous vertex
void QfVertexModel::canPreviousVertexChanged;
signal canRemoveVertexChanged
determines if one can remove current vertex
void QfVertexModel::canRemoveVertexChanged;
signal crsChanged
Emitted when the coordinate reference system has changed.
void QfVertexModel::crsChanged;
signal currentPointChanged
The current point being edited.
void QfVertexModel::currentPointChanged;
See also: editingMode. The expected CRS to read/write is the map canvas CRS
signal currentVertexIndexChanged
void QfVertexModel::currentVertexIndexChanged;
signal dirtyChanged
determines if the model has changes
void QfVertexModel::dirtyChanged;
signal editingModeChanged
The current mode.
void QfVertexModel::editingModeChanged;
signal geometryChanged
Emitted when the geometry has changed.
void QfVertexModel::geometryChanged;
signal geometryTypeChanged
Returns the geometry type.
void QfVertexModel::geometryTypeChanged;
signal historyChanged
Emitted when the history has been modified.
void QfVertexModel::historyChanged;
signal mapSettingsChanged
Map settings is used to define the map canvas CRS and detect any extent change.
void QfVertexModel::mapSettingsChanged;
signal ringCountChanged
number of rings in the model
void QfVertexModel::ringCountChanged;
signal vertexCountChanged
number of vertices in the model
void QfVertexModel::vertexCountChanged;
Public Functions Documentation
function QfVertexModel
explicit QfVertexModel::QfVertexModel (
QObject * parent=nullptr
)
function addToHistory
void QfVertexModel::addToHistory (
VertexChangeType type
)
function addVertexNearestToPosition
Adds a new vertex on the segment having its mid-point nearest to the mapPoint .
Q_INVOKABLE void QfVertexModel::addVertexNearestToPosition (
const QgsPoint & mapPoint
)
function canAddVertex [2/2]
determines if one can add vertex
bool QfVertexModel::canAddVertex ()
function canNextVertex [2/2]
determines if one can go to next vertex
bool QfVertexModel::canNextVertex ()
function canPreviousVertex [2/2]
determines if one can go to previous vertex
bool QfVertexModel::canPreviousVertex ()
function canRemoveVertex [2/2]
determines if one can remove current vertex
bool QfVertexModel::canRemoveVertex ()
function canUndo [2/2]
bool QfVertexModel::canUndo ()
function clear
This will clear the data.
Q_INVOKABLE void QfVertexModel::clear ()
function clearHistory
void QfVertexModel::clearHistory ()
function columnCount
int QfVertexModel::columnCount (
const QModelIndex & parent
) override const
function crs [2/2]
QgsCoordinateReferenceSystem QfVertexModel::crs () const
The coordinate reference system in which the geometry is
function currentPoint [2/2]
The current point being edited.
QgsPoint QfVertexModel::currentPoint () const
See also: editingMode. The expected CRS to read/write is the map canvas CRS
function currentVertexIndex [2/2]
int QfVertexModel::currentVertexIndex () const
function data
QVariant QfVertexModel::data (
const QModelIndex & index,
int role
) override const
function dirty [2/2]
determines if the model has changes
bool QfVertexModel::dirty () const
function editingAllowed [2/2]
determines if the model allows editing the geometry
bool QfVertexModel::editingAllowed () const
function editingMode [2/2]
The current mode.
EditingMode QfVertexModel::editingMode () const
function flatVertices
QVector< QgsPoint > QfVertexModel::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 QfVertexModel::geometry () const
The geometry in layer coordinates
function geometryType
Returns the geometry type.
Qgis::GeometryType QfVertexModel::geometryType () const
function history
QList< VertexChange > QfVertexModel::history (
bool transformPoints=false,
bool includeAvailableRedos=false
) const
function index
QModelIndex QfVertexModel::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 * QfVertexModel::mapSettings ()
function next
next vertex or segment
Q_INVOKABLE void QfVertexModel::next ()
function parent
QModelIndex QfVertexModel::parent (
const QModelIndex & child
) override const
function previous
previous vertex or segment
Q_INVOKABLE void QfVertexModel::previous ()
function removeCurrentVertex
Q_INVOKABLE void QfVertexModel::removeCurrentVertex ()
function reset
Reset the model to its original geometry.
Q_INVOKABLE void QfVertexModel::reset ()
function ringCount [2/2]
number of rings in the model
int QfVertexModel::ringCount () const
function roleNames
QHash< int, QByteArray > QfVertexModel::roleNames () override const
function rowCount
int QfVertexModel::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 QfVertexModel::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 QfVertexModel::selectVertexAtPosition (
const QgsPoint & mapPoint,
double threshold,
bool autoInsert=true
)
function setCrs
void QfVertexModel::setCrs (
const QgsCoordinateReferenceSystem & crs
)
The coorinate reference system in which the geometry is
function setCurrentPoint
The current point being edited.
void QfVertexModel::setCurrentPoint (
const QgsPoint & point
)
See also: editingMode. The expected CRS to read/write is the map canvas CRS
function setCurrentVertexIndex
void QfVertexModel::setCurrentVertexIndex (
qsizetype currentIndex
)
function setEditingMode
The current mode.
void QfVertexModel::setEditingMode (
EditingMode mode
)
function setGeometry
void QfVertexModel::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 QfVertexModel::setMapSettings (
QgsQuickMapSettings * mapSettings
)
function undoHistory
Q_INVOKABLE void QfVertexModel::undoHistory ()
function updateGeometry
Q_INVOKABLE void QfVertexModel::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 QfVertexModel::vertex (
int row
) const
function vertexCount [2/2]
number of vertices in the model
int QfVertexModel::vertexCount () const
function vertices
Returns a list of vertices.
QList< Vertex > QfVertexModel::vertices () const
function verticesAdded
Returns a list of added vertices not found in linked geometry.
QVector< QgsPoint > QfVertexModel::verticesAdded () const
function verticesDeleted
Returns a list of added vertices not found in linked geometry.
QVector< QgsPoint > QfVertexModel::verticesDeleted () const
function verticesMoved
Returns a list of moved vertices found in linked geometry.
QVector< QPair< QgsPoint, QgsPoint > > QfVertexModel::verticesMoved () const
function ~QfVertexModel
QfVertexModel::~QfVertexModel () override
The documentation for this class was generated from the following file src/core/qfvertexmodel.h