Skip to content

Commit

Permalink
[NF] use combobox instead of slider for string axes
Browse files Browse the repository at this point in the history
  • Loading branch information
helene-t committed May 19, 2022
1 parent 0059b64 commit 1c6a1c4
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 10 deletions.
47 changes: 44 additions & 3 deletions SciDataTool/GUI/WSliceOperator/Ui_WSliceOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Ui_WSliceOperator(object):
def setupUi(self, WSliceOperator):
if not WSliceOperator.objectName():
WSliceOperator.setObjectName(u"WSliceOperator")
WSliceOperator.resize(375, 133)
WSliceOperator.resize(375, 160)
self.gridLayout = QGridLayout(WSliceOperator)
self.gridLayout.setObjectName(u"gridLayout")
self.horizontalLayout = QHBoxLayout()
Expand Down Expand Up @@ -100,19 +100,35 @@ def setupUi(self, WSliceOperator):

self.gridLayout.addLayout(self.horizontalLayout_2, 1, 0, 1, 2)

self.c_values = QComboBox(WSliceOperator)
self.c_values.addItem("")
self.c_values.addItem("")
self.c_values.addItem("")
self.c_values.addItem("")
self.c_values.addItem("")
self.c_values.addItem("")
self.c_values.addItem("")
self.c_values.addItem("")
self.c_values.setObjectName(u"c_values")
sizePolicy.setHeightForWidth(self.c_values.sizePolicy().hasHeightForWidth())
self.c_values.setSizePolicy(sizePolicy)
self.c_values.setMinimumSize(QSize(0, 20))

self.gridLayout.addWidget(self.c_values, 2, 0, 1, 2)

self.b_action = QPushButton(WSliceOperator)
self.b_action.setObjectName(u"b_action")
sizePolicy3.setHeightForWidth(self.b_action.sizePolicy().hasHeightForWidth())
self.b_action.setSizePolicy(sizePolicy3)
self.b_action.setMinimumSize(QSize(0, 30))

self.gridLayout.addWidget(self.b_action, 2, 1, 1, 1)
self.gridLayout.addWidget(self.b_action, 3, 1, 1, 1)

self.l_loading = QLabel(WSliceOperator)
self.l_loading.setObjectName(u"l_loading")
self.l_loading.setEnabled(True)

self.gridLayout.addWidget(self.l_loading, 3, 0, 1, 1)
self.gridLayout.addWidget(self.l_loading, 4, 0, 1, 1)

self.retranslateUi(WSliceOperator)

Expand Down Expand Up @@ -157,6 +173,31 @@ def retranslateUi(self, WSliceOperator):
)
self.in_unit.setText(QCoreApplication.translate("WSliceOperator", u"[m]", None))
self.b_animate.setText("")
self.c_values.setItemText(
0, QCoreApplication.translate("WSliceOperator", u"slice", None)
)
self.c_values.setItemText(
1, QCoreApplication.translate("WSliceOperator", u"slice (fft)", None)
)
self.c_values.setItemText(
2, QCoreApplication.translate("WSliceOperator", u"rms", None)
)
self.c_values.setItemText(
3, QCoreApplication.translate("WSliceOperator", u"rss", None)
)
self.c_values.setItemText(
4, QCoreApplication.translate("WSliceOperator", u"sum", None)
)
self.c_values.setItemText(
5, QCoreApplication.translate("WSliceOperator", u"mean", None)
)
self.c_values.setItemText(
6, QCoreApplication.translate("WSliceOperator", u"integrate", None)
)
self.c_values.setItemText(
7, QCoreApplication.translate("WSliceOperator", u"overlay/filter", None)
)

self.b_action.setText(
QCoreApplication.translate("WSliceOperator", u"Overlay", None)
)
Expand Down
21 changes: 17 additions & 4 deletions SciDataTool/GUI/WSliceOperator/WSliceOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def __init__(self, parent=None, path_to_image=None):
self.slider.valueChanged.connect(self.update_floatEdit)
self.slider.valueChanged.connect(self.update_plot)
self.lf_value.editingFinished.connect(self.update_slider)
self.c_values.currentTextChanged.connect(self.update_plot)
self.b_action.clicked.connect(self.open_filter)
self.b_animate.mousePressEvent = self.gen_animate
self.l_loading.setHidden(True)
Expand Down Expand Up @@ -117,9 +118,11 @@ def get_operation_selected(self):
# slice_index = self.slider.value()
# action = "[" + str(slice_index) + "]"

if self.is_pattern or self.is_components:
if self.is_pattern:
# When working with DataPattern we must use index to give the exact value
action = "[" + str(self.slider.value()) + "]"
elif not self.c_values.isHidden():
action = "[" + str(self.c_values.currentIndex()) + "]"
else:
action = "=" + str(self.lf_value.value())

Expand Down Expand Up @@ -299,14 +302,19 @@ def set_slider_floatedit(self):
# Setting the initial value of the floatEdit to the minimum slice (=1)
self.lf_value.setValue(1)
self.in_unit.setText("[-]")
self.c_values.hide()
elif self.is_components:
self.lf_value.hide()
self.b_animate.hide()
self.in_unit.setText(self.axis_value[0])
self.in_unit.hide()
self.c_values.clear()
self.c_values.addItems(self.axis_value)
self.slider.hide()
else:
# Setting the initial value of the floatEdit to the minimum inside the axis
self.lf_value.setValue(min(self.axis_value))
self.in_unit.setText("[" + self.unit + "]")
self.c_values.hide()

# Setting the slider by giving the number of index according to the size of the axis
self.slider.setMinimum(0)
Expand Down Expand Up @@ -431,8 +439,11 @@ def update_layout(self):
self.set_slider_floatedit()
if not self.is_components:
self.lf_value.show()
self.in_unit.show()
self.slider.show()
self.in_unit.show()
self.slider.show()
self.c_values.hide()
else:
self.c_values.show()
self.b_action.hide()
if extraction_selected == "slice" and not self.is_components:
self.b_animate.show()
Expand All @@ -452,6 +463,7 @@ def update_layout(self):
self.b_animate.hide()
self.b_action.show()
self.b_action.setText("Overlay")
self.c_values.hide()
self.refreshNeeded.emit()
else:
if self.axis_name in ifft_dict:
Expand All @@ -464,6 +476,7 @@ def update_layout(self):
self.slider.hide()
self.b_animate.hide()
self.b_action.hide()
self.c_values.hide()
self.refreshNeeded.emit()

def update_slider(self):
Expand Down
62 changes: 59 additions & 3 deletions SciDataTool/GUI/WSliceOperator/WSliceOperator.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>375</width>
<height>133</height>
<height>160</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -179,7 +179,63 @@
</item>
</layout>
</item>
<item row="2" column="1">
<item row="2" column="0" colspan="2">
<widget class="QComboBox" name="c_values">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<item>
<property name="text">
<string>slice</string>
</property>
</item>
<item>
<property name="text">
<string>slice (fft)</string>
</property>
</item>
<item>
<property name="text">
<string>rms</string>
</property>
</item>
<item>
<property name="text">
<string>rss</string>
</property>
</item>
<item>
<property name="text">
<string>sum</string>
</property>
</item>
<item>
<property name="text">
<string>mean</string>
</property>
</item>
<item>
<property name="text">
<string>integrate</string>
</property>
</item>
<item>
<property name="text">
<string>overlay/filter</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="b_action">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
Expand All @@ -198,7 +254,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="l_loading">
<property name="enabled">
<bool>true</bool>
Expand Down

0 comments on commit 1c6a1c4

Please sign in to comment.