Commit cf3877fe authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Add saving and loading function

When saving projects, the save has to register if the instrument window
has an integration scroll bar or not, so when it loaded the loader won't
attempt to add values to a non-existent bar, resulting in a segfault.
Also, it remembers the mask tube and mask pixel buttons being checked
and restores them to their previous state at loading, as for any other button.
parent 1126520f
......@@ -160,7 +160,7 @@ public:
void addTab(const std::string &tabName);
void hideHelp();
InstrumentWidgetPickTab *getPickTab() { return m_pickTab; };
bool isIntegrable() { return m_shouldIntegrate; }
bool isIntegrable() const { return m_shouldIntegrate; }
signals:
void enableLighting(bool /*_t1*/);
......
......@@ -1569,8 +1569,11 @@ void InstrumentWidget::loadFromProject(const std::string &lines) {
if (tsv.selectLine("EnergyTransfer")) {
double min, max;
tsv >> min >> max;
setBinRange(min, max);
bool isIntegrable;
tsv >> min >> max >> isIntegrable;
if (isIntegrable) {
setBinRange(min, max);
}
}
if (tsv.selectSection("Surface")) {
......
......@@ -53,7 +53,14 @@ 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();
obj.setBinRange(min, max);
if (energyTransferList.size() > 2) {
const auto isIntegrable = energyTransferList[2].toBool();
if (isIntegrable) {
obj.setBinRange(min, max);
}
} else {
obj.setBinRange(min, max);
}
this->decodeSurface(map[QString("surface")].toMap(), obj.getSurface());
this->decodeActor(map[QString("actor")].toMap(), obj.m_instrumentActor);
......@@ -81,6 +88,8 @@ void InstrumentWidgetDecoder::decodeMaskTab(const QMap<QString, QVariant> &map,
obj->m_ring_rectangle->setChecked(
activeTools["ringRectangleButton"].toBool());
obj->m_free_draw->setChecked(activeTools["freeFrawButton"].toBool());
obj->m_pixel->setChecked(activeTools["pixelButton"].toBool());
obj->m_tube->setChecked(activeTools["tubeButton"].toBool());
// Decode the active type
obj->m_masking_on->setChecked(activeType["maskingOn"].toBool());
......
......@@ -51,6 +51,8 @@ InstrumentWidgetEncoder::encode(const InstrumentWidget &obj,
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));
map.insert(QString("energyTransfer"), QVariant(energyTransferList));
map.insert(QString("surface"),
......@@ -158,6 +160,9 @@ InstrumentWidgetEncoder::encodeMaskTab(const InstrumentWidgetMaskTab *tab) {
QVariant(tab->m_ring_rectangle->isChecked()));
activeTools.insert(QString("freeDrawButton"),
QVariant(tab->m_free_draw->isChecked()));
activeTools.insert(QString("pixelButton"),
QVariant(tab->m_pixel->isChecked()));
activeTools.insert(QString("tubeButton"), QVariant(tab->m_tube->isChecked()));
map.insert(QString("activeTools"), QVariant(activeTools));
activeType.insert(QString("maskingOn"),
......@@ -450,4 +455,4 @@ QList<QVariant> InstrumentWidgetEncoder::encodeAlignmentInfo(
return list;
}
} // namespace MantidWidgets
} // namespace MantidQt
\ No newline at end of file
} // namespace MantidQt
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