jfjoch_viewer: live updates no longer rebuild open combo boxes
During a collection every dataset tick ran JFJochViewerDatasetInfo::UpdateLabels(), which clear()ed the plot-type combo and re-added every item, so an open dropdown lost its hovered row and scroll position on each tick and picking a plot type was a race against the next update. The same clear-and-refill ran per tick or per image in the calibration window's calibration combo, the ROI list combo and the powder calibrant combo; the last two also threw away the user's choice (the calibrant was reset to the first entry on every image). New LiveComboBox::SetItems() takes the full item list and leaves the combo untouched when the list is unchanged. When it does change while the popup is open, the change is held back and applied (queued) once the popup window hides, so a click that closes the popup lands first. A replacement keeps the selection by item data, blocks signals, and a held-back one emits itemsReplaced() so the owner can re-plot. The calibration window now re-shows the selected calibration on a dataset tick instead of always reloading the pixel mask over it. Tested offscreen: a timer fires datasetLoaded() every 25 ms while the dropdown is open; the popup and hovered row survive, newly available indexing metrics are held back until the popup closes, and the picked type sticks and is what the chart plots. The rc175 code fails the hover checks of the same harness. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
83b1d85400
commit
9cf987cd4e
11 files changed
+204
-72
No files matched your search
@@ -17,7 +17,7 @@ JFJochCalibrationWindow::JFJochCalibrationWindow(QWidget *parent) : JFJochHelper
|
||||
|
||||
viewer = new JFJochSimpleImage(this);
|
||||
|
||||
calibration_option = new QComboBox(this);
|
||||
calibration_option = new LiveComboBox(this);
|
||||
color_map_select = new QComboBox(this);
|
||||
|
||||
color_map_select->addItem("Viridis", static_cast<int>(ColorScaleEnum::Viridis));
|
||||
@@ -61,6 +61,9 @@ JFJochCalibrationWindow::JFJochCalibrationWindow(QWidget *parent) : JFJochHelper
|
||||
});
|
||||
|
||||
connect(calibration_option, &QComboBox::currentIndexChanged, this, &JFJochCalibrationWindow::CalibrationSelected);
|
||||
connect(calibration_option, &LiveComboBox::itemsReplaced, this, [this] {
|
||||
CalibrationSelected(calibration_option->currentIndex());
|
||||
});
|
||||
centralWidget->setLayout(grid_layout);
|
||||
|
||||
statusBar = new QStatusBar(this);
|
||||
@@ -73,13 +76,15 @@ JFJochCalibrationWindow::JFJochCalibrationWindow(QWidget *parent) : JFJochHelper
|
||||
void JFJochCalibrationWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset) {
|
||||
dataset = std::move(in_dataset);
|
||||
|
||||
QSignalBlocker b(calibration_option);
|
||||
calibration_option->clear();
|
||||
// Arrives on every dataset tick of a live acquisition; the combo only changes when the list
|
||||
// does, and keeps the selection by name.
|
||||
QVector<LiveComboBox::Item> items;
|
||||
if (dataset) {
|
||||
calibration_option->addItem("Pixel mask");
|
||||
items.push_back({"Pixel mask", "Pixel mask"});
|
||||
for (auto &calibration : dataset->calibration_data)
|
||||
calibration_option->addItem(calibration.c_str());
|
||||
items.push_back({calibration.c_str(), calibration.c_str()});
|
||||
}
|
||||
calibration_option->SetItems(items);
|
||||
|
||||
// Rebuilding the mask is a full-detector copy plus a full-resolution recolour on the GUI
|
||||
// thread, and this arrives on every dataset tick when following a live acquisition. Do not pay
|
||||
@@ -88,14 +93,14 @@ void JFJochCalibrationWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDa
|
||||
pending_mask_reload = true;
|
||||
return;
|
||||
}
|
||||
LoadMask();
|
||||
CalibrationSelected(calibration_option->currentIndex()); // the user's pick, not always the mask
|
||||
}
|
||||
|
||||
void JFJochCalibrationWindow::showEvent(QShowEvent *event) {
|
||||
JFJochHelperWindow::showEvent(event);
|
||||
if (pending_mask_reload) {
|
||||
pending_mask_reload = false;
|
||||
LoadMask();
|
||||
CalibrationSelected(calibration_option->currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +121,7 @@ void JFJochCalibrationWindow::LoadMask() {
|
||||
}
|
||||
|
||||
void JFJochCalibrationWindow::CalibrationSelected(int val) {
|
||||
if (val == 0)
|
||||
if (val <= 0)
|
||||
LoadMask();
|
||||
else
|
||||
emit loadCalibration(calibration_option->itemText(val));
|
||||
|
||||
Reference in new issue
Block a user