示例#1
0
class TextTexture(Texture):
    _view_name = Unicode('TextTextureView').tag(sync=True)
    _model_name = Unicode('TextTextureModel').tag(sync=True)

    fontFace = Unicode('Arial').tag(sync=True)
    size = CInt(12).tag(sync=True)
    color = Color('black').tag(sync=True)
    string = Unicode(sync=True)
    squareTexture = Bool(True).tag(sync=True)
示例#2
0
class Play(_BoundedInt):
    interval = CInt(100).tag(sync=True)

    _view_name = Unicode('PlayView').tag(sync=True)
    _model_name = Unicode('PlayModel').tag(sync=True)
    _view_module = Unicode('jupyter-js-widgets').tag(sync=True)
    _model_module = Unicode('jupyter-js-widgets').tag(sync=True)

    _playing = Bool().tag(sync=True)
示例#3
0
class Play(_BoundedInt):
    """Play/repeat buttons to step through values automatically, and optionally loop.
    """
    interval = CInt(
        100, help="The maximum value for the play control.").tag(sync=True)
    step = CInt(1, help="Increment step").tag(sync=True)

    _view_name = Unicode('PlayView').tag(sync=True)
    _model_name = Unicode('PlayModel').tag(sync=True)

    _playing = Bool(help="Whether the control is currently playing.").tag(
        sync=True)
    _repeat = Bool(
        help="Whether the control will repeat in a continous loop.").tag(
            sync=True)
    show_repeat = Bool(
        True,
        help="Show the repeat toggle button in the widget.").tag(sync=True)
示例#4
0
class TubeGeometry(Geometry):
    _view_name = Unicode('TubeGeometryView').tag(sync=True)
    _model_name = Unicode('TubeGeometryModel').tag(sync=True)

    path = List(vector3()).tag(sync=True)
    segments = CInt(64).tag(sync=True)
    radius = CFloat(1).tag(sync=True)
    radialSegments = CFloat(8).tag(sync=True)
    closed = Bool().tag(sync=True)
示例#5
0
 def __init__(self, **kwargs):
     super(Face3, self).__init__(
         CInt(),  # a - Vertex A index.
         CInt(),  # b - Vertex B index.
         CInt(),  # c - Vertex C index.
         Union(
             [  # normal - (optional) Face normal (Vector3) or array of 3 vertex normals.
                 Vector3(allow_none=True),
                 Tuple((Vector3(), ) * 3),
             ]),
         Union([  # color - (optional) Face color or array of vertex colors.
             Unicode(allow_none=True),
             Tuple((Unicode(), ) * 3),
         ]),
         CInt(
             allow_none=True
         ),  # materialIndex - (optional) which index of an array of materials to associate with the face.
         default_value=(0, 0, 0, None, None, None))
示例#6
0
class Sheet(widgets.DOMWidget):
    """"""
    _view_name = Unicode('SheetView').tag(sync=True)
    _model_name = Unicode('SheetModel').tag(sync=True)
    _view_module = Unicode('ipysheet').tag(sync=True)
    _model_module = Unicode('ipysheet').tag(sync=True)
    _view_module_version = Unicode(semver_range_frontend).tag(sync=True)
    _model_module_version = Unicode(semver_range_frontend).tag(sync=True)
    rows = CInt(3).tag(sync=True)
    columns = CInt(4).tag(sync=True)
    cells = Tuple().tag(sync=True, **widgets.widget_serialization)
    named_cells = Dict(value={},
                       allow_none=False).tag(sync=True,
                                             **widgets.widget_serialization)
    row_headers = Union([Bool(), List(Unicode())],
                        default_value=True).tag(sync=True)
    column_headers = Union([Bool(), List(Unicode())],
                           default_value=True).tag(sync=True)
    stretch_headers = Unicode('all').tag(sync=True)
    column_width = Union([CInt(), List(CInt())],
                         default_value=None,
                         allow_none=True).tag(sync=True)
    column_resizing = Bool(True).tag(sync=True)
    row_resizing = Bool(True).tag(sync=True)

    def __getitem__(self, item):
        '''Gets a previously created cell at row and column

        Example:

        >>> sheet = ipysheet.sheet(rows=10, columns=5)
        >>> cell = ipysheet.cell(2,0, value='hello')
        >>> assert sheet[2,0] is cell
        >>> sheet[2,0].value = 'bonjour'

        '''
        row, column = item
        for cell in self.cells:
            if cell.row_start == row and cell.column_start == column \
               and cell.row_end == row and cell.column_end == column:
                return cell
        raise IndexError(
            'no cell was previously created for (row, index) = (%s, %s)'.
            format(row, column))
