Skip to content

Commit

Permalink
Release v1.0.0
Browse files Browse the repository at this point in the history
- add detached window mode
- add selecting voxel paint color
- update project requirements
  • Loading branch information
artur-trzesiok authored and skremiec committed Dec 3, 2015
1 parent 5a9eed7 commit cdaf59c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Jupyter notebook extension for K3D visualization library.

* [bower](http://bower.io/#install-bower) (to fetch K3D dependency)
* [pip](https://pypi.python.org/pypi/pip) (to install Python module)
* [jupyter-pip](https://pypi.python.org/pypi/jupyter-pip) (to install Jupyter nbextension)
* [numpy](https://pypi.python.org/pypi/numpy) (for efficient data manipulation)

## Installation

Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "k3d-jupyter",
"version": "0.9.0",
"version": "1.0.0",
"authors": [
"Artur Trzesiok <[email protected]>",
"Sebastian Kremiec <[email protected]>"
],
"description": "Juyter notebook extension for K3D visualization library.",
"license": "GPLv2",
"dependencies": {
"k3d": "~0.12.0",
"k3d": "~1.0.0",
"pako": "~0.2.8"
}
}
10 changes: 8 additions & 2 deletions examples/voxels_edit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
"outputs": [],
"source": [
"from k3d import K3D\n",
"from ipywidgets import interact, IntSlider\n",
"\n",
"width = height = length = 3\n",
"\n",
"color_map = (0xFF0000,) * width * height * length\n",
"color_map = (0xFF0000, 0x00FF00)\n",
"voxels = (1,) * width * height * length\n",
"obj = K3D.voxels(voxels, color_map, width=width, height=height, length=length)\n",
"\n",
"plot = K3D()\n",
"plot = K3D(voxel_paint_color=2)\n",
"plot += obj\n",
"\n",
"@interact(color=IntSlider(value=plot.voxel_paint_color, min=0, max=len(color_map)))\n",
"def color(color):\n",
" plot.voxel_paint_color = color\n",
"\n",
"plot.display()"
]
},
Expand Down
6 changes: 4 additions & 2 deletions k3d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ipywidgets import DOMWidget
from IPython.display import display
from traitlets import Unicode, Bytes, Dict, Bool
from traitlets import Unicode, Bytes, Dict, Bool, Int
from functools import partial
from .factory import Factory
from .objects import Drawable
Expand All @@ -23,8 +23,9 @@ class K3D(DOMWidget, Factory):
camera_auto_fit = Bool(sync=True)
data = Bytes(sync=True)
parameters = Dict(sync=True)
voxel_paint_color = Int(sync=True)

def __init__(self, antialias=False, background_color=0xFFFFFF, camera_auto_fit=True, height=512):
def __init__(self, antialias=False, background_color=0xFFFFFF, camera_auto_fit=True, height=512, voxel_paint_color=0):
super(K3D, self).__init__()
self.on_msg(self.__on_msg)

Expand All @@ -39,6 +40,7 @@ def __init__(self, antialias=False, background_color=0xFFFFFF, camera_auto_fit=T
'backgroundColor': background_color,
'height': height,
}
self.voxel_paint_color = voxel_paint_color

def __add__(self, obj):
assert isinstance(obj, Drawable)
Expand Down
14 changes: 12 additions & 2 deletions k3d_widget/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,36 @@ define(['nbextensions/widgets/widgets/js/widget', 'k3d/providers/k3d.threejs.min

this.model.on('change:camera_auto_fit', this._setCameraAutoFit, this);
this.model.on('change:object', this._onObjectChange, this);
this.model.on('change:voxel_paint_color', this._setVoxelPaintColor, this);
this.model.on('fetchData', this._fetchData, this);
},

_init: function () {
var renderer = new THREE.WebGLRenderer({
antialias: this.parameters.antialias,
});
antialias: this.parameters.antialias,
}),
self = this;

this.K3D = K3D.Core(K3D.Providers.ThreeJS, this.container, {
renderer: renderer
}, function (newInstance) {
self.K3D = newInstance;
});

renderer.setClearColor(this.parameters.backgroundColor);
this._setCameraAutoFit();
this._setVoxelPaintColor();
},

_setCameraAutoFit: function () {
this.K3D.setCameraAutoFit(this.model.get('camera_auto_fit'));
},

_setVoxelPaintColor: function () {
this.K3D.parameters.voxelPaintColor = this.model.get('voxel_paint_color');
console.log(this.K3D.parameters.voxelPaintColor);
},

_onObjectChange: function (model, object) {
if (object.type) {
return this._add(object);
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run(self):
version=version,
packages=['k3d'],
include_package_data=True,
install_requires=['jupyter-pip'],
install_requires=['ipywidgets', 'jupyter-pip', 'numpy'],
cmdclass={
'install': InstallK3D
},
Expand Down

0 comments on commit cdaf59c

Please sign in to comment.