From 679610c7f9a5d3809ccd4440e670d20a959b4b3c Mon Sep 17 00:00:00 2001
From: Samuel Jackson <samueljackson@outlook.com>
Date: Tue, 16 Aug 2016 11:05:51 +0100
Subject: [PATCH] Refs #16962 Refactoring and updating documentation

---
 .../InstrumentWidget/InstrumentWindow.cpp     |  93 +++++++------
 .../InstrumentWidget/InstrumentWindow.h       |   2 +
 MantidQt/API/inc/MantidQtAPI/TSVSerialiser.h  |   2 +
 MantidQt/API/src/TSVSerialiser.cpp            |  12 ++
 .../InstrumentView/InstrumentWidgetPickTab.h  |   4 +-
 .../InstrumentView/InstrumentWidgetTab.h      |   4 +-
 .../InstrumentView/InstrumentWidgetTreeTab.h  |   4 +-
 .../InstrumentView/Projection3D.h             |   4 +-
 .../InstrumentView/ProjectionSurface.h        |   4 +-
 .../InstrumentView/Shape2D.h                  |  22 +--
 .../InstrumentView/Shape2DCollection.h        |   4 +-
 .../InstrumentView/UnwrappedSurface.h         |   4 +-
 .../InstrumentWidgetMaskTab.cpp               |  85 ++++++------
 .../InstrumentWidgetPickTab.cpp               |  93 +++++++------
 .../InstrumentWidgetRenderTab.cpp             | 115 ++++++++--------
 .../InstrumentWidgetTreeTab.cpp               |  31 +++--
 .../src/InstrumentView/MaskBinsData.cpp       |   6 +
 .../src/InstrumentView/Projection3D.cpp       |   6 +
 .../src/InstrumentView/ProjectionSurface.cpp  |  12 +-
 .../src/InstrumentView/Shape2D.cpp            | 128 ++++++++++++------
 .../src/InstrumentView/Shape2DCollection.cpp  |   6 +
 .../src/InstrumentView/UnwrappedSurface.cpp   |  41 ++++--
 22 files changed, 399 insertions(+), 283 deletions(-)

