Mantid
Loading...
Searching...
No Matches
LogValueSelector.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
8
10
12
13// Convert strings to enum values
14const std::map<std::string, StatisticType> LogValueSelector::STRING_TO_FUNC = {{"Mean", StatisticType::Mean},
15 {"Min", StatisticType::Minimum},
16 {"Max", StatisticType::Maximum},
17 {"First", StatisticType::FirstValue},
18 {"Last", StatisticType::LastValue}};
19
25 m_ui.setupUi(this);
26 m_ui.horizontalLayout->addStretch(1);
27 doConnect();
28 m_ui.chkUseLog->setChecked(false);
29 this->setEnabled(Qt::Unchecked);
30}
31
35void LogValueSelector::doConnect() { connect(m_ui.chkUseLog, SIGNAL(stateChanged(int)), this, SLOT(setEnabled(int))); }
36
41QString LogValueSelector::getLog() const { return m_ui.log->currentText(); }
42
47QString LogValueSelector::getFunctionText() const { return m_ui.function->currentText(); }
48
53StatisticType LogValueSelector::getFunction() const {
54 const auto &text = getFunctionText().toStdString();
55 return STRING_TO_FUNC.at(text);
56}
57
62bool LogValueSelector::isCheckboxShown() const { return m_ui.chkUseLog->isVisible(); }
63
68void LogValueSelector::setCheckboxShown(bool visible) { m_ui.chkUseLog->setVisible(visible); }
69
74QComboBox *LogValueSelector::getLogComboBox() const { return m_ui.log; }
75
80void LogValueSelector::setEnabled(int checkstate) {
81 const bool enabled = checkstate == Qt::Checked;
82 m_ui.log->setEnabled(enabled);
83 m_ui.function->setEnabled(enabled);
84 emit logOptionsEnabled(enabled);
85}
86
91bool LogValueSelector::isCheckboxTicked() const { return m_ui.chkUseLog->isChecked(); }
92
93} // namespace MantidQt::MantidWidgets
This is the base class all customised widgets that do not wish to be tied to a specific Mantid algori...
Definition: MantidWidget.h:27
Ui::LogValueSelector m_ui
User interface.
static const std::map< std::string, Mantid::Kernel::Math::StatisticType > STRING_TO_FUNC
Converts strings like "Mean" or "Max" to enum values.
void setCheckboxShown(bool visible)
Control whether checkbox is shown.
LogValueSelector(QWidget *parent)
Constructor.
Mantid::Kernel::Math::StatisticType getFunction() const
Get selected function enum value.
bool isCheckboxTicked() const
Whether checkbox is ticked or not.
bool isCheckboxShown() const
Whether checkbox is shown or not.
QString getFunctionText() const
Get selected function text.
QString getLog() const
Get selected log text.
void setEnabled(int checkstate)
Set enabled/disabled.
void logOptionsEnabled(bool enabled)
Checkbox state has changed.
QComboBox * getLogComboBox() const
Get a pointer to log combo box.
StatisticType
Maps a "statistic" to a number.
Definition: Statistics.h:18