vispy 0.9.5__cp38-cp38-win_amd64.whl → 0.14.0__cp38-cp38-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vispy might be problematic. Click here for more details.
- vispy/app/backends/_glfw.py +2 -2
- vispy/app/backends/_pyglet.py +8 -2
- vispy/app/backends/_qt.py +88 -63
- vispy/app/backends/_wx.py +6 -1
- vispy/app/canvas.py +4 -2
- vispy/app/tests/test_canvas.py +52 -1
- vispy/app/tests/test_context.py +5 -3
- vispy/color/color_array.py +8 -1
- vispy/color/colormap.py +5 -25
- vispy/geometry/meshdata.py +76 -38
- vispy/geometry/rect.py +6 -0
- vispy/geometry/tests/test_meshdata.py +72 -0
- vispy/gloo/buffer.py +12 -0
- vispy/gloo/gl/_constants.py +9 -5
- vispy/gloo/gl/_es2.py +8 -4
- vispy/gloo/gl/_gl2.py +2 -3
- vispy/gloo/gl/_proxy.py +1 -1
- vispy/gloo/gl/_pyopengl2.py +12 -7
- vispy/gloo/gl/tests/test_names.py +3 -0
- vispy/gloo/glir.py +26 -13
- vispy/gloo/program.py +39 -22
- vispy/gloo/tests/test_program.py +9 -2
- vispy/gloo/tests/test_texture.py +19 -2
- vispy/gloo/texture.py +46 -16
- vispy/gloo/wrappers.py +4 -2
- vispy/glsl/build_spatial_filters.py +241 -293
- vispy/glsl/misc/spatial-filters.frag +1299 -254
- vispy/io/_data/spatial-filters.npy +0 -0
- vispy/io/datasets.py +2 -2
- vispy/io/image.py +1 -1
- vispy/io/stl.py +3 -3
- vispy/scene/cameras/base_camera.py +6 -2
- vispy/scene/cameras/panzoom.py +10 -14
- vispy/scene/cameras/perspective.py +6 -0
- vispy/scene/cameras/tests/test_cameras.py +27 -0
- vispy/scene/cameras/tests/test_perspective.py +37 -0
- vispy/scene/cameras/turntable.py +39 -23
- vispy/scene/canvas.py +9 -5
- vispy/scene/events.py +9 -0
- vispy/scene/node.py +19 -2
- vispy/scene/tests/test_canvas.py +30 -1
- vispy/scene/tests/test_visuals.py +113 -0
- vispy/scene/visuals.py +6 -1
- vispy/scene/widgets/viewbox.py +3 -2
- vispy/testing/_runners.py +6 -12
- vispy/testing/_testing.py +3 -4
- vispy/util/check_environment.py +4 -4
- vispy/util/gallery_scraper.py +50 -32
- vispy/util/tests/test_gallery_scraper.py +2 -0
- vispy/util/transforms.py +1 -1
- vispy/util/wrappers.py +1 -1
- vispy/version.py +2 -3
- vispy/visuals/__init__.py +2 -0
- vispy/visuals/_scalable_textures.py +20 -17
- vispy/visuals/collections/array_list.py +3 -3
- vispy/visuals/collections/base_collection.py +1 -1
- vispy/visuals/ellipse.py +1 -1
- vispy/visuals/filters/__init__.py +3 -2
- vispy/visuals/filters/base_filter.py +120 -0
- vispy/visuals/filters/clipping_planes.py +24 -12
- vispy/visuals/filters/markers.py +28 -0
- vispy/visuals/filters/mesh.py +61 -6
- vispy/visuals/filters/tests/test_primitive_picking_filters.py +70 -0
- vispy/visuals/graphs/graph.py +1 -1
- vispy/visuals/image.py +114 -26
- vispy/visuals/image_complex.py +130 -0
- vispy/visuals/instanced_mesh.py +152 -0
- vispy/visuals/isocurve.py +1 -1
- vispy/visuals/line/dash_atlas.py +46 -41
- vispy/visuals/line/line.py +2 -5
- vispy/visuals/markers.py +310 -384
- vispy/visuals/mesh.py +2 -2
- vispy/visuals/shaders/function.py +3 -0
- vispy/visuals/shaders/tests/test_function.py +6 -0
- vispy/visuals/tests/test_axis.py +2 -2
- vispy/visuals/tests/test_image.py +92 -2
- vispy/visuals/tests/test_image_complex.py +36 -0
- vispy/visuals/tests/test_instanced_mesh.py +50 -0
- vispy/visuals/tests/test_markers.py +6 -0
- vispy/visuals/tests/test_mesh.py +17 -0
- vispy/visuals/tests/test_text.py +11 -0
- vispy/visuals/tests/test_volume.py +218 -12
- vispy/visuals/text/_sdf_cpu.cp38-win_amd64.pyd +0 -0
- vispy/visuals/text/_sdf_cpu.pyx +21 -23
- vispy/visuals/text/text.py +9 -3
- vispy/visuals/tube.py +2 -2
- vispy/visuals/visual.py +144 -3
- vispy/visuals/volume.py +300 -131
- {vispy-0.9.5.dist-info → vispy-0.14.0.dist-info}/LICENSE.txt +1 -1
- {vispy-0.9.5.dist-info → vispy-0.14.0.dist-info}/METADATA +218 -198
- {vispy-0.9.5.dist-info → vispy-0.14.0.dist-info}/RECORD +93 -96
- {vispy-0.9.5.dist-info → vispy-0.14.0.dist-info}/WHEEL +1 -1
- vispy/glsl/antialias/__init__.py +0 -0
- vispy/glsl/arrowheads/__init__.py +0 -0
- vispy/glsl/arrows/__init__.py +0 -0
- vispy/glsl/collections/__init__.py +0 -0
- vispy/glsl/colormaps/__init__.py +0 -0
- vispy/glsl/lines/__init__.py +0 -0
- vispy/glsl/markers/__init__.py +0 -0
- vispy/glsl/math/__init__.py +0 -0
- vispy/glsl/misc/__init__.py +0 -0
- vispy/glsl/transforms/__init__.py +0 -0
- {vispy-0.9.5.dist-info → vispy-0.14.0.dist-info}/top_level.txt +0 -0
vispy/visuals/text/text.py
CHANGED
|
@@ -201,7 +201,7 @@ _FRAGMENT_SHADER = """
|
|
|
201
201
|
|
|
202
202
|
// Use interpolation at high font sizes
|
|
203
203
|
if(u_npix >= 50.0)
|
|
204
|
-
rgb =
|
|
204
|
+
rgb = CatRom2D(u_font_atlas, u_font_atlas_shape, uv);
|
|
205
205
|
else
|
|
206
206
|
rgb = texture2D(u_font_atlas, uv);
|
|
207
207
|
float distance = rgb.r;
|
|
@@ -227,6 +227,8 @@ _FRAGMENT_SHADER = """
|
|
|
227
227
|
alpha = (alpha + 0.5 * asum) / 3.0;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
if (alpha <= 0) discard;
|
|
231
|
+
|
|
230
232
|
gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);
|
|
231
233
|
}
|
|
232
234
|
"""
|
|
@@ -395,6 +397,10 @@ class TextVisual(Visual):
|
|
|
395
397
|
The 'gpu' method should produce higher quality results.
|
|
396
398
|
font_manager : object | None
|
|
397
399
|
Font manager to use (can be shared if the GLContext is shared).
|
|
400
|
+
depth_test : bool
|
|
401
|
+
Whether to apply depth testing. Default False. If False, the text
|
|
402
|
+
behaves like an overlay that does not get hidden behind other
|
|
403
|
+
visuals in the scene.
|
|
398
404
|
"""
|
|
399
405
|
|
|
400
406
|
_shaders = {
|
|
@@ -405,7 +411,7 @@ class TextVisual(Visual):
|
|
|
405
411
|
def __init__(self, text=None, color='black', bold=False,
|
|
406
412
|
italic=False, face='OpenSans', font_size=12, pos=[0, 0, 0],
|
|
407
413
|
rotation=0., anchor_x='center', anchor_y='center',
|
|
408
|
-
method='cpu', font_manager=None):
|
|
414
|
+
method='cpu', font_manager=None, depth_test=False):
|
|
409
415
|
Visual.__init__(self, vcode=self._shaders['vertex'], fcode=self._shaders['fragment'])
|
|
410
416
|
# Check input
|
|
411
417
|
valid_keys = ('top', 'center', 'middle', 'baseline', 'bottom')
|
|
@@ -430,7 +436,7 @@ class TextVisual(Visual):
|
|
|
430
436
|
self.rotation = rotation
|
|
431
437
|
self._text_scale = STTransform()
|
|
432
438
|
self._draw_mode = 'triangles'
|
|
433
|
-
self.set_gl_state(blend=True, depth_test=
|
|
439
|
+
self.set_gl_state(blend=True, depth_test=depth_test, cull_face=False,
|
|
434
440
|
blend_func=('src_alpha', 'one_minus_src_alpha'))
|
|
435
441
|
self.freeze()
|
|
436
442
|
|
vispy/visuals/tube.py
CHANGED
|
@@ -65,7 +65,7 @@ class TubeVisual(MeshVisual):
|
|
|
65
65
|
segments = len(points) - 1
|
|
66
66
|
|
|
67
67
|
# if single radius, convert to list of radii
|
|
68
|
-
if not isinstance(radius, collections.Iterable):
|
|
68
|
+
if not isinstance(radius, collections.abc.Iterable):
|
|
69
69
|
radius = [radius] * len(points)
|
|
70
70
|
elif len(radius) != len(points):
|
|
71
71
|
raise ValueError('Length of radii list must match points.')
|
|
@@ -80,7 +80,7 @@ class TubeVisual(MeshVisual):
|
|
|
80
80
|
|
|
81
81
|
# Add a vertex for each point on the circle
|
|
82
82
|
v = np.arange(tube_points,
|
|
83
|
-
dtype=np.
|
|
83
|
+
dtype=np.float32) / tube_points * 2 * np.pi
|
|
84
84
|
cx = -1. * r * np.cos(v)
|
|
85
85
|
cy = r * np.sin(v)
|
|
86
86
|
grid[i] = (pos + cx[:, np.newaxis]*normal +
|
vispy/visuals/visual.py
CHANGED
|
@@ -83,9 +83,10 @@ A compound visual will automatically handle forwarding transform system changes
|
|
|
83
83
|
and filter attachments to its internally-wrapped visuals. To the user, this
|
|
84
84
|
will appear to behave as a single visual.
|
|
85
85
|
"""
|
|
86
|
-
|
|
87
86
|
from __future__ import division
|
|
88
87
|
import weakref
|
|
88
|
+
from contextlib import contextmanager
|
|
89
|
+
|
|
89
90
|
import numpy as np
|
|
90
91
|
|
|
91
92
|
from .. import gloo
|
|
@@ -337,6 +338,7 @@ class Visual(BaseVisual):
|
|
|
337
338
|
raise ValueError("Cannot specify both program and "
|
|
338
339
|
"vcode/fcode arguments.")
|
|
339
340
|
|
|
341
|
+
self._prev_gl_state = []
|
|
340
342
|
self._program = self._vshare.program.add_program()
|
|
341
343
|
self._prepare_transforms(self)
|
|
342
344
|
self._filters = []
|
|
@@ -347,6 +349,11 @@ class Visual(BaseVisual):
|
|
|
347
349
|
|
|
348
350
|
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
349
351
|
|
|
352
|
+
This can also be used as a context manager that will revert the
|
|
353
|
+
gl_state on exit. When used as a context manager, this function is
|
|
354
|
+
designed to be constructed directly in the header of the `with`
|
|
355
|
+
statement to avoid confusion about what state will be restored on exit.
|
|
356
|
+
|
|
350
357
|
Parameters
|
|
351
358
|
----------
|
|
352
359
|
preset : str
|
|
@@ -354,27 +361,83 @@ class Visual(BaseVisual):
|
|
|
354
361
|
**kwargs : dict
|
|
355
362
|
Keyword arguments.
|
|
356
363
|
"""
|
|
364
|
+
prev_gl_state = self._vshare.gl_state.copy()
|
|
365
|
+
|
|
357
366
|
self._vshare.gl_state = kwargs
|
|
358
367
|
self._vshare.gl_state['preset'] = preset
|
|
359
368
|
|
|
369
|
+
return _revert_gl_state([(self, prev_gl_state)])
|
|
370
|
+
|
|
360
371
|
def update_gl_state(self, *args, **kwargs):
|
|
361
372
|
"""Modify the set of GL state parameters to use when drawing.
|
|
362
373
|
|
|
363
374
|
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
364
375
|
|
|
376
|
+
This can also be used as a context manager that will revert the
|
|
377
|
+
gl_state on exit.
|
|
378
|
+
|
|
365
379
|
Parameters
|
|
366
380
|
----------
|
|
367
381
|
*args : tuple
|
|
368
382
|
Arguments.
|
|
369
383
|
**kwargs : dict
|
|
370
|
-
Keyword
|
|
384
|
+
Keyword arguments.
|
|
371
385
|
"""
|
|
386
|
+
prev_gl_state = self._vshare.gl_state.copy()
|
|
387
|
+
|
|
372
388
|
if len(args) == 1:
|
|
373
389
|
self._vshare.gl_state['preset'] = args[0]
|
|
374
390
|
elif len(args) != 0:
|
|
375
391
|
raise TypeError("Only one positional argument allowed.")
|
|
376
392
|
self._vshare.gl_state.update(kwargs)
|
|
377
393
|
|
|
394
|
+
return _revert_gl_state([(self, prev_gl_state)])
|
|
395
|
+
|
|
396
|
+
def push_gl_state(self, *args, **kwargs):
|
|
397
|
+
"""Define the set of GL state parameters to use when drawing.
|
|
398
|
+
|
|
399
|
+
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
400
|
+
|
|
401
|
+
This differs from :py:meth:`.set_gl_state` in that it stashes the
|
|
402
|
+
current state. See :py:meth:`.pop_gl_state` for restoring the state.
|
|
403
|
+
|
|
404
|
+
Parameters
|
|
405
|
+
----------
|
|
406
|
+
*args : tuple
|
|
407
|
+
Arguments.
|
|
408
|
+
**kwargs : dict
|
|
409
|
+
Keyword arguments.
|
|
410
|
+
"""
|
|
411
|
+
self._prev_gl_state.append(self._vshare.gl_state.copy())
|
|
412
|
+
self.set_gl_state(*args, **kwargs)
|
|
413
|
+
|
|
414
|
+
def push_gl_state_update(self, *args, **kwargs):
|
|
415
|
+
"""Modify the set of GL state parameters to use when drawing.
|
|
416
|
+
|
|
417
|
+
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
418
|
+
|
|
419
|
+
This differs from :py:meth:`.update_gl_state` in that it stashes the
|
|
420
|
+
current state. See :py:meth:`.pop_gl_state` for restoring the state.
|
|
421
|
+
|
|
422
|
+
Parameters
|
|
423
|
+
----------
|
|
424
|
+
*args : tuple
|
|
425
|
+
Arguments.
|
|
426
|
+
**kwargs : dict
|
|
427
|
+
Keyword arguments.
|
|
428
|
+
"""
|
|
429
|
+
self._prev_gl_state.append(self._vshare.gl_state.copy())
|
|
430
|
+
self.update_gl_state(*args, **kwargs)
|
|
431
|
+
|
|
432
|
+
def pop_gl_state(self):
|
|
433
|
+
"""Restore a previous set of GL state parameters if available.
|
|
434
|
+
|
|
435
|
+
If no previous GL state is available (see :py:meth:`.push_gl_state`),
|
|
436
|
+
this has no effect.
|
|
437
|
+
"""
|
|
438
|
+
if self._prev_gl_state:
|
|
439
|
+
self.set_gl_state(**self._prev_gl_state.pop())
|
|
440
|
+
|
|
378
441
|
def _compute_bounds(self, axis, view):
|
|
379
442
|
"""Return the (min, max) bounding values of this visual along *axis*
|
|
380
443
|
in the local coordinate system.
|
|
@@ -616,6 +679,9 @@ class CompoundVisual(BaseVisual):
|
|
|
616
679
|
|
|
617
680
|
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
618
681
|
|
|
682
|
+
This can also be used as a context manager that will revert the
|
|
683
|
+
gl_state on exit.
|
|
684
|
+
|
|
619
685
|
Parameters
|
|
620
686
|
----------
|
|
621
687
|
preset : str
|
|
@@ -623,24 +689,80 @@ class CompoundVisual(BaseVisual):
|
|
|
623
689
|
**kwargs : dict
|
|
624
690
|
Keyword arguments.
|
|
625
691
|
"""
|
|
692
|
+
prev_gl_state = []
|
|
626
693
|
for v in self._subvisuals:
|
|
694
|
+
prev_gl_state.append((v, v._vshare.gl_state))
|
|
627
695
|
v.set_gl_state(preset=preset, **kwargs)
|
|
628
696
|
|
|
697
|
+
return _revert_gl_state(prev_gl_state)
|
|
698
|
+
|
|
629
699
|
def update_gl_state(self, *args, **kwargs):
|
|
630
700
|
"""Modify the set of GL state parameters to use when drawing.
|
|
631
701
|
|
|
632
702
|
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
633
703
|
|
|
704
|
+
This can also be used as a context manager that will revert the
|
|
705
|
+
gl_state on exit.
|
|
706
|
+
|
|
634
707
|
Parameters
|
|
635
708
|
----------
|
|
636
709
|
*args : tuple
|
|
637
710
|
Arguments.
|
|
638
711
|
**kwargs : dict
|
|
639
|
-
Keyword
|
|
712
|
+
Keyword arguments.
|
|
640
713
|
"""
|
|
714
|
+
prev_gl_state = []
|
|
641
715
|
for v in self._subvisuals:
|
|
716
|
+
prev_gl_state.append((v, v._vshare.gl_state))
|
|
642
717
|
v.update_gl_state(*args, **kwargs)
|
|
643
718
|
|
|
719
|
+
return _revert_gl_state(prev_gl_state)
|
|
720
|
+
|
|
721
|
+
def push_gl_state(self, *args, **kwargs):
|
|
722
|
+
"""Define the set of GL state parameters to use when drawing.
|
|
723
|
+
|
|
724
|
+
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
725
|
+
|
|
726
|
+
This differs from :py:meth:`.set_gl_state` in that it stashes the
|
|
727
|
+
current state. See :py:meth:`.pop_gl_state` for restoring the state.
|
|
728
|
+
|
|
729
|
+
Parameters
|
|
730
|
+
----------
|
|
731
|
+
*args : tuple
|
|
732
|
+
Arguments.
|
|
733
|
+
**kwargs : dict
|
|
734
|
+
Keyword arguments.
|
|
735
|
+
"""
|
|
736
|
+
for v in self._subvisuals:
|
|
737
|
+
v.push_gl_state(*args, **kwargs)
|
|
738
|
+
|
|
739
|
+
def push_gl_state_update(self, *args, **kwargs):
|
|
740
|
+
"""Modify the set of GL state parameters to use when drawing.
|
|
741
|
+
|
|
742
|
+
The arguments are forwarded to :func:`vispy.gloo.wrappers.set_state`.
|
|
743
|
+
|
|
744
|
+
This differs from :py:meth:`.update_gl_state` in that it stashes the
|
|
745
|
+
current state. See :py:meth:`.pop_gl_state` for restoring the state.
|
|
746
|
+
|
|
747
|
+
Parameters
|
|
748
|
+
----------
|
|
749
|
+
*args : tuple
|
|
750
|
+
Arguments.
|
|
751
|
+
**kwargs : dict
|
|
752
|
+
Keyword arguments.
|
|
753
|
+
"""
|
|
754
|
+
for v in self._subvisuals:
|
|
755
|
+
v.push_gl_state_update(*args, **kwargs)
|
|
756
|
+
|
|
757
|
+
def pop_gl_state(self):
|
|
758
|
+
"""Restore a previous set of GL state parameters if available.
|
|
759
|
+
|
|
760
|
+
If no previous GL state is available (see :py:meth:`.push_gl_state`),
|
|
761
|
+
this has no effect.
|
|
762
|
+
"""
|
|
763
|
+
for v in self._subvisuals:
|
|
764
|
+
v.pop_gl_state()
|
|
765
|
+
|
|
644
766
|
def attach(self, filt, view=None):
|
|
645
767
|
"""Attach a Filter to this visual
|
|
646
768
|
|
|
@@ -681,6 +803,25 @@ class CompoundVisual(BaseVisual):
|
|
|
681
803
|
return bounds
|
|
682
804
|
|
|
683
805
|
|
|
806
|
+
@contextmanager
|
|
807
|
+
def _revert_gl_state(prev_gl_state):
|
|
808
|
+
"""Context manager to store and revert GL state for a list of visuals.
|
|
809
|
+
|
|
810
|
+
Parameters
|
|
811
|
+
----------
|
|
812
|
+
prev_gl_state : list
|
|
813
|
+
A list of (Visual, gl_state) tuples, where gl_state is a dictionary of
|
|
814
|
+
`gl_state` params as would be passed to :py:func:`set_gl_state`.
|
|
815
|
+
"""
|
|
816
|
+
for v, state in prev_gl_state:
|
|
817
|
+
v._prev_gl_state.append(state)
|
|
818
|
+
try:
|
|
819
|
+
yield
|
|
820
|
+
finally:
|
|
821
|
+
for v, _ in prev_gl_state:
|
|
822
|
+
v.pop_gl_state()
|
|
823
|
+
|
|
824
|
+
|
|
684
825
|
class CompoundVisualView(BaseVisualView, CompoundVisual):
|
|
685
826
|
def __init__(self, visual):
|
|
686
827
|
BaseVisualView.__init__(self, visual)
|