Skip to content

Commit 8121ed1

Browse files
Tom O'ReillyTom O'Reilly
authored andcommitted
added EditRecord type, restoreQualityBatch()
1 parent 036b397 commit 8121ed1

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

src/qt-guilib/TopoDataset.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,17 @@ void TopoDataset::gridBounds(double *xMin, double *xMax,
138138
*yMin = gridBounds_[2]; *yMax = gridBounds_[3];
139139
*zMin = gridBounds_[4]; *zMax = gridBounds_[5];
140140
}
141+
142+
// ─────────────────────────────────────────────────────────────────────────────
143+
// restoreQualityBatch — undo helper: restore multiple quality values at once
144+
// ─────────────────────────────────────────────────────────────────────────────
145+
146+
void TopoDataset::restoreQualityBatch(const EditRecord &rec) {
147+
if (!dataLoaded_ || rec.empty()) return;
148+
for (const auto &[id, q] : rec) {
149+
quality_->SetValue(id, q);
150+
}
151+
quality_->Modified();
152+
polyData()->Modified();
153+
emit qualityChanged();
154+
}

src/qt-guilib/TopoDataset.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <QObject>
55
#include <QString>
6+
#include <vector>
7+
#include <utility>
68
#include <vtkNew.h>
79
#include <vtkPolyData.h>
810
#include <vtkIntArray.h>
@@ -65,6 +67,16 @@ class TopoDataset : public QObject {
6567
/// response to the signal.
6668
void setPointQuality(vtkIdType originalId, int quality);
6769

70+
/// Type alias for undo records. Each entry is (originalPointId, oldQuality)
71+
/// captured before a quality-edit gesture in EditDataItem.
72+
using EditRecord = std::vector<std::pair<vtkIdType, int>>;
73+
74+
/// Restore a batch of (originalId, oldQuality) pairs in one operation and
75+
/// emit qualityChanged() once. Called by EditDataItem::undoLastEdit() on
76+
/// the VTK render thread; safe there for the same reason setPointQuality()
77+
/// is safe from the render thread.
78+
void restoreQualityBatch(const EditRecord &rec);
79+
6880
// ── Metadata accessors ────────────────────────────────────────────────────
6981

7082
double elevMin() const { return elevMin_; }
@@ -102,14 +114,8 @@ class TopoDataset : public QObject {
102114

103115
private:
104116
// Early pipeline stages — data, not rendering
105-
106-
/// Reads topo data
107117
vtkNew<TopoDataReader> reader_;
108-
109-
/// Keeps track of point IDs
110118
vtkNew<vtkIdFilter> idFilter_;
111-
112-
/// Generate scalar elevation values from the topo data
113119
vtkNew<vtkElevationFilter> elevFilter_;
114120

115121
/// Per-point quality flags; lives in polyData's PointData as DATA_QUALITY_NAME

0 commit comments

Comments
 (0)