Permalink
Browse files

First fully working version of the Dropbox sharing feature.

Also, upgrade to a newer version of XTK.
  • Loading branch information...
Daniel Haehn
Daniel Haehn committed Feb 25, 2013
1 parent bd9ff65 commit 5af0fbbeb26b9d8b4199ac7a009bb88a98a24088
Showing with 877 additions and 337 deletions.
  1. +8 −3 css/viewer.css
  2. +3 −1 index.html
  3. +36 −21 js/jquery.frontpage.js
  4. +4 −0 js/x.rendering.js
  5. +197 −0 js/x.scene.js
  6. +344 −27 js/x.share.js
  7. +285 −285 js/xtk.js
View
@@ -34,11 +34,16 @@
#share {
position: absolute;
- bottom: 10px;
- right: 30%;
+ top: 10px;
+ right: 25%;
+ width: 250px;
font-size: 10px;
cursor: pointer;
- opacity: 0.7;
+ background: rgba(0,0,0,0.3);
+}
+
+#sharemsg {
+ margin-left: 40px;
}
.threeDRenderer {
View
@@ -68,6 +68,7 @@
<script type='text/javascript' src='js/x.controller.js'></script>
<script type='text/javascript' src='js/x.examples.js'></script>
<script type='text/javascript' src='js/x.rendering.js'></script>
+<script type='text/javascript' src='js/x.scene.js'></script>
<script type='text/javascript' src='js/x.share.js'></script>
<script type='text/javascript' src='js/xtk.js'></script>
@@ -435,7 +436,8 @@ <h1>Drop files anywhere...</h1>
</div>
<div id='share'>
- <img src='gfx/dropbox.png'/>
+ <img id='sharelogo' src='gfx/dropbox.png'/>
+ <div id='sharemsg' style='display:none'></div>
</div>
</div>
View
@@ -48,36 +48,51 @@ jQuery(document).ready(function() {
};
- // parse the url for variables which trigger demos immediately
- if (location.href.match(/(\?)(\w*.\w*)*/)) {
+ // from http://stackoverflow.com/a/7826782/1183453
+ var args = document.location.search.substring(1).split('&');
+ argsParsed = {};
+ for (var i=0; i < args.length; i++)
+ {
+ arg = unescape(args[i]);
+
+ if (arg.length == 0) continue;
+
+ if (arg.indexOf('=') == -1)
+ {
+ argsParsed[arg.replace(new RegExp('/$'),'').trim()] = true;
+ }
+ else
+ {
+ kvp = arg.split('=');
+ argsParsed[kvp[0].trim()] = kvp[1].replace(new RegExp('/$'),'').trim();
+ }
+ }
+
+ if ('14yrold' in argsParsed) {
- // this is any file
- var _file = location.href.match(/(\?)(\w*.\w*)*/)[0];
- _file = _file.replace('?', ''); // replace any ?
-
- // only replace the last /
- _file = _file.replace(new RegExp('/$'),'');
-
- if (_file == '14yrold') {
-
- load14yrold();
-
- } else if (_file == 'avf') {
+ load14yrold();
- loadAvf();
+ } else if ('avf' in argsParsed) {
- } else if (_file == '2yrold') {
+ loadAvf();
- load2yrold();
+ } else if ('2yrold' in argsParsed) {
- } else if (_file == 'brainstem') {
+ load2yrold();
- loadBrainstem();
+ } else if ('brainstem' in argsParsed) {
- } else {
+ loadBrainstem();
- loadFile(_file);
+ } else if ('scene' in argsParsed) {
+
+ console.log('Found scene ' + argsParsed['scene']);
+ loadScene(argsParsed['scene']);
+
+ } else {
+ for (var a in argsParsed) {
+ loadFile(a);
}
}
View
@@ -532,6 +532,10 @@ function onTouchEnd(rend,container) {
_touch_ended = Date.now();
+ if (typeof _touch_started == 'undefined') {
+ _touch_started = _touch_ended;
+ }
+
if (_touch_ended - _touch_started < 200) {
var _old_2d_content = eval('_current_' + container + '_content');
View
@@ -0,0 +1,197 @@
+function loadScene(sceneUrl) {
+
+ // grab the JSON scene
+ $.ajax({
+ url: sceneUrl
+ }).done(function(scene) {
+
+ // now switch to the viewer
+ switchToViewer();
+
+ console.log(scene);
+
+ // init renderers
+ initializeRenderers();
+ createData();
+
+ if (scene.volume.file.length > 0) {
+
+ volume = new X.volume();
+ volume.file = scene.volume.file;
+ _data.volume.file = volume.file;
+
+ if (scene.labelmap.file.length > 0) {
+
+ volume.labelmap.file = scene.labelmap.file[0];
+ _data.labelmap.file = volume.labelmap.file;
+
+ if (scene.colortable.file.length > 0) {
+
+ volume.labelmap.colortable.file = scene.colortable.file[0];
+ _data.colortable.file = volume.labelmap.colortable.file;
+
+ }
+
+ }
+
+ ren3d.add(volume);
+
+ }
+
+ if (scene.mesh.file.length > 0) {
+
+ mesh = new X.mesh();
+ mesh.file = scene.mesh.file;
+ _data.mesh.file = mesh.file;
+
+ if (scene.scalars.file.length > 0) {
+
+ mesh.scalars.file = scene.scalars.file[0];
+ _data.scalars.file = mesh.scalars.file;
+
+ }
+
+ ren3d.add(mesh);
+
+ }
+
+ if (scene.fibers.file.length > 0) {
+
+ fibers = new X.fibers();
+ fibers.file = scene.fibers.file;
+ _data.fibers.file = fibers.file;
+ ren3d.add(fibers);
+
+ }
+
+ ren3d.render();
+
+ configurator = function() {
+
+ // restore the cameras
+ ren3d.camera.view = new Float32Array(scene.camera.ren3d);
+ sliceX.camera.view = new Float32Array(scene.camera.sliceX);
+ sliceY.camera.view = new Float32Array(scene.camera.sliceY);
+ sliceZ.camera.view = new Float32Array(scene.camera.sliceZ);
+
+ //
+ // restore the volume settings
+ //
+ if (_data.volume.file.length > 0) {
+
+ volume.indexX = scene.volume.indexX;
+ volume.indexY = scene.volume.indexY;
+ volume.indexZ = scene.volume.indexZ;
+ jQuery("#yellow_slider").slider("option", "value", volume.indexX);
+ jQuery("#red_slider").slider("option", "value", volume.indexY);
+ jQuery("#green_slider").slider("option", "value", volume.indexZ);
+
+ if (scene.volume.volumeRendering) {
+ volume.volumeRendering = true;
+ jQuery('#slicing').removeClass('ui-state-active');
+ jQuery('#volumerendering').addClass('ui-state-active');
+ jQuery('#windowlevel-label').hide();
+ jQuery('#windowlevel-volume').hide();
+ jQuery('#opacity-label').show();
+ jQuery('#opacity-volume').show();
+ }
+
+ volume.lowerThreshold = scene.volume.lowerThreshold;
+ volume.upperThreshold = scene.volume.upperThreshold;
+ jQuery('#threshold-volume').dragslider("option", "values", [volume.lowerThreshold, volume.upperThreshold]);
+
+ volume.windowLow = scene.volume.windowLow;
+ volume.windowHigh = scene.volume.windowHigh;
+ jQuery('#windowlevel-volume').dragslider("option", "values", [volume.windowLow, volume.windowHigh]);
+
+ volume.opacity = scene.volume.opacity;
+ jQuery('#opacity-volume').slider("option", "value", volume.opacity * 100);
+
+ volume.minColor = scene.volume.minColor;
+ var bgColor = ((1 << 24) + (volume.minColor[0] * 255 << 16) +
+ (volume.minColor[1] * 255 << 8) + volume.minColor[2] * 255)
+ .toString(16).substr(1);
+
+ volume.maxColor = scene.volume.maxColor;
+ var fgColor = ((1 << 24) + (volume.maxColor[0] * 255 << 16) +
+ (volume.maxColor[1] * 255 << 8) + volume.maxColor[2] * 255)
+ .toString(16).substr(1);
+
+ jQuery('#bgColorVolume').miniColors("value", bgColor);
+ jQuery('#fgColorVolume').miniColors("value", fgColor);
+
+ }
+
+ // restore the labelmap settings
+ if (_data.labelmap.file.length > 0) {
+ volume.labelmap.visible = scene.labelmap.visible;
+ if (!volume.labelmap.visible) {
+ $('#labelmapvisibility').removeClass('show-icon');
+ $('#labelmapvisibility').addClass('hide-icon');
+ }
+ volume.labelmap.opacity = scene.labelmap.opacity;
+ jQuery('#opacity-labelmap').slider("option", "value", volume.labelmap.opacity * 100);
+ }
+
+ //
+ // restore the mesh settings
+ //
+ if (_data.mesh.file.length > 0) {
+ mesh.visible = scene.mesh.visible;
+ if (!mesh.visible) {
+ $('#meshvisibility').removeClass('show-icon');
+ $('#meshvisibility').addClass('hide-icon');
+ }
+ mesh.opacity = scene.mesh.opacity;
+ jQuery('#opacity-mesh').slider("option", "value", mesh.opacity * 100);
+
+ mesh.color = scene.mesh.color;
+ var meshColor = ((1 << 24) + (mesh.color[0] * 255 << 16) +
+ (mesh.color[1] * 255 << 8) + mesh.color[2] * 255)
+ .toString(16).substr(1);
+ jQuery('#meshColor').miniColors("value", meshColor);
+
+ }
+
+ // restore the scalars settings
+ if (_data.scalars.file.length > 0) {
+ mesh.scalars.lowerThreshold = scene.scalars.lowerThreshold;
+ mesh.scalars.upperThreshold = scene.scalars.upperThreshold;
+ jQuery("#threshold-scalars").dragslider("option", "values",
+ [mesh.scalars.lowerThreshold * 100, mesh.scalars.upperThreshold * 100]);
+
+ mesh.scalars.minColor = scene.scalars.minColor;
+ var scalarsminColor = ((1 << 24) + (mesh.scalars.minColor[0] * 255 << 16) +
+ (mesh.scalars.minColor[1] * 255 << 8) + mesh.scalars.minColor[2] * 255)
+ .toString(16).substr(1);
+ jQuery('#scalarsMinColor').miniColors("value", scalarsminColor);
+
+ mesh.scalars.maxColor = scene.scalars.maxColor;
+ var scalarsmaxColor = ((1 << 24) + (mesh.scalars.maxColor[0] * 255 << 16) +
+ (mesh.scalars.maxColor[1] * 255 << 8) + mesh.scalars.maxColor[2] * 255)
+ .toString(16).substr(1);
+ jQuery('#scalarsMaxColor').miniColors("value", scalarsmaxColor);
+
+ }
+
+ //
+ // restore the fiber settings
+ //
+ if (_data.fibers.file.length > 0) {
+ fibers.visible = scene.fibers.visible;
+ if (!fibers.visible) {
+ $('#fibersvisibility').removeClass('show-icon');
+ $('#fibersvisibility').addClass('hide-icon');
+ }
+
+ fibers.scalars.lowerThreshold = scene.fibers.lowerThreshold;
+ fibers.scalars.upperThreshold = scene.fibers.upperThreshold;
+ jQuery('#threshold-fibers').dragslider("option", "values", [fibers.scalars.lowerThreshold, fibers.scalars.upperThreshold]);
+
+ }
+
+ };
+
+ });
+
+}
Oops, something went wrong.

0 comments on commit 5af0fbb

Please sign in to comment.