Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (70 sloc) 2.78 KB
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
# -----------------------------------------------------------------------------
from ..geometry import create_box
from .mesh import MeshVisual
from .visual import CompoundVisual
class BoxVisual(CompoundVisual):
"""Visual that displays a box.
Parameters
----------
width : float
Box width.
height : float
Box height.
depth : float
Box depth.
width_segments : int
Box segments count along the width.
height_segments : float
Box segments count along the height.
depth_segments : float
Box segments count along the depth.
planes: array_like
Any combination of ``{'-x', '+x', '-y', '+y', '-z', '+z'}``
Included planes in the box construction.
vertex_colors : ndarray
Same as for `MeshVisual` class. See `create_plane` for vertex ordering.
face_colors : ndarray
Same as for `MeshVisual` class. See `create_plane` for vertex ordering.
color : Color
The `Color` to use when drawing the cube faces.
edge_color : tuple or Color
The `Color` to use when drawing the cube edges. If `None`, then no
cube edges are drawn.
"""
def __init__(self, width=1, height=1, depth=1, width_segments=1,
height_segments=1, depth_segments=1, planes=None,
vertex_colors=None, face_colors=None,
color=(0.5, 0.5, 1, 1), edge_color=None, **kwargs):
vertices, filled_indices, outline_indices = create_box(
width, height, depth, width_segments, height_segments,
depth_segments, planes)
self._mesh = MeshVisual(vertices['position'], filled_indices,
vertex_colors, face_colors, color)
if edge_color:
self._border = MeshVisual(vertices['position'], outline_indices,
color=edge_color, mode='lines')
else:
self._border = MeshVisual()
CompoundVisual.__init__(self, [self._mesh, self._border], **kwargs)
self.mesh.set_gl_state(polygon_offset_fill=True,
polygon_offset=(1, 1), depth_test=True)
@property
def mesh(self):
"""The vispy.visuals.MeshVisual that used to fill in.
"""
return self._mesh
@mesh.setter
def mesh(self, mesh):
self._mesh = mesh
@property
def border(self):
"""The vispy.visuals.MeshVisual that used to draw the border.
"""
return self._border
@border.setter
def border(self, border):
self._border = border
You can’t perform that action at this time.