30 , mAttribute( attribute )
36 if ( editIndex->mEditedNodeData.contains( n ) )
43 std::unique_ptr<QgsPointCloudBlock> block = index.
nodeData( n, req );
44 const char *ptr = block->data();
45 block->attributes().find( attribute.
name(), mAttributeOffset );
46 const int size = block->pointRecordSize();
47 for (
const int point : points )
49 const int offset = point * size + mAttributeOffset;
51 mPointValues[point] = oldValue;
58 mFirstEditForNode =
true;
59 for (
const int point : points )
61 mPointValues[point] = std::numeric_limits<double>::quiet_NaN();
68 undoRedoPrivate(
true );
73 undoRedoPrivate(
false );
76void QgsPointCloudLayerUndoCommandChangeAttribute::undoRedoPrivate(
bool isUndo )
79 QgsCopcPointCloudIndex *copcIndex =
static_cast<QgsCopcPointCloudIndex *
>( editIndex->mIndex.
get() );
82 if ( editIndex->mEditedNodeData.contains( mNode ) )
84 chunkData = editIndex->mEditedNodeData[mNode];
88 QPair<uint64_t, int32_t> offsetSizePair = copcIndex->mHierarchyNodePos[mNode];
89 chunkData = copcIndex->readRange( offsetSizePair.first, offsetSizePair.second );
93 if ( isUndo && mFirstEditForNode )
95 editIndex->mEditedNodeData.remove( mNode );
Collection of point cloud attributes.
Attribute for point cloud data pair of name and size in bytes.
QString name() const
Returns name of the attribute.
double convertValueToDouble(const char *ptr) const
Returns the attribute's value as a double for data pointed to by ptr.
The QgsPointCloudEditingIndex class is a QgsPointCloudIndex that is used as an editing buffer when ed...
Smart pointer for QgsAbstractPointCloudIndex.
std::unique_ptr< QgsPointCloudBlock > nodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request)
Returns node data block.
bool updateNodeData(const QHash< QgsPointCloudNodeId, QByteArray > &data)
Tries to update the data for the specified nodes.
QgsAbstractPointCloudIndex * get()
Returns pointer to the implementation class.
QgsPointCloudAttributeCollection attributes() const
Returns all attributes that are stored in the file.
static QByteArray updateChunkValues(QgsCopcPointCloudIndex *copcIndex, const QByteArray &chunkData, const QgsPointCloudAttribute &attribute, const QgsPointCloudNodeId &n, const QHash< int, double > &pointValues, std::optional< double > newValue=std::nullopt)
Sets new classification value for the given points in voxel and return updated chunk data.
QgsPointCloudLayerUndoCommandChangeAttribute(QgsPointCloudLayer *layer, const QgsPointCloudNodeId &n, const QVector< int > &points, const QgsPointCloudAttribute &attribute, double value)
Constructor for QgsPointCloudLayerUndoCommandChangeAttribute.
Base class for undo/redo command for point cloud editing.
QgsPointCloudLayerUndoCommand(QgsPointCloudLayer *layer)
Ctor.
QgsPointCloudLayer * mLayer
Represents a map layer supporting display of point clouds.
QgsPointCloudIndex index() const
Returns the point cloud index associated with the layer.
void chunkAttributeValuesChanged(const QgsPointCloudNodeId &n)
Emitted when a node gets some attribute values of some points changed.
Represents a indexed point cloud node's position in octree.
Point cloud data request.
void setIgnoreIndexFilterEnabled(bool enable)
When enable is true, the request will ignore the point cloud index's filter expression and use an emp...
void setAttributes(const QgsPointCloudAttributeCollection &attributes)
Set attributes filter in the request.