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
9 changes: 7 additions & 2 deletions src/silx/gui/plot3d/items/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class SymbolMixIn(_SymbolMixIn):
def __init__(self):
super().__init__()
self.__primitive = None
self.__scaleFactor = 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.__scaleFactor = 1
self.__scaleFactor = 1.0


def _setPrimitive(self, primitive: primitives.Points):
"""Set the scene primitive on which to set the symbol and size"""
Expand All @@ -193,12 +194,16 @@ def setSymbolSize(self, size: float | ArrayLike | None, copy: bool = True):
super().setSymbolSize(size, copy)
self._syncPointsPrimitive()

def setSizeScaleFactor(self, scaleFactor: float):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I propose to name it getSymbolSizeScaleFactor or getSymbolSizeScale. It's a bit long but makes it unambiguous which size it is.

Can you add a getter for it as well?

self.__scaleFactor = scaleFactor
self._syncPointsPrimitive()

def _syncPointsPrimitive(self):
"""Synchronize scene object's symbol and size"""
if self.__primitive is not None:
symbol, size = self._getSceneSymbol()
self.__primitive.marker = symbol
self.__primitive.setAttribute("size", size, copy=False)
self.__primitive.setAttribute("size", self.__scaleFactor * size, copy=False)

def _getPickingDistances(self) -> float | numpy.ndarray:
"""Returns distances below which to consider a point as picked
Expand All @@ -208,7 +213,7 @@ def _getPickingDistances(self) -> float | numpy.ndarray:
_, size = self._getSceneSymbol()
return numpy.maximum(size, 3.0)

def _getSceneSymbol(self) -> tuple[str, float | ArrayLike]:
def _getSceneSymbol(self) -> tuple[str, float | numpy.ndarray]:
Comment thread
t20100 marked this conversation as resolved.
"""Returns a symbol name and size suitable for scene primitives.

:return: (symbol, size)
Expand Down
6 changes: 5 additions & 1 deletion src/silx/gui/plot3d/tools/GroupPropertiesWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ def _markerSizeButtonClicked(self, checked=False):

markerSize = self._markerSizeSlider.value()
for item in group.visit():
if isinstance(item, SymbolMixIn) and item.isSingleSymbolSize():
if not isinstance(item, SymbolMixIn):
continue
if item.isSingleSymbolSize():
item.setSymbolSize(markerSize)
else:
item.setSizeScaleFactor(markerSize)

def _lineWidthButtonClicked(self, checked=False):
"""Handle line width set button clicked"""
Expand Down
Loading