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
@@ -14,15 +14,14 @@
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QInputDialog>
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
|
||||
JFJochViewerROIList::JFJochViewerROIList(QWidget *parent) : QWidget(parent) {
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
|
||||
combo_ = new QComboBox(this);
|
||||
combo_ = new LiveComboBox(this);
|
||||
layout->addWidget(combo_);
|
||||
connect(combo_, &QComboBox::currentIndexChanged, this, &JFJochViewerROIList::OnSelectionChanged);
|
||||
connect(combo_, &LiveComboBox::itemsReplaced, this, &JFJochViewerROIList::OnSelectionChanged);
|
||||
|
||||
auto *buttons = new QHBoxLayout();
|
||||
type_combo_ = new QComboBox(this);
|
||||
@@ -154,22 +153,21 @@ void JFJochViewerROIList::loadImage(std::shared_ptr<const JFJochReaderImage> ima
|
||||
|
||||
void JFJochViewerROIList::RebuildCombo(const QString &keep_selected) {
|
||||
rebuilding_ = true;
|
||||
combo_->clear();
|
||||
|
||||
// Running index across boxes/circles/azimuthal - matches the enumeration order used by the
|
||||
// image overlay, so each item's swatch colour equals its annotation colour on the image.
|
||||
int color_index = 0;
|
||||
// Called on every image of a live acquisition; the combo only changes when the list does.
|
||||
QVector<LiveComboBox::Item> items;
|
||||
auto add_item = [&](const std::string &name, const char *type) {
|
||||
// display "name · type", with the bare name kept as item data for lookups
|
||||
QPixmap swatch(14, 14);
|
||||
swatch.fill(ROIAnnotationColor(color_index++));
|
||||
combo_->addItem(QIcon(swatch),
|
||||
QString("%1 · %2").arg(QString::fromStdString(name), type),
|
||||
QString::fromStdString(name));
|
||||
items.push_back({QString("%1 · %2").arg(QString::fromStdString(name), type),
|
||||
QString::fromStdString(name), QString(),
|
||||
ROIAnnotationColor(static_cast<int>(items.size()))});
|
||||
};
|
||||
for (const auto &b : rois_.boxes) add_item(b.GetName(), "box");
|
||||
for (const auto &c : rois_.circles) add_item(c.GetName(), "circle");
|
||||
for (const auto &a : rois_.azimuthal) add_item(a.GetName(), "azim");
|
||||
combo_->SetItems(items);
|
||||
|
||||
if (!keep_selected.isEmpty()) {
|
||||
const int idx = combo_->findData(keep_selected);
|
||||
|
||||
Reference in new issue
Block a user