Commit e8767823 authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #16962 Serialise peak overlay markers

parent 22d53e06
......@@ -127,6 +127,9 @@ public:
virtual void loadFromProject(const std::string &lines) override;
/// Save settings for the widget tab to a project file
virtual std::string saveToProject() const override;
/// Get a handle to a peaks workspace from a name
boost::shared_ptr<Mantid::API::IPeaksWorkspace>
retrievePeaksWorkspace(const std::string &name) const;
protected slots:
......
......@@ -1372,7 +1372,8 @@ void InstrumentWidget::loadFromProject(const std::string &lines) {
tsv >> surfaceLines;
getSurface()->loadFromProject(surfaceLines);
}
// updateInstrumentView();
updateInstrumentView();
}
} // MantidWidgets
......
......@@ -440,4 +440,4 @@ void PeakOverlay::setPeakVisibility(double xmin, double xmax, QString units) {
}
} // MantidWidgets
} // MantidQt
\ No newline at end of file
} // MantidQt
......@@ -738,7 +738,6 @@ std::string MantidQt::MantidWidgets::ProjectionSurface::saveToProject() const
TSVSerialiser tsv;
tsv.writeLine("BackgroundColor") << m_backgroundColor;
tsv.writeSection("shapes", m_maskShapes.saveToProject());
// tsv.writeSection("peaks", m_peakShapes.saveToProject());
return tsv.outputLines();
}
......
......@@ -4,9 +4,10 @@
#include "MantidQtMantidWidgets/InstrumentView/OpenGLError.h"
#include "MantidQtMantidWidgets/InstrumentView/PeakMarker2D.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include "MantidGeometry/IDetector.h"
#include "MantidGeometry/Objects/Object.h"
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Objects/Object.h"
#include "MantidQtMantidWidgets/InputController.h"
#include <QRgb>
......@@ -730,16 +731,48 @@ void UnwrappedSurface::loadFromProject(const std::string &lines) {
updateView();
emit updateInfoText();
}
if (tsv.selectLine("PeaksWorkspaces")) {
size_t workspaceCount = tsv.values("PeaksWorkspaces").size();
for (size_t i = 0; i < workspaceCount; ++i) {
std::string name;
tsv >> name;
auto ws = retrievePeaksWorkspace(name);
if (ws)
setPeaksWorkspace(ws);
}
}
}
std::string UnwrappedSurface::saveToProject() const {
TSVSerialiser tsv;
tsv.writeRaw(ProjectionSurface::saveToProject());
tsv.writeLine("Zoom");
tsv << m_viewRect.x0() << m_viewRect.y0();
tsv << m_viewRect.x1() << m_viewRect.y1();
tsv.writeLine("PeaksWorkspaces");
for (auto overlay : m_peakShapes) {
tsv << overlay->getPeaksWorkspace()->name();
}
return tsv.outputLines();
}
boost::shared_ptr<Mantid::API::IPeaksWorkspace>
UnwrappedSurface::retrievePeaksWorkspace(const std::string &name) const {
using namespace Mantid::API;
Workspace_sptr ws;
try {
ws = AnalysisDataService::Instance().retrieve(name);
} catch (std::runtime_error) {
// couldn't find the workspace in the ADS for some reason
// just fail silently. There's nothing more we can do.
return nullptr;
}
return boost::dynamic_pointer_cast<Mantid::API::IPeaksWorkspace>(ws);
}
} // MantidWidgets
} // 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