From c72315bdf5cff61185e3fa5959f221c23b86067c Mon Sep 17 00:00:00 2001
From: Jose Borreguero <borreguero@gmail.com>
Date: Sat, 6 Feb 2016 17:17:44 -0500
Subject: [PATCH] Refs #14936 replace MWSpectrogram with MWView

---
 MantidQt/API/CMakeLists.txt                   | 10 +--
 .../DynamicPDF/SliceSelector.h                | 10 +--
 .../src/DynamicPDF/SliceSelector.cpp          | 10 ++-
 MantidQt/MantidWidgets/CMakeLists.txt         |  5 +-
 .../inc/MantidQtMantidWidgets/MWSpectrogram.h | 70 -------------------
 .../inc/MantidQtMantidWidgets/MWView.h        | 70 +++++++++++++++++++
 .../inc/MantidQtMantidWidgets/MWView.ui       |  0
 MantidQt/MantidWidgets/src/MWSpectrogram.cpp  | 66 -----------------
 MantidQt/MantidWidgets/src/MWView.cpp         | 16 +++++
 9 files changed, 101 insertions(+), 156 deletions(-)
 delete mode 100644 MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWSpectrogram.h
 create mode 100644 MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWView.h
 create mode 100644 MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWView.ui
 delete mode 100644 MantidQt/MantidWidgets/src/MWSpectrogram.cpp
 create mode 100644 MantidQt/MantidWidgets/src/MWView.cpp

diff --git a/MantidQt/API/CMakeLists.txt b/MantidQt/API/CMakeLists.txt
index 035ec660328..e7b70d31c42 100644
--- a/MantidQt/API/CMakeLists.txt
+++ b/MantidQt/API/CMakeLists.txt
@@ -29,7 +29,8 @@
 	src/PythonRunner.cpp
 	src/PythonThreading.cpp
 	src/QtSignalChannel.cpp
-	src/QwtRasterDataMD.cpp
+        src/QwtRasterDataMD.cpp
+        src/QwtRasterDataMW.cpp
 	src/QwtWorkspaceBinData.cpp
 	src/QwtWorkspaceSpectrumData.cpp
 	src/RepoModel.cpp
