diff --git a/fastplotlib/graphics/image.py b/fastplotlib/graphics/image.py index 1cad33f22..ce736dab2 100644 --- a/fastplotlib/graphics/image.py +++ b/fastplotlib/graphics/image.py @@ -282,12 +282,15 @@ def __init__( # if data is RGB or RGBA if data.ndim > 2: material = pygfx.ImageBasicMaterial( - clim=(vmin, vmax), map_interpolation=filter + clim=(vmin, vmax), map_interpolation=filter, pick_write=True ) # if data is just 2D without color information, use colormap LUT else: material = pygfx.ImageBasicMaterial( - clim=(vmin, vmax), map=self.cmap(), map_interpolation=filter + clim=(vmin, vmax), + map=self.cmap(), + map_interpolation=filter, + pick_write=True, ) world_object = pygfx.Image(geometry, material) @@ -443,7 +446,10 @@ def __init__( self.cmap = HeatmapCmapFeature(self, cmap) self._material = pygfx.ImageBasicMaterial( - clim=(vmin, vmax), map=self.cmap(), map_interpolation=filter + clim=(vmin, vmax), + map=self.cmap(), + map_interpolation=filter, + pick_write=True, ) for start, stop, chunk in zip(start_ixs, stop_ixs, chunks): diff --git a/fastplotlib/graphics/line.py b/fastplotlib/graphics/line.py index cfb697dff..0371fe59b 100644 --- a/fastplotlib/graphics/line.py +++ b/fastplotlib/graphics/line.py @@ -114,7 +114,9 @@ def __init__( world_object: pygfx.Line = pygfx.Line( # self.data.feature_data because data is a Buffer geometry=pygfx.Geometry(positions=self.data(), colors=self.colors()), - material=material(thickness=self.thickness(), color_mode="vertex"), + material=material( + thickness=self.thickness(), color_mode="vertex", pick_write=True + ), ) self._set_world_object(world_object) diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index 2557cd637..8682df3d5 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -93,7 +93,9 @@ def __init__( pygfx.Geometry( positions=self.data(), sizes=self.sizes(), colors=self.colors() ), - material=pygfx.PointsMaterial(color_mode="vertex", size_mode="vertex"), + material=pygfx.PointsMaterial( + color_mode="vertex", size_mode="vertex", pick_write=True + ), ) self._set_world_object(world_object) diff --git a/fastplotlib/graphics/selectors/_linear.py b/fastplotlib/graphics/selectors/_linear.py index 4b77a6cd9..82e553f0a 100644 --- a/fastplotlib/graphics/selectors/_linear.py +++ b/fastplotlib/graphics/selectors/_linear.py @@ -125,12 +125,14 @@ def __init__( line_inner = pygfx.Line( # self.data.feature_data because data is a Buffer geometry=pygfx.Geometry(positions=line_data), - material=material(thickness=thickness, color=color), + material=material(thickness=thickness, color=color, pick_write=True), ) self.line_outer = pygfx.Line( geometry=pygfx.Geometry(positions=line_data), - material=material(thickness=thickness + 6, color=self.colors_outer), + material=material( + thickness=thickness + 6, color=self.colors_outer, pick_write=True + ), ) line_inner.world.z = self.line_outer.world.z + 1 diff --git a/fastplotlib/graphics/selectors/_linear_region.py b/fastplotlib/graphics/selectors/_linear_region.py index 47191bfb1..09c134800 100644 --- a/fastplotlib/graphics/selectors/_linear_region.py +++ b/fastplotlib/graphics/selectors/_linear_region.py @@ -139,13 +139,13 @@ def __init__( if axis == "x": mesh = pygfx.Mesh( pygfx.box_geometry(1, size, 1), - pygfx.MeshBasicMaterial(color=pygfx.Color(fill_color)), + pygfx.MeshBasicMaterial(color=pygfx.Color(fill_color), pick_write=True), ) elif axis == "y": mesh = pygfx.Mesh( pygfx.box_geometry(size, 1, 1), - pygfx.MeshBasicMaterial(color=pygfx.Color(fill_color)), + pygfx.MeshBasicMaterial(color=pygfx.Color(fill_color), pick_write=True), ) else: raise ValueError("`axis` must be one of 'x' or 'y'") @@ -169,7 +169,9 @@ def __init__( left_line = pygfx.Line( pygfx.Geometry(positions=left_line_data), - pygfx.LineMaterial(thickness=edge_thickness, color=edge_color), + pygfx.LineMaterial( + thickness=edge_thickness, color=edge_color, pick_write=True + ), ) # position data for the right edge line @@ -182,7 +184,9 @@ def __init__( right_line = pygfx.Line( pygfx.Geometry(positions=right_line_data), - pygfx.LineMaterial(thickness=edge_thickness, color=edge_color), + pygfx.LineMaterial( + thickness=edge_thickness, color=edge_color, pick_write=True + ), ) self.edges: Tuple[pygfx.Line, pygfx.Line] = (left_line, right_line) @@ -198,7 +202,9 @@ def __init__( bottom_line = pygfx.Line( pygfx.Geometry(positions=bottom_line_data), - pygfx.LineMaterial(thickness=edge_thickness, color=edge_color), + pygfx.LineMaterial( + thickness=edge_thickness, color=edge_color, pick_write=True + ), ) # position data for the right edge line @@ -211,7 +217,9 @@ def __init__( top_line = pygfx.Line( pygfx.Geometry(positions=top_line_data), - pygfx.LineMaterial(thickness=edge_thickness, color=edge_color), + pygfx.LineMaterial( + thickness=edge_thickness, color=edge_color, pick_write=True + ), ) self.edges: Tuple[pygfx.Line, pygfx.Line] = (bottom_line, top_line) diff --git a/fastplotlib/graphics/selectors/_polygon.py b/fastplotlib/graphics/selectors/_polygon.py index 3d2ee98fd..a4ecd440c 100644 --- a/fastplotlib/graphics/selectors/_polygon.py +++ b/fastplotlib/graphics/selectors/_polygon.py @@ -71,7 +71,9 @@ def _add_segment(self, ev): new_line = pygfx.Line( geometry=pygfx.Geometry(positions=data.astype(np.float32)), material=pygfx.LineMaterial( - thickness=self.edge_width, color=pygfx.Color(self.edge_color) + thickness=self.edge_width, + color=pygfx.Color(self.edge_color), + pick_write=True, ), ) @@ -126,7 +128,9 @@ def _finish_polygon(self, ev): new_line = pygfx.Line( geometry=pygfx.Geometry(positions=data.astype(np.float32)), material=pygfx.LineMaterial( - thickness=self.edge_width, color=pygfx.Color(self.edge_color) + thickness=self.edge_width, + color=pygfx.Color(self.edge_color), + pick_write=True, ), ) diff --git a/fastplotlib/graphics/selectors/_rectangle_region.py b/fastplotlib/graphics/selectors/_rectangle_region.py index 1081a49a9..bc2cad5b1 100644 --- a/fastplotlib/graphics/selectors/_rectangle_region.py +++ b/fastplotlib/graphics/selectors/_rectangle_region.py @@ -214,7 +214,7 @@ def __init__( self.fill = pygfx.Mesh( pygfx.box_geometry(width, height, 1), - pygfx.MeshBasicMaterial(color=pygfx.Color(fill_color)), + pygfx.MeshBasicMaterial(color=pygfx.Color(fill_color), pick_write=True), ) self.fill.position.set(*origin, -2) diff --git a/fastplotlib/graphics/text.py b/fastplotlib/graphics/text.py index a486b1bd2..49b4ac4be 100644 --- a/fastplotlib/graphics/text.py +++ b/fastplotlib/graphics/text.py @@ -70,6 +70,7 @@ def __init__( color=face_color, outline_color=outline_color, outline_thickness=outline_thickness, + pick_write=True, ), ) diff --git a/fastplotlib/widgets/histogram_lut.py b/fastplotlib/widgets/histogram_lut.py index 67af972b8..971bc1a28 100644 --- a/fastplotlib/widgets/histogram_lut.py +++ b/fastplotlib/widgets/histogram_lut.py @@ -80,6 +80,8 @@ def __init__( outline_thickness=1, ) + self._text_vmin.world_object.material.pick_write = False + self._text_vmax = TextGraphic( text=vmax_str, size=16, @@ -89,6 +91,8 @@ def __init__( outline_thickness=1, ) + self._text_vmax.world_object.material.pick_write = False + widget_wo = Group() widget_wo.add( self._histogram_line.world_object,