Mantid
Loading...
Searching...
No Matches
ImageInfoPresenter.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7
11
12#include <QTableWidget>
13
15
17
22ImageInfoPresenter::ImageInfoPresenter(IImageInfoWidget *view) : m_model(), m_view(view), m_showSignal(true) {
24}
25
32void ImageInfoPresenter::cursorAt(const double x, const double y, const double signal,
33 const QMap<QString, QString> &extraValues) {
34 assert(m_model);
35 m_view->showInfo(m_model->info(x, y, signal, extraValues));
36}
37
43 if (auto matrixWS = std::dynamic_pointer_cast<MatrixWorkspace>(workspace))
44 m_model = std::make_unique<ImageInfoModelMatrixWS>(matrixWS);
45 else {
46 m_model = std::make_unique<ImageInfoModelMD>();
47 }
48}
49
55 if (info.empty())
56 return;
57
58 const auto &itemCount(info.size());
59 m_view->setColumnCount(itemCount);
60 for (int i = 0; i < itemCount; ++i) {
61 const auto &name = info.name(i);
62 if (name == "Signal") {
63 if (m_showSignal) {
65 } else {
67 }
68 }
69 auto header = new QTableWidgetItem(name);
70 header->setFlags(header->flags() & ~Qt::ItemIsEditable);
71 m_view->setItem(0, i, header);
72 auto value = new QTableWidgetItem(info.value(i));
73 value->setFlags(header->flags() & ~Qt::ItemIsEditable);
74 m_view->setItem(1, i, value);
75 }
76}
77
78} // namespace MantidQt::MantidWidgets
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
IPeaksWorkspace_sptr workspace
virtual void setColumnCount(const int count)=0
virtual void setRowCount(const int count)=0
virtual void hideColumn(const int index)=0
virtual void showInfo(const ImageInfoModel::ImageInfo &info)=0
virtual void showColumn(const int index)=0
virtual void setItem(const int rowIndex, const int columnIndex, QTableWidgetItem *item)=0
const QString & value(int index) const noexcept
const QString & name(int index) const noexcept
void setWorkspace(const Mantid::API::Workspace_sptr &ws)
Set a new workspace for the view to display.
void fillTableCells(const ImageInfoModel::ImageInfo &info)
Fill the view table cells using the model.
std::unique_ptr< ImageInfoModel > m_model
ImageInfoPresenter(IImageInfoWidget *view)
Constructor.
void cursorAt(const double x, const double y, const double signal, const QMap< QString, QString > &extraValues)
Base MatrixWorkspace Abstract Class.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace