Skip to content
Permalink
Browse files
[mesh] mesh frame editing part-1 (qgis_core) (#43828)
[feature] qgis_core changes to allow mesh layer editing (part-1 or QEP#228)
  • Loading branch information
vcloarec committed Jun 25, 2021
1 parent f14e098 commit d326d38660734d48e48e0d4baf9cd4c084626bd3
@@ -956,7 +956,7 @@ if (WITH_CORE AND WITH_BINDINGS AND NOT WITH_QT6)
include(SIPMacros)

set(SIP_INCLUDES ${PYQT_SIP_DIR} ${CMAKE_SOURCE_DIR}/python)
set(SIP_CONCAT_PARTS 13)
set(SIP_CONCAT_PARTS 14)

if (NOT BINDINGS_GLOBAL_INSTALL)
set(Python_SITEARCH ${QGIS_DATA_DIR}/python)
@@ -11,6 +11,10 @@



%ModuleHeaderCode
#include "qgsinterpolator.h"
%End

struct QgsInterpolatorVertexData
{

@@ -378,3 +378,12 @@
Qgis.RasterResamplingStage.__doc__ = 'Stage at which raster resampling occurs.\n\n.. versionadded:: 3.22\n\n' + '* ``ResampleFilter``: ' + Qgis.RasterResamplingStage.ResampleFilter.__doc__ + '\n' + '* ``Provider``: ' + Qgis.RasterResamplingStage.Provider.__doc__
# --
Qgis.RasterResamplingStage.baseClass = Qgis
# monkey patching scoped based enum
Qgis.MeshEditingErrorType.NoError.__doc__ = "No type"
Qgis.MeshEditingErrorType.InvalidFace.__doc__ = "An error occurs due to an invalid face (for example, vertex indexes are unordered)"
Qgis.MeshEditingErrorType.FlatFace.__doc__ = "A flat face is present"
Qgis.MeshEditingErrorType.UniqueSharedVertex.__doc__ = "A least two faces share only one vertices"
Qgis.MeshEditingErrorType.InvalidVertex.__doc__ = "An error occurs due to an invalid vertex (for example, vertex index is out of range the available vertex)"
Qgis.MeshEditingErrorType.__doc__ = 'Type of error that can occur during mesh frame editing\n\n.. versionadded:: 3.22\n\n' + '* ``NoError``: ' + Qgis.MeshEditingErrorType.NoError.__doc__ + '\n' + '* ``InvalidFace``: ' + Qgis.MeshEditingErrorType.InvalidFace.__doc__ + '\n' + '* ``FlatFace``: ' + Qgis.MeshEditingErrorType.FlatFace.__doc__ + '\n' + '* ``UniqueSharedVertex``: ' + Qgis.MeshEditingErrorType.UniqueSharedVertex.__doc__ + '\n' + '* ``InvalidVertex``: ' + Qgis.MeshEditingErrorType.InvalidVertex.__doc__
# --
Qgis.MeshEditingErrorType.baseClass = Qgis
@@ -0,0 +1,118 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/mesh/qgsmesheditor.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsMeshEditingError
{
%Docstring(signature="appended")

Class that represents an error during mesh editing

.. versionadded:: 3.22
%End

%TypeHeaderCode
#include "qgsmesheditor.h"
%End
public:

QgsMeshEditingError();
%Docstring
Constructor of the default error, that is NoError
%End

QgsMeshEditingError( Qgis::MeshEditingErrorType type, int elementIndex );
%Docstring
Constructor with eht error ``type`` and the index of the element ``elementIndex``
%End

Qgis::MeshEditingErrorType errorType;

int elementIndex;

bool operator==( const QgsMeshEditingError &other ) const;
bool operator!=( const QgsMeshEditingError &other ) const;
};

class QgsMeshEditor : QObject
{
%Docstring(signature="appended")

Class that makes edit operation on a mesh

.. versionadded:: 3.22
%End

%TypeHeaderCode
#include "qgsmesheditor.h"
%End
public:

QgsMeshEditor( QgsMeshLayer *meshLayer );
%Docstring
Constructor with a specified layer ``meshLayer``
%End


QgsMeshEditingError initialize();
%Docstring
Initialize the mesh editor and return errors if the internal native mesh have topologic errors
%End

QgsMeshEditingError addFace( const QVector<int> &vertexIndexes );
%Docstring
Adds a face ``face`` to the mesh with vertex indexes ``vertexIndexes``, returns topological errors if this operation fails (operation is not realized)
%End

QgsMeshEditingError removeFaces( const QList<int> &facesToRemove );
%Docstring
Removes faces ``faces`` to the mesh, returns topological errors if this operation fails (operation is not realized)
%End

int addPointsAsVertices( const QVector<QgsPoint> &point, double tolerance );
%Docstring
Adds points as vertices in triangular mesh coordinate in the mesh. Vertex is effectivly added if the transform
from triangular coordinate to layer coordinate succeeds or if any vertices are next the added vertex (under ``tolerance`` distance).
The method returns the number of vertices effectivly added.

.. note::

this operation remove including face if exists and replace it by new faces surrounding the vertex
if the mesh hasn't topological error before this operation, the toological operation always succeed
%End

QgsMeshEditingError removeVertices( const QList<int> &verticesToRemoveIndexes, bool fillHoles = false );
%Docstring
Removes vertices with indexes in the list ``verticesToRemoveIndexes`` in the mesh
if ``fillHoles`` is set to ``True``, this operation will fill holes created in the mesh, if not remove the surrounding faces

If removing these vertices leads to a topological errors, the method will return the corresponding error and the operatio is canceled
%End

void stopEditing();
%Docstring
Stops editing
%End

signals:
void meshEdited();
%Docstring
Emitted when the mesh is edited
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/mesh/qgsmesheditor.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -706,6 +706,51 @@ Returns the relative time of the dataset from the reference time of its group
Returns the relative time (in milliseconds) of the dataset from the reference time of its group

.. versionadded:: 3.16
%End

bool startFrameEditing( const QgsCoordinateTransform &transform );
%Docstring
Starts edition of the mesh frame. Coordinate ``transform`` used to initialize the triangular mesh if needed.
This operation will disconnect the mesh layer from the data provider anf removes all existing dataset group

.. versionadded:: 3.22
%End

void stopFrameEditing( const QgsCoordinateTransform &transform );
%Docstring
Stops edition of the mesh, re-indexes the faces and vertices,
rebuilds the triangular mesh and its spatial index with ``transform``,
clean the undostack

.. versionadded:: 3.22
%End

QgsMeshEditor *meshEditor();
%Docstring
Returns a pointer to the mesh editor own by the mesh layer

.. versionadded:: 3.22
%End

int meshVerticesCount() const;
%Docstring
Returns the vertices count of the mesh frame

.. versionadded:: 3.22
%End

int meshFacesCount() const;
%Docstring
Returns the faces count of the mesh frame

.. versionadded:: 3.22
%End

int meshEdgeCount() const;
%Docstring
Returns the edges count of the mesh frame

.. versionadded:: 3.22
%End

public slots:
@@ -89,6 +89,17 @@ Returns the type of mesh elements that are indexed
.. versionadded:: 3.14
%End

void addFace( int faceIndex, const QgsMesh &mesh );
%Docstring
Adds a face with ``faceIndex`` from the ``mesh`` in the spatial index
%End

void removeFace( int faceIndex, const QgsMesh &mesh );
%Docstring
Removes a face with ``faceIndex`` from the ``mesh`` in the spatial index
%End


};

/************************************************************************
@@ -272,6 +272,15 @@ The development version
Provider
};

enum class MeshEditingErrorType
{
NoError,
InvalidFace,
FlatFace,
UniqueSharedVertex,
InvalidVertex,
};

static const double DEFAULT_SEARCH_RADIUS_MM;

static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
@@ -412,6 +412,7 @@
%Include auto_generated/maprenderer/qgsmaprenderersequentialjob.sip
%Include auto_generated/maprenderer/qgsmaprenderertask.sip
%Include auto_generated/mesh/qgsmesh3daveraging.sip
%Include auto_generated/mesh/qgsmesheditor.sip
%Include auto_generated/mesh/qgsmeshdataprovider.sip
%Include auto_generated/mesh/qgsmeshdataprovidertemporalcapabilities.sip
%Include auto_generated/mesh/qgsmeshdataset.sip
@@ -29,6 +29,12 @@ class QgsFeatureSource;
class QgsGeometry;
class QgsFeedback;

#ifdef SIP_RUN
% ModuleHeaderCode
#include "qgsinterpolator.h"
% End
#endif

/**
* Interpolation data for an individual source vertex.
* \since QGIS 3.0
@@ -16144,6 +16144,13 @@ void QgisApp::updateUndoActions()
canUndo = vlayer->undoStack()->canUndo();
canRedo = vlayer->undoStack()->canRedo();
}

QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( layer );
if ( meshLayer && meshLayer->meshEditor() )
{
canUndo = meshLayer->undoStack()->canUndo();
canRedo = meshLayer->undoStack()->canRedo();
}
}
mActionUndo->setEnabled( canUndo );
mActionRedo->setEnabled( canRedo );
@@ -637,6 +637,7 @@ set(QGIS_CORE_SRCS
raster/qgshillshaderenderer.cpp

mesh/qgsmesh3daveraging.cpp
mesh/qgsmesheditor.cpp
mesh/qgsmeshdataprovider.cpp
mesh/qgsmeshdataprovidertemporalcapabilities.cpp
mesh/qgsmeshdataset.cpp
@@ -657,6 +658,7 @@ set(QGIS_CORE_SRCS
mesh/qgsmeshcalculator.cpp
mesh/qgsmeshcalcutils.cpp
mesh/qgsmeshvirtualdatasetgroup.cpp
mesh/qgstopologicalmesh.cpp

pointcloud/qgspointcloudattribute.cpp
pointcloud/qgspointcloudattributebyramprenderer.cpp
@@ -1354,6 +1356,7 @@ set(QGIS_CORE_HDRS
maprenderer/qgsmaprenderertask.h

mesh/qgsmesh3daveraging.h
mesh/qgsmesheditor.h
mesh/qgsmeshdataprovider.h
mesh/qgsmeshdataprovidertemporalcapabilities.h
mesh/qgsmeshdataset.h
@@ -1374,6 +1377,7 @@ set(QGIS_CORE_HDRS
mesh/qgsmeshcalculator.h
mesh/qgsmeshcalcutils.h
mesh/qgsmeshvirtualdatasetgroup.h
mesh/qgstopologicalmesh.h

pal/costcalculator.h
pal/feature.h

0 comments on commit d326d38

Please sign in to comment.