-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8725dcc
support imageaggregate in _plot2d
df68c57
add aggregation action in _Plot2dView
b07bc53
imageaggregate by default
14bf6d6
no kwargs needed
044a912
predefined imagedataaggregatd
af98201
suggestions
3b43874
blank
73e566f
set aggregation mode in set data
fa45a02
setdata
6216f46
correction
ba5ec27
typo
5ab1d19
imageaggregate in NXdataWidget
1e44061
simplify
ed3e275
stackview inherits from ImageDataAggregated
ea0bd4c
aggregation items to ArrayImagePlot
ef444ad
aggregation items to StackView
8f58e87
again
6f074c1
Merge remote-tracking branch 'origin/main' into silx_view_imageaggreg…
c8d19dd
simpler implementation by using self._stackItem
t20100 c934c5e
remove unused import and useless code in _NXdataImageView
t20100 bb290ad
simplify implementation by reusing the same item
t20100 e6868fe
Make the image active to enable mask and histogram
t20100 b4b2529
Merge pull request #3 from t20100/pr4174
EdgarGF93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ | |
from . import control | ||
from . import mode | ||
from . import io | ||
from . import image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# /*########################################################################## | ||
# | ||
# Copyright (c) 2024 European Synchrotron Radiation Facility | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
# ###########################################################################*/ | ||
""" | ||
: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:`AggregationModeAction` | ||
""" | ||
|
||
__authors__ = ["T. Vincent"] | ||
__license__ = "MIT" | ||
__date__ = "19/09/2024" | ||
|
||
import logging | ||
from silx.gui import qt | ||
from silx.gui import icons | ||
from ..items.image_aggregated import ImageDataAggregated | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
class AggregationModeAction(qt.QWidgetAction): | ||
"""Action providing filters for an aggregated image""" | ||
|
||
sigAggregationModeChanged = qt.Signal() | ||
EdgarGF93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Signal emitted when the aggregation mode has changed""" | ||
|
||
def __init__(self, parent): | ||
qt.QWidgetAction.__init__(self, parent) | ||
|
||
toolButton = qt.QToolButton(parent) | ||
|
||
filterAction = qt.QAction(self) | ||
filterAction.setText("No filter") | ||
filterAction.setCheckable(True) | ||
filterAction.setChecked(True) | ||
filterAction.setProperty( | ||
"aggregation", ImageDataAggregated.Aggregation.NONE | ||
) | ||
densityNoFilterAction = filterAction | ||
|
||
filterAction = qt.QAction(self) | ||
filterAction.setText("Max filter") | ||
filterAction.setCheckable(True) | ||
filterAction.setProperty( | ||
"aggregation", ImageDataAggregated.Aggregation.MAX | ||
) | ||
densityMaxFilterAction = filterAction | ||
|
||
filterAction = qt.QAction(self) | ||
filterAction.setText("Mean filter") | ||
filterAction.setCheckable(True) | ||
filterAction.setProperty( | ||
"aggregation", ImageDataAggregated.Aggregation.MEAN | ||
) | ||
densityMeanFilterAction = filterAction | ||
|
||
filterAction = qt.QAction(self) | ||
filterAction.setText("Min filter") | ||
filterAction.setCheckable(True) | ||
filterAction.setProperty( | ||
"aggregation", ImageDataAggregated.Aggregation.MIN | ||
) | ||
densityMinFilterAction = filterAction | ||
|
||
densityGroup = qt.QActionGroup(self) | ||
densityGroup.setExclusive(True) | ||
densityGroup.addAction(densityNoFilterAction) | ||
densityGroup.addAction(densityMaxFilterAction) | ||
densityGroup.addAction(densityMeanFilterAction) | ||
densityGroup.addAction(densityMinFilterAction) | ||
densityGroup.triggered.connect(self._aggregationModeChanged) | ||
self.__densityGroup = densityGroup | ||
|
||
filterMenu = qt.QMenu(toolButton) | ||
filterMenu.addAction(densityNoFilterAction) | ||
filterMenu.addAction(densityMaxFilterAction) | ||
filterMenu.addAction(densityMeanFilterAction) | ||
filterMenu.addAction(densityMinFilterAction) | ||
|
||
toolButton.setPopupMode(qt.QToolButton.InstantPopup) | ||
toolButton.setMenu(filterMenu) | ||
toolButton.setText("Data filters") | ||
toolButton.setToolTip("Enable/disable filter on the image") | ||
icon = icons.getQIcon("aggregation-mode") | ||
toolButton.setIcon(icon) | ||
toolButton.setText("Pixel aggregation filter") | ||
|
||
self.setDefaultWidget(toolButton) | ||
|
||
def _aggregationModeChanged(self): | ||
self.sigAggregationModeChanged.emit() | ||
|
||
def setAggregationMode(self, mode): | ||
"""Set an Aggregated enum from ImageDataAggregated""" | ||
for a in self.__densityGroup.actions(): | ||
if a.property("aggregation") is mode: | ||
a.setChecked(True) | ||
|
||
def getAggregationMode(self): | ||
"""Returns an Aggregated enum from ImageDataAggregated""" | ||
densityAction = self.__densityGroup.checkedAction() | ||
if densityAction is None: | ||
return ImageDataAggregated.Aggregation.NONE | ||
return densityAction.property("aggregation") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: