Skip to content
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
4 changes: 2 additions & 2 deletions examples/screenshots/linear_selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/screenshots/no-imgui-linear_selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/selection_tools/linear_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Example showing how to use a `LinearSelector` with lines and line collections.
"""

# test_example = false
# test_example = true
# sphinx_gallery_pygfx_docs = 'screenshot'

import fastplotlib as fpl
Expand Down
2 changes: 0 additions & 2 deletions fastplotlib/graphics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ def add_linear_selector(
selector = LinearSelector(
selection=selection,
limits=limits,
size=size,
center=center,
axis=axis,
parent=self,
**kwargs,
Expand Down
2 changes: 0 additions & 2 deletions fastplotlib/graphics/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ def add_linear_selector(
selector = LinearSelector(
selection=selection,
limits=limits,
size=size,
center=center,
axis=axis,
parent=self,
**kwargs,
Expand Down
2 changes: 0 additions & 2 deletions fastplotlib/graphics/line_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@ def add_linear_selector(
selector = LinearSelector(
selection=selection,
limits=limits,
size=size,
center=center,
axis=axis,
parent=self,
**kwargs,
Expand Down
37 changes: 11 additions & 26 deletions fastplotlib/graphics/selectors/_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ def __init__(
self,
selection: float,
limits: Sequence[float],
size: float,
center: float,
axis: str = "x",
parent: Graphic = None,
edge_color: str | Sequence[float] | np.ndarray = "w",
Expand All @@ -95,12 +93,6 @@ def __init__(
limits: (int, int)
(min, max) limits along the x or y-axis for the selector, in data space

size: float
size of the selector, usually the range of the data

center: float
center offset of the selector on the orthogonal axis, usually the data mean

axis: str, default "x"
"x" | "y", the axis along which the selector can move

Expand Down Expand Up @@ -131,29 +123,22 @@ def __init__(

self._limits = np.asarray(limits)

end_points = [-size / 2, size / 2]

if axis == "x":
xs = np.array([selection, selection])
ys = np.array(end_points)
zs = np.zeros(2)
xs = np.array([selection, selection], dtype=np.float32)
ys = np.array([0, 1], dtype=np.float32)
zs = np.zeros(2, dtype=np.float32)

line_data = np.column_stack([xs, ys, zs])
elif axis == "y":
xs = np.array(end_points)
ys = np.array([selection, selection])
zs = np.zeros(2)
xs = np.array([0, 1], dtype=np.float32)
ys = np.array([selection, selection], dtype=np.float32)
zs = np.zeros(2, dtype=np.float32)

line_data = np.column_stack([xs, ys, zs])
else:
raise ValueError("`axis` must be one of 'x' or 'y'")
raise ValueError("`axis` must be one of 'x' | 'y'")

line_data = line_data.astype(np.float32)
line_data = np.column_stack([xs, ys, zs])

if thickness < 1.1:
material = pygfx.LineThinMaterial
else:
material = pygfx.LineMaterial
material = pygfx.LineInfiniteSegmentMaterial

self.colors_outer = pygfx.Color([0.3, 0.3, 0.3, 1.0])

Expand All @@ -178,9 +163,9 @@ def __init__(
world_object.add(line_inner)

if axis == "x":
offset = (parent.offset[0], center + parent.offset[1], 0)
offset = (parent.offset[0], 0, 0)
elif axis == "y":
offset = (center + parent.offset[0], parent.offset[1], 0)
offset = (0, parent.offset[1], 0)

# init base selector
BaseSelector.__init__(
Expand Down
Loading