示例#7
0
class _BoundedInt(_Int):
    """Base class for widgets that represent an integer bounded from above and below.
    """
    max = CInt(100, help="Max value").tag(sync=True)
    min = CInt(0, help="Min value").tag(sync=True)

    def __init__(self, value=None, min=None, max=None, step=None, **kwargs):
        if value is not None:
            kwargs['value'] = value
        if min is not None:
            kwargs['min'] = min
        if max is not None:
            kwargs['max'] = max
        if step is not None:
            kwargs['step'] = step
        super(_BoundedInt, self).__init__(**kwargs)

    @validate('value')
    def _validate_value(self, proposal):
        """Cap and floor value"""
        value = proposal['value']
        if self.min > value or self.max < value:
            value = min(max(value, self.min), self.max)
        return value

    @validate('min')
    def _validate_min(self, proposal):
        """Enforce min <= value <= max"""
        min = proposal['value']
        if min > self.max:
            raise TraitError('setting min > max')
        if min > self.value:
            self.value = min
        return min

    @validate('max')
    def _validate_max(self, proposal):
        """Enforce min <= value <= max"""
        max = proposal['value']
        if max < self.min:
            raise TraitError('setting max < min')
        if max < self.value:
            self.value = max
        return max
示例#8
0
class _Int(DescriptionWidget, ValueWidget, CoreWidget):
    """Base class for widgets that represent an integer."""
    value = CInt(0, help="Int value").tag(sync=True)
    disabled = Bool(False,
                    help="Enable or disable user changes").tag(sync=True)

    def __init__(self, value=None, **kwargs):
        if value is not None:
            kwargs['value'] = value
        super(_Int, self).__init__(**kwargs)
示例#9
0
class _Int(DOMWidget):
    """Base class used to create widgets that represent an int."""
    value = CInt(0, help="Int value", sync=True)
    disabled = Bool(False, help="Enable or disable user changes", sync=True)
    description = Unicode(help="Description of the value this widget represents", sync=True)

    def __init__(self, value=None, **kwargs):
        if value is not None:
            kwargs['value'] = value
        super(_Int, self).__init__(**kwargs)
示例#10
0
class Renderer(RenderableWidget):
    """Renderer
    """

    _view_name = Unicode('RendererView').tag(sync=True)
    _model_name = Unicode('RendererModel').tag(sync=True)

    width = CInt(200)
    height = CInt(200)
    scene = Instance(Scene).tag(sync=True, **widget_serialization)
    camera = Instance(Camera).tag(sync=True, **widget_serialization)
    controls = List(Instance(Controls)).tag(sync=True, **widget_serialization)
    #effect = Instance(Effect, allow_none=True).tag(sync=True, **widget_serialization)
    background = Color('black', allow_none=True).tag(sync=True)
    background_opacity = Float(1.0, min=0.0, max=1.0).tag(sync=True)

    def __init__(self,
                 scene,
                 camera,
                 controls=None,
                 antialias=False,
                 alpha=False,
                 **kwargs):
        super(Renderer, self).__init__(scene=scene,
                                       camera=camera,
                                       controls=controls or [],
                                       _antialias=antialias,
                                       _alpha=alpha,
                                       **kwargs)
        link((self, 'width'), (self, '_width'))
        link((self, 'height'), (self, '_height'))

    def render(self, scene, camera):
        content = {
            "type": "render",
            "scene": to_json(scene, None),
            "camera": to_json(camera, None)
        }
        self.send(content)

    def freeze(self):
        content = {"type": "freeze"}
        self.send(content)
