-
Notifications
You must be signed in to change notification settings - Fork 74
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
silx.gui: support imageaggregate in _plot2d #4174
Conversation
Not sure if the slot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I left a first round of feedbacks that aims at hopefully simplifying the implementation.
src/silx/gui/plot/actions/image.py
Outdated
:mod:`silx.gui.plot.actions.image` provides a set of QAction relative to data processing | ||
and outputs for a :class:`.PlotWidget`. | ||
|
||
The following QAction are available: | ||
|
||
- :class:`CopyAction` | ||
- :class:`PrintAction` | ||
- :class:`SaveAction` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring in not consistent with the module content
how about this approach? If yes, I will use it for the rest of the classes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By avoiding calling addImage
there is no need for setData
**kwargs
About the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the complex number for another PR!
I left a few more comments. The main point is to put the aggregation mode action in the widget that adds/updates the aggregated plot item rather in the widget that is using this widget.
src/silx/gui/data/NXdataWidgets.py
Outdated
imageItem = ImageDataAggregated() | ||
imageItem.setName(legend) | ||
self._plot.addItem(imageItem) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't sounds to be the right place to add the image item since it can be a scatter that is added
imageItem = ImageDataAggregated() | |
imageItem.setName(legend) | |
self._plot.addItem(imageItem) | |
imageItem.setData(image) | ||
imageItem.setOrigin(origin) | ||
imageItem.setScale(scale) | ||
imageItem.setColormap(self._plot.getDefaultColormap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds this is where to create and add the image item:
imageItem.setData(image) | |
imageItem.setOrigin(origin) | |
imageItem.setScale(scale) | |
imageItem.setColormap(self._plot.getDefaultColormap()) | |
imageItem = ImageDataAggregated() | |
imageItem.setName(legend) | |
imageItem.setData(image) | |
imageItem.setOrigin(origin) | |
imageItem.setScale(scale) | |
imageItem.setColormap(self._plot.getDefaultColormap()) | |
self._plot.addItem(imageItem) |
src/silx/gui/data/DataViews.py
Outdated
self.__aggregationModeAction = AggregationModeAction(parent=widget) | ||
widget.getPlotWidget().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().getPlotWidget() | ||
item = plot._getItem("image") | ||
|
||
if item is None: | ||
return | ||
|
||
if isinstance(item, ImageDataAggregated): | ||
aggregationMode = self.getAggregationModeAction().getAggregationMode() | ||
item.setAggregationMode(aggregationMode) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the AggregationModeAction
in the widget which controls the item in the plot.
- For
_Plot2dView
above, it is the widget that controls the plot item. - Here, the widget controlling the plot item is the
StackView
, so best to control it's plot item from this widget. Otherwise it adds implicit relations: When looking at theStackView
code, one can wonder why an `ImageDataAggregated item is used there.
src/silx/gui/data/DataViews.py
Outdated
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): | ||
item.setAggregationMode(self.getAggregationModeAction().getAggregationMode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, the widget controlling the plot item is ArrayImagePlot
, so the let it handle the aggregation mode as well (this would allow to enable/disable this action according to the displayed item image/scatter)
Do you mean adding the Aggregation items in the class where the Check it if I understood correctly |
Yes, StackView and ArrayImagePlot which are the widgets that create and add/remove the |
it's already done in ArrayImagePlot
I made a PR on your branch with a few updates/fixes: EdgarGF93#3 Apart from that, this looks good to me! Thanks for the work and your patience ! |
Update for PR silx-kit#4174
Looks good to me, thanks Thomas! |
Checklist:
<Module or Topic>: <Action> <Summary>
(see contributing guidelines)This PR enables: