viewer: remove the dead scratch-ROI widgets and worker methods
With the scratch ROI panel gone, delete the now-orphaned JFJochViewerImageROIStatistics(_Box/_Circle) widgets and the worker's unused scratch-ROI plumbing (SetROIBox/SetROICircle, the ROIElement member, AddROIToUserMask/SubtractROIFromUserMask). ROI-to-mask, if wanted later, should act on the selected list ROI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -64,12 +64,6 @@ ADD_EXECUTABLE(jfjoch_viewer jfjoch_viewer.cpp JFJochViewerWindow.cpp JFJochView
|
||||
image_viewer/JFJochAzIntImage.h
|
||||
windows/JFJochViewerReflectionListWindow.cpp
|
||||
windows/JFJochViewerReflectionListWindow.h
|
||||
widgets/JFJochViewerImageROIStatistics.cpp
|
||||
widgets/JFJochViewerImageROIStatistics.h
|
||||
widgets/JFJochViewerImageROIStatistics_Box.cpp
|
||||
widgets/JFJochViewerImageROIStatistics_Box.h
|
||||
widgets/JFJochViewerImageROIStatistics_Circle.cpp
|
||||
widgets/JFJochViewerImageROIStatistics_Circle.h
|
||||
toolbar/JFJochViewerToolbarImage.cpp
|
||||
toolbar/JFJochViewerToolbarImage.h
|
||||
toolbar/JFJochViewerToolbarDisplay.cpp
|
||||
|
||||
@@ -432,24 +432,6 @@ void JFJochImageReadingWorker::LoadImage_i(int64_t image_number, int64_t summati
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochImageReadingWorker::SetROIBox(QRect box) {
|
||||
QMutexLocker ul(&m);
|
||||
|
||||
if (box.width() * box.height() == 0)
|
||||
roi.reset();
|
||||
|
||||
roi = std::make_unique<ROIBox>("roi1", box.left(), box.right(), box.bottom(), box.top());
|
||||
}
|
||||
|
||||
void JFJochImageReadingWorker::SetROICircle(double x, double y, double radius) {
|
||||
QMutexLocker ul(&m);
|
||||
|
||||
if (radius <= 0)
|
||||
roi.reset();
|
||||
else
|
||||
roi = std::make_unique<ROICircle>("roi1", x, y, radius);
|
||||
}
|
||||
|
||||
void JFJochImageReadingWorker::UpdateDataset_i(const std::optional<DiffractionExperiment> &experiment) {
|
||||
if (!current_image_ptr)
|
||||
return;
|
||||
@@ -690,47 +672,6 @@ void JFJochImageReadingWorker::UpdateUserMask_i(const std::vector<uint32_t> &mas
|
||||
}
|
||||
|
||||
|
||||
void JFJochImageReadingWorker::AddROIToUserMask() {
|
||||
QMutexLocker locker(&m);
|
||||
|
||||
if (!roi || !current_image_ptr)
|
||||
return;
|
||||
|
||||
auto user_mask = current_image_ptr->Dataset().pixel_mask.GetUserMask();
|
||||
|
||||
int64_t width = current_image_ptr->Dataset().experiment.GetXPixelsNum();
|
||||
int64_t height = current_image_ptr->Dataset().experiment.GetYPixelsNum();
|
||||
const auto res = azint_mapping->Resolution();
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (roi->CheckROI(x, y, 0, 0))
|
||||
user_mask[x + y * width] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateUserMask_i(user_mask);
|
||||
}
|
||||
|
||||
void JFJochImageReadingWorker::SubtractROIFromUserMask() {
|
||||
QMutexLocker locker(&m);
|
||||
if (!roi || !current_image_ptr)
|
||||
return;
|
||||
|
||||
auto user_mask = current_image_ptr->Dataset().pixel_mask.GetUserMask();
|
||||
|
||||
int64_t width = current_image_ptr->Dataset().experiment.GetXPixelsNum();
|
||||
int64_t height = current_image_ptr->Dataset().experiment.GetYPixelsNum();
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (roi->CheckROI(x, y, 0, 0))
|
||||
user_mask[x + y * width] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateUserMask_i(user_mask);
|
||||
}
|
||||
|
||||
void JFJochImageReadingWorker::ClearUserMask() {
|
||||
QMutexLocker locker(&m);
|
||||
if (!current_image_ptr)
|
||||
|
||||
@@ -68,8 +68,6 @@ private:
|
||||
// Azimuthal profile buffer of the most recently analyzed image (filled by Analyze).
|
||||
std::unique_ptr<AzimuthalIntegrationProfile> last_profile_;
|
||||
|
||||
std::unique_ptr<ROIElement> roi;
|
||||
|
||||
SpotFindingSettings spot_finding_settings;
|
||||
|
||||
std::optional<int64_t> current_image;
|
||||
@@ -155,9 +153,6 @@ public slots:
|
||||
void LoadImage(int64_t image_number, int64_t summation);
|
||||
void LoadSpots(int64_t start_image, int64_t end_image, int64_t stride);
|
||||
|
||||
void SetROIBox(QRect box);
|
||||
void SetROICircle(double x, double y, double radius);
|
||||
|
||||
void UpdateDataset(const DiffractionExperiment& experiment);
|
||||
|
||||
void FindCenter(const UnitCell& calibrant, bool guess);
|
||||
@@ -167,8 +162,6 @@ public slots:
|
||||
void UpdateSpotFindingSettings(const SpotFindingSettings &settings, const IndexingSettings &indexing, int64_t max_spots);
|
||||
void ReanalyzeImages(bool input);
|
||||
void UpdateAzintSettings(const AzimuthalIntegrationSettings& settings);
|
||||
void AddROIToUserMask();
|
||||
void SubtractROIFromUserMask();
|
||||
|
||||
void SetROIDefinition(const ROIDefinition &rois);
|
||||
void DownloadROIsFromServer();
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "JFJochViewerSidePanel.h"
|
||||
|
||||
#include "widgets/JFJochViewerImageROIStatistics.h"
|
||||
#include "widgets/TitleLabel.h"
|
||||
#include "widgets/JFJochViewerImageStatistics.h"
|
||||
#include "widgets/PowderCalibrationWidget.h"
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "JFJochViewerImageROIStatistics.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
JFJochViewerImageROIStatistics::JFJochViewerImageROIStatistics(QWidget *parent)
|
||||
: QWidget(parent) {
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
|
||||
box_radio = new QRadioButton("Box", this);
|
||||
box_settings = new JFJochViewerImageROIStatistics_Box(this);
|
||||
QHBoxLayout *box_row = new QHBoxLayout();
|
||||
box_row->addWidget(box_radio);
|
||||
box_row->addWidget(box_settings);
|
||||
layout->addLayout(box_row);
|
||||
|
||||
circle_radio = new QRadioButton("Circle", this);
|
||||
circle_settings = new JFJochViewerImageROIStatistics_Circle(this);
|
||||
QHBoxLayout *circle_row = new QHBoxLayout();
|
||||
circle_row->addWidget(circle_radio);
|
||||
circle_row->addWidget(circle_settings);
|
||||
layout->addLayout(circle_row);
|
||||
|
||||
radio_group = new QButtonGroup(this);
|
||||
radio_group->addButton(box_radio, 1);
|
||||
radio_group->addButton(circle_radio, 2);
|
||||
|
||||
connect(box_radio, &QRadioButton::clicked, this, &JFJochViewerImageROIStatistics::BoxButtonClicked);
|
||||
connect(circle_radio, &QRadioButton::clicked, this, &JFJochViewerImageROIStatistics::CircleButtonClicked);
|
||||
connect(box_settings, &JFJochViewerImageROIStatistics_Box::Updated, this,
|
||||
&JFJochViewerImageROIStatistics::BoxButtonClicked);
|
||||
connect(circle_settings, &JFJochViewerImageROIStatistics_Circle::Updated, this,
|
||||
&JFJochViewerImageROIStatistics::CircleButtonClicked);
|
||||
|
||||
circle_settings->Disable();
|
||||
box_radio->setChecked(true);
|
||||
|
||||
roi_result = new JFJochViewerROIResult(this);
|
||||
layout->addWidget(roi_result);
|
||||
|
||||
QPushButton *add_button = new QPushButton("Add ROI to user mask", this);
|
||||
connect(add_button, &QPushButton::clicked, [this]() { emit AddROIToUserMask(); });
|
||||
|
||||
QPushButton *sub_button = new QPushButton("Subtract ROI from user mask", this);
|
||||
connect(sub_button, &QPushButton::clicked, [this]() { emit SubtractROIFromUserMask(); });
|
||||
|
||||
QHBoxLayout *buttons_row = new QHBoxLayout();
|
||||
buttons_row->setSpacing(12);
|
||||
buttons_row->addWidget(add_button);
|
||||
buttons_row->addWidget(sub_button);
|
||||
|
||||
layout->addLayout(buttons_row);
|
||||
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics::SetROIResult(ROIMessage roi) {
|
||||
roi_result->SetROIResult(roi);
|
||||
}
|
||||
|
||||
|
||||
void JFJochViewerImageROIStatistics::SetROIBox(QRect box) {
|
||||
box_radio->setChecked(true);
|
||||
box_settings->ROIBoxConfigured(box);
|
||||
circle_settings->Disable();
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics::SetROICircle(double x, double y, double radius) {
|
||||
circle_radio->setChecked(true);
|
||||
circle_settings->SetROICircle(CircleSettings{.x = x, .y = y, .r = radius});
|
||||
box_settings->Disable();
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics::BoxButtonClicked() {
|
||||
box_radio->setChecked(true);
|
||||
box_settings->Enable();
|
||||
circle_settings->Disable();
|
||||
|
||||
emit ROIBoxConfigured(box_settings->GetROIBox());
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics::CircleButtonClicked() {
|
||||
circle_settings->Enable();
|
||||
box_settings->Disable();
|
||||
circle_radio->setChecked(true);
|
||||
auto tmp = circle_settings->GetROICircle();
|
||||
emit ROICircleConfigured(tmp.x, tmp.y, tmp.r);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
#include <QRadioButton>
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include "../JFJochImageReadingWorker.h"
|
||||
#include "JFJochViewerImageROIStatistics_Box.h"
|
||||
#include "JFJochViewerImageROIStatistics_Circle.h"
|
||||
#include "JFJochViewerROIResult.h"
|
||||
#include "../../reader/JFJochReaderImage.h"
|
||||
|
||||
class JFJochViewerImageROIStatistics : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
QRadioButton *box_radio;
|
||||
QRadioButton *circle_radio;
|
||||
QRadioButton *azim_radio;
|
||||
QButtonGroup *radio_group;
|
||||
|
||||
JFJochViewerImageROIStatistics_Box *box_settings;
|
||||
JFJochViewerImageROIStatistics_Circle *circle_settings;
|
||||
|
||||
JFJochViewerROIResult *roi_result;
|
||||
|
||||
public:
|
||||
JFJochViewerImageROIStatistics(QWidget *parent);
|
||||
private slots:
|
||||
void BoxButtonClicked();
|
||||
void CircleButtonClicked();
|
||||
public slots:
|
||||
void SetROIBox(QRect box);
|
||||
void SetROICircle(double x, double y, double radius);
|
||||
void SetROIResult(ROIMessage msg);
|
||||
signals:
|
||||
void ROIBoxConfigured(QRect box); // Signal emitted when Box ROI is set
|
||||
void ROICircleConfigured(double center_x, double center_y, double radius); // Signal emitted when Circle ROI is set
|
||||
void AddROIToUserMask();
|
||||
void SubtractROIFromUserMask();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include "JFJochViewerImageROIStatistics_Box.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
JFJochViewerImageROIStatistics_Box::JFJochViewerImageROIStatistics_Box(QWidget *parent)
|
||||
: QWidget(parent) {
|
||||
auto layout = new QHBoxLayout(this);
|
||||
|
||||
setFixedWidth(300);
|
||||
layout->addWidget(new QLabel("x:"));
|
||||
|
||||
x0 = new NumberLineEdit(0, 10000, 0, 0, "", this);
|
||||
x0->setFixedWidth(50);
|
||||
layout->addWidget(x0);
|
||||
|
||||
layout->addWidget(new QLabel(" - "));
|
||||
|
||||
x1 = new NumberLineEdit(0, 10000, 0, 0, "", this);
|
||||
x1->setFixedWidth(50);
|
||||
layout->addWidget(x1);
|
||||
|
||||
layout->addWidget(new QLabel(" y:"));
|
||||
y0 = new NumberLineEdit(0, 10000, 0, 0, "", this);
|
||||
y0->setFixedWidth(50);
|
||||
layout->addWidget(y0);
|
||||
layout->addWidget(new QLabel(" - "));
|
||||
|
||||
y1 = new NumberLineEdit(0, 10000, 0, 0, "", this);
|
||||
y1->setFixedWidth(50);
|
||||
layout->addWidget(y1);
|
||||
|
||||
connect(x0, &NumberLineEdit::newValue, [this] (float) { emit Updated(); } );
|
||||
connect(y0, &NumberLineEdit::newValue, [this] (float) { emit Updated(); } );
|
||||
connect(x1, &NumberLineEdit::newValue, [this] (float) { emit Updated(); } );
|
||||
connect(y1, &NumberLineEdit::newValue, [this] (float) { emit Updated(); } );
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics_Box::ROIBoxConfigured(QRect box) {
|
||||
Enable();
|
||||
x0->setValue(box.left());
|
||||
x1->setValue(box.right());
|
||||
y0->setValue(box.top());
|
||||
y1->setValue(box.bottom());
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics_Box::Disable() {
|
||||
x0->setEnabled(false);
|
||||
x1->setEnabled(false);
|
||||
y0->setEnabled(false);
|
||||
y1->setEnabled(false);
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics_Box::Enable() {
|
||||
x0->setEnabled(true);
|
||||
x1->setEnabled(true);
|
||||
y0->setEnabled(true);
|
||||
y1->setEnabled(true);
|
||||
}
|
||||
|
||||
QRect JFJochViewerImageROIStatistics_Box::GetROIBox() {
|
||||
int64_t out_x0 = std::lround(x0->value());
|
||||
int64_t out_x1 = std::lround(x1->value());
|
||||
int64_t out_y0 = std::lround(y0->value());
|
||||
int64_t out_y1 = std::lround(y1->value());
|
||||
|
||||
return QRect(out_x0, out_y0, out_x1 - out_x0, out_y1 - out_y0).normalized();
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "NumberLineEdit.h"
|
||||
|
||||
class JFJochViewerImageROIStatistics_Box : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
NumberLineEdit *x0 = nullptr;
|
||||
NumberLineEdit *x1 = nullptr;
|
||||
NumberLineEdit *y0 = nullptr;
|
||||
NumberLineEdit *y1 = nullptr;
|
||||
|
||||
public:
|
||||
JFJochViewerImageROIStatistics_Box(QWidget *parent = nullptr);
|
||||
QRect GetROIBox();
|
||||
signals:
|
||||
void Updated(); // Signal emitted when Box ROI is set
|
||||
|
||||
public slots:
|
||||
void ROIBoxConfigured(QRect box); // Signal emitted when Box ROI is set
|
||||
void Disable();
|
||||
void Enable();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include "JFJochViewerImageROIStatistics_Circle.h"
|
||||
|
||||
JFJochViewerImageROIStatistics_Circle::JFJochViewerImageROIStatistics_Circle(QWidget *parent)
|
||||
:QWidget(parent) {
|
||||
auto layout = new QHBoxLayout(this);
|
||||
|
||||
setFixedWidth(300);
|
||||
|
||||
layout->addWidget(new QLabel("x: "));
|
||||
x = new NumberLineEdit(0, 10000, 0, 1, "", this);
|
||||
layout->addWidget(x);
|
||||
|
||||
layout->addWidget(new QLabel(" y: "));
|
||||
y = new NumberLineEdit(0, 10000, 0, 1, "", this);
|
||||
layout->addWidget(y);
|
||||
|
||||
|
||||
layout->addWidget(new QLabel(" r: "));
|
||||
r = new NumberLineEdit(0, 10000, 0, 1, "", this);
|
||||
layout->addWidget(r);
|
||||
|
||||
connect(x, &NumberLineEdit::newValue, [this] (float) {emit Updated();});
|
||||
connect(y, &NumberLineEdit::newValue, [this] (float) {emit Updated();});
|
||||
connect(r, &NumberLineEdit::newValue, [this] (float) {emit Updated();});
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics_Circle::SetROICircle(const CircleSettings& input) {
|
||||
Enable();
|
||||
x->setValue(input.x);
|
||||
y->setValue(input.y);
|
||||
r->setValue(input.r);
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics_Circle::Disable() {
|
||||
x->setEnabled(false);
|
||||
y->setEnabled(false);
|
||||
r->setEnabled(false);
|
||||
}
|
||||
|
||||
void JFJochViewerImageROIStatistics_Circle::Enable() {
|
||||
x->setEnabled(true);
|
||||
y->setEnabled(true);
|
||||
r->setEnabled(true);
|
||||
}
|
||||
|
||||
CircleSettings JFJochViewerImageROIStatistics_Circle::GetROICircle() {
|
||||
return CircleSettings{.x = x->value(), .y = y->value(), .r = r->value()};
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "NumberLineEdit.h"
|
||||
|
||||
struct CircleSettings {
|
||||
double x, y, r;
|
||||
};
|
||||
|
||||
class JFJochViewerImageROIStatistics_Circle : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
NumberLineEdit *x = nullptr;
|
||||
NumberLineEdit *y = nullptr;
|
||||
NumberLineEdit *r = nullptr;
|
||||
public:
|
||||
JFJochViewerImageROIStatistics_Circle(QWidget *parent = nullptr);
|
||||
void SetROICircle(const CircleSettings &input);
|
||||
CircleSettings GetROICircle();
|
||||
|
||||
void Disable();
|
||||
void Enable();
|
||||
signals:
|
||||
void Updated();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user