From 053990cb3b4d7eb8a7340e2849780c2bf08bd030 Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Wed, 20 Dec 2023 11:53:33 +0100 Subject: [PATCH 1/4] Propagate symbol size --- src/silx/gui/plot/backends/BackendBase.py | 1 + src/silx/gui/plot/backends/BackendMatplotlib.py | 3 ++- src/silx/gui/plot/backends/BackendOpenGL.py | 6 +++++- src/silx/gui/plot/items/marker.py | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/silx/gui/plot/backends/BackendBase.py b/src/silx/gui/plot/backends/BackendBase.py index 8d70286a8a..35aa429af7 100755 --- a/src/silx/gui/plot/backends/BackendBase.py +++ b/src/silx/gui/plot/backends/BackendBase.py @@ -216,6 +216,7 @@ def addMarker( text: str | None, color: str, symbol: str | None, + symbolsize: float, linestyle: str | tuple[float, tuple[float, ...] | None], linewidth: float, constraint: Callable[[float, float], tuple[float, float]] | None, diff --git a/src/silx/gui/plot/backends/BackendMatplotlib.py b/src/silx/gui/plot/backends/BackendMatplotlib.py index c6784050ef..7ca5533544 100755 --- a/src/silx/gui/plot/backends/BackendMatplotlib.py +++ b/src/silx/gui/plot/backends/BackendMatplotlib.py @@ -942,6 +942,7 @@ def addMarker( text, color, symbol, + symbolsize: float, linestyle, linewidth, constraint, @@ -968,7 +969,7 @@ def addMarker( marker = self._getMarkerFromSymbol(symbol) if x is not None and y is not None: line = ax.plot( - x, y, linestyle=" ", color=color, marker=marker, markersize=10.0 + x, y, linestyle=" ", color=color, marker=marker, markersize=symbolsize )[-1] if text is not None: diff --git a/src/silx/gui/plot/backends/BackendOpenGL.py b/src/silx/gui/plot/backends/BackendOpenGL.py index 4ee509d0ce..928424191f 100755 --- a/src/silx/gui/plot/backends/BackendOpenGL.py +++ b/src/silx/gui/plot/backends/BackendOpenGL.py @@ -110,6 +110,7 @@ def __init__( text, color, symbol, + symbolsize, linewidth, dashoffset, dashpattern, @@ -136,6 +137,7 @@ def __init__( "color": colors.rgba(color), "constraint": constraint if isConstraint else None, "symbol": symbol, + "symbolsize": symbolsize, "linewidth": linewidth, "dashoffset": dashoffset, "dashpattern": dashpattern, @@ -737,7 +739,7 @@ def _renderItems(self, overlay=False): (pixelPos[1],), marker=item["symbol"], color=color, - size=11, + size=item["symbolsize"], ) context.matrix = self.matScreenProj marker.render(context) @@ -1184,6 +1186,7 @@ def addMarker( text, color, symbol, + symbolsize: float, linestyle, linewidth, constraint, @@ -1201,6 +1204,7 @@ def addMarker( text, color, symbol, + symbolsize, linewidth, dashoffset, dashpattern, diff --git a/src/silx/gui/plot/items/marker.py b/src/silx/gui/plot/items/marker.py index b3da451f5a..e5cb4ba7a0 100755 --- a/src/silx/gui/plot/items/marker.py +++ b/src/silx/gui/plot/items/marker.py @@ -78,6 +78,7 @@ def __init__(self): self._x = None self._y = None + self._symbol_size = 10.0 self._bgColor: colors.RGBAColorType | None = None self._constraint = self._defaultConstraint self.__isBeingDragged = False @@ -90,6 +91,7 @@ def _addRendererCall(self, backend, symbol=None, linestyle="-", linewidth=1): text=self.getText(), color=self.getColor(), symbol=symbol, + symbolsize=self.getSymbolSize(), linestyle=linestyle, linewidth=linewidth, constraint=self.getConstraint(), From dc36aefe546f28b303bae6ecc5f8f1b475eb92c0 Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Wed, 20 Dec 2023 11:54:31 +0100 Subject: [PATCH 2/4] WIP: Consistency with the previous implem (have to be checked) --- src/silx/gui/plot/backends/BackendOpenGL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/silx/gui/plot/backends/BackendOpenGL.py b/src/silx/gui/plot/backends/BackendOpenGL.py index 928424191f..2f45107636 100755 --- a/src/silx/gui/plot/backends/BackendOpenGL.py +++ b/src/silx/gui/plot/backends/BackendOpenGL.py @@ -1204,7 +1204,7 @@ def addMarker( text, color, symbol, - symbolsize, + int(symbolsize + 0), linewidth, dashoffset, dashpattern, From 42f9c3d0178e374bc04eb8237e823d52aa4e8910 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Thu, 21 Dec 2023 11:12:47 +0100 Subject: [PATCH 3/4] use symbolsize as float in OpenGL backend --- src/silx/gui/plot/backends/BackendOpenGL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/silx/gui/plot/backends/BackendOpenGL.py b/src/silx/gui/plot/backends/BackendOpenGL.py index 2f45107636..928424191f 100755 --- a/src/silx/gui/plot/backends/BackendOpenGL.py +++ b/src/silx/gui/plot/backends/BackendOpenGL.py @@ -1204,7 +1204,7 @@ def addMarker( text, color, symbol, - int(symbolsize + 0), + symbolsize, linewidth, dashoffset, dashpattern, From dd24a6be49e1c9d8024faf8db365de53f3426c1a Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Mon, 7 Oct 2024 16:33:34 +0200 Subject: [PATCH 4/4] fix marker's symbolsize in backend/item --- src/silx/gui/plot/items/marker.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/silx/gui/plot/items/marker.py b/src/silx/gui/plot/items/marker.py index e5cb4ba7a0..6e5467a314 100755 --- a/src/silx/gui/plot/items/marker.py +++ b/src/silx/gui/plot/items/marker.py @@ -83,7 +83,14 @@ def __init__(self): self._constraint = self._defaultConstraint self.__isBeingDragged = False - def _addRendererCall(self, backend, symbol=None, linestyle="-", linewidth=1): + def _addRendererCall( + self, + backend, + symbol=None, + symbolsize=10., + linestyle="-", + linewidth=1, + ): """Perform the update of the backend renderer""" return backend.addMarker( x=self.getXPosition(), @@ -91,7 +98,7 @@ def _addRendererCall(self, backend, symbol=None, linestyle="-", linewidth=1): text=self.getText(), color=self.getColor(), symbol=symbol, - symbolsize=self.getSymbolSize(), + symbolsize=symbolsize, linestyle=linestyle, linewidth=linewidth, constraint=self.getConstraint(), @@ -248,6 +255,9 @@ class Marker(MarkerBase, SymbolMixIn): _DEFAULT_SYMBOL = "+" """Default symbol of the marker""" + _DEFAULT_SYMBOL_SIZE = 10.0 + """Default size of marker's symbol""" + def __init__(self): MarkerBase.__init__(self) SymbolMixIn.__init__(self) @@ -256,7 +266,11 @@ def __init__(self): self._y = 0.0 def _addBackendRenderer(self, backend): - return self._addRendererCall(backend, symbol=self.getSymbol()) + return self._addRendererCall( + backend, + symbol=self.getSymbol(), + symbolsize=self.getSymbolSize(), + ) def _setConstraint(self, constraint): """Set the constraint function of the marker drag.