Skip to content
Snippets Groups Projects
Commit d19350e1 authored by Zhou, Wenduo's avatar Zhou, Wenduo
Browse files

Refs #29903. Exposed several InstrumentWidget methods to workbench.

parent 135a8a82
No related branches found
No related tags found
No related merge requests found
......@@ -13,18 +13,97 @@ qRegisterMetaType<Mantid::API::Workspace_sptr>("Workspace");
//----------------------------------------------------------------------------
// Classes
// ----------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Tab
class InstrumentWidgetTab: QFrame
{
%TypeHeaderCode
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetTab.h"
%End
public:
// This is a duplicate from the same enum in InstrumentWidget, just so you
// can do like InstrumentWidgetRenderTab.FULL3D
enum SurfaceType { FULL3D, CYLINDRICAL_X, CYLINDRICAL_Y, CYLINDRICAL_Z,
SPHERICAL_X, SPHERICAL_Y, SPHERICAL_Z,
RENDERMODE_SIZE };
private:
InstrumentWidgetTab(const InstrumentWidgetTab &);
};
class InstrumentWidget : QWidget {
%TypeHeaderCode
#include "MantidQtWidgets/InstrumentView/InstrumentWidget.h"
%End
public:
// Note this enum is also defined in InstrumentWidgetTab
enum SurfaceType { FULL3D, CYLINDRICAL_X, CYLINDRICAL_Y, CYLINDRICAL_Z,
SPHERICAL_X, SPHERICAL_Y, SPHERICAL_Z,
RENDERMODE_SIZE };
enum Tab { RENDER, PICK, MASK, TREE };
// constructor
InstrumentWidget(const QString &ws_name, QWidget *parent /TransferThis/ = 0,
bool reset_geometry = true, bool autoscaling = true,
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);
%Docstring
Overlay ... whatever
%End
// get tab (1)
InstrumentWidgetTab * getTab(const QString & title) const;
%Docstring
Returns a handler to the requested tab
Args:
title The full title of a tab in the window
Returns:
a pointer to the requested tab widget
%End
// get tab (2)
InstrumentWidgetTab * getTab(const Tab tab) const;
%Docstring
Returns a handler to the requested tab
Args:
tab One of the Tab enumeration types:
InstrumentWidget.RENDER,InstrumentWidget.PICK,
InstrumentWidget.MASK,InstrumentWidget.TREE
Returns:
a pointer to the requested tab widget
%End
// get render tab
InstrumentWidgetRenderTab *getRenderTab(const Tab tab) const;
void setBinRange(double min_value, double max_value);
%Docstring
Updates the integration range over which the colours
are calculated
Args:
min_value The minimum value over which the data is integrated
max_value The maximum value over which the data is integrated
%End
};
class InstrumentWidgetEncoder {
......@@ -49,3 +128,39 @@ public:
const QString &projectPath,
const bool loadMask = true) /ReleaseGIL/;
};
// Render Tab
class InstrumentWidgetRenderTab: InstrumentWidgetTab
{
%TypeHeaderCode
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h"
%End
public:
// set surface type
void setSurfaceType(int type);
%Docstring
Set the surface type of the current window.
Args:
type A known suface type: FULL3D, CYLINDRICAL_X, CYLINDRICAL_Y,
CYLINDRICAL_Z,SPHERICAL_X, SPHERICAL_Y,
SPHERICAL_Z
%End
// set min value
void setMinValue(double value, bool apply);
// set max value
void setMaxValue(double value, bool apply);
// set Axis at Full 3D
void setAxis(const QString &axisNameArg);
private:
// constructors all private
InstrumentWidgetRenderTab();
InstrumentWidgetRenderTab(const InstrumentWidgetRenderTab &);
};
......@@ -19,8 +19,9 @@ from mantidqt.utils.qt import import_qt
# import widget class from C++ wrappers
from mantidqt.widgets.observers.observing_view import ObservingView
InstrumentWidget = import_qt('._instrumentview', 'mantidqt.widgets.instrumentview',
'InstrumentWidget')
# _instrumentview.sip --> _instrumentview
InstrumentWidget = import_qt('._instrumentview', 'mantidqt.widgets.instrumentview', 'InstrumentWidget')
class InstrumentView(QWidget, ObservingView):
......@@ -54,6 +55,20 @@ class InstrumentView(QWidget, ObservingView):
self.close_signal.connect(self._run_close)
def get_tab(self, tab_index):
tab_name = [InstrumentWidget.RENDER,
InstrumentWidget.PICK,
InstrumentWidget.MASK,
InstrumentWidget.TREE][tab_index]
print(f'Tab: {tab_name}')
return self.widget.getTab(tab_name)
def get_render_tab(self):
return self.widget.getRenderTab(0)
@Slot()
def _run_close(self):
self.close()
......@@ -137,6 +137,9 @@ public:
void selectTab(Tab tab) { selectTab(int(tab)); }
InstrumentWidgetTab *getTab(const QString &title = "") const;
InstrumentWidgetTab *getTab(const Tab tab) const;
/// Get a specific tab
InstrumentWidgetRenderTab *getRenderTab(const Tab tab) const;
/// Get a filename for saving
QString getSaveFileName(const QString &title, const QString &filters,
QString *selectedFilter = nullptr);
......
......@@ -396,6 +396,28 @@ InstrumentWidgetTab *InstrumentWidget::getTab(const Tab tab) const {
return nullptr;
}
/**
* @brief getRenderTab
* @param tab
* @return
*/
InstrumentWidgetRenderTab *InstrumentWidget::getRenderTab(const Tab tab) const {
// Call to get Q widget
InstrumentWidgetTab *widget_tab = getTab(tab);
// Cast
if (widget_tab != nullptr)
{
InstrumentWidgetRenderTab *render_tab = dynamic_cast<InstrumentWidgetRenderTab *>(widget_tab);
return render_tab;
}
return nullptr;
}
/**
* Opens Qt file dialog to select the filename.
* The dialog opens in the directory used last for saving or the default user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment