vispy 0.15.0__cp312-cp312-macosx_10_13_x86_64.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/__init__.py +33 -0
- vispy/app/__init__.py +15 -0
- vispy/app/_default_app.py +76 -0
- vispy/app/_detect_eventloop.py +148 -0
- vispy/app/application.py +263 -0
- vispy/app/backends/__init__.py +52 -0
- vispy/app/backends/_egl.py +264 -0
- vispy/app/backends/_glfw.py +513 -0
- vispy/app/backends/_jupyter_rfb.py +278 -0
- vispy/app/backends/_offscreen_util.py +121 -0
- vispy/app/backends/_osmesa.py +235 -0
- vispy/app/backends/_pyglet.py +451 -0
- vispy/app/backends/_pyqt4.py +36 -0
- vispy/app/backends/_pyqt5.py +36 -0
- vispy/app/backends/_pyqt6.py +40 -0
- vispy/app/backends/_pyside.py +37 -0
- vispy/app/backends/_pyside2.py +52 -0
- vispy/app/backends/_pyside6.py +53 -0
- vispy/app/backends/_qt.py +1003 -0
- vispy/app/backends/_sdl2.py +444 -0
- vispy/app/backends/_template.py +244 -0
- vispy/app/backends/_test.py +8 -0
- vispy/app/backends/_tk.py +800 -0
- vispy/app/backends/_wx.py +476 -0
- vispy/app/backends/tests/__init__.py +0 -0
- vispy/app/backends/tests/test_offscreen_util.py +52 -0
- vispy/app/backends/tests/test_rfb.py +77 -0
- vispy/app/base.py +294 -0
- vispy/app/canvas.py +828 -0
- vispy/app/qt.py +92 -0
- vispy/app/tests/__init__.py +0 -0
- vispy/app/tests/qt-designer.ui +58 -0
- vispy/app/tests/test_app.py +442 -0
- vispy/app/tests/test_backends.py +164 -0
- vispy/app/tests/test_canvas.py +122 -0
- vispy/app/tests/test_context.py +92 -0
- vispy/app/tests/test_qt.py +47 -0
- vispy/app/tests/test_simultaneous.py +134 -0
- vispy/app/timer.py +174 -0
- vispy/color/__init__.py +17 -0
- vispy/color/_color_dict.py +193 -0
- vispy/color/color_array.py +447 -0
- vispy/color/color_space.py +181 -0
- vispy/color/colormap.py +1213 -0
- vispy/color/tests/__init__.py +0 -0
- vispy/color/tests/test_color.py +378 -0
- vispy/conftest.py +12 -0
- vispy/ext/__init__.py +0 -0
- vispy/ext/cocoapy.py +1522 -0
- vispy/ext/cubehelix.py +138 -0
- vispy/ext/egl.py +375 -0
- vispy/ext/fontconfig.py +118 -0
- vispy/ext/gdi32plus.py +206 -0
- vispy/ext/osmesa.py +105 -0
- vispy/geometry/__init__.py +23 -0
- vispy/geometry/_triangulation_debugger.py +171 -0
- vispy/geometry/calculations.py +162 -0
- vispy/geometry/curves.py +399 -0
- vispy/geometry/generation.py +643 -0
- vispy/geometry/isocurve.py +175 -0
- vispy/geometry/isosurface.py +465 -0
- vispy/geometry/meshdata.py +700 -0
- vispy/geometry/normals.py +78 -0
- vispy/geometry/parametric.py +56 -0
- vispy/geometry/polygon.py +137 -0
- vispy/geometry/rect.py +210 -0
- vispy/geometry/tests/__init__.py +0 -0
- vispy/geometry/tests/test_calculations.py +23 -0
- vispy/geometry/tests/test_generation.py +56 -0
- vispy/geometry/tests/test_meshdata.py +106 -0
- vispy/geometry/tests/test_triangulation.py +594 -0
- vispy/geometry/torusknot.py +142 -0
- vispy/geometry/triangulation.py +876 -0
- vispy/gloo/__init__.py +56 -0
- vispy/gloo/buffer.py +505 -0
- vispy/gloo/context.py +272 -0
- vispy/gloo/framebuffer.py +257 -0
- vispy/gloo/gl/__init__.py +234 -0
- vispy/gloo/gl/_constants.py +332 -0
- vispy/gloo/gl/_es2.py +986 -0
- vispy/gloo/gl/_gl2.py +1365 -0
- vispy/gloo/gl/_proxy.py +499 -0
- vispy/gloo/gl/_pyopengl2.py +362 -0
- vispy/gloo/gl/dummy.py +24 -0
- vispy/gloo/gl/es2.py +62 -0
- vispy/gloo/gl/gl2.py +98 -0
- vispy/gloo/gl/glplus.py +168 -0
- vispy/gloo/gl/pyopengl2.py +97 -0
- vispy/gloo/gl/tests/__init__.py +0 -0
- vispy/gloo/gl/tests/test_basics.py +282 -0
- vispy/gloo/gl/tests/test_functionality.py +568 -0
- vispy/gloo/gl/tests/test_names.py +246 -0
- vispy/gloo/gl/tests/test_use.py +71 -0
- vispy/gloo/glir.py +1824 -0
- vispy/gloo/globject.py +101 -0
- vispy/gloo/preprocessor.py +67 -0
- vispy/gloo/program.py +543 -0
- vispy/gloo/tests/__init__.py +0 -0
- vispy/gloo/tests/test_buffer.py +558 -0
- vispy/gloo/tests/test_context.py +119 -0
- vispy/gloo/tests/test_framebuffer.py +195 -0
- vispy/gloo/tests/test_glir.py +307 -0
- vispy/gloo/tests/test_globject.py +35 -0
- vispy/gloo/tests/test_program.py +302 -0
- vispy/gloo/tests/test_texture.py +732 -0
- vispy/gloo/tests/test_use_gloo.py +187 -0
- vispy/gloo/tests/test_util.py +60 -0
- vispy/gloo/tests/test_wrappers.py +261 -0
- vispy/gloo/texture.py +1046 -0
- vispy/gloo/util.py +129 -0
- vispy/gloo/wrappers.py +762 -0
- vispy/glsl/__init__.py +42 -0
- vispy/glsl/antialias/antialias.glsl +7 -0
- vispy/glsl/antialias/cap-butt.glsl +31 -0
- vispy/glsl/antialias/cap-round.glsl +29 -0
- vispy/glsl/antialias/cap-square.glsl +30 -0
- vispy/glsl/antialias/cap-triangle-in.glsl +30 -0
- vispy/glsl/antialias/cap-triangle-out.glsl +30 -0
- vispy/glsl/antialias/cap.glsl +67 -0
- vispy/glsl/antialias/caps.glsl +67 -0
- vispy/glsl/antialias/filled.glsl +50 -0
- vispy/glsl/antialias/outline.glsl +40 -0
- vispy/glsl/antialias/stroke.glsl +43 -0
- vispy/glsl/arrowheads/angle.glsl +99 -0
- vispy/glsl/arrowheads/arrowheads.frag +60 -0
- vispy/glsl/arrowheads/arrowheads.glsl +12 -0
- vispy/glsl/arrowheads/arrowheads.vert +83 -0
- vispy/glsl/arrowheads/curved.glsl +48 -0
- vispy/glsl/arrowheads/inhibitor.glsl +26 -0
- vispy/glsl/arrowheads/stealth.glsl +46 -0
- vispy/glsl/arrowheads/triangle.glsl +97 -0
- vispy/glsl/arrowheads/util.glsl +13 -0
- vispy/glsl/arrows/angle-30.glsl +12 -0
- vispy/glsl/arrows/angle-60.glsl +12 -0
- vispy/glsl/arrows/angle-90.glsl +12 -0
- vispy/glsl/arrows/arrow.frag +39 -0
- vispy/glsl/arrows/arrow.vert +49 -0
- vispy/glsl/arrows/arrows.glsl +17 -0
- vispy/glsl/arrows/common.glsl +187 -0
- vispy/glsl/arrows/curved.glsl +63 -0
- vispy/glsl/arrows/stealth.glsl +50 -0
- vispy/glsl/arrows/triangle-30.glsl +12 -0
- vispy/glsl/arrows/triangle-60.glsl +12 -0
- vispy/glsl/arrows/triangle-90.glsl +12 -0
- vispy/glsl/arrows/util.glsl +98 -0
- vispy/glsl/build_spatial_filters.py +660 -0
- vispy/glsl/collections/agg-fast-path.frag +20 -0
- vispy/glsl/collections/agg-fast-path.vert +78 -0
- vispy/glsl/collections/agg-glyph.frag +60 -0
- vispy/glsl/collections/agg-glyph.vert +33 -0
- vispy/glsl/collections/agg-marker.frag +35 -0
- vispy/glsl/collections/agg-marker.vert +48 -0
- vispy/glsl/collections/agg-path.frag +55 -0
- vispy/glsl/collections/agg-path.vert +166 -0
- vispy/glsl/collections/agg-point.frag +21 -0
- vispy/glsl/collections/agg-point.vert +35 -0
- vispy/glsl/collections/agg-segment.frag +32 -0
- vispy/glsl/collections/agg-segment.vert +75 -0
- vispy/glsl/collections/marker.frag +38 -0
- vispy/glsl/collections/marker.vert +48 -0
- vispy/glsl/collections/raw-path.frag +15 -0
- vispy/glsl/collections/raw-path.vert +24 -0
- vispy/glsl/collections/raw-point.frag +14 -0
- vispy/glsl/collections/raw-point.vert +31 -0
- vispy/glsl/collections/raw-segment.frag +18 -0
- vispy/glsl/collections/raw-segment.vert +26 -0
- vispy/glsl/collections/raw-triangle.frag +13 -0
- vispy/glsl/collections/raw-triangle.vert +26 -0
- vispy/glsl/collections/sdf-glyph-ticks.vert +69 -0
- vispy/glsl/collections/sdf-glyph.frag +80 -0
- vispy/glsl/collections/sdf-glyph.vert +59 -0
- vispy/glsl/collections/tick-labels.vert +71 -0
- vispy/glsl/colormaps/autumn.glsl +20 -0
- vispy/glsl/colormaps/blues.glsl +20 -0
- vispy/glsl/colormaps/color-space.glsl +17 -0
- vispy/glsl/colormaps/colormaps.glsl +24 -0
- vispy/glsl/colormaps/cool.glsl +20 -0
- vispy/glsl/colormaps/fire.glsl +21 -0
- vispy/glsl/colormaps/gray.glsl +20 -0
- vispy/glsl/colormaps/greens.glsl +20 -0
- vispy/glsl/colormaps/hot.glsl +22 -0
- vispy/glsl/colormaps/ice.glsl +20 -0
- vispy/glsl/colormaps/icefire.glsl +23 -0
- vispy/glsl/colormaps/parse.py +40 -0
- vispy/glsl/colormaps/reds.glsl +20 -0
- vispy/glsl/colormaps/spring.glsl +20 -0
- vispy/glsl/colormaps/summer.glsl +20 -0
- vispy/glsl/colormaps/user.glsl +22 -0
- vispy/glsl/colormaps/util.glsl +41 -0
- vispy/glsl/colormaps/wheel.glsl +21 -0
- vispy/glsl/colormaps/winter.glsl +20 -0
- vispy/glsl/lines/agg.frag +320 -0
- vispy/glsl/lines/agg.vert +241 -0
- vispy/glsl/markers/arrow.glsl +12 -0
- vispy/glsl/markers/asterisk.glsl +16 -0
- vispy/glsl/markers/chevron.glsl +14 -0
- vispy/glsl/markers/clover.glsl +20 -0
- vispy/glsl/markers/club.glsl +31 -0
- vispy/glsl/markers/cross.glsl +17 -0
- vispy/glsl/markers/diamond.glsl +12 -0
- vispy/glsl/markers/disc.glsl +9 -0
- vispy/glsl/markers/ellipse.glsl +67 -0
- vispy/glsl/markers/hbar.glsl +9 -0
- vispy/glsl/markers/heart.glsl +15 -0
- vispy/glsl/markers/infinity.glsl +15 -0
- vispy/glsl/markers/marker-sdf.frag +74 -0
- vispy/glsl/markers/marker-sdf.vert +41 -0
- vispy/glsl/markers/marker.frag +36 -0
- vispy/glsl/markers/marker.vert +46 -0
- vispy/glsl/markers/markers.glsl +24 -0
- vispy/glsl/markers/pin.glsl +18 -0
- vispy/glsl/markers/ring.glsl +11 -0
- vispy/glsl/markers/spade.glsl +28 -0
- vispy/glsl/markers/square.glsl +10 -0
- vispy/glsl/markers/tag.glsl +11 -0
- vispy/glsl/markers/triangle.glsl +14 -0
- vispy/glsl/markers/vbar.glsl +9 -0
- vispy/glsl/math/circle-through-2-points.glsl +30 -0
- vispy/glsl/math/constants.glsl +48 -0
- vispy/glsl/math/double.glsl +114 -0
- vispy/glsl/math/functions.glsl +20 -0
- vispy/glsl/math/point-to-line-distance.glsl +31 -0
- vispy/glsl/math/point-to-line-projection.glsl +29 -0
- vispy/glsl/math/signed-line-distance.glsl +27 -0
- vispy/glsl/math/signed-segment-distance.glsl +30 -0
- vispy/glsl/misc/regular-grid.frag +244 -0
- vispy/glsl/misc/spatial-filters.frag +1407 -0
- vispy/glsl/misc/viewport-NDC.glsl +20 -0
- vispy/glsl/transforms/azimuthal-equal-area.glsl +32 -0
- vispy/glsl/transforms/azimuthal-equidistant.glsl +38 -0
- vispy/glsl/transforms/hammer.glsl +44 -0
- vispy/glsl/transforms/identity.glsl +6 -0
- vispy/glsl/transforms/identity_forward.glsl +23 -0
- vispy/glsl/transforms/identity_inverse.glsl +23 -0
- vispy/glsl/transforms/linear-scale.glsl +127 -0
- vispy/glsl/transforms/log-scale.glsl +126 -0
- vispy/glsl/transforms/mercator-transverse-forward.glsl +40 -0
- vispy/glsl/transforms/mercator-transverse-inverse.glsl +40 -0
- vispy/glsl/transforms/panzoom.glsl +10 -0
- vispy/glsl/transforms/polar.glsl +41 -0
- vispy/glsl/transforms/position.glsl +44 -0
- vispy/glsl/transforms/power-scale.glsl +139 -0
- vispy/glsl/transforms/projection.glsl +7 -0
- vispy/glsl/transforms/pvm.glsl +13 -0
- vispy/glsl/transforms/rotate.glsl +45 -0
- vispy/glsl/transforms/trackball.glsl +15 -0
- vispy/glsl/transforms/translate.glsl +35 -0
- vispy/glsl/transforms/transverse_mercator.glsl +38 -0
- vispy/glsl/transforms/viewport-clipping.glsl +14 -0
- vispy/glsl/transforms/viewport-transform.glsl +16 -0
- vispy/glsl/transforms/viewport.glsl +50 -0
- vispy/glsl/transforms/x.glsl +24 -0
- vispy/glsl/transforms/y.glsl +19 -0
- vispy/glsl/transforms/z.glsl +14 -0
- vispy/io/__init__.py +20 -0
- vispy/io/_data/spatial-filters.npy +0 -0
- vispy/io/datasets.py +94 -0
- vispy/io/image.py +231 -0
- vispy/io/mesh.py +122 -0
- vispy/io/stl.py +167 -0
- vispy/io/tests/__init__.py +0 -0
- vispy/io/tests/test_image.py +47 -0
- vispy/io/tests/test_io.py +121 -0
- vispy/io/wavefront.py +350 -0
- vispy/plot/__init__.py +36 -0
- vispy/plot/fig.py +58 -0
- vispy/plot/plotwidget.py +522 -0
- vispy/plot/tests/__init__.py +0 -0
- vispy/plot/tests/test_plot.py +46 -0
- vispy/scene/__init__.py +43 -0
- vispy/scene/cameras/__init__.py +27 -0
- vispy/scene/cameras/_base.py +38 -0
- vispy/scene/cameras/arcball.py +105 -0
- vispy/scene/cameras/base_camera.py +551 -0
- vispy/scene/cameras/fly.py +474 -0
- vispy/scene/cameras/magnify.py +163 -0
- vispy/scene/cameras/panzoom.py +311 -0
- vispy/scene/cameras/perspective.py +338 -0
- vispy/scene/cameras/tests/__init__.py +0 -0
- vispy/scene/cameras/tests/test_cameras.py +27 -0
- vispy/scene/cameras/tests/test_link.py +53 -0
- vispy/scene/cameras/tests/test_perspective.py +122 -0
- vispy/scene/cameras/turntable.py +183 -0
- vispy/scene/canvas.py +639 -0
- vispy/scene/events.py +85 -0
- vispy/scene/node.py +644 -0
- vispy/scene/subscene.py +20 -0
- vispy/scene/tests/__init__.py +0 -0
- vispy/scene/tests/test_canvas.py +119 -0
- vispy/scene/tests/test_node.py +142 -0
- vispy/scene/tests/test_visuals.py +141 -0
- vispy/scene/visuals.py +276 -0
- vispy/scene/widgets/__init__.py +18 -0
- vispy/scene/widgets/anchor.py +25 -0
- vispy/scene/widgets/axis.py +88 -0
- vispy/scene/widgets/colorbar.py +176 -0
- vispy/scene/widgets/console.py +351 -0
- vispy/scene/widgets/grid.py +509 -0
- vispy/scene/widgets/label.py +50 -0
- vispy/scene/widgets/tests/__init__.py +0 -0
- vispy/scene/widgets/tests/test_colorbar.py +47 -0
- vispy/scene/widgets/viewbox.py +199 -0
- vispy/scene/widgets/widget.py +478 -0
- vispy/testing/__init__.py +51 -0
- vispy/testing/_runners.py +448 -0
- vispy/testing/_testing.py +416 -0
- vispy/testing/image_tester.py +494 -0
- vispy/testing/rendered_array_tester.py +85 -0
- vispy/testing/tests/__init__.py +0 -0
- vispy/testing/tests/test_testing.py +20 -0
- vispy/util/__init__.py +32 -0
- vispy/util/bunch.py +15 -0
- vispy/util/check_environment.py +57 -0
- vispy/util/config.py +490 -0
- vispy/util/dpi/__init__.py +19 -0
- vispy/util/dpi/_linux.py +69 -0
- vispy/util/dpi/_quartz.py +26 -0
- vispy/util/dpi/_win32.py +34 -0
- vispy/util/dpi/tests/__init__.py +0 -0
- vispy/util/dpi/tests/test_dpi.py +16 -0
- vispy/util/eq.py +41 -0
- vispy/util/event.py +774 -0
- vispy/util/fetching.py +276 -0
- vispy/util/filter.py +44 -0
- vispy/util/fonts/__init__.py +14 -0
- vispy/util/fonts/_freetype.py +73 -0
- vispy/util/fonts/_quartz.py +192 -0
- vispy/util/fonts/_triage.py +36 -0
- vispy/util/fonts/_vispy_fonts.py +20 -0
- vispy/util/fonts/_win32.py +105 -0
- vispy/util/fonts/data/OpenSans-Bold.ttf +0 -0
- vispy/util/fonts/data/OpenSans-BoldItalic.ttf +0 -0
- vispy/util/fonts/data/OpenSans-Italic.ttf +0 -0
- vispy/util/fonts/data/OpenSans-Regular.ttf +0 -0
- vispy/util/fonts/tests/__init__.py +0 -0
- vispy/util/fonts/tests/test_font.py +45 -0
- vispy/util/fourier.py +69 -0
- vispy/util/frozen.py +25 -0
- vispy/util/gallery_scraper.py +268 -0
- vispy/util/keys.py +91 -0
- vispy/util/logs.py +358 -0
- vispy/util/osmesa_gl.py +17 -0
- vispy/util/profiler.py +135 -0
- vispy/util/ptime.py +16 -0
- vispy/util/quaternion.py +229 -0
- vispy/util/svg/__init__.py +18 -0
- vispy/util/svg/base.py +20 -0
- vispy/util/svg/color.py +219 -0
- vispy/util/svg/element.py +51 -0
- vispy/util/svg/geometry.py +478 -0
- vispy/util/svg/group.py +66 -0
- vispy/util/svg/length.py +81 -0
- vispy/util/svg/number.py +25 -0
- vispy/util/svg/path.py +332 -0
- vispy/util/svg/shapes.py +57 -0
- vispy/util/svg/style.py +59 -0
- vispy/util/svg/svg.py +40 -0
- vispy/util/svg/transform.py +223 -0
- vispy/util/svg/transformable.py +28 -0
- vispy/util/svg/viewport.py +73 -0
- vispy/util/tests/__init__.py +0 -0
- vispy/util/tests/test_config.py +58 -0
- vispy/util/tests/test_docstring_parameters.py +123 -0
- vispy/util/tests/test_emitter_group.py +262 -0
- vispy/util/tests/test_event_emitter.py +743 -0
- vispy/util/tests/test_fourier.py +35 -0
- vispy/util/tests/test_gallery_scraper.py +112 -0
- vispy/util/tests/test_import.py +127 -0
- vispy/util/tests/test_key.py +22 -0
- vispy/util/tests/test_logging.py +45 -0
- vispy/util/tests/test_run.py +14 -0
- vispy/util/tests/test_transforms.py +42 -0
- vispy/util/tests/test_vispy.py +48 -0
- vispy/util/transforms.py +201 -0
- vispy/util/wrappers.py +155 -0
- vispy/version.py +21 -0
- vispy/visuals/__init__.py +50 -0
- vispy/visuals/_scalable_textures.py +487 -0
- vispy/visuals/axis.py +678 -0
- vispy/visuals/border.py +208 -0
- vispy/visuals/box.py +79 -0
- vispy/visuals/collections/__init__.py +30 -0
- vispy/visuals/collections/agg_fast_path_collection.py +219 -0
- vispy/visuals/collections/agg_path_collection.py +197 -0
- vispy/visuals/collections/agg_point_collection.py +52 -0
- vispy/visuals/collections/agg_segment_collection.py +142 -0
- vispy/visuals/collections/array_list.py +401 -0
- vispy/visuals/collections/base_collection.py +482 -0
- vispy/visuals/collections/collection.py +253 -0
- vispy/visuals/collections/path_collection.py +23 -0
- vispy/visuals/collections/point_collection.py +19 -0
- vispy/visuals/collections/polygon_collection.py +25 -0
- vispy/visuals/collections/raw_path_collection.py +119 -0
- vispy/visuals/collections/raw_point_collection.py +113 -0
- vispy/visuals/collections/raw_polygon_collection.py +77 -0
- vispy/visuals/collections/raw_segment_collection.py +112 -0
- vispy/visuals/collections/raw_triangle_collection.py +78 -0
- vispy/visuals/collections/segment_collection.py +19 -0
- vispy/visuals/collections/triangle_collection.py +16 -0
- vispy/visuals/collections/util.py +168 -0
- vispy/visuals/colorbar.py +699 -0
- vispy/visuals/cube.py +41 -0
- vispy/visuals/ellipse.py +162 -0
- vispy/visuals/filters/__init__.py +10 -0
- vispy/visuals/filters/base_filter.py +242 -0
- vispy/visuals/filters/clipper.py +60 -0
- vispy/visuals/filters/clipping_planes.py +122 -0
- vispy/visuals/filters/color.py +181 -0
- vispy/visuals/filters/markers.py +28 -0
- vispy/visuals/filters/mesh.py +801 -0
- vispy/visuals/filters/picking.py +60 -0
- vispy/visuals/filters/tests/__init__.py +3 -0
- vispy/visuals/filters/tests/test_primitive_picking_filters.py +70 -0
- vispy/visuals/filters/tests/test_wireframe_filter.py +16 -0
- vispy/visuals/glsl/__init__.py +1 -0
- vispy/visuals/glsl/antialiasing.py +133 -0
- vispy/visuals/glsl/color.py +63 -0
- vispy/visuals/graphs/__init__.py +1 -0
- vispy/visuals/graphs/graph.py +240 -0
- vispy/visuals/graphs/layouts/__init__.py +55 -0
- vispy/visuals/graphs/layouts/circular.py +49 -0
- vispy/visuals/graphs/layouts/force_directed.py +211 -0
- vispy/visuals/graphs/layouts/networkx_layout.py +87 -0
- vispy/visuals/graphs/layouts/random.py +52 -0
- vispy/visuals/graphs/tests/__init__.py +1 -0
- vispy/visuals/graphs/tests/test_layouts.py +139 -0
- vispy/visuals/graphs/tests/test_networkx_layout.py +47 -0
- vispy/visuals/graphs/util.py +120 -0
- vispy/visuals/gridlines.py +161 -0
- vispy/visuals/gridmesh.py +98 -0
- vispy/visuals/histogram.py +58 -0
- vispy/visuals/image.py +701 -0
- vispy/visuals/image_complex.py +130 -0
- vispy/visuals/infinite_line.py +199 -0
- vispy/visuals/instanced_mesh.py +152 -0
- vispy/visuals/isocurve.py +213 -0
- vispy/visuals/isoline.py +241 -0
- vispy/visuals/isosurface.py +113 -0
- vispy/visuals/line/__init__.py +6 -0
- vispy/visuals/line/arrow.py +289 -0
- vispy/visuals/line/dash_atlas.py +90 -0
- vispy/visuals/line/line.py +545 -0
- vispy/visuals/line_plot.py +135 -0
- vispy/visuals/linear_region.py +199 -0
- vispy/visuals/markers.py +819 -0
- vispy/visuals/mesh.py +373 -0
- vispy/visuals/mesh_normals.py +159 -0
- vispy/visuals/plane.py +54 -0
- vispy/visuals/polygon.py +145 -0
- vispy/visuals/rectangle.py +196 -0
- vispy/visuals/regular_polygon.py +56 -0
- vispy/visuals/scrolling_lines.py +197 -0
- vispy/visuals/shaders/__init__.py +17 -0
- vispy/visuals/shaders/compiler.py +206 -0
- vispy/visuals/shaders/expression.py +99 -0
- vispy/visuals/shaders/function.py +788 -0
- vispy/visuals/shaders/multiprogram.py +145 -0
- vispy/visuals/shaders/parsing.py +140 -0
- vispy/visuals/shaders/program.py +161 -0
- vispy/visuals/shaders/shader_object.py +162 -0
- vispy/visuals/shaders/tests/__init__.py +0 -0
- vispy/visuals/shaders/tests/test_function.py +486 -0
- vispy/visuals/shaders/tests/test_multiprogram.py +78 -0
- vispy/visuals/shaders/tests/test_parsing.py +57 -0
- vispy/visuals/shaders/variable.py +272 -0
- vispy/visuals/spectrogram.py +169 -0
- vispy/visuals/sphere.py +80 -0
- vispy/visuals/surface_plot.py +192 -0
- vispy/visuals/tests/__init__.py +0 -0
- vispy/visuals/tests/test_arrows.py +109 -0
- vispy/visuals/tests/test_axis.py +120 -0
- vispy/visuals/tests/test_collections.py +15 -0
- vispy/visuals/tests/test_colorbar.py +179 -0
- vispy/visuals/tests/test_colormap.py +97 -0
- vispy/visuals/tests/test_ellipse.py +122 -0
- vispy/visuals/tests/test_gridlines.py +30 -0
- vispy/visuals/tests/test_histogram.py +24 -0
- vispy/visuals/tests/test_image.py +392 -0
- vispy/visuals/tests/test_image_complex.py +36 -0
- vispy/visuals/tests/test_infinite_line.py +53 -0
- vispy/visuals/tests/test_instanced_mesh.py +50 -0
- vispy/visuals/tests/test_isosurface.py +22 -0
- vispy/visuals/tests/test_linear_region.py +152 -0
- vispy/visuals/tests/test_markers.py +54 -0
- vispy/visuals/tests/test_mesh.py +261 -0
- vispy/visuals/tests/test_mesh_normals.py +218 -0
- vispy/visuals/tests/test_polygon.py +112 -0
- vispy/visuals/tests/test_rectangle.py +163 -0
- vispy/visuals/tests/test_regular_polygon.py +111 -0
- vispy/visuals/tests/test_scalable_textures.py +196 -0
- vispy/visuals/tests/test_sdf.py +73 -0
- vispy/visuals/tests/test_spectrogram.py +42 -0
- vispy/visuals/tests/test_surface_plot.py +57 -0
- vispy/visuals/tests/test_text.py +95 -0
- vispy/visuals/tests/test_volume.py +542 -0
- vispy/visuals/tests/test_windbarb.py +33 -0
- vispy/visuals/text/__init__.py +7 -0
- vispy/visuals/text/_sdf_cpu.cpython-312-darwin.so +0 -0
- vispy/visuals/text/_sdf_cpu.pyx +112 -0
- vispy/visuals/text/_sdf_gpu.py +316 -0
- vispy/visuals/text/text.py +675 -0
- vispy/visuals/transforms/__init__.py +34 -0
- vispy/visuals/transforms/_util.py +191 -0
- vispy/visuals/transforms/base_transform.py +233 -0
- vispy/visuals/transforms/chain.py +300 -0
- vispy/visuals/transforms/interactive.py +98 -0
- vispy/visuals/transforms/linear.py +564 -0
- vispy/visuals/transforms/nonlinear.py +398 -0
- vispy/visuals/transforms/tests/__init__.py +0 -0
- vispy/visuals/transforms/tests/test_transforms.py +243 -0
- vispy/visuals/transforms/transform_system.py +339 -0
- vispy/visuals/tube.py +173 -0
- vispy/visuals/visual.py +923 -0
- vispy/visuals/volume.py +1366 -0
- vispy/visuals/windbarb.py +291 -0
- vispy/visuals/xyz_axis.py +34 -0
- vispy-0.15.0.dist-info/METADATA +243 -0
- vispy-0.15.0.dist-info/RECORD +521 -0
- vispy-0.15.0.dist-info/WHEEL +6 -0
- vispy-0.15.0.dist-info/licenses/LICENSE.txt +36 -0
- vispy-0.15.0.dist-info/top_level.txt +1 -0
vispy/visuals/isoline.py
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (c) Vispy Development Team. All Rights Reserved.
|
|
3
|
+
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
|
|
4
|
+
|
|
5
|
+
from __future__ import division
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from .line import LineVisual
|
|
10
|
+
from ..color import ColorArray
|
|
11
|
+
from ..color.colormap import _normalize, get_colormap
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def iso_mesh_line(vertices, tris, vertex_data, levels):
|
|
15
|
+
"""Generate an isocurve from vertex data in a surface mesh.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
vertices : ndarray, shape (Nv, 3)
|
|
20
|
+
Vertex coordinates.
|
|
21
|
+
tris : ndarray, shape (Nf, 3)
|
|
22
|
+
Indices of triangular element into the vertices array.
|
|
23
|
+
vertex_data : ndarray, shape (Nv,)
|
|
24
|
+
data at vertex.
|
|
25
|
+
levels : ndarray, shape (Nl,)
|
|
26
|
+
Levels at which to generate an isocurve
|
|
27
|
+
|
|
28
|
+
Returns
|
|
29
|
+
-------
|
|
30
|
+
lines : ndarray, shape (Nvout, 3)
|
|
31
|
+
Vertex coordinates for lines points
|
|
32
|
+
connects : ndarray, shape (Ne, 2)
|
|
33
|
+
Indices of line element into the vertex array.
|
|
34
|
+
vertex_level: ndarray, shape (Nvout,)
|
|
35
|
+
level for vertex in lines
|
|
36
|
+
|
|
37
|
+
Notes
|
|
38
|
+
-----
|
|
39
|
+
Uses a marching squares algorithm to generate the isolines.
|
|
40
|
+
"""
|
|
41
|
+
lines = None
|
|
42
|
+
connects = None
|
|
43
|
+
vertex_level = None
|
|
44
|
+
level_index = None
|
|
45
|
+
if not all([isinstance(x, np.ndarray) for x in (vertices, tris,
|
|
46
|
+
vertex_data, levels)]):
|
|
47
|
+
raise ValueError('all inputs must be numpy arrays')
|
|
48
|
+
if vertices.shape[1] <= 3:
|
|
49
|
+
verts = vertices
|
|
50
|
+
elif vertices.shape[1] == 4:
|
|
51
|
+
verts = vertices[:, :-1]
|
|
52
|
+
else:
|
|
53
|
+
verts = None
|
|
54
|
+
if (verts is not None and tris.shape[1] == 3 and
|
|
55
|
+
vertex_data.shape[0] == verts.shape[0]):
|
|
56
|
+
edges = np.vstack((tris.reshape((-1)),
|
|
57
|
+
np.roll(tris, -1, axis=1).reshape((-1)))).T
|
|
58
|
+
edge_datas = vertex_data[edges]
|
|
59
|
+
edge_coors = verts[edges].reshape(tris.shape[0]*3, 2, 3)
|
|
60
|
+
for lev in levels:
|
|
61
|
+
# index for select edges with vertices have only False - True
|
|
62
|
+
# or True - False at extremity
|
|
63
|
+
index = (edge_datas >= lev)
|
|
64
|
+
index = index[:, 0] ^ index[:, 1] # xor calculation
|
|
65
|
+
# Selectect edge
|
|
66
|
+
edge_datas_Ok = edge_datas[index, :]
|
|
67
|
+
xyz = edge_coors[index]
|
|
68
|
+
# Linear interpolation
|
|
69
|
+
ratio = np.array([(lev - edge_datas_Ok[:, 0]) /
|
|
70
|
+
(edge_datas_Ok[:, 1] - edge_datas_Ok[:, 0])])
|
|
71
|
+
point = xyz[:, 0, :] + ratio.T * (xyz[:, 1, :] - xyz[:, 0, :])
|
|
72
|
+
nbr = point.shape[0]//2
|
|
73
|
+
if connects is not None:
|
|
74
|
+
connect = np.arange(0, nbr*2).reshape((nbr, 2)) + \
|
|
75
|
+
len(lines)
|
|
76
|
+
connects = np.append(connects, connect, axis=0)
|
|
77
|
+
lines = np.append(lines, point, axis=0)
|
|
78
|
+
vertex_level = np.append(vertex_level,
|
|
79
|
+
np.zeros(len(point)) +
|
|
80
|
+
lev)
|
|
81
|
+
level_index = np.append(level_index, np.array(len(point)))
|
|
82
|
+
else:
|
|
83
|
+
lines = point
|
|
84
|
+
connects = np.arange(0, nbr*2).reshape((nbr, 2))
|
|
85
|
+
vertex_level = np.zeros(len(point)) + lev
|
|
86
|
+
level_index = np.array(len(point))
|
|
87
|
+
|
|
88
|
+
vertex_level = vertex_level.reshape((vertex_level.size, 1))
|
|
89
|
+
|
|
90
|
+
return lines, connects, vertex_level, level_index
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class IsolineVisual(LineVisual):
|
|
94
|
+
"""Isocurves of a tri mesh with data at vertices at different levels.
|
|
95
|
+
|
|
96
|
+
Parameters
|
|
97
|
+
----------
|
|
98
|
+
vertices : ndarray, shape (Nv, 3) | None
|
|
99
|
+
Vertex coordinates.
|
|
100
|
+
tris : ndarray, shape (Nf, 3) | None
|
|
101
|
+
Indices into the vertex array.
|
|
102
|
+
data : ndarray, shape (Nv,) | None
|
|
103
|
+
scalar at vertices
|
|
104
|
+
levels : ndarray, shape (Nlev,) | None
|
|
105
|
+
The levels at which the isocurve is constructed from "data".
|
|
106
|
+
color_lev : Color, tuple, colormap name or array
|
|
107
|
+
The color to use when drawing the line. If an array is given, it
|
|
108
|
+
must be of shape (Nlev, 4) and provide one rgba color by level.
|
|
109
|
+
**kwargs : dict
|
|
110
|
+
Keyword arguments to pass to `LineVisual`.
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
def __init__(self, vertices=None, tris=None, data=None,
|
|
114
|
+
levels=None, color_lev=None, **kwargs):
|
|
115
|
+
self._data = None
|
|
116
|
+
self._vertices = None
|
|
117
|
+
self._tris = None
|
|
118
|
+
self._levels = levels
|
|
119
|
+
self._color_lev = color_lev
|
|
120
|
+
self._need_color_update = True
|
|
121
|
+
self._need_recompute = True
|
|
122
|
+
self._v = None
|
|
123
|
+
self._c = None
|
|
124
|
+
self._vl = None
|
|
125
|
+
self._li = None
|
|
126
|
+
self._lc = None
|
|
127
|
+
self._cl = None
|
|
128
|
+
self._update_color_lev = False
|
|
129
|
+
kwargs['antialias'] = False
|
|
130
|
+
LineVisual.__init__(self, method='gl', **kwargs)
|
|
131
|
+
self.set_data(vertices=vertices, tris=tris, data=data)
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def levels(self):
|
|
135
|
+
"""The threshold at which the isocurves are constructed from the data."""
|
|
136
|
+
return self._levels
|
|
137
|
+
|
|
138
|
+
@levels.setter
|
|
139
|
+
def levels(self, levels):
|
|
140
|
+
self._levels = levels
|
|
141
|
+
self._need_recompute = True
|
|
142
|
+
self.update()
|
|
143
|
+
|
|
144
|
+
@property
|
|
145
|
+
def data(self):
|
|
146
|
+
"""The mesh data"""
|
|
147
|
+
return self._vertices, self._tris, self._data
|
|
148
|
+
|
|
149
|
+
def set_data(self, vertices=None, tris=None, data=None):
|
|
150
|
+
"""Set the data
|
|
151
|
+
|
|
152
|
+
Parameters
|
|
153
|
+
----------
|
|
154
|
+
vertices : ndarray, shape (Nv, 3) | None
|
|
155
|
+
Vertex coordinates.
|
|
156
|
+
tris : ndarray, shape (Nf, 3) | None
|
|
157
|
+
Indices into the vertex array.
|
|
158
|
+
data : ndarray, shape (Nv,) | None
|
|
159
|
+
scalar at vertices
|
|
160
|
+
"""
|
|
161
|
+
# modifier pour tenier compte des None self._recompute = True
|
|
162
|
+
if data is not None:
|
|
163
|
+
self._data = data
|
|
164
|
+
self._need_recompute = True
|
|
165
|
+
if vertices is not None:
|
|
166
|
+
self._vertices = vertices
|
|
167
|
+
self._need_recompute = True
|
|
168
|
+
if tris is not None:
|
|
169
|
+
self._tris = tris
|
|
170
|
+
self._need_recompute = True
|
|
171
|
+
self.update()
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def color(self):
|
|
175
|
+
return self._color_lev
|
|
176
|
+
|
|
177
|
+
def set_color(self, color):
|
|
178
|
+
"""Set the color
|
|
179
|
+
|
|
180
|
+
Parameters
|
|
181
|
+
----------
|
|
182
|
+
color : instance of Color
|
|
183
|
+
The color to use.
|
|
184
|
+
"""
|
|
185
|
+
if color is not None:
|
|
186
|
+
self._color_lev = color
|
|
187
|
+
self._need_color_update = True
|
|
188
|
+
self.update()
|
|
189
|
+
|
|
190
|
+
def _levels_to_colors(self):
|
|
191
|
+
# computes ColorArrays for given levels
|
|
192
|
+
# try _color_lev as colormap, except as everything else
|
|
193
|
+
try:
|
|
194
|
+
f_color_levs = get_colormap(self._color_lev)
|
|
195
|
+
except (KeyError, TypeError):
|
|
196
|
+
colors = ColorArray(self._color_lev).rgba
|
|
197
|
+
else:
|
|
198
|
+
lev = _normalize(self._levels, self._levels.min(),
|
|
199
|
+
self._levels.max())
|
|
200
|
+
# map function expects (Nlev,1)!
|
|
201
|
+
colors = f_color_levs.map(lev[:, np.newaxis])
|
|
202
|
+
|
|
203
|
+
if len(colors) == 1:
|
|
204
|
+
colors = colors * np.ones((len(self._levels), 1))
|
|
205
|
+
|
|
206
|
+
# detect color/level mismatch and raise error
|
|
207
|
+
if (len(colors) != len(self._levels)):
|
|
208
|
+
raise TypeError("Color/level mismatch. Color must be of shape "
|
|
209
|
+
"(Nlev, ...) and provide one color per level")
|
|
210
|
+
|
|
211
|
+
self._lc = colors
|
|
212
|
+
|
|
213
|
+
def _compute_iso_color(self):
|
|
214
|
+
"""Compute LineVisual color from level index and corresponding level color"""
|
|
215
|
+
level_color = []
|
|
216
|
+
colors = self._lc
|
|
217
|
+
for i, index in enumerate(self._li):
|
|
218
|
+
level_color.append(np.zeros((index, 4)) + colors[i])
|
|
219
|
+
self._cl = np.vstack(level_color)
|
|
220
|
+
|
|
221
|
+
def _prepare_draw(self, view):
|
|
222
|
+
if (self._data is None or self._levels is None or self._tris is None or
|
|
223
|
+
self._vertices is None or self._color_lev is None):
|
|
224
|
+
return False
|
|
225
|
+
|
|
226
|
+
if self._need_recompute:
|
|
227
|
+
self._v, self._c, self._vl, self._li = iso_mesh_line(
|
|
228
|
+
self._vertices, self._tris, self._data, self._levels)
|
|
229
|
+
self._levels_to_colors()
|
|
230
|
+
self._compute_iso_color()
|
|
231
|
+
LineVisual.set_data(self, pos=self._v, connect=self._c,
|
|
232
|
+
color=self._cl)
|
|
233
|
+
self._need_recompute = False
|
|
234
|
+
|
|
235
|
+
if self._need_color_update:
|
|
236
|
+
self._levels_to_colors()
|
|
237
|
+
self._compute_iso_color()
|
|
238
|
+
LineVisual.set_data(self, color=self._cl)
|
|
239
|
+
self._update_color_lev = False
|
|
240
|
+
|
|
241
|
+
return LineVisual._prepare_draw(self, view)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (c) Vispy Development Team. All Rights Reserved.
|
|
3
|
+
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
|
|
4
|
+
|
|
5
|
+
from __future__ import division
|
|
6
|
+
|
|
7
|
+
from .mesh import MeshVisual
|
|
8
|
+
from ..geometry.isosurface import isosurface
|
|
9
|
+
from ..color import Color
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class IsosurfaceVisual(MeshVisual):
|
|
13
|
+
"""Displays an isosurface of a 3D scalar array.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
data : ndarray | None
|
|
18
|
+
3D scalar array.
|
|
19
|
+
level: float | None
|
|
20
|
+
The level at which the isosurface is constructed from *data*.
|
|
21
|
+
vertex_colors : ndarray | None
|
|
22
|
+
The vertex colors to use.
|
|
23
|
+
face_colors : ndarray | None
|
|
24
|
+
The face colors to use.
|
|
25
|
+
color : ndarray | None
|
|
26
|
+
The color to use.
|
|
27
|
+
**kwargs : dict
|
|
28
|
+
Keyword arguments to pass to the mesh construction.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, data=None, level=None, vertex_colors=None,
|
|
32
|
+
face_colors=None, color=(0.5, 0.5, 1, 1), **kwargs):
|
|
33
|
+
self._data = None
|
|
34
|
+
self._level = level
|
|
35
|
+
self._vertex_colors = vertex_colors
|
|
36
|
+
self._face_colors = face_colors
|
|
37
|
+
self._color = Color(color)
|
|
38
|
+
|
|
39
|
+
# We distinguish between recomputing and just changing the visual
|
|
40
|
+
# properties - in the latter case we don't recompute the faces.
|
|
41
|
+
self._vertices_cache = None
|
|
42
|
+
self._faces_cache = None
|
|
43
|
+
self._recompute = True
|
|
44
|
+
self._update_meshvisual = True
|
|
45
|
+
|
|
46
|
+
MeshVisual.__init__(self, **kwargs)
|
|
47
|
+
if data is not None:
|
|
48
|
+
self.set_data(data, vertex_colors=vertex_colors,
|
|
49
|
+
face_colors=face_colors, color=color)
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def level(self):
|
|
53
|
+
"""The threshold at which the isosurface is constructed from the 3D data."""
|
|
54
|
+
return self._level
|
|
55
|
+
|
|
56
|
+
@level.setter
|
|
57
|
+
def level(self, level):
|
|
58
|
+
self._level = level
|
|
59
|
+
self._recompute = True
|
|
60
|
+
self.update()
|
|
61
|
+
|
|
62
|
+
def set_data(self, data=None, vertex_colors=None, face_colors=None,
|
|
63
|
+
color=None):
|
|
64
|
+
"""Set the scalar array data
|
|
65
|
+
|
|
66
|
+
Parameters
|
|
67
|
+
----------
|
|
68
|
+
data : ndarray
|
|
69
|
+
A 3D array of scalar values. The isosurface is constructed to show
|
|
70
|
+
all locations in the scalar field equal to ``self.level``.
|
|
71
|
+
vertex_colors : array-like | None
|
|
72
|
+
Colors to use for each vertex.
|
|
73
|
+
face_colors : array-like | None
|
|
74
|
+
Colors to use for each face.
|
|
75
|
+
color : instance of Color
|
|
76
|
+
The color to use.
|
|
77
|
+
"""
|
|
78
|
+
# We only change the internal variables if they are provided
|
|
79
|
+
if data is not None:
|
|
80
|
+
self._data = data
|
|
81
|
+
self._recompute = True
|
|
82
|
+
if vertex_colors is not None:
|
|
83
|
+
self._vertex_colors = vertex_colors
|
|
84
|
+
self._update_meshvisual = True
|
|
85
|
+
if face_colors is not None:
|
|
86
|
+
self._face_colors = face_colors
|
|
87
|
+
self._update_meshvisual = True
|
|
88
|
+
if color is not None:
|
|
89
|
+
self._color = Color(color)
|
|
90
|
+
self._update_meshvisual = True
|
|
91
|
+
self.update()
|
|
92
|
+
|
|
93
|
+
def _prepare_draw(self, view):
|
|
94
|
+
|
|
95
|
+
if self._data is None or self._level is None:
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
if self._recompute:
|
|
99
|
+
self._vertices_cache, self._faces_cache = isosurface(self._data,
|
|
100
|
+
self._level)
|
|
101
|
+
self._recompute = False
|
|
102
|
+
self._update_meshvisual = True
|
|
103
|
+
|
|
104
|
+
if self._update_meshvisual:
|
|
105
|
+
MeshVisual.set_data(self,
|
|
106
|
+
vertices=self._vertices_cache,
|
|
107
|
+
faces=self._faces_cache,
|
|
108
|
+
vertex_colors=self._vertex_colors,
|
|
109
|
+
face_colors=self._face_colors,
|
|
110
|
+
color=self._color)
|
|
111
|
+
self._update_meshvisual = False
|
|
112
|
+
|
|
113
|
+
return MeshVisual._prepare_draw(self, view)
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (c) Vispy Development Team. All Rights Reserved.
|
|
3
|
+
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
|
|
4
|
+
"""
|
|
5
|
+
Arrows are a subclass of line visuals, which adds the ability to put several
|
|
6
|
+
heads on a line.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import division
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
|
|
13
|
+
from ... import glsl, gloo
|
|
14
|
+
from ..transforms._util import as_vec4
|
|
15
|
+
from ..visual import Visual
|
|
16
|
+
from .line import LineVisual
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
ARROW_TYPES = (
|
|
20
|
+
'stealth',
|
|
21
|
+
'curved',
|
|
22
|
+
'angle_30',
|
|
23
|
+
'angle_60',
|
|
24
|
+
'angle_90',
|
|
25
|
+
'triangle_30',
|
|
26
|
+
'triangle_60',
|
|
27
|
+
'triangle_90',
|
|
28
|
+
'inhibitor_round'
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class _ArrowHeadVisual(Visual):
|
|
33
|
+
"""Arrow head visual
|
|
34
|
+
|
|
35
|
+
Several shapes to put on the end of a line. This visual differs from
|
|
36
|
+
MarkersVisual in the sense that this visual calculates the orientation of
|
|
37
|
+
the visual on the GPU, by calculating the tangent of the line between two
|
|
38
|
+
given vertices.
|
|
39
|
+
|
|
40
|
+
This is not really a visual you would use on your own,
|
|
41
|
+
use :class:`ArrowVisual` instead.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
parent : ArrowVisual
|
|
46
|
+
This actual ArrowVisual this arrow head is part of.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
ARROWHEAD_VERTEX_SHADER = glsl.get('arrowheads/arrowheads.vert')
|
|
50
|
+
ARROWHEAD_FRAGMENT_SHADER = glsl.get('arrowheads/arrowheads.frag')
|
|
51
|
+
|
|
52
|
+
_arrow_vtype = np.dtype([
|
|
53
|
+
('v1', np.float32, (4,)),
|
|
54
|
+
('v2', np.float32, (4,)),
|
|
55
|
+
('size', np.float32),
|
|
56
|
+
('color', np.float32, (4,)),
|
|
57
|
+
('linewidth', np.float32)
|
|
58
|
+
])
|
|
59
|
+
|
|
60
|
+
def __init__(self, parent):
|
|
61
|
+
Visual.__init__(self, self.ARROWHEAD_VERTEX_SHADER,
|
|
62
|
+
self.ARROWHEAD_FRAGMENT_SHADER)
|
|
63
|
+
self._parent = parent
|
|
64
|
+
self.set_gl_state(depth_test=False, blend=True,
|
|
65
|
+
blend_func=('src_alpha', 'one_minus_src_alpha'))
|
|
66
|
+
self._draw_mode = 'points'
|
|
67
|
+
|
|
68
|
+
self._arrow_vbo = gloo.VertexBuffer(
|
|
69
|
+
np.array([], dtype=self._arrow_vtype))
|
|
70
|
+
|
|
71
|
+
def _prepare_transforms(self, view):
|
|
72
|
+
xform = view.transforms.get_transform()
|
|
73
|
+
view.view_program.vert['transform'] = xform
|
|
74
|
+
|
|
75
|
+
def _prepare_draw(self, view=None):
|
|
76
|
+
if self._parent._arrows_changed:
|
|
77
|
+
self._prepare_vertex_data()
|
|
78
|
+
self.shared_program.bind(self._arrow_vbo)
|
|
79
|
+
self.shared_program['antialias'] = 1.0
|
|
80
|
+
self.shared_program.frag['arrow_type'] = self._parent.arrow_type
|
|
81
|
+
self.shared_program.frag['fill_type'] = "filled"
|
|
82
|
+
|
|
83
|
+
def _prepare_vertex_data(self):
|
|
84
|
+
arrows = self._parent.arrows
|
|
85
|
+
|
|
86
|
+
if arrows is None or arrows.size == 0:
|
|
87
|
+
self._arrow_vbo = gloo.VertexBuffer(
|
|
88
|
+
np.array([], dtype=self._arrow_vtype))
|
|
89
|
+
return
|
|
90
|
+
|
|
91
|
+
v = np.zeros(len(arrows), dtype=self._arrow_vtype)
|
|
92
|
+
# 2d // 3d v1 v2.
|
|
93
|
+
sh = int(arrows.shape[1] / 2)
|
|
94
|
+
v['v1'] = as_vec4(arrows[:, 0:sh])
|
|
95
|
+
v['v2'] = as_vec4(arrows[:, sh:int(2 * sh)])
|
|
96
|
+
v['size'][:] = self._parent.arrow_size
|
|
97
|
+
color, cmap = self._parent._interpret_color(self._parent.arrow_color)
|
|
98
|
+
v['color'][:] = color
|
|
99
|
+
v['linewidth'][:] = self._parent.width
|
|
100
|
+
self._arrow_vbo = gloo.VertexBuffer(v)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class ArrowVisual(LineVisual):
|
|
104
|
+
"""Arrow visual
|
|
105
|
+
|
|
106
|
+
A special line visual which can also draw optional arrow heads at the
|
|
107
|
+
specified vertices.
|
|
108
|
+
|
|
109
|
+
You add an arrow head by specifying two vertices `v1` and `v2` which
|
|
110
|
+
represent the arrow body. This visual will draw an arrow head using `v2`
|
|
111
|
+
as center point, and the orientation of the arrow head is automatically
|
|
112
|
+
determined by calculating the direction vector between `v1` and `v2`.
|
|
113
|
+
The arrow head can be detached from arrow body.
|
|
114
|
+
|
|
115
|
+
Parameters
|
|
116
|
+
----------
|
|
117
|
+
pos : array
|
|
118
|
+
Array of shape (..., 2) or (..., 3) specifying vertex coordinates
|
|
119
|
+
of arrow body.
|
|
120
|
+
color : Color, tuple, or array
|
|
121
|
+
The color to use when drawing the line. If an array is given, it
|
|
122
|
+
must be of shape (..., 4) and provide one rgba color per vertex.
|
|
123
|
+
Can also be a colormap name, or appropriate `Function`.
|
|
124
|
+
width:
|
|
125
|
+
The width of the line in px. Line widths > 1px are only
|
|
126
|
+
guaranteed to work when using 'agg' method.
|
|
127
|
+
connect : str or array
|
|
128
|
+
Determines which vertices are connected by lines.
|
|
129
|
+
|
|
130
|
+
* "strip" causes the line to be drawn with each vertex
|
|
131
|
+
connected to the next.
|
|
132
|
+
* "segments" causes each pair of vertices to draw an
|
|
133
|
+
independent line segment
|
|
134
|
+
* numpy arrays specify the exact set of segment pairs to
|
|
135
|
+
connect.
|
|
136
|
+
method : str
|
|
137
|
+
Mode to use for drawing.
|
|
138
|
+
|
|
139
|
+
* "agg" uses anti-grain geometry to draw nicely antialiased lines
|
|
140
|
+
with proper joins and endcaps.
|
|
141
|
+
* "gl" uses OpenGL's built-in line rendering. This is much faster,
|
|
142
|
+
but produces much lower-quality results and is not guaranteed to
|
|
143
|
+
obey the requested line width or join/endcap styles.
|
|
144
|
+
antialias : bool
|
|
145
|
+
Enables or disables antialiasing.
|
|
146
|
+
For method='gl', this specifies whether to use GL's line smoothing,
|
|
147
|
+
which may be unavailable or inconsistent on some platforms.
|
|
148
|
+
arrows : array
|
|
149
|
+
A (N, 4) or (N, 6) matrix where each row contains the (x, y) or the
|
|
150
|
+
(x, y, z) coordinates of the first and second vertex of the arrow
|
|
151
|
+
head. Remember that the second vertex is used as center point for
|
|
152
|
+
the arrow head, and the first vertex is only used for determining
|
|
153
|
+
the arrow head orientation.
|
|
154
|
+
arrow_type : string
|
|
155
|
+
Specify the arrow head type, the currently available arrow head types
|
|
156
|
+
are:
|
|
157
|
+
|
|
158
|
+
* stealth
|
|
159
|
+
* curved
|
|
160
|
+
* triangle_30
|
|
161
|
+
* triangle_60
|
|
162
|
+
* triangle_90
|
|
163
|
+
* angle_30
|
|
164
|
+
* angle_60
|
|
165
|
+
* angle_90
|
|
166
|
+
* inhibitor_round
|
|
167
|
+
arrow_size : float
|
|
168
|
+
Specify the arrow size
|
|
169
|
+
arrow_color : Color, tuple, or array
|
|
170
|
+
The arrow head color. If an array is given, it must be of shape
|
|
171
|
+
(..., 4) and provide one rgba color per arrow head. Can also be a
|
|
172
|
+
colormap name, or appropriate `Function`.
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
def __init__(self, pos=None, color=(0.5, 0.5, 0.5, 1), width=1,
|
|
176
|
+
connect='strip', method='gl', antialias=False, arrows=None,
|
|
177
|
+
arrow_type='stealth', arrow_size=None,
|
|
178
|
+
arrow_color=(0.5, 0.5, 0.5, 1)):
|
|
179
|
+
|
|
180
|
+
# Do not use the self._changed dictionary as it gets overwritten by
|
|
181
|
+
# the LineVisual constructor.
|
|
182
|
+
self._arrows_changed = False
|
|
183
|
+
|
|
184
|
+
self._arrow_type = None
|
|
185
|
+
self._arrow_size = None
|
|
186
|
+
self._arrows = None
|
|
187
|
+
|
|
188
|
+
self.arrow_type = arrow_type
|
|
189
|
+
self.arrow_size = arrow_size
|
|
190
|
+
self.arrow_color = arrow_color
|
|
191
|
+
|
|
192
|
+
self.arrow_head = _ArrowHeadVisual(self)
|
|
193
|
+
|
|
194
|
+
# TODO: `LineVisual.__init__` also calls its own `set_data` method,
|
|
195
|
+
# which triggers an *update* event. This results in a redraw. After
|
|
196
|
+
# that we call our own `set_data` method, which triggers another
|
|
197
|
+
# redraw. This should be fixed.
|
|
198
|
+
LineVisual.__init__(self, pos, color, width, connect, method,
|
|
199
|
+
antialias)
|
|
200
|
+
ArrowVisual.set_data(self, arrows=arrows)
|
|
201
|
+
|
|
202
|
+
# Add marker visual for the arrow head
|
|
203
|
+
self.add_subvisual(self.arrow_head)
|
|
204
|
+
|
|
205
|
+
def set_data(self, pos=None, color=None, width=None, connect=None,
|
|
206
|
+
arrows=None):
|
|
207
|
+
"""Set the data used for this visual
|
|
208
|
+
|
|
209
|
+
Parameters
|
|
210
|
+
----------
|
|
211
|
+
pos : array
|
|
212
|
+
Array of shape (..., 2) or (..., 3) specifying vertex coordinates.
|
|
213
|
+
color : Color, tuple, or array
|
|
214
|
+
The color to use when drawing the line. If an array is given, it
|
|
215
|
+
must be of shape (..., 4) and provide one rgba color per vertex.
|
|
216
|
+
Can also be a colormap name, or appropriate `Function`.
|
|
217
|
+
width:
|
|
218
|
+
The width of the line in px. Line widths > 1px are only
|
|
219
|
+
guaranteed to work when using 'agg' method.
|
|
220
|
+
connect : str or array
|
|
221
|
+
Determines which vertices are connected by lines.
|
|
222
|
+
|
|
223
|
+
* "strip" causes the line to be drawn with each vertex
|
|
224
|
+
connected to the next.
|
|
225
|
+
* "segments" causes each pair of vertices to draw an
|
|
226
|
+
independent line segment
|
|
227
|
+
* numpy arrays specify the exact set of segment pairs to
|
|
228
|
+
connect.
|
|
229
|
+
arrows : array
|
|
230
|
+
A (N, 4) or (N, 6) matrix where each row contains the (x, y) or the
|
|
231
|
+
(x, y, z) coordinate of the first and second vertex of the arrow
|
|
232
|
+
body. Remember that the second vertex is used as center point for
|
|
233
|
+
the arrow head, and the first vertex is only used for determining
|
|
234
|
+
the arrow head orientation.
|
|
235
|
+
"""
|
|
236
|
+
if arrows is not None:
|
|
237
|
+
self._arrows = arrows
|
|
238
|
+
self._arrows_changed = True
|
|
239
|
+
|
|
240
|
+
LineVisual.set_data(self, pos, color, width, connect)
|
|
241
|
+
|
|
242
|
+
@property
|
|
243
|
+
def arrow_type(self):
|
|
244
|
+
return self._arrow_type
|
|
245
|
+
|
|
246
|
+
@arrow_type.setter
|
|
247
|
+
def arrow_type(self, value):
|
|
248
|
+
if value not in ARROW_TYPES:
|
|
249
|
+
raise ValueError(
|
|
250
|
+
"Invalid arrow type '{}'. Should be one of {}".format(
|
|
251
|
+
value, ", ".join(ARROW_TYPES)
|
|
252
|
+
)
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
if value == self._arrow_type:
|
|
256
|
+
return
|
|
257
|
+
|
|
258
|
+
self._arrow_type = value
|
|
259
|
+
self._arrows_changed = True
|
|
260
|
+
|
|
261
|
+
@property
|
|
262
|
+
def arrow_size(self):
|
|
263
|
+
return self._arrow_size
|
|
264
|
+
|
|
265
|
+
@arrow_size.setter
|
|
266
|
+
def arrow_size(self, value):
|
|
267
|
+
if value is None:
|
|
268
|
+
self._arrow_size = 5.0
|
|
269
|
+
else:
|
|
270
|
+
if value <= 0.0:
|
|
271
|
+
raise ValueError("Arrow size should be greater than zero.")
|
|
272
|
+
|
|
273
|
+
self._arrow_size = value
|
|
274
|
+
|
|
275
|
+
self._arrows_changed = True
|
|
276
|
+
|
|
277
|
+
@property
|
|
278
|
+
def arrow_color(self):
|
|
279
|
+
return self._arrow_color
|
|
280
|
+
|
|
281
|
+
@arrow_color.setter
|
|
282
|
+
def arrow_color(self, value):
|
|
283
|
+
if value is not None:
|
|
284
|
+
self._arrow_color = value
|
|
285
|
+
self._arrows_changed = True
|
|
286
|
+
|
|
287
|
+
@property
|
|
288
|
+
def arrows(self):
|
|
289
|
+
return self._arrows
|