jfjoch_viewer: add helper class for window in the viewer (to simplify tasks in the future)
This commit is contained in:
@@ -69,6 +69,8 @@ ADD_EXECUTABLE(jfjoch_viewer jfjoch_viewer.cpp JFJochViewerWindow.cpp JFJochView
|
||||
widgets/JFJochSimpleImageViewer.h
|
||||
windows/JFJochCalibrationWindow.cpp
|
||||
windows/JFJochCalibrationWindow.h
|
||||
windows/JFJochHelperWindow.cpp
|
||||
windows/JFJochHelperWindow.h
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(jfjoch_viewer Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Charts Qt6::DBus
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
JFJochCalibrationWindow::JFJochCalibrationWindow(QWidget *parent) : QMainWindow(parent) {
|
||||
JFJochCalibrationWindow::JFJochCalibrationWindow(QWidget *parent) : JFJochHelperWindow(parent) {
|
||||
QWidget *centralWidget = new QWidget(this);
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
@@ -60,17 +60,6 @@ JFJochCalibrationWindow::JFJochCalibrationWindow(QWidget *parent) : QMainWindow(
|
||||
statusBar, &QStatusBar::showMessage);
|
||||
}
|
||||
|
||||
void JFJochCalibrationWindow::closeEvent(QCloseEvent *event) {
|
||||
event->accept();
|
||||
emit closing();
|
||||
}
|
||||
|
||||
void JFJochCalibrationWindow::open() {
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void JFJochCalibrationWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset) {
|
||||
dataset = std::move(in_dataset);
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
#include <QString>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "JFJochHelperWindow.h"
|
||||
#include "../widgets/JFJochSimpleImageViewer.h"
|
||||
#include "../../reader/JFJochReaderDataset.h"
|
||||
#include "../SimpleImage.h"
|
||||
#include "../widgets/SliderPlusBox.h"
|
||||
|
||||
class JFJochCalibrationWindow : public QMainWindow {
|
||||
class JFJochCalibrationWindow : public JFJochHelperWindow {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
QComboBox *calibration_option;
|
||||
QComboBox *color_map_select;
|
||||
SliderPlusBox *foreground_slider;
|
||||
@@ -28,21 +28,17 @@ class JFJochCalibrationWindow : public QMainWindow {
|
||||
|
||||
JFJochSimpleImageViewer *viewer = nullptr;
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
public:
|
||||
JFJochCalibrationWindow(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void closing();
|
||||
void loadCalibration(QString name);
|
||||
|
||||
private slots:
|
||||
void LoadMask();
|
||||
void CalibrationSelected(int val);
|
||||
public slots:
|
||||
void open();
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset);
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset) override;
|
||||
void calibrationLoaded(std::shared_ptr<const SimpleImage> image);
|
||||
void setFeatureColor(QColor input);
|
||||
};
|
||||
|
||||
22
viewer/windows/JFJochHelperWindow.cpp
Normal file
22
viewer/windows/JFJochHelperWindow.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "JFJochHelperWindow.h"
|
||||
#include <QCloseEvent>
|
||||
|
||||
void JFJochHelperWindow::closeEvent(QCloseEvent *event) {
|
||||
event->accept();
|
||||
emit closing();
|
||||
}
|
||||
|
||||
void JFJochHelperWindow::open() {
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
JFJochHelperWindow::JFJochHelperWindow(QWidget *parent) : QMainWindow(parent) {}
|
||||
|
||||
void JFJochHelperWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset) {}
|
||||
|
||||
void JFJochHelperWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage> image) {}
|
||||
28
viewer/windows/JFJochHelperWindow.h
Normal file
28
viewer/windows/JFJochHelperWindow.h
Normal file
@@ -0,0 +1,28 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#ifndef JFJOCH_JFJOCHHELPERWINDOW_H
|
||||
#define JFJOCH_JFJOCHHELPERWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "../../reader/JFJochReaderDataset.h"
|
||||
#include "../../reader/JFJochReaderImage.h"
|
||||
|
||||
class JFJochHelperWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void closing();
|
||||
|
||||
public slots:
|
||||
void open();
|
||||
virtual void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset);
|
||||
virtual void imageLoaded(std::shared_ptr<const JFJochReaderImage> image);
|
||||
public:
|
||||
JFJochHelperWindow(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
|
||||
#endif //JFJOCH_JFJOCHHELPERWINDOW_H
|
||||
@@ -150,17 +150,6 @@ void JFJochViewerImageListWindow::imageLoaded(std::shared_ptr<const JFJochReader
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochViewerImageListWindow::closeEvent(QCloseEvent *event) {
|
||||
event->accept();
|
||||
emit closing();
|
||||
}
|
||||
|
||||
void JFJochViewerImageListWindow::open() {
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void JFJochViewerImageListWindow::onTableRowDoubleClicked(const QModelIndex &index) {
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
#include <QTableView>
|
||||
#include <QStandardItemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "JFJochHelperWindow.h"
|
||||
#include "../../reader/JFJochReader.h"
|
||||
|
||||
class JFJochViewerImageListWindow : public QMainWindow {
|
||||
class JFJochViewerImageListWindow : public JFJochHelperWindow {
|
||||
Q_OBJECT
|
||||
|
||||
QTableView *tableView;
|
||||
@@ -23,18 +25,15 @@ class JFJochViewerImageListWindow : public QMainWindow {
|
||||
double resolutionEstimate, int64_t max_value);
|
||||
|
||||
void clearAllData();
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
public:
|
||||
explicit JFJochViewerImageListWindow(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void closing();
|
||||
void imageSelected(int64_t image_number, int64_t summation);
|
||||
|
||||
public slots:
|
||||
void open();
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset);
|
||||
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image);
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) override;
|
||||
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image) override;
|
||||
private slots:
|
||||
void onTableRowDoubleClicked(const QModelIndex &index);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "JFJochViewerMetadataWindow.h"
|
||||
|
||||
JFJochViewerMetadataWindow::JFJochViewerMetadataWindow(QWidget *parent) : QMainWindow(parent) {
|
||||
JFJochViewerMetadataWindow::JFJochViewerMetadataWindow(QWidget *parent) : JFJochHelperWindow(parent) {
|
||||
|
||||
setWindowTitle("Dataset metadata");
|
||||
|
||||
@@ -127,12 +127,6 @@ JFJochViewerMetadataWindow::JFJochViewerMetadataWindow(QWidget *parent) : QMainW
|
||||
mainLayout->addWidget(updateButton);
|
||||
}
|
||||
|
||||
void JFJochViewerMetadataWindow::open() {
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void JFJochViewerMetadataWindow::datasetUpdate() {
|
||||
if (dataset) {
|
||||
try {
|
||||
@@ -237,11 +231,6 @@ void JFJochViewerMetadataWindow::updateSpaceGroupName() {
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochViewerMetadataWindow::closeEvent(QCloseEvent *event) {
|
||||
event->accept();
|
||||
emit closing();
|
||||
}
|
||||
|
||||
void JFJochViewerMetadataWindow::toggleUnitCellFields(bool enabled) {
|
||||
unit_cell_a->setEnabled(enabled);
|
||||
unit_cell_b->setEnabled(enabled);
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
#ifndef JFJOCH_JFJOCHVIEWERMETADATAWINDOW_H
|
||||
#define JFJOCH_JFJOCHVIEWERMETADATAWINDOW_H
|
||||
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "JFJochHelperWindow.h"
|
||||
#include "../widgets/NumberLineEdit.h"
|
||||
#include "../../reader/JFJochReader.h"
|
||||
|
||||
class JFJochViewerMetadataWindow : public QMainWindow {
|
||||
class JFJochViewerMetadataWindow : public JFJochHelperWindow {
|
||||
Q_OBJECT
|
||||
std::shared_ptr<const JFJochReaderDataset> dataset;
|
||||
|
||||
@@ -40,21 +39,18 @@ Q_OBJECT
|
||||
|
||||
void updateSpaceGroupName();
|
||||
void toggleUnitCellFields(bool enabled);
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
public:
|
||||
explicit JFJochViewerMetadataWindow(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void datasetUpdated(const DiffractionExperiment& experiment);
|
||||
void closing();
|
||||
|
||||
private slots:
|
||||
void datasetUpdate();
|
||||
|
||||
public slots:
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset);
|
||||
void open();
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <QCloseEvent>
|
||||
|
||||
JFJochViewerProcessingWindow::JFJochViewerProcessingWindow(const SpotFindingSettings &settings, const IndexingSettings& indexing,QWidget *parent)
|
||||
: QMainWindow(parent), m_settings(settings), m_indexing(indexing) {
|
||||
: JFJochHelperWindow(parent), m_settings(settings), m_indexing(indexing) {
|
||||
|
||||
setWindowTitle("Processing settings");
|
||||
|
||||
@@ -238,14 +238,3 @@ void JFJochViewerProcessingWindow::Update() {
|
||||
const auto max_spots = std::lround(m_maxSpotCount->value());
|
||||
emit settingsChanged(m_settings, m_indexing, max_spots, m_reanalyzeCheckBox->isChecked());
|
||||
}
|
||||
|
||||
void JFJochViewerProcessingWindow::open() {
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void JFJochViewerProcessingWindow::closeEvent(QCloseEvent *event) {
|
||||
event->accept();
|
||||
emit closing();
|
||||
}
|
||||
@@ -9,11 +9,12 @@
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "JFJochHelperWindow.h"
|
||||
#include "../common/IndexingSettings.h"
|
||||
#include "../widgets/SliderPlusBox.h"
|
||||
#include "../../image_analysis/spot_finding/SpotFindingSettings.h"
|
||||
|
||||
class JFJochViewerProcessingWindow : public QMainWindow {
|
||||
class JFJochViewerProcessingWindow : public JFJochHelperWindow {
|
||||
Q_OBJECT
|
||||
|
||||
QCheckBox *m_enableCheckBox;
|
||||
@@ -45,17 +46,12 @@ class JFJochViewerProcessingWindow : public QMainWindow {
|
||||
IndexingSettings m_indexing;
|
||||
|
||||
void Update();
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
public:
|
||||
explicit JFJochViewerProcessingWindow(const SpotFindingSettings &settings, const IndexingSettings& indexing,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void open();
|
||||
|
||||
signals:
|
||||
void settingsChanged(const SpotFindingSettings &settings, const IndexingSettings &indexing, int64_t max_spots, bool reanalyze);
|
||||
void closing();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -91,13 +91,6 @@ void JFJochViewerReflectionListWindow::addReflectionRow(int index, const Reflect
|
||||
tableModel->appendRow(row);
|
||||
}
|
||||
|
||||
|
||||
void JFJochViewerReflectionListWindow::open() {
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void JFJochViewerReflectionListWindow::onTableRowDoubleClicked(const QModelIndex& index) {
|
||||
if (!index.isValid())
|
||||
return;
|
||||
@@ -112,12 +105,6 @@ void JFJochViewerReflectionListWindow::onTableRowDoubleClicked(const QModelIndex
|
||||
image->ImageData().reflections[reflIndex].predicted_y);
|
||||
}
|
||||
|
||||
void JFJochViewerReflectionListWindow::closeEvent(QCloseEvent* event) {
|
||||
event->accept();
|
||||
emit closing();
|
||||
}
|
||||
|
||||
|
||||
void JFJochViewerReflectionListWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) {
|
||||
image = {};
|
||||
tableModel->removeRows(0, tableModel->rowCount());
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#ifndef JFJOCH_JFJOCHVIEWERREFLECTIONLISTWINDOW_H
|
||||
#define JFJOCH_JFJOCHVIEWERREFLECTIONLISTWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "JFJochHelperWindow.h"
|
||||
#include <QTableView>
|
||||
#include <QStandardItemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QCloseEvent>
|
||||
#include <vector>
|
||||
|
||||
#include "../../common/Reflection.h"
|
||||
#include "../../reader/JFJochReaderImage.h"
|
||||
|
||||
class JFJochViewerReflectionListWindow : public QMainWindow {
|
||||
class JFJochViewerReflectionListWindow : public JFJochHelperWindow {
|
||||
Q_OBJECT
|
||||
|
||||
std::shared_ptr<const JFJochReaderImage> image;
|
||||
@@ -22,8 +22,6 @@ class JFJochViewerReflectionListWindow : public QMainWindow {
|
||||
void setupTableModel();
|
||||
void addReflectionRow(int index, const Reflection& r);
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
QTableView* tableView = nullptr;
|
||||
QStandardItemModel* tableModel = nullptr;
|
||||
QSortFilterProxyModel* proxyModel = nullptr;
|
||||
@@ -33,15 +31,13 @@ public:
|
||||
|
||||
signals:
|
||||
void reflectionSelected(float x, float y);
|
||||
void closing();
|
||||
|
||||
private slots:
|
||||
void onTableRowDoubleClicked(const QModelIndex& index);
|
||||
|
||||
public slots:
|
||||
void open();
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset);
|
||||
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image);
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) override;
|
||||
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <QHeaderView>
|
||||
|
||||
JFJochViewerSpotListWindow::JFJochViewerSpotListWindow(QWidget* parent)
|
||||
: QMainWindow(parent) {
|
||||
: JFJochHelperWindow(parent) {
|
||||
QWidget* centralWidget = new QWidget(this);
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
@@ -125,12 +125,6 @@ void JFJochViewerSpotListWindow::imageLoaded(std::shared_ptr<const JFJochReaderI
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochViewerSpotListWindow::open() {
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void JFJochViewerSpotListWindow::onTableRowDoubleClicked(const QModelIndex& index) {
|
||||
if (!index.isValid())
|
||||
return;
|
||||
@@ -144,7 +138,3 @@ void JFJochViewerSpotListWindow::onTableRowDoubleClicked(const QModelIndex& inde
|
||||
emit spotSelected(image->ImageData().spots[spotIndex].x, image->ImageData().spots[spotIndex].y);
|
||||
}
|
||||
|
||||
void JFJochViewerSpotListWindow::closeEvent(QCloseEvent* event) {
|
||||
event->accept();
|
||||
emit closing();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#ifndef JFJOCH_JFJOCHVIEWERSPOTLISTWINDOW_H
|
||||
#define JFJOCH_JFJOCHVIEWERSPOTLISTWINDOW_H
|
||||
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "JFJochHelperWindow.h"
|
||||
#include <QTableView>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
@@ -15,7 +14,7 @@
|
||||
#include "../../reader/JFJochReaderImage.h"
|
||||
#include "../../common/JFJochMessages.h"
|
||||
|
||||
class JFJochViewerSpotListWindow : public QMainWindow {
|
||||
class JFJochViewerSpotListWindow : public JFJochHelperWindow {
|
||||
Q_OBJECT
|
||||
|
||||
std::shared_ptr<const JFJochReaderImage> image;
|
||||
@@ -23,8 +22,6 @@ class JFJochViewerSpotListWindow : public QMainWindow {
|
||||
void setupTableModel();
|
||||
void addSpotRow(int index, const SpotToSave& s);
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
QTableView* tableView = nullptr;
|
||||
QStandardItemModel* tableModel = nullptr;
|
||||
QSortFilterProxyModel* proxyModel = nullptr;
|
||||
@@ -33,16 +30,14 @@ public:
|
||||
explicit JFJochViewerSpotListWindow(QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void closing();
|
||||
void spotSelected(double x, double y);
|
||||
|
||||
private slots:
|
||||
void onTableRowDoubleClicked(const QModelIndex& index);
|
||||
|
||||
public slots:
|
||||
void open();
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset);
|
||||
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image);
|
||||
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) override;
|
||||
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user