Skip to content

making picking default for all graphics #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions fastplotlib/graphics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion fastplotlib/graphics/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion fastplotlib/graphics/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions fastplotlib/graphics/selectors/_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions fastplotlib/graphics/selectors/_linear_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'")
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions fastplotlib/graphics/selectors/_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)

Expand Down Expand Up @@ -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,
),
)

Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/selectors/_rectangle_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions fastplotlib/graphics/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
color=face_color,
outline_color=outline_color,
outline_thickness=outline_thickness,
pick_write=True,
),
)

Expand Down
4 changes: 4 additions & 0 deletions fastplotlib/widgets/histogram_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy