Skip to content

Commit 4101651

Browse files
authored
Merge pull request #4181 from t20100/size-for-markers2
silx.gui.plot.items: Fixed Marker.setSymbolSize
2 parents deaaf46 + dd24a6b commit 4101651

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

src/silx/gui/plot/backends/BackendBase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def addMarker(
216216
text: str | None,
217217
color: str,
218218
symbol: str | None,
219+
symbolsize: float,
219220
linestyle: str | tuple[float, tuple[float, ...] | None],
220221
linewidth: float,
221222
constraint: Callable[[float, float], tuple[float, float]] | None,

src/silx/gui/plot/backends/BackendMatplotlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ def addMarker(
942942
text,
943943
color,
944944
symbol,
945+
symbolsize: float,
945946
linestyle,
946947
linewidth,
947948
constraint,
@@ -968,7 +969,7 @@ def addMarker(
968969
marker = self._getMarkerFromSymbol(symbol)
969970
if x is not None and y is not None:
970971
line = ax.plot(
971-
x, y, linestyle=" ", color=color, marker=marker, markersize=10.0
972+
x, y, linestyle=" ", color=color, marker=marker, markersize=symbolsize
972973
)[-1]
973974

974975
if text is not None:

src/silx/gui/plot/backends/BackendOpenGL.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def __init__(
110110
text,
111111
color,
112112
symbol,
113+
symbolsize,
113114
linewidth,
114115
dashoffset,
115116
dashpattern,
@@ -136,6 +137,7 @@ def __init__(
136137
"color": colors.rgba(color),
137138
"constraint": constraint if isConstraint else None,
138139
"symbol": symbol,
140+
"symbolsize": symbolsize,
139141
"linewidth": linewidth,
140142
"dashoffset": dashoffset,
141143
"dashpattern": dashpattern,
@@ -737,7 +739,7 @@ def _renderItems(self, overlay=False):
737739
(pixelPos[1],),
738740
marker=item["symbol"],
739741
color=color,
740-
size=11,
742+
size=item["symbolsize"],
741743
)
742744
context.matrix = self.matScreenProj
743745
marker.render(context)
@@ -1184,6 +1186,7 @@ def addMarker(
11841186
text,
11851187
color,
11861188
symbol,
1189+
symbolsize: float,
11871190
linestyle,
11881191
linewidth,
11891192
constraint,
@@ -1201,6 +1204,7 @@ def addMarker(
12011204
text,
12021205
color,
12031206
symbol,
1207+
symbolsize,
12041208
linewidth,
12051209
dashoffset,
12061210
dashpattern,

src/silx/gui/plot/items/marker.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,27 @@ def __init__(self):
7878

7979
self._x = None
8080
self._y = None
81+
self._symbol_size = 10.0
8182
self._bgColor: colors.RGBAColorType | None = None
8283
self._constraint = self._defaultConstraint
8384
self.__isBeingDragged = False
8485

85-
def _addRendererCall(self, backend, symbol=None, linestyle="-", linewidth=1):
86+
def _addRendererCall(
87+
self,
88+
backend,
89+
symbol=None,
90+
symbolsize=10.,
91+
linestyle="-",
92+
linewidth=1,
93+
):
8694
"""Perform the update of the backend renderer"""
8795
return backend.addMarker(
8896
x=self.getXPosition(),
8997
y=self.getYPosition(),
9098
text=self.getText(),
9199
color=self.getColor(),
92100
symbol=symbol,
101+
symbolsize=symbolsize,
93102
linestyle=linestyle,
94103
linewidth=linewidth,
95104
constraint=self.getConstraint(),
@@ -246,6 +255,9 @@ class Marker(MarkerBase, SymbolMixIn):
246255
_DEFAULT_SYMBOL = "+"
247256
"""Default symbol of the marker"""
248257

258+
_DEFAULT_SYMBOL_SIZE = 10.0
259+
"""Default size of marker's symbol"""
260+
249261
def __init__(self):
250262
MarkerBase.__init__(self)
251263
SymbolMixIn.__init__(self)
@@ -254,7 +266,11 @@ def __init__(self):
254266
self._y = 0.0
255267

256268
def _addBackendRenderer(self, backend):
257-
return self._addRendererCall(backend, symbol=self.getSymbol())
269+
return self._addRendererCall(
270+
backend,
271+
symbol=self.getSymbol(),
272+
symbolsize=self.getSymbolSize(),
273+
)
258274

259275
def _setConstraint(self, constraint):
260276
"""Set the constraint function of the marker drag.

0 commit comments

Comments
 (0)