Commit 84a9da99 authored by Zhou, Wenduo's avatar Zhou, Wenduo
Browse files

Refs #29903. Implement pick tab select/get and test.

parent a3cb1234
......@@ -106,6 +106,9 @@ public:
// get render tab
InstrumentWidgetRenderTab *getRenderTab(const Tab tab) const;
// get pick tab
InstrumentWidgetPickTab *getPickTab(const Tab tab) const;
// select tab
void selectTab(Tab tab);
......@@ -181,3 +184,17 @@ private:
InstrumentWidgetRenderTab(const InstrumentWidgetRenderTab &);
};
// Pick tab
class InstrumentWidgetPickTab: InstrumentWidgetTab
{
%TypeHeaderCode
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
%End
private:
// constructors all private
InstrumentWidgetPickTab();
InstrumentWidgetPickTab(const InstrumentWidgetPickTab &);
};
......@@ -59,6 +59,9 @@ class InstrumentViewPresenter(ObservingPresenter):
def get_render_tab(self):
return self.container.get_render_tab()
def get_pick_tab(self):
return self.container.get_pick_tab()
def select_render_tab(self):
self.container.select_tab(0)
......
......@@ -59,15 +59,17 @@ class InstrumentViewTest(unittest.TestCase, QtWidgetFinder):
# select tab
# select pick tab
iv_presenter.select_pick_tab()
# current_tab = iv_presenter.get_current_tab()
# pick_tab = iv_presenter.get_pick_tab()
# assert current_tab == pick_tab, f'{current_tab} != {pick_tab}'
current_tab_index = iv_presenter.container.widget.getCurrentTab()
assert current_tab_index == 1
pick_tab = iv_presenter.get_pick_tab()
assert pick_tab
# render tab
iv_presenter.select_render_tab()
current_tab = iv_presenter.get_current_tab()
current_tab_index = iv_presenter.container.widget.getCurrentTab()
assert current_tab_index == 0
render_tab = iv_presenter.get_render_tab()
assert current_tab == render_tab, f'{current_tab} != {render_tab}'
assert render_tab
# close
iv_presenter.close(ws.name())
......
......@@ -73,7 +73,10 @@ class InstrumentView(QWidget, ObservingView):
return self.get_tab(curr_index)
def get_render_tab(self):
return self.widget.getRenderTab(0)
return self.widget.getRenderTab(InstrumentWidget.RENDER)
def get_pick_tab(self):
return self.widget.getPickTab(InstrumentWidget.PICK)
def select_tab(self, tab_index):
self.widget.selectTab(tab_index)
......
......@@ -139,6 +139,8 @@ public:
InstrumentWidgetTab *getTab(const Tab tab) const;
/// Get a specific tab
InstrumentWidgetRenderTab *getRenderTab(const Tab tab) const;
/// Get a Pick tab
InstrumentWidgetPickTab *getPickTab(const Tab tab) const;
/// Get a filename for saving
QString getSaveFileName(const QString &title, const QString &filters,
......
......@@ -16,6 +16,7 @@
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetMaskTab.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetTreeTab.h"
#include "MantidAPI/Axis.h"
......@@ -397,8 +398,8 @@ InstrumentWidgetTab *InstrumentWidget::getTab(const Tab tab) const {
}
/**
* @brief getRenderTab
* @param tab
* @brief Get render tab from user specified tab
* @param tab :: render tab index
* @return
*/
InstrumentWidgetRenderTab *InstrumentWidget::getRenderTab(const Tab tab) const {
......@@ -416,6 +417,25 @@ InstrumentWidgetRenderTab *InstrumentWidget::getRenderTab(const Tab tab) const {
return nullptr;
}
/**
* @brief Get Pick tab from user specified tab
* @param tab :: pick tab index
* @return
*/
InstrumentWidgetPickTab *InstrumentWidget::getPickTab(const Tab tab) const {
// Call to get base class Q widget
InstrumentWidgetTab *tab_widget = getTab(tab);
// Cast
if (tab_widget != nullptr) {
InstrumentWidgetPickTab *pick_tab = dynamic_cast<InstrumentWidgetPickTab *>(tab_widget);
return pick_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
......
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