Commit 9a065365 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Allow changing the instrument window title

When using replaceWorkspace to replace the workspace being shown in an
instrument window using the python API, the user can specify the
new title of the window.
If none is specified, the name of the new workspace is used.
parent b7a962e8
......@@ -28,11 +28,11 @@ 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 replaceWs(const std::string &wsName, SIP_PYOBJECT);
void replaceWorkspace(const std::string &wsName, SIP_PYOBJECT, const std::string &newInstrumentWindowName);
try {
using Mantid::PythonInterface::ExtractSharedPtr;
sipCpp->replaceWs(*a0, ExtractSharedPtr<Mantid::API::Workspace>(a1)());
sipCpp->replaceWorkspace(*a0, ExtractSharedPtr<Mantid::API::Workspace>(a1)(), *a2);
} catch(const std::exception & exc) {
PyErr_SetString(PyExc_RuntimeError, exc.what());
......@@ -34,8 +34,10 @@ class InstrumentViewPresenter(ObservingPresenter):
def current_workspace_equals(self, name):
return self.ws_name == name
def replace_workspace(self, workspace_name, workspace):
self.container.widget.replaceWs(workspace_name, workspace)
def replace_workspace(self, workspace_name, workspace, 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)
# replace is handled by the InstrumentWidget inside C++
def rename_workspace(self, old_name, new_name):
......@@ -149,8 +149,10 @@ public:
void handleWorkspaceReplacement(
const std::string &wsName,
const std::shared_ptr<Mantid::API::Workspace> &workspace);
void replaceWs(const std::string &newWs,
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);
/// Get the currently selected tab index
int getCurrentTab() const;
......@@ -161,7 +163,7 @@ public:
void removeTab(const std::string &tabName);
void addTab(const std::string &tabName);
void hideHelp();
InstrumentWidgetPickTab *getPickTab() { return m_pickTab; };
InstrumentWidgetPickTab *getPickTab() { return m_pickTab; }
bool isIntegrable() const { return m_isIntegrable; }
......@@ -576,20 +576,28 @@ void InstrumentWidget::setSurfaceType(const QString &typeStr) {
* @brief InstrumentWidget::replaceWs
* @brief InstrumentWidget::replaceWorkspace
* Replace the workspace currently linked to the instrument viewer by a new one.
* @param newWs the name of the new workspace
* @param workspace the new workspace to show
* @param newInstrumentWindowName the new title of the window
void InstrumentWidget::replaceWs(const std::string &newWs,
const std::shared_ptr<Workspace> &workspace) {
void InstrumentWidget::replaceWorkspace(
const std::string &newWs, const std::shared_ptr<Workspace> &workspace,
const std::string &newInstrumentWindowName) {
// change inside objects
handleWorkspaceReplacement(m_workspaceName.toStdString(), workspace);
m_instrumentActor.reset(new InstrumentActor(QString::fromStdString(newWs)));
// change the view and colormap
auto surface = getSurface();
// change the title of the instrument window
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