From 40f1c6e3415c731e9622fb8e40b352a449f56e0e Mon Sep 17 00:00:00 2001 From: Moore <lamar.moore@stfc.ac.uk> Date: Wed, 28 Sep 2016 08:17:48 +0100 Subject: [PATCH] refactored some mantidplot dependencies to MantidQt re #17315 --- MantidPlot/CMakeLists.txt | 16 -- .../src/Mantid/MantidGroupPlotGenerator.cpp | 8 +- .../src/Mantid/MantidGroupPlotGenerator.h | 39 +++-- MantidPlot/src/Mantid/MantidUI.cpp | 122 ++++++++++----- MantidPlot/src/Mantid/MantidUI.h | 12 +- MantidQt/API/CMakeLists.txt | 6 + .../API/inc/MantidQtAPI}/FlowLayout.h | 9 +- .../API/inc/MantidQtAPI}/WorkspaceIcons.h | 14 +- .../API/inc/MantidQtAPI}/pixmaps.h | 13 +- .../API/src}/FlowLayout.cpp | 7 +- .../API/src}/WorkspaceIcons.cpp | 8 +- {MantidPlot => MantidQt/API}/src/pixmaps.cpp | 6 +- MantidQt/MantidWidgets/CMakeLists.txt | 12 +- .../MantidDisplayBase.h | 10 ++ .../MantidSurfacePlotDialog.h | 15 +- .../MantidQtMantidWidgets}/MantidTreeWidget.h | 25 ++- .../MantidTreeWidgetItem.h | 8 +- .../MantidWSIndexDialog.h | 146 ++++++++++-------- .../WorkspacePresenter/IWorkspaceDockView.h | 12 +- .../WorkspacePresenter}/QWorkspaceDockView.h | 46 +++--- .../WorkspaceDockViewMockObjects.h | 10 +- .../WorkspacePresenter/WorkspacePresenter.h | 6 +- .../src}/MantidSurfacePlotDialog.cpp | 15 +- .../MantidWidgets/src}/MantidTreeWidget.cpp | 33 ++-- .../src}/MantidTreeWidgetItem.cpp | 8 +- .../src}/MantidWSIndexDialog.cpp | 18 ++- .../QWorkspaceDockView.cpp | 109 ++++++------- 27 files changed, 440 insertions(+), 293 deletions(-) rename {MantidPlot/src/Mantid => MantidQt/API/inc/MantidQtAPI}/FlowLayout.h (95%) rename {MantidPlot/src/Mantid => MantidQt/API/inc/MantidQtAPI}/WorkspaceIcons.h (64%) rename {MantidPlot/src => MantidQt/API/inc/MantidQtAPI}/pixmaps.h (89%) rename {MantidPlot/src/Mantid => MantidQt/API/src}/FlowLayout.cpp (98%) rename {MantidPlot/src/Mantid => MantidQt/API/src}/WorkspaceIcons.cpp (94%) rename {MantidPlot => MantidQt/API}/src/pixmaps.cpp (99%) rename MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/{WorkspacePresenter => }/MantidDisplayBase.h (93%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/inc/MantidQtMantidWidgets}/MantidSurfacePlotDialog.h (91%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/inc/MantidQtMantidWidgets}/MantidTreeWidget.h (76%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/inc/MantidQtMantidWidgets}/MantidTreeWidgetItem.h (75%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/inc/MantidQtMantidWidgets}/MantidWSIndexDialog.h (78%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter}/QWorkspaceDockView.h (91%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/src}/MantidSurfacePlotDialog.cpp (95%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/src}/MantidTreeWidget.cpp (93%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/src}/MantidTreeWidgetItem.cpp (95%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/src}/MantidWSIndexDialog.cpp (98%) rename {MantidPlot/src/Mantid => MantidQt/MantidWidgets/src/WorkspacePresenter}/QWorkspaceDockView.cpp (95%) diff --git a/MantidPlot/CMakeLists.txt b/MantidPlot/CMakeLists.txt index c77d5eb54fd..a9b6b6acf25 100644 --- a/MantidPlot/CMakeLists.txt +++ b/MantidPlot/CMakeLists.txt @@ -82,7 +82,6 @@ set ( QTIPLOT_SRCS src/ApplicationWindow.cpp src/Note.cpp src/nrutil.cpp src/OpenProjectDialog.cpp - src/pixmaps.cpp src/Plot3DDialog.cpp src/Plot.cpp src/PlotCurve.cpp @@ -165,7 +164,6 @@ set ( MANTID_SRCS src/Mantid/AlgorithmDockWidget.cpp src/Mantid/ErrorBarSettings.cpp src/Mantid/FirstTimeSetup.cpp src/Mantid/FitParameterTie.cpp - src/Mantid/FlowLayout.cpp src/Mantid/IFunctionWrapper.cpp src/Mantid/ImportWorkspaceDlg.cpp src/Mantid/InputHistory.cpp @@ -188,20 +186,14 @@ set ( MANTID_SRCS src/Mantid/AlgorithmDockWidget.cpp src/Mantid/MantidMatrixDialog.cpp src/Mantid/MantidSampleLogDialog.cpp src/Mantid/MantidSampleMaterialDialog.cpp - src/Mantid/MantidSurfacePlotDialog.cpp src/Mantid/MantidGroupPlotGenerator.cpp src/Mantid/MantidUI.cpp src/Mantid/MantidTable.cpp - src/Mantid/MantidTreeWidget.cpp - src/Mantid/MantidTreeWidgetItem.cpp - src/Mantid/MantidWSIndexDialog.cpp src/Mantid/PeakPickerTool.cpp src/Mantid/Preferences.cpp - src/Mantid/QWorkspaceDockView.cpp src/Mantid/RemoveErrorsDialog.cpp src/Mantid/SampleLogDialogBase.cpp src/Mantid/UserFitFunctionDialog.cpp - src/Mantid/WorkspaceIcons.cpp src/Mantid/InstrumentWidget/InstrumentWindow.cpp ) @@ -287,7 +279,6 @@ set ( QTIPLOT_HDRS src/ApplicationWindow.h src/Note.h src/nrutil.h src/OpenProjectDialog.h - src/pixmaps.h src/Plot3DDialog.h src/PlotCurve.h src/PlotDialog.h @@ -364,7 +355,6 @@ set ( MANTID_HDRS src/Mantid/AlgorithmDockWidget.h src/Mantid/ErrorBarSettings.h src/Mantid/FirstTimeSetup.h src/Mantid/FitParameterTie.h - src/Mantid/FlowLayout.h src/Mantid/IFunctionWrapper.h src/Mantid/ImportWorkspaceDlg.h src/Mantid/IMantidMatrixExtensionHandler.h @@ -390,20 +380,14 @@ set ( MANTID_HDRS src/Mantid/AlgorithmDockWidget.h src/Mantid/MantidMatrixFunction.h src/Mantid/MantidSampleLogDialog.h src/Mantid/MantidSampleMaterialDialog.h - src/Mantid/MantidSurfacePlotDialog.h src/Mantid/MantidGroupPlotGenerator.h src/Mantid/MantidUI.h - src/Mantid/MantidWSIndexDialog.h src/Mantid/MantidTable.h - src/Mantid/MantidTreeWidget.h - src/Mantid/MantidTreeWidgetItem.h src/Mantid/PeakPickerTool.h src/Mantid/Preferences.h - src/Mantid/QWorkspaceDockView.h src/Mantid/RemoveErrorsDialog.h src/Mantid/SampleLogDialogBase.h src/Mantid/UserFitFunctionDialog.h - src/Mantid/WorkspaceIcons.h src/Mantid/InstrumentWidget/InstrumentWindow.h ) diff --git a/MantidPlot/src/Mantid/MantidGroupPlotGenerator.cpp b/MantidPlot/src/Mantid/MantidGroupPlotGenerator.cpp index 2fede3c1cd4..7f9c6bcf345 100644 --- a/MantidPlot/src/Mantid/MantidGroupPlotGenerator.cpp +++ b/MantidPlot/src/Mantid/MantidGroupPlotGenerator.cpp @@ -2,7 +2,10 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidQtMantidWidgets/MantidDisplayBase.h" +using MantidQt::MantidWidgets::MantidSurfacePlotDialog; +using MantidQt::MantidWidgets::MantidDisplayBase; using Mantid::API::WorkspaceGroup_const_sptr; using Mantid::API::WorkspaceGroup_sptr; using Mantid::API::MatrixWorkspace_const_sptr; @@ -14,7 +17,7 @@ using Mantid::API::ExperimentInfo; * Constructor * @param mantidUI :: [input] Pointer to the Mantid UI */ -MantidGroupPlotGenerator::MantidGroupPlotGenerator(MantidUI *mantidUI) +MantidGroupPlotGenerator::MantidGroupPlotGenerator(MantidDisplayBase *mantidUI) : m_mantidUI(mantidUI) {} /** @@ -73,7 +76,8 @@ void MantidGroupPlotGenerator::plot( plot->setYAxisLabel(options.axisName); plot->setResolution(1); // If auto-set too high, appears empty } else if (graphType == Type::Contour) { - MultiLayer *plot = matrixToPlot->plotGraph2D(Graph::ColorMapContour); + MultiLayer *plot = + matrixToPlot->plotGraph2D(GraphOptions::ColorMapContour); plot->activeGraph()->setXAxisTitle(xLabelQ); plot->activeGraph()->setYAxisTitle(options.axisName); plot->activeGraph()->setTitle(QString("Contour ").append(title)); diff --git a/MantidPlot/src/Mantid/MantidGroupPlotGenerator.h b/MantidPlot/src/Mantid/MantidGroupPlotGenerator.h index ff864c2b69f..a36f47477e5 100644 --- a/MantidPlot/src/Mantid/MantidGroupPlotGenerator.h +++ b/MantidPlot/src/Mantid/MantidGroupPlotGenerator.h @@ -1,10 +1,10 @@ #ifndef MANTIDGROUPPLOTGENERATOR_H_ #define MANTIDGROUPPLOTGENERATOR_H_ -#include "MantidSurfacePlotDialog.h" -#include "MantidMatrix.h" #include "Graph3D.h" #include "MantidAPI/NumericAxis.h" +#include "MantidMatrix.h" +#include "MantidQtMantidWidgets/MantidSurfacePlotDialog.h" /** * This utility class generates a surface or contour plot from a group of @@ -13,40 +13,45 @@ class MantidGroupPlotGenerator { public: /// Constructor - explicit MantidGroupPlotGenerator(MantidUI *mantidUI); + explicit MantidGroupPlotGenerator(MantidDisplayBase *mantidUI); /// Plots a surface from the given workspace group - void - plotSurface(const Mantid::API::WorkspaceGroup_const_sptr &wsGroup, - const MantidSurfacePlotDialog::UserInputSurface &options) const; + void plotSurface( + const Mantid::API::WorkspaceGroup_const_sptr &wsGroup, + const MantidQt::MantidWidgets::MantidSurfacePlotDialog::UserInputSurface + &options) const; /// Plots a contour plot from the given workspace group - void - plotContour(const Mantid::API::WorkspaceGroup_const_sptr &wsGroup, - const MantidSurfacePlotDialog::UserInputSurface &options) const; + void plotContour( + const Mantid::API::WorkspaceGroup_const_sptr &wsGroup, + const MantidQt::MantidWidgets::MantidSurfacePlotDialog::UserInputSurface + &options) const; /// Tests if WorkspaceGroup contains only MatrixWorkspaces static bool groupIsAllMatrixWorkspaces( const Mantid::API::WorkspaceGroup_const_sptr &wsGroup); /// Validates the given options and returns an error string - static std::string - validatePlotOptions(MantidSurfacePlotDialog::UserInputSurface &options, - int nWorkspaces); + static std::string validatePlotOptions( + MantidQt::MantidWidgets::MantidSurfacePlotDialog::UserInputSurface + &options, + int nWorkspaces); private: /// Type of graph to plot enum class Type { Surface, Contour }; /// Plots a graph from the given workspace group - void plot(Type graphType, - const Mantid::API::WorkspaceGroup_const_sptr &wsGroup, - const MantidSurfacePlotDialog::UserInputSurface &options) const; + void + plot(Type graphType, const Mantid::API::WorkspaceGroup_const_sptr &wsGroup, + const MantidQt::MantidWidgets::MantidSurfacePlotDialog::UserInputSurface + &options) const; /// Creates a single workspace to plot from const Mantid::API::MatrixWorkspace_sptr createWorkspaceForGroupPlot( boost::shared_ptr<const Mantid::API::WorkspaceGroup> wsGroup, - const MantidSurfacePlotDialog::UserInputSurface &options, + const MantidQt::MantidWidgets::MantidSurfacePlotDialog::UserInputSurface + &options, QString *xAxisTitle) const; /// Returns a single log value from the given workspace @@ -68,7 +73,7 @@ private: void convertXData(Mantid::API::MatrixWorkspace_sptr ws, Type graphType) const; /// Pointer to the Mantid UI - MantidUI *const m_mantidUI; + MantidDisplayBase *const m_mantidUI; }; #endif diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index 83a8740bc68..b08e0c27d6c 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -1,44 +1,44 @@ // Python header must go first #include "MantidQtAPI/PythonThreading.h" -#include "MantidUI.h" -#include "MantidMatrix.h" -#include "MantidDock.h" -#include "MantidTreeWidget.h" #include "AlgorithmDockWidget.h" -#include "ImportWorkspaceDlg.h" -#include "AlgorithmMonitor.h" -#include "MantidSampleLogDialog.h" -#include "MantidSampleMaterialDialog.h" #include "AlgorithmHistoryWindow.h" -#include "MantidMatrixCurve.h" +#include "AlgorithmMonitor.h" +#include "ImportWorkspaceDlg.h" +#include "MantidDock.h" +#include "MantidGroupPlotGenerator.h" #include "MantidMDCurve.h" #include "MantidMDCurveDialog.h" -#include "MantidSurfacePlotDialog.h" -#include "MantidWSIndexDialog.h" +#include "MantidMatrix.h" +#include "MantidMatrixCurve.h" #include "MantidQtMantidWidgets/FitPropertyBrowser.h" +#include "MantidSampleLogDialog.h" +#include "MantidSampleMaterialDialog.h" +#include "MantidQtMantidWidgets/MantidSurfacePlotDialog.h" #include "MantidTable.h" +#include "MantidUI.h" +#include "MantidQtMantidWidgets/MantidWSIndexDialog.h" #include "ProjectSerialiser.h" #include "../../MantidQt/MantidWidgets/ui_SequentialFitDialog.h" -#include "../Spectrogram.h" -#include "../pixmaps.h" -#include "../ScriptingWindow.h" #include "../Folder.h" +#include "../ScriptingWindow.h" +#include "../Spectrogram.h" #include "../TiledWindow.h" +#include "MantidQtAPI/pixmaps.h" +#include "Mantid/InstrumentWidget/InstrumentWindow.h" #include "MantidAPI/Axis.h" #include "MantidAPI/TextAxis.h" -#include "MantidKernel/Property.h" #include "MantidKernel/ConfigService.h" #include "MantidKernel/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/EnvironmentHistory.h" #include "MantidKernel/FacilityInfo.h" #include "MantidKernel/LogFilter.h" -#include "Mantid/InstrumentWidget/InstrumentWindow.h" -#include "MantidKernel/DateAndTime.h" -#include "MantidKernel/UnitConversion.h" +#include "MantidKernel/Property.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/UnitConversion.h" #include "InstrumentWidget/InstrumentWindow.h" @@ -47,24 +47,26 @@ #include "MantidQtAPI/PlotAxis.h" #include "MantidQtAPI/VatesViewerInterface.h" +#include "MantidQtMantidWidgets/MantidTreeWidget.h" + #include "MantidAPI/CompositeFunction.h" -#include "MantidAPI/ITableWorkspace.h" -#include "MantidAPI/IMDHistoWorkspace.h" #include "MantidAPI/IMDEventWorkspace.h" +#include "MantidAPI/IMDHistoWorkspace.h" #include "MantidAPI/IPeaksWorkspace.h" +#include "MantidAPI/ITableWorkspace.h" -#include <QMessageBox> -#include <QTextEdit> +#include <QApplication> +#include <QInputDialog> #include <QListWidget> #include <QMdiArea> +#include <QMenu> #include <QMenuBar> -#include <QApplication> +#include <QMessageBox> +#include <QTextEdit> #include <QToolBar> -#include <QMenu> -#include <QInputDialog> -#include <qwt_plot_curve.h> #include <algorithm> +#include <qwt_plot_curve.h> #include <time.h> #ifdef _WIN32 @@ -72,9 +74,9 @@ #endif #include <algorithm> +#include <fstream> #include <locale> #include <set> -#include <fstream> #include <sstream> #include <boost/tokenizer.hpp> @@ -82,8 +84,8 @@ #include <Poco/ActiveResult.h> #include "MantidAPI/IMDWorkspace.h" -#include "MantidQtSliceViewer/SliceViewerWindow.h" #include "MantidQtFactory/WidgetFactory.h" +#include "MantidQtSliceViewer/SliceViewerWindow.h" #include "MantidQtSpectrumViewer/SpectrumView.h" #include <typeinfo> @@ -91,7 +93,11 @@ using namespace std; using namespace Mantid::API; +using namespace MantidQt::API; using namespace MantidQt::MantidWidgets; +using MantidQt::MantidWidgets::MantidWSIndexDialog; +using MantidQt::MantidWidgets::MantidSurfacePlotDialog; +using MantidQt::MantidWidgets::MantidTreeWidget; using Mantid::Kernel::DateAndTime; using MantidQt::SliceViewer::SliceViewerWindow; @@ -2946,8 +2952,9 @@ Ignored if plotWindow == NULL MultiLayer *MantidUI::plot1D(const QStringList &ws_names, const QList<int> &indexList, bool spectrumPlot, MantidQt::DistributionFlag distr, bool errs, - GraphOptions::CurveType style, MultiLayer *plotWindow, - bool clearWindow, bool waterfallPlot) { + GraphOptions::CurveType style, + MultiLayer *plotWindow, bool clearWindow, + bool waterfallPlot) { // Convert the list into a map (with the same workspace as key in each case) QMultiMap<QString, int> pairs; QListIterator<QString> ws_itr(ws_names); @@ -3051,8 +3058,9 @@ not NULL - plotWindow MultiLayer *MantidUI::plot1D(const QMultiMap<QString, int> &toPlot, bool spectrumPlot, MantidQt::DistributionFlag distr, bool errs, - GraphOptions::CurveType style, MultiLayer *plotWindow, - bool clearWindow, bool waterfallPlot) { + GraphOptions::CurveType style, + MultiLayer *plotWindow, bool clearWindow, + bool waterfallPlot) { if (toPlot.size() == 0) return NULL; @@ -3514,7 +3522,8 @@ void MantidUI::plotLayerOfMultilayer(MultiLayer *multi, const bool plotErrors, QString legendText = wsName + '\n'; int curveIndex(0); for (const int spec : spectra) { - layer->insertCurve(wsName, spec, plotErrors, GraphOptions::Unspecified, plotDist); + layer->insertCurve(wsName, spec, plotErrors, GraphOptions::Unspecified, + plotDist); legendText += "\\l(" + QString::number(++curveIndex) + ")" + getLegendKey(wsName, spec) + "\n"; } @@ -3886,7 +3895,7 @@ void MantidUI::test() { } void MantidUI::updateRecentFilesList(const QString &fname) { - m_appWindow->updateRecentFilesList(fname); + m_appWindow->updateRecentFilesList(fname); } MantidSurfacePlotDialog * @@ -3901,7 +3910,6 @@ MantidUI::createSurfacePlotDialog(int flags, QStringList wsNames, names, plotType); } - MantidWSIndexDialog *MantidUI::createWorkspaceIndexDialog(int flags, QStringList wsNames, bool showWaterfall, @@ -3915,5 +3923,45 @@ MantidWSIndexDialog *MantidUI::createWorkspaceIndexDialog(int flags, showWaterfall, showPlotAll); } -void MantidUI::showSurfacePlot() {} -void MantidUI::showContourPlot() {} \ No newline at end of file +void MantidUI::showSurfacePlot() { + // find the workspace group clicked on + auto tree = m_exploreMantid->m_tree; + auto items = tree->selectedItems(); + if (!items.empty()) { + auto data = items[0]->data(0, Qt::UserRole).value<Workspace_sptr>(); + const auto wsGroup = + boost::dynamic_pointer_cast<const WorkspaceGroup>(data); + if (wsGroup) { + auto options = + tree->chooseSurfacePlotOptions(wsGroup->getNumberOfEntries()); + + // TODO: Figure out how to get rid of MantidUI dependency here. + auto plotter = + Mantid::Kernel::make_unique<MantidGroupPlotGenerator>(this); + plotter->plotSurface(wsGroup, options); + } + } +} + +void MantidUI::showContourPlot() { + auto tree = m_exploreMantid->m_tree; + auto items = tree->selectedItems(); + if (!items.empty()) { + auto data = items[0]->data(0, Qt::UserRole).value<Workspace_sptr>(); + const auto wsGroup = + boost::dynamic_pointer_cast<const WorkspaceGroup>(data); + if (wsGroup) { + auto options = + tree->chooseContourPlotOptions(wsGroup->getNumberOfEntries()); + + // TODO: Figure out how to remove the MantidUI dependency + auto plotter = + Mantid::Kernel::make_unique<MantidGroupPlotGenerator>(this); + plotter->plotContour(wsGroup, options); + } + } +} + +QWidget *MantidUI::getParent() { + return m_appWindow; +} \ No newline at end of file diff --git a/MantidPlot/src/Mantid/MantidUI.h b/MantidPlot/src/Mantid/MantidUI.h index 483ef1896d6..6af08436a97 100644 --- a/MantidPlot/src/Mantid/MantidUI.h +++ b/MantidPlot/src/Mantid/MantidUI.h @@ -7,7 +7,7 @@ #include "../ApplicationWindow.h" #include "../Graph.h" #include "MantidQtAPI/IProjectSerialisable.h" -#include "MantidQtMantidWidgets/WorkspacePresenter/MantidDisplayBase.h" +#include "MantidQtMantidWidgets/MantidDisplayBase.h" #include "MantidAPI/Algorithm.h" #include "MantidAPI/AlgorithmFactory.h" @@ -148,12 +148,15 @@ public: const bool wait = false) override; // Gets a pointer to workspace workspaceName - Mantid::API::Workspace_const_sptr getWorkspace(const QString &workspaceName); + Mantid::API::Workspace_const_sptr + getWorkspace(const QString &workspaceName) override; + + QWidget *getParent() override; // Deletes workspace from QtiPlot void deleteWorkspace(const QString &workspaceName); - //Delete multiple workspaces from QtiPlot + // Delete multiple workspaces from QtiPlot void deleteWorkspaces(const QStringList &wsNames = QStringList()) override; // Returns the name of selected workspace in exploreMantid window @@ -449,7 +452,8 @@ public slots: // Create a MantidMatrix from workspace MantidMatrix * importMatrixWorkspace(const Mantid::API::MatrixWorkspace_sptr workspace, - int lower = -1, int upper = -1, bool showDlg = true); + int lower = -1, int upper = -1, + bool showDlg = true) override; // Create a Table from workspace wsName Table *importTableWorkspace(const QString &wsName, bool showDlg = true, diff --git a/MantidQt/API/CMakeLists.txt b/MantidQt/API/CMakeLists.txt index 82d75b19f9a..1b667020786 100644 --- a/MantidQt/API/CMakeLists.txt +++ b/MantidQt/API/CMakeLists.txt @@ -8,6 +8,7 @@ src/FilePropertyWidget.cpp src/GenericDialog.cpp src/HelpWindow.cpp + src/FlowLayout.cpp src/InterfaceFactory.cpp src/InterfaceManager.cpp src/ListPropertyWidget.cpp @@ -23,6 +24,7 @@ src/MdSettings.cpp src/Message.cpp src/OptionsPropertyWidget.cpp + src/pixmaps.cpp src/PlotAxis.cpp src/PowerScaleEngine.cpp src/PropertyWidget.cpp @@ -47,6 +49,7 @@ src/VatesViewerInterface.cpp src/WidgetScrollbarDecorator.cpp src/WorkspaceObserver.cpp + src/WorkspaceIcons.cpp ) set ( MOC_FILES @@ -56,6 +59,7 @@ set ( MOC_FILES inc/MantidQtAPI/BatchAlgorithmRunner.h inc/MantidQtAPI/BoolPropertyWidget.h inc/MantidQtAPI/FilePropertyWidget.h + inc/MantidQtAPI/FlowLayout.h inc/MantidQtAPI/GenericDialog.h inc/MantidQtAPI/ListPropertyWidget.h inc/MantidQtAPI/ManageUserDirectories.h @@ -99,6 +103,7 @@ set ( INC_FILES inc/MantidQtAPI/MdConstants.h inc/MantidQtAPI/MdPlottingCmapsProvider.h inc/MantidQtAPI/MdSettings.h + inc/MantidQtAPI/pixmaps.h inc/MantidQtAPI/PlotAxis.h inc/MantidQtAPI/PowerScaleEngine.h inc/MantidQtAPI/PropertyWidgetFactory.h @@ -116,6 +121,7 @@ set ( INC_FILES inc/MantidQtAPI/TSVSerialiser.h inc/MantidQtAPI/qwt_compat.h inc/MantidQtAPI/WidgetScrollbarDecorator.h + inc/MantidQtAPI/WorkspaceIcons.h ) set ( UI_FILES diff --git a/MantidPlot/src/Mantid/FlowLayout.h b/MantidQt/API/inc/MantidQtAPI/FlowLayout.h similarity index 95% rename from MantidPlot/src/Mantid/FlowLayout.h rename to MantidQt/API/inc/MantidQtAPI/FlowLayout.h index 6dfd605e1e1..c189190c067 100644 --- a/MantidPlot/src/Mantid/FlowLayout.h +++ b/MantidQt/API/inc/MantidQtAPI/FlowLayout.h @@ -41,10 +41,15 @@ #ifndef FLOWLAYOUT_H #define FLOWLAYOUT_H +#include "MantidQtAPI/DllOption.h" #include <QLayout> #include <QRect> +#include <QStyle> #include <QWidgetItem> -class FlowLayout : public QLayout { + +namespace MantidQt { +namespace API { +class EXPORT_OPT_MANTIDQT_API FlowLayout : public QLayout { public: FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); @@ -72,5 +77,7 @@ private: int m_hSpace; int m_vSpace; }; +} +} #endif diff --git a/MantidPlot/src/Mantid/WorkspaceIcons.h b/MantidQt/API/inc/MantidQtAPI/WorkspaceIcons.h similarity index 64% rename from MantidPlot/src/Mantid/WorkspaceIcons.h rename to MantidQt/API/inc/MantidQtAPI/WorkspaceIcons.h index 68d75f8cced..4aa1f3574a6 100644 --- a/MantidPlot/src/Mantid/WorkspaceIcons.h +++ b/MantidQt/API/inc/MantidQtAPI/WorkspaceIcons.h @@ -1,14 +1,17 @@ -#ifndef WORKSPACEICONS_H_ -#define WORKSPACEICONS_H_ +#ifndef MANTIDQT_API_WORKSPACEICONS_H_ +#define MANTIDQT_API_WORKSPACEICONS_H_ +#include "DllOption.h" #include <QMap> #include <QPixmap> +namespace MantidQt { +namespace API { /** * Defines a mapping between a workspace ID and a pixmap * to use for an icon. */ -class WorkspaceIcons { +class EXPORT_OPT_MANTIDQT_API WorkspaceIcons { public: WorkspaceIcons(); @@ -22,5 +25,6 @@ private: /// Internal map instance QMap<std::string, std::string> m_idToPixmapName; }; - -#endif +} +} +#endif //MANTIDQT_API_WORKSPACEICONS_H_ diff --git a/MantidPlot/src/pixmaps.h b/MantidQt/API/inc/MantidQtAPI/pixmaps.h similarity index 89% rename from MantidPlot/src/pixmaps.h rename to MantidQt/API/inc/MantidQtAPI/pixmaps.h index d0083c72057..52ea0c8be15 100644 --- a/MantidPlot/src/pixmaps.h +++ b/MantidQt/API/inc/MantidQtAPI/pixmaps.h @@ -28,12 +28,17 @@ * * ***************************************************************************/ -#ifndef PIXMAPS_H -#define PIXMAPS_H +#ifndef MANTIDQT_API_PIXMAPS_H +#define MANTIDQT_API_PIXMAPS_H +#include "DLLOption.h" #include "qpixmap.h" +namespace MantidQt { +namespace API { /** Function that returns a QPixmap given a string name. */ -QPixmap getQPixmap(const std::string &name); +EXPORT_OPT_MANTIDQT_API QPixmap getQPixmap(const std::string &name); +} +} -#endif +#endif // MANTIDQT_API_PIXMAPS_H diff --git a/MantidPlot/src/Mantid/FlowLayout.cpp b/MantidQt/API/src/FlowLayout.cpp similarity index 98% rename from MantidPlot/src/Mantid/FlowLayout.cpp rename to MantidQt/API/src/FlowLayout.cpp index e45d988c836..41aee2ade0c 100644 --- a/MantidPlot/src/Mantid/FlowLayout.cpp +++ b/MantidQt/API/src/FlowLayout.cpp @@ -40,7 +40,10 @@ #include <QtGui> -#include "FlowLayout.h" +#include "MantidQtAPI/FlowLayout.h" + +namespace MantidQt { +namespace API { FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) { setContentsMargins(margin, margin, margin, margin); @@ -160,3 +163,5 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const { return static_cast<QLayout *>(parent)->spacing(); } } +} +} \ No newline at end of file diff --git a/MantidPlot/src/Mantid/WorkspaceIcons.cpp b/MantidQt/API/src/WorkspaceIcons.cpp similarity index 94% rename from MantidPlot/src/Mantid/WorkspaceIcons.cpp rename to MantidQt/API/src/WorkspaceIcons.cpp index 114d7e46590..ebc388cf8f0 100644 --- a/MantidPlot/src/Mantid/WorkspaceIcons.cpp +++ b/MantidQt/API/src/WorkspaceIcons.cpp @@ -1,9 +1,11 @@ //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- -#include "WorkspaceIcons.h" -#include "../pixmaps.h" +#include "MantidQtAPI/WorkspaceIcons.h" +#include "MantidQtAPI/pixmaps.h" +namespace MantidQt { +namespace API { //----------------------------------------------------------------------------- // Public member functions //----------------------------------------------------------------------------- @@ -53,3 +55,5 @@ void WorkspaceIcons::initInternalLookup() { m_idToPixmapName["MDHistoWorkspace"] = "mantid_mdws_xpm"; m_idToPixmapName["MDEventWorkspace"] = "mantid_mdws_xpm"; } +} +} diff --git a/MantidPlot/src/pixmaps.cpp b/MantidQt/API/src/pixmaps.cpp similarity index 99% rename from MantidPlot/src/pixmaps.cpp rename to MantidQt/API/src/pixmaps.cpp index 0d2a02e4a2f..d9aca682285 100644 --- a/MantidPlot/src/pixmaps.cpp +++ b/MantidQt/API/src/pixmaps.cpp @@ -6,11 +6,13 @@ * Author: janik */ -#include "pixmaps.h" +#include "MantidQtAPI/pixmaps.h" #include <sstream> #include <stdexcept> +namespace MantidQt{ +namespace API{ //================================================================================== // xpms from other spots in the files @@ -13000,3 +13002,5 @@ QPixmap getQPixmap(const std::string &name) } +} +} \ No newline at end of file diff --git a/MantidQt/MantidWidgets/CMakeLists.txt b/MantidQt/MantidWidgets/CMakeLists.txt index a87b7e829e1..6a026ff34e5 100644 --- a/MantidQt/MantidWidgets/CMakeLists.txt +++ b/MantidQt/MantidWidgets/CMakeLists.txt @@ -84,10 +84,14 @@ set ( SRC_FILES src/InstrumentView/XIntegrationControl.cpp src/LineEditWithClear.cpp src/LogValueSelector.cpp + src/MantidTreeWidget.cpp + src/MantidTreeWidgetItem.cpp src/MWDiag.cpp src/MWRunFiles.cpp src/MWView.cpp src/MantidHelpWindow.cpp + src/MantidSurfacePlotDialog.cpp + src/MantidWSIndexDialog.cpp src/MessageDisplay.cpp src/MultifitSetupDialog.cpp src/MuonFitDataSelector.cpp @@ -117,6 +121,7 @@ set ( SRC_FILES src/pythonCalc.cpp src/WorkspacePresenter/WorkspacePresenter.cpp src/WorkspacePresenter/ADSAdapter.cpp + src/WorkspacePresenter/QWorkspaceDockView.cpp ) # Header files with Q_OBJECT that qmake will "moc" @@ -147,6 +152,10 @@ set ( MOC_FILES inc/MantidQtMantidWidgets/InstrumentSelector.h inc/MantidQtMantidWidgets/IndirectInstrumentConfig.h inc/MantidQtMantidWidgets/InputController.h + inc/MantidQtMantidWidgets/MantidSurfacePlotDialog.h + inc/MantidQtMantidWidgets/MantidWSIndexDialog.h + inc/MantidQtMantidWidgets/MantidTreeWidget.h + inc/MantidQtMantidWidgets/MantidTreeWidgetItem.h inc/MantidQtMantidWidgets/MantidHelpWindow.h inc/MantidQtMantidWidgets/MessageDisplay.h inc/MantidQtMantidWidgets/MultifitSetupDialog.h @@ -201,6 +210,7 @@ set ( MOC_FILES inc/MantidQtMantidWidgets/InstrumentView/UCorrectionDialog.h inc/MantidQtMantidWidgets/InstrumentView/XIntegrationControl.h inc/MantidQtMantidWidgets/LogValueSelector.h + inc/MantidQtMantidWidgets/WorkspacePresenter/QWorkspaceDockView.h ) # Add the include files are NOT already in MOC_FILES @@ -301,6 +311,7 @@ set ( INC_FILES inc/MantidQtMantidWidgets/InstrumentView/Viewport.h inc/MantidQtMantidWidgets/InstrumentView/XIntegrationControl.h inc/MantidQtMantidWidgets/LogValueSelector.h + inc/MantidQtMantidWidgets/MantidDisplayBase.h inc/MantidQtMantidWidgets/MuonFitDataSelector.h inc/MantidQtMantidWidgets/MuonFunctionBrowser.h inc/MantidQtMantidWidgets/ProgressPresenter.h @@ -312,7 +323,6 @@ set ( INC_FILES inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspaceProvider.h inc/MantidQtMantidWidgets/WorkspacePresenter/ADSAdapter.h inc/MantidQtMantidWidgets/WorkspacePresenter/IWorkspaceDockView.h - inc/MantidQtMantidWidgets/WorkspacePresenter/MantidDisplayBase.h ) # QtDesigner UI files to process diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/MantidDisplayBase.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidDisplayBase.h similarity index 93% rename from MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/MantidDisplayBase.h rename to MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidDisplayBase.h index 2db37cbc8a3..9d0fcbb5b9e 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/MantidDisplayBase.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidDisplayBase.h @@ -18,6 +18,7 @@ class QString; class QStringList; class Table; class MultiLayer; +class MantidMatrix; class MantidSurfacePlotDialog; class MantidWSIndexDialog; @@ -62,6 +63,10 @@ public: virtual void disableSaveNexus() = 0; virtual void deleteWorkspaces(const QStringList &wsNames = QStringList()) = 0; virtual void importWorkspace() = 0; + virtual MantidMatrix * + importMatrixWorkspace(const Mantid::API::MatrixWorkspace_sptr workspace, + int lower = -1, int upper = -1, + bool showDlg = true) = 0; virtual void importWorkspace(const QString &wsName, bool showDlg = true, bool makeVisible = true) = 0; virtual void renameWorkspace(QStringList = QStringList()) = 0; @@ -86,6 +91,11 @@ public: virtual bool executeAlgorithmAsync(Mantid::API::IAlgorithm_sptr alg, const bool wait = false) = 0; + virtual Mantid::API::Workspace_const_sptr + getWorkspace(const QString &workspaceName) = 0; + + virtual QWidget *getParent() = 0; + // Plotting Methods virtual MultiLayer * plot1D(const QMultiMap<QString, std::set<int>> &toPlot, bool spectrumPlot, diff --git a/MantidPlot/src/Mantid/MantidSurfacePlotDialog.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidSurfacePlotDialog.h similarity index 91% rename from MantidPlot/src/Mantid/MantidSurfacePlotDialog.h rename to MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidSurfacePlotDialog.h index 052e8bceb9f..ba110e3b239 100644 --- a/MantidPlot/src/Mantid/MantidSurfacePlotDialog.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidSurfacePlotDialog.h @@ -1,8 +1,12 @@ #ifndef MANTIDSURFACEPLOTDIALOG_H_ #define MANTIDSURFACEPLOTDIALOG_H_ -#include <QComboBox> #include "MantidWSIndexDialog.h" +#include <QComboBox> + +namespace MantidQt { +namespace MantidWidgets { +class MantidDisplayBase; /** * The MantidSurfacePlotDialog offers the same functionality of choosing a @@ -14,7 +18,7 @@ * - The user is offered the choice of only those logs that have single values * per workspace. */ -class MantidSurfacePlotDialog : public QDialog { +class DLLExport MantidSurfacePlotDialog : public QDialog { Q_OBJECT public: @@ -29,7 +33,7 @@ public: /// Constructor - same parameters as one of the parent constructors, along /// with a list of the names of workspaces to be plotted. - MantidSurfacePlotDialog(MantidUI *parent, Qt::WFlags flags, + MantidSurfacePlotDialog(MantidDisplayBase *parent, Qt::WFlags flags, QList<QString> wsNames, const QString &plotType); /// Returns a structure holding all of the selected options UserInputSurface getSelections() const; @@ -65,7 +69,7 @@ private: /// Returns the input custom log values const std::set<double> getCustomLogValues() const; /// A pointer to the parent MantidUI object - MantidUI *m_mantidUI; + MantidDisplayBase *m_mantidUI; /// A list of names of workspaces which are to be plotted. QList<QString> m_wsNames; /// Set to true when user accepts input @@ -80,5 +84,6 @@ private: /// Minimum width for dialog to fit title in static const int MINIMUM_WIDTH; }; - +} +} #endif diff --git a/MantidPlot/src/Mantid/MantidTreeWidget.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidTreeWidget.h similarity index 76% rename from MantidPlot/src/Mantid/MantidTreeWidget.h rename to MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidTreeWidget.h index 56aef37a414..efc42320f9b 100644 --- a/MantidPlot/src/Mantid/MantidTreeWidget.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidTreeWidget.h @@ -1,28 +1,26 @@ -#ifndef MANTIDTREEWIDGET_H -#define MANTIDTREEWIDGET_H +#ifndef MANTIDQT_MANTIDWIDGETS_MANTIDTREEWIDGET_H +#define MANTIDQT_MANTIDWIDGETS_MANTIDTREEWIDGET_H -#include "Mantid/MantidSurfacePlotDialog.h" -#include "Mantid/MantidWSIndexDialog.h" +#include "MantidQtMantidWidgets/WidgetDllOption.h" +#include <MantidAPI/MatrixWorkspace_fwd.h> +#include <MantidQtMantidWidgets/MantidSurfacePlotDialog.h> +#include <MantidQtMantidWidgets/MantidWSIndexDialog.h> #include <QTreeWidget> #include <boost/shared_ptr.hpp> -class QWorkspaceDockView; - namespace MantidQt { namespace MantidWidgets { class MantidDisplayBase; -} -} +class QWorkspaceDockView; enum class MantidItemSortScheme { ByName, ByLastModified }; -class MantidTreeWidget : public QTreeWidget { +class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS MantidTreeWidget : public QTreeWidget { Q_OBJECT public: - MantidTreeWidget(QWorkspaceDockView *w, - MantidQt::MantidWidgets::MantidDisplayBase *mui); + MantidTreeWidget(QWorkspaceDockView *w, MantidDisplayBase *mui); void mousePressEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override; @@ -60,5 +58,6 @@ private: MantidItemSortScheme m_sortScheme; Qt::SortOrder m_sortOrder; }; - -#endif // MANTIDTREEWIDGET_H \ No newline at end of file +} +} +#endif // MANTIDQT_MANTIDWIDGETS_MANTIDTREEWIDGET_H \ No newline at end of file diff --git a/MantidPlot/src/Mantid/MantidTreeWidgetItem.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidTreeWidgetItem.h similarity index 75% rename from MantidPlot/src/Mantid/MantidTreeWidgetItem.h rename to MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidTreeWidgetItem.h index 1629b41a035..8cee9a4c128 100644 --- a/MantidPlot/src/Mantid/MantidTreeWidgetItem.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidTreeWidgetItem.h @@ -1,15 +1,19 @@ #ifndef MANTIDTREEWIDGETITEM_H #define MANTIDTREEWIDGETITEM_H +#include "MantidQtMantidWidgets/WidgetDllOption.h" #include <MantidKernel/DateAndTime.h> +#include <MantidQtAPI/WorkspaceObserver.h> #include <QTreeWidgetItem> +namespace MantidQt { +namespace MantidWidgets { class MantidTreeWidget; /**A class derived from QTreeWidgetItem, to accomodate * sorting on the items in a MantidTreeWidget. */ -class MantidTreeWidgetItem : public QTreeWidgetItem { +class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS MantidTreeWidgetItem : public QTreeWidgetItem { public: explicit MantidTreeWidgetItem(MantidTreeWidget *); MantidTreeWidgetItem(QStringList, MantidTreeWidget *); @@ -23,4 +27,6 @@ private: static Mantid::Kernel::DateAndTime getLastModified(const QTreeWidgetItem *); int m_sortPos; }; +} +} #endif // MANTIDTREEWIDGETITEM_H \ No newline at end of file diff --git a/MantidPlot/src/Mantid/MantidWSIndexDialog.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidWSIndexDialog.h similarity index 78% rename from MantidPlot/src/Mantid/MantidWSIndexDialog.h rename to MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidWSIndexDialog.h index e421b670121..24d3df2d8ed 100644 --- a/MantidPlot/src/Mantid/MantidWSIndexDialog.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MantidWSIndexDialog.h @@ -6,72 +6,86 @@ //---------------------------------- #include <QCheckBox> #include <QDialog> -#include <QString> -#include <QList> #include <QLabel> -#include <QVBoxLayout> #include <QLineEdit> -#include <QValidator> +#include <QList> #include <QMap> +#include <QString> +#include <QVBoxLayout> +#include <QValidator> #include <set> -#include "MantidUI.h" - +namespace MantidQt { +namespace MantidWidgets { //---------------------------------- // Forward declarations //---------------------------------- class IntervalList; /** - The MantidWSIndexDialog class presents users with a dialog so that they may - specify which workspace indices / spectra IDs are to be plotted by Mantid. - - They are prompted with the available range(s) of indices/IDs they can plot. - They must enter a range(s) that is(are) enclosed within those ranges. - - "Ranges" are of a format you've probably seen when inputting page numbers to - print into a word processing program or similar, i.e. "2, 4-6" to print out - pages 2, 4, 5 and 6. - - Ranges are defined by the "Interval" and "IntervalList" classes. - - The IntervalListValidator class overrides QValidator, and allows Mantid - to assertain whether a user has attempted to input a valid range or not. - Altering this class will affect the behaviour of what is allowed to be + The MantidWSIndexDialog class presents users with a dialog so that + they may + specify which workspace indices / spectra IDs are to be plotted by + Mantid. + + They are prompted with the available range(s) of indices/IDs they + can plot. + They must enter a range(s) that is(are) enclosed within those + ranges. + + "Ranges" are of a format you've probably seen when inputting page + numbers to + print into a word processing program or similar, i.e. "2, 4-6" to + print out + pages 2, 4, 5 and 6. + + Ranges are defined by the "Interval" and "IntervalList" classes. + + The IntervalListValidator class overrides QValidator, and allows + Mantid + to assertain whether a user has attempted to input a valid range or + not. + Altering this class will affect the behaviour of what is allowed to + be typed, - and what inputs allow the "OK" button to be pressed. + and what inputs allow the "OK" button to be pressed. - TODO - perhaps the interval objects are useful elsewhere, in which case + TODO - perhaps the interval objects are useful elsewhere, in which + case those - three classes are best in thier own header and source. + three classes are best in thier own header and source. - @author Peter G Parker, ISIS, RAL - @date 2011/10/06 + @author Peter G Parker, ISIS, RAL + @date 2011/10/06 - Copyright © 2009 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + Copyright © 2009 ISIS Rutherford Appleton Laboratory, NScD Oak + Ridge National Laboratory & European Spallation Source - This file is part of Mantid. + 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 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. + 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/>. + 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> + File change history is stored at: + <https://github.com/mantidproject/mantid> + Code Documentation is available at: + <http://doxygen.mantidproject.org> */ -class Interval { +class DLLExport Interval { public: /// Constructor - starting and ending at single. explicit Interval(int single); @@ -97,7 +111,8 @@ public: /// Returns a set of ints that represents the interval. std::set<int> getIntSet() const; - /// Returns true if this interval completely contains the interval passed to + /// Returns true if this interval completely contains the interval passed + /// to /// it, else false. bool contains(const Interval &) const; @@ -114,7 +129,7 @@ private: int m_start, m_end; }; -class IntervalList { +class DLLExport IntervalList { public: /// Constructor - with empty list. IntervalList(void); @@ -133,7 +148,8 @@ public: /// Returns a string that represents the IntervalList, of the form /// "0, 2-5, 8, 10-12". String is cut short by default to 6 intervals. std::string toStdString(int numOfIntervals = 6) const; - /// Convenience function that returns the contents of toStdString as a QString + /// Convenience function that returns the contents of toStdString as a + /// QString /// object. QString toQString(int numOfIntervals = 6) const; @@ -147,24 +163,28 @@ public: void addIntervals(QString); /// Adds an IntervalList to this IntervalList. void addIntervalList(const IntervalList &); - /// Replaces the current list with the list belonging to given IntervalList + /// Replaces the current list with the list belonging to given + /// IntervalList /// object. void setIntervalList(const IntervalList &); /// Returns a set of ints that represents the interval. std::set<int> getIntSet() const; - /// Returns true if this interval list completely contains the interval passed + /// Returns true if this interval list completely contains the interval + /// passed /// to it, else false. bool contains(const Interval &) const; - /// Returns true if this interval list completely contains the interval list + /// Returns true if this interval list completely contains the interval + /// list /// passed to it, else false. bool contains(const IntervalList &) const; /// Returns true if the QString can be parsed into an IntervalList, else /// false. static bool isParsable(const QString &); - /// Returns true if the QString can be parsed into an IntervalList which can + /// Returns true if the QString can be parsed into an IntervalList which + /// can /// then be contained /// in the IntervalList given, else false. static bool isParsable(const QString &, const IntervalList &); @@ -181,7 +201,7 @@ private: QList<Interval> m_list; }; -class IntervalListValidator : public QValidator { +class DLLExport IntervalListValidator : public QValidator { Q_OBJECT public: @@ -197,15 +217,17 @@ private: IntervalList m_intervalList; }; -class MantidWSIndexWidget : public QWidget { +class DLLExport MantidWSIndexWidget : public QWidget { Q_OBJECT - /** Auxiliar class to wrap the QLine allowing to have a warn to the user for + /** Auxiliar class to wrap the QLine allowing to have a warn to the user + * for * invalid inputs. */ class QLineEditWithErrorMark : public QWidget { public: - /// constructor that will join togheter the QLineEdit and an 'invisible' * + /// constructor that will join togheter the QLineEdit and an 'invisible' + /// * /// label. explicit QLineEditWithErrorMark(QWidget *parent = 0); /// virtual destructor to allow Qt to deallocate all objects @@ -223,8 +245,8 @@ class MantidWSIndexWidget : public QWidget { public: /** - * POD structure to hold all user-selected input - */ + * POD structure to hold all user-selected input + */ struct UserInput { QMultiMap<QString, std::set<int>> plots; bool waterfall; @@ -272,11 +294,13 @@ private: /// Check to see if all workspaces have a spectrum axis void checkForSpectraAxes(); - /// Generates an IntervalList which defines which workspace indices the user + /// Generates an IntervalList which defines which workspace indices the + /// user /// can /// ask to plot. void generateWsIndexIntervals(); - /// Generates an IntervalList which defines which spectra IDs the user can ask + /// Generates an IntervalList which defines which spectra IDs the user can + /// ask /// to plot. void generateSpectraNumIntervals(); @@ -307,13 +331,12 @@ private: IntervalList m_wsIndexChoice, m_spectraIdChoice; }; -class MantidWSIndexDialog : public QDialog { +class DLLExport MantidWSIndexDialog : public QDialog { Q_OBJECT public: /// Constructor - has a list of the names of workspaces to be plotted. - MantidWSIndexDialog(MantidUI *parent, Qt::WFlags flags, - QList<QString> wsNames, + MantidWSIndexDialog(QWidget *parent, Qt::WFlags flags, QList<QString> wsNames, const bool showWaterfallOption = false, const bool showPlotAll = true, const bool showTiledOption = false); @@ -339,8 +362,6 @@ private: void init(); /// Initializes the layout of the buttons void initButtons(); - /// A pointer to the parent MantidUI object - MantidUI *m_mantidUI; /// Do we allow the display of the "Plot all" button bool m_plotAll; /// Qt objects @@ -348,5 +369,6 @@ private: QHBoxLayout *m_buttonBox; QVBoxLayout *m_outer; }; - +} +} #endif // MANTIDWSINDEXDIALOG_H_ diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/IWorkspaceDockView.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/IWorkspaceDockView.h index 4d352ef70f8..0a28aafe02a 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/IWorkspaceDockView.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/IWorkspaceDockView.h @@ -1,8 +1,7 @@ -#ifndef MANTID_MANTIDWIDGETS_IWORKSPACEDOCKVIEW_H_ -#define MANTID_MANTIDWIDGETS_IWORKSPACEDOCKVIEW_H_ +#ifndef MANTIDQT_MANTIDWIDGETS_IWORKSPACEDOCKVIEW_H_ +#define MANTIDQT_MANTIDWIDGETS_IWORKSPACEDOCKVIEW_H_ #include <MantidAPI/Workspace_fwd.h> -#include <boost/enable_shared_from_this.hpp> #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> #include <map> @@ -43,14 +42,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid> */ -class IWorkspaceDockView - : public boost::enable_shared_from_this<IWorkspaceDockView> { +class IWorkspaceDockView { public: enum class SortDirection { Ascending, Descending }; enum class SortCriteria { ByName, ByLastModified }; enum class SaveFileType { Nexus, ASCII, ASCIIv1 }; - virtual ~IWorkspaceDockView() = default; + virtual ~IWorkspaceDockView(){}; virtual void init() = 0; virtual WorkspacePresenterWN_wptr getPresenterWeakPtr() = 0; @@ -113,4 +111,4 @@ public: } // namespace MantidWidgets } // namespace MantidQt -#endif // MANTID_MANTIDWIDGETS_IWORKSPACEDOCKVIEW_H_ \ No newline at end of file +#endif // MANTIDQT_MANTIDWIDGETS_IWORKSPACEDOCKVIEW_H_ \ No newline at end of file diff --git a/MantidPlot/src/Mantid/QWorkspaceDockView.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/QWorkspaceDockView.h similarity index 91% rename from MantidPlot/src/Mantid/QWorkspaceDockView.h rename to MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/QWorkspaceDockView.h index 75b7dc1cbd6..1c746f2f8d7 100644 --- a/MantidPlot/src/Mantid/QWorkspaceDockView.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/QWorkspaceDockView.h @@ -1,23 +1,23 @@ -#ifndef QWORKSPACEDOCKVIEW_H -#define QWORKSPACEDOCKVIEW_H +#ifndef MANTIDQT_MANTIDWIDGETS_QWORKSPACEDOCKVIEW_H +#define MANTIDQT_MANTIDWIDGETS_QWORKSPACEDOCKVIEW_H -#include "MantidAPI/ExperimentInfo.h" -#include "MantidAPI/IAlgorithm_fwd.h" -#include "MantidAPI/IMDEventWorkspace_fwd.h" -#include "MantidAPI/IMDWorkspace.h" -#include "MantidAPI/IPeaksWorkspace_fwd.h" -#include "MantidAPI/ITableWorkspace_fwd.h" -#include "MantidAPI/MatrixWorkspace_fwd.h" -#include "MantidAPI/WorkspaceGroup_fwd.h" +#include "MantidQtMantidWidgets/WidgetDLLOption.h" +#include <MantidAPI/ExperimentInfo.h> +#include <MantidAPI/IAlgorithm_fwd.h> +#include <MantidAPI/IMDEventWorkspace_fwd.h> +#include <MantidAPI/IMDWorkspace.h> +#include <MantidAPI/IPeaksWorkspace_fwd.h> +#include <MantidAPI/ITableWorkspace_fwd.h> +#include <MantidAPI/MatrixWorkspace_fwd.h> +#include <MantidAPI/WorkspaceGroup_fwd.h> #include <MantidQtMantidWidgets/WorkspacePresenter/IWorkspaceDockView.h> #include <QDockWidget> #include <QMap> +#include <boost/enable_shared_from_this.hpp> #include <boost/shared_ptr.hpp> class QMainWindow; -class MantidTreeWidgetItem; -class MantidTreeWidget; class QLabel; class QFileDialog; class QLineEdit; @@ -35,8 +35,8 @@ class QSortFilterProxyModel; namespace MantidQt { namespace MantidWidgets { class MantidDisplayBase; -} -} +class MantidTreeWidgetItem; +class MantidTreeWidget; /** \class QWorkspaceDockView @@ -65,12 +65,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid> */ -class QWorkspaceDockView : public MantidQt::MantidWidgets::IWorkspaceDockView, - public QDockWidget { +class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS QWorkspaceDockView + : public QDockWidget, + public IWorkspaceDockView, + public boost::enable_shared_from_this<QWorkspaceDockView> { Q_OBJECT public: - explicit QWorkspaceDockView(MantidQt::MantidWidgets::MantidDisplayBase *mui, QMainWindow *parent); - ~QWorkspaceDockView() override; + explicit QWorkspaceDockView(MantidQt::MantidWidgets::MantidDisplayBase *mui, + QMainWindow *parent); + ~QWorkspaceDockView(); void dropEvent(QDropEvent *de) override; void init() override; MantidQt::MantidWidgets::WorkspacePresenterWN_wptr @@ -219,7 +222,6 @@ private slots: void onClickPlotSurface(); void onClickPlotContour(); void onClickClearUB(); - void updateTree(); void incrementUpdateCount(); void filterWorkspaceTree(const QString &text); @@ -228,7 +230,7 @@ private: protected: MantidTreeWidget *m_tree; - //TODO:remove + // TODO:remove friend class MantidDisplayBase; private: @@ -281,4 +283,6 @@ signals: void signalUpdateTree(const std::map<std::string, Mantid::API::Workspace_sptr> &); }; -#endif // QWORKSPACEDOCKVIEW_H \ No newline at end of file +} +} +#endif // MANTIDQT_MANTIDWIDGETS_QWORKSPACEDOCKVIEW_H \ No newline at end of file diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspaceDockViewMockObjects.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspaceDockViewMockObjects.h index 4abb5b8df7e..80a7385fa5d 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspaceDockViewMockObjects.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspaceDockViewMockObjects.h @@ -1,5 +1,5 @@ -#ifndef MANTID_MANTIDWIDGETS_WORKSPACEDOCKVIEWMOCKOBJECTS_H -#define MANTID_MANTIDWIDGETS_WORKSPACEDOCKVIEWMOCKOBJECTS_H +#ifndef MANTIDQT_MANTIDWIDGETS_WORKSPACEDOCKVIEWMOCKOBJECTS_H +#define MANTIDQT_MANTIDWIDGETS_WORKSPACEDOCKVIEWMOCKOBJECTS_H #include "MantidKernel/WarningSuppressions.h" #include "MantidKernel/make_unique.h" @@ -14,7 +14,9 @@ using namespace MantidQt::MantidWidgets; GCC_DIAG_OFF_SUGGEST_OVERRIDE -class MockWorkspaceDockView : public IWorkspaceDockView { +class MockWorkspaceDockView + : public IWorkspaceDockView, + public boost::enable_shared_from_this<MockWorkspaceDockView> { public: MockWorkspaceDockView() {} ~MockWorkspaceDockView() override {} @@ -99,4 +101,4 @@ private: GCC_DIAG_ON_SUGGEST_OVERRIDE -#endif // MANTID_MANTIDWIDGETS_WORKSPACEDOCKVIEWMOCKOBJECTS_H \ No newline at end of file +#endif // MANTIDQT_MANTIDWIDGETS_WORKSPACEDOCKVIEWMOCKOBJECTS_H \ No newline at end of file diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspacePresenter.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspacePresenter.h index ebbab230066..152f4f3840d 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspacePresenter.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/WorkspacePresenter/WorkspacePresenter.h @@ -1,5 +1,5 @@ -#ifndef MANTID_MANTIDWIDGETS_WORKSPACEPRESENTER_H_ -#define MANTID_MANTIDWIDGETS_WORKSPACEPRESENTER_H_ +#ifndef MANTIDQT_MANTIDWIDGETS_WORKSPACEPRESENTER_H_ +#define MANTIDQT_MANTIDWIDGETS_WORKSPACEPRESENTER_H_ #include "MantidQtMantidWidgets/WidgetDllOption.h" #include "MantidQtMantidWidgets/WorkspacePresenter/ViewNotifiable.h" @@ -110,4 +110,4 @@ private: }; } // namespace MantidWidgets } // namespace MantidQt -#endif // MANTID_MANTIDWIDGETS_WORKSPACEPRESENTER_H_ \ No newline at end of file +#endif // MANTIDQT_MANTIDWIDGETS_WORKSPACEPRESENTER_H_ \ No newline at end of file diff --git a/MantidPlot/src/Mantid/MantidSurfacePlotDialog.cpp b/MantidQt/MantidWidgets/src/MantidSurfacePlotDialog.cpp similarity index 95% rename from MantidPlot/src/Mantid/MantidSurfacePlotDialog.cpp rename to MantidQt/MantidWidgets/src/MantidSurfacePlotDialog.cpp index bc14dce8eb2..738a206a132 100644 --- a/MantidPlot/src/Mantid/MantidSurfacePlotDialog.cpp +++ b/MantidQt/MantidWidgets/src/MantidSurfacePlotDialog.cpp @@ -1,12 +1,17 @@ -#include "MantidSurfacePlotDialog.h" -#include "MantidAPI/IMDWorkspace.h" +#include "MantidQtMantidWidgets/MantidSurfacePlotDialog.h" #include "MantidAPI/ExperimentInfo.h" +#include "MantidAPI/IMDWorkspace.h" +#include "MantidQtMantidWidgets/MantidDisplayBase.h" #include <QMessageBox> +#include <QPushButton> +using MantidQt::MantidWidgets::MantidDisplayBase; using Mantid::API::IMDWorkspace; using Mantid::API::IMDWorkspace_sptr; using Mantid::API::ExperimentInfo; +namespace MantidQt { +namespace MantidWidgets { /// The string "Workspace index" const QString MantidSurfacePlotDialog::WORKSPACE_INDEX = "Workspace index"; @@ -23,11 +28,11 @@ const int MantidSurfacePlotDialog::MINIMUM_WIDTH = 275; * @param wsNames :: the names of the workspaces to be plotted * @param plotType :: Type of plot (for window title) */ -MantidSurfacePlotDialog::MantidSurfacePlotDialog(MantidUI *mui, +MantidSurfacePlotDialog::MantidSurfacePlotDialog(MantidDisplayBase *mui, Qt::WFlags flags, QList<QString> wsNames, const QString &plotType) - : QDialog(mui->appWindow(), flags), m_widget(this, flags, wsNames, false), + : QDialog(mui->getParent(), flags), m_widget(this, flags, wsNames, false), m_mantidUI(mui), m_wsNames(wsNames), m_accepted(false) { // Set up UI. init(plotType); @@ -263,3 +268,5 @@ void MantidSurfacePlotDialog::showPlotOptionsError(const QString &message) { errorMessage.exec(); } } +} +} \ No newline at end of file diff --git a/MantidPlot/src/Mantid/MantidTreeWidget.cpp b/MantidQt/MantidWidgets/src/MantidTreeWidget.cpp similarity index 93% rename from MantidPlot/src/Mantid/MantidTreeWidget.cpp rename to MantidQt/MantidWidgets/src/MantidTreeWidget.cpp index 6dc4685d535..1caabc3f032 100644 --- a/MantidPlot/src/Mantid/MantidTreeWidget.cpp +++ b/MantidQt/MantidWidgets/src/MantidTreeWidget.cpp @@ -1,11 +1,10 @@ -#include "MantidTreeWidget.h" -#include "MantidGroupPlotGenerator.h" -#include "MantidUI.h" -#include "QWorkspaceDockView.h" +#include "MantidQtMantidWidgets/MantidTreeWidget.h" +#include "MantidQtMantidWidgets/WorkspacePresenter/QWorkspaceDockView.h" +#include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" -#include "MantidQtMantidWidgets/WorkspacePresenter/MantidDisplayBase.h" +#include "MantidQtMantidWidgets/MantidDisplayBase.h" #include <QApplication> #include <QDragMoveEvent> @@ -13,13 +12,15 @@ #include <QList> #include <QUrl> -using namespace MantidQt::MantidWidgets; using namespace Mantid::API; namespace { Mantid::Kernel::Logger treelog("MantidTreeWidget"); } +namespace MantidQt { +namespace MantidWidgets { + MantidTreeWidget::MantidTreeWidget(QWorkspaceDockView *w, MantidDisplayBase *mui) : QTreeWidget(w), m_dockWidget(w), m_mantidUI(mui), @@ -141,7 +142,7 @@ void MantidTreeWidget::mouseMoveEvent(QMouseEvent *e) { void MantidTreeWidget::mouseDoubleClickEvent(QMouseEvent *e) { try { - auto wsName = m_dockWidget->getSelectedWorkspaceNames()[0]; + std::string wsName = m_dockWidget->getSelectedWorkspaceNames()[0]; Mantid::API::WorkspaceGroup_sptr grpWSPstr; grpWSPstr = boost::dynamic_pointer_cast<WorkspaceGroup>(m_ads.retrieve(wsName)); @@ -282,8 +283,20 @@ MantidTreeWidget::choosePlotOptions(const QString &type, m_mantidUI->createSurfacePlotDialog(0, selectedMatrixWsNameList, type); dlg->exec(); auto selections = dlg->getSelections(); - std::string errors = - MantidGroupPlotGenerator::validatePlotOptions(selections, nWorkspaces); + std::stringstream err; + + if (selections.accepted) { + if (selections.logName == MantidSurfacePlotDialog::CUSTOM) { + // Check number of values supplied + if (static_cast<int>(selections.customLogValues.size()) != nWorkspaces) { + err << "Number of custom log values must be equal to " + "number of workspaces in group"; + selections.accepted = false; + } + } + } + + auto errors = err.str(); if (!errors.empty()) { MantidSurfacePlotDialog::showPlotOptionsError(errors.c_str()); } @@ -339,4 +352,6 @@ void MantidTreeWidget::sort() { sortItems(sortColumn(), m_sortOrder); } */ void MantidTreeWidget::logWarningMessage(const std::string &msg) { treelog.warning(msg); +} +} } \ No newline at end of file diff --git a/MantidPlot/src/Mantid/MantidTreeWidgetItem.cpp b/MantidQt/MantidWidgets/src/MantidTreeWidgetItem.cpp similarity index 95% rename from MantidPlot/src/Mantid/MantidTreeWidgetItem.cpp rename to MantidQt/MantidWidgets/src/MantidTreeWidgetItem.cpp index 6b07734f8d7..eed5ee7694e 100644 --- a/MantidPlot/src/Mantid/MantidTreeWidgetItem.cpp +++ b/MantidQt/MantidWidgets/src/MantidTreeWidgetItem.cpp @@ -1,11 +1,13 @@ -#include "MantidTreeWidgetItem.h" -#include "MantidTreeWidget.h" +#include "MantidQtMantidWidgets/MantidTreeWidgetItem.h" +#include "MantidQtMantidWidgets/MantidTreeWidget.h" #include <MantidAPI/Workspace.h> using namespace Mantid::Kernel; using namespace Mantid::API; +namespace MantidQt { +namespace MantidWidgets { /**Constructor. * Must be passed its parent MantidTreeWidget, to facilitate correct sorting. */ @@ -99,3 +101,5 @@ DateAndTime MantidTreeWidgetItem::getLastModified(const QTreeWidgetItem *item) { const auto lastAlgHist = wsHist.getAlgorithmHistory(indexOfLast); return lastAlgHist->executionDate(); } +} +} diff --git a/MantidPlot/src/Mantid/MantidWSIndexDialog.cpp b/MantidQt/MantidWidgets/src/MantidWSIndexDialog.cpp similarity index 98% rename from MantidPlot/src/Mantid/MantidWSIndexDialog.cpp rename to MantidQt/MantidWidgets/src/MantidWSIndexDialog.cpp index 987f0cc0823..e0fa462bb72 100644 --- a/MantidPlot/src/Mantid/MantidWSIndexDialog.cpp +++ b/MantidQt/MantidWidgets/src/MantidWSIndexDialog.cpp @@ -1,19 +1,21 @@ //---------------------------------- // Includes //---------------------------------- -#include "MantidWSIndexDialog.h" -#include "MantidUI.h" +#include "MantidQtMantidWidgets/MantidWSIndexDialog.h" #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectraDetectorTypes.h" -#include <stdlib.h> +#include <QPalette> +#include <QPushButton> #include <QRegExp> #include <QtAlgorithms> #include <boost/lexical_cast.hpp> #include <exception> -#include <QPalette> +#include <stdlib.h> +namespace MantidQt { +namespace MantidWidgets { //---------------------------------- // MantidWSIndexWidget methods //---------------------------------- @@ -367,14 +369,14 @@ bool MantidWSIndexWidget::usingSpectraNumbers() const { * @param showPlotAll :: If true the "Plot all" button is created * @param showTiledOption :: If true the "Tiled" checkbox is created */ -MantidWSIndexDialog::MantidWSIndexDialog(MantidUI *mui, Qt::WFlags flags, +MantidWSIndexDialog::MantidWSIndexDialog(QWidget *parent, Qt::WFlags flags, QList<QString> wsNames, const bool showWaterfallOption, const bool showPlotAll, const bool showTiledOption) - : QDialog(mui->appWindow(), flags), + : QDialog(parent, flags), m_widget(this, flags, wsNames, showWaterfallOption, showTiledOption), - m_mantidUI(mui), m_plotAll(showPlotAll) { + m_plotAll(showPlotAll) { // Set up UI. init(); } @@ -854,3 +856,5 @@ void MantidWSIndexWidget::QLineEditWithErrorMark::setError(QString error) { m_validLbl->setToolTip(error.trimmed()); } } +} +} diff --git a/MantidPlot/src/Mantid/QWorkspaceDockView.cpp b/MantidQt/MantidWidgets/src/WorkspacePresenter/QWorkspaceDockView.cpp similarity index 95% rename from MantidPlot/src/Mantid/QWorkspaceDockView.cpp rename to MantidQt/MantidWidgets/src/WorkspacePresenter/QWorkspaceDockView.cpp index fdbe8761666..400837b8ad8 100644 --- a/MantidPlot/src/Mantid/QWorkspaceDockView.cpp +++ b/MantidQt/MantidWidgets/src/WorkspacePresenter/QWorkspaceDockView.cpp @@ -1,19 +1,17 @@ -#include "QWorkspaceDockView.h" -#include "FlowLayout.h" -#include "MantidGroupPlotGenerator.h" -#include "MantidMatrix.h" -#include "MantidTreeWidget.h" -#include "MantidTreeWidgetItem.h" -#include "WorkspaceIcons.h" -#include "pixmaps.h" #include <MantidGeometry/Instrument.h> #include <MantidKernel/make_unique.h> #include <MantidQtAPI/AlgorithmDialog.h> #include <MantidQtAPI/AlgorithmInputHistory.h> +#include <MantidQtAPI/FlowLayout.h> #include <MantidQtAPI/InterfaceManager.h> +#include <MantidQtAPI/WorkspaceIcons.h> +#include <MantidQtAPI/pixmaps.h> #include <MantidQtMantidWidgets/LineEditWithClear.h> -#include <MantidQtMantidWidgets/WorkspacePresenter/MantidDisplayBase.h> +#include <MantidQtMantidWidgets/MantidDisplayBase.h> +#include <MantidQtMantidWidgets/MantidTreeWidget.h> +#include <MantidQtMantidWidgets/MantidTreeWidgetItem.h> #include <MantidQtMantidWidgets/WorkspacePresenter/ADSAdapter.h> +#include <MantidQtMantidWidgets/WorkspacePresenter/QWorkspaceDockView.h> #include <MantidQtMantidWidgets/WorkspacePresenter/WorkspacePresenter.h> #include <MantidAPI/FileProperty.h> @@ -26,16 +24,17 @@ #include <QFileDialog> #include <QHash> +#include <QMainWindow> #include <QMenu> #include <QMessageBox> -#include <QMainWindow> +#include <QPushButton> #include <QSignalMapper> #ifdef MAKE_VATES #include "vtkPVDisplayInformation.h" #endif -using namespace MantidQt::MantidWidgets; +using namespace MantidQt::API; using namespace Mantid::API; using namespace Mantid::Kernel; @@ -44,9 +43,32 @@ namespace { Mantid::Kernel::Logger docklog("MantidDockWidget"); WorkspaceIcons WORKSPACE_ICONS = WorkspaceIcons(); + +bool isAllMatrixWorkspaces(const WorkspaceGroup_const_sptr &wsGroup) { + bool allMatrixWSes = false; + + if (wsGroup) { + if (!wsGroup->isEmpty()) { + allMatrixWSes = true; + for (int index = 0; index < wsGroup->getNumberOfEntries(); index++) { + if (nullptr == boost::dynamic_pointer_cast<MatrixWorkspace>( + wsGroup->getItem(index))) { + allMatrixWSes = false; + break; + } + } + } + } + + return allMatrixWSes; } +} + +namespace MantidQt { +namespace MantidWidgets { -QWorkspaceDockView::QWorkspaceDockView(MantidDisplayBase *mui, QMainWindow *parent) +QWorkspaceDockView::QWorkspaceDockView(MantidDisplayBase *mui, + QMainWindow *parent) : QDockWidget(tr("Workspaces"), parent), m_mantidUI(mui), m_updateCount(0), m_treeUpdating(false), m_promptDelete(false), m_saveFileType(SaveFileType::Nexus), m_sortCriteria(SortCriteria::ByName), @@ -223,7 +245,9 @@ void QWorkspaceDockView::onLoadAccept() { m_mantidUI->updateRecentFilesList(fn); } -void QWorkspaceDockView::showLoadDialog() { m_mantidUI->showAlgorithmDialog("Load"); } +void QWorkspaceDockView::showLoadDialog() { + m_mantidUI->showAlgorithmDialog("Load"); +} void QWorkspaceDockView::showLiveDataDialog() { m_mantidUI->showAlgorithmDialog("StartLiveData"); @@ -343,14 +367,6 @@ void QWorkspaceDockView::deleteWorkspaces(const StringList &wsNames) { void QWorkspaceDockView::clearView() { emit signalClearView(); } -QWorkspaceDockView::SortDirection QWorkspaceDockView::getSortDirection() const { - return m_sortDirection; -} - -QWorkspaceDockView::SortCriteria QWorkspaceDockView::getSortCriteria() const { - return m_sortCriteria; -} - void QWorkspaceDockView::sortAscending() { m_sortDirection = SortDirection::Ascending; m_presenter->notifyFromView(ViewNotifiable::Flag::SortWorkspaces); @@ -400,10 +416,6 @@ void QWorkspaceDockView::sortWorkspaces(SortCriteria criteria, m_tree->sort(); } -QWorkspaceDockView::SaveFileType QWorkspaceDockView::getSaveFileType() const { - return m_saveFileType; -} - void QWorkspaceDockView::saveWorkspaceCollection() { m_presenter->notifyFromView(ViewNotifiable::Flag::SaveWorkspaceCollection); } @@ -1028,7 +1040,7 @@ void QWorkspaceDockView::addWorkspaceGroupMenuItems( // - only one group is selected if (m_tree->selectedItems().size() == 1) { if (groupWS && groupWS->getNumberOfEntries() > 2) { - if (MantidGroupPlotGenerator::groupIsAllMatrixWorkspaces(groupWS)) { + if (isAllMatrixWorkspaces(groupWS)) { menu->addAction(m_plotSurface); m_plotSurface->setEnabled(true); menu->addAction(m_plotContour); @@ -1230,7 +1242,7 @@ void QWorkspaceDockView::popupContextMenu() { menu->setObjectName("WorkspaceContextMenu"); auto mantidTreeItem = dynamic_cast<MantidTreeWidgetItem *>(treeItem); auto ws = mantidTreeItem->data(0, Qt::UserRole) - .value<Mantid::API::Workspace_const_sptr>(); + .value<Mantid::API::Workspace_sptr>(); // Add the items that are appropriate for the type if (auto matrixWS = @@ -1537,8 +1549,8 @@ void QWorkspaceDockView::onClickShowDetectorTable() { void QWorkspaceDockView::showDetectorsTable() { // get selected workspace auto ws = getSelectedWorkspaceNames()[0]; - m_mantidUI->createDetectorTable(QString::fromStdString(ws), std::vector<int>(), - false); + m_mantidUI->createDetectorTable(QString::fromStdString(ws), + std::vector<int>(), false); } void QWorkspaceDockView::onClickShowBoxData() { @@ -1653,7 +1665,7 @@ void QWorkspaceDockView::clearUBMatrix() { if (alg) { alg->initialize(); alg->setPropertyValue("Workspace", ws); - m_mantidUI->executeAlgorithmAsync(alg); + m_mantidUI->executeAlgorithmAsync(alg); } else break; } @@ -1666,24 +1678,7 @@ void QWorkspaceDockView::onClickPlotSurface() { m_presenter->notifyFromView(ViewNotifiable::Flag::ShowSurfacePlot); } -void QWorkspaceDockView::showSurfacePlot() { - // find the workspace group clicked on - auto items = m_tree->selectedItems(); - if (!items.empty()) { - auto data = items[0]->data(0, Qt::UserRole).value<Workspace_sptr>(); - const auto wsGroup = - boost::dynamic_pointer_cast<const WorkspaceGroup>(data); - if (wsGroup) { - auto options = - m_tree->chooseSurfacePlotOptions(wsGroup->getNumberOfEntries()); - - // TODO: Figure out how to get rid of MantidUI dependency here. - auto plotter = - Mantid::Kernel::make_unique<MantidGroupPlotGenerator>(m_mantidUI); - plotter->plotSurface(wsGroup, options); - } - } -} +void QWorkspaceDockView::showSurfacePlot() { m_mantidUI->showSurfacePlot(); } /** * Create a contour plot from the selected workspace group @@ -1692,20 +1687,6 @@ void QWorkspaceDockView::onClickPlotContour() { m_presenter->notifyFromView(ViewNotifiable::Flag::ShowContourPlot); } -void QWorkspaceDockView::showContourPlot() { - auto items = m_tree->selectedItems(); - if (!items.empty()) { - auto data = items[0]->data(0, Qt::UserRole).value<Workspace_sptr>(); - const auto wsGroup = - boost::dynamic_pointer_cast<const WorkspaceGroup>(data); - if (wsGroup) { - auto options = - m_tree->chooseContourPlotOptions(wsGroup->getNumberOfEntries()); - - // TODO: Figure out how to remove the MantidUI dependency - auto plotter = - Mantid::Kernel::make_unique<MantidGroupPlotGenerator>(m_mantidUI); - plotter->plotContour(wsGroup, options); - } - } +void QWorkspaceDockView::showContourPlot() { m_mantidUI->showContourPlot(); } +} } -- GitLab