@@ -89,6 +89,15 @@ def colour(self) -> tuple[int, int, int, int]:
89
89
def colour (self , colour : tuple [int , int , int , int ]) -> None :
90
90
self ._colour = colour
91
91
self .setPen (self ._colour )
92
+ self .hoverPen = mkPen (self ._colour , width = 3 )
93
+
94
+ def set_visibility (self , visible : bool ) -> None :
95
+ """
96
+ Set the visibility of the ROI and its handles.
97
+ """
98
+ self .setVisible (visible )
99
+ for handle in self .getHandles ():
100
+ handle .setVisible (visible )
92
101
93
102
@property
94
103
def selected_row (self ) -> int | None :
@@ -166,12 +175,8 @@ def colour_generator(self) -> tuple[int, int, int, int]:
166
175
def change_roi_colour (self , name : str , colour : tuple [int , int , int , int ]) -> None :
167
176
"""
168
177
Change the colour of an existing ROI
169
-
170
- @param name: The name of the ROI.
171
- @param colour: The new colour of the ROI.
172
178
"""
173
179
self .roi_dict [name ].colour = colour
174
- self .roi_dict [name ].setPen (self .roi_dict [name ].colour )
175
180
176
181
def set_roi_visibility_flags (self , name : str , visible : bool ) -> None :
177
182
"""
@@ -181,19 +186,14 @@ def set_roi_visibility_flags(self, name: str, visible: bool) -> None:
181
186
@param name: The name of the ROI.
182
187
@param visible: The new visibility of the ROI.
183
188
"""
184
- handles = self .roi_dict [name ].getHandles ()
185
- for handle in handles :
186
- handle .setVisible (visible )
187
- self .roi_dict [name ].setVisible (visible )
189
+ self .roi_dict [name ].set_visibility (visible )
188
190
189
191
def set_roi_alpha (self , name : str , alpha : float ) -> None :
190
192
"""
191
193
Change the alpha value of an existing ROI
192
-
193
194
@param name: The name of the ROI.
194
195
@param alpha: The new alpha value of the ROI.
195
196
"""
196
-
197
197
self .roi_dict [name ].colour = self .roi_dict [name ].colour [:3 ] + (alpha , )
198
198
self .roi_dict [name ].setPen (self .roi_dict [name ].colour )
199
199
self .roi_dict [name ].hoverPen = mkPen (self .roi_dict [name ].colour , width = 3 )
@@ -271,7 +271,7 @@ def rename_roi(self, old_name: str, new_name: str) -> None:
271
271
class CustomViewBox (ViewBox ):
272
272
273
273
def __init__ (self , * args , ** kwds ) -> None :
274
- #kwds['enableMenu'] = False
274
+ # kwds['enableMenu'] = False
275
275
ViewBox .__init__ (self , * args , ** kwds )
276
276
self .setMouseMode (self .PanMode )
277
277
0 commit comments