Mantid
Loading...
Searching...
No Matches
ImageInfoModel.h
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#pragma once
8
9#include "DllOption.h"
10
11#include "MantidAPI/Workspace.h"
12#include "MantidKernel/Unit.h"
14#include <QMap>
15#include <QString>
16#include <cmath>
17#include <vector>
18
19namespace MantidQt {
20namespace MantidWidgets {
21
23public:
24 class ImageInfo {
25 public:
26 using StringItems = std::vector<QString>;
28
29 inline bool empty() const noexcept { return m_names.empty(); }
30 inline int size() const noexcept { return static_cast<int>(m_names.size()); }
31 inline const QString &name(int index) const noexcept { return m_names[index]; }
32 inline const QString &value(int index) const noexcept { return m_values[index]; }
33 inline void setValue(int index, const QString &value) noexcept { m_values[index] = value; }
36 };
37
39 static constexpr auto FourDigitPrecision = 4;
41 static constexpr auto DecimalFormat = 'f';
43 static constexpr auto UnsetValue = std::numeric_limits<double>::max();
45 static inline const QString MissingValue = QString("-");
46
47 static inline const QString defaultFormat(const double x) {
48 if (abs(x) == UnsetValue)
49 return MissingValue;
50 return QString::number(x, ImageInfoModel::DecimalFormat, ImageInfoModel::FourDigitPrecision);
51 }
52
53 static inline const QString defaultFormat(const int x) { return QString::number(x); }
54
55public:
56 virtual ~ImageInfoModel() = default;
57
66 virtual ImageInfoModel::ImageInfo info(const double x, const double y, const double signal,
67 const QMap<QString, QString> &extraValues) const = 0;
68};
69
70} // namespace MantidWidgets
71} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
double value
The value of the point.
Definition: FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
const QString & value(int index) const noexcept
const QString & name(int index) const noexcept
void setValue(int index, const QString &value) noexcept
static const QString defaultFormat(const int x)
virtual ImageInfoModel::ImageInfo info(const double x, const double y, const double signal, const QMap< QString, QString > &extraValues) const =0
Creates information about the point at the given coordinates in the workspace.
static const QString defaultFormat(const double x)
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...