Commit 01b9d00a authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Save viewport in maskshape table

When saving the shapes to table in the draw tab of the instrument
viewer, also save the viewport as a dummy shape so the real geometry of
the shape can be figured later on, taking into account the user's moves.
parent dee3f949
......@@ -51,6 +51,7 @@ public:
virtual void loadFromProject(const std::string &lines) override;
/// Save settings for the 3D projection to a project file
virtual std::string saveToProject() const override;
virtual void saveShapesToTableWorkspace() override;
signals:
void finishedMove();
......
......@@ -126,6 +126,9 @@ public:
/// Change the interaction mode
virtual void setInteractionMode(int mode);
/// Save masks to a table workspace
virtual void saveShapesToTableWorkspace();
//-----------------------------------
Mantid::Kernel::V3D getDetectorPos(int x, int y) const;
......@@ -234,8 +237,7 @@ public:
void changeBorderColor(const QColor &color) {
m_maskShapes.changeBorderColor(color);
}
/// Save masks to a table workspace
void saveShapesToTableWorkspace();
/// Load masks from a table workspace
void loadShapesFromTableWorkspace(
const Mantid::API::ITableWorkspace_const_sptr &ws);
......
......@@ -19,7 +19,6 @@
#include "MantidAPI/IMaskWorkspace.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
// #include "MantidDataObjects/TableWorkspace.h"
#include "MantidGeometry/Instrument/ComponentInfo.h"
#include "MantidKernel/Logger.h"
#include "MantidKernel/Strings.h"
......
......@@ -13,7 +13,9 @@
#include "MantidQtWidgets/InstrumentView/UnwrappedCylinder.h"
#include "MantidQtWidgets/InstrumentView/UnwrappedSphere.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/TableRow.h"
#include "MantidGeometry/Instrument/ComponentInfo.h"
#include "MantidGeometry/Objects/CSGObject.h"
#include "MantidQtWidgets/Common/InputController.h"
......@@ -492,5 +494,17 @@ std::string Projection3D::saveToProject() const {
#endif
}
void Projection3D::saveShapesToTableWorkspace() {
m_maskShapes.saveToTableWorkspace();
std::shared_ptr<Mantid::API::ITableWorkspace> table =
AnalysisDataService::Instance()
.retrieveWS<typename Mantid::API::ITableWorkspace>(
std::string("MaskShapes"));
Mantid::API::TableRow row = table->appendRow();
auto viewPortStr = m_viewport.saveToProject();
row << std::to_string(-1) << viewPortStr;
}
} // namespace MantidWidgets
} // namespace MantidQt
......@@ -8,10 +8,8 @@
#include "MantidGeometry/Rendering/OpenGL_Headers.h"
#include "MantidKernel/V3D.h"
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include "MantidQtWidgets/Common/TSVSerialiser.h"
#endif
#include <QtGlobal>
#include "MantidQtWidgets/InstrumentView/OpenGLError.h"
#include <cmath>
......@@ -503,7 +501,6 @@ void Viewport::loadFromProject(const std::string &lines) {
}
std::string Viewport::saveToProject() const {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
API::TSVSerialiser tsv;
tsv.writeLine("Translation") << m_xTrans << m_yTrans;
tsv.writeLine("Zoom") << m_zoomFactor;
......@@ -514,10 +511,6 @@ std::string Viewport::saveToProject() const {
}
return tsv.outputLines();
#else
throw std::runtime_error(
"Viewport::saveToProject() not implemented for Qt >= 5");
#endif
}
} // namespace MantidWidgets
} // 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