Commit 461df748 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Remove need for the workspace to be passed

The workspace to be added is no longer necessary, because it appears
that calling afterReplaceHandle only slows the process while not doing
anything noticeable.

This commit thus simplify this, and thus quickens the execution of
replace_workspace by some 30%.
parent eabfe065
......@@ -20,7 +20,6 @@ qRegisterMetaType<Mantid::API::Workspace_sptr>("Workspace");
class InstrumentWidget : QWidget {
#include "MantidQtWidgets/InstrumentView/InstrumentWidget.h"
#include "MantidPythonInterface/core/ExtractSharedPtr.h"
InstrumentWidget(const QString &ws_name, QWidget *parent /TransferThis/ = 0,
......@@ -28,21 +27,8 @@ public:
double scale_min = 0.0, double scale_max = 0.0,
bool set_default_view = true) throw (std::runtime_error);
bool overlay(const QString & ws_name);
void replaceWorkspace(const std::string &wsName, SIP_PYOBJECT, const std::string &newInstrumentWindowName);
try {
using Mantid::PythonInterface::ExtractSharedPtr;
sipCpp->replaceWorkspace(*a0, ExtractSharedPtr<Mantid::API::Workspace>(a1)(), *a2);
} catch(const std::exception & exc) {
PyErr_SetString(PyExc_RuntimeError, exc.what());
return NULL;
} catch(...) {
return NULL;
void replaceWorkspace(const std::string &wsName, const std::string &newInstrumentWindowName);
class InstrumentWidgetEncoder {
......@@ -34,10 +34,10 @@ class InstrumentViewPresenter(ObservingPresenter):
def current_workspace_equals(self, name):
return self.ws_name == name
def replace_workspace(self, workspace_name, workspace, new_window_name=None):
def replace_workspace(self, new_workspace_name, new_window_name=None):
if new_window_name is None:
new_window_name = workspace_name
self.container.widget.replaceWorkspace(workspace_name, workspace, new_window_name)
new_window_name = new_workspace_name
self.container.widget.replaceWorkspace(new_workspace_name, new_window_name)
# replace is handled by the InstrumentWidget inside C++
def rename_workspace(self, old_name, new_name):
......@@ -151,10 +151,8 @@ public:
void handleWorkspaceReplacement(
const std::string &wsName,
const std::shared_ptr<Mantid::API::Workspace> &workspace);
replaceWorkspace(const std::string &newWs,
const std::shared_ptr<Mantid::API::Workspace> &workspace,
const std::string &newInstrumentWindowName);
void replaceWorkspace(const std::string &newWs,
const std::string &newInstrumentWindowName);
/// Get the currently selected tab index
int getCurrentTab() const;
......@@ -582,10 +582,8 @@ void InstrumentWidget::setSurfaceType(const QString &typeStr) {
* @param newInstrumentWindowName the new title of the window
void InstrumentWidget::replaceWorkspace(
const std::string &newWs, const std::shared_ptr<Workspace> &workspace,
const std::string &newInstrumentWindowName) {
const std::string &newWs, const std::string &newInstrumentWindowName) {
// change inside objects
handleWorkspaceReplacement(m_workspaceName.toStdString(), workspace);
m_instrumentActor.reset(new InstrumentActor(QString::fromStdString(newWs)));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment