Skip to content

Commit

Permalink
Tune the ruler color with fixed style
Browse files Browse the repository at this point in the history
  • Loading branch information
vallsv committed Dec 20, 2023
1 parent 9ec0df9 commit 4ca9025
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/silx/gui/plot/tools/RulerToolButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

from silx.gui.plot.tools.roi import RegionOfInterestManager
from silx.gui.plot.items.roi import LineROI
from silx.gui.plot import items


_logger = logging.getLogger(__name__)
Expand All @@ -54,6 +55,7 @@ def __init__(self, parent=None):
[numpy.ndarray, numpy.ndarray], str
]
] = None
self.setColor("#001122") # Only there to trig updateStyle

def registerFormatFunction(
self,
Expand All @@ -64,6 +66,17 @@ def registerFormatFunction(
"""Register a function for the formatting of the label"""
self._formatFunction = fct

def _updatedStyle(self, event, style: items.CurveStyle):
style = items.CurveStyle(
color="red",
gapcolor="white",
linestyle=(0, (5, 5)),
linewidth=style.getLineWidth())
LineROI._updatedStyle(self, event, style)
self._handleLabel.setColor("black")
self._handleLabel.setBackgroundColor("#FFFFFF60")
self._handleLabel.setZValue(1000)

def setEndPoints(self, startPoint: numpy.ndarray, endPoint: numpy.ndarray):
super().setEndPoints(startPoint=startPoint, endPoint=endPoint)
if self._formatFunction is not None:
Expand All @@ -90,9 +103,7 @@ def __init__(
self,
parent=None,
plot=None,
color: str = "yellow",
):
self.__color = color
super().__init__(parent=parent, plot=plot)
self.setCheckable(True)
self._roiManager = None
Expand Down Expand Up @@ -143,7 +154,6 @@ def _connectPlot(self, plot):
if plot is None:
return
self._roiManager = RegionOfInterestManager(plot)
self._roiManager.setColor(self.__color) # Set the color of ROI
self._roiManager.sigRoiAdded.connect(self._registerCurrentROI)

def _disconnectPlot(self, plot):
Expand Down

0 comments on commit 4ca9025

Please sign in to comment.