From c383becbc2a773ea8f52183d5480670f7068acee Mon Sep 17 00:00:00 2001 From: Samuel Jackson <samueljackson@outlook.com> Date: Mon, 8 Aug 2016 14:29:36 +0100 Subject: [PATCH] Refs #16962 Serialise instrument widget mask tab --- .../InstrumentView/InstrumentWidgetMaskTab.h | 6 +- .../InstrumentWidgetMaskTab.cpp | 64 ++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetMaskTab.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetMaskTab.h index 34a19366d7a..69259b085c7 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetMaskTab.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetMaskTab.h @@ -72,9 +72,11 @@ public: void setMode(Mode mode); void selectTool(Activity tool); /// Load settings for the widget tab from a project file - virtual void loadFromProject(const std::string &lines) override{}; + virtual void loadFromProject(const std::string &lines) override; + ; /// Save settings for the widget tab to a project file - virtual std::string saveToProject() const override { return ""; }; + virtual std::string saveToProject() const override; + ; signals: void executeAlgorithm(const QString &, const QString &); diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp index 0b0989675be..6e62c14fc9f 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp @@ -1,8 +1,9 @@ -#include "MantidQtMantidWidgets/InstrumentView/InstrumentWidget.h" #include "MantidQtMantidWidgets/InstrumentView/InstrumentWidgetMaskTab.h" +#include "MantidQtAPI/TSVSerialiser.h" +#include "MantidQtMantidWidgets/InstrumentView/DetXMLFile.h" #include "MantidQtMantidWidgets/InstrumentView/InstrumentActor.h" +#include "MantidQtMantidWidgets/InstrumentView/InstrumentWidget.h" #include "MantidQtMantidWidgets/InstrumentView/ProjectionSurface.h" -#include "MantidQtMantidWidgets/InstrumentView/DetXMLFile.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" @@ -1179,5 +1180,64 @@ void InstrumentWidgetMaskTab::storeMask() { void InstrumentWidgetMaskTab::changedIntegrationRange(double, double) { enableApplyButtons(); } + +void MantidQt::MantidWidgets::InstrumentWidgetMaskTab::loadFromProject( + const std::string &lines) { + TSVSerialiser tsv(lines); + + if (tsv.selectSection("masktab")) { + std::string tabLines; + tsv >> tabLines; + TSVSerialiser tab(tabLines); + + std::vector<QPushButton *> buttons{ + m_move, m_pointer, m_ellipse, m_rectangle, + m_ring_ellipse, m_ring_rectangle, m_free_draw}; + + tab.selectLine("ActiveTools"); + for (auto button : buttons) { + bool value; + tab >> value; + button->setChecked(value); + } + + std::vector<QRadioButton *> typeButtons{m_masking_on, m_grouping_on, + m_roi_on}; + + tab.selectLine("ActiveType"); + for (auto type : typeButtons) { + bool value; + tab >> value; + type->setChecked(value); + } + } +} + +std::string +MantidQt::MantidWidgets::InstrumentWidgetMaskTab::saveToProject() const { + TSVSerialiser tsv; + TSVSerialiser tab; + + std::vector<QPushButton *> buttons{ + m_move, m_pointer, m_ellipse, m_rectangle, + m_ring_ellipse, m_ring_rectangle, m_free_draw}; + + tab.writeLine("ActiveTools"); + for (auto button : buttons) { + tab << button->isChecked(); + } + + std::vector<QRadioButton *> typeButtons{m_masking_on, m_grouping_on, + m_roi_on}; + + tab.writeLine("ActiveType"); + for (auto type : typeButtons) { + tab << type->isChecked(); + } + + tsv.writeSection("masktab", tab.outputLines()); + return tsv.outputLines(); +} + } // MantidWidgets } // MantidQt -- GitLab