diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.cxx b/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.cxx index fb147413c4823dcc545ce1ecfc6d06443605456c..638613a7b1297286ce5154c95947bb02b6bc0e78 100644 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.cxx +++ b/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.cxx @@ -22,7 +22,7 @@ using namespace Mantid::VATES; vtkStandardNewMacro(vtkMDEWSource); /// Constructor -vtkMDEWSource::vtkMDEWSource() : m_wsName(""), m_depth(1000), m_time(0), m_presenter(NULL) +vtkMDEWSource::vtkMDEWSource() : m_wsName(""), m_depth(1000), m_time(0), m_presenter(NULL), m_isStartup(true), m_startupTimeValue(0) { this->SetNumberOfInputPorts(0); this->SetNumberOfOutputPorts(1); @@ -173,8 +173,16 @@ int vtkMDEWSource::RequestData(vtkInformation *, vtkInformationVector **, vtkInf //get the info objects vtkInformation *outInfo = outputVector->GetInformationObject(0); - - if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) + if (m_isStartup) + { + // This is part of a workaround for ParaView time steps. The time we get + // is the first time point for all sources, and not necessarily of this source. + // This causes problems when getting the time slice and we end up with an empty + // data set. We therefore feed m_time the first time step of this source at + // start up. + m_time = m_startupTimeValue; + } + else if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) { // usually only one actual step requested m_time =outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); @@ -256,6 +264,9 @@ void vtkMDEWSource::setTimeRange(vtkInformationVector* outputVector) timeRange[0] = timeStepValues.front(); timeRange[1] = timeStepValues.back(); + // This is part of a workaround to get the first time value of the current source. + m_startupTimeValue = timeRange[0]; + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2); } } diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.h b/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.h index abe5da855e30b484af89bfdfc2fb871a45c1814f..f2f7a3e1b19a7f18b745d13e0ad602e782116fc2 100644 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.h +++ b/Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDEWSource/vtkMDEWSource.h @@ -97,6 +97,17 @@ private: /// Cached typename. std::string typeName; + + // This is part of a workaround for a ParaView providing not the start time of + // of current data set. + ///Startup flag + bool m_isStartup; + + // This is part of a workaround for a ParaView providing not the start time of + // of current data set. + /// Startup time value + double m_startupTimeValue; + vtkMDEWSource(const vtkMDEWSource&); void operator = (const vtkMDEWSource&); void setTimeRange(vtkInformationVector* outputVector); diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt index b9e72fc0d15f55eb16eab8d122e4f9a19c0c3af3..07fddbf79bfd48272ab56e98cdf4f161f97510fe 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt @@ -8,9 +8,9 @@ set( INCLUDE_FILES inc/MantidVatesSimpleGuiViewWidgets/LibHelper.h inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h inc/MantidVatesSimpleGuiViewWidgets/MultisliceView.h - inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h + inc/MantidVatesSImpleGuiViewWidgets/RebinAlgorithmDialogProvider.h inc/MantidVatesSimpleGuiViewWidgets/SaveScreenshotReaction.h - inc/MantidVatesSimpleGuiViewWidgets/SourcesManager.h + inc/MantidVatesSimpleGuiViewWidgets/RebinnedSourcesManager.h inc/MantidVatesSimpleGuiViewWidgets/StandardView.h inc/MantidVatesSimpleGuiViewWidgets/SplatterPlotView.h inc/MantidVatesSimpleGuiViewWidgets/ThreesliceView.h @@ -25,9 +25,9 @@ set( SOURCE_FILES src/ColorUpdater.cpp src/MdViewerWidget.cpp src/MultisliceView.cpp - src/RebinManager.cpp + src/RebinAlgorithmDialogProvider.cpp src/SaveScreenshotReaction.cpp - src/SourcesManager.cpp + src/RebinnedSourcesManager.cpp src/StandardView.cpp src/SplatterPlotView.cpp src/ThreesliceView.cpp @@ -41,9 +41,8 @@ qt4_wrap_cpp( MOC_SOURCES inc/MantidVatesSimpleGuiViewWidgets/ColorSelectionWidget.h inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h inc/MantidVatesSimpleGuiViewWidgets/MultisliceView.h - inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h inc/MantidVatesSimpleGuiViewWidgets/SaveScreenshotReaction.h - inc/MantidVatesSimpleGuiViewWidgets/SourcesManager.h + inc/MantidVatesSimpleGuiViewWidgets/RebinnedSourcesManager.h inc/MantidVatesSimpleGuiViewWidgets/StandardView.h inc/MantidVatesSimpleGuiViewWidgets/SplatterPlotView.h inc/MantidVatesSimpleGuiViewWidgets/ThreesliceView.h diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h index 6b50c52e17db965107f936ced2bf5e111735ac26..b1beb14b94ab29f85d25ba3666bbfdee76390652 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h @@ -3,8 +3,8 @@ #include "ui_MdViewerWidget.h" #include "MantidVatesSimpleGuiViewWidgets/WidgetDllOption.h" -#include "MantidVatesSimpleGuiViewWidgets/RebinManager.h" -#include "MantidVatesSimpleGuiViewWidgets/SourcesManager.h" +#include "MantidVatesSimpleGuiViewWidgets/RebinAlgorithmDialogProvider.h" +#include "MantidVatesSimpleGuiViewWidgets/RebinnedSourcesManager.h" #include "MantidQtAPI/VatesViewerInterface.h" #include "MantidQtAPI/WorkspaceObserver.h" @@ -108,8 +108,8 @@ protected slots: void onRebin(std::string algorithmType); /// On unbin void onUnbin(); - /// On switching an MDEvent source to a temporary MDHisto source. - void onSwitchSoures(std::string temporaryWorkspaceName, std::string sourceType); + /// On switching an MDEvent source to a temporary source. + void onSwitchSoures(std::string rebinnedWorkspaceName, std::string sourceType); protected: /// Handle workspace preDeletion tasks. @@ -136,9 +136,9 @@ private: pqViewSettingsReaction *viewSettings; ///< Holder for the view settings reaction bool viewSwitched; ModeControlWidget::Views initialView; ///< Holds the initial view - RebinManager m_rebinManager; ///<Holds the rebin manager - SourcesManager m_temporarySourcesManager; ///<Holds the sources manager - QString m_temporaryWorkspaceIdentifier; ///< Holds the identifier for temporary workspaces + RebinAlgorithmDialogProvider m_rebinAlgorithmDialogProvider; ///<Provides dialogs to execute rebin algorithms + RebinnedSourcesManager m_rebinnedSourcesManager; ///<Holds the rebinned sources manager + QString m_rebinnedWorkspaceIdentifier; ///< Holds the identifier for temporary workspaces /// Check the environmental variables. void checkEnvSetup(); @@ -186,8 +186,8 @@ private: bool checkIfTechniqueContainsKeyword(const std::set<std::string>& techniques, const std::string& keyword) const; /// Reset the current view to the appropriate initial view. void resetCurrentView(int workspaceType, const std::string& instrumentName); - /// Render temporary workspace - void prepareTemporaryWorkspace(const std::string temporaryWorkspaceName, std::string sourceType); + /// Render rebinned workspace + void prepareRebinnedWorkspace(const std::string rebinnedWorkspaceName, std::string sourceType); /// Set visibility listener void setVisibilityListener(); /// Render the original workspace diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinAlgorithmDialogProvider.h similarity index 90% rename from Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h rename to Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinAlgorithmDialogProvider.h index 22af0dbfa16b2efa1b9a4894388fb710ac56d744..4c6ff44a6ffcbbe3b817dab6d64aaba8540e5238 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinAlgorithmDialogProvider.h @@ -1,16 +1,14 @@ -#ifndef REBINMANAGER_H_ -#define REBINMANAGER_H_ +#ifndef REBINALGORITHMDIALOGPROVIDER_H_ +#define REBINALGORITHMDIALOGPROVIDER_H_ #include "MantidVatesSimpleGuiViewWidgets/WidgetDllOption.h" + #include "MantidVatesAPI/ADSWorkspaceProvider.h" #include "MantidAPI/IMDEventWorkspace.h" #include "MantidAPI/Algorithm.h" #include "MantidQtAPI/AlgorithmDialog.h" #include "MantidQtMantidWidgets/SlicingAlgorithmDialog.h" -#include <QWidget> - - namespace Mantid { namespace Vates @@ -44,13 +42,12 @@ namespace Mantid File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ - class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS RebinManager : public QWidget + class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS RebinAlgorithmDialogProvider { - Q_OBJECT public: - RebinManager(QWidget* parent = 0); + RebinAlgorithmDialogProvider(QWidget* parent); - ~RebinManager(); + ~RebinAlgorithmDialogProvider(); void showDialog(std::string inputWorkspace, std::string outputWorkspace, std::string algorithmType); @@ -72,6 +69,7 @@ namespace Mantid QString m_lblInputWorkspace; QString m_lblOutputWorkspace; size_t m_binCutOffValue; + QWidget* m_parent; }; } // SimpleGui diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/SourcesManager.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinnedSourcesManager.h similarity index 64% rename from Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/SourcesManager.h rename to Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinnedSourcesManager.h index 5540aa686502c2e2fce5f50b712408fb475ab57f..304b71221b81845c18e031bb662514ba31abd08a 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/SourcesManager.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinnedSourcesManager.h @@ -1,5 +1,5 @@ -#ifndef SOURCESMANAGER_H_ -#define SOURCESMANAGER_H_ +#ifndef REBINNEDSOURCESMANAGER_H_ +#define REBINNEDSOURCESMANAGER_H_ #include "MantidVatesSimpleGuiViewWidgets/WidgetDllOption.h" #include "MantidQtAPI/WorkspaceObserver.h" @@ -30,8 +30,8 @@ namespace Mantid { /** * - This class keeps track of the MDEvent workspaces and associated temporary MDHisto workspaces. Rebinning requires temporary MDHisto workspaces instead of - the MDEvent workspaces. This class switches between these types of sources. + This class keeps track of the MDEvent workspaces and associated rebinned workspaces. Rebinning requires temporary workspaces instead of + the original MDEvent workspaces. This class switches between these types of sources. @date 21/01/2015 @@ -55,44 +55,44 @@ namespace Mantid File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ - class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS SourcesManager :public QWidget, MantidQt::API::WorkspaceObserver + class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS RebinnedSourcesManager :public QWidget, MantidQt::API::WorkspaceObserver { Q_OBJECT public: - SourcesManager(QWidget* parent = 0); + RebinnedSourcesManager(QWidget* parent = 0); - ~SourcesManager(); + ~RebinnedSourcesManager(); void checkSource(pqPipelineSource* source, std::string& inputWorkspace, std::string& outputWorkspace, std::string algorithmType); - void repipeTemporarySource(std::string temporarySource, std::string& sourceToBeDeleted); + void repipeRebinnedSource(std::string rebinnedSource, std::string& sourceToBeDeleted); - void repipeOriginalSource(std::string temporarySource, std::string originalSource); + void repipeOriginalSource(std::string rebinnedSource, std::string originalSource); - void getStoredWorkspaceNames(pqPipelineSource* source, std::string& originalWorkspaceName, std::string& temporaryWorkspaceName); + void getStoredWorkspaceNames(pqPipelineSource* source, std::string& originalWorkspaceName, std::string& rebinnedWorkspaceName); - void registerTemporarySource(pqPipelineSource* source); + void registerRebinnedSource(pqPipelineSource* source); - bool isTemporarySource(std::string name); + bool isRebinnedSource(std::string name); signals: - void switchSources(std::string temporaryWorkspaceName, std::string sourceType); + void switchSources(std::string rebinnedWorkspaceName, std::string sourceType); void triggerAcceptForNewFilters(); protected: void addHandle(const std::string &workspaceName, const boost::shared_ptr<Mantid::API::Workspace> workspace); - void SourcesManager::preDeleteHandle(const std::string &wsName, const boost::shared_ptr<Mantid::API::Workspace> ws); + void preDeleteHandle(const std::string &wsName, const boost::shared_ptr<Mantid::API::Workspace> ws); private slots: - void onTemporarySourceDestroyed(); + void onRebinnedSourceDestroyed(); private: - std::map<std::string, std::string> m_originalWorkspaceToTemporaryWorkspace; ///< Holds the mapping from the original source to the temporary source + std::map<std::string, std::string> m_originalWorkspaceToRebinnedWorkspace; ///< Holds the mapping from the original source to the rebinned source - std::map<std::string, std::string> m_temporaryWorkspaceToOriginalWorkspace; ///< Holds the mapping from the temporary source to the original source + std::map<std::string, std::string> m_rebinnedWorkspaceToOriginalWorkspace; ///< Holds the mapping from the rebinned source to the original source - std::map<std::string, std::string> m_temporaryWorkspaceToTemporaryWorkspace; ///< Holds information from a temporary source to another temproary source which replaces it. + std::map<std::string, std::string> m_rebinnedWorkspaceToRebinnedWorkspace; ///< Holds information from a rebinned source to another temproary source which replaces it. std::string m_tempPostfix; @@ -106,11 +106,11 @@ namespace Mantid void processWorkspaceNames(std::string& inputWorkspace, std::string& outputWorkspace, std::string workspaceName, std::string algorithmType); - void removeUnusedTemporaryWorkspaces(); + void removeUnusedRebinnedWorkspaces(); - void untrackWorkspaces(std::string temporarySource); + void untrackWorkspaces(std::string rebinnedSource); - void removeTemporaryWorkspace(std::string temporaryWorkspace); + void removeRebinnedWorkspace(std::string rebinnedWorkspace); void compareToSources(std::string workspaceName); diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp index ca7ba1b855e44a603eb296161751bfdc15010cc3..5c3933100119e932ae13b465bc0efbc49344a0da 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp @@ -9,7 +9,6 @@ #include "MantidVatesSimpleGuiViewWidgets/StandardView.h" #include "MantidVatesSimpleGuiViewWidgets/ThreesliceView.h" #include "MantidVatesSimpleGuiViewWidgets/TimeControlWidget.h" - #include "MantidQtAPI/InterfaceManager.h" #include "MantidKernel/DynamicFactory.h" #include "MantidKernel/Logger.h" @@ -122,7 +121,7 @@ REGISTER_VATESGUI(MdViewerWidget) */ MdViewerWidget::MdViewerWidget() : VatesViewerInterface(), currentView(NULL), dataLoader(NULL), hiddenView(NULL), lodAction(NULL), screenShot(NULL), viewLayout(NULL), - viewSettings(NULL), m_temporaryWorkspaceIdentifier("_tempvsi") + viewSettings(NULL), m_rebinAlgorithmDialogProvider(this), m_rebinnedWorkspaceIdentifier("_tempvsi") { // Calling workspace observer functions. observeAfterReplace(); @@ -131,8 +130,8 @@ MdViewerWidget::MdViewerWidget() : VatesViewerInterface(), currentView(NULL), this->internalSetup(true); - // Connect the temporary sources manager - QObject::connect(&m_temporarySourcesManager, SIGNAL(switchSources(std::string, std::string)), + // Connect the rebinned sources manager + QObject::connect(&m_rebinnedSourcesManager, SIGNAL(switchSources(std::string, std::string)), this, SLOT(onSwitchSoures(std::string, std::string))); } @@ -140,7 +139,7 @@ MdViewerWidget::MdViewerWidget() : VatesViewerInterface(), currentView(NULL), * This constructor is used in the standalone mode operation of the VSI. * @param parent the parent widget for the main window */ -MdViewerWidget::MdViewerWidget(QWidget *parent) : VatesViewerInterface(parent) +MdViewerWidget::MdViewerWidget(QWidget *parent) : VatesViewerInterface(parent), m_rebinAlgorithmDialogProvider(this) { this->checkEnvSetup(); // We're in the standalone application mode @@ -214,8 +213,8 @@ void MdViewerWidget::setupUiAndConnections() this, SLOT(onRotationPoint())); - // Connect the temporary sources manager - QObject::connect(&m_temporarySourcesManager, + // Connect the rebinned sources manager + QObject::connect(&m_rebinnedSourcesManager, SIGNAL(triggerAcceptForNewFilters()), this->ui.propertiesPanel, SLOT(apply())); @@ -486,33 +485,32 @@ void MdViewerWidget::onRebin(std::string algorithmType) std::string inputWorkspaceName; std::string outputWorkspaceName; - - m_temporarySourcesManager.checkSource(source, inputWorkspaceName, outputWorkspaceName, algorithmType); - m_rebinManager.showDialog(inputWorkspaceName, outputWorkspaceName, algorithmType); + m_rebinnedSourcesManager.checkSource(source, inputWorkspaceName, outputWorkspaceName, algorithmType); + m_rebinAlgorithmDialogProvider.showDialog(inputWorkspaceName, outputWorkspaceName, algorithmType); } /** * Switch a source. - * @param temporaryWorkspaceName The name of the temporary workspace. + * @param rebinnedWorkspaceName The name of the rebinned workspace. * @param sourceType The type of the source. */ -void MdViewerWidget::onSwitchSoures(std::string temporaryWorkspaceName, std::string sourceType) +void MdViewerWidget::onSwitchSoures(std::string rebinnedWorkspaceName, std::string sourceType) { - // Create the temporary workspace - prepareTemporaryWorkspace(temporaryWorkspaceName, sourceType); + // Create the rebinned workspace + prepareRebinnedWorkspace(rebinnedWorkspaceName, sourceType); try { std::string sourceToBeDeleted; - // Repipe the filters to the temporary source - m_temporarySourcesManager.repipeTemporarySource(temporaryWorkspaceName, sourceToBeDeleted); + // Repipe the filters to the rebinned source + m_rebinnedSourcesManager.repipeRebinnedSource(rebinnedWorkspaceName, sourceToBeDeleted); // Remove the original source deleteSpecificSource(sourceToBeDeleted); // Update the color scale - renderAndFinalSetup(); + this->currentView->onAutoScale(this->ui.colorSelectionWidget); // Set the splatterplot button explicitly this->currentView->setSplatterplot(true); @@ -524,21 +522,23 @@ void MdViewerWidget::onSwitchSoures(std::string temporaryWorkspaceName, std::str } /** - * Creates and renders a temporary workspace source - * @param temporaryWorkspaceName The name of the temporary workspace. + * Creates and renders a rebinned workspace source + * @param rebinnedWorkspaceName The name of the rebinned workspace. * @param sourceType The name of the source plugin. */ -void MdViewerWidget::prepareTemporaryWorkspace(const std::string temporaryWorkspaceName, std::string sourceType) +void MdViewerWidget::prepareRebinnedWorkspace(const std::string rebinnedWorkspaceName, std::string sourceType) { // Load a new source plugin - pqPipelineSource* newTemporarySource = this->currentView->setPluginSource(QString::fromStdString(sourceType), QString::fromStdString(temporaryWorkspaceName)); + pqPipelineSource* newRebinnedSource = this->currentView->setPluginSource(QString::fromStdString(sourceType), QString::fromStdString(rebinnedWorkspaceName)); // It seems that the new source gets set as active before it is fully constructed. We therefore reset it. pqActiveObjects::instance().setActiveSource(NULL); - pqActiveObjects::instance().setActiveSource(newTemporarySource); - m_temporarySourcesManager.registerTemporarySource(newTemporarySource); + pqActiveObjects::instance().setActiveSource(newRebinnedSource); + m_rebinnedSourcesManager.registerRebinnedSource(newRebinnedSource); this->renderAndFinalSetup(); + + this->currentView->onAutoScale(this->ui.colorSelectionWidget); } /** @@ -550,6 +550,9 @@ void MdViewerWidget::renderOriginalWorkspace(const std::string originalWorkspace // Load a new source plugin QString sourcePlugin = "MDEW Source"; this->currentView->setPluginSource(sourcePlugin, QString::fromStdString(originalWorkspaceName)); + + // Render and final setup + this->renderAndFinalSetup(); } @@ -576,12 +579,12 @@ void MdViewerWidget::removeRebinning(pqPipelineSource* source, bool forced, Mode if (forced || view == ModeControlWidget::SPLATTERPLOT) { std::string originalWorkspaceName; - std::string temporaryWorkspaceName; - m_temporarySourcesManager.getStoredWorkspaceNames(source, originalWorkspaceName, temporaryWorkspaceName); + std::string rebinnedWorkspaceName; + m_rebinnedSourcesManager.getStoredWorkspaceNames(source, originalWorkspaceName, rebinnedWorkspaceName); // If the active source has not been rebinned, then send a reminder to the user that only rebinned sources // can be unbinned - if (originalWorkspaceName.empty() || temporaryWorkspaceName.empty()) + if (originalWorkspaceName.empty() || rebinnedWorkspaceName.empty()) { if (forced == true) { @@ -599,18 +602,18 @@ void MdViewerWidget::removeRebinning(pqPipelineSource* source, bool forced, Mode // Repipe the filters to the original source try { - m_temporarySourcesManager.repipeOriginalSource(temporaryWorkspaceName, originalWorkspaceName); + m_rebinnedSourcesManager.repipeOriginalSource(rebinnedWorkspaceName, originalWorkspaceName); } catch (const std::runtime_error& error) { g_log.warning() << error.what(); } - // Remove the temporary workspace source - deleteSpecificSource(temporaryWorkspaceName); + // Remove the rebinned workspace source + deleteSpecificSource(rebinnedWorkspaceName); // Render and final setup - this->renderAndFinalSetup(); + pqActiveObjects::instance().activeView()->forceRender(); // Set the buttons correctly if we switch to splatterplot if ( view == ModeControlWidget::SPLATTERPLOT) @@ -627,7 +630,7 @@ void MdViewerWidget::removeRebinning(pqPipelineSource* source, bool forced, Mode */ void MdViewerWidget::removeAllRebinning(ModeControlWidget::Views view) { - // Iterate over all temporary sources and remove them + // Iterate over all rebinned sources and remove them pqServer *server = pqActiveObjects::instance().activeServer(); pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel(); QList<pqPipelineSource *> sources = smModel->findItems<pqPipelineSource *>(server); @@ -703,11 +706,11 @@ void MdViewerWidget::renderWorkspace(QString workspaceName, int workspaceType, s sourcePlugin = "MDEW Source"; } - // Make sure that we are not loading a temporary vsi workspace. - if (workspaceName.contains(m_temporaryWorkspaceIdentifier)) + // Make sure that we are not loading a rebinned vsi workspace. + if (workspaceName.contains(m_rebinnedWorkspaceIdentifier)) { QMessageBox::information(this, QApplication::tr("Loading Source Warning"), - QApplication::tr("You cannot laod a temporary vsi source. \n "\ + QApplication::tr("You cannot load a rebinned rebinned vsi source. \n "\ "Please select another source.")); return; @@ -1293,7 +1296,7 @@ void MdViewerWidget::afterReplaceHandle(const std::string &wsName, /** * This function responds to a workspace being deleted. If there are one or * more PeaksWorkspaces present, the requested one will be deleted. If the - * deleted source is a temporary source, then we revert back to the + * deleted source is a rebinned source, then we revert back to the * original source. Otherwise, if it is an IMDWorkspace, everything goes! * @param wsName : Name of workspace being deleted * @param ws : Pointer to workspace being deleted @@ -1317,8 +1320,8 @@ void MdViewerWidget::preDeleteHandle(const std::string &wsName, } } - // Check if temporary source and perform an unbinning - if (m_temporarySourcesManager.isTemporarySource(wsName)) + // Check if rebinned source and perform an unbinning + if (m_rebinnedSourcesManager.isRebinnedSource(wsName)) { removeRebinning(src, true); return; diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinManager.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinAlgorithmDialogProvider.cpp similarity index 86% rename from Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinManager.cpp rename to Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinAlgorithmDialogProvider.cpp index b522ebfb32dad683e02061baf2a479fe9de2cddc..e109f25a617cc0713073f6ef9cb0b0cce1d547a6 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinManager.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinAlgorithmDialogProvider.cpp @@ -1,4 +1,4 @@ -#include "MantidVatesSimpleGuiViewWidgets/RebinManager.h" +#include "MantidVatesSimpleGuiViewWidgets/RebinAlgorithmDialogProvider.h" #include "MantidVatesAPI/ADSWorkspaceProvider.h" #include "MantidAPI/Algorithm.h" #include "MantidQtAPI/InterfaceManager.h" @@ -34,19 +34,20 @@ namespace Mantid namespace { - Mantid::Kernel::Logger g_log("RebinManager"); + Mantid::Kernel::Logger g_log("RebinAlgorithmDialogProvider"); } - RebinManager::RebinManager(QWidget* parent) : QWidget(parent), + RebinAlgorithmDialogProvider::RebinAlgorithmDialogProvider(QWidget* parent) : m_binMdVersion(1), m_binMdName("BinMD"), m_lblInputWorkspace("InputWorkspace"), m_lblOutputWorkspace("OutputWorkspace"), - m_binCutOffValue(50) + m_binCutOffValue(50), + m_parent(parent) { } - RebinManager::~RebinManager() + RebinAlgorithmDialogProvider::~RebinAlgorithmDialogProvider() { } @@ -56,7 +57,7 @@ namespace Mantid * @param outputWorkspace The name of the output workspace. * @param algorithmType The type of algorithm which is to be used for rebinning. */ - void RebinManager::showDialog(std::string inputWorkspace, std::string outputWorkspace, std::string algorithmType) + void RebinAlgorithmDialogProvider::showDialog(std::string inputWorkspace, std::string outputWorkspace, std::string algorithmType) { if (inputWorkspace.empty() || outputWorkspace.empty()) { @@ -83,7 +84,7 @@ namespace Mantid * @param workspaceName The name of the input workspace. * @returns A pointer to the current event workspace */ - Mantid::API::IMDEventWorkspace_sptr RebinManager::getWorkspace(std::string workspaceName) + Mantid::API::IMDEventWorkspace_sptr RebinAlgorithmDialogProvider::getWorkspace(std::string workspaceName) { Mantid::API::IMDEventWorkspace_sptr eventWorkspace; @@ -107,7 +108,7 @@ namespace Mantid * @param version The version of the algorithm * @returns A pointer to the newly created algorithm. */ - Mantid::API::IAlgorithm_sptr RebinManager::createAlgorithm(const std::string& algorithmName, int version) + Mantid::API::IAlgorithm_sptr RebinAlgorithmDialogProvider::createAlgorithm(const std::string& algorithmName, int version) { Mantid::API::IAlgorithm_sptr alg; try @@ -128,7 +129,7 @@ namespace Mantid * @param outputWorkspace The name of the output workspace. * @returns The algorithm dialog */ - MantidQt::API::AlgorithmDialog* RebinManager::createDialog(Mantid::API::IAlgorithm_sptr algorithm, + MantidQt::API::AlgorithmDialog* RebinAlgorithmDialogProvider::createDialog(Mantid::API::IAlgorithm_sptr algorithm, std::string inputWorkspace, std::string outputWorkspace, std::string algorithmType) @@ -143,16 +144,16 @@ namespace Mantid // Set the correct algorithm dialog if (algorithmType == "BinMD") { - dialog = new MantidQt::MantidWidgets::BinMDDialog(this); + dialog = new MantidQt::MantidWidgets::BinMDDialog(m_parent); getPresetsForSliceMDAlgorithmDialog(inputWorkspace, outputWorkspace, presets); } else if (algorithmType == "SliceMD") { - dialog = new MantidQt::MantidWidgets::SliceMDDialog(this); + dialog = new MantidQt::MantidWidgets::SliceMDDialog(m_parent); getPresetsForSliceMDAlgorithmDialog(inputWorkspace, outputWorkspace, presets); } else if (algorithmType == "CutMD") { - + return dialog; } else { @@ -160,7 +161,7 @@ namespace Mantid } // The parent so that the dialog appears on top of it - dialog->setParent(this); + dialog->setParent(m_parent); dialog->setAttribute(Qt::WA_DeleteOnClose, true); // Set the QDialog window flags to ensure the dialog ends up on top @@ -203,7 +204,7 @@ namespace Mantid * @param outputWorkspace The name of the output workspace. * @param presets A container for the preset values. */ - void RebinManager::getPresetsForSliceMDAlgorithmDialog(std::string inputWorkspace, std::string outputWorkspace, QHash<QString, QString>& presets) + void RebinAlgorithmDialogProvider::getPresetsForSliceMDAlgorithmDialog(std::string inputWorkspace, std::string outputWorkspace, QHash<QString, QString>& presets) { // Set the input workspace presets.insert(QString(m_lblInputWorkspace),QString::fromStdString(inputWorkspace)); @@ -217,7 +218,7 @@ namespace Mantid * @param dialog A pointer to the SliceMDDialog * @param inputWorkspace The name of the input workspace. */ - void RebinManager::setAxisDimensions(MantidQt::MantidWidgets::SlicingAlgorithmDialog* dialog, std::string inputWorkspace) + void RebinAlgorithmDialogProvider::setAxisDimensions(MantidQt::MantidWidgets::SlicingAlgorithmDialog* dialog, std::string inputWorkspace) { Mantid::API::IMDEventWorkspace_sptr eventWorkspace = getWorkspace(inputWorkspace); diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/SourcesManager.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinnedSourcesManager.cpp similarity index 67% rename from Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/SourcesManager.cpp rename to Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinnedSourcesManager.cpp index 9aaa8654f56901921285cd610c0b17bfb566b63c..fe93fd21f30afe51098b0e403ad938ec780811cb 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/SourcesManager.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinnedSourcesManager.cpp @@ -1,4 +1,4 @@ -#include "MantidVatesSimpleGuiViewWidgets/SourcesManager.h" +#include "MantidVatesSimpleGuiViewWidgets/RebinnedSourcesManager.h" #include "MantidVatesAPI/ADSWorkspaceProvider.h" #include "MantidQtAPI/WorkspaceObserver.h" #include "MantidAPI/AnalysisDataService.h" @@ -48,27 +48,27 @@ namespace Mantid namespace { - Mantid::Kernel::Logger g_log("SourcesManager"); + Mantid::Kernel::Logger g_log("RebinnedSourcesManager"); } - SourcesManager::SourcesManager(QWidget* parent) : QWidget(parent), m_tempPostfix("_tempvsi"), m_tempPrefix("__") + RebinnedSourcesManager::RebinnedSourcesManager(QWidget* parent) : QWidget(parent), m_tempPostfix("_tempvsi"), m_tempPrefix("__") { observeAdd(); observePreDelete(); } - SourcesManager::~SourcesManager() + RebinnedSourcesManager::~RebinnedSourcesManager() { } /** - * Checks if a temporary MDHisto workspace was added and invokes a replacement procedure + * Checks if a rebinned MDHisto workspace was added and invokes a replacement procedure * @param workspaceName Name of the workspace. * @param workspace A pointer to the added workspace. */ - void SourcesManager::addHandle(const std::string &workspaceName, Mantid::API::Workspace_sptr workspace) + void RebinnedSourcesManager::addHandle(const std::string &workspaceName, Mantid::API::Workspace_sptr workspace) { - if (m_temporaryWorkspaceToOriginalWorkspace.count(workspaceName) > 0 || m_temporaryWorkspaceToTemporaryWorkspace.count(workspaceName) > 0) + if (m_rebinnedWorkspaceToOriginalWorkspace.count(workspaceName) > 0 || m_rebinnedWorkspaceToRebinnedWorkspace.count(workspaceName) > 0) { std::string sourceType; Mantid::API::IMDEventWorkspace_sptr eventWorkspace = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(workspace); @@ -92,18 +92,18 @@ namespace Mantid } /** - * Catch the deletion of either the temporary or the original workspace. + * Catch the deletion of either the rebinned or the original workspace. * @param wsName The name of the workspace. * @param ws The handle to the workspace */ - void SourcesManager::preDeleteHandle(const std::string &wsName, const boost::shared_ptr<Mantid::API::Workspace> ws) + void RebinnedSourcesManager::preDeleteHandle(const std::string &wsName, const boost::shared_ptr<Mantid::API::Workspace> ws) { - // If the original workspace has been deleted, then delete the temporary + // If the original workspace has been deleted, then delete the rebinned // source (and workspace via the listener) - if (m_originalWorkspaceToTemporaryWorkspace.count(wsName)) + if (m_originalWorkspaceToRebinnedWorkspace.count(wsName)) { - // Get the temporary source and destroy the entire pipeline - pqPipelineSource* source = getSourceForWorkspace(m_originalWorkspaceToTemporaryWorkspace[wsName]); + // Get the rebinned source and destroy the entire pipeline + pqPipelineSource* source = getSourceForWorkspace(m_originalWorkspaceToRebinnedWorkspace[wsName]); // Go to the end of the pipeline while(source->getNumberOfConsumers() > 0) @@ -123,7 +123,7 @@ namespace Mantid } builder->destroy(source); // The listener takes now care of the workspace. - untrackWorkspaces(m_originalWorkspaceToTemporaryWorkspace[wsName]); + untrackWorkspaces(m_originalWorkspaceToRebinnedWorkspace[wsName]); } } @@ -132,9 +132,9 @@ namespace Mantid * @param source The pipeline source. * @param inputWorkspace Reference for the name of the input workspace. * @param outputWorkspace Reference for the name of the output workspace. - * @param algorithmType The type of the algorithm which will be used to create the temporary source. + * @param algorithmType The type of the algorithm which will be used to create the rebinned source. */ - void SourcesManager::checkSource(pqPipelineSource* source, std::string& inputWorkspace, std::string& outputWorkspace, std::string algorithmType) + void RebinnedSourcesManager::checkSource(pqPipelineSource* source, std::string& inputWorkspace, std::string& outputWorkspace, std::string algorithmType) { std::string workspaceName; std::string workspaceType; @@ -156,7 +156,7 @@ namespace Mantid * @param workspaceName Reference to workspace name. * @param workspaceType Reference to workspace type. */ - void SourcesManager::getWorkspaceInfo(pqPipelineSource* source, std::string& workspaceName, std::string& workspaceType) + void RebinnedSourcesManager::getWorkspaceInfo(pqPipelineSource* source, std::string& workspaceName, std::string& workspaceType) { // Make sure that the input source exists. Note that this can happen when there is no active view if (!source) @@ -196,53 +196,53 @@ namespace Mantid } /** - * Creates the pipeline for the temporary source. - * @param temporarySource The name of the temporary source. + * Creates the pipeline for the rebinned source. + * @param rebinnedSource The name of the rebinned source. * @param sourceToBeDeleted The name of the sources which needs to be removed from the pipeline browser. */ - void SourcesManager::repipeTemporarySource(std::string temporarySource, std::string& sourceToBeDeleted) + void RebinnedSourcesManager::repipeRebinnedSource(std::string rebinnedSource, std::string& sourceToBeDeleted) { // We need to check if the source from which we receive our filters is the original source or - // a temporary source. - if (m_temporaryWorkspaceToTemporaryWorkspace.count(temporarySource) == 0) + // a rebinned source. + if (m_rebinnedWorkspaceToRebinnedWorkspace.count(rebinnedSource) == 0) { - std::string originalSource = m_temporaryWorkspaceToOriginalWorkspace[temporarySource]; + std::string originalSource = m_rebinnedWorkspaceToOriginalWorkspace[rebinnedSource]; // Swap with the original source - swapSources(originalSource, temporarySource); + swapSources(originalSource, rebinnedSource); sourceToBeDeleted = originalSource; } else { - std::string oldTemporarySource = m_temporaryWorkspaceToTemporaryWorkspace[temporarySource]; - std::string originalSource = m_temporaryWorkspaceToOriginalWorkspace[oldTemporarySource]; + std::string oldRebinnedSource = m_rebinnedWorkspaceToRebinnedWorkspace[rebinnedSource]; + std::string originalSource = m_rebinnedWorkspaceToOriginalWorkspace[oldRebinnedSource]; - // Swap with the other temporary source - swapSources(oldTemporarySource, temporarySource); + // Swap with the other rebinned source + swapSources(oldRebinnedSource, rebinnedSource); - sourceToBeDeleted = oldTemporarySource; + sourceToBeDeleted = oldRebinnedSource; - m_originalWorkspaceToTemporaryWorkspace.insert(std::pair<std::string, std::string>(originalSource, temporarySource)); - m_temporaryWorkspaceToOriginalWorkspace.insert(std::pair<std::string, std::string>(temporarySource, originalSource)); + m_originalWorkspaceToRebinnedWorkspace.insert(std::pair<std::string, std::string>(originalSource, rebinnedSource)); + m_rebinnedWorkspaceToOriginalWorkspace.insert(std::pair<std::string, std::string>(rebinnedSource, originalSource)); - // Unregister the connection between the two temporary sources. - m_temporaryWorkspaceToTemporaryWorkspace.erase(temporarySource); + // Unregister the connection between the two rebinned sources. + m_rebinnedWorkspaceToRebinnedWorkspace.erase(rebinnedSource); } } /** * Creates the pipeline for the original source. - * @param temporarySource The name of the temporary source. + * @param rebinnedSource The name of the rebinned source. * @param originalSource The name of the original source. */ - void SourcesManager::repipeOriginalSource(std::string temporarySource, std::string originalSource) + void RebinnedSourcesManager::repipeOriginalSource(std::string rebinnedSource, std::string originalSource) { - // Swap source from temporary source to original source. - swapSources(temporarySource, originalSource); + // Swap source from rebinned source to original source. + swapSources(rebinnedSource, originalSource); - m_originalWorkspaceToTemporaryWorkspace.erase(originalSource); - m_temporaryWorkspaceToOriginalWorkspace.erase(temporarySource); + m_originalWorkspaceToRebinnedWorkspace.erase(originalSource); + m_rebinnedWorkspaceToOriginalWorkspace.erase(rebinnedSource); } /** @@ -250,14 +250,14 @@ namespace Mantid * @param source1 First source. * @param source2 Second source. */ - void SourcesManager::swapSources(std::string source1, std::string source2) + void RebinnedSourcesManager::swapSources(std::string source1, std::string source2) { pqPipelineSource* src1= getSourceForWorkspace(source1); pqPipelineSource* src2 = getSourceForWorkspace(source2); if (!src1 || !src2) { - throw std::runtime_error("VSI error: Either the original or temporary source don't seem to exist."); + throw std::runtime_error("VSI error: Either the original or rebinned source don't seem to exist."); } // Check that both sources contain non-empty data sets @@ -265,6 +265,8 @@ namespace Mantid // Check if the original source has a filter if such then repipe otherwise we are done if ((src1->getAllConsumers()).size() <= 0) { + // Need to press apply to finalize the internal setup of the source. + //emit triggerAcceptForNewFilters(); return; } @@ -279,9 +281,9 @@ namespace Mantid * Get the stored workspace names assoicated with a source. * @param source The name of the source. * @param originalWorkspaceName The name of the original workspace. - * @param temporaryWorkspaceName The name of the temporary workspace. + * @param rebinnedWorkspaceName The name of the rebinned workspace. */ - void SourcesManager::getStoredWorkspaceNames(pqPipelineSource* source, std::string& originalWorkspaceName, std::string& temporaryWorkspaceName) + void RebinnedSourcesManager::getStoredWorkspaceNames(pqPipelineSource* source, std::string& originalWorkspaceName, std::string& rebinnedWorkspaceName) { if (!source) { @@ -293,15 +295,15 @@ namespace Mantid std::string workspaceType; getWorkspaceInfo(source, workspaceName, workspaceType); - // The input can either be a temporary source or a - if (m_temporaryWorkspaceToOriginalWorkspace.count(workspaceName) > 0) + // The input can either be a rebinned source or a + if (m_rebinnedWorkspaceToOriginalWorkspace.count(workspaceName) > 0) { - originalWorkspaceName = m_temporaryWorkspaceToOriginalWorkspace[workspaceName]; - temporaryWorkspaceName = workspaceName; - } else if (m_originalWorkspaceToTemporaryWorkspace.count(workspaceName) > 0) + originalWorkspaceName = m_rebinnedWorkspaceToOriginalWorkspace[workspaceName]; + rebinnedWorkspaceName = workspaceName; + } else if (m_originalWorkspaceToRebinnedWorkspace.count(workspaceName) > 0) { originalWorkspaceName = workspaceName; - temporaryWorkspaceName = m_originalWorkspaceToTemporaryWorkspace[workspaceName]; + rebinnedWorkspaceName = m_originalWorkspaceToRebinnedWorkspace[workspaceName]; } } @@ -309,7 +311,7 @@ namespace Mantid * Get the desired source * @param workspaceName The workspace name associated with the source. */ - pqPipelineSource* SourcesManager::getSourceForWorkspace(std::string workspaceName) + pqPipelineSource* RebinnedSourcesManager::getSourceForWorkspace(std::string workspaceName) { pqServer *server = pqActiveObjects::instance().activeServer(); pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel(); @@ -343,9 +345,9 @@ namespace Mantid * @param inputWorkspace Reference to the input workpspace. * @param outputWorkspace Reference to the output workspace. * @param workspaceName The name of the workspace of the current source. - * @param algorithmType The algorithm which creates the temporary source. + * @param algorithmType The algorithm which creates the rebinned source. */ - void SourcesManager::processWorkspaceNames(std::string& inputWorkspace, std::string& outputWorkspace, std::string workspaceName, std::string algorithmType) + void RebinnedSourcesManager::processWorkspaceNames(std::string& inputWorkspace, std::string& outputWorkspace, std::string workspaceName, std::string algorithmType) { // If the workspace is the original workspace if (workspaceName.find(m_tempPostfix) == std::string::npos) @@ -354,56 +356,56 @@ namespace Mantid outputWorkspace = m_tempPrefix + workspaceName + algorithmType + m_tempPostfix; // Record the workspace - m_originalWorkspaceToTemporaryWorkspace.insert(std::pair<std::string, std::string>(inputWorkspace, outputWorkspace)); - m_temporaryWorkspaceToOriginalWorkspace.insert(std::pair<std::string, std::string>(outputWorkspace, inputWorkspace)); - } // If the workspace is temporary and was created with the same algorithm as the currently selected one. + m_originalWorkspaceToRebinnedWorkspace.insert(std::pair<std::string, std::string>(inputWorkspace, outputWorkspace)); + m_rebinnedWorkspaceToOriginalWorkspace.insert(std::pair<std::string, std::string>(outputWorkspace, inputWorkspace)); + } // If the workspace is rebinned and was created with the same algorithm as the currently selected one. else if (workspaceName.find(algorithmType) != std::string::npos) { - if (m_temporaryWorkspaceToOriginalWorkspace.count(workspaceName) > 0) + if (m_rebinnedWorkspaceToOriginalWorkspace.count(workspaceName) > 0) { - inputWorkspace = m_temporaryWorkspaceToOriginalWorkspace[workspaceName]; + inputWorkspace = m_rebinnedWorkspaceToOriginalWorkspace[workspaceName]; outputWorkspace = workspaceName; } } - else // If the workspace is temporary but was not created with the same algorithm as the currently selected one. + else // If the workspace is rebinned but was not created with the same algorithm as the currently selected one. { - if (m_temporaryWorkspaceToOriginalWorkspace.count(workspaceName) > 0) + if (m_rebinnedWorkspaceToOriginalWorkspace.count(workspaceName) > 0) { - inputWorkspace = m_temporaryWorkspaceToOriginalWorkspace[workspaceName]; + inputWorkspace = m_rebinnedWorkspaceToOriginalWorkspace[workspaceName]; outputWorkspace = m_tempPrefix + inputWorkspace + algorithmType + m_tempPostfix; - // Map the new temporary workspace name to the old temporary workspace name - m_temporaryWorkspaceToTemporaryWorkspace.insert(std::pair<std::string, std::string>(outputWorkspace, workspaceName)); + // Map the new rebinned workspace name to the old rebinned workspace name + m_rebinnedWorkspaceToRebinnedWorkspace.insert(std::pair<std::string, std::string>(outputWorkspace, workspaceName)); } } } /** * Stop keeping tabs on the specific workspace pair - * @param temporaryWorspace The name of the temporary workspace. + * @param rebinnedWorspace The name of the rebinned workspace. */ - void SourcesManager::untrackWorkspaces(std::string temporaryWorkspace) + void RebinnedSourcesManager::untrackWorkspaces(std::string rebinnedWorkspace) { - std::string originalWorkspace = m_temporaryWorkspaceToOriginalWorkspace[temporaryWorkspace]; + std::string originalWorkspace = m_rebinnedWorkspaceToOriginalWorkspace[rebinnedWorkspace]; - // Remove the mapping ofthe temporary workspace to the original workspace. - if (m_temporaryWorkspaceToOriginalWorkspace.count(temporaryWorkspace) > 0) + // Remove the mapping ofthe rebinned workspace to the original workspace. + if (m_rebinnedWorkspaceToOriginalWorkspace.count(rebinnedWorkspace) > 0) { - m_temporaryWorkspaceToOriginalWorkspace.erase(temporaryWorkspace); + m_rebinnedWorkspaceToOriginalWorkspace.erase(rebinnedWorkspace); } - // Remove the mapping of the original workspace to the temporary workspace, if the mapping is still intact. - if (m_originalWorkspaceToTemporaryWorkspace.count(originalWorkspace) > 0 && m_originalWorkspaceToTemporaryWorkspace[originalWorkspace] == temporaryWorkspace) + // Remove the mapping of the original workspace to the rebinned workspace, if the mapping is still intact. + if (m_originalWorkspaceToRebinnedWorkspace.count(originalWorkspace) > 0 && m_originalWorkspaceToRebinnedWorkspace[originalWorkspace] == rebinnedWorkspace) { - m_originalWorkspaceToTemporaryWorkspace.erase(originalWorkspace); + m_originalWorkspaceToRebinnedWorkspace.erase(originalWorkspace); } } /** - * Register the temporary source. Specifically, connect to the destroyed signal of the temporary source. - * @param source The temporary source. + * Register the rebinned source. Specifically, connect to the destroyed signal of the rebinned source. + * @param source The rebinned source. */ - void SourcesManager::registerTemporarySource(pqPipelineSource* source) + void RebinnedSourcesManager::registerRebinnedSource(pqPipelineSource* source) { if (!source) { @@ -411,28 +413,28 @@ namespace Mantid } QObject::connect(source, SIGNAL(destroyed()), - this, SLOT(onTemporarySourceDestroyed())); + this, SLOT(onRebinnedSourceDestroyed())); } /** - * React to the deletion of a temporary source. + * React to the deletion of a rebinned source. */ - void SourcesManager::onTemporarySourceDestroyed() + void RebinnedSourcesManager::onRebinnedSourceDestroyed() { - removeUnusedTemporaryWorkspaces(); + removeUnusedRebinnedWorkspaces(); } /** - * Remove unused temporary workspaces, by comparing the workspaces against the sources. + * Remove unused rebinned workspaces, by comparing the workspaces against the sources. */ - void SourcesManager::removeUnusedTemporaryWorkspaces() + void RebinnedSourcesManager::removeUnusedRebinnedWorkspaces() { // Iterate through all workspaces and check for ones ending with the tempIdentifier std::set<std::string> workspaceNames = Mantid::API::AnalysisDataService::Instance().getObjectNamesInclHidden(); for (std::set<std::string>::iterator it = workspaceNames.begin(); it != workspaceNames.end(); ++it) { - // Only look at the temporary files + // Only look at the rebinned files if (it->find(m_tempPostfix) != std::string::npos) { compareToSources(*it); @@ -444,7 +446,7 @@ namespace Mantid * Compare if the workspace name exists among the sources. If it doesnt't exist, remove it. * @param workspaceName The name of the workspace */ - void SourcesManager::compareToSources(std::string workspaceName) + void RebinnedSourcesManager::compareToSources(std::string workspaceName) { pqServer *server = pqActiveObjects::instance().activeServer(); pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel(); @@ -459,7 +461,7 @@ namespace Mantid std::string name(vtkSMPropertyHelper((*source)->getProxy(), "WorkspaceName", true).GetAsString()); - // If the temporary workspace has a source equivalent, then exit + // If the rebinned workspace has a source equivalent, then exit if (name==workspaceName) { return; @@ -468,26 +470,26 @@ namespace Mantid } // There is no source which corresponds to the workspace, hence delete and unregister the workspace. - removeTemporaryWorkspace(workspaceName); + removeRebinnedWorkspace(workspaceName); untrackWorkspaces(workspaceName); } /** - * Removes the temporary workspace from memory. - * @param temporaryWorkspace The name of the temporary workspace. + * Removes the rebinned workspace from memory. + * @param rebinnedWorkspace The name of the rebinned workspace. */ - void SourcesManager::removeTemporaryWorkspace(std::string temporaryWorkspace) + void RebinnedSourcesManager::removeRebinnedWorkspace(std::string rebinnedWorkspace) { Mantid::VATES::ADSWorkspaceProvider<Mantid::API::IMDHistoWorkspace> adsHistoWorkspaceProvider; Mantid::VATES::ADSWorkspaceProvider<Mantid::API::IMDEventWorkspace> adsEventWorkspaceProvider; - if (adsHistoWorkspaceProvider.canProvideWorkspace(temporaryWorkspace)) + if (adsHistoWorkspaceProvider.canProvideWorkspace(rebinnedWorkspace)) { - adsHistoWorkspaceProvider.disposeWorkspace(temporaryWorkspace); + adsHistoWorkspaceProvider.disposeWorkspace(rebinnedWorkspace); } - else if (adsEventWorkspaceProvider.canProvideWorkspace(temporaryWorkspace)) + else if (adsEventWorkspaceProvider.canProvideWorkspace(rebinnedWorkspace)) { - adsEventWorkspaceProvider.disposeWorkspace(temporaryWorkspace); + adsEventWorkspaceProvider.disposeWorkspace(rebinnedWorkspace); } } @@ -496,7 +498,7 @@ namespace Mantid * @param source1 The old source. * @param source2 The new source. */ - void SourcesManager::rebuildPipeline(pqPipelineSource* source1, pqPipelineSource* source2) + void RebinnedSourcesManager::rebuildPipeline(pqPipelineSource* source1, pqPipelineSource* source2) { // Step through all the filters in old pipeline and reproduce them pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder(); @@ -549,7 +551,7 @@ namespace Mantid * @param filter1 The old filter. * @param filter2 The new filter. */ - void SourcesManager::copyProperties(pqPipelineFilter* filter1, pqPipelineFilter* filter2) + void RebinnedSourcesManager::copyProperties(pqPipelineFilter* filter1, pqPipelineFilter* filter2) { vtkSMProxy* proxy1 = filter1->getProxy(); vtkSMProxy* proxy2 = filter2->getProxy(); @@ -563,7 +565,7 @@ namespace Mantid * @param dest Destination proxy. * @param source Source proxy. */ - void SourcesManager::copySafe(vtkSMProxy* dest, vtkSMProxy* source) + void RebinnedSourcesManager::copySafe(vtkSMProxy* dest, vtkSMProxy* source) { if (dest && source) { @@ -635,12 +637,12 @@ namespace Mantid } /** - * Check if we have a temporary source + * Check if we have a rebinned source * @param name The source name. */ - bool SourcesManager::isTemporarySource(std::string name) + bool RebinnedSourcesManager::isRebinnedSource(std::string name) { - if (m_temporaryWorkspaceToOriginalWorkspace.count(name) > 0) + if (m_rebinnedWorkspaceToOriginalWorkspace.count(name) > 0) { return true; }