Skip to content

Commit

Permalink
imageaggregate in NXdataWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar committed Sep 29, 2024
1 parent ba5ec27 commit 5ab1d19
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
27 changes: 27 additions & 0 deletions src/silx/gui/data/DataViews.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,26 @@ def createWidget(self, parent):
widget.getPlot().getColormapAction().setColormapDialog(
self.defaultColorDialog()
)
self.__aggregationModeAction = AggregationModeAction(parent=widget)
widget.getPlot().toolBar().addAction(self.__aggregationModeAction)
self.__aggregationModeAction.sigAggregationModeChanged.connect(self._aggregationModeChanged)
return widget

def getAggregationModeAction(self) -> AggregationModeAction:
"""Action toggling the aggregation mode action
"""
return self.__aggregationModeAction

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

if item is None:
return

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

def axesNames(self, data, info):
# disabled (used by default axis selector widget in Hdf5Viewer)
Expand Down Expand Up @@ -1862,6 +1881,14 @@ 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.getAggregationModeAction().getAggregationMode())

def getDataPriority(self, data, info):
data = self.normalizeData(data)
Expand Down
19 changes: 11 additions & 8 deletions src/silx/gui/data/NXdataWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from silx.gui.data.NumpyAxesSelector import NumpyAxesSelector
from silx.gui.plot import Plot1D, Plot2D, StackView, ScatterView, items
from silx.gui.plot.ComplexImageView import ComplexImageView
from silx.gui.plot.items.image_aggregated import ImageDataAggregated
from silx.gui.colors import Colormap
from silx.gui.widgets.FrameBrowser import HorizontalSliderWithBrowser

Expand Down Expand Up @@ -555,6 +556,10 @@ def _updateImage(self):
"image",
)
)
imageItem = ImageDataAggregated()
imageItem.setName(legend)
self._plot.addItem(imageItem)

if xcalib.is_affine() and ycalib.is_affine():
# regular image
xorigin, xscale = xcalib(0), xcalib.get_slope()
Expand All @@ -564,14 +569,12 @@ def _updateImage(self):

self._plot.getXAxis().setScale("linear")
self._plot.getYAxis().setScale("linear")
self._plot.addImage(
image,
legend=legend,
origin=origin,
scale=scale,
replace=True,
resetzoom=False,
)

imageItem.setData(image)
imageItem.setOrigin(origin)
imageItem.setScale(scale)
imageItem.setColormap(self._plot.getDefaultColormap())

else:
xaxisscale, yaxisscale = self._axis_scales

Expand Down

0 comments on commit 5ab1d19

Please sign in to comment.