Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for PR #4174 #3

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 13 additions & 34 deletions src/silx/gui/data/DataViews.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from silx.gui.dialog.ColormapDialog import ColormapDialog
from silx.gui.plot.items.image import ImageDataAggregated
from silx.gui.plot.actions.image import AggregationModeAction
from silx._utils import NP_OPTIONAL_COPY

__authors__ = ["V. Valls", "P. Knobel"]
__license__ = "MIT"
Expand Down Expand Up @@ -1074,30 +1073,25 @@ def createWidget(self, parent):
widget.toolBar().addAction(self.__aggregationModeAction)
self.__aggregationModeAction.sigAggregationModeChanged.connect(self._aggregationModeChanged)

self.__imageItem = ImageDataAggregated()
self.__imageItem.setAggregationMode(self.__aggregationModeAction.getAggregationMode())
self.__imageItem.setName("data")
self.__imageItem.setColormap(widget.getDefaultColormap())
widget.addItem(self.__imageItem)
EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved
widget.setActiveImage(self.__imageItem)
EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved

widget.setKeepDataAspectRatio(True)
widget.getXAxis().setLabel("X")
widget.getYAxis().setLabel("Y")
maskToolsWidget = widget.getMaskToolsDockWidget().widget()
maskToolsWidget.setItemMaskUpdated(True)
return widget

def getAggregationModeAction(self) -> AggregationModeAction:
"""Action toggling the aggregation mode action
"""
return self.__aggregationModeAction
EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved

def _aggregationModeChanged(self):
plot = self.getWidget()
item = plot._getItem("image")

if item is None:
return

aggregationMode = self.getAggregationModeAction().getAggregationMode()
item.setAggregationMode(aggregationMode)
self.__imageItem.setAggregationMode(self.__aggregationModeAction.getAggregationMode())
EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved

def clear(self):
self.getWidget().clear()
self.__imageItem.setData(numpy.zeros((0, 0), dtype=numpy.float32))
EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved
self.__resetZoomNextTime = True

def normalizeData(self, data):
Expand All @@ -1108,16 +1102,8 @@ def normalizeData(self, data):
def setData(self, data):
data = self.normalizeData(data)
plot = self.getWidget()
imageItem = plot._getItem("image")

if imageItem is None:
imageItem = ImageDataAggregated()
imageItem.setAggregationMode(self.getAggregationModeAction().getAggregationMode())
imageItem.setName("data")
imageItem.setColormap(plot.getDefaultColormap())
plot.addItem(imageItem)

imageItem.setData(data=data)

self.__imageItem.setData(data=data)
if self.__resetZoomNextTime:
plot.resetZoom()
self.__resetZoomNextTime = False
Expand Down Expand Up @@ -1336,7 +1322,7 @@ def createWidget(self, parent):
maskToolWidget = widget.getPlotWidget().getMaskToolsDockWidget().widget()
maskToolWidget.setItemMaskUpdated(True)
return widget

def clear(self):
self.getWidget().clear()
self.__resetZoomNextTime = True
Expand Down Expand Up @@ -1826,6 +1812,7 @@ def createWidget(self, parent):
self.defaultColorDialog()
)
return widget

def axesNames(self, data, info):
# disabled (used by default axis selector widget in Hdf5Viewer)
return None
Expand Down Expand Up @@ -1861,14 +1848,6 @@ def setData(self, data):
yscale=y_scale,
keep_ratio=(x_units == y_units),
)

item = self.getWidget().getPlot()._getItem("image")

if item is None:
return

if isinstance(item, ImageDataAggregated):
item.setAggregationMode(self.getWidget().getAggregationModeAction().getAggregationMode())

EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved
def getDataPriority(self, data, info):
data = self.normalizeData(data)
Expand Down
1 change: 1 addition & 0 deletions src/silx/gui/data/NXdataWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ def _updateImage(self):
imageItem.setColormap(self._plot.getDefaultColormap())
imageItem.setAggregationMode(self.getAggregationModeAction().getAggregationMode())
self._plot.addItem(imageItem)
self._plot.setActiveImage(imageItem)
EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved
else:
xaxisscale, yaxisscale = self._axis_scales

Expand Down
10 changes: 1 addition & 9 deletions src/silx/gui/plot/StackView.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,7 @@ def getAggregationModeAction(self) -> AggregationModeAction:
return self.__aggregationModeAction

def _aggregationModeChanged(self):
plot = self.getPlotWidget()
item = plot._getItem("image")

if item is None:
return

if isinstance(item, ImageDataAggregated):
aggregationMode = self.getAggregationModeAction().getAggregationMode()
item.setAggregationMode(aggregationMode)
self._stackItem.setAggregationMode(self.getAggregationModeAction().getAggregationMode())
EdgarGF93 marked this conversation as resolved.
Show resolved Hide resolved

def _saveImageStack(self, plot, filename, nameFilter):
"""Save all images from the stack into a volume.
Expand Down
Loading