13#include "boost/algorithm/string.hpp"
21const std::string PERIOD_INFO_NOT_FOUND =
"Not found";
22const std::string NOT_DAQ_STRING =
"-";
23const std::string DAQ =
"1";
24const std::string DWELL =
"2";
25const std::string CYCLES_NOT_FOUND =
"Number of period cycles not found";
26const std::string DEFAULT_TITLE =
"Period Information for Run(s) ";
27const QStringList HEADERS{
"Period Count",
"Period Name",
"Type",
"DAQ Number",
28 "Frames",
"Total Frames",
"Counts",
"Tag"};
29const QString HEADER_STYLE =
"QHeaderView { font-weight: bold; }";
43 return ws->run().getLogData(logName)->value();
44 }
catch (
const std::runtime_error &) {
45 Logger(
"MuonPeriodInfo").
warning(
"Workspace does not contain " + logName);
58 return std::vector<std::string>();
59 std::vector<std::string> values;
60 boost::split(values, log, boost::is_any_of(delim));
72 const auto it = std::max_element(logs.cbegin(), logs.cend(),
73 [](
const auto &log1,
const auto &log2) { return log1.size() < log2.size(); });
74 size_t maxSize = it == logs.cend() ? 0 : (*it).size();
76 for (
size_t i = 0; i < logs.size(); ++i) {
77 if (logs[i].empty()) {
78 logs[i] = std::vector<std::string>(maxSize, PERIOD_INFO_NOT_FOUND);
80 while (logs[i].size() < maxSize) {
81 logs[i].emplace_back(PERIOD_INFO_NOT_FOUND);
96 m_uiForm.label->setText(QString::fromStdString(CYCLES_NOT_FOUND));
113 std::vector<std::vector<std::string>> logs = {names, types, frames, total_frames, counts, tags};
122 if (
auto matrixWS = std::dynamic_pointer_cast<MatrixWorkspace>(ws)) {
124 const auto numSeq =
readSampleLog(matrixWS,
"period_sequences");
132 for (
size_t i = 0; i < logs[0].size(); ++i) {
136 Logger(
"MuonPeriodInfo").
warning(
"Could not read workspace");
150 const std::string &totalFrames,
const std::string &counts,
151 const std::string &tag) {
152 const auto row =
m_uiForm.table->rowCount();
161 }
else if (type == DWELL) {
181 this->setWindowTitle(QString::fromStdString(DEFAULT_TITLE));
183 this->setWindowTitle(QString::fromStdString(DEFAULT_TITLE + title));
196 if (numberOfSequences < 0)
197 m_uiForm.label->setText(QString::fromStdString(CYCLES_NOT_FOUND));
200 QString::fromStdString(
"Run contains " +
std::to_string(numberOfSequences) +
" cycles of periods"));
216 for (
int i =
m_uiForm.table->rowCount(); i >= 0; --i)
231 m_uiForm.table->setColumnCount(HEADERS.size());
232 m_uiForm.table->setHorizontalHeaderLabels(QStringList(HEADERS));
233 m_uiForm.table->horizontalHeader()->setStyleSheet(HEADER_STYLE);
234 m_uiForm.table->verticalHeader()->setVisible(
false);
235 auto header =
m_uiForm.table->horizontalHeader();
236 for (
int i = 0; i < HEADERS.size(); ++i)
237 header->setSectionResizeMode(i, QHeaderView::ResizeToContents);
246 auto item =
new QTableWidgetItem();
247 item->setText(QString::fromStdString(
value));
248 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
double value
The value of the point.
The Logger class is in charge of the publishing messages from the framework through various channels.
void warning(const std::string &msg)
Logs at warning level.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::string to_string(const wide_integer< Bits, Signed > &n)