Commit 8ad456b5 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[gui][grainplot] Disable and enable methods depending on the number of dimensions

parent d9213f62
......@@ -26,7 +26,7 @@
__authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "22/02/2021"
__date__ = "07/06/2021"
from matplotlib.colors import hsv_to_rgb
import numpy
......@@ -111,22 +111,26 @@ class GrainPlotWidget(qt.QMainWindow):
self.indices = indices
self.bg_indices = bg_indices
self.bg_dataset = bg_dataset
for i in range(len(Method)):
self._methodCB.model().item(i).setEnabled(False)
scale = 100
self.ori_dist, self.hsv_key = self.dataset.compute_mosaicity_colorkey()
xdim = self.dataset.dims.get(1)
ydim = self.dataset.dims.get(0)
xscale = (xdim.unique_values[-1] - xdim.unique_values[0]) / (xdim.size - 1)
yscale = (ydim.unique_values[-1] - ydim.unique_values[0]) / (ydim.size - 1)
self._contoursPlot.addImage(hsv_to_rgb(self.hsv_key), xlabel=xdim.name,
ylabel=ydim.name, scale=(xscale / scale, yscale / scale))
self._contoursPlot.getColorBarWidget().hide()
self._methodCB.model().item(4).setEnabled(True)
self._methodCB.setCurrentIndex(4)
self._curvesColormap = Colormap(name='temperature',
vmin=numpy.min(self.ori_dist),
vmax=numpy.max(self.ori_dist))
self._computeContoursB.clicked.connect(self._computeContours)
if self.dataset.dims.ndim > 1:
self.ori_dist, self.hsv_key = self.dataset.compute_mosaicity_colorkey()
xdim = self.dataset.dims.get(1)
ydim = self.dataset.dims.get(0)
xscale = (xdim.unique_values[-1] - xdim.unique_values[0]) / (xdim.size - 1)
yscale = (ydim.unique_values[-1] - ydim.unique_values[0]) / (ydim.size - 1)
self._contoursPlot.addImage(hsv_to_rgb(self.hsv_key), xlabel=xdim.name,
ylabel=ydim.name, scale=(xscale / scale, yscale / scale))
self._contoursPlot.getColorBarWidget().hide()
self._curvesColormap = Colormap(name='temperature',
vmin=numpy.min(self.ori_dist),
vmax=numpy.max(self.ori_dist))
self._computeContoursB.clicked.connect(self._computeContours)
self._methodCB.model().item(4).setEnabled(True)
self._methodCB.setCurrentIndex(4)
self._updatePlot(self._methodCB.currentText())
self._thread = OperationThread(self, self.dataset.apply_moments)
self._thread.setArgs(self.indices)
self._thread.finished.connect(self._updateData)
......@@ -140,7 +144,6 @@ class GrainPlotWidget(qt.QMainWindow):
self._plots[-1].setGraphTitle(dim.name)
self._plots[-1].setDefaultColormap(Colormap(name='viridis'))
self._plotWidget.layout().addWidget(self._plots[-1])
self._updatePlot(self._methodCB.currentText())
def _updateData(self):
"""
......@@ -149,7 +152,9 @@ class GrainPlotWidget(qt.QMainWindow):
self._thread.finished.disconnect(self._updateData)
if self._thread.data is not None:
self._moments = self._thread.data
for i in range(len(Method)):
self._updatePlot(self._methodCB.currentText())
rg = len(Method) if self.dataset.dims.ndim > 1 else 4
for i in range(rg):
self._methodCB.model().item(i).setEnabled(True)
else:
print("\nComputation aborted")
......
Markdown is supported
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