diff --git a/MantidPlot/CMakeLists.txt b/MantidPlot/CMakeLists.txt index 4f616470ce3d44232c3bb2f45b0858cdde66abf1..10cca32934b8b76e1f7632b0e85fdf8533a38b38 100644 --- a/MantidPlot/CMakeLists.txt +++ b/MantidPlot/CMakeLists.txt @@ -134,6 +134,7 @@ set ( QTIPLOT_SRCS src/ApplicationWindow.cpp src/TSVSerialiser.cpp src/UserFunction.cpp src/VectorCurve.cpp + src/WindowFactory.cpp src/origin/OPJFile.cpp src/plot2D/ImageSymbol.cpp src/analysis/fft2D.cpp @@ -335,6 +336,7 @@ set ( QTIPLOT_HDRS src/ApplicationWindow.h src/TSVSerialiser.h src/UserFunction.h src/VectorCurve.h + src/WindowFactory.h src/analysis/fft2D.h src/origin/OPJFile.h src/plot2D/ImageSymbol.h diff --git a/MantidPlot/src/Graph3D.h b/MantidPlot/src/Graph3D.h index f16fa32ea3ceccbf7df43c5c4861af3909055a31..71da00caaf88d0cab448d99fce5e46f74aa74378 100644 --- a/MantidPlot/src/Graph3D.h +++ b/MantidPlot/src/Graph3D.h @@ -60,7 +60,7 @@ class Function2D; // Mantid *directly to a file, so they * can't be combined with output generated via QPrinter. */ -class Graph3D : public MdiSubWindow, public Mantid::IProjectSerialisable { +class Graph3D : public MdiSubWindow { Q_OBJECT public: diff --git a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h index 51580e7aea3c1c86dfced0222fe0ad20e0762323..5a9a81fb51d7f7c5b1b46704e6f874d3bc6eadf1 100644 --- a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h +++ b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h @@ -17,8 +17,7 @@ class InstrumentWidgetTab; } } -class InstrumentWindow : public MdiSubWindow, - public Mantid::IProjectSerialisable { +class InstrumentWindow : public MdiSubWindow { Q_OBJECT public: explicit InstrumentWindow(const QString &wsName, diff --git a/MantidPlot/src/Mantid/MantidMatrix.h b/MantidPlot/src/Mantid/MantidMatrix.h index ce5d6c13c16e792b86ac6ad404318e36522b3d63..19b8c7eed8a1a6e4e417c80a5a60d3bb11164706 100644 --- a/MantidPlot/src/Mantid/MantidMatrix.h +++ b/MantidPlot/src/Mantid/MantidMatrix.h @@ -9,7 +9,6 @@ #include "MantidMatrixModel.h" #include "MantidMatrixTabExtension.h" -#include "Mantid/IProjectSerialisable.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/MatrixWorkspace_fwd.h" @@ -84,8 +83,7 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> */ class MantidMatrix : public MdiSubWindow, - MantidQt::API::WorkspaceObserver, - public Mantid::IProjectSerialisable { + MantidQt::API::WorkspaceObserver { Q_OBJECT public: diff --git a/MantidPlot/src/Matrix.h b/MantidPlot/src/Matrix.h index 2b7c69c300f945cac1828db56f6f2337569d6c6a..b69e3cbebe470cb557d3eb9f6762399b7fe56ad8 100644 --- a/MantidPlot/src/Matrix.h +++ b/MantidPlot/src/Matrix.h @@ -62,8 +62,7 @@ class QUndoStack; //! Matrix worksheet class class Matrix : public MdiSubWindow, - public Scripted, - public Mantid::IProjectSerialisable { + public Scripted { Q_OBJECT protected: diff --git a/MantidPlot/src/MdiSubWindow.cpp b/MantidPlot/src/MdiSubWindow.cpp index 0767cfb722adbc4eb00f630c915cb7db1f82b44c..00e210a68cb57256031bd6ec5d259fd299b87317 100644 --- a/MantidPlot/src/MdiSubWindow.cpp +++ b/MantidPlot/src/MdiSubWindow.cpp @@ -117,6 +117,20 @@ void MdiSubWindow::setLabel(const QString &label) { d_label = label; } +void MdiSubWindow::loadFromProject(const std::string &lines, ApplicationWindow *app, const int fileVersion) +{ + Q_UNUSED(lines); + Q_UNUSED(app); + Q_UNUSED(fileVersion); + throw std::runtime_error("LoadToProject not implemented for raw MdiSubWindow"); +} + +std::string MdiSubWindow::saveToProject(ApplicationWindow *app) +{ + Q_UNUSED(app); + throw std::runtime_error("SaveToProject not implemented for raw MdiSubWindow"); +} + void MdiSubWindow::resizeEvent(QResizeEvent *e) { emit resizedWindow(this); MdiSubWindowParent_t::resizeEvent(e); diff --git a/MantidPlot/src/MdiSubWindow.h b/MantidPlot/src/MdiSubWindow.h index 7bdfcae880bf7f800700a6324923e69f717761e0..7189fbc7a974dde5e72a10bbb76e58b4d3085727 100644 --- a/MantidPlot/src/MdiSubWindow.h +++ b/MantidPlot/src/MdiSubWindow.h @@ -29,6 +29,7 @@ #ifndef MdiSubWindow_H #define MdiSubWindow_H +#include "Mantid/IProjectSerialisable.h" #include <QMdiSubWindow> #include <QDockWidget> #include <QVBoxLayout> @@ -108,7 +109,8 @@ protected: * * \sa Folder, ApplicationWindow */ -class MdiSubWindow : public MdiSubWindowParent_t { +class MdiSubWindow : public MdiSubWindowParent_t, + public Mantid::IProjectSerialisable { Q_OBJECT public: @@ -271,6 +273,11 @@ public: // non-slot methods ///@} /// Set the label property on the widget void setLabel(const QString &label); + /// Loads the given lines from the project file and applies them. + void loadFromProject(const std::string &lines, ApplicationWindow *app, + const int fileVersion) override; + /// Serialises to a string that can be saved to a project file. + std::string saveToProject(ApplicationWindow *app) override; signals: //! Emitted when the window was closed void closedWindow(MdiSubWindow *); diff --git a/MantidPlot/src/MultiLayer.h b/MantidPlot/src/MultiLayer.h index 109d6f94b7010d6dbff7cd1edd397f3b2268ecc9..509567f6fb3be41b14aceec26f5e04e5a9d9dee6 100644 --- a/MantidPlot/src/MultiLayer.h +++ b/MantidPlot/src/MultiLayer.h @@ -72,7 +72,7 @@ class WaterfallFillDialog; *could handle things like creating * tables by calling methods of Project instead of sending signals. */ -class MultiLayer : public MdiSubWindow, public Mantid::IProjectSerialisable { +class MultiLayer : public MdiSubWindow { Q_OBJECT public: diff --git a/MantidPlot/src/Note.h b/MantidPlot/src/Note.h index 0c476ca05a97d0149926126fd9b448598868adcf..6bb569c8eca49dcdaf0cf0c8cf5f5122d3bcabea 100644 --- a/MantidPlot/src/Note.h +++ b/MantidPlot/src/Note.h @@ -41,7 +41,7 @@ class ApplicationWindow; * \section future Future Plans * - Search and replace */ -class Note : public MdiSubWindow, public Mantid::IProjectSerialisable { +class Note : public MdiSubWindow { Q_OBJECT public: diff --git a/MantidPlot/src/ProjectSerialiser.cpp b/MantidPlot/src/ProjectSerialiser.cpp index 60b0afd3635cc7dbfce0df09b2d37ee2669423e8..c76821d1635c76881cc1226708a5ba8f57c992dc 100644 --- a/MantidPlot/src/ProjectSerialiser.cpp +++ b/MantidPlot/src/ProjectSerialiser.cpp @@ -8,6 +8,7 @@ #include "TableStatistics.h" #include "Graph3D.h" +#include "WindowFactory.h" #include "Mantid/MantidMatrix.h" #include "Mantid/MantidUI.h" #include "MantidAPI/MatrixWorkspace.h" diff --git a/MantidPlot/src/Table.h b/MantidPlot/src/Table.h index 6a4d8c795c87a65006b119d85cff08ebcc4ce2e3..59af062b911a9446b98b1cc967e1e6f9fce49995 100644 --- a/MantidPlot/src/Table.h +++ b/MantidPlot/src/Table.h @@ -88,8 +88,7 @@ private: * [ assigned to thzs ] */ class Table : public MdiSubWindow, - public Scripted, - public Mantid::IProjectSerialisable { + public Scripted { Q_OBJECT public: diff --git a/MantidPlot/src/WindowFactory.cpp b/MantidPlot/src/WindowFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ba8cc21dd635cde8b849504e6e9d4c5470c1fcb2 --- /dev/null +++ b/MantidPlot/src/WindowFactory.cpp @@ -0,0 +1,8 @@ +#include "WindowFactory.h" + +using namespace Mantid::API; + +WindowFactoryImpl::WindowFactoryImpl() +{ + +} diff --git a/MantidPlot/src/WindowFactory.h b/MantidPlot/src/WindowFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..2cc0776b5453a2505a2f35870be0d3fd99cb8dad --- /dev/null +++ b/MantidPlot/src/WindowFactory.h @@ -0,0 +1,67 @@ +#ifndef WINDOWFACTORY_H +#define WINDOWFACTORY_H + +//---------------------------------------------------------------------- +// Includes +//---------------------------------------------------------------------- +#include "MantidAPI/DllConfig.h" +#include "MantidKernel/DynamicFactory.h" +#include "MantidKernel/SingletonHolder.h" + +//---------------------------------------------------------------------- +// Forward declarations +//---------------------------------------------------------------------- +class MdiSubWindow; + +namespace Mantid { +namespace API { + +/** The WindowFactory class is in charge of the creation of concrete + instances of MdiSubWindow. It inherits most of its implementation from + the Dynamic Factory base class. + It is implemented as a singleton class. + + @author Samuel Jackson, ISIS Rutherford Appleton Laboratory + @date 11/07/2016 + + Copyright © 2007-2011 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> +*/ + +class MANTID_API_DLL WindowFactoryImpl final : public Kernel::DynamicFactory<MdiSubWindow> { +public: + WindowFactoryImpl(); +}; + +/// Forward declaration of a specialisation of SingletonHolder for +/// AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. +#ifdef _WIN32 +// this breaks new namespace declaraion rules; need to find a better fix +template class MANTID_API_DLL + Mantid::Kernel::SingletonHolder<WindowFactoryImpl>; +#endif /* _WIN32 */ + +typedef MANTID_API_DLL Mantid::Kernel::SingletonHolder<WindowFactoryImpl> + WindowFactory; + +} +} + +#endif // WINDOWFACTORY_H