Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 29d4a87

Browse filesBrowse files
authored
use LineInfiniteSegmentMaterial for LinearSelector (#813)
* use LineInfiniteSegmentMaterial * remove comment * linear selector wasn't in screenshot tests * linear selector ground truths
1 parent 4294969 commit 29d4a87
Copy full SHA for 29d4a87

File tree

7 files changed

+17
-35
lines changed
Filter options

7 files changed

+17
-35
lines changed
+2-2
Loading
Loading

‎examples/selection_tools/linear_selector.py

Copy file name to clipboardExpand all lines: examples/selection_tools/linear_selector.py
+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Example showing how to use a `LinearSelector` with lines and line collections.
66
"""
77

8-
# test_example = false
8+
# test_example = true
99
# sphinx_gallery_pygfx_docs = 'screenshot'
1010

1111
import fastplotlib as fpl

‎fastplotlib/graphics/image.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/image.py
-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ def add_linear_selector(
312312
selector = LinearSelector(
313313
selection=selection,
314314
limits=limits,
315-
size=size,
316-
center=center,
317315
axis=axis,
318316
parent=self,
319317
**kwargs,

‎fastplotlib/graphics/line.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/line.py
-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ def add_linear_selector(
166166
selector = LinearSelector(
167167
selection=selection,
168168
limits=limits,
169-
size=size,
170-
center=center,
171169
axis=axis,
172170
parent=self,
173171
**kwargs,

‎fastplotlib/graphics/line_collection.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/line_collection.py
-2
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,6 @@ def add_linear_selector(
374374
selector = LinearSelector(
375375
selection=selection,
376376
limits=limits,
377-
size=size,
378-
center=center,
379377
axis=axis,
380378
parent=self,
381379
**kwargs,

‎fastplotlib/graphics/selectors/_linear.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_linear.py
+11-26
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def __init__(
7575
self,
7676
selection: float,
7777
limits: Sequence[float],
78-
size: float,
79-
center: float,
8078
axis: str = "x",
8179
parent: Graphic = None,
8280
edge_color: str | Sequence[float] | np.ndarray = "w",
@@ -95,12 +93,6 @@ def __init__(
9593
limits: (int, int)
9694
(min, max) limits along the x or y-axis for the selector, in data space
9795
98-
size: float
99-
size of the selector, usually the range of the data
100-
101-
center: float
102-
center offset of the selector on the orthogonal axis, usually the data mean
103-
10496
axis: str, default "x"
10597
"x" | "y", the axis along which the selector can move
10698
@@ -131,29 +123,22 @@ def __init__(
131123

132124
self._limits = np.asarray(limits)
133125

134-
end_points = [-size / 2, size / 2]
135-
136126
if axis == "x":
137-
xs = np.array([selection, selection])
138-
ys = np.array(end_points)
139-
zs = np.zeros(2)
127+
xs = np.array([selection, selection], dtype=np.float32)
128+
ys = np.array([0, 1], dtype=np.float32)
129+
zs = np.zeros(2, dtype=np.float32)
140130

141-
line_data = np.column_stack([xs, ys, zs])
142131
elif axis == "y":
143-
xs = np.array(end_points)
144-
ys = np.array([selection, selection])
145-
zs = np.zeros(2)
132+
xs = np.array([0, 1], dtype=np.float32)
133+
ys = np.array([selection, selection], dtype=np.float32)
134+
zs = np.zeros(2, dtype=np.float32)
146135

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

151-
line_data = line_data.astype(np.float32)
139+
line_data = np.column_stack([xs, ys, zs])
152140

153-
if thickness < 1.1:
154-
material = pygfx.LineThinMaterial
155-
else:
156-
material = pygfx.LineMaterial
141+
material = pygfx.LineInfiniteSegmentMaterial
157142

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

@@ -178,9 +163,9 @@ def __init__(
178163
world_object.add(line_inner)
179164

180165
if axis == "x":
181-
offset = (parent.offset[0], center + parent.offset[1], 0)
166+
offset = (parent.offset[0], 0, 0)
182167
elif axis == "y":
183-
offset = (center + parent.offset[0], parent.offset[1], 0)
168+
offset = (0, parent.offset[1], 0)
184169

185170
# init base selector
186171
BaseSelector.__init__(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.