Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source
# & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
import numpy as np
from qtpy.QtWidgets import QWidget
from mantidqt.utils.qt import load_ui
from mantidqt.widgets.plotconfigdialog.axestabwidget import AxProperties
class AxesTabWidgetView(QWidget):
def __init__(self, parent=None):
super(AxesTabWidgetView, self).__init__(parent=parent)
self.ui = load_ui(__file__,
'axes_tab_widget.ui',
baseinstance=self)
# Set maxima and minima for the axis limit spin boxes
for axis in ['x', 'y']:
for limit in ['upper', 'lower']:
spin_box = getattr(self, '%s%s_limit_spin_box' % (axis, limit))
spin_box.setRange(np.finfo(np.float32).min,
np.finfo(np.float32).max)
def populate_select_axes_combo_box(self, axes_names):
self.select_axes_combo_box.addItems(axes_names)
def set_current_axes_selector_text(self, new_text):
current_index = self.select_axes_combo_box.currentIndex()
self.select_axes_combo_box.setItemText(current_index, new_text)
def get_title(self):
return self.axes_title_line_edit.text()
def set_title(self, title):
self.axes_title_line_edit.setText(title)
# X-Axis getters
def get_xlower_limit(self):
return self.xlower_limit_spin_box.value()
def get_xupper_limit(self):
return self.xupper_limit_spin_box.value()
def get_xlabel(self):
return self.xlabel_line_edit.text()
def get_xscale(self):
return self.xscale_combo_box.currentText()
# Y-Axis getters
def get_ylower_limit(self):
return self.ylower_limit_spin_box.value()
def get_yupper_limit(self):
return self.yupper_limit_spin_box.value()
def get_ylabel(self):
return self.ylabel_line_edit.text()
def get_yscale(self):
return self.yscale_combo_box.currentText()
# X-Axis setters
def set_xlower_limit(self, limit):
self.xlower_limit_spin_box.setValue(limit)
def set_xupper_limit(self, limit):
self.xupper_limit_spin_box.setValue(limit)
def set_xlabel(self, label):
self.xlabel_line_edit.setText(label)
def set_xscale(self, scale):
self.xscale_combo_box.setCurrentText(scale.title())
# Y-Axis setters
def set_ylower_limit(self, limit):
self.ylower_limit_spin_box.setValue(limit)
def set_yupper_limit(self, limit):
self.yupper_limit_spin_box.setValue(limit)
def set_ylabel(self, label):
self.ylabel_line_edit.setText(label)
def set_yscale(self, scale):
self.yscale_combo_box.setCurrentText(scale.title())
def get_selected_ax_name(self):
return self.select_axes_combo_box.currentText()
def set_properties(self, ax_props):
self.set_title(ax_props.title)
self.set_xlower_limit(ax_props.xlim[0])
self.set_xupper_limit(ax_props.xlim[1])
self.set_xlabel(ax_props.xlabel)
self.set_xscale(ax_props.xscale)
self.set_ylower_limit(ax_props.ylim[0])
self.set_yupper_limit(ax_props.ylim[1])
self.set_ylabel(ax_props.ylabel)
self.set_yscale(ax_props.yscale)
def get_properties(self):
return AxProperties.from_view(self)