23#include <QtConcurrentMap> 
   32  , mAttribute( attribute )
 
   35  QgsEventTracing::ScopedEvent _trace( QStringLiteral( 
"PointCloud" ), QStringLiteral( 
"QgsPointCloudLayerUndoCommand constructor" ) );
 
   40  std::function mapFn = [editIndex, attribute, index = std::move( index )]( std::pair<const QgsPointCloudNodeId &, const QVector<int> &> pair )
 
   43    auto &points = pair.second;
 
   46    PerNodeData perNodeData;
 
   55      std::unique_ptr<QgsPointCloudBlock> block = index2.
nodeData( n, req );
 
   56      const char *ptr = block->data();
 
   57      block->attributes().find( attribute.
name(), perNodeData.attributeOffset );
 
   58      const int size = block->pointRecordSize();
 
   59      for ( 
const int point : points )
 
   61        const int offset = point * size + perNodeData.attributeOffset;
 
   63        perNodeData.oldPointValues[point] = oldValue;
 
   70      perNodeData.firstEdit = 
true;
 
   71      for ( 
const int point : points )
 
   73        perNodeData.oldPointValues[point] = std::numeric_limits<double>::quiet_NaN();
 
   77    return std::pair { n, perNodeData };
 
   80  std::function reduceFn = []( QHash<QgsPointCloudNodeId, PerNodeData> &res, 
const std::pair<QgsPointCloudNodeId, PerNodeData> &pair )
 
   82    res[pair.first] = pair.second;
 
   85  mPerNodeData = QtConcurrent::blockingMappedReduced<QHash<QgsPointCloudNodeId, PerNodeData>>(
 
   86                   nodesAndPoints.keyValueBegin(), nodesAndPoints.keyValueEnd(),
 
   87                   std::move( mapFn ), std::move( reduceFn )
 
 
   93  undoRedoPrivate( 
true );
 
 
   98  undoRedoPrivate( 
false );
 
 
  101void QgsPointCloudLayerUndoCommandChangeAttribute::undoRedoPrivate( 
bool isUndo )
 
  103  QgsEventTracing::ScopedEvent _trace( QStringLiteral( 
"PointCloud" ), QStringLiteral( 
"QgsPointCloudLayerUndoCommand::undoRedoPrivate" ) );
 
  105  QgsCopcPointCloudIndex *copcIndex = 
dynamic_cast<QgsCopcPointCloudIndex *
>( editIndex->
backingIndex().
get() );
 
  108  QtConcurrent::blockingMap(
 
  109    mPerNodeData.keyValueBegin(),
 
  110    mPerNodeData.keyValueEnd(),
 
  111    [editIndex, copcIndex, isUndo, attribute = mAttribute, newValue = mNewValue](
 
  112      std::pair<const QgsPointCloudNodeId &, PerNodeData &> pair
 
  115    QgsPointCloudNodeId node = pair.first;
 
  116    PerNodeData &perNodeData = pair.second;
 
  118    QByteArray chunkData = editIndex->rawEditedNodeData( node );
 
  119    if ( chunkData.isEmpty() ) 
 
  120      chunkData = copcIndex->rawNodeData( node );
 
  123    if ( isUndo && perNodeData.firstEdit )
 
  125      editIndex->resetNodeEdits( node );
 
  140  for ( 
auto it = mPerNodeData.constBegin(); it != mPerNodeData.constEnd(); it++ )
 
  142    emit mLayer->chunkAttributeValuesChanged( it.key() );
 
A 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.
 
A QgsPointCloudIndex that is used as an editing buffer when editing point cloud data.
 
QgsPointCloudIndex backingIndex() const
Returns index for the underlying non-edited data.
 
bool isNodeModified(QgsPointCloudNodeId n) const
Returns true if this node was modified.
 
bool updateNodeData(const QHash< QgsPointCloudNodeId, QByteArray > &data) override
Tries to update the data for the specified nodes.
 
Smart pointer for QgsAbstractPointCloudIndex.
 
std::unique_ptr< QgsPointCloudBlock > nodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request)
Returns node data block.
 
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 QHash< QgsPointCloudNodeId, QVector< int > > &nodesAndPoints, 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.
 
Represents an 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.