vispy 0.15.0__cp313-cp313-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/__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.cp313-win_amd64.pyd +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 +5 -0
- vispy-0.15.0.dist-info/licenses/LICENSE.txt +36 -0
- vispy-0.15.0.dist-info/top_level.txt +1 -0
vispy/scene/node.py
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
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 weakref
|
|
8
|
+
from contextlib import contextmanager
|
|
9
|
+
|
|
10
|
+
from ..util.event import Event, EmitterGroup
|
|
11
|
+
from ..visuals.transforms import (NullTransform, BaseTransform,
|
|
12
|
+
ChainTransform, create_transform,
|
|
13
|
+
TransformSystem)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Node(object):
|
|
17
|
+
"""Base class representing an object in a scene.
|
|
18
|
+
|
|
19
|
+
A group of nodes connected through parent-child relationships define a
|
|
20
|
+
scenegraph. Nodes may have any number of children.
|
|
21
|
+
|
|
22
|
+
Each Node defines a ``transform`` property, which describes the position,
|
|
23
|
+
orientation, scale, etc. of the Node relative to its parent. The Node's
|
|
24
|
+
children inherit this property, and then further apply their own
|
|
25
|
+
transformations on top of that.
|
|
26
|
+
|
|
27
|
+
With the ``transform`` property, each Node implicitly defines a "local"
|
|
28
|
+
coordinate system, and the Nodes and edges in the scenegraph can be thought
|
|
29
|
+
of as coordinate systems connected by transformation functions.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
parent : Node
|
|
34
|
+
The parent of the Node.
|
|
35
|
+
name : str
|
|
36
|
+
The name used to identify the node.
|
|
37
|
+
transforms : instance of TransformSystem | None
|
|
38
|
+
The associated transforms.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
# Needed to allow subclasses to repr() themselves before Node.__init__()
|
|
42
|
+
_name = None
|
|
43
|
+
|
|
44
|
+
def __init__(self, parent=None, name=None, transforms=None):
|
|
45
|
+
self.name = name
|
|
46
|
+
self._visible = True
|
|
47
|
+
self._canvas = None
|
|
48
|
+
self._document_node = None
|
|
49
|
+
self._scene_node = None
|
|
50
|
+
self._opacity = 1.0
|
|
51
|
+
self._order = 0
|
|
52
|
+
self._picking = False
|
|
53
|
+
|
|
54
|
+
# clippers inherited from parents
|
|
55
|
+
self._clippers = weakref.WeakKeyDictionary() # {node: clipper}
|
|
56
|
+
|
|
57
|
+
# whether this widget should clip its children
|
|
58
|
+
self._clip_children = False
|
|
59
|
+
self._clipper = None
|
|
60
|
+
|
|
61
|
+
self.transforms = (TransformSystem() if transforms is None else
|
|
62
|
+
transforms)
|
|
63
|
+
|
|
64
|
+
# Add some events to the emitter groups:
|
|
65
|
+
events = ['canvas_change', 'parent_change', 'children_change',
|
|
66
|
+
'transform_change', 'mouse_press', 'mouse_move',
|
|
67
|
+
'mouse_release', 'mouse_wheel', 'key_press', 'key_release',
|
|
68
|
+
'gesture_zoom', 'gesture_rotate']
|
|
69
|
+
# Create event emitter if needed (in subclasses that inherit from
|
|
70
|
+
# Visual, we already have an emitter to share)
|
|
71
|
+
if not hasattr(self, 'events'):
|
|
72
|
+
self.events = EmitterGroup(source=self, auto_connect=True,
|
|
73
|
+
update=Event)
|
|
74
|
+
self.events.add(**dict([(ev, Event) for ev in events]))
|
|
75
|
+
|
|
76
|
+
self._children = []
|
|
77
|
+
self._transform = NullTransform()
|
|
78
|
+
self._parent = None
|
|
79
|
+
if parent is not None:
|
|
80
|
+
self.parent = parent
|
|
81
|
+
|
|
82
|
+
self._document = None
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def visible(self):
|
|
86
|
+
"""Whether this node should be drawn or not. Only applicable to
|
|
87
|
+
nodes that can be drawn.
|
|
88
|
+
"""
|
|
89
|
+
return self._visible
|
|
90
|
+
|
|
91
|
+
@visible.setter
|
|
92
|
+
def visible(self, val):
|
|
93
|
+
self._visible = bool(val)
|
|
94
|
+
self.update()
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def name(self):
|
|
98
|
+
return self._name
|
|
99
|
+
|
|
100
|
+
@name.setter
|
|
101
|
+
def name(self, n):
|
|
102
|
+
self._name = n
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def opacity(self):
|
|
106
|
+
return self._opacity
|
|
107
|
+
|
|
108
|
+
@opacity.setter
|
|
109
|
+
def opacity(self, o):
|
|
110
|
+
self._opacity = o
|
|
111
|
+
self._update_opacity()
|
|
112
|
+
|
|
113
|
+
def _update_opacity(self):
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
def _set_clipper(self, node, clipper):
|
|
117
|
+
"""Assign a clipper that is inherited from a parent node.
|
|
118
|
+
|
|
119
|
+
If *clipper* is None, then remove any clippers for *node*.
|
|
120
|
+
"""
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def clip_children(self):
|
|
125
|
+
"""Boolean indicating whether children of this node will inherit its
|
|
126
|
+
clipper.
|
|
127
|
+
"""
|
|
128
|
+
return self._clip_children
|
|
129
|
+
|
|
130
|
+
@clip_children.setter
|
|
131
|
+
def clip_children(self, clip):
|
|
132
|
+
if self._clip_children == clip:
|
|
133
|
+
return
|
|
134
|
+
self._clip_children = clip
|
|
135
|
+
|
|
136
|
+
for ch in self.children:
|
|
137
|
+
ch._set_clipper(self, self.clipper)
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def clipper(self):
|
|
141
|
+
"""A visual filter that can be used to clip visuals to the boundaries
|
|
142
|
+
of this node.
|
|
143
|
+
"""
|
|
144
|
+
return self._clipper
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def order(self):
|
|
148
|
+
"""A value used to determine the order in which nodes are drawn.
|
|
149
|
+
|
|
150
|
+
Greater values are drawn later. Children are always drawn after their
|
|
151
|
+
parent.
|
|
152
|
+
"""
|
|
153
|
+
return self._order
|
|
154
|
+
|
|
155
|
+
@order.setter
|
|
156
|
+
def order(self, o):
|
|
157
|
+
self._order = o
|
|
158
|
+
self.update()
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def children(self):
|
|
162
|
+
"""A copy of the list of children of this node. Do not add
|
|
163
|
+
items to this list, but use ``x.parent = y`` instead.
|
|
164
|
+
"""
|
|
165
|
+
return list(self._children)
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def parent(self):
|
|
169
|
+
"""The parent of this node in the scenegraph.
|
|
170
|
+
|
|
171
|
+
Nodes inherit coordinate transformations and some filters (opacity and
|
|
172
|
+
clipping by default) from their parents. Setting this property assigns
|
|
173
|
+
a new parent, changing the topology of the scenegraph.
|
|
174
|
+
|
|
175
|
+
May be set to None to remove this node (and its children) from a
|
|
176
|
+
scenegraph.
|
|
177
|
+
"""
|
|
178
|
+
if self._parent is None:
|
|
179
|
+
return None
|
|
180
|
+
else:
|
|
181
|
+
return self._parent()
|
|
182
|
+
|
|
183
|
+
@parent.setter
|
|
184
|
+
def parent(self, parent):
|
|
185
|
+
if not isinstance(parent, (Node, type(None))):
|
|
186
|
+
raise ValueError('Parent must be Node instance or None (got %s).'
|
|
187
|
+
% parent.__class__.__name__)
|
|
188
|
+
prev = self.parent
|
|
189
|
+
if parent is prev:
|
|
190
|
+
return
|
|
191
|
+
if prev is not None:
|
|
192
|
+
prev._remove_child(self)
|
|
193
|
+
# remove all clippers inherited from parents
|
|
194
|
+
for k in list(self._clippers):
|
|
195
|
+
self._set_clipper(k, None)
|
|
196
|
+
if parent is None:
|
|
197
|
+
self._set_canvas(None)
|
|
198
|
+
self._parent = None
|
|
199
|
+
else:
|
|
200
|
+
self._set_canvas(parent.canvas)
|
|
201
|
+
self._parent = weakref.ref(parent)
|
|
202
|
+
parent._add_child(self)
|
|
203
|
+
# inherit clippers from parents
|
|
204
|
+
p = parent
|
|
205
|
+
while p is not None:
|
|
206
|
+
if p.clip_children:
|
|
207
|
+
self._set_clipper(p, p.clipper)
|
|
208
|
+
p = p.parent
|
|
209
|
+
|
|
210
|
+
self.events.parent_change(new=parent, old=prev)
|
|
211
|
+
self._update_trsys(None)
|
|
212
|
+
self.update()
|
|
213
|
+
|
|
214
|
+
def _add_child(self, node):
|
|
215
|
+
self._children.append(node)
|
|
216
|
+
self.events.children_change(added=node)
|
|
217
|
+
node.events.children_change.connect(self.events.children_change)
|
|
218
|
+
self.events.parent_change.connect(node.events.parent_change)
|
|
219
|
+
|
|
220
|
+
def _remove_child(self, node):
|
|
221
|
+
self._children.remove(node)
|
|
222
|
+
self.events.children_change(removed=node)
|
|
223
|
+
node.events.children_change.disconnect(self.events.children_change)
|
|
224
|
+
self.events.parent_change.disconnect(node.events.parent_change)
|
|
225
|
+
|
|
226
|
+
def on_parent_change(self, event):
|
|
227
|
+
"""Parent change event handler
|
|
228
|
+
|
|
229
|
+
Parameters
|
|
230
|
+
----------
|
|
231
|
+
event : instance of Event
|
|
232
|
+
The event.
|
|
233
|
+
"""
|
|
234
|
+
self._scene_node = None
|
|
235
|
+
|
|
236
|
+
def is_child(self, node):
|
|
237
|
+
"""Check if a node is a child of the current node
|
|
238
|
+
|
|
239
|
+
Parameters
|
|
240
|
+
----------
|
|
241
|
+
node : instance of Node
|
|
242
|
+
The potential child.
|
|
243
|
+
|
|
244
|
+
Returns
|
|
245
|
+
-------
|
|
246
|
+
child : bool
|
|
247
|
+
Whether or not the node is a child.
|
|
248
|
+
"""
|
|
249
|
+
if node in self.children:
|
|
250
|
+
return True
|
|
251
|
+
for c in self.children:
|
|
252
|
+
if c.is_child(node):
|
|
253
|
+
return True
|
|
254
|
+
return False
|
|
255
|
+
|
|
256
|
+
@property
|
|
257
|
+
def canvas(self):
|
|
258
|
+
"""The canvas in which this node's scenegraph is being drawn."""
|
|
259
|
+
if self._canvas is None:
|
|
260
|
+
return None
|
|
261
|
+
else:
|
|
262
|
+
return self._canvas()
|
|
263
|
+
|
|
264
|
+
@property
|
|
265
|
+
def document_node(self):
|
|
266
|
+
"""The node to be used as the document coordinate system.
|
|
267
|
+
|
|
268
|
+
By default, the document node is `self.root_node`.
|
|
269
|
+
"""
|
|
270
|
+
if self._document_node is None:
|
|
271
|
+
return self.root_node
|
|
272
|
+
return self._document_node
|
|
273
|
+
|
|
274
|
+
@document_node.setter
|
|
275
|
+
def document_node(self, doc):
|
|
276
|
+
self._document_node = doc
|
|
277
|
+
self._update_transform()
|
|
278
|
+
|
|
279
|
+
@property
|
|
280
|
+
def scene_node(self):
|
|
281
|
+
"""The first ancestor of this node that is a SubScene instance, or self
|
|
282
|
+
if no such node exists.
|
|
283
|
+
"""
|
|
284
|
+
if self._scene_node is None:
|
|
285
|
+
from .subscene import SubScene
|
|
286
|
+
p = self.parent
|
|
287
|
+
while True:
|
|
288
|
+
if isinstance(p, SubScene) or p is None:
|
|
289
|
+
self._scene_node = p and weakref.ref(p)
|
|
290
|
+
break
|
|
291
|
+
p = p.parent
|
|
292
|
+
if self._scene_node is None:
|
|
293
|
+
self._scene_node = weakref.ref(self)
|
|
294
|
+
return self._scene_node()
|
|
295
|
+
|
|
296
|
+
@property
|
|
297
|
+
def root_node(self):
|
|
298
|
+
node = self
|
|
299
|
+
while True:
|
|
300
|
+
p = node.parent
|
|
301
|
+
if p is None:
|
|
302
|
+
return node
|
|
303
|
+
node = p
|
|
304
|
+
|
|
305
|
+
def _set_canvas(self, c):
|
|
306
|
+
old = self.canvas
|
|
307
|
+
if old is c:
|
|
308
|
+
return
|
|
309
|
+
|
|
310
|
+
# Use canvas/framebuffer transforms from canvas
|
|
311
|
+
self.transforms.canvas = c
|
|
312
|
+
if c is None:
|
|
313
|
+
self._canvas = None
|
|
314
|
+
else:
|
|
315
|
+
self._canvas = weakref.ref(c)
|
|
316
|
+
tr = c.transforms
|
|
317
|
+
self.transforms.canvas_transform = tr.canvas_transform
|
|
318
|
+
self.transforms.framebuffer_transform = tr.framebuffer_transform
|
|
319
|
+
|
|
320
|
+
# update all children
|
|
321
|
+
for ch in self.children:
|
|
322
|
+
ch._set_canvas(c)
|
|
323
|
+
|
|
324
|
+
self.events.canvas_change(old=old, new=c)
|
|
325
|
+
|
|
326
|
+
def update(self):
|
|
327
|
+
"""
|
|
328
|
+
Emit an event to inform listeners that properties of this Node have
|
|
329
|
+
changed. Also request a canvas update.
|
|
330
|
+
"""
|
|
331
|
+
self.events.update()
|
|
332
|
+
c = getattr(self, 'canvas', None)
|
|
333
|
+
if c is not None:
|
|
334
|
+
c.update(node=self)
|
|
335
|
+
|
|
336
|
+
@property
|
|
337
|
+
def document(self):
|
|
338
|
+
"""The document is an optional property that is an node representing
|
|
339
|
+
the coordinate system from which this node should make physical
|
|
340
|
+
measurements such as px, mm, pt, in, etc. This coordinate system
|
|
341
|
+
should be used when determining line widths, font sizes, and any
|
|
342
|
+
other lengths specified in physical units.
|
|
343
|
+
|
|
344
|
+
The default is None; in this case, a default document is used during
|
|
345
|
+
drawing (usually this is supplied by the SceneCanvas).
|
|
346
|
+
"""
|
|
347
|
+
return self._document
|
|
348
|
+
|
|
349
|
+
@document.setter
|
|
350
|
+
def document(self, doc):
|
|
351
|
+
if doc is not None and not isinstance(doc, Node):
|
|
352
|
+
raise TypeError("Document property must be Node or None.")
|
|
353
|
+
self._document = doc
|
|
354
|
+
self.update()
|
|
355
|
+
|
|
356
|
+
@property
|
|
357
|
+
def transform(self):
|
|
358
|
+
"""The transform that maps the local coordinate frame to the
|
|
359
|
+
coordinate frame of the parent.
|
|
360
|
+
"""
|
|
361
|
+
return self._transform
|
|
362
|
+
|
|
363
|
+
@transform.setter
|
|
364
|
+
def transform(self, tr):
|
|
365
|
+
# Other nodes might be interested in this information, but turning it
|
|
366
|
+
# on by default is too expensive.
|
|
367
|
+
assert isinstance(tr, BaseTransform)
|
|
368
|
+
if tr is not self._transform:
|
|
369
|
+
self._transform = tr
|
|
370
|
+
self._update_trsys(None)
|
|
371
|
+
|
|
372
|
+
def set_transform(self, type_, *args, **kwargs):
|
|
373
|
+
"""Create a new transform of *type* and assign it to this node.
|
|
374
|
+
|
|
375
|
+
All extra arguments are used in the construction of the transform.
|
|
376
|
+
|
|
377
|
+
Parameters
|
|
378
|
+
----------
|
|
379
|
+
type_ : str
|
|
380
|
+
The transform type.
|
|
381
|
+
*args : tuple
|
|
382
|
+
Arguments.
|
|
383
|
+
**kwargs : dict
|
|
384
|
+
Keywoard arguments.
|
|
385
|
+
"""
|
|
386
|
+
self.transform = create_transform(type_, *args, **kwargs)
|
|
387
|
+
|
|
388
|
+
def _update_trsys(self, event):
|
|
389
|
+
"""Called when has changed.
|
|
390
|
+
|
|
391
|
+
This allows the node and its children to react (notably, VisualNode
|
|
392
|
+
uses this to update its TransformSystem).
|
|
393
|
+
|
|
394
|
+
Note that this method is only called when one transform is replaced by
|
|
395
|
+
another; it is not called if an existing transform internally changes
|
|
396
|
+
its state.
|
|
397
|
+
"""
|
|
398
|
+
for ch in self.children:
|
|
399
|
+
ch._update_trsys(event)
|
|
400
|
+
self.events.transform_change()
|
|
401
|
+
self.update()
|
|
402
|
+
|
|
403
|
+
def parent_chain(self):
|
|
404
|
+
"""
|
|
405
|
+
Return the list of parents starting from this node. The chain ends
|
|
406
|
+
at the first node with no parents.
|
|
407
|
+
"""
|
|
408
|
+
chain = [self]
|
|
409
|
+
while True:
|
|
410
|
+
try:
|
|
411
|
+
parent = chain[-1].parent
|
|
412
|
+
except Exception:
|
|
413
|
+
break
|
|
414
|
+
if parent is None:
|
|
415
|
+
break
|
|
416
|
+
chain.append(parent)
|
|
417
|
+
return chain
|
|
418
|
+
|
|
419
|
+
def describe_tree(self, with_transform=False):
|
|
420
|
+
"""Create tree diagram of children
|
|
421
|
+
|
|
422
|
+
Parameters
|
|
423
|
+
----------
|
|
424
|
+
with_transform : bool
|
|
425
|
+
If true, add information about node transform types.
|
|
426
|
+
|
|
427
|
+
Returns
|
|
428
|
+
-------
|
|
429
|
+
tree : str
|
|
430
|
+
The tree diagram.
|
|
431
|
+
"""
|
|
432
|
+
# inspired by https://github.com/mbr/asciitree/blob/master/asciitree.py
|
|
433
|
+
return self._describe_tree('', with_transform)
|
|
434
|
+
|
|
435
|
+
def _describe_tree(self, prefix, with_transform):
|
|
436
|
+
"""Helper function to actuall construct the tree"""
|
|
437
|
+
extra = ': "%s"' % self.name if self.name is not None else ''
|
|
438
|
+
if with_transform:
|
|
439
|
+
extra += (' [%s]' % self.transform.__class__.__name__)
|
|
440
|
+
output = ''
|
|
441
|
+
if len(prefix) > 0:
|
|
442
|
+
output += prefix[:-3]
|
|
443
|
+
output += ' +--'
|
|
444
|
+
output += '%s%s\n' % (self.__class__.__name__, extra)
|
|
445
|
+
|
|
446
|
+
n_children = len(self.children)
|
|
447
|
+
for ii, child in enumerate(self.children):
|
|
448
|
+
sub_prefix = prefix + (' ' if ii+1 == n_children else ' |')
|
|
449
|
+
output += child._describe_tree(sub_prefix, with_transform)
|
|
450
|
+
return output
|
|
451
|
+
|
|
452
|
+
def common_parent(self, node):
|
|
453
|
+
"""
|
|
454
|
+
Return the common parent of two entities
|
|
455
|
+
|
|
456
|
+
If the entities have no common parent, return None.
|
|
457
|
+
|
|
458
|
+
Parameters
|
|
459
|
+
----------
|
|
460
|
+
node : instance of Node
|
|
461
|
+
The other node.
|
|
462
|
+
|
|
463
|
+
Returns
|
|
464
|
+
-------
|
|
465
|
+
parent : instance of Node | None
|
|
466
|
+
The parent.
|
|
467
|
+
"""
|
|
468
|
+
p1 = self.parent_chain()
|
|
469
|
+
p2 = node.parent_chain()
|
|
470
|
+
for p in p1:
|
|
471
|
+
if p in p2:
|
|
472
|
+
return p
|
|
473
|
+
return None
|
|
474
|
+
|
|
475
|
+
def node_path_to_child(self, node):
|
|
476
|
+
"""Return a list describing the path from this node to a child node
|
|
477
|
+
|
|
478
|
+
If *node* is not a (grand)child of this node, then raise RuntimeError.
|
|
479
|
+
|
|
480
|
+
Parameters
|
|
481
|
+
----------
|
|
482
|
+
node : instance of Node
|
|
483
|
+
The child node.
|
|
484
|
+
|
|
485
|
+
Returns
|
|
486
|
+
-------
|
|
487
|
+
path : list | None
|
|
488
|
+
The path.
|
|
489
|
+
"""
|
|
490
|
+
if node is self:
|
|
491
|
+
return []
|
|
492
|
+
|
|
493
|
+
# Go up from the child node as far as we can
|
|
494
|
+
path1 = [node]
|
|
495
|
+
child = node
|
|
496
|
+
while child.parent is not None:
|
|
497
|
+
child = child.parent
|
|
498
|
+
path1.append(child)
|
|
499
|
+
# Early exit
|
|
500
|
+
if child is self:
|
|
501
|
+
return list(reversed(path1))
|
|
502
|
+
|
|
503
|
+
# Verify that we're not cut off
|
|
504
|
+
if path1[-1].parent is None:
|
|
505
|
+
raise RuntimeError('%r is not a child of %r' % (node, self))
|
|
506
|
+
|
|
507
|
+
def _is_child(path, parent, child):
|
|
508
|
+
path.append(parent)
|
|
509
|
+
if child in parent.children:
|
|
510
|
+
return path
|
|
511
|
+
else:
|
|
512
|
+
for c in parent.children:
|
|
513
|
+
possible_path = _is_child(path[:], c, child)
|
|
514
|
+
if possible_path:
|
|
515
|
+
return possible_path
|
|
516
|
+
return None
|
|
517
|
+
|
|
518
|
+
# Search from the parent towards the child
|
|
519
|
+
path2 = _is_child([], self, path1[-1])
|
|
520
|
+
if not path2:
|
|
521
|
+
raise RuntimeError('%r is not a child of %r' % (node, self))
|
|
522
|
+
|
|
523
|
+
# Return
|
|
524
|
+
return path2 + list(reversed(path1))
|
|
525
|
+
|
|
526
|
+
def node_path(self, node):
|
|
527
|
+
"""Return two lists describing the path from this node to another
|
|
528
|
+
|
|
529
|
+
Parameters
|
|
530
|
+
----------
|
|
531
|
+
node : instance of Node
|
|
532
|
+
The other node.
|
|
533
|
+
|
|
534
|
+
Returns
|
|
535
|
+
-------
|
|
536
|
+
p1 : list
|
|
537
|
+
First path (see below).
|
|
538
|
+
p2 : list
|
|
539
|
+
Second path (see below).
|
|
540
|
+
|
|
541
|
+
Notes
|
|
542
|
+
-----
|
|
543
|
+
The first list starts with this node and ends with the common parent
|
|
544
|
+
between the endpoint nodes. The second list contains the remainder of
|
|
545
|
+
the path from the common parent to the specified ending node.
|
|
546
|
+
|
|
547
|
+
For example, consider the following scenegraph::
|
|
548
|
+
|
|
549
|
+
A --- B --- C --- D
|
|
550
|
+
\
|
|
551
|
+
--- E --- F
|
|
552
|
+
|
|
553
|
+
Calling `D.node_path(F)` will return::
|
|
554
|
+
|
|
555
|
+
([D, C, B], [E, F])
|
|
556
|
+
|
|
557
|
+
"""
|
|
558
|
+
p1 = self.parent_chain()
|
|
559
|
+
p2 = node.parent_chain()
|
|
560
|
+
cp = None
|
|
561
|
+
for p in p1:
|
|
562
|
+
if p in p2:
|
|
563
|
+
cp = p
|
|
564
|
+
break
|
|
565
|
+
if cp is None:
|
|
566
|
+
raise RuntimeError("No single-path common parent between nodes %s "
|
|
567
|
+
"and %s." % (self, node))
|
|
568
|
+
|
|
569
|
+
p1 = p1[:p1.index(cp)+1]
|
|
570
|
+
p2 = p2[:p2.index(cp)][::-1]
|
|
571
|
+
return p1, p2
|
|
572
|
+
|
|
573
|
+
def node_path_transforms(self, node):
|
|
574
|
+
"""Return the list of transforms along the path to another node.
|
|
575
|
+
|
|
576
|
+
The transforms are listed in reverse order, such that the last
|
|
577
|
+
transform should be applied first when mapping from this node to
|
|
578
|
+
the other.
|
|
579
|
+
|
|
580
|
+
Parameters
|
|
581
|
+
----------
|
|
582
|
+
node : instance of Node
|
|
583
|
+
The other node.
|
|
584
|
+
|
|
585
|
+
Returns
|
|
586
|
+
-------
|
|
587
|
+
transforms : list
|
|
588
|
+
A list of Transform instances.
|
|
589
|
+
"""
|
|
590
|
+
a, b = self.node_path(node)
|
|
591
|
+
return ([n.transform for n in a[:-1]] +
|
|
592
|
+
[n.transform.inverse for n in b])[::-1]
|
|
593
|
+
|
|
594
|
+
def node_transform(self, node):
|
|
595
|
+
"""
|
|
596
|
+
Return the transform that maps from the coordinate system of
|
|
597
|
+
*self* to the local coordinate system of *node*.
|
|
598
|
+
|
|
599
|
+
Note that there must be a _single_ path in the scenegraph that connects
|
|
600
|
+
the two entities; otherwise an exception will be raised.
|
|
601
|
+
|
|
602
|
+
Parameters
|
|
603
|
+
----------
|
|
604
|
+
node : instance of Node
|
|
605
|
+
The other node.
|
|
606
|
+
|
|
607
|
+
Returns
|
|
608
|
+
-------
|
|
609
|
+
transform : instance of ChainTransform
|
|
610
|
+
The transform.
|
|
611
|
+
"""
|
|
612
|
+
return ChainTransform(self.node_path_transforms(node))
|
|
613
|
+
|
|
614
|
+
def __repr__(self):
|
|
615
|
+
name = "" if self.name is None else " name="+self.name
|
|
616
|
+
return "<%s%s at 0x%x>" % (self.__class__.__name__, name, id(self))
|
|
617
|
+
|
|
618
|
+
@property
|
|
619
|
+
def picking(self):
|
|
620
|
+
"""Boolean that determines whether this node (and its children) are
|
|
621
|
+
drawn in picking mode.
|
|
622
|
+
"""
|
|
623
|
+
return self._picking
|
|
624
|
+
|
|
625
|
+
@picking.setter
|
|
626
|
+
def picking(self, p):
|
|
627
|
+
for c in self.children:
|
|
628
|
+
c.picking = p
|
|
629
|
+
self._picking = p
|
|
630
|
+
|
|
631
|
+
@contextmanager
|
|
632
|
+
def set_picking(self, *, picking=True):
|
|
633
|
+
"""Context manager to temporarily set picking for this node and its children.
|
|
634
|
+
|
|
635
|
+
Note that this function will not alter the picking mode unless/until
|
|
636
|
+
the context manager is entered (using the `with` statement). Use
|
|
637
|
+
:py:attr:`~.picking` for setting the picking mode directly.
|
|
638
|
+
"""
|
|
639
|
+
old_picking = self.picking
|
|
640
|
+
try:
|
|
641
|
+
self.picking = picking
|
|
642
|
+
yield self.picking
|
|
643
|
+
finally:
|
|
644
|
+
self.picking = old_picking
|
vispy/scene/subscene.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 .node import Node
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SubScene(Node):
|
|
11
|
+
"""A Node subclass that serves as a marker and parent node for certain
|
|
12
|
+
branches of the scenegraph.
|
|
13
|
+
|
|
14
|
+
SubScene nodes are used as the top-level node for the internal scenes of
|
|
15
|
+
a canvas and a view box.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, **kwargs):
|
|
19
|
+
Node.__init__(self, **kwargs)
|
|
20
|
+
self.document = self
|
|
File without changes
|