示例#11
0
class ShapeGeometry(BaseGeometry):
    """ShapeGeometry

    Autogenerated by generate-wrappers.js
    See https://threejs.org/docs/#api/geometries/ShapeGeometry
    """
    def __init__(self, shapes=[], **kwargs):
        kwargs['shapes'] = shapes
        super(ShapeGeometry, self).__init__(**kwargs)

    _model_name = Unicode('ShapeGeometryModel').tag(sync=True)

    shapes = Tuple().tag(sync=True, **widget_serialization)

    curveSegments = CInt(12, allow_none=False).tag(sync=True)

    material = CInt(0, allow_none=False).tag(sync=True)

    type = Unicode("ShapeGeometry", allow_none=False).tag(sync=True)
示例#12
0
class InputNumber(ReactWidget, ValueMixin):
    _model_name = Unicode('InputNumberModel').tag(sync=True)
    auto_focus  = CBool(False, help="auto_focus").tag(sync=True)
    disabled    = CBool(False, help="disabled").tag(sync=True)
    min         = CFloat(help="min value").tag(sync=True)
    max         = CFloat(help="max value").tag(sync=True)
    precision   = CInt(help="precision").tag(sync=True)
    decimal_separator = Unicode('', help="decimal_separator").tag(sync=True)
    size        = Unicode('default', help="size of the widget").tag(sync=True)
    step        = CFloat(1, help="step").tag(sync=True)
class Object3D(ThreeWidget):
    """Object3D

    Autogenerated by generate-wrappers.js
    See https://threejs.org/docs/#api/core/Object3D
    """
    def __init__(self, **kwargs):
        super(Object3D, self).__init__(**kwargs)

    _model_name = Unicode('Object3DModel').tag(sync=True)

    name = Unicode("", allow_none=False).tag(sync=True)

    type = Unicode("Object3D", allow_none=False).tag(sync=True)

    children = Tuple().tag(sync=True, **widget_serialization)

    up = Vector3(default_value=[0, 1, 0]).tag(sync=True)

    position = Vector3(default_value=[0, 0, 0]).tag(sync=True)

    rotation = Euler(default_value=[0, 0, 0, "XYZ"]).tag(sync=True)

    quaternion = Vector4(default_value=[0, 0, 0, 1]).tag(sync=True)

    scale = Vector3(default_value=[1, 1, 1]).tag(sync=True)

    modelViewMatrix = Matrix4(
        default_value=[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]).tag(
            sync=True)

    normalMatrix = Matrix3(default_value=[1, 0, 0, 0, 1, 0, 0, 0, 1]).tag(
        sync=True)

    matrix = Matrix4(
        default_value=[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]).tag(
            sync=True)

    matrixWorld = Matrix4(
        default_value=[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]).tag(
            sync=True)

    matrixAutoUpdate = Bool(True, allow_none=False).tag(sync=True)

    matrixWorldNeedsUpdate = Bool(False, allow_none=False).tag(sync=True)

    visible = Bool(True, allow_none=False).tag(sync=True)

    castShadow = Bool(False, allow_none=False).tag(sync=True)

    receiveShadow = Bool(False, allow_none=False).tag(sync=True)

    frustumCulled = Bool(True, allow_none=False).tag(sync=True)

    renderOrder = CInt(0, allow_none=False).tag(sync=True)
示例#14
0
class _SelectionContainer(Box, CoreWidget):
    """Base class used to display multiple child widgets."""
    _titles = Dict(help="Titles of the pages").tag(sync=True)
    selected_index = CInt(
        help="""The index of the selected page.

        This is either an integer selecting a particular sub-widget,
        or None to have no widgets selected.""",
        allow_none=True
    ).tag(sync=True)

    @validate('selected_index')
    def _validated_index(self, proposal):
        if proposal.value is None or 0 <= proposal.value < len(self.children):
            return proposal.value
        else:
            raise TraitError('Invalid selection: index out of bounds')

    # Public methods
    def set_title(self, index, title):
        """Sets the title of a container page.

        Parameters
        ----------
        index : int
            Index of the container page
        title : unicode
            New title
        """
        # JSON dictionaries have string keys, so we convert index to a string
        index = unicode_type(int(index))
        self._titles[index] = title
        self.send_state('_titles')

    def get_title(self, index):
        """Gets the title of a container pages.

        Parameters
        ----------
        index : int
            Index of the container page
        """
        # JSON dictionaries have string keys, so we convert index to a string
        index = unicode_type(int(index))
        if index in self._titles:
            return self._titles[index]
        else:
            return None

    def _repr_keys(self):
        # We also need to include _titles in repr for reproducibility
        for key in super(_SelectionContainer, self)._repr_keys():
            yield key
        if self._titles:
            yield '_titles'
