Skip to content
Permalink
Browse files
[mesh] mesh frame editing part-2 - start, commit, roll back and cancel (
#43982)

[mesh] allows the user of mesh layers to start editing, save, roll back or cancel editing, in the same way as vector layers (editing part-2)
  • Loading branch information
vcloarec committed Jul 1, 2021
1 parent 174d5ee commit db21851bbb16899d73697d12ded531a535134283
Showing with 955 additions and 169 deletions.
  1. +30 −0 python/core/auto_generated/mesh/qgsmeshdataprovider.sip.in
  2. +10 −0 python/core/auto_generated/mesh/qgsmesheditor.sip.in
  3. +43 −2 python/core/auto_generated/mesh/qgsmeshlayer.sip.in
  4. +45 −0 python/core/auto_generated/qgsmaplayer.sip.in
  5. +3 −16 python/core/auto_generated/vector/qgsvectorlayer.sip.in
  6. +246 −36 src/app/qgisapp.cpp
  7. +37 −0 src/app/qgisapp.h
  8. +9 −13 src/core/layertree/qgslayertreemodel.cpp
  9. +7 −8 src/core/layertree/qgslayertreeutils.cpp
  10. +2 −0 src/core/mesh/qgsmeshdataprovider.cpp
  11. +30 −0 src/core/mesh/qgsmeshdataprovider.h
  12. +2 −2 src/core/mesh/qgsmeshdatasetgroupstore.cpp
  13. +14 −1 src/core/mesh/qgsmesheditor.cpp
  14. +6 −0 src/core/mesh/qgsmesheditor.h
  15. +124 −7 src/core/mesh/qgsmeshlayer.cpp
  16. +37 −2 src/core/mesh/qgsmeshlayer.h
  17. +23 −1 src/core/mesh/qgstriangularmesh.cpp
  18. +8 −0 src/core/mesh/qgstriangularmesh.h
  19. +8 −0 src/core/providers/meshmemory/qgsmeshmemorydataprovider.cpp
  20. +4 −0 src/core/providers/meshmemory/qgsmeshmemorydataprovider.h
  21. +10 −0 src/core/qgsmaplayer.cpp
  22. +33 −0 src/core/qgsmaplayer.h
  23. +3 −7 src/core/qgsmaplayerlegend.cpp
  24. +1 −1 src/core/vector/qgsvectorlayer.cpp
  25. +2 −11 src/core/vector/qgsvectorlayer.h
  26. +3 −3 src/gui/mesh/qgsmeshrendereractivedatasetwidget.cpp
  27. +3 −6 src/gui/mesh/qgsmeshrendererscalarsettingswidget.cpp
  28. +2 −4 src/gui/mesh/qgsrenderermeshpropertieswidget.cpp
  29. +45 −1 src/providers/mdal/qgsmdalprovider.cpp
  30. +7 −0 src/providers/mdal/qgsmdalprovider.h
  31. +130 −48 tests/src/core/testqgsmesheditor.cpp
  32. +3 −0 tests/src/core/testqgsmeshlayer.cpp
  33. +14 −0 tests/testdata/mesh/quad_flower_to_edit.2dm
  34. +11 −0 tests/testdata/mesh/quad_flower_to_edit_expected.2dm
@@ -147,6 +147,18 @@ Returns number of edges in the native mesh
Populates the mesh vertices, edges and faces

.. versionadded:: 3.6
%End

virtual bool saveMeshFrame( const QgsMesh &mesh ) = 0;
%Docstring
Saves the ``mesh`` frame to the source.

:param mesh: the mesh to save

:return: ``True`` on success


.. versionadded:: 3.22
%End
};

@@ -412,6 +424,24 @@ Sets the temporal unit of the provider and reload data if it changes.
.. versionadded:: 3.14
%End


virtual QgsMeshDriverMetadata driverMetadata() const;
%Docstring
Returns the mesh driver metadata of the provider

:return: the mesh driver metadata of the provider

.. versionadded:: 3.22
%End


virtual void close() = 0;
%Docstring
Closes the data provider and free every resources used

.. versionadded:: 3.22
%End

signals:
void datasetGroupsAdded( int count );
%Docstring
@@ -98,6 +98,16 @@ If removing these vertices leads to a topological errors, the method will return
void stopEditing();
%Docstring
Stops editing
%End

QgsRectangle extent() const;
%Docstring
Returns the extent of the edited mesh
%End

