Skip to content

Commit d6ad895

Browse files
committed
New BasePlot.SIG_AXIS_PARAMETERS_CHANGED signal emitted when axis parameters change
1 parent 1a78117 commit d6ad895

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ In this release, test coverage is 79%.
2323
* Or after: `plot_widget.manager.get_tool(ImageStatsTool).set_stats_func(...)`
2424
* The `stats_func` parameter is a function that takes the image item and selected
2525
rectangle coordinates, and returns a string with the statistics to display
26+
* New `SIG_AXIS_PARAMETERS_CHANGED` signal emitted by `BasePlot` when the axes parameters
27+
are changed (e.g. when the axes are inverted, or the scale is changed)
2628

2729
🧹 API cleanup:
2830

plotpy/plot/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ class BasePlot(qwt.QwtPlot):
236236
#: item: the item
237237
SIG_ITEM_PARAMETERS_CHANGED = QC.Signal(object)
238238

239+
#: Signal emitted by plot when axis parameters have changed (through the axis
240+
#: parameters dialog)
241+
#:
242+
#: Args:
243+
#: axis_id: the axis id (0: left, 1: right, 2: bottom, 3: top)
244+
SIG_AXIS_PARAMETERS_CHANGED = QC.Signal(int)
245+
239246
#: Signal emitted by plot when selected item has changed
240247
#:
241248
#: Args:

plotpy/styles/axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def update_axis(self, plot: BasePlot, axis_id: int) -> None:
7373
plot.set_axis_scale(axis_id, self.scale, autoscale=False)
7474
plot.setAxisScale(axis_id, self.vmin, self.vmax)
7575
plot.disable_unused_axes()
76+
plot.SIG_AXIS_PARAMETERS_CHANGED.emit(axis_id)
7677

7778

7879
class AxisItemWidget(DataSetWidget):

plotpy/tools/image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
get_items_in_rectangle,
3535
)
3636
from plotpy.mathutils.colormap import ALL_COLORMAPS, build_icon_from_cmap_name, get_cmap
37+
from plotpy.plot import BasePlot
3738
from plotpy.tools.base import (
3839
CommandTool,
3940
DefaultToolbarID,
@@ -57,7 +58,6 @@
5758
from plotpy.items.image.base import BaseImageItem
5859
from plotpy.items.shape.base import AbstractShape
5960
from plotpy.items.shape.polygon import PolygonShape
60-
from plotpy.plot import BasePlot
6161
from plotpy.plot.manager import PlotManager
6262
from plotpy.plot.plotwidget import PlotOptions
6363
from plotpy.styles.image import BaseImageParam
@@ -370,6 +370,7 @@ def activate_command(self, plot: BasePlot, checked: bool) -> None:
370370
"""
371371
plot.set_axis_direction("left", checked)
372372
plot.replot()
373+
plot.SIG_AXIS_PARAMETERS_CHANGED.emit(BasePlot.Y_LEFT)
373374

374375
def update_status(self, plot: BasePlot) -> None:
375376
"""Update tool status if the plot type is not PlotType.CURVE.

0 commit comments

Comments
 (0)