jfjoch_viewer: More dataset info docks possible
This commit is contained in:
1 parent
dde45612d2
commit
9117056e30
4 files changed
+68
-45
No files matched your search
@@ -13,6 +13,7 @@
|
||||
#include <QSpinBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
#include "JFJochViewerWindow.h"
|
||||
#include "../common/GitInfo.h"
|
||||
|
||||
JFJochViewerMenu::JFJochViewerMenu(QWidget *parent) : QMenuBar(parent) {
|
||||
@@ -47,6 +48,10 @@ JFJochViewerMenu::JFJochViewerMenu(QWidget *parent) : QMenuBar(parent) {
|
||||
|
||||
windowMenu = addMenu("Window");
|
||||
|
||||
QMenu *dockMenu = addMenu("Dock");
|
||||
const QAction *dockCalibration = dockMenu->addAction("Dataset info");
|
||||
connect(dockCalibration, &QAction::triggered, [this] { emit openDatasetInfo();});
|
||||
|
||||
QMenu *helpMenu = addMenu("Help");
|
||||
// Add "About" action
|
||||
const QAction *aboutAction = helpMenu->addAction("About");
|
||||
|
||||
@@ -31,7 +31,7 @@ signals:
|
||||
void saveUserMaskTiffSelected(const QString &filename);
|
||||
void uploadUserMaskSelected();
|
||||
void clearUserMaskSelected();
|
||||
|
||||
void openDatasetInfo();
|
||||
|
||||
private slots:
|
||||
void aboutSelected();
|
||||
|
||||
@@ -32,10 +32,10 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
|
||||
addToolBar(Qt::TopToolBarArea, toolBarImage);
|
||||
addToolBarBreak(Qt::TopToolBarArea);
|
||||
|
||||
auto toolBarDisplay = new JFJochViewerToolbarDisplay(this);
|
||||
toolBarDisplay = new JFJochViewerToolbarDisplay(this);
|
||||
addToolBar(Qt::TopToolBarArea, toolBarDisplay);
|
||||
|
||||
auto statusbar = new JFJochViewerStatusBar(this);
|
||||
statusbar = new JFJochViewerStatusBar(this);
|
||||
setStatusBar(statusbar);
|
||||
|
||||
setStyleSheet(stylesheet);
|
||||
@@ -81,32 +81,6 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
|
||||
|
||||
h_splitter->addWidget(side_panel_scroll);
|
||||
|
||||
dataset_info = new JFJochViewerDatasetInfo(this);
|
||||
// Put dataset info into a bottom dock
|
||||
auto datasetDock = new QDockWidget("Dataset info", this);
|
||||
datasetDock->setAllowedAreas(Qt::BottomDockWidgetArea);
|
||||
datasetDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
||||
datasetDock->setWidget(dataset_info);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, datasetDock);
|
||||
|
||||
// When docked: fixed height 200. When floating: free size.
|
||||
// Initial state is docked.
|
||||
dataset_info->setMinimumHeight(200);
|
||||
dataset_info->setMaximumHeight(200);
|
||||
dataset_info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
connect(datasetDock, &QDockWidget::topLevelChanged, this, [this](bool floating) {
|
||||
if (floating) {
|
||||
dataset_info->setMinimumHeight(0);
|
||||
dataset_info->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
dataset_info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
} else {
|
||||
dataset_info->setMinimumHeight(200);
|
||||
dataset_info->setMaximumHeight(200);
|
||||
dataset_info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
}
|
||||
dataset_info->updateGeometry();
|
||||
});
|
||||
|
||||
reading_worker = new JFJochImageReadingWorker(spot_finding_settings, experiment);
|
||||
reading_thread = new QThread(this);
|
||||
reading_worker->moveToThread(reading_thread);
|
||||
@@ -185,9 +159,6 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
|
||||
connect(toolBarDisplay, &JFJochViewerToolbarDisplay::colorMapChanged, azintImageWindow,
|
||||
&JFJoch2DAzintImageWindow::setColorMap);
|
||||
|
||||
connect(toolBarDisplay, &JFJochViewerToolbarDisplay::colorMapChanged, dataset_info,
|
||||
&JFJochViewerDatasetInfo::setColorMap);
|
||||
|
||||
connect(reading_worker, &JFJochImageReadingWorker::imageLoaded,
|
||||
azintImageWindow, &JFJoch2DAzintImageWindow::imageLoaded);
|
||||
|
||||
@@ -236,15 +207,6 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
|
||||
connect(menuBar, &JFJochViewerMenu::uploadUserMaskSelected,
|
||||
reading_worker, &JFJochImageReadingWorker::UploadUserMask);
|
||||
|
||||
connect(reading_worker, &JFJochImageReadingWorker::datasetLoaded,
|
||||
dataset_info, &JFJochViewerDatasetInfo::datasetLoaded);
|
||||
|
||||
connect(reading_worker, &JFJochImageReadingWorker::imageLoaded,
|
||||
dataset_info, &JFJochViewerDatasetInfo::imageLoaded);
|
||||
|
||||
connect(dataset_info, &JFJochViewerDatasetInfo::imageSelected,
|
||||
reading_worker, &JFJochImageReadingWorker::LoadImage);
|
||||
|
||||
connect(reading_worker, &JFJochImageReadingWorker::datasetLoaded,
|
||||
tableWindow, &JFJochViewerImageListWindow::datasetLoaded);
|
||||
|
||||
@@ -338,12 +300,17 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
|
||||
connect(azintImageWindow, &JFJoch2DAzintImageWindow::zoomOnBin,
|
||||
viewer, &JFJochDiffractionImage::centerOnSpot);
|
||||
|
||||
connect(dataset_info, &JFJochViewerDatasetInfo::writeStatusBar,
|
||||
statusbar, &JFJochViewerStatusBar::display);
|
||||
|
||||
// Ensure worker is deleted in its own thread when the thread stops
|
||||
connect(reading_thread, &QThread::finished, reading_worker, &QObject::deleteLater);
|
||||
|
||||
connect(reading_worker, &JFJochImageReadingWorker::datasetLoaded, this,
|
||||
[this](std::shared_ptr<const JFJochReaderDataset> ds) { lastDataset = std::move(ds); });
|
||||
connect(reading_worker, &JFJochImageReadingWorker::imageLoaded, this,
|
||||
[this](std::shared_ptr<const JFJochReaderImage> im) { lastImage = std::move(im); });
|
||||
|
||||
connect(menuBar, &JFJochViewerMenu::openDatasetInfo, this, &JFJochViewerWindow::NewDatasetInfo);
|
||||
NewDatasetInfo();
|
||||
|
||||
if (!file.isEmpty())
|
||||
LoadFile(file, 0, 1);
|
||||
}
|
||||
@@ -362,3 +329,47 @@ void JFJochViewerWindow::LoadFile(const QString &filename, qint64 image_number,
|
||||
void JFJochViewerWindow::LoadImage(qint64 image_number, qint64 summation) {
|
||||
emit LoadImageRequest(image_number, summation);
|
||||
}
|
||||
|
||||
|
||||
void JFJochViewerWindow::NewDatasetInfo() {
|
||||
auto info = new JFJochViewerDatasetInfo(this);
|
||||
info->datasetLoaded(lastDataset);
|
||||
info->imageLoaded(lastImage);
|
||||
|
||||
auto dock = new QDockWidget(QString("Dataset info"), this);
|
||||
dock->setAllowedAreas(Qt::BottomDockWidgetArea);
|
||||
dock->setFeatures(
|
||||
QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable);
|
||||
dock->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dock->setWidget(info);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
||||
|
||||
// Docked vs floating sizing behavior, same as the initial widget
|
||||
info->setMinimumHeight(200);
|
||||
info->setMaximumHeight(200);
|
||||
info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
connect(dock, &QDockWidget::topLevelChanged, this, [info](bool floating) {
|
||||
if (floating) {
|
||||
info->setMinimumHeight(0);
|
||||
info->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
} else {
|
||||
info->setMinimumHeight(200);
|
||||
info->setMaximumHeight(200);
|
||||
info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
}
|
||||
info->updateGeometry();
|
||||
});
|
||||
|
||||
// Wire signals like the initial dataset_info
|
||||
connect(reading_worker, &JFJochImageReadingWorker::datasetLoaded,
|
||||
info, &JFJochViewerDatasetInfo::datasetLoaded);
|
||||
connect(reading_worker, &JFJochImageReadingWorker::imageLoaded,
|
||||
info, &JFJochViewerDatasetInfo::imageLoaded);
|
||||
connect(info, &JFJochViewerDatasetInfo::imageSelected,
|
||||
reading_worker, &JFJochImageReadingWorker::LoadImage);
|
||||
connect(toolBarDisplay, &JFJochViewerToolbarDisplay::colorMapChanged,
|
||||
info, &JFJochViewerDatasetInfo::setColorMap);
|
||||
connect(info, &JFJochViewerDatasetInfo::writeStatusBar,
|
||||
statusbar, &JFJochViewerStatusBar::display);
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "../reader/JFJochHDF5Reader.h"
|
||||
#include "JFJochImageReadingWorker.h"
|
||||
#include "JFJochViewerDatasetInfo.h"
|
||||
#include "JFJochViewerStatusBar.h"
|
||||
#include "toolbar/JFJochViewerToolbarDisplay.h"
|
||||
|
||||
class JFJochViewerWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
@@ -21,14 +23,19 @@ public:
|
||||
|
||||
private:
|
||||
JFJochViewerMenu *menuBar;
|
||||
JFJochViewerDatasetInfo *dataset_info;
|
||||
JFJochImageReadingWorker *reading_worker;
|
||||
JFJochViewerToolbarDisplay *toolBarDisplay;
|
||||
JFJochViewerStatusBar *statusbar;
|
||||
|
||||
std::shared_ptr<const JFJochReaderDataset> lastDataset; // added
|
||||
std::shared_ptr<const JFJochReaderImage> lastImage; // added
|
||||
|
||||
QThread *reading_thread;
|
||||
|
||||
public slots:
|
||||
void LoadFile(const QString &filename, qint64 image_number, qint64 summation);
|
||||
void LoadImage(qint64 image_number, qint64 summation);
|
||||
void NewDatasetInfo();
|
||||
|
||||
signals:
|
||||
void LoadFileRequest(const QString &filename, qint64 image_number, qint64 summation);
|
||||
|
||||
Reference in new issue
Block a user