示例#15
0
class _SelectionContainer(Box, CoreWidget):
    """Base class used to display multiple child widgets."""
    titles = TypedTuple(trait=Unicode(),
                        help="Titles of the pages").tag(sync=True)
    selected_index = CInt(
        help=
        """The index of the selected page. This is either an integer selecting a particular sub-widget, or None to have no widgets selected.""",
        allow_none=True,
        default_value=None).tag(sync=True)

    @validate('selected_index')
    def _validated_index(self, proposal):
        if proposal.value is None or 0 <= proposal.value < len(self.children):
            return proposal.value
        else:
            raise TraitError('Invalid selection: index out of bounds')

    @validate('titles')
    def _validate_titles(self, proposal):
        return tuple(pad(proposal.value, '', len(self.children)))

    @observe('children')
    def _observe_children(self, change):
        if self.selected_index is not None and len(
                change.new) < self.selected_index:
            self.selected_index = None
        if len(self.titles) != len(change.new):
            # Run validation function
            self.titles = tuple(self.titles)

    def set_title(self, index, title):
        """Sets the title of a container page.
        Parameters
        ----------
        index : int
            Index of the container page
        title : unicode
            New title
        """
        titles = list(self.titles)
        # for backwards compatibility with ipywidgets 7.x
        if title is None:
            title = ''
        titles[index] = title
        self.titles = tuple(titles)

    def get_title(self, index):
        """Gets the title of a container page.
        Parameters
        ----------
        index : int
            Index of the container page
        """
        return self.titles[index]
示例#16
0
class Play(_BoundedInt):
    """Play/repeat buttons to step through values automatically, and optionally loop.
    """
    _view_name = Unicode('PlayView').tag(sync=True)
    _model_name = Unicode('PlayModel').tag(sync=True)

    playing = Bool(help="Whether the control is currently playing.").tag(
        sync=True)
    repeat = Bool(
        help="Whether the control will repeat in a continuous loop.").tag(
            sync=True)

    interval = CInt(
        100, help="The time between two animation steps (ms).").tag(sync=True)
    step = CInt(1, help="Increment step").tag(sync=True)
    disabled = Bool(False,
                    help="Enable or disable user changes").tag(sync=True)
    show_repeat = Bool(
        True,
        help="Show the repeat toggle button in the widget.").tag(sync=True)
示例#17
0
class Updater(HasTraits):
    _updated = CInt(sync=True)

    def __init__(self, *args, **kwargs):
        super(Updater, self).__init__(*args, **kwargs)
        if hasattr(self, "book"):
            link((self.book, "_updated"), (self, "_updated"))

    def __updated_changed(self, name=None, old=None, new=None):
        if name != "_updated":
            self._updated = time.time()
class SphereGeometry(BaseGeometry):
    """SphereGeometry

    Autogenerated by generate-wrappers.js
    See https://threejs.org/docs/#api/geometries/SphereGeometry
    """
    def __init__(self,
                 radius=1,
                 widthSegments=8,
                 heightSegments=6,
                 phiStart=0,
                 phiLength=6.283185307179586,
                 thetaStart=0,
                 thetaLength=3.141592653589793,
                 **kwargs):
        kwargs['radius'] = radius
        kwargs['widthSegments'] = widthSegments
        kwargs['heightSegments'] = heightSegments
        kwargs['phiStart'] = phiStart
        kwargs['phiLength'] = phiLength
        kwargs['thetaStart'] = thetaStart
        kwargs['thetaLength'] = thetaLength
        super(SphereGeometry, self).__init__(**kwargs)

    _model_name = Unicode('SphereGeometryModel').tag(sync=True)

    radius = CFloat(1, allow_none=False).tag(sync=True)

    widthSegments = CInt(8, allow_none=False).tag(sync=True)

    heightSegments = CInt(6, allow_none=False).tag(sync=True)

    phiStart = CFloat(0, allow_none=False).tag(sync=True)

    phiLength = CFloat(6.283185307179586, allow_none=False).tag(sync=True)

    thetaStart = CFloat(0, allow_none=False).tag(sync=True)

    thetaLength = CFloat(3.141592653589793, allow_none=False).tag(sync=True)

    type = Unicode("SphereGeometry", allow_none=False).tag(sync=True)