diff --git a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp
index 11717eac2bd..afd8b4b583b 100644
--- a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp
+++ b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp
@@ -40,61 +40,68 @@ InstrumentWindow::InstrumentWindow(const QString &wsName, const QString &label,
 
 InstrumentWindow::~InstrumentWindow() {}
 
+/**
+ * Load instrument window state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ * @return handle to the created instrument window
+ */
 IProjectSerialisable *InstrumentWindow::loadFromProject(
     const std::string &lines, ApplicationWindow *app, const int fileVersion) {
   Q_UNUSED(fileVersion);
 
   TSVSerialiser tsv(lines);
-  if (tsv.selectLine("WorkspaceName")) {
-    std::string wsName = tsv.asString(1);
-    QString name = QString::fromStdString(wsName);
-
-    if (!Mantid::API::AnalysisDataService::Instance().doesExist(wsName))
-      return nullptr;
-    MatrixWorkspace_const_sptr ws =
-        boost::dynamic_pointer_cast<const MatrixWorkspace>(
-            app->mantidUI->getWorkspace(QString::fromStdString(wsName)));
-    if (!ws)
-      return nullptr;
-
-    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-    Mantid::Geometry::Instrument_const_sptr instr = ws->getInstrument();
-    if (!instr || instr->getName().empty()) {
-      QApplication::restoreOverrideCursor();
-      QMessageBox::critical(app, "MantidPlot - Error",
-                            "Instrument view cannot be opened");
-      return nullptr;
-    }
 
-    // Need a new window
-    const QString windowName(QString("InstrumentWindow:") +
-                             QString::fromStdString(wsName));
-    auto iw =
-        new InstrumentWindow(name, QString("Instrument"), app, windowName);
-
-    try {
-      if (tsv.hasLine("geometry")) {
-        const QString geometry =
-            QString::fromStdString(tsv.lineAsString("geometry"));
-        app->restoreWindowGeometry(app, iw, geometry);
-      }
-
-      iw->m_instrumentWidget->loadFromProject(lines);
-      app->addMdiSubWindow(iw);
-
-      QApplication::restoreOverrideCursor();
-      return iw;
-    } catch (const std::exception &e) {
-      QApplication::restoreOverrideCursor();
-      QString errorMessage =
-          "Instrument view cannot be created:\n\n" + QString(e.what());
-      QMessageBox::critical(app, "MantidPlot - Error", errorMessage);
+  if (!tsv.selectLine("WorkspaceName"))
+    return nullptr;
+
+  const auto name = tsv.asQString(1);
+  const auto workspace = app->mantidUI->getWorkspace(name);
+  const auto ws = boost::dynamic_pointer_cast<const MatrixWorkspace>(workspace);
+
+  if (!ws)
+    return nullptr;
+
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+
+  auto instr = ws->getInstrument();
+  if (!instr || instr->getName().empty()) {
+    QApplication::restoreOverrideCursor();
+    QMessageBox::critical(app, "MantidPlot - Error",
+                          "Instrument view cannot be opened");
+    return nullptr;
+  }
+
+  // Create a new window
+  const QString windowName("InstrumentWindow:" + name);
+  auto iw = new InstrumentWindow(name, "Instrument", app, windowName);
+
+  // Populate window properties
+  try {
+    if (tsv.hasLine("geometry")) {
+      const auto geometry = tsv.lineAsQString("geometry");
+      app->restoreWindowGeometry(app, iw, geometry);
     }
+
+    iw->m_instrumentWidget->loadFromProject(lines);
+    app->addMdiSubWindow(iw);
+
+    QApplication::restoreOverrideCursor();
+    return iw;
+  } catch (const std::exception &e) {
+    QApplication::restoreOverrideCursor();
+    QString errorMessage =
+        "Instrument view cannot be created:\n\n" + QString(e.what());
+    QMessageBox::critical(app, "MantidPlot - Error", errorMessage);
   }
 
   return nullptr;
 }
 
+/**
+ * Save the state of the instrument window to a Mantid project file
+ * @param app :: handle to the current application window instance
+ * @return a string representing the state of the instrument window
+ */
 std::string InstrumentWindow::saveToProject(ApplicationWindow *app) {
   TSVSerialiser tsv, window;
   window.writeRaw(app->windowGeometryInfo(this));
diff --git a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h
index 775d52f2ecd..40110ac1758 100644
--- a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h
+++ b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h
@@ -28,9 +28,11 @@ public:
                             const QString &name = QString());
   ~InstrumentWindow() override;
 
+  /// Load the state of the instrument window for a Mantid project file
   static IProjectSerialisable *loadFromProject(const std::string &lines,
                                                ApplicationWindow *app,
                                                const int fileVersion);
+  /// Save the state of the instrument window to a Mantid project file
   std::string saveToProject(ApplicationWindow *app) override;
   void selectTab(int tab);
   MantidQt::MantidWidgets::InstrumentWidgetTab *
diff --git a/MantidQt/API/inc/MantidQtAPI/TSVSerialiser.h b/MantidQt/API/inc/MantidQtAPI/TSVSerialiser.h
index 7da8caa320c..a261f219fac 100644
--- a/MantidQt/API/inc/MantidQtAPI/TSVSerialiser.h
+++ b/MantidQt/API/inc/MantidQtAPI/TSVSerialiser.h
@@ -57,6 +57,7 @@ public:
   std::vector<std::string> sections(const std::string &name) const;
 
   std::string lineAsString(const std::string &name, const size_t i = 0) const;
+  QString lineAsQString(const std::string &name, const size_t i = 0) const;
 
   bool selectLine(const std::string &name, const size_t i = 0);
   bool selectSection(const std::string &name, const size_t i = 0);
@@ -66,6 +67,7 @@ public:
   double asDouble(const size_t i) const;
   float asFloat(const size_t i) const;
   std::string asString(const size_t i) const;
+  QString asQString(const size_t i) const;
   bool asBool(const size_t i) const;
   QRect asQRect(const size_t i) const;
   QColor asQColor(const size_t i) const;
diff --git a/MantidQt/API/src/TSVSerialiser.cpp b/MantidQt/API/src/TSVSerialiser.cpp
index da70dbf5cff..04555244a06 100644
--- a/MantidQt/API/src/TSVSerialiser.cpp
+++ b/MantidQt/API/src/TSVSerialiser.cpp
@@ -149,6 +149,11 @@ std::string TSVSerialiser::lineAsString(const std::string &name,
   return lines[i];
 }
 
+QString TSVSerialiser::lineAsQString(const std::string &name,
+                                     const size_t i) const {
+  return QString::fromStdString(lineAsString(name, i));
+}
+
 bool TSVSerialiser::selectLine(const std::string &name, const size_t i) {
   if (!hasLine(name))
     return false;
@@ -278,6 +283,13 @@ std::string TSVSerialiser::asString(const size_t i) const {
   return m_curValues.at(i);
 }
 
+QString TSVSerialiser::asQString(const size_t i) const {
+  if (i >= m_curValues.size())
+    return "";
+
+  return QString::fromStdString(m_curValues.at(i));
+}
+
 TSVSerialiser &TSVSerialiser::operator>>(int &val) {
   val = asInt(m_curIndex++);
   return *this;
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetPickTab.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetPickTab.h
index ecd266372bb..258fae376f0 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetPickTab.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetPickTab.h
@@ -83,9 +83,9 @@ public:
   bool addToDisplayContextMenu(QMenu &) const override;
   void selectTool(const ToolType tool);
   boost::shared_ptr<ProjectionSurface> getSurface() const;
-  /// Load settings for the widget tab from a project file
+  /// Load settings for the pick tab from a project file
   virtual void loadFromProject(const std::string &lines) override;
-  /// Save settings for the widget tab to a project file
+  /// Save settings for the pick tab to a project file
   virtual std::string saveToProject() const override;
 
 public slots:
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTab.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTab.h
index 955ec0d27df..c596fec152d 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTab.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTab.h
@@ -38,9 +38,9 @@ public:
   virtual bool addToDisplayContextMenu(QMenu &) const { return false; }
   /// Get the projection surface
   boost::shared_ptr<ProjectionSurface> getSurface() const;
-  /// Load settings for the widget tab from a project file
+  /// Load state for the widget tab from a project file
   virtual void loadFromProject(const std::string &lines) = 0;
-  /// Save settings for the widget tab to a project file
+  /// Save state for the widget tab to a project file
   virtual std::string saveToProject() const = 0;
 
 protected:
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTreeTab.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTreeTab.h
index 69257b0c06e..f073c0a8c45 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTreeTab.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/InstrumentWidgetTreeTab.h
@@ -19,10 +19,10 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS InstrumentWidgetTreeTab
 public:
   explicit InstrumentWidgetTreeTab(InstrumentWidget *instrWidget);
   void initSurface() override;
-  /// Load settings for the widget tab from a project file
+  /// Load settings for the tree widget tab from a project file
   virtual void loadFromProject(const std::string &lines) override;
   ;
-  /// Save settings for the widget tab to a project file
+  /// Save settings for the tree widget tab to a project file
   virtual std::string saveToProject() const override;
   ;
 public slots:
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Projection3D.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Projection3D.h
index ed22be7b6a1..991e8751f89 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Projection3D.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Projection3D.h
@@ -44,9 +44,9 @@ public:
   void getMaskedDetectors(QList<int> &dets) const override;
   void resize(int, int) override;
   QString getInfoText() const override;
-  /// Load settings for the widget tab from a project file
+  /// Load settings for the 3D projection from a project file
   virtual void loadFromProject(const std::string &lines) override;
-  /// Save settings for the widget tab to a project file
+  /// Save settings for the 3D projection to a project file
   virtual std::string saveToProject() const override;
 
 signals:
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/ProjectionSurface.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/ProjectionSurface.h
index ba1a8646d55..c8eabf00ea6 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/ProjectionSurface.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/ProjectionSurface.h
@@ -136,9 +136,9 @@ public:
   void requestRedraw(bool resetPeakVisibility = false);
   /// Enable lighting if the implementation allows it
   void enableLighting(bool on);
-  /// Load settings for the widget tab from a project file
+  /// Load settings for the projection surface from a project file
   virtual void loadFromProject(const std::string &lines);
-  /// Save settings for the widget tab to a project file
+  /// Save settings for the projection surface to a project file
   virtual std::string saveToProject() const;
 
   //-----------------------------------
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h
index e913763addd..7ed76f7f25c 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h
@@ -180,9 +180,9 @@ protected:
   bool m_visible;  ///< flag to show or hide the shape
 
 private:
-  static Shape2D* loadShape2DRectangle(const std::string &lines);
-  static Shape2D* loadShape2DRing(const std::string &lines);
-  static Shape2D* loadShape2DFree(const std::string &lines);
+  /// Instantiate specifc shapes from a type string
+  static Shape2D *loadShape2DFromType(const std::string &type,
+                                      const std::string &lines);
 };
 
 /**
@@ -207,9 +207,9 @@ public:
   QStringList getPointNames() const override { return QStringList("center"); }
   QPointF getPoint(const QString &prop) const override;
   void setPoint(const QString &prop, const QPointF &value) override;
-  /// Load settings for the shape from a project file
+  /// Load state for the shape from a project file
   static Shape2D* loadFromProject(const std::string &lines);
-  /// Save settings for the widget tab to a project file
+  /// Save state for the shape to a project file
   virtual std::string saveToProject() const override;
 
 protected:
@@ -233,9 +233,9 @@ public:
     return m_boundingRect.contains(p);
   }
   void addToPath(QPainterPath &path) const override;
-  /// Load settings for the shape from a project file
+  /// Load state for the shape from a project file
   static Shape2D* loadFromProject(const std::string &lines);
-  /// Save settings for the widget tab to a project file
+  /// Save state for the shape to a project file
   virtual std::string saveToProject() const override;
 
 protected:
@@ -269,9 +269,9 @@ public:
   void setColor(const QColor &color) override;
   QColor getColor() const override { return m_outer_shape->getColor(); }
   const Shape2D *getOuterShape() const { return m_outer_shape; }
-  /// Load settings for the shape from a project file
+  /// Load state for the shape from a project file
   static Shape2D* loadFromProject(const std::string &lines);
-  /// Save settings for the widget tab to a project file
+  /// Save state for the shape to a project file
   virtual std::string saveToProject() const override;
 
 protected:
@@ -304,9 +304,9 @@ public:
   void addToPath(QPainterPath &path) const override;
   void addPolygon(const QPolygonF &polygon);
   void subtractPolygon(const QPolygonF &polygon);
-  /// Load settings for the shape from a project file
+  /// Load state for the shape from a project file
   static Shape2D* loadFromProject(const std::string &lines);
-  /// Save settings for the widget tab to a project file
+  /// Save state for the shape to a project file
   virtual std::string saveToProject() const override;
 
 protected:
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2DCollection.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2DCollection.h
index 7df60b3d1df..a817239b347 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2DCollection.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2DCollection.h
@@ -85,9 +85,9 @@ public:
 
   /// Change border color of all shapes.
   void changeBorderColor(const QColor &color);
-  /// Load settings for the widget tab from a project file
+  /// Load settings for the shape 2D collection from a project file
   virtual void loadFromProject(const std::string &lines);
-  /// Save settings for the widget tab to a project file
+  /// Save settings for the shape 2D collection to a project file
   virtual std::string saveToProject() const override;
 
 signals:
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/UnwrappedSurface.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/UnwrappedSurface.h
index ad1ce312131..17f86e04670 100644
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/UnwrappedSurface.h
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/UnwrappedSurface.h
@@ -123,9 +123,9 @@ public:
   /// Zoom into an area of the screen
   void zoom(const QRectF &area);
   //@}
-  /// Load settings for the widget tab from a project file
+  /// Load settings for the unwrapped surface from a project file
   virtual void loadFromProject(const std::string &lines) override;
-  /// Save settings for the widget tab to a project file
+  /// Save settings for the unwrapped surface 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>
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp
index e1d45f87cc8..c6afbda0932 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp
@@ -36,23 +36,23 @@
 #endif
 #endif
 
-#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QGridLayout>
-#include <QPushButton>
-#include <QRadioButton>
-#include <QTextEdit>
-#include <QMenu>
 #include <QAction>
-#include <QLabel>
-#include <QMessageBox>
 #include <QApplication>
+#include <QCheckBox>
 #include <QFileDialog>
-#include <QToolTip>
-#include <QTemporaryFile>
+#include <QGridLayout>
 #include <QGroupBox>
-#include <QCheckBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMenu>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QRadioButton>
 #include <QSettings>
+#include <QTemporaryFile>
+#include <QTextEdit>
+#include <QToolTip>
+#include <QVBoxLayout>
 
 #include "MantidQtAPI/FileDialogHandler.h"
 
@@ -1182,46 +1182,46 @@ void InstrumentWidgetMaskTab::changedIntegrationRange(double, double) {
   enableApplyButtons();
 }
 
-/** Load mask tab settings from a Mantid project file
- *
+/** Load mask tab state from a Mantid project file
  * @param lines :: lines from the project file to load state from
  */
 void InstrumentWidgetMaskTab::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
 
-  if (tsv.selectSection("masktab")) {
-    std::string tabLines;
-    tsv >> tabLines;
-    TSVSerialiser tab(tabLines);
+  if (!tsv.selectSection("masktab"))
+    return;
 
-    std::vector<QPushButton *> buttons{
-        m_move,         m_pointer,        m_ellipse,  m_rectangle,
-        m_ring_ellipse, m_ring_rectangle, m_free_draw};
+  std::string tabLines;
+  tsv >> tabLines;
+  TSVSerialiser tab(tabLines);
 
-    tab.selectLine("ActiveTools");
-    for (auto button : buttons) {
-      bool value;
-      tab >> value;
-      button->setChecked(value);
-    }
+  std::vector<QPushButton *> buttons{
+      m_move,         m_pointer,        m_ellipse,  m_rectangle,
+      m_ring_ellipse, m_ring_rectangle, m_free_draw};
 
-    std::vector<QRadioButton *> typeButtons{m_masking_on, m_grouping_on,
-                                            m_roi_on};
+  tab.selectLine("ActiveTools");
+  for (auto button : buttons) {
+    bool value;
+    tab >> value;
+    button->setChecked(value);
+  }
 
-    tab.selectLine("ActiveType");
-    for (auto type : typeButtons) {
-      bool value;
-      tab >> value;
-      type->setChecked(value);
-    }
+  std::vector<QRadioButton *> typeButtons{m_masking_on, m_grouping_on,
+                                          m_roi_on};
 
-    if (tab.selectLine("MaskViewWorkspace")) {
-      // the view was masked. We should load reapply this from a cached
-      // workspace in the project folder
-      std::string maskWSName;
-      tab >> maskWSName;
-      loadMaskViewFromProject(maskWSName);
-    }
+  tab.selectLine("ActiveType");
+  for (auto type : typeButtons) {
+    bool value;
+    tab >> value;
+    type->setChecked(value);
+  }
+
+  if (tab.selectLine("MaskViewWorkspace")) {
+    // the view was masked. We should load reapply this from a cached
+    // workspace in the project folder
+    std::string maskWSName;
+    tab >> maskWSName;
+    loadMaskViewFromProject(maskWSName);
   }
 }
 
@@ -1294,7 +1294,6 @@ InstrumentWidgetMaskTab::loadMask(const std::string &fileName) {
 }
 
 /** Save the state of the mask tab to a Mantid project file
- *
  * @return a string representing the state of the mask tab
  */
 std::string InstrumentWidgetMaskTab::saveToProject() const {
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp
index 6923ff895b6..a804c5eb662 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp
@@ -696,6 +696,55 @@ void InstrumentWidgetPickTab::savePlotToWorkspace() {
   m_plotController->savePlotToWorkspace();
 }
 
+/** Load pick tab state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ */
+void InstrumentWidgetPickTab::loadFromProject(const std::string &lines) {
+  TSVSerialiser tsv(lines);
+
+  if (!tsv.selectSection("picktab"))
+    return;
+
+  std::string tabLines;
+  tsv >> tabLines;
+  TSVSerialiser tab(tabLines);
+
+  // load active push button
+  std::vector<QPushButton *> buttons{
+      m_zoom,         m_edit,           m_ellipse,   m_rectangle,
+      m_ring_ellipse, m_ring_rectangle, m_free_draw, m_one,
+      m_tube,         m_peak,           m_peakSelect};
+
+  tab.selectLine("ActiveTools");
+  for (auto button : buttons) {
+    bool value;
+    tab >> value;
+    button->setChecked(value);
+  }
+}
+
+/** Save the state of the pick tab to a Mantid project file
+ * @return a string representing the state of the pick tab
+ */
+std::string InstrumentWidgetPickTab::saveToProject() const {
+  TSVSerialiser tsv;
+  TSVSerialiser tab;
+
+  // save active push button
+  std::vector<QPushButton *> buttons{
+      m_zoom,         m_edit,           m_ellipse,   m_rectangle,
+      m_ring_ellipse, m_ring_rectangle, m_free_draw, m_one,
+      m_tube,         m_peak,           m_peakSelect};
+
+  tab.writeLine("ActiveTools");
+  for (auto button : buttons) {
+    tab << button->isChecked();
+  }
+
+  tsv.writeSection("picktab", tab.outputLines());
+  return tsv.outputLines();
+}
+
 //=====================================================================================//
 
 /**
@@ -1631,49 +1680,5 @@ void DetectorPlotController::addPeak(double x, double y) {
   }
 }
 
-void MantidQt::MantidWidgets::InstrumentWidgetPickTab::loadFromProject(
-    const std::string &lines) {
-  TSVSerialiser tsv(lines);
-
-  if (tsv.selectSection("picktab")) {
-    std::string tabLines;
-    tsv >> tabLines;
-    TSVSerialiser tab(tabLines);
-
-    // load active push button
-    std::vector<QPushButton *> buttons{
-        m_zoom,         m_edit,           m_ellipse,   m_rectangle,
-        m_ring_ellipse, m_ring_rectangle, m_free_draw, m_one,
-        m_tube,         m_peak,           m_peakSelect};
-
-    tab.selectLine("ActiveTools");
-    for (auto button : buttons) {
-      bool value;
-      tab >> value;
-      button->setChecked(value);
-    }
-  }
-}
-
-std::string
-MantidQt::MantidWidgets::InstrumentWidgetPickTab::saveToProject() const {
-  TSVSerialiser tsv;
-  TSVSerialiser tab;
-
-  // save active push button
-  std::vector<QPushButton *> buttons{
-      m_zoom,         m_edit,           m_ellipse,   m_rectangle,
-      m_ring_ellipse, m_ring_rectangle, m_free_draw, m_one,
-      m_tube,         m_peak,           m_peakSelect};
-
-  tab.writeLine("ActiveTools");
-  for (auto button : buttons) {
-    tab << button->isChecked();
-  }
-
-  tsv.writeSection("picktab", tab.outputLines());
-  return tsv.outputLines();
-}
-
 } // MantidWidgets
 } // MantidQt
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetRenderTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetRenderTab.cpp
index 4d2f5ba028e..1a8e6167024 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetRenderTab.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetRenderTab.cpp
@@ -769,63 +769,64 @@ MantidQt::MantidWidgets::InstrumentWidgetRenderTab::saveToProject() const {
 void InstrumentWidgetRenderTab::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
 
-  if (tsv.selectSection("rendertab")) {
-    std::string tabLines;
-    tsv >> tabLines;
-    TSVSerialiser tab(tabLines);
-
-    bool autoScaling, displayAxes, flipView, displayDetectorsOnly,
-        displayWireframe, displayLighting, useOpenGL, useUCorrection;
-    int axesView;
-
-    tab.selectLine("AxesView");
-    tab >> axesView;
-    tab.selectLine("AutoScaling");
-    tab >> autoScaling;
-    tab.selectLine("DisplayAxes");
-    tab >> displayAxes;
-    tab.selectLine("FlipView");
-    tab >> flipView;
-    tab.selectLine("DisplayDetectorsOnly");
-    tab >> displayDetectorsOnly;
-    tab.selectLine("DisplayWireframe");
-    tab >> displayWireframe;
-    tab.selectLine("DisplayLighting");
-    tab >> displayLighting;
-    tab.selectLine("UseOpenGL");
-    tab >> useOpenGL;
-    tab.selectLine("UseUCorrection");
-    tab >> useUCorrection;
-
-    mAxisCombo->setCurrentIndex(axesView);
-    m_autoscaling->setChecked(autoScaling);
-    m_displayAxes->setChecked(displayAxes);
-    m_flipCheckBox->setChecked(flipView);
-    m_displayDetectorsOnly->setChecked(displayDetectorsOnly);
-    m_wireframe->setChecked(displayWireframe);
-    m_lighting->setChecked(displayLighting);
-    m_GLView->setChecked(useOpenGL);
-    m_UCorrection->setChecked(useUCorrection);
-
-    // peak options
-    auto surface = getSurface();
-    bool showLabels, showRows, showRelativeIntensity;
-    int labelPrecision;
-
-    tab.selectLine("ShowLabels");
-    tab >> showLabels;
-    tab.selectLine("ShowRows");
-    tab >> showRows;
-    tab.selectLine("LabelPrecision");
-    tab >> labelPrecision;
-    tab.selectLine("ShowRelativeIntensity");
-    tab >> showRelativeIntensity;
-
-    surface->setShowPeakLabelsFlag(showLabels);
-    surface->setShowPeakRowsFlag(showRows);
-    surface->setPeakLabelPrecision(labelPrecision);
-    surface->setShowPeakRelativeIntensityFlag(showRelativeIntensity);
-  }
+  if (!tsv.selectSection("rendertab"))
+    return;
+
+  std::string tabLines;
+  tsv >> tabLines;
+  TSVSerialiser tab(tabLines);
+
+  bool autoScaling, displayAxes, flipView, displayDetectorsOnly,
+      displayWireframe, displayLighting, useOpenGL, useUCorrection;
+  int axesView;
+
+  tab.selectLine("AxesView");
+  tab >> axesView;
+  tab.selectLine("AutoScaling");
+  tab >> autoScaling;
+  tab.selectLine("DisplayAxes");
+  tab >> displayAxes;
+  tab.selectLine("FlipView");
+  tab >> flipView;
+  tab.selectLine("DisplayDetectorsOnly");
+  tab >> displayDetectorsOnly;
+  tab.selectLine("DisplayWireframe");
+  tab >> displayWireframe;
+  tab.selectLine("DisplayLighting");
+  tab >> displayLighting;
+  tab.selectLine("UseOpenGL");
+  tab >> useOpenGL;
+  tab.selectLine("UseUCorrection");
+  tab >> useUCorrection;
+
+  mAxisCombo->setCurrentIndex(axesView);
+  m_autoscaling->setChecked(autoScaling);
+  m_displayAxes->setChecked(displayAxes);
+  m_flipCheckBox->setChecked(flipView);
+  m_displayDetectorsOnly->setChecked(displayDetectorsOnly);
+  m_wireframe->setChecked(displayWireframe);
+  m_lighting->setChecked(displayLighting);
+  m_GLView->setChecked(useOpenGL);
+  m_UCorrection->setChecked(useUCorrection);
+
+  // peak options
+  auto surface = getSurface();
+  bool showLabels, showRows, showRelativeIntensity;
+  int labelPrecision;
+
+  tab.selectLine("ShowLabels");
+  tab >> showLabels;
+  tab.selectLine("ShowRows");
+  tab >> showRows;
+  tab.selectLine("LabelPrecision");
+  tab >> labelPrecision;
+  tab.selectLine("ShowRelativeIntensity");
+  tab >> showRelativeIntensity;
+
+  surface->setShowPeakLabelsFlag(showLabels);
+  surface->setShowPeakRowsFlag(showRows);
+  surface->setPeakLabelPrecision(labelPrecision);
+  surface->setShowPeakRelativeIntensityFlag(showRelativeIntensity);
 
   m_colorMapWidget->loadFromProject(lines);
 }
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetTreeTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetTreeTab.cpp
index e195608ea2a..49a87889887 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetTreeTab.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetTreeTab.cpp
@@ -61,25 +61,30 @@ void InstrumentWidgetTreeTab::showEvent(QShowEvent *) {
   getSurface()->setInteractionMode(ProjectionSurface::MoveMode);
 }
 
-void MantidQt::MantidWidgets::InstrumentWidgetTreeTab::loadFromProject(
-    const std::string &lines) {
+/** Load tree tab state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ */
+void InstrumentWidgetTreeTab::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
 
-  if (tsv.selectSection("treetab")) {
-    std::string tabLines;
-    tsv >> tabLines;
-    TSVSerialiser tab(tabLines);
+  if (!tsv.selectSection("treetab"))
+    return;
+
+  std::string tabLines;
+  tsv >> tabLines;
+  TSVSerialiser tab(tabLines);
 
-    std::string componentName;
-    if (tab.selectLine("SelectedComponent")) {
-      tab >> componentName;
-      selectComponentByName(QString::fromStdString(componentName));
-    }
+  std::string componentName;
+  if (tab.selectLine("SelectedComponent")) {
+    tab >> componentName;
+    selectComponentByName(QString::fromStdString(componentName));
   }
 }
 
-std::string
-MantidQt::MantidWidgets::InstrumentWidgetTreeTab::saveToProject() const {
+/** Save the state of the tree tab to a Mantid project file
+ * @return a string representing the state of the tree tab
+ */
+std::string InstrumentWidgetTreeTab::saveToProject() const {
   TSVSerialiser tsv;
   TSVSerialiser tab;
 
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/MaskBinsData.cpp b/MantidQt/MantidWidgets/src/InstrumentView/MaskBinsData.cpp
index da88afc265d..2e69849a1f7 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/MaskBinsData.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/MaskBinsData.cpp
@@ -58,6 +58,9 @@ void MaskBinsData::subtractIntegratedSpectra(
 /// Clear the masking data
 void MaskBinsData::clear() { m_masks.clear(); }
 
+/** Load mask bins state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ */
 void MaskBinsData::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
   for (auto &maskLines : tsv.sections("Mask")) {
@@ -78,6 +81,9 @@ void MaskBinsData::loadFromProject(const std::string &lines) {
   }
 }
 
+/** Save the state of the mask bins to a Mantid project file
+ * @return a string representing the state of the mask bins
+ */
 std::string MaskBinsData::saveToProject() const {
   TSVSerialiser tsv;
   for (const auto &binMask : m_masks) {
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp b/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp
index d5b8501a9a8..14db847c059 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp
@@ -462,6 +462,9 @@ void Projection3D::setLightingModel(bool picking) const {
   }
 }
 
+/** Load 3D projection state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ */
 void Projection3D::loadFromProject(const std::string &lines)
 {
   ProjectionSurface::loadFromProject(lines);
@@ -474,6 +477,9 @@ void Projection3D::loadFromProject(const std::string &lines)
   }
 }
 
+/** Save the state of the 3D projection to a Mantid project file
+ * @return a string representing the state of the 3D projection
+ */
 std::string Projection3D::saveToProject() const
 {
   TSVSerialiser tsv;
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp b/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp
index 15ac81985da..46bb81d9488 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp
@@ -718,8 +718,10 @@ QStringList ProjectionSurface::getPeaksWorkspaceNames() const {
   return names;
 }
 
-void MantidQt::MantidWidgets::ProjectionSurface::loadFromProject(const std::string &lines)
-{
+/** Load projection surface state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ */
+void ProjectionSurface::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
 
   if (tsv.selectLine("BackgroundColor")) {
@@ -733,8 +735,10 @@ void MantidQt::MantidWidgets::ProjectionSurface::loadFromProject(const std::stri
   }
 }
 
-std::string MantidQt::MantidWidgets::ProjectionSurface::saveToProject() const
-{
+/** Save the state of the projection surface to a Mantid project file
+ * @return a string representing the state of the projection surface
+ */
+std::string ProjectionSurface::saveToProject() const {
   TSVSerialiser tsv;
   tsv.writeLine("BackgroundColor") << m_backgroundColor;
   tsv.writeSection("shapes", m_maskShapes.saveToProject());
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp b/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp
index 8889c7792bf..3d07af8e647 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp
@@ -155,53 +155,76 @@ bool Shape2D::isMasked(const QPointF &p) const {
   return m_fill_color != QColor() && contains(p);
 }
 
-
+/** Load shape 2D state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ * @return a new shape2D with old state applied
+ */
 Shape2D* Shape2D::loadFromProject(const std::string &lines)
 {
   TSVSerialiser tsv(lines);
-  Shape2D *shape = nullptr;
 
-  if(tsv.selectLine("Type")) {
-    std::string type;
-    tsv >> type;
-
-    if(type == "ellipse") {
-      shape = Shape2DEllipse::loadFromProject(lines);
-    } else if (type == "rectangle") {
-      shape = Shape2DRectangle::loadFromProject(lines);
-    } else if (type == "ring") {
-      shape = Shape2DRing::loadFromProject(lines);
-    } else if (type == "free") {
-      shape = Shape2DFree::loadFromProject(lines);
-    }
+  if (!tsv.selectLine("Type"))
+    return nullptr;
 
-    if(shape && tsv.selectLine("Properties")) {
-      bool scalable, editing, selected, visible;
-      tsv >> scalable >> editing >> selected >> visible;
+  std::string type;
+  tsv >> type;
 
-      shape->setScalable(scalable);
-      shape->edit(editing);
-      shape->setSelected(selected);
-      shape->setVisible(visible);
-    }
+  Shape2D *shape = loadShape2DFromType(type, lines);
+  if (!shape)
+    return nullptr;
 
-    if(shape && tsv.selectLine("Color")) {
-      int r, g, b, a;
-      tsv >> r >> g >> b >> a;
-      QColor color(r, g, b, a);
-      shape->setColor(color);
-    }
+  if (tsv.selectLine("Properties")) {
+    bool scalable, editing, selected, visible;
+    tsv >> scalable >> editing >> selected >> visible;
 
-    if(shape && tsv.selectLine("FillColor")) {
-      int r, g, b, a;
-      tsv >> r >> g >> b >> a;
-      QColor color(r, g, b, a);
-      shape->setFillColor(color);
-    }
+    shape->setScalable(scalable);
+    shape->edit(editing);
+    shape->setSelected(selected);
+    shape->setVisible(visible);
+  }
+
+  if (tsv.selectLine("Color")) {
+    QColor color;
+    tsv >> color;
+    shape->setColor(color);
+  }
+
+  if (tsv.selectLine("FillColor")) {
+    QColor color;
+    tsv >> color;
+    shape->setFillColor(color);
   }
+
+  return shape;
+}
+
+/**
+ * Instantiate different types of Shape2D from a string
+ *
+ * @param type :: a string representing the type e.g. ellipse
+ * @param lines :: Mantid project lines to parse state from
+ * @return a new instance of a Shape2D
+ */
+Shape2D *Shape2D::loadShape2DFromType(const std::string &type,
+                                      const std::string &lines) {
+  Shape2D *shape = nullptr;
+
+  if (type == "ellipse") {
+    shape = Shape2DEllipse::loadFromProject(lines);
+  } else if (type == "rectangle") {
+    shape = Shape2DRectangle::loadFromProject(lines);
+  } else if (type == "ring") {
+    shape = Shape2DRing::loadFromProject(lines);
+  } else if (type == "free") {
+    shape = Shape2DFree::loadFromProject(lines);
+  }
+
   return shape;
 }
 
+/** Save the state of the shape 2D to a Mantid project file
+ * @return a string representing the state of the shape 2D
+ */
 std::string Shape2D::saveToProject() const
 {
   TSVSerialiser tsv;
@@ -217,12 +240,10 @@ std::string Shape2D::saveToProject() const
   }
 
   auto color = getColor();
-  tsv.writeLine("Color");
-  tsv << color.red() << color.green() << color.blue() << color.alpha();
+  tsv.writeLine("Color") << color;
 
   auto fillColor = getFillColor();
-  tsv.writeLine("FillColor");
-  tsv << fillColor.red() << fillColor.green() << fillColor.blue() << fillColor.alpha();
+  tsv.writeLine("FillColor") << fillColor;
 
   return tsv.outputLines();
 }
@@ -333,6 +354,10 @@ void Shape2DEllipse::setPoint(const QString &prop, const QPointF &value) {
   }
 }
 
+/** Load shape 2D state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ * @return a new shape2D in the shape of a ellipse
+ */
 Shape2D* Shape2DEllipse::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
   tsv.selectLine("Parameters");
@@ -341,6 +366,9 @@ Shape2D* Shape2DEllipse::loadFromProject(const std::string &lines) {
   return new Shape2DEllipse(QPointF(x, y), radius1, radius2);
 }
 
+/** Save the state of the shape 2D ellipe to a Mantid project file
+ * @return a string representing the state of the shape 2D
+ */
 std::string Shape2DEllipse::saveToProject() const
 {
   TSVSerialiser tsv;
@@ -391,6 +419,10 @@ void Shape2DRectangle::addToPath(QPainterPath &path) const {
   path.addRect(m_boundingRect.toQRectF());
 }
 
+/** Load shape 2D state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ * @return a new shape2D in the shape of a rectangle
+ */
 Shape2D* Shape2DRectangle::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
   tsv.selectLine("Parameters");
@@ -401,6 +433,9 @@ Shape2D* Shape2DRectangle::loadFromProject(const std::string &lines) {
   return new Shape2DRectangle(point1, point2);
 }
 
+/** Save the state of the shape 2D rectangle to a Mantid project file
+ * @return a string representing the state of the shape 2D
+ */
 std::string Shape2DRectangle::saveToProject() const
 {
   TSVSerialiser tsv;
@@ -554,7 +589,10 @@ void Shape2DRing::setColor(const QColor &color) {
   m_outer_shape->setColor(color);
 }
 
-
+/** Load shape 2D state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ * @return a new shape2D in the shape of a ring
+ */
 Shape2D* Shape2DRing::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
   tsv.selectLine("Parameters");
@@ -569,6 +607,9 @@ Shape2D* Shape2DRing::loadFromProject(const std::string &lines) {
   return new Shape2DRing(baseShape, xWidth, yWidth);
 }
 
+/** Save the state of the shape 2D ring to a Mantid project file
+ * @return a string representing the state of the shape 2D
+ */
 std::string Shape2DRing::saveToProject() const
 {
   TSVSerialiser tsv;
@@ -717,6 +758,10 @@ void Shape2DFree::subtractPolygon(const QPolygonF &polygon) {
   resetBoundingRect();
 }
 
+/** Load shape 2D state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ * @return a new freefrom shape2D
+ */
 Shape2D* Shape2DFree::loadFromProject(const std::string &lines) {
   TSVSerialiser tsv(lines);
   QPolygonF polygon;
@@ -733,6 +778,9 @@ Shape2D* Shape2DFree::loadFromProject(const std::string &lines) {
   return new Shape2DFree(polygon);
 }
 
+/** Save the state of the shape 2D to a Mantid project file
+ * @return a string representing the state of the shape 2D
+ */
 std::string Shape2DFree::saveToProject() const
 {
   TSVSerialiser tsv;
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp b/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp
index 297f1745ad3..26d15460209 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp
@@ -665,6 +665,9 @@ void Shape2DCollection::eraseFree(const QPolygonF &polygon) {
   }
 }
 
+/** Load shape 2D collection state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ */
 void Shape2DCollection::loadFromProject(const std::string &lines)
 {
   TSVSerialiser tsv(lines);
@@ -674,6 +677,9 @@ void Shape2DCollection::loadFromProject(const std::string &lines)
   }
 }
 
+/** Save the state of the shape 2D collection to a Mantid project file
+ * @return a string representing the state of the shape 2D collection
+ */
 std::string Shape2DCollection::saveToProject() const
 {
   TSVSerialiser tsv;
diff --git a/MantidQt/MantidWidgets/src/InstrumentView/UnwrappedSurface.cpp b/MantidQt/MantidWidgets/src/InstrumentView/UnwrappedSurface.cpp
index 8cbffebd440..ebec8df7298 100644
--- a/MantidQt/MantidWidgets/src/InstrumentView/UnwrappedSurface.cpp
+++ b/MantidQt/MantidWidgets/src/InstrumentView/UnwrappedSurface.cpp
@@ -717,6 +717,9 @@ void UnwrappedSurface::calcSize(UnwrappedDetector &udet) {
     m_height_max = udet.height;
 }
 
+/** Load unwrapped surface state from a Mantid project file
+ * @param lines :: lines from the project file to load state from
+ */
 void UnwrappedSurface::loadFromProject(const std::string &lines) {
   ProjectionSurface::loadFromProject(lines);
   TSVSerialiser tsv(lines);
@@ -744,6 +747,30 @@ void UnwrappedSurface::loadFromProject(const std::string &lines) {
   }
 }
 
+/**
+ * Get a peaks workspace from the ADS
+ * @param name :: name of the workspace to retrieve
+ * @return a shared pointer to the fond peaks workspace
+ */
+Mantid::API::IPeaksWorkspace_sptr
+UnwrappedSurface::retrievePeaksWorkspace(const std::string &name) const {
+  using namespace Mantid::API;
+  Workspace_sptr ws = nullptr;
+
+  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<IPeaksWorkspace>(ws);
+}
+
+/** Save the state of the unwrapped surface to a Mantid project file
+ * @return a string representing the state of the surface
+ */
 std::string UnwrappedSurface::saveToProject() const {
   TSVSerialiser tsv;
   tsv.writeRaw(ProjectionSurface::saveToProject());
@@ -760,19 +787,5 @@ std::string UnwrappedSurface::saveToProject() const {
   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
-- 
GitLab