@@ -82,7 +83,7 @@ set ( INC_FILES
 	inc/MantidQtAPI/DllOption.h
 	inc/MantidQtAPI/FileDialogHandler.h
 	inc/MantidQtAPI/GraphOptions.h
-    inc/MantidQtAPI/DistributionOptions.h
+        inc/MantidQtAPI/DistributionOptions.h
 	inc/MantidQtAPI/HelpWindow.h
 	inc/MantidQtAPI/InterfaceFactory.h
 	inc/MantidQtAPI/InterfaceManager.h
@@ -98,8 +99,9 @@ set ( INC_FILES
 	inc/MantidQtAPI/PropertyWidgetFactory.h
 	inc/MantidQtAPI/PythonSystemHeader.h
 	inc/MantidQtAPI/PythonThreading.h
-	inc/MantidQtAPI/QwtRasterDataMD.h
-	inc/MantidQtAPI/QwtWorkspaceBinData.h
+        inc/MantidQtAPI/QwtRasterDataMD.h
+        inc/MantidQtAPI/QwtRasterDataMW.h
+        inc/MantidQtAPI/QwtWorkspaceBinData.h
 	inc/MantidQtAPI/QwtWorkspaceSpectrumData.h
 	inc/MantidQtAPI/ScaleEngine.h
 	inc/MantidQtAPI/ScriptRepositoryView.h
diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/DynamicPDF/SliceSelector.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/DynamicPDF/SliceSelector.h
index d0db0815395..57793adb998 100644
--- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/DynamicPDF/SliceSelector.h
+++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/DynamicPDF/SliceSelector.h
@@ -8,7 +8,7 @@
 
 namespace MantidQt {
 namespace MantidWidgets {
-  class SafeQwtPlot;
+  class MWSpectrogram;
 }
 namespace CustomInterfaces {
 namespace DynamicPDF {
@@ -29,12 +29,6 @@ public:
   std::string m_label;
 };
 
-/// A wrapper for all elements associated to the 2D view
-struct slices2DviewStruct {
-  MantidQt::MantidWidgets::MWSpectrogram* plot2D;
-  QwtPlotSpectrogram* spectrogram;
-};
-
 class MANTIDQT_CUSTOMINTERFACES_DLL SliceSelector
     : public MantidQt::API::UserSubWindow {
   Q_OBJECT
@@ -65,7 +59,7 @@ private:
   void initLayout();
   /// The form generated by Qt Designer
   Ui::SliceSelector m_uiForm;
-  slices2DviewStruct m_view2D;
+  MantidQt::MantidWidgets::MWSpectrogram* m_plot2D;
   boost::shared_ptr<WorkspaceRecord> m_loadedWorkspace;
   size_t m_selectedWorkspaceIndex;
   /// The child dialog to remove the multiphonon background
diff --git a/MantidQt/CustomInterfaces/src/DynamicPDF/SliceSelector.cpp b/MantidQt/CustomInterfaces/src/DynamicPDF/SliceSelector.cpp
index 364a82c6774..03094760b56 100644
--- a/MantidQt/CustomInterfaces/src/DynamicPDF/SliceSelector.cpp
+++ b/MantidQt/CustomInterfaces/src/DynamicPDF/SliceSelector.cpp
@@ -41,7 +41,7 @@ DECLARE_SUBWINDOW(SliceSelector)
 // SliceSelector::SliceSelector(QWidget *parent) : UserSubWindow{parent},
 // m_loadedWorkspace{nullptr}, m_BackgroundRemover{nullptr} {
 SliceSelector::SliceSelector(QWidget *parent)
-    : UserSubWindow{parent}, m_view2D{nullptr,nullptr},
+    : UserSubWindow{parent}, m_plot2D{nullptr},
       m_loadedWorkspace{nullptr} {}
 
 SliceSelector::~SliceSelector() { m_selectedWorkspaceIndex = 0; }
@@ -85,11 +85,9 @@ void SliceSelector::loadSlices(const QString &workspaceName) {
   m_uiForm.spinboxSliceSelector->setValue(0);
 
   /// initialize the 2D view of the histogram;
-  m_view2D.plot2D = m_uiForm.slices2DPlot;
-  m_view2D.spectrogram = new QwtPlotSpectrogram();
-  m_view2D.spectrogram->attach(m_view2D.plot2D);
-  m_view2D.plot2D->setWorkspace(m_loadedWorkspace->m_ws);
-  m_view2D.plot2D->replot();
+  m_plot2D = m_uiForm.slices2DPlot;
+  m_plot2D->setWorkspace(m_loadedWorkspace->m_ws);
+  m_plot2D->updateDisplay();
 
   /// initialize the preview plot
   updatePlotSelectedSlice();
diff --git a/MantidQt/MantidWidgets/CMakeLists.txt b/MantidQt/MantidWidgets/CMakeLists.txt
index 837080244e9..0f3f1ec5124 100644
--- a/MantidQt/MantidWidgets/CMakeLists.txt
+++ b/MantidQt/MantidWidgets/CMakeLists.txt
@@ -22,8 +22,8 @@ set ( SRC_FILES
     src/InputController.cpp
     src/MantidHelpWindow.cpp
     src/MWDiag.cpp
-    src/MWSpectrogram.cpp
     src/MWRunFiles.cpp
+    src/MWView.cpp
     src/MessageDisplay.cpp
     src/MultifitSetupDialog.cpp
     src/MuonFitPropertyBrowser.cpp
@@ -125,8 +125,8 @@ set ( MOC_FILES
     inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h
     inc/MantidQtMantidWidgets/MuonSequentialFitDialog.h
     inc/MantidQtMantidWidgets/MWDiag.h
-    inc/MantidQtMantidWidgets/MWSpectrogram.h
     inc/MantidQtMantidWidgets/MWRunFiles.h
+    inc/MantidQtMantidWidgets/MWView.h
     inc/MantidQtMantidWidgets/PeakPicker.h
     inc/MantidQtMantidWidgets/PeriodicTableWidget.h
     inc/MantidQtMantidWidgets/pqHelpWindow.h
@@ -237,6 +237,7 @@ set ( UI_FILES
     inc/MantidQtMantidWidgets/IndirectInstrumentConfig.ui
     inc/MantidQtMantidWidgets/MWDiag.ui
     inc/MantidQtMantidWidgets/MWRunFiles.ui
+    inc/MantidQtMantidWidgets/MWView.ui
     inc/MantidQtMantidWidgets/MultifitSetupDialog.ui
     inc/MantidQtMantidWidgets/MuonSequentialFitDialog.ui
     inc/MantidQtMantidWidgets/ProcessingAlgoWidget.ui
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWSpectrogram.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWSpectrogram.h
deleted file mode 100644
index 85558f7500d..00000000000
--- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWSpectrogram.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef MANTID_MANTIDWIDGETS_MWSPECTROGRAM_H_
-#define MANTID_MANTIDWIDGETS_MWSPECTROGRAM_H_
-
-#include "MantidQtMantidWidgets/WidgetDllOption.h"
-#include <qwt_plot.h>
-#include <qpainter.h>
-#include "qwt_text.h"
-#include "MantidAPI/MatrixWorkspace_fwd.h"
-#include "WidgetDllOption.h"
-
-namespace MantidQt
-{
-namespace MantidWidgets
-{
-
-  /** A version of QwtPlot that adds a layer of thread safety.
-   *
-   * Each SafeQwtPlot has a workspace associated with it.
-   * Before drawing, it acquires a ReadLock to prevent
-   * an algorithm from modifying the underlying workspace while it is
-   * drawing.
-   *
-   * If no workspace is set, no drawing occurs (silently).
-    
-    @date 2012-01-24
-
-    Copyright &copy; 2012 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source
-
-    This file is part of Mantid.
-
-    Mantid is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 3 of the License, or
-    (at your option) any later version.
-
-    Mantid is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-    File change history is stored at: <https://github.com/mantidproject/mantid>
-    Code Documentation is available at: <http://doxygen.mantidproject.org>
-  */
-  class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS MWSpectrogram : public QwtPlot
-  {
-    Q_OBJECT
-
-  public:
-    explicit MWSpectrogram(QWidget * parent = NULL);
-    explicit MWSpectrogram(const QwtText &title, QWidget *p = NULL);
-
-    virtual ~MWSpectrogram();
-    
-    virtual void drawCanvas(QPainter * painter);
-
-    void setWorkspace(Mantid::API::MatrixWorkspace_sptr ws);
-
-  private:
-    /// Workspace being read-locked
-    Mantid::API::MatrixWorkspace_sptr m_ws;
-  };
-
-
-} // namespace MantidWidgets
-} // namespace MantidQt
-
-#endif  /* MANTID_MANTIDWIDGETS_MWSPECTROGRAM_H_ */
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWView.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWView.h
new file mode 100644
index 00000000000..7c61cc9feae
--- /dev/null
+++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWView.h
@@ -0,0 +1,70 @@
+#ifndef MANTID_MANTIDWIDGETS_MWVIEW_H_
+#define MANTID_MANTIDWIDGETS_MWVIEW_H_
+
+#include "MantidQtMantidWidgets/WidgetDllOption.h"
+#include "MantidAPI/MatrixWorkspace_fwd.h"
+#include "WidgetDllOption.h"
+
+#include <qwt_plot.h>
+#include <qpainter.h>
+#include "qwt_text.h"
+#include <qwt_plot_spectrogram.h>
+#include <qwt_raster_data.h>
+
+
+namespace MantidQt {
+
+namespace API {
+class QwtRasterDataMW;
+}
+
+namespace MantidWidgets {
+
+
+/** A viewer for a Matrix Workspace.
+ *
+ * Before drawing, it acquires a ReadLock to prevent
+ * an algorithm from modifying the underlying workspace while it is
+ * drawing.
+ *
+ * If no workspace is set, no drawing occurs (silently).
+
+  @date 2016-02-05
+
+  Copyright &copy; 2012 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
+ National Laboratory & European Spallation Source
+
+  This file is part of Mantid.
+
+  Mantid is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  Mantid is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  File change history is stored at: <https://github.com/mantidproject/mantid>
+  Code Documentation is available at: <http://doxygen.mantidproject.org>
+*/
+class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS MWView : public QWidget {
+  Q_OBJECT
+
+public:
+
+protected:
+
+private:
+
+
+};
+
+} // namespace MantidWidgets
+} // namespace MantidQt
+
+#endif /* MANTID_MANTIDWIDGETS_MWVIEW_H_ */
diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWView.ui b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWView.ui
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/MantidQt/MantidWidgets/src/MWSpectrogram.cpp b/MantidQt/MantidWidgets/src/MWSpectrogram.cpp
deleted file mode 100644
index 70d99deff32..00000000000
--- a/MantidQt/MantidWidgets/src/MWSpectrogram.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "MantidQtMantidWidgets/MWSpectrogram.h"
-#include "MantidAPI/MatrixWorkspace.h"
-#include "MantidKernel/System.h"
-#include "MantidKernel/ReadLock.h"
-
-
-namespace MantidQt
-{
-namespace MantidWidgets
-{
-
-
-  //----------------------------------------------------------------------------------------------
-  /** Constructor
-   */
-  MWSpectrogram::MWSpectrogram(QWidget * parent)
-  : QwtPlot(parent)
-  {
-  }
-
-
-  //----------------------------------------------------------------------------------------------
-  /** Constructor
-   */
-  MWSpectrogram::MWSpectrogram(const QwtText &title, QWidget * parent)
-  : QwtPlot(title, parent)
-  {
-  }
-    
-  //----------------------------------------------------------------------------------------------
-  /** Destructor
-   */
-  MWSpectrogram::~MWSpectrogram()
-  {
-  }
-  
-
-  //----------------------------------------------------------------------------------------------
-  /** Set the workspace that we read-lock when drawing.
-   *
-   * @param ws :: shared ptr to workspace
-   */
-  void MWSpectrogram::setWorkspace(Mantid::API::MatrixWorkspace_sptr ws)
-  {
-    m_ws = ws;
-  }
-
-  //----------------------------------------------------------------------------------------------
-  /** Overridden drawCanvas() that protects the
-   * workspace from being overwritten while being drawn
-   *
-   * @param painter :: QPainter
-   */
-  void MWSpectrogram::drawCanvas(QPainter * painter)
-  {
-    // Do nothing if the workspace is not valid.
-    if (!m_ws) return;
-    // Get the scoped read lock.
-    Mantid::Kernel::ReadLock lock(*m_ws);
-    // Draw using the usual procedure.
-    QwtPlot::drawCanvas(painter);
-    // lock is released when it goes out of scope.
-  }
-
-} // namespace MantidQt
-} // namespace MantidWidgets
diff --git a/MantidQt/MantidWidgets/src/MWView.cpp b/MantidQt/MantidWidgets/src/MWView.cpp
new file mode 100644
index 00000000000..ea3a6bbb10f
--- /dev/null
+++ b/MantidQt/MantidWidgets/src/MWView.cpp
@@ -0,0 +1,16 @@
+#include "MantidQtMantidWidgets/MWView.h"
+#include "MantidAPI/MatrixWorkspace.h"
+#include "MantidKernel/System.h"
+#include "MantidKernel/ReadLock.h"
+
+#include "MantidQtAPI/QwtRasterDataMD.h"
+#include "MantidQtAPI/MantidColorMap.h"
+#include <qwt_color_map.h>
+
+namespace MantidQt {
+namespace MantidWidgets {
+
+
+
+} // namespace MantidQt
+} // namespace MantidWidgets
-- 
GitLab