def __init__(self, default_value=Undefined, **kwargs): if default_value is Undefined: default_value = self.default_value super(Euler, self).__init__(CFloat(), CFloat(), CFloat(), Enum(self._accepted_orders, self._accepted_orders[0]), default_value=default_value, **kwargs)
class RangeSlider(widgets.DOMWidget): _view_name = Unicode('RangeSliderView', sync=True) _view_module = Unicode('nbextensions/brunel_ext/BrunelWidgets', sync=True) field_label = Unicode('field_label', sync=True) visid = Unicode('visid', sync=True) field_id = Unicode('field_id', sync=True) data_min = CFloat(0, sync=True) data_max = CFloat(10, sync=True) low_value = CFloat(sync=True) high_value = CFloat(sync=True)
class PhongMaterial(BasicMaterial): _view_name = Unicode('PhongMaterialView').tag(sync=True) _model_name = Unicode('PhongMaterialModel').tag(sync=True) emissive = Color('black').tag(sync=True) specular = Color('darkgray').tag(sync=True) shininess = CFloat(30).tag(sync=True) reflectivity = CFloat(1.0).tag(sync=True) refractionRatio = CFloat(0.98).tag(sync=True) combine = Enum(Operations, 'MultiplyOperation').tag(sync=True)
class RingGeometry(Geometry): _view_name = Unicode('RingGeometryView').tag(sync=True) _model_name = Unicode('RingGeometryModel').tag(sync=True) innerRadius = CFloat(1.0).tag(sync=True) outerRadius = CFloat(3.0).tag(sync=True) thetaSegments = CInt(8).tag(sync=True) phiSegments = CInt(8).tag(sync=True) thetaStart = CFloat(0).tag(sync=True) thetaLength = CFloat(pi * 2).tag(sync=True)
class QuantizeScale(Scale): """A quantized scale widget. """ _model_name = Unicode("QuantizeScaleModel").tag(sync=True) domain = Tuple(CFloat(), CFloat(), default_value=(0.0, 1.0)).tag(sync=True) range = VarlenTuple(trait=Any(), default_value=(0.0, 1.0), minlen=2).tag(sync=True)
class CylinderGeometry(Geometry): _view_name = Unicode('CylinderGeometryView').tag(sync=True) _model_name = Unicode('CylinderGeometryModel').tag(sync=True) radiusTop = CFloat(1).tag(sync=True) radiusBottom = CFloat(1).tag(sync=True) height = CFloat(1).tag(sync=True) radiusSegments = CFloat(20).tag(sync=True) heightSegments = CFloat(1).tag(sync=True) openEnded = Bool().tag(sync=True)
class LineDashedMaterial(_LineMaterial): _view_name = Unicode('LineDashedMaterialView').tag(sync=True) _model_name = Unicode('LineDashedMaterialModel').tag(sync=True) color = Color('white').tag(sync=True) linewidth = CFloat(1.0).tag(sync=True) scale = CFloat(1.0).tag(sync=True) dashSize = CFloat(3.0).tag(sync=True) gapSize = CFloat(1.0).tag(sync=True) vertexColors = Enum(['NoColors', 'FaceColors', 'VertexColors'], 'NoColors').tag(sync=True) fog = Bool().tag(sync=True)
class Choropleth(GeoJSON): geo_data = Dict() choro_data = Dict() value_min = CFloat(None, allow_none=True) value_max = CFloat(None, allow_none=True) colormap = Instance(ColorMap) key_on = Unicode('id') @observe('choro_data') def _update_bounds(self, change): self.value_min = min(self.choro_data.items(), key=lambda x: x[1])[1] self.value_max = max(self.choro_data.items(), key=lambda x: x[1])[1] @observe('style', 'style_callback', 'value_min', 'value_max', 'geo_data', 'choro_data', 'colormap') def _update_data(self, change): self.data = self._get_data() @default('colormap') def _default_colormap(self): return linear.OrRd_06 @default('style_callback') def _default_style_callback(self): def compute_style(feature, colormap, choro_data): return dict(fillColor=colormap(choro_data), color='black', weight=0.9) return compute_style def _get_data(self): if not self.geo_data: return {} if self.value_min is None: self.value_min = min(self.choro_data.items(), key=lambda x: x[1])[1] if self.value_max is None: self.value_max = max(self.choro_data.items(), key=lambda x: x[1])[1] colormap = self.colormap.scale(self.value_min, self.value_max) data = copy.deepcopy(self.geo_data) for feature in data['features']: feature['properties']['style'] = self.style_callback( feature, colormap, self.choro_data[feature[self.key_on]]) return data def __init__(self, **kwargs): super(Choropleth, self).__init__(**kwargs) self.data = self._get_data()
class RenderableWidget(DOMWidget): _view_module = Unicode(npm_pkg_name).tag(sync=True) _model_module = Unicode(npm_pkg_name).tag(sync=True) _view_module_version = Unicode(EXTENSION_SPEC_VERSION).tag(sync=True) _model_module_version = Unicode(EXTENSION_SPEC_VERSION).tag(sync=True) # renderer properties _width = CInt(200).tag(sync=True) _height = CInt(200).tag(sync=True) _antialias = Bool(False).tag(sync=True) _alpha = Bool(False).tag(sync=True) autoClear = Bool(True).tag(sync=True) autoClearColor = Bool(True).tag(sync=True) autoClearDepth = Bool(True).tag(sync=True) autoClearStencil = Bool(True).tag(sync=True) clippingPlanes = List(Instance(Plane)).tag(sync=True, **widget_serialization) gammaFactor = CFloat(2.0).tag(sync=True) gammaInput = Bool(False).tag(sync=True) gammaOutput = Bool(False).tag(sync=True) localClippingEnabled = Bool(False).tag(sync=True) maxMorphTargets = CInt(8).tag(sync=True) maxMorphNormals = CInt(4).tag(sync=True) physicallyCorrectLights = Bool(False).tag(sync=True) shadowMap = Instance(WebGLShadowMap, args=(), allow_none=True).tag(sync=True, **widget_serialization) sortObject = Bool(True).tag(sync=True) toneMapping = Enum(ToneMappings, 'LinearToneMapping').tag(sync=True) toneMappingExposure = CFloat(1.0).tag(sync=True) toneMappingWhitePoint = CFloat(1.0).tag(sync=True) clearColor = Unicode('#000000').tag(sync=True) clearOpacity = CFloat(1.0).tag(sync=True) def send_msg(self, message_type, payload=None): if payload is None: payload = {} content = { "type": message_type, "payload": payload } self.send(content=content, buffers=None) def log(self, msg): content = { 'type': 'print', 'msg': msg } self.send(content=content, buffers=None) def freeze(self): content = { "type": "freeze" } self.send(content)
class PhongMaterial(BasicMaterial): _view_name = Unicode('PhongMaterialView', sync=True) ambient = Color('white', sync=True) emissive = Color('black', sync=True) specular = Color('darkgray', sync=True) shininess = CFloat(30, sync=True) reflectivity = CFloat(1.0, sync=True) refractionRatio = CFloat(0.98, sync=True) combine = Enum(['MultiplyOperation', 'MixOperation', 'AddOperation'], 'MultiplyOperation', sync=True)
class Component(_GanyWidgetBase): """A data component widget.""" _model_name = Unicode('ComponentModel').tag(sync=True) name = Unicode().tag(sync=True) array = Union( (Instance(Widget), Array())).tag(sync=True, **component_array_serialization) min = CFloat(allow_none=True, default_value=None) max = CFloat(allow_none=True, default_value=None)
class IsoColor(Effect): """An IsoColor effect to another block.""" _model_name = Unicode('IsoColorModel').tag(sync=True) min = CFloat(0.).tag(sync=True) max = CFloat(0.).tag(sync=True) @property def input_dim(self): """Input dimension.""" return 1
class Slider(ReactWidget, DefaultValueMixin, ValueMixin): _model_name = Unicode('SliderModel').tag(sync=True) allow_clear = CBool(False, help="allow_clear").tag(sync=True) disabled = CBool(False, help="disabled").tag(sync=True) dots = CBool(False, help="dots").tag(sync=True) included = CBool(True, help="included").tag(sync=True) min = CFloat(0, help="min value").tag(sync=True) max = CFloat(100, help="max value").tag(sync=True) range = CBool(False, help="range mode or not").tag(sync=True) step = CFloat(1, help="step").tag(sync=True) vertical = CBool(False, help="vertical").tag(sync=True) tooltip_visible = CBool(False, help="tooltip_visible").tag(sync=True) size = Unicode('default', help="size of the widget").tag(sync=True)
class Popconfirm(ReactWidget): _model_name = Unicode('PopconfirmModel').tag(sync=True) title = Unicode('Title', allow_none=True, help="title").tag(sync=True) arrow_point_at_center = CBool(False, help="arrow_point_at_center").tag(sync=True) auto_adjust_overflow = CBool(True, help="auto_adjust_overflow").tag(sync=True) default_visible = CBool(False, help="default_visible").tag(sync=True) #get_popup_container = Unicode('body', help="get_popup_container").tag(sync=True) mouse_enter_delay = CFloat(0.1, help="mouse_enter_delay").tag(sync=True) mouse_leave_delay = CFloat(0.1, help="mouse_leave_delay").tag(sync=True) overlay_class_name = Unicode('', help="overlay_class_name").tag(sync=True) overlay_style = Dict({}, help="overlay_style").tag(sync=True) placement = Unicode('top', help="placement").tag(sync=True) trigger = Unicode('hover', help="trigger").tag(sync=True)
class FloatLogSlider(_BoundedLogFloat): """ Slider/trackbar of logarithmic floating values with the specified range. Parameters ---------- value : float position of the slider base : float base of the logarithmic scale. Default is 10 min : float minimal position of the slider in log scale, i.e., actual minimum is base ** min max : float maximal position of the slider in log scale, i.e., actual maximum is base ** max step : float step of the trackbar, denotes steps for the exponent, not the actual value description : str name of the slider orientation : {'horizontal', 'vertical'} default is 'horizontal', orientation of the slider readout : {True, False} default is True, display the current value of the slider next to it readout_format : str default is '.3g', specifier for the format function used to represent slider value for human consumption, modeled after Python 3's format specification mini-language (PEP 3101). """ _view_name = Unicode('FloatLogSliderView').tag(sync=True) _model_name = Unicode('FloatLogSliderModel').tag(sync=True) step = CFloat( 0.1, allow_none=True, help="Minimum step in the exponent 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 = NumberFormat('.3g', 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) disabled = Bool(False, help="Enable or disable user changes").tag(sync=True) base = CFloat(10., help="Base for the logarithm").tag(sync=True) style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization)
class IsoSurface(Effect): """An IsoSurface effect to another block.""" _model_name = Unicode('IsoSurfaceModel').tag(sync=True) input = Union((Tuple(trait=Unicode, minlen=2, maxlen=2), Unicode(), CFloat(0.))).tag(sync=True) value = CFloat(0.).tag(sync=True) dynamic = Bool(False).tag(sync=True) @default('input') def _default_input(self): return self.parent.data[0].name
class Threshold(Effect): """An Threshold effect to another block.""" _model_name = Unicode('ThresholdModel').tag(sync=True) min = CFloat(0.).tag(sync=True) max = CFloat(0.).tag(sync=True) dynamic = Bool(False).tag(sync=True) inclusive = Bool(True).tag(sync=True) @property def input_dim(self): """Input dimension.""" return 1
class NumbersInputBase(TagsInput): _model_name = Unicode('NumbersInputBaseModel').tag(sync=True) min = CFloat(default_value=None, allow_none=True).tag(sync=True) max = CFloat(default_value=None, allow_none=True).tag(sync=True) @validate('value') def _validate_numbers(self, proposal): for tag_value in proposal['value']: if self.min is not None and tag_value < self.min: raise TraitError('Tag value {} should be >= {}'.format(tag_value, self.min)) if self.max is not None and tag_value > self.max: raise TraitError('Tag value {} should be <= {}'.format(tag_value, self.max)) return proposal['value']
class IsoColor(Effect): """An IsoColor effect to another block.""" _model_name = Unicode('IsoColorModel').tag(sync=True) input = Union((Tuple(trait=Unicode, minlen=2, maxlen=2), Unicode(), CFloat(0.))).tag(sync=True) min = CFloat(0.).tag(sync=True) max = CFloat(0.).tag(sync=True) @default('input') def _default_input(self): return self.parent.data[0].name
class ColorizableTileLayer(LocalTileLayer): _view_name = Unicode('LeafletColorizableTileLayerView').tag(sync=True) _model_name = Unicode('LeafletColorizableTileLayerModel').tag(sync=True) _view_module = Unicode('jupyter-leaflet-car').tag(sync=True) _model_module = Unicode('jupyter-leaflet-car').tag(sync=True) _view_module_version = Unicode(EXTENSION_VERSION).tag(sync=True) _model_module_version = Unicode(EXTENSION_VERSION).tag(sync=True) colormap = Enum(values=allowed_colormaps, default_value='planck').tag(sync=True, o=True) value_min = CFloat(-500).tag(sync=True, o=True) value_max = CFloat(+500).tag(sync=True, o=True) scale = CFloat(1.0).tag(sync=True, o=True)
class ShaderMaterial(Material): _view_name = Unicode('ShaderMaterialView', sync=True) fragmentShader = Unicode('void main(){ }', sync=True) vertexShader = Unicode('void main(){ }', sync=True) morphTargets = Bool(False, sync=True) lights = Bool(False, sync=True) morphNormals = Bool(False, sync=True) wireframe = Bool(False, sync=True) vertexColors = Enum(['NoColors', 'FaceColors', 'VertexColors'], 'NoColors', sync=True) skinning = Bool(False, sync=True) fog = Bool(False, sync=True) shading = Enum(['SmoothShading', 'FlatShading', 'NoShading'], 'SmoothShading', sync=True) linewidth = CFloat(1.0, sync=True) wireframeLinewidth = CFloat(1.0, sync=True)
class Warp(Effect): """A warp effect to another block.""" _model_name = Unicode('WarpModel').tag(sync=True) offset = Union((Tuple(trait=Unicode, minlen=3, maxlen=3), CFloat(0.)), default_value=0.).tag(sync=True) factor = Union((Tuple(trait=Unicode, minlen=3, maxlen=3), CFloat(0.)), default_value=1.).tag(sync=True) @property def input_dim(self): """Input dimension.""" return 3
class Texture(ThreeWidget): """Texture Autogenerated by generate-wrappers.js See https://threejs.org/docs/#api/textures/Texture """ def __init__(self, **kwargs): super(Texture, self).__init__(**kwargs) _model_name = Unicode('TextureModel').tag(sync=True) name = Unicode("", allow_none=False).tag(sync=True) mapping = Enum(MappingModes, "UVMapping", allow_none=False).tag(sync=True) wrapS = Enum(WrappingModes, "ClampToEdgeWrapping", allow_none=False).tag(sync=True) wrapT = Enum(WrappingModes, "ClampToEdgeWrapping", allow_none=False).tag(sync=True) magFilter = Enum(Filters, "LinearFilter", allow_none=False).tag(sync=True) minFilter = Enum(Filters, "LinearMipMapLinearFilter", allow_none=False).tag(sync=True) format = Enum(PixelFormats, "RGBAFormat", allow_none=False).tag(sync=True) type = Enum(DataTypes, "UnsignedByteType", allow_none=False).tag(sync=True) anisotropy = CFloat(1, allow_none=False).tag(sync=True) repeat = Vector2(default_value=[1, 1]).tag(sync=True) offset = Vector2(default_value=[0, 0]).tag(sync=True) generateMipmaps = Bool(True, allow_none=False).tag(sync=True) premultiplyAlpha = Bool(False, allow_none=False).tag(sync=True) flipY = Bool(True, allow_none=False).tag(sync=True) unpackAlignment = CInt(4, allow_none=False).tag(sync=True) encoding = Enum(TextureEncodings, "LinearEncoding", allow_none=False).tag(sync=True) version = CInt(0, allow_none=False).tag(sync=True) rotation = CFloat(0, allow_none=False).tag(sync=True)
class Popover(ReactWidget): _model_name = Unicode('PopoverModel').tag(sync=True) extra = Instance('ipyantd.core.ReactWidget', allow_none=True).tag(sync=True, **widget_serialization) title = Unicode(help="title").tag(sync=True) arrow_point_at_center = CBool(False, help="arrow_point_at_center").tag(sync=True) auto_adjust_overflow = CBool(True, help="auto_adjust_overflow").tag(sync=True) default_visible = CBool(False, help="default_visible").tag(sync=True) #get_popup_container = Unicode('body', help="get_popup_container").tag(sync=True) mouse_enter_delay = CFloat(0.1, help="mouse_enter_delay").tag(sync=True) mouse_leave_delay = CFloat(0.1, help="mouse_leave_delay").tag(sync=True) overlay_class_name = Unicode('', help="overlay_class_name").tag(sync=True) overlay_style = Dict({}, help="overlay_style").tag(sync=True) placement = Unicode('top', help="placement").tag(sync=True) trigger = Unicode('hover', help="trigger").tag(sync=True)
class WebGLRenderer(RenderableWidget): """WebGLRenderer Author: @abelnation Date: Wed Aug 31 2016 23:46:30 GMT-0700 (PDT) See http://threejs.org/docs/#api/renderers/WebGLRenderer """ _view_name = Unicode('WebGLRendererView').tag(sync=True) _model_name = Unicode('WebGLRendererModel').tag(sync=True) width = CInt(200) height = CInt(200) autoClear = Bool(True).tag(sync=True) autoClearColor = Bool(True).tag(sync=True) clearColor = Unicode('#000000').tag(sync=True) clearOpacity = CFloat(1.0).tag(sync=True) autoClearDepth = Bool(True).tag(sync=True) autoClearStencil = Bool(True).tag(sync=True) sortObject = Bool(True).tag(sync=True) clippingPlanes = List(Instance(Plane)).tag(sync=True, **widget_serialization) localClippingEnabled = Bool(False).tag(sync=True) gammaFactor = CFloat(2.0).tag(sync=True) gammaInput = Bool(False).tag(sync=True) gammaOutput = Bool(False).tag(sync=True) physicallyCorrectLights = Bool(False).tag(sync=True) toneMapping = Enum(ToneMappings, 'LinearToneMapping').tag(sync=True) toneMappingExposure = CFloat(1.0).tag(sync=True) toneMappingWhitePoint = CFloat(1.0).tag(sync=True) maxMorphTargets = CInt(8).tag(sync=True) maxMorphNormals = CInt(4).tag(sync=True) def __init__(self, **kwargs): super(WebGLRenderer, self).__init__(**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)
class Drawer(ReactWidget): _model_name = Unicode('DrawerModel').tag(sync=True) closable = CBool(True, help="visible").tag(sync=True) destroy_on_close = CBool(False, help="destroy_on_close").tag(sync=True) get_container = Unicode('body', help="get_container").tag(sync=True) mask_closable = CBool(True, help="mask_closable").tag(sync=True) mask = CBool(True, help="mask").tag(sync=True) mask_style = Dict(help="mask_style").tag(sync=True) body_style = Dict(help="body_style").tag(sync=True) title = Unicode('Title', help="title").tag(sync=True) visible = CBool(False, help="visible").tag(sync=True) width = CFloat(256, help="width").tag(sync=True) height = CFloat(256, help="height").tag(sync=True) z_index = CInt(1000, help="z_index").tag(sync=True) placement = Unicode('right', help="placement").tag(sync=True)
class Threshold(Effect): """An Threshold effect to another block.""" _model_name = Unicode('ThresholdModel').tag(sync=True) input = Union((Tuple(trait=Unicode, minlen=2, maxlen=2), Unicode(), CFloat(0.))).tag(sync=True) min = CFloat(0.).tag(sync=True) max = CFloat(0.).tag(sync=True) dynamic = Bool(False).tag(sync=True) @default('input') def _default_input(self): return self.parent.data[0].name
class SumPlot(Plot): """A volumetric pure emission projection plot widget.""" _model_name = Unicode('SumPlotModel').tag(sync=True) # Color field with color mapping or constant color color = Instance(ColorValued, allow_none=False).tag(sync=True, **widget_serialization) # Exposure level (color is scaled by 2**exposure) # TODO: Validate in range [-10, 10] exposure = CFloat(0.0).tag(sync=True) def dashboard(self): "Create a combined dashboard for this plot." children, titles = _gather_dashboards(self, ["restrict", "color"]) w = widgets.FloatSlider(value=self.exposure, min=-4, max=+4, description="Exposure") widgets.jslink((w, "value"), (self, "exposure")) children.append(w) titles.append("Exposure") return _make_accordion(children, titles)
class XrayPlot(Plot): """An xray plot widget""" _model_name = Unicode('XrayPlotModel').tag(sync=True) # Density can be a constant or a scalar field with scalar mapping density = Instance(ScalarValued, allow_none=True).tag(sync=True, **widget_serialization) # Extinction rate constant # TODO: Validate positive extinction = CFloat(1.0).tag(sync=True) # Constant color to weight absorption # TODO: To do this properly need some other blend equation setup #color = Color("#ffffff").tag(sync=True) def dashboard(self): "Create a combined dashboard for this plot." names = ["restrict", "density"] children, titles = _gather_dashboards(self, names) w = widgets.FloatSlider(value=self.extinction, min=0, max=5, description="Extinction") widgets.jslink((w, "value"), (self, "extinction")) children.append(w) titles.append("Extinction") # w = widgets.ColorPicker(value=self.color) # widgets.jslink((w, "value"), (self, "color")) # children.append(w) # titles.append("Color") return _make_accordion(children, titles)
class ShaderMaterial(Material): _view_name = Unicode('ShaderMaterialView').tag(sync=True) _model_name = Unicode('ShaderMaterialModel').tag(sync=True) fragmentShader = Unicode('void main(){ }').tag(sync=True) vertexShader = Unicode('void main(){ }').tag(sync=True) morphTargets = Bool().tag(sync=True) lights = Bool().tag(sync=True) morphNormals = Bool().tag(sync=True) wireframe = Bool().tag(sync=True) vertexColors = Enum(Colors, 'NoColors').tag(sync=True) skinning = Bool().tag(sync=True) fog = Bool().tag(sync=True) shading = Enum(Shading, 'SmoothShading').tag(sync=True) linewidth = CFloat(1.0).tag(sync=True) wireframeLinewidth = CFloat(1.0).tag(sync=True)