Commit 22024e52 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Modify the integration scroll bar removal process

When not setting an integration scroll bar, instead of just not showing
it, rather not create it at all. This is mmore heavy handed, as it
implies checking for the existence of the object each time it is called,
but it is more reliable (as the non-created object cannot possibly
occupy any space on screen).

This solves the problem of the unclickable Render and Pick tabs.
parent 4bc9ad31
......@@ -59,8 +59,7 @@ private:
class XIntegrationControl : public QFrame {
Q_OBJECT
public:
explicit XIntegrationControl(InstrumentWidget *instrWindow,
bool hidden = false);
explicit XIntegrationControl(InstrumentWidget *instrWindow);
void setTotalRange(double minimum, double maximum);
void setUnits(const QString &units);
void setRange(double minimum, double maximum);
......@@ -89,7 +88,6 @@ private:
double m_totalMaximum;
double m_minimum;
double m_maximum;
bool m_hidden;
};
} // namespace MantidWidgets
} // namespace MantidQt
......@@ -166,8 +166,8 @@ InstrumentWidget::InstrumentWidget(const QString &wsName, QWidget *parent,
m_shouldIntegrate = true;
}
m_xIntegration = new XIntegrationControl(this, !m_shouldIntegrate);
if (m_shouldIntegrate) {
m_xIntegration = new XIntegrationControl(this);
mainLayout->addWidget(m_xIntegration);
connect(m_xIntegration, SIGNAL(changed(double, double)), this,
SLOT(setIntegrationRange(double, double)));
......@@ -184,7 +184,6 @@ InstrumentWidget::InstrumentWidget(const QString &wsName, QWidget *parent,
infoLayout->setStretchFactor(mInteractionInfo, 1);
infoLayout->setStretchFactor(m_help, 0);
mainLayout->addLayout(infoLayout);
QSettings settings;
settings.beginGroup(InstrumentWidgetSettingsGroup);
......@@ -888,7 +887,9 @@ void InstrumentWidget::setIntegrationRange(double xmin, double xmax) {
* python.
*/
void InstrumentWidget::setBinRange(double xmin, double xmax) {
m_xIntegration->setRange(xmin, xmax);
if (m_shouldIntegrate) {
m_xIntegration->setRange(xmin, xmax);
}
}
/**
......@@ -1256,12 +1257,12 @@ void InstrumentWidget::createTabs(QSettings &settings) {
m_maskTab = new InstrumentWidgetMaskTab(this);
connect(m_maskTab, SIGNAL(executeAlgorithm(const QString &, const QString &)),
this, SLOT(executeAlgorithm(const QString &, const QString &)));
m_maskTab->loadSettings(settings);
if (m_shouldIntegrate) {
connect(m_xIntegration, SIGNAL(changed(double, double)), m_maskTab,
SLOT(changedIntegrationRange(double, double)));
}
m_maskTab->loadSettings(settings);
// Instrument tree controls
m_treeTab = new InstrumentWidgetTreeTab(this);
m_treeTab->loadSettings(settings);
......
......@@ -53,8 +53,8 @@ void InstrumentWidgetDecoder::decode(const QMap<QString, QVariant> &map,
const auto energyTransferList = map[QString("energyTransfer")].toList();
const auto min = energyTransferList[0].toDouble();
const auto max = energyTransferList[1].toDouble();
if (energyTransferList.size() > 2) {
const auto isIntegrable = energyTransferList[2].toBool();
if (energyTransferList.size() == 3) {
const bool isIntegrable = energyTransferList[2].toBool();
if (isIntegrable) {
obj.setBinRange(min, max);
}
......
......@@ -49,10 +49,14 @@ InstrumentWidgetEncoder::encode(const InstrumentWidget &obj,
map.insert(QString("currentTab"), QVariant(obj.getCurrentTab()));
QList<QVariant> energyTransferList;
energyTransferList.append(QVariant(obj.m_xIntegration->getMinimum()));
energyTransferList.append(QVariant(obj.m_xIntegration->getMaximum()));
bool isInt = obj.isIntegrable();
energyTransferList.append(QVariant(isInt));
if (obj.isIntegrable()) {
energyTransferList.append(QVariant(obj.m_xIntegration->getMinimum()));
energyTransferList.append(QVariant(obj.m_xIntegration->getMaximum()));
} else {
energyTransferList.append(QVariant(0));
energyTransferList.append(QVariant(1));
}
energyTransferList.append(QVariant(obj.isIntegrable()));
map.insert(QString("energyTransfer"), QVariant(energyTransferList));
map.insert(QString("surface"),
......
......@@ -175,41 +175,39 @@ void XIntegrationScrollBar::updateMinMax() {
//---------------------------------------------------------------------------------//
XIntegrationControl::XIntegrationControl(InstrumentWidget *instrWindow,
bool hidden)
XIntegrationControl::XIntegrationControl(InstrumentWidget *instrWindow)
: QFrame(instrWindow), m_instrWindow(instrWindow), m_totalMinimum(0),
m_totalMaximum(1), m_minimum(0), m_maximum(1), m_hidden(hidden) {
m_totalMaximum(1), m_minimum(0), m_maximum(1) {
// if the integration control panel is hidden, most of the fields should not
// be declared
if (!hidden) {
auto *layout = new QHBoxLayout();
m_minText = new QLineEdit(this);
m_minText->setMaximumWidth(100);
m_minText->setToolTip("Minimum x value");
m_maxText = new QLineEdit(this);
m_maxText->setMaximumWidth(100);
m_maxText->setToolTip("Maximum x value");
m_units = new QLabel("TOF", this);
m_setWholeRange = new QPushButton("Reset");
m_setWholeRange->setToolTip("Reset integration range to maximum");
m_scrollBar = new XIntegrationScrollBar(this);
layout->addWidget(m_units, 0);
layout->addWidget(m_minText, 0);
layout->addWidget(m_scrollBar, 1);
layout->addWidget(m_maxText, 0);
layout->addWidget(m_setWholeRange, 0);
setLayout(layout);
connect(m_scrollBar, SIGNAL(changed(double, double)), this,
SLOT(sliderChanged(double, double)));
connect(m_scrollBar, SIGNAL(running(double, double)), this,
SLOT(sliderRunning(double, double)));
connect(m_minText, SIGNAL(editingFinished()), this, SLOT(setMinimum()));
connect(m_maxText, SIGNAL(editingFinished()), this, SLOT(setMaximum()));
connect(m_setWholeRange, SIGNAL(clicked()), this, SLOT(setWholeRange()));
updateTextBoxes();
}
auto *layout = new QHBoxLayout();
m_minText = new QLineEdit(this);
m_minText->setMaximumWidth(100);
m_minText->setToolTip("Minimum x value");
m_maxText = new QLineEdit(this);
m_maxText->setMaximumWidth(100);
m_maxText->setToolTip("Maximum x value");
m_units = new QLabel("TOF", this);
m_setWholeRange = new QPushButton("Reset");
m_setWholeRange->setToolTip("Reset integration range to maximum");
m_scrollBar = new XIntegrationScrollBar(this);
layout->addWidget(m_units, 0);
layout->addWidget(m_minText, 0);
layout->addWidget(m_scrollBar, 1);
layout->addWidget(m_maxText, 0);
layout->addWidget(m_setWholeRange, 0);
setLayout(layout);
connect(m_scrollBar, SIGNAL(changed(double, double)), this,
SLOT(sliderChanged(double, double)));
connect(m_scrollBar, SIGNAL(running(double, double)), this,
SLOT(sliderRunning(double, double)));
connect(m_minText, SIGNAL(editingFinished()), this, SLOT(setMinimum()));
connect(m_maxText, SIGNAL(editingFinished()), this, SLOT(setMaximum()));
connect(m_setWholeRange, SIGNAL(clicked()), this, SLOT(setWholeRange()));
updateTextBoxes();
}
void XIntegrationControl::sliderChanged(double minimum, double maximum) {
......@@ -255,10 +253,9 @@ void XIntegrationControl::setRange(double minimum, double maximum) {
m_minimum = minimum;
m_maximum = maximum;
double w = m_totalMaximum - m_totalMinimum;
if (!m_hidden) {
m_scrollBar->set((m_minimum - m_totalMinimum) / w,
(m_maximum - m_totalMinimum) / w);
}
m_scrollBar->set((m_minimum - m_totalMinimum) / w,
(m_maximum - m_totalMinimum) / w);
updateTextBoxes();
emit changed(m_minimum, m_maximum);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment