@@ -11,23 +11,23 @@ class InteractiveInfiniteLine(InfiniteLine):
1111 """
1212 A subclass of InfiniteLine that provides custom hover behavior.
1313 """
14-
15- def __init__ (self , angle = 90 , pos = None , movable = False , bounds = None , ** kwargs ):
14+
15+ def __init__ (self , angle = 90 , pos = None , movable = False , bounds = None ,
16+ normal_pen = None , highlight_pen = None , ** kwargs ):
1617 super ().__init__ (angle = angle , pos = pos , movable = movable , bounds = bounds , ** kwargs )
17- self ._normal_pen = None
18- self ._highlight_pen = None
19-
18+ self ._normal_pen = normal_pen
19+ self ._highlight_pen = highlight_pen
20+ self .setPen (normal_pen )
21+
2022 def hoverEvent (self , ev ):
2123 """
2224 Override hoverEvent to provide custom hover behavior.
23-
25+
2426 Parameters
2527 ----------
2628 ev : HoverEvent
2729 The hover event from pyqtgraph
2830 """
29- if not hasattr (ev , 'isEnter' ):
30- return
3131
3232 if ev .isEnter () and self ._highlight_pen is not None :
3333 self .setPen (self ._highlight_pen )
@@ -164,37 +164,26 @@ def _plot_cutpoint(self, x):
164164 self ._line = None
165165 return
166166 if self ._line is None :
167- # plot interactive vertical line
167+ normal_pen = mkPen (self .palette ().text ().color (), width = 4 ,
168+ style = Qt .SolidLine , capStyle = Qt .RoundCap )
169+ highlight_pen = mkPen (self .palette ().link ().color (), width = 4 ,
170+ style = Qt .SolidLine , capStyle = Qt .RoundCap )
171+
168172 self ._line = InteractiveInfiniteLine (
169173 angle = 90 , pos = x , movable = True ,
170174 bounds = self .selection_limit if self .selection_limit is not None
171- else (self .x .min (), self .x .max ())
175+ else (self .x .min (), self .x .max ()),
176+ normal_pen = normal_pen ,
177+ highlight_pen = highlight_pen
172178 )
173179 self ._line .setCursor (Qt .SizeHorCursor )
174-
175- # Create normal and highlight pens
176- normal_pen = mkPen (self .palette ().text ().color (), width = 4 , style = Qt .SolidLine , capStyle = Qt .RoundCap )
177- highlight_color = self .palette ().highlight ().color ()
178- highlight_color .setHsv (
179- highlight_color .hue (),
180- min (highlight_color .saturation () + 30 , 255 ),
181- max (highlight_color .value () - 20 , 0 )
182- )
183- highlight_pen = mkPen (highlight_color , width = 10 , style = Qt .SolidLine , capStyle = Qt .RoundCap )
184-
185- # Set pens directly
186- self ._line ._normal_pen = normal_pen
187- self ._line ._highlight_pen = highlight_pen
188- self ._line .setPen (normal_pen )
189180 self ._line .sigPositionChanged .connect (self ._on_cut_changed )
190181 self .addItem (self ._line )
191182 else :
192183 self ._line .setValue (x )
193184
194185 self ._update_horizontal_lines ()
195186
196-
197-
198187 def _plot_horizontal_lines (self ):
199188 """
200189 Function plots the vertical dashed lines that points to the selected
0 commit comments