示例#19
0
class _BoundedInt(_Int):
    """Base class used to create widgets that represent an integer that is bounded
    by a minium and maximum.
    """
    step = CInt(1, help="Minimum step to increment the value (ignored by some views)", sync=True)
    max = CInt(100, help="Max value", sync=True)
    min = CInt(0, help="Min value", sync=True)

    def __init__(self, value=None, min=None, max=None, step=None, **kwargs):
        if value is not None:
            kwargs['value'] = value
        if min is not None:
            kwargs['min'] = min
        if max is not None:
            kwargs['max'] = max
        if step is not None:
            kwargs['step'] = step
        
        super(_BoundedInt, self).__init__(**kwargs)

    def _value_validate(self, value, trait):
        """Cap and floor value"""
        if self.min > value or self.max < value:
            value = min(max(value, self.min), self.max)
        return value

    def _min_validate(self, min, trait):
        """Enforce min <= value <= max"""
        if min > self.max:
            raise TraitError("Setting min > max")
        if min > self.value:
            self.value = min
        return min

    def _max_validate(self, max, trait):
        """Enforce min <= value <= max"""
        if max < self.min:
            raise TraitError("setting max < min")
        if max < self.value:
            self.value = max
        return max
示例#20
0
class Title(ReactWidget):
    _model_name = Unicode('TitleModel').tag(sync=True)
    level       = CInt(1, help="level").tag(sync=True)
    copyable    = CBool(False, help="copyable").tag(sync=True)
    delete      = CBool(False, help="delete").tag(sync=True)
    disabled    = CBool(False, help="disabled").tag(sync=True)
    editable    = CBool(False, help="editable").tag(sync=True)
    ellipsis    = CBool(False, help="ellipsis").tag(sync=True)
    mark        = CBool(False, help="mark").tag(sync=True)
    underline   = CBool(False, help="underline").tag(sync=True)
    strong      = CBool(False, help="strong").tag(sync=True)
    type        = Unicode('', help='type').tag(sync=True)
示例#21
0
class IntTextSlider(_BoundedInt):
    """An integer text element  that you can slide for changing its value."""

    format = NumberFormat('d').tag(sync=True)
    step = CInt(1, help="Minimum step to increment the value").tag(sync=True)

    _view_name = Unicode('IntTextSliderView').tag(sync=True)
    _view_module = Unicode(module_name).tag(sync=True)
    _model_name = Unicode('IntTextSliderModel').tag(sync=True)
    _model_module = Unicode(module_name).tag(sync=True)
    _view_module_version = Unicode(module_version).tag(sync=True)
    _model_module_version = Unicode(module_version).tag(sync=True)
示例#22
0
class _Int(LabeledWidget, ValueWidget, CoreWidget):
    """Base class for widgets that represent an integer."""
    value = CInt(0, help="Int value").tag(sync=True)
    disabled = Bool(False, help="Enable or disable user changes").tag(sync=True)

    _model_module = Unicode('jupyter-js-widgets').tag(sync=True)
    _view_module = Unicode('jupyter-js-widgets').tag(sync=True)

    def __init__(self, value=None, **kwargs):
        if value is not None:
            kwargs['value'] = value
        super(_Int, self).__init__(**kwargs)
示例#23
0
class IntText(_Int):
    """Textbox widget that represents an integer."""
    _view_name = Unicode('IntTextView').tag(sync=True)
    _model_name = Unicode('IntTextModel').tag(sync=True)
    disabled = Bool(False,
                    help="Enable or disable user changes").tag(sync=True)
    continuous_update = Bool(
        False,
        help=
        "Update the value as the user types. If False, update on submission, e.g., pressing Enter or navigating away."
    ).tag(sync=True)
    step = CInt(1, help="Minimum step to increment the value").tag(sync=True)
