Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getCurrentStyle(self):
"""Returns the current curve style.
Curve style depends on curve highlighting
:rtype: CurveStyle
"""
baseColor = rgba(self.getColor())
if isinstance(self, core.LineMixIn):
baseLinestyle = self.getLineStyle()
baseLinewidth = self.getLineWidth()
else:
baseLinestyle = self._DEFAULT_LINESTYLE
baseLinewidth = self._DEFAULT_LINEWIDTH
if isinstance(self, core.SymbolMixIn):
baseSymbol = self.getSymbol()
baseSymbolsize = self.getSymbolSize()
else:
baseSymbol = 'o'
baseSymbolsize = 1
if self.isHighlighted():
style = self.getHighlightedStyle()
color = style.getColor()
def strokeColor(self, color):
color = rgba(color)
if color != self.strokeColor:
self._stroke.setAttribute('color', color)
# Fully transparent = hidden
self._stroke.visible = color[-1] != 0.
self.notify()
def background(self, color):
if color is not None:
color = rgba(color)
if self._background != color:
self._background = color
self._changed()
def _setOverlayColorForImage(self, image):
"""Set the color of overlay adapted to image
:param image: :class:`.items.ImageBase` object to set color for.
"""
if isinstance(image, items.ColormapMixIn):
colormap = image.getColormap()
self._defaultOverlayColor = rgba(
cursorColorForColormap(colormap['name']))
else:
self._defaultOverlayColor = rgba('black')
def addHandle(self, item=None, role="default"):
"""
Add a new handle to the ROI.
Dragging handles while affect the position or the shape of the
ROI.
:param Union[None,silx.gui.plot.items.Marker] item: The new marker to
add, else None to create a default marker.
:rtype: silx.gui.plot.items.Marker
"""
if item is None:
item = items.Marker()
color = rgba(self.getColor())
color = self._computeHandleColor(color)
item.setColor(color)
if role == "default":
item.setSymbol("s")
elif role == "user":
pass
elif role == "translate":
item.setSymbol("+")
elif role == "label":
item.setSymbol("")
if role == "user":
pass
elif role == "label":
item._setSelectable(False)
item._setDraggable(False)
def _adjustColorAndBrushSize(self, activeScatter):
colormap = activeScatter.getColormap()
self._defaultOverlayColor = rgba(cursorColorForColormap(colormap['name']))
self._setMaskColors(self.levelSpinBox.value(),
self.transparencySlider.value() /
self.transparencySlider.maximum())
self._z = activeScatter.getZValue() + 1
self._data_scatter = activeScatter
# Adjust brush size to data range
xData = self._data_scatter.getXData(copy=False)
yData = self._data_scatter.getYData(copy=False)
# Adjust brush size to data range
if xData.size > 0 and yData.size > 0:
xMin, xMax = min_max(xData)
yMin, yMax = min_max(yData)
self._data_extent = max(xMax - xMin, yMax - yMin)
else:
self._data_extent = None
def __updateMaskColor(self, color):
maskTool = self.getMaskTool()
# TODO: Not anymore needed for silx >= 0.10
color = colors.rgba(color)[0:3]
maskTool.setMaskColors(color)
if not isinstance(destination, (list, tuple)):
destination = [destination]
if event == items.ItemChangedType.NAME:
value = source.getName()
for d in destination:
d.setName(value)
elif event == items.ItemChangedType.EDITABLE:
value = source.isEditable()
for d in destination:
d.setEditable(value)
elif event == items.ItemChangedType.SELECTABLE:
value = source.isSelectable()
for d in destination:
d._setSelectable(value)
elif event == items.ItemChangedType.COLOR:
value = rgba(source.getColor())
for d in destination:
d.setColor(value)
elif event == items.ItemChangedType.LINE_STYLE:
value = self.getLineStyle()
for d in destination:
d.setLineStyle(value)
elif event == items.ItemChangedType.LINE_WIDTH:
value = self.getLineWidth()
for d in destination:
d.setLineWidth(value)
elif event == items.ItemChangedType.SYMBOL:
value = self.getSymbol()
for d in destination:
d.setSymbol(value)
elif event == items.ItemChangedType.SYMBOL_SIZE:
value = self.getSymbolSize()