Skip to content
Permalink
Browse files

Add QgsPointCloudAttributeModel model for display of attributes in

a point cloud layer
  • Loading branch information
nyalldawson committed Nov 9, 2020
1 parent d0d7aa6 commit aa428a060e875ff410b02a77be2d2ee75156b44a
@@ -123,7 +123,14 @@ Returns the attribute at the specified ``index``.
%Docstring
Finds the attribute with the name

Returns None if not found
Returns ``None`` if not found.
%End

int indexOf( const QString &name ) const;
%Docstring
Returns the index of the attribute with the specified ``name``.

Returns -1 if a matching attribute was not found.
%End

size_t pointRecordSize() const;
@@ -0,0 +1,116 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/pointcloud/qgspointcloudattributemodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsPointCloudAttributeModel : QAbstractItemModel
{
%Docstring

A model for display of available attributes from a point cloud.

.. versionadded:: 3.18
%End

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

enum FieldRoles
{
AttributeNameRole,
AttributeSizeRole,
AttributeTypeRole,
IsEmptyRole,
IsNumericRole,
};

explicit QgsPointCloudAttributeModel( QObject *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsPointCloudAttributeModel, with the specified ``parent`` object.
%End

void setLayer( QgsPointCloudLayer *layer );
%Docstring
Sets the ``layer`` associated with the model.

.. seealso:: :py:func:`setAttributes`
%End

void setAttributes( const QgsPointCloudAttributeCollection &attributes );
%Docstring
Sets the ``attributes`` to include in the model.

.. seealso:: :py:func:`setLayer`

.. seealso:: :py:func:`attributes`
%End

QgsPointCloudAttributeCollection attributes() const;
%Docstring
Returns the attributes associated with the model.

.. seealso:: :py:func:`setAttributes`
%End

void setAllowEmptyAttributeName( bool allowEmpty );
%Docstring
Sets whether an optional empty attribute ("not set") option is present in the model.

.. seealso:: :py:func:`allowEmptyAttributeName`
%End

QModelIndex indexFromName( const QString &name );
%Docstring
Returns the index corresponding to a given attribute ``name``.
%End

bool allowEmptyAttributeName() const;
%Docstring
Returns ``True`` if the model allows the empty attribute ("not set") choice.

.. seealso:: :py:func:`setAllowEmptyAttributeName`
%End

virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;

virtual QModelIndex parent( const QModelIndex &child ) const;

virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;

virtual int columnCount( const QModelIndex &parent ) const;

virtual QVariant data( const QModelIndex &index, int role ) const;


static QString attributeToolTip( const QgsPointCloudAttribute &attribute );
%Docstring
Returns a HTML formatted tooltip string for a ``attribute``, containing details
like the attribute name and type.
%End

static QIcon iconForAttributeType( QgsPointCloudAttribute::DataType type );
%Docstring
Returns an icon corresponding to an attribute ``type``
%End

};



/************************************************************************
* This file has been generated automatically from *
* *
* src/core/pointcloud/qgspointcloudattributemodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -631,6 +631,7 @@ SET(QGIS_CORE_SRCS
mesh/qgsmeshvirtualdatasetgroup.cpp

pointcloud/qgspointcloudattribute.cpp
pointcloud/qgspointcloudattributemodel.cpp
pointcloud/qgspointcloudrequest.cpp
pointcloud/qgspointcloudblock.cpp
pointcloud/qgspointcloudlayer.cpp
@@ -1315,6 +1316,7 @@ SET(QGIS_CORE_HDRS
mesh/qgsmeshvirtualdatasetgroup.h

pointcloud/qgspointcloudattribute.h
pointcloud/qgspointcloudattributemodel.h
pointcloud/qgspointcloudrequest.h
pointcloud/qgspointcloudblock.h
pointcloud/qgspointcloudlayer.h
@@ -119,3 +119,15 @@ const QgsPointCloudAttribute *QgsPointCloudAttributeCollection::find( const QStr
// not found
return nullptr;
}

int QgsPointCloudAttributeCollection::indexOf( const QString &name ) const
{
auto it = mCachedAttributes.constFind( name );
if ( it != mCachedAttributes.constEnd() )
{
return it->index;
}

// not found
return -1;
}
@@ -121,10 +121,17 @@ class CORE_EXPORT QgsPointCloudAttributeCollection
/**
* Finds the attribute with the name
*
* Returns nullptr if not found
* Returns NULLPTR if not found.
*/
const QgsPointCloudAttribute *find( const QString &attributeName, int &offset ) const;

/**
* Returns the index of the attribute with the specified \a name.
*
* Returns -1 if a matching attribute was not found.
*/
int indexOf( const QString &name ) const;

//! Returns total size of record
size_t pointRecordSize() const { return mSize; }

0 comments on commit aa428a0

Please sign in to comment.
You can’t perform that action at this time.