|
From: <ma...@us...> - 2012-03-11 16:34:40
|
Revision: 725
http://openautomation.svn.sourceforge.net/openautomation/?rev=725&view=rev
Author: mayerch
Date: 2012-03-11 16:34:34 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
CometVisu:
- Added <layout> to trigger
- made 3D use full space
- added GA to switch floors (also temporary as well as azimut and elevation)
- removed a few timeouts that seemed unnecessary
JSFloorPlan3D:
- added ability to resize canvas
- improved moveToRoom
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/visu_config_2d3d.xml
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -173,7 +173,11 @@
container.append( '<embed src="' + backdrop + '" style="position: absolute; top: 0px; left: 0px;z-index:-1;width:100%;height:100%;"/>' );
} else if( '3d' == type )
{
- container.data( 'JSFloorPlan3D', JSFloorPlan3D( container, backdrop ) );
+ var floorplan = JSFloorPlan3D( container, backdrop );
+ floorplan.moveToRoom( 'Underground', false, true, false );
+ container.data( 'JSFloorPlan3D', floorplan );
+ container.find('canvas').css({position: 'absolute', top: '0px', left: '0px', 'z-index':'-1', width:'100%',height:'100%'});
+ $(window).bind( 'resize', function(){ floorplan.resize($('.page').width(), $('.page').height(), true);} );
if ($p.attr('azimut')) {
ga_list.push($p.attr('azimut'));
address[ '_' + $p.attr('azimut') ] = [ 'DPT:5.001', 0, 'azimut' ];
@@ -183,7 +187,13 @@
ga_list.push($p.attr('elevation'));
address[ '_' + $p.attr('elevation') ] = [ 'DPT:5.001', 0, 'elevation' ];
container.bind( '_' + $p.attr('elevation'), this.update );
- }; container.data( 'address', address );
+ };
+ if ($p.attr('floor')) {
+ ga_list.push($p.attr('floor'));
+ address[ '_' + $p.attr('floor') ] = [ 'DPT:5.004', 0, 'floor' ];
+ container.bind( '_' + $p.attr('floor'), this.update );
+ };
+ container.data( 'address', address );
}
$( childs ).each( function(i){
container.append( create_pages( childs[i], path + '_' + i, flavour ) );
@@ -205,13 +215,14 @@
rowspan: { type: 'numeric', required: false },
backdrop: { type: 'string', required: false },
azimut: { type: 'addr', required: false },
- elevation:{ type: 'addr', required: false }
+ elevation:{ type: 'addr', required: false },
+ floor: { type: 'addr', required: false }
},
elements: {
},
update: function(e, data) {
var element = $(this);
- var value = defaultUpdate( e, data, element );
+ var value = defaultValueHandling( e, data, element );
var type = element.data().address[ e.type ][2];
switch( type )
{
@@ -223,6 +234,10 @@
element.data().JSFloorPlan3D.setState('currentElevation', value, true);
break;
+ case 'floor':
+ element.data().JSFloorPlan3D.moveToRoom( value, false, true, true );
+ break;
+
default:
if (data==01) {
scrollToPage(this.attributes.path.nodeValue);
@@ -745,8 +760,10 @@
this.addCreator('trigger', {
create: function( page, path ) {
var $p = $(page);
+ var layout = $p.find('layout')[0];
+ var style = layout ? 'style="' + extractLayout( layout ) + '"' : '';
var value = $p.attr('value') ? $p.attr('value') : 0;
- var ret_val = $('<div class="widget clearfix switch" />');
+ var ret_val = $('<div class="widget clearfix switch" ' + style + ' />');
ret_val.setWidgetLayout($p);
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
@@ -794,7 +811,8 @@
},
elements: {
label: { type: 'string', required: true, multi: false },
- address: { type: 'address', required: true, multi: true }
+ address: { type: 'address', required: true, multi: true },
+ layout: { type: 'layout', required: false, multi: false }
},
content: false
});
@@ -1237,17 +1255,12 @@
return { x: 0, y: 0 }; // sanity return
}
-function defaultUpdate( e, data, passedElement )
+function defaultValueHandling( e, data, passedElement )
{
var element = passedElement || $(this);
var thisTransform = element.data().address[ e.type ][0];
var value = transformDecode( element.data().address[ e.type ][0], data );
-
- element.setWidgetStyling(value);
- if( element.data( 'align' ) )
- element.addClass(element.data( 'align' ) );
-
element.data( 'basicvalue', value );
if( element.data( 'precision' ) )
value = Number( value ).toPrecision( element.data( 'precision' ) );
@@ -1267,6 +1280,20 @@
break;
}
}
+ return value;
+}
+
+function defaultUpdate( e, data, passedElement )
+{
+// var value = defaultValueHandling( e, data, passedElement )
+ var element = passedElement || $(this);
+ var value = defaultValueHandling( e, data, element );
+
+ element.setWidgetStyling( element.data( 'basicvalue' ) );
+
+ if( element.data( 'align' ) )
+ element.addClass(element.data( 'align' ) );
+
element.find('.value').text( value );
return value;
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -74,7 +74,7 @@
$(document).ready(function() {
// get the data once the page was loaded
$.ajaxSetup({cache: !forceReload});
- window.setTimeout("$.get( 'visu_config" + configSuffix + ".xml', parseXML );", 200);
+ $.get( 'visu_config' + configSuffix + '.xml', parseXML );
} );
$(window).unload(function() {
@@ -276,13 +276,9 @@
$('.footer').html( $('.footer').html() + text );
});
- // adapt width for pages to show
- handleResize();
-
if (pluginsToLoad <= 0) {
setup_page(xml);
}
-
}
function setup_page( xml )
@@ -291,7 +287,6 @@
var page = $( 'pages > page', xml )[0]; // only one page element allowed...
$('head').append(($('<div class="colspandefault" id="colspandefault">')));
- setTimeout(function() {
$('head').data('colspanDefault', parseInt($('#colspandefault').css('width')));
$('#colspandefault').remove();
@@ -342,8 +337,8 @@
}
visu.subscribe( ga_list );
+ $(window).trigger('resize');
$("#pages").triggerHandler("done");
- }, 1);
}
function create_pages( page, path, flavour ) {
Modified: CometVisu/trunk/visu/visu_config_2d3d.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-11 16:34:34 UTC (rev 725)
@@ -78,7 +78,7 @@
<address transform="DPT:5.001" type="">12/7/52</address>
</info>
</page>
- <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54">
+ <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54" floor="12/7/51">
<slide min="0" max="6.283185307179586">
<layout x="0px" y="570px" width="600px" />
<label>Azimut</label>
@@ -89,6 +89,16 @@
<label>Elevation</label>
<address transform="DPT:5.001" type="">12/7/54</address>
</slide>
+ <trigger value="0">
+ <layout x="0px" y="150px" width="600px" />
+ <label>Underground</label>
+ <address transform="DPT:5.004" readonly="false" type="">12/7/51</address>
+ </trigger>
+ <trigger value="1">
+ <layout x="0px" y="100px" width="600px" />
+ <label>Ground</label>
+ <address transform="DPT:5.004" readonly="false" type="">12/7/51</address>
+ </trigger>
</page>
<line/>
</page>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-07 22:55:34 UTC (rev 724)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -173,7 +173,7 @@
*/
// public variables of this object instance
- this.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+ this.buildingProperties = { floor: [], Object3D: new THREE.Object3D(), floorNames:{} };
// private variables of this object instance will follow
@@ -384,6 +384,7 @@
var floorName = floor.getAttribute('name');
self.buildingProperties.floor[floorCount].name = floorName;
+ self.buildingProperties.floorNames[floorName] = floorCount;
var floorheight = Number( floor.getAttribute('height') );
self.buildingProperties.floor[floorCount].height = floorheight;
@@ -1098,6 +1099,31 @@
return showStates[ property ];
}
+ /**
+ * Resize the canvas. This might be done explicit by passing a width and
+ * height. Or implicit by passing no parameter or just the redraw parameter.
+ */
+ this.resize = function( width, height, redraw )
+ {
+ if( arguments.length === 2 || arguments.length === 3 )
+ {
+ WIDTH = width;
+ HEIGHT = height;
+ } else {
+ WIDTH = container.find('canvas').width();
+ HEIGHT = container.find('canvas').height();
+ redraw = width; // the first and only parameter is now the "redraw"
+ }
+ ASPECT = WIDTH / HEIGHT;
+ renderer.setSize(WIDTH, HEIGHT);
+ camera.aspect = ASPECT;
+
+ if( redraw ) // is set and true
+ {
+ update3D();
+ }
+ }
+
this.hideFloor = function( floorNr, doShow )
{
THREE.SceneUtils.traverseHierarchy( self.buildingProperties.floor[floorNr].wallGroup, function( object ) {
@@ -1178,13 +1204,14 @@
* is taken from the parameter <code>floor</code>
* @param {Function} delayedFn (optional) Function to call after animation is
* finished
+ * @param {Bool} animate Animate unless set to false
*/
- this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
+ this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn, animate )
{
if( noSetup ) setup3D( this.buildingProperties.Object3D );
// speed of the changing
- var steps = 100;
+ var steps = (animate == undefined || !animate) ? 1 : 100;
var rate = { azimut: 0.0, elevation: 0.0, distance: 0.0, target: new THREE.Vector3 };
function calcRate()
@@ -1271,10 +1298,14 @@
/**
* @method moveToRoom
*/
- this.moveToRoom = function( floor, room )
+ this.moveToRoom = function( floor, room, hideOtherFloors, animate )
{
var target = new THREE.Vector3();
var dist;
+ if( typeof floor === 'string' )
+ {
+ floor = this.buildingProperties.floorNames[floor];
+ }
if( room ) // use room if defined
{
target.x = room.center.x;
@@ -1287,7 +1318,25 @@
}
target.z = this.buildingProperties.floor[ floor ].heightOfGround +
this.buildingProperties.floor[ floor ].height / 2;
- this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target );
+ if( hideOtherFloors )
+ {
+ // show relevant floors
+ var minFloor = floor < showStates.showFloor ? floor : showStates.showFloor;
+ var maxFloor = floor < showStates.showFloor ? showStates.showFloor : floor;
+ var f = self.buildingProperties.floor.length-1;
+ for( ; f >= 0; f-- ) self.hideFloor( f, minFloor <= f && f <= maxFloor );
+ }
+ this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target,
+ function(){
+ if( hideOtherFloors )
+ {
+ // hide all except target floors
+ var f = self.buildingProperties.floor.length-1;
+ for( ; f >= 0; f-- ) self.hideFloor( f, f == floor );
+ }
+ self.render();
+ }, animate );
+ showStates.showFloor = floor;
return target;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|