Skip to content
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.plot.iterms: Fixed Marker.setSymbolSize #4181

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions src/silx/gui/plot/backends/BackendBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/silx/gui/plot/backends/BackendMatplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ def addMarker(
text,
color,
symbol,
symbolsize: float,
linestyle,
linewidth,
constraint,
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion src/silx/gui/plot/backends/BackendOpenGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __init__(
text,
color,
symbol,
symbolsize,
linewidth,
dashoffset,
dashpattern,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1184,6 +1186,7 @@ def addMarker(
text,
color,
symbol,
symbolsize: float,
linestyle,
linewidth,
constraint,
Expand All @@ -1201,6 +1204,7 @@ def addMarker(
text,
color,
symbol,
symbolsize,
linewidth,
dashoffset,
dashpattern,
Expand Down
20 changes: 18 additions & 2 deletions src/silx/gui/plot/items/marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,27 @@ 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

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(),
y=self.getYPosition(),
text=self.getText(),
color=self.getColor(),
symbol=symbol,
symbolsize=symbolsize,
linestyle=linestyle,
linewidth=linewidth,
constraint=self.getConstraint(),
Expand Down Expand Up @@ -246,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)
Expand All @@ -254,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.
Expand Down
Loading