Skip to content
Open
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
28 changes: 15 additions & 13 deletions src/silx/gui/plot/PlotWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def __init__(
resetzoom=True,
autoScale=True,
logScale=True,
chooseScale=False,
grid=True,
curveStyle=True,
colormap=True,
Expand All @@ -123,6 +122,7 @@ def __init__(
roi=True,
mask=True,
fit=False,
axisScales=False,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved as last argument to be fully backward compatible + renamed to be inline with other argument names

):
super().__init__(parent=parent, backend=backend)
if parent is None:
Expand Down Expand Up @@ -186,14 +186,14 @@ def __init__(
self.yAxisLogarithmicAction.setVisible(logScale)
self.addAction(self.yAxisLogarithmicAction)

self.xAxisScaleButton = PlotToolButtons.XAxisScaleToolButton(
self._xAxisScaleButton = PlotToolButtons.XAxisScaleToolButton(
parent=self, plot=self
)
self.xAxisScaleButton.setVisible(chooseScale)
self.yAxisScaleButton = PlotToolButtons.YAxisScaleToolButton(
self._xAxisScaleButton.setVisible(axisScales)
self._yAxisScaleButton = PlotToolButtons.YAxisScaleToolButton(
parent=self, plot=self
)
self.yAxisScaleButton.setVisible(chooseScale)
self._yAxisScaleButton.setVisible(axisScales)

self.gridAction = self.group.addAction(
actions.control.GridAction(self, gridMode="both", parent=self)
Expand Down Expand Up @@ -487,12 +487,8 @@ def _createToolBar(self, title, parent):
self.yAxisInvertedAction = toolbar.insertWidget(
self.colorbarAction, self.yAxisInvertedButton
)
self.xAxisScaleAction = toolbar.insertWidget(
self.colorbarAction, self.xAxisScaleButton
)
self.yAxisScaleAction = toolbar.insertWidget(
self.colorbarAction, self.yAxisScaleButton
)
toolbar.insertWidget(self.gridAction, self._xAxisScaleButton)
toolbar.insertWidget(self.gridAction, self._yAxisScaleButton)
return toolbar

def saveGraph(
Expand Down Expand Up @@ -782,6 +778,12 @@ def getYAxisLogarithmicAction(self):
"""
return self.yAxisLogarithmicAction

def getXAxisScaleButton(self) -> PlotToolButtons.XAxisScaleToolButton:
return self._xAxisScaleButton

def getYAxisScaleButton(self) -> PlotToolButtons.YAxisScaleToolButton:
return self._yAxisScaleButton

Comment on lines +781 to +786

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make attributes added in #4529 private and expose them through methods

def getGridAction(self):
"""Action to toggle the grid visibility in the plot

Expand Down Expand Up @@ -923,7 +925,7 @@ def __init__(self, parent=None, backend=None):
resetzoom=True,
autoScale=True,
logScale=False,
chooseScale=True,
axisScales=True,
grid=True,
curveStyle=True,
colormap=False,
Expand Down Expand Up @@ -975,7 +977,7 @@ def __init__(self, parent=None, backend=None):
resetzoom=True,
autoScale=False,
logScale=False,
chooseScale=False,
axisScales=False,
grid=False,
curveStyle=False,
colormap=True,
Expand Down
10 changes: 3 additions & 7 deletions src/silx/gui/plot/items/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ class Axis(qt.QObject):
sigScaleChanged = qt.Signal(str)
"""Signal emitted when axis scale has changed"""

_sigLogarithmicChanged = qt.Signal(bool)
"""Signal emitted when axis scale has changed to or from logarithmic"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

legacy unused signal

sigAutoScaleChanged = qt.Signal(bool)
"""Signal emitted when axis autoscale has changed"""

Expand Down Expand Up @@ -231,13 +228,10 @@ def setScale(self, scale: AxisScaleType):
return

# For the backward compatibility signal
emitLog = self._scale == self.LOGARITHMIC or scale == self.LOGARITHMIC
self._scale = scale
self._internalSetScale()

self.sigScaleChanged.emit(self._scale)
if emitLog:
self._sigLogarithmicChanged.emit(self._scale == self.LOGARITHMIC)

def _isLogarithmic(self) -> bool:
"""Return True if this axis scale is logarithmic, False if linear."""
Expand Down Expand Up @@ -405,6 +399,7 @@ def _internalSetScale(self):
for item in plot.getItems():
item._updated()
plot._invalidateDataRange()
plot._setDirtyPlot()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure plot is updated when changing axis scale


if scale == self.LOGARITHMIC:
self._getBackend().setXAxisScale(scale="log")
Expand Down Expand Up @@ -470,6 +465,8 @@ def _internalSetScale(self):
for item in plot.getItems():
item._updated()
plot._invalidateDataRange()
plot._setDirtyPlot()

if scale == self.LOGARITHMIC:
self._getBackend().setYAxisScale(scale="log")
if vmin <= 0:
Expand Down Expand Up @@ -539,7 +536,6 @@ def __init__(self, plot, mainAxis):
self.__mainAxis = mainAxis
self.__mainAxis.sigInvertedChanged.connect(self.sigInvertedChanged.emit)
self.__mainAxis.sigScaleChanged.connect(self.sigScaleChanged.emit)
self.__mainAxis._sigLogarithmicChanged.connect(self._sigLogarithmicChanged.emit)
self.__mainAxis.sigAutoScaleChanged.connect(self.sigAutoScaleChanged.emit)

def _internalSetCurrentLabel(self, label):
Expand Down