diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-18 20:47:56 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-18 20:47:56 (GMT) |
commit | a6fe85c2e883bda2be9951fa1252fd04706f7b6a (patch) | |
tree | a6d7fc7b5e6295055ece3531fdb7aa3db0dc0494 /apps | |
parent | 98bb92660e542dc1b76b2a4de098c14856637429 (diff) | |
download | uscxml-a6fe85c2e883bda2be9951fa1252fd04706f7b6a.zip uscxml-a6fe85c2e883bda2be9951fa1252fd04706f7b6a.tar.gz uscxml-a6fe85c2e883bda2be9951fa1252fd04706f7b6a.tar.bz2 |
New XPath datamodel tests
Diffstat (limited to 'apps')
-rw-r--r-- | apps/samples/vrml/annotations.js | 72 | ||||
-rw-r--r-- | apps/samples/vrml/viewer.html | 17 | ||||
-rw-r--r-- | apps/samples/vrml/viewer.js | 57 |
3 files changed, 114 insertions, 32 deletions
diff --git a/apps/samples/vrml/annotations.js b/apps/samples/vrml/annotations.js new file mode 100644 index 0000000..f915285 --- /dev/null +++ b/apps/samples/vrml/annotations.js @@ -0,0 +1,72 @@ +function Annotations(element, params) { + + // private attributes + var self = this; + var dojo = require("dojo"); + var domConst = dojo.require('dojo/dom-construct'); + var xhr = dojo.require("dojo/_base/xhr"); + + if (typeof(element) === 'string') { + element = dojo.byId(element); + } + + // private instanceId + if (!Annotations.instances) + Annotations.instances = 0; + var instanceId = Annotations.instances++; + + // public attributes + this.annotations = []; + this.vrmlViewer = params.viewer; + + // establish our dom + element.appendChild(domConst.toDom('\ + <div style="text-align: right"><div class="annotation" /></div><button type="button" class="annotate"></button></div>\ + <div class="messages"></div>\ + ')); + + this.annotationTextElem = dojo.query("div.annotation", element)[0]; + this.annotateButtonElem = dojo.query("button.annotate", element)[0]; + this.messagesElem = dojo.query("div.messages", element)[0]; + + // privileged public methods + this.annotate = function(text) { + var pose = self.vrmlViewer.pose; + var imageURL = self.imageURL; + var annoLink = document.createElement("a"); + annoLink.setAttribute("href", "#"); + var annoText = document.createTextNode(text + "\n"); + annoLink.appendChild(annoText); + annoLink.onclick = function() { + self.vrmlViewer.pose = pose; + self.vrmlViewer.imageURL = imageURL; + self.vrmlViewer.updateScene(); + } + this.messagesElem.appendChild(annoLink); + } + + require(["dijit/form/TextBox"], function(TextBox) { + self.annotationBox = new TextBox({ + name: "Annotation", + style: "width: 70%", + onKeyDown: function(e) { + var code = e.keyCode || e.which; + if( code === 13 ) { + e.preventDefault(); + self.annotate(this.get("value")); + return false; + } + }, + }, self.annotationTextElem); + }); + + require(["dijit/form/Button"], function(Button) { + self.resetButton = new Button({ + label: "Annotate", + onClick: function(){ + self.annotate(self.annotationBox.get("value")); + } + }, self.annotateButtonElem); + }); + +} diff --git a/apps/samples/vrml/viewer.html b/apps/samples/vrml/viewer.html index ea1e7a4..977eeeb 100644 --- a/apps/samples/vrml/viewer.html +++ b/apps/samples/vrml/viewer.html @@ -33,16 +33,25 @@ <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js"></script> <script type="text/javascript" src="viewer.js"></script> + <script type="text/javascript" src="annotations.js"></script> <script type="text/javascript"> require(["dojo/domReady!", "dojo"], function(dom, dojo) { var viewer = new VRMLViewer("scene1"); - }); + var annotations = new Annotations("annotations1", { 'viewer': viewer }); + }); </script> </head> <body class="tundra"> - <div style="width: 600px; height: 400px"> - <div id="scene1"></div> - </div> + <table> + <tr><td> + <div style="width: 600px; height: 600px"> + <div id="scene1"></div> + </div> + </td></tr> + <tr><td> + <div id="annotations1"></div> + </td></tr> + </table> </body> </html> diff --git a/apps/samples/vrml/viewer.js b/apps/samples/vrml/viewer.js index 42edce1..c75aa70 100644 --- a/apps/samples/vrml/viewer.js +++ b/apps/samples/vrml/viewer.js @@ -34,16 +34,17 @@ function VRMLViewer(element, params) { var instanceId = VRMLViewer.instances++; // public attributes - this.pitch = 0; - this.roll = 0; - this.yaw = 0; - this.zoom = 1; - this.x = 0; - this.y = 0; - this.z = 0; - this.width = 640; - this.height = 480; - this.autorotate = false; + this.pose = {}; + this.pose.pitch = 0; + this.pose.roll = 0; + this.pose.yaw = 0; + this.pose.zoom = 1; + this.pose.x = 0; + this.pose.y = 0; + this.pose.z = 0; + this.pose.width = 640; + this.pose.height = 480; + this.pose.autorotate = false; this.serverURL = "http://88.69.49.213:8080/vrml"; this.imageURL; @@ -65,16 +66,16 @@ function VRMLViewer(element, params) { this.updateScene = function() { if (self.imageURL) { self.imgElem.src = self.imageURL + - '?width=' + self.width + - '&height=' + self.height + - '&pitch=' + self.pitch + - '&roll=' + self.roll + - '&yaw=' + self.yaw + - '&x=' + self.x + - '&y=' + self.y + - '&z=' + self.z + - '&zoom=' + self.zoom + - '&autorotate=' + (self.autorotate ? '1' : '0'); + '?width=' + self.pose.width + + '&height=' + self.pose.height + + '&pitch=' + self.pose.pitch + + '&roll=' + self.pose.roll + + '&yaw=' + self.pose.yaw + + '&x=' + self.pose.x + + '&y=' + self.pose.y + + '&z=' + self.pose.z + + '&zoom=' + self.pose.zoom + + '&autorotate=' + (self.pose.autorotate ? '1' : '0'); } } @@ -113,7 +114,7 @@ function VRMLViewer(element, params) { <tr>\ <td valign="top">\ <div style="position: relative; padding: 0px">\ - <img class="model" style="z-index: -1; min-width: ' + self.width + 'px; min-height: ' + self.height + 'px"></img>\ + <img class="model" style="z-index: -1; min-width: ' + self.pose.width + 'px; min-height: ' + self.pose.height + 'px"></img>\ <div style="position: absolute; left: 10px; top: 7%; height: 100%">\ <div class="pitchSlide"></div>\ </div>\ @@ -268,7 +269,7 @@ function VRMLViewer(element, params) { constraints: { places:0 }, style: "width:60px", onChange: function(value){ - self.x = value; + self.pose.x = value; self.updateScene(); } }, self.xSpinnerElem ); @@ -281,7 +282,7 @@ function VRMLViewer(element, params) { constraints: { places:0 }, style: "width:60px", onChange: function(value){ - self.y = value; + self.pose.y = value; self.updateScene(); } }, self.ySpinnerElem ); @@ -294,7 +295,7 @@ function VRMLViewer(element, params) { constraints: { places:0 }, style: "width:60px", onChange: function(value){ - self.z = value; + self.pose.z = value; self.updateScene(); } }, self.zSpinnerElem ); @@ -319,7 +320,7 @@ function VRMLViewer(element, params) { intermediateChanges: false, style: "height: 90%", onChange: function(value){ - self.zoom = Math.ceil(value * 1000) / 1000; + self.pose.zoom = Math.ceil(value * 1000) / 1000; self.updateScene(); } }, self.zoomSlideElem); @@ -351,7 +352,7 @@ function VRMLViewer(element, params) { intermediateChanges: false, style: "height: 90%", onChange: function(value){ - self.pitch = Math.ceil(value * 100) / 100; + self.pose.pitch = Math.ceil(value * 100) / 100; self.updateScene(); } }, self.pitchSlideElem); @@ -366,7 +367,7 @@ function VRMLViewer(element, params) { intermediateChanges: false, style: "width: 90%", onChange: function(value){ - self.roll = Math.ceil(value * 100) / 100; + self.pose.roll = Math.ceil(value * 100) / 100; self.updateScene(); } }, self.rollSlideElem); @@ -381,7 +382,7 @@ function VRMLViewer(element, params) { intermediateChanges: false, style: "width: 90%", onChange: function(value){ - self.yaw = Math.ceil(value * 100) / 100; + self.pose.yaw = Math.ceil(value * 100) / 100; self.updateScene(); } }, self.yawSlideElem); |