bool isModified() const;
%Docstring
Returns whether the mesh has been modified
%End

signals:
@@ -157,6 +157,10 @@ QgsMeshLayer cannot be copied.

virtual QString htmlMetadata() const;

virtual bool isEditable() const;

virtual bool supportsEditing() const;


QString providerType() const;
%Docstring
@@ -713,6 +717,28 @@ Returns the relative time (in milliseconds) of the dataset from the reference ti
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

bool commitFrameEditing( const QgsCoordinateTransform &transform, bool continueEditing = true );
%Docstring
Commits edition of the mesh frame,
Rebuilds the triangular mesh and its spatial index with ``transform``,
Continue editing with the same mesh editor if ``continueEditing`` is True

:return: ``True`` if the commit succeeds

.. versionadded:: 3.22
%End

bool rollBackFrameEditing( const QgsCoordinateTransform &transform, bool continueEditing = true );
%Docstring
Rolls Back edition of the mesh frame.
Reload mesh from file, rebuilds the triangular mesh and its spatial index with ``transform``,
Continue editing with the same mesh editor if ``continueEditing`` is ``True``

:return: ``True`` if the rollback succeeds

.. versionadded:: 3.22
%End

@@ -732,14 +758,29 @@ Returns a pointer to the mesh editor own by the mesh layer
.. versionadded:: 3.22
%End

int meshVerticesCount() const;
virtual bool isModified() const;

%Docstring
Returns whether the mesh frame has been modified since the last save

.. versionadded:: 3.22
%End

bool contains( const QgsMesh::ElementType &type ) const;
%Docstring
Returns whether the mesh contains at mesh elements of given type

.. versionadded:: 3.22
%End

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

.. versionadded:: 3.22
%End

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

@@ -550,11 +550,35 @@ Set the visibility of the given sublayer name.

:param name: sublayer name
:param visible: sublayer visibility
%End

virtual bool supportsEditing() const;
%Docstring
Returns whether the layer supports editing or not.

:return: ``False`` if the layer is read only or the data provider has no editing capabilities.

.. note::

default implementation returns ``False``.

.. versionadded:: 3.22
%End

virtual bool isEditable() const;
%Docstring
Returns ``True`` if the layer can be edited.
%End

virtual bool isModified() const;
%Docstring
Returns ``True`` if the layer has been modified since last commit/save.

.. note::

default implementation returns ``False``.

.. versionadded:: 3.22
%End

virtual bool isSpatial() const;
@@ -1724,6 +1748,27 @@ Emitted when the validity of this layer changed.
Emitted when a custom property of the layer has been changed or removed.

.. versionadded:: 3.18
%End

void editingStarted();
%Docstring
Emitted when editing on this layer has started.

.. versionadded:: 3.22
%End

void editingStopped();
%Docstring
Emitted when edited changes have been successfully written to the data provider.

.. versionadded:: 3.22
%End

void layerModified();
%Docstring
Emitted when modifications has been done on layer

.. versionadded:: 3.22
%End

protected:
@@ -1742,6 +1742,7 @@ Returns ``True`` if this is a geometry layer and ``False`` in case of NoGeometry
%End

virtual bool isModified() const;

%Docstring
Returns ``True`` if the provider has been modified since the last commit
%End
@@ -1808,7 +1809,8 @@ Makes layer read-only (editing disabled) or not
:return: ``False`` if the layer is in editing yet
%End

bool supportsEditing();
virtual bool supportsEditing() const;

%Docstring
Returns whether the layer supports editing or not

@@ -2727,11 +2729,6 @@ Emitted when selection was changed
:param selected: Newly selected feature ids
:param deselected: Ids of all features which have previously been selected but are not any more
:param clearAndSelect: In case this is set to ``True``, the old selection was dismissed and the new selection corresponds to selected
%End

void layerModified();
%Docstring
Emitted when modifications has been done on layer
%End

void allowCommitChanged();
@@ -2749,16 +2746,6 @@ Emitted when the layer is checked for modifications. Use for last-minute additio
void beforeEditingStarted();
%Docstring
Emitted before editing on this layer is started.
%End

void editingStarted();
%Docstring
Emitted when editing on this layer has started.
%End

void editingStopped();
%Docstring
Emitted when edited changes have been successfully written to the data provider.
%End

void beforeCommitChanges( bool stopEditing );

0 comments on commit db21851

Please sign in to comment.