-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] QgsMeshLayer part 1: Reading raw mesh #6820
Conversation
Introducting MDAL, QgsMeshLayer, mesh data providers (mesh_memory, mdal) to read and visualize raw meshes: vertices and faces. Support dragging 2dm files from browser on canvas to visualize 2dm meshes. Support for QgsMeshLayer in Python API.
@@ -1177,6 +1190,7 @@ INCLUDE_DIRECTORIES( | |||
scalebar | |||
symbology | |||
metadata | |||
mesh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to add core/mesh to the doxygen paths too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/core/mesh/qgsmeshlayer.cpp
Outdated
mProviderKey = provider; | ||
QString dataSource = mDataSource; | ||
|
||
if ( mDataProvider ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to project calls to delete - they do nothing for a nullptr anyway
src/core/mesh/qgsmeshlayer.h
Outdated
//! Return const data provider | ||
const QgsMeshDataProvider *dataProvider() const override SIP_SKIP; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't add docs for overridden methods unless they specifically add something relevant to the subclass - otherwise doxygen no longer inherits the base class docs and the subclass docs can go out of date and miss base class doxygen improvements.
src/core/mesh/qgsmeshlayer.h
Outdated
|
||
private: | ||
//! Pointer to native mesh structure, used as cache for rendering | ||
QgsMesh *mNativeMesh = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use unique_ptr for these members (all except the QObject derived data provider)
src/core/mesh/qgsmeshlayerrenderer.h
Outdated
|
||
// copy from mesh layer | ||
QgsSymbol *mNativeMeshSymbol = nullptr; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unique ptrs
src/core/mesh/qgstriangularmesh.cpp
Outdated
|
||
|
||
QgsTriangularMesh::QgsTriangularMesh( ) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=default
src/core/mesh/qgstriangularmesh.cpp
Outdated
} | ||
|
||
QgsTriangularMesh::~QgsTriangularMesh() | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= default (in header)
src/core/mesh/qgstriangularmesh.cpp
Outdated
// CREATE TRIANGULAR MESH | ||
for ( int i = 0; i < nativeMesh->faces.size(); ++i ) | ||
{ | ||
QgsMeshFace face = nativeMesh->faces[i] ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may detach - use faces.at( i ) instead (and use Qt creator 4.6 with all levels of clazy warnings enabled to catch these)
src/gui/qgsbrowserdockwidget_p.cpp
Outdated
else if ( type == QgsMapLayer::MeshLayer ) | ||
{ | ||
QgsDebugMsg( "creating mesh layer" ); | ||
QgsMeshLayer *layer = new QgsMeshLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique_ptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather keep it this way, since both if ( type == QgsMapLayer::RasterLayer )
and else if ( type == QgsMapLayer::VectorLayer )
do it without unique_ptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boy Scout that code then! Don't let new code be influenced by existing bad practice, instead fix the existing code and leave the codebase in a cleaner state then it was before.
src/core/mesh/qgsmeshlayer.h
Outdated
QgsTriangularMesh *triangularMesh() SIP_SKIP {return mTriangularMesh;} | ||
|
||
//! Returns a line symbol used for rendering native mesh. | ||
QgsSymbol *nativeMeshSymbol() {return mNativeMeshSymbol;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about having symbol and toggleTriangularMeshRendering here - those seem to be more of mesh renderer properties, and I think belong in their own separate class.
Cool! Exciting stuff |
@nyalldawson thank you for your review again, all should be OK now |
This triggers some build warnings here
PS: realized that I am working on an old codebase, might be solved meanwhile. |
Introducting MDAL, QgsMeshLayer, mesh data providers (mesh_memory, mdal)
to read and visualize raw meshes: vertices and faces. Support dragging
2dm files from browser on canvas to visualize 2dm meshes. Support for QgsMeshLayer in Python API.
See QEP Unstructured Mesh Layers