示例#24
0
class SurfaceGeometry(BufferGeometry):
    """
    A regular grid with heights
    """
    z = List(CFloat, [0] * 100)
    width = CInt(10)
    height = CInt(10)
    width_segments = CInt(10)
    height_segments = CInt(10)

    @observe('z', 'width', 'height', 'width_segments', 'height_segments')
    def _update_surface(self, change):
        nx = self.width_segments + 1
        ny = self.height_segments + 1
        x = np.linspace(-self.width / 2, self.width / 2, nx)
        y = np.linspace(-self.height / 2, self.height / 2, ny)
        xx, yy = np.meshgrid(x, y)
        z = np.array(self.z).reshape((nx, ny))

        positions = np.dstack((xx, yy, z)).reshape(nx * ny,
                                                   3).astype(np.float32)

        dx, dy = np.gradient(z, self.width / nx, self.height / ny)
        normals = np.dstack(
            (-dx, -dy, np.ones_like(dx))).reshape(nx * ny,
                                                  3).astype(np.float32)

        vmin = np.min(positions, 0)[:2]
        vrange = np.max(positions, 0)[:2] - vmin
        uvs = ((positions[:, :2] - vmin) / vrange)

        indices = np.array(tuple(grid_indices_gen(nx, ny)),
                           dtype=np.uint16).ravel()

        self.attributes = {
            'position': BufferAttribute(positions),
            'index': BufferAttribute(indices),
            'normal': BufferAttribute(normals),
            'uv': BufferAttribute(uvs),
        }
示例#25
0
class IntSlider(_BoundedInt):
    """Slider widget that represents an integer bounded from above and below.
    """
    _view_name = Unicode('IntSliderView').tag(sync=True)
    _model_name = Unicode('IntSliderModel').tag(sync=True)
    step = CInt(1, help="Minimum step to increment the value").tag(sync=True)
    orientation = CaselessStrEnum(values=['horizontal', 'vertical'],
        default_value='horizontal', help="Vertical or horizontal.").tag(sync=True)
    readout = Bool(True, help="Display the current value of the slider next to it.").tag(sync=True)
    readout_format = Unicode('d', help="Format for the readout").tag(sync=True)
    continuous_update = Bool(True, help="Update the value of the widget as the user is holding the slider.").tag(sync=True)

    style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization)
示例#26
0
class NumDisplay(widgets.DOMWidget):
    _view_name = Unicode('HelloView').tag(sync=True)
    _model_name = Unicode('HelloModel').tag(sync=True)
    _view_module = Unicode('jupyter_skydata').tag(sync=True)
    _model_module = Unicode('jupyter_skydata').tag(sync=True)
    _view_module_version = Unicode('^0.1.0').tag(sync=True)
    _model_module_version = Unicode('^0.1.0').tag(sync=True)
    model = CInt().tag(sync=True)

    def __init__(self, *args, **kwargs):
        super(NumDisplay, self).__init__(**kwargs)
        self.model = args[0]
        args[0].model = self.model
示例#27
0
class _BoundedIntRange(_IntRange):
    max = CInt(100, help="Max value").tag(sync=True)
    min = CInt(0, help="Min value").tag(sync=True)

    def __init__(self, *args, **kwargs):
        min, max = kwargs.get('min', 0), kwargs.get('max', 100)
        if kwargs.get('value', None) is None:
            kwargs['value'] = (0.75 * min + 0.25 * max,
                               0.25 * min + 0.75 * max)
        elif not isinstance(kwargs['value'], tuple):
            try:
                kwargs['value'] = tuple(kwargs['value'])
            except:
                raise TypeError(
                    "A 'range' must be able to be cast to a tuple. The input of type"
                    " {} could not be cast to a tuple".format(
                        type(kwargs['value'])))
        super().__init__(*args, **kwargs)

    @validate('min', 'max')
    def _validate_bounds(self, proposal):
        trait = proposal['trait']
        new = proposal['value']
        if trait.name == 'min' and new > self.max:
            raise TraitError('setting min > max')
        if trait.name == 'max' and new < self.min:
            raise TraitError('setting max < min')
        if trait.name == 'min':
            self.value = (max(new, self.value[0]), max(new, self.value[1]))
        if trait.name == 'max':
            self.value = (min(new, self.value[0]), min(new, self.value[1]))
        return new

    @validate('value')
    def _validate_value(self, proposal):
        lower, upper = super()._validate_value(proposal)
        lower, upper = min(lower, self.max), min(upper, self.max)
        lower, upper = max(lower, self.min), max(upper, self.min)
        return lower, upper
class ParametricGeometry(BaseGeometry):
    """ParametricGeometry

    Autogenerated by generate-wrappers.js
    See https://threejs.org/docs/#api/geometries/ParametricGeometry
    """

    def __init__(self, func, slices=3, stacks=3, **kwargs):
        kwargs['func'] = func
        kwargs['slices'] = slices
        kwargs['stacks'] = stacks
        super(ParametricGeometry, self).__init__(**kwargs)

    _model_name = Unicode('ParametricGeometryModel').tag(sync=True)

    func = Unicode('function(u, v, vec) { }').tag(sync=True)

    slices = CInt(3, allow_none=False).tag(sync=True)

    stacks = CInt(3, allow_none=False).tag(sync=True)

    type = Unicode("ParametricGeometry", allow_none=False).tag(sync=True)
示例#29
0
class _IntRange(_Int):
    value = Tuple(CInt(),
                  CInt(),
                  default_value=(0, 1),
                  help="Tuple of (lower, upper) bounds",
                  sync=True)
    lower = CInt(0, help="Lower bound", sync=False)
    upper = CInt(1, help="Upper bound", sync=False)

    def __init__(self, *pargs, **kwargs):
        value_given = 'value' in kwargs
        lower_given = 'lower' in kwargs
        upper_given = 'upper' in kwargs
        if value_given and (lower_given or upper_given):
            raise ValueError(
                "Cannot specify both 'value' and 'lower'/'upper' for range widget"
            )
        if lower_given != upper_given:
            raise ValueError(
                "Must specify both 'lower' and 'upper' for range widget")

        super(_IntRange, self).__init__(*pargs, **kwargs)

        # ensure the traits match, preferring whichever (if any) was given in kwargs
        if value_given:
            self.lower, self.upper = self.value
        else:
            self.value = (self.lower, self.upper)

        self.on_trait_change(self._validate, ['value', 'upper', 'lower'])

    def _validate(self, name, old, new):
        if name == 'value':
            self.lower, self.upper = min(new), max(new)
        elif name == 'lower':
            self.value = (new, self.value[1])
        elif name == 'upper':
            self.value = (self.value[0], new)
示例#30
0
class DataTexture(Texture):
    """A data-based texture.

    See http://threejs.org/docs/#Reference/Textures/DataTexture.
    """
    _view_name = Unicode('DataTextureView').tag(sync=True)
    _model_name = Unicode('DataTextureModel').tag(sync=True)

    data = List(CInt).tag(sync=True)
    format = Enum([
        'RGBAFormat', 'AlphaFormat', 'RGBFormat', 'LuminanceFormat',
        'LuminanceAlphaFormat'
    ], 'RGBAFormat').tag(sync=True)
    width = CInt(256).tag(sync=True)
    height = CInt(256).tag(sync=True)
    type = Enum([
        'UnsignedByteType', 'ByteType', 'ShortType', 'UnsignedShortType',
        'IntType', 'UnsignedIntType', 'FloatType', 'UnsignedShort4444Type',
        'UnsignedShort5551Type', 'UnsignedShort565Type'
    ], 'UnsignedByteType').tag(sync=True)
    mapping = Enum([
        'UVMapping', 'CubeReflectionMapping', 'CubeRefractionMapping',
        'SphericalReflectionMapping', 'SphericalRefractionMapping'
    ], 'UVMapping').tag(sync=True)
    wrapS = Enum(
        ['ClampToEdgeWrapping', 'RepeatWrapping', 'MirroredRepeatWrapping'],
        'ClampToEdgeWrapping').tag(sync=True)
    wrapT = Enum(
        ['ClampToEdgeWrapping', 'RepeatWrapping', 'MirroredRepeatWrapping'],
        'ClampToEdgeWrapping').tag(sync=True)
    magFilter = Enum(['LinearFilter', 'NearestFilter'],
                     'LinearFilter').tag(sync=True)
    minFilter = Enum([
        'NearestFilter', 'NearestMipMapNearestFilter',
        'NearestMipMapLinearFilter', 'LinearFilter',
        'LinearMipMapNearestFilter'
    ], 'NearestFilter').tag(sync=True)
    anisotropy = CInt(1).tag(sync=True)