You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(121) |
Dec
(58) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2011 |
Jan
(38) |
Feb
(36) |
Mar
(7) |
Apr
(2) |
May
(32) |
Jun
(24) |
Jul
(16) |
Aug
(21) |
Sep
(17) |
Oct
(62) |
Nov
(60) |
Dec
(70) |
| 2012 |
Jan
(54) |
Feb
(41) |
Mar
(21) |
Apr
(38) |
May
(76) |
Jun
(47) |
Jul
(25) |
Aug
(72) |
Sep
(29) |
Oct
(64) |
Nov
(93) |
Dec
(97) |
| 2013 |
Jan
(100) |
Feb
(168) |
Mar
(115) |
Apr
(59) |
May
(37) |
Jun
(32) |
Jul
(45) |
Aug
(42) |
Sep
(24) |
Oct
(73) |
Nov
(64) |
Dec
(4) |
| 2014 |
Jan
(14) |
Feb
(57) |
Mar
(58) |
Apr
(10) |
May
(18) |
Jun
(12) |
Jul
(7) |
Aug
(12) |
Sep
(15) |
Oct
(6) |
Nov
(32) |
Dec
(17) |
| 2015 |
Jan
(50) |
Feb
(5) |
Mar
(1) |
Apr
(26) |
May
(10) |
Jun
(3) |
Jul
(3) |
Aug
(2) |
Sep
(3) |
Oct
(18) |
Nov
(18) |
Dec
(8) |
| 2016 |
Jan
(33) |
Feb
(35) |
Mar
(50) |
Apr
(20) |
May
(25) |
Jun
(17) |
Jul
(8) |
Aug
(73) |
Sep
(64) |
Oct
(51) |
Nov
(20) |
Dec
(14) |
| 2017 |
Jan
(41) |
Feb
(57) |
Mar
(44) |
Apr
(136) |
May
(32) |
Jun
(39) |
Jul
(2) |
Aug
(12) |
Sep
(32) |
Oct
(103) |
Nov
(12) |
Dec
(4) |
| 2018 |
Jan
(9) |
Feb
(1) |
Mar
(60) |
Apr
(24) |
May
(15) |
Jun
(1) |
Jul
(2) |
Aug
(23) |
Sep
(15) |
Oct
(57) |
Nov
(21) |
Dec
(77) |
| 2019 |
Jan
(62) |
Feb
(99) |
Mar
(98) |
Apr
(49) |
May
(6) |
Jun
(3) |
Jul
(6) |
Aug
(18) |
Sep
(9) |
Oct
(15) |
Nov
(30) |
Dec
(6) |
| 2020 |
Jan
(14) |
Feb
(2) |
Mar
(22) |
Apr
(33) |
May
(47) |
Jun
(12) |
Jul
|
Aug
|
Sep
(4) |
Oct
(2) |
Nov
(5) |
Dec
(5) |
| 2021 |
Jan
(4) |
Feb
(101) |
Mar
(13) |
Apr
(32) |
May
(40) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
(25) |
Nov
(12) |
Dec
|
| 2022 |
Jan
(154) |
Feb
(82) |
Mar
(63) |
Apr
(27) |
May
(26) |
Jun
(5) |
Jul
(12) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(13) |
Dec
(21) |
| 2023 |
Jan
(43) |
Feb
(43) |
Mar
(15) |
Apr
(8) |
May
(3) |
Jun
(25) |
Jul
(6) |
Aug
(38) |
Sep
(5) |
Oct
(20) |
Nov
(9) |
Dec
(28) |
| 2024 |
Jan
(15) |
Feb
(2) |
Mar
(12) |
Apr
(2) |
May
(8) |
Jun
(10) |
Jul
(10) |
Aug
(2) |
Sep
(3) |
Oct
(15) |
Nov
(6) |
Dec
(20) |
| 2025 |
Jan
|
Feb
(2) |
Mar
(6) |
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(11) |
Nov
(2) |
Dec
|
|
From: <ma...@us...> - 2011-12-20 17:46:43
|
Revision: 605
http://openautomation.svn.sourceforge.net/openautomation/?rev=605&view=rev
Author: mayerch
Date: 2011-12-20 17:46:36 +0000 (Tue, 20 Dec 2011)
Log Message:
-----------
Fix holes in the wall (finally!)
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-20 17:06:40 UTC (rev 604)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-20 17:46:36 UTC (rev 605)
@@ -564,23 +564,30 @@
var wall1vertices = [];
var wall2vertices = [];
var sId, eId;
+ var l1SquaredInv = 1.0 / ((e1.x-s1.x)*(e1.x-s1.x) + (e1.y-s1.y)*(e1.y-s1.y));
+ var l1SquaredInv = 1.0 / ((e2.x-s2.x)*(e2.x-s2.x) + (e2.y-s2.y)*(e2.y-s2.y));
for( var v = 0; v < Tvertices.length; v++ )
{
- // project s1, e1 and s2, e2 onto line sm->em
- var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
- var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var e1f = 1-((e1.x-sm.x)*(em.x-sm.x) + (e1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var s2f = 1-((s2.x-sm.x)*(em.x-sm.x) + (s2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var e2f = 1-((e2.x-sm.x)*(em.x-sm.x) + (e2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var tv = Tvertices[v];
- var tv = Tvertices[v];
- var tvx1 = Math.min( 1.0, Math.max( 0.0, (tv.x - s1f) * (e1f - s1f) ) ); // map between s1 and e1
- var tvx2 = Math.min( 1.0, Math.max( 0.0, (tv.x - s2f) * (e2f - s2f) ) ); // map between s2 and e2
- var x1 = s1.x * tvx1 + e1.x * (1 - tvx1);
- var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
- var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
- var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
- //console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
+ // get point in building space:
+ var tm = {
+ x: sm.x * (1-tv.x) + em.x * tv.x ,
+ y: sm.y * (1-tv.x) + em.y * tv.x
+ };
+
+ // project it onto s1->e1
+ var f1 = ((tm.x-s1.x)*(e1.x-s1.x) + (tm.y-s1.y)*(e1.y-s1.y))*l1SquaredInv;
+ if( tv.x == 0.0 || tv.x == 1.0 ) f1 = 1-tv.x; // special case on concave wall bend
+ var x1 = s1.x * (1-f1) + e1.x * f1;
+ var y1 = s1.y * (1-f1) + e1.y * f1;
+
+ // project it onto s2->e2
+ var f2 = ((tm.x-s2.x)*(e2.x-s2.x) + (tm.y-s2.y)*(e2.y-s2.y))*l1SquaredInv;
+ if( tv.x == 0.0 || tv.x == 1.0 ) f2 = 1-tv.x; // special case on concave wall bend
+ var x2 = s2.x * (1-f2) + e2.x * f2;
+ var y2 = s2.y * (1-f2) + e2.y * f2;
+
var z = heightOfGround + sh*tv.y;
if( wallSideOrder > 0 )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-20 17:06:50
|
Revision: 604
http://openautomation.svn.sourceforge.net/openautomation/?rev=604&view=rev
Author: mayerch
Date: 2011-12-20 17:06:40 +0000 (Tue, 20 Dec 2011)
Log Message:
-----------
Bugfix that placed all floors in one...
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-20 16:57:26 UTC (rev 603)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-20 17:06:40 UTC (rev 604)
@@ -330,7 +330,7 @@
JSFloorPlan3D.buildingProperties.floor[floorCount].height = floorheight;
JSFloorPlan3D.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
- var floorWallsStart = 0;// floorWalls.length; <- not defined here yet...
+ var floorWallsStart = floorWalls.length;
// iterate over the content of this floor
for( var j=0; j < floor.childNodes.length; j++ )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-20 16:57:36
|
Revision: 603
http://openautomation.svn.sourceforge.net/openautomation/?rev=603&view=rev
Author: mayerch
Date: 2011-12-20 16:57:26 +0000 (Tue, 20 Dec 2011)
Log Message:
-----------
Fix documentation anoyity that was caused by "overloading" a method (which JS can't do...).
As this method isn't used (yet) it won't have any side effects.
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-20 16:39:19 UTC (rev 602)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-20 16:57:26 UTC (rev 603)
@@ -222,27 +222,10 @@
}
/**
- * calculate the rotation of a cartesian 2D point around the center
- * @method rotate2D
- * @private
- * @param {Float} angle Rotation angle
- * @param {Point} point
- * @param {Point} center
- * @return {Point} new point containing the turned coordinates
- */
- function rotate2D( angle, point, center )
- {
- var s = Math.sin( angle );
- var c = Math.cos( angle );
- var ret = new Object;
- ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
- ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
- return ret;
- }
-
- /**
* Calculate the rotation of a cartesian 2D point around the center
- * but with given sin and cos of the angle.
+ * but with given sin and cos of the angle. <br />
+ * Note: This method might also be used in a three argument form where the
+ * first argument is the angle (and not it's sin/cos pair).
* @method rotate2D
* @private
* @param {Float} s Sin of the rotation angle
@@ -253,6 +236,14 @@
*/
function rotate2D( s, c, point, center )
{
+ if( rotate2D.arguments.length == 3 )
+ {
+ center = rotate2D.arguments[2];
+ point = rotate2D.arguments[1];
+ c = Math.cos( rotate2D.arguments[0] );
+ s = Math.sin( rotate2D.arguments[0] );
+ }
+
var ret = new Object;
ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-20 16:39:30
|
Revision: 602
http://openautomation.svn.sourceforge.net/openautomation/?rev=602&view=rev
Author: mayerch
Date: 2011-12-20 16:39:19 +0000 (Tue, 20 Dec 2011)
Log Message:
-----------
Clarify coordinate system and change camera and light position to azimut/elevation. (This should later allow an easy lighting based by the current time and date)
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-19 21:35:14 UTC (rev 601)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-20 16:39:19 UTC (rev 602)
@@ -65,11 +65,14 @@
* <dd>The attribute <code>orientation</code> defines a rotation of the local
* coordinate system to north.
* <ul>
- * <li><code>orientation="0"</code> means that the x axis is looking
- * north and the y axis is looking east.</li>
- * <li><code>orientation="90"</code> means that the x axis is looking
- * west and the y axis is looking south.</li>
+ * <li><code>orientation="0"</code> means that the y axis is looking
+ * north and the x axis is looking east.</li>
+ * <li><code>orientation="90"</code> means that the y axis is looking
+ * east and the x axis is looking south.</li>
* </ul>
+ * Note: As the z axis points upwards this is a right handed coordinate
+ * system.
+ * <img src="assets/coordinate_system.png" />
* </dd>
* <dt><code><b><floor></b></code></dt>
* <dd>The <code>floor</code> element contains all relevant information
@@ -905,32 +908,32 @@
* Show the floor plan by updating the relevant view parameters and calling
* the render() method
* @method show3D
- * @param {Integer} rotation The direction to look at. 0° = North, 180° =
- * South
- * @param {Integer} tilt The amount of tilting the vire. 0° = no tilt,
- * 90° = bird eyes view
+ * @param {Integer} azmiut The direction of the camera. 0° = North, 90° =
+ * East.
+ * @param {Integer} elevation The amount of tilting the view. 0° = no tilt,
+ * 90° = bird eyes view
*/
- JSFloorPlan3D.show3D = function( rotation, tilt )
+ JSFloorPlan3D.show3D = function( azimut, elevation )
{
if( noSetup ) setup3D();
// set up camera
- var cx = -Math.cos(rotation) * Math.cos(tilt);
- var cy = Math.sin(rotation) * Math.cos(tilt);
- var cz = Math.sin(tilt);
+ var cx = Math.sin(azimut) * Math.cos(elevation);
+ var cy = Math.cos(azimut) * Math.cos(elevation);
+ var cz = Math.sin(elevation);
var heightOfGround = JSFloorPlan3D.buildingProperties.floor[ showStates.showFloor ].heightOfGround;
var target = new THREE.Vector3( JSFloorPlan3D.buildingProperties.x_center, JSFloorPlan3D.buildingProperties.y_center, heightOfGround);
- camera.up = new THREE.Vector3( Math.cos(rotation) * Math.sin(tilt), -Math.sin(rotation) * Math.sin(tilt), Math.cos(tilt) );
+ camera.up = new THREE.Vector3( -Math.sin(azimut) * Math.sin(elevation), -Math.cos(azimut) * Math.sin(elevation), Math.cos(elevation) );
camera.position = new THREE.Vector3( cx*dist + JSFloorPlan3D.buildingProperties.x_center, cy*dist + JSFloorPlan3D.buildingProperties.y_center, dist * cz + heightOfGround);
camera.lookAt( target );
pointLight.position = camera.position;
// set up sun
- var sx = -Math.cos(lightDirection) * Math.cos(lightHeight);
- var sy = Math.sin(lightDirection) * Math.cos(lightHeight);
- var sz = Math.sin(lightHeight);
+ var sx = Math.sin(lightAzimut) * Math.cos(lightElevation);
+ var sy = Math.cos(lightAzimut) * Math.cos(lightElevation);
+ var sz = Math.sin(lightElevation);
sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance );
+ sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance + heightOfGround);
sunLight.intensity = lightStrength / 100.0;
sunLightViewLine.geometry.vertices[0].position = sunLight.position;
sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-19 21:35:14 UTC (rev 601)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-20 16:39:19 UTC (rev 602)
@@ -21,6 +21,12 @@
//
//////////////////////////////////////////////////////////////////////////////
+/**
+ * The "Example helpers" module contains all the JavaScript functions that are
+ * needed to show the example.
+ * @module JS FloorPlan 3D Example
+ */
+
j = new JSFLOORPLAN3D();
function loadFloorplan()
{
@@ -148,8 +154,8 @@
// add to the scene
//scene.add(pointLight);
-var lightDirection = 3.9;
-var lightHeight = 0.25;
+var lightAzimut = 3.9;
+var lightElevation = 0.25;
var lightStrength = 80;
var lightDistance = 50;
//var sunLight = new THREE.PointLight( 0xFFFFFF );
@@ -452,8 +458,8 @@
globalInUpdateSlider = true;
var rollAngle = (roll * 180/Math.PI);
var tiltAngle = (tilt * 180/Math.PI);
- var lightDirectionAngle = (lightDirection * 180/Math.PI);
- var lightHeightAngle = (lightHeight * 180/Math.PI);
+ var lightDirectionAngle = (lightAzimut * 180/Math.PI);
+ var lightHeightAngle = (lightElevation * 180/Math.PI);
$( "#rollSlider" ).slider( "option", "value", rollAngle );
$( "#tiltSlider" ).slider( "option", "value", tiltAngle );
$( "#distSlider" ).slider( "option", "value", dist );
@@ -488,14 +494,14 @@
function lightDirectionChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightDirection = ui.value * Math.PI / 180;
+ lightAzimut = ui.value * Math.PI / 180;
j.show3D( roll, tilt );
}
function lightHeightChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightHeight = ui.value * Math.PI / 180;
+ lightElevation = ui.value * Math.PI / 180;
j.show3D( roll, tilt );
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tho...@us...> - 2011-12-19 21:35:22
|
Revision: 601
http://openautomation.svn.sourceforge.net/openautomation/?rev=601&view=rev
Author: thomas_s
Date: 2011-12-19 21:35:14 +0000 (Mon, 19 Dec 2011)
Log Message:
-----------
- more refactoring
Modified Paths:
--------------
xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt
xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp
xPLHAL/branches/thomas_s_dev/src/devicemanager.h
xPLHAL/branches/thomas_s_dev/src/main.cpp
xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp
xPLHAL/branches/thomas_s_dev/src/xplhandler.h
xPLHAL/branches/thomas_s_dev/src/xplmessage.h
xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt
xPLHAL/branches/thomas_s_dev/test/test_devicemanager.cpp
Added Paths:
-----------
xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp
xPLHAL/branches/thomas_s_dev/test/mock_xplhandler.h
Modified: xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt 2011-12-19 21:35:14 UTC (rev 601)
@@ -19,7 +19,7 @@
#set(CMAKE_CXX_FLAGS "-g -O2 -std=c++0x")
set(CMAKE_CXX_FLAGS "-g -Os -std=c++0x")
-set(xPLHAL_SRCS xplmessagequeue.cpp devicemanager.cpp xplhandler.cpp xplcache.cpp xhcpthread.cpp log.cpp xhcp.cpp main.cpp)
+set(xPLHAL_SRCS xplmessagequeue.cpp devicemanager.cpp xplhandler.cpp xplcache.cpp xhcpthread.cpp log.cpp xhcp.cpp xplmessage.cpp main.cpp)
add_executable(xPLHAL ${xPLHAL_SRCS})
#message(STATUS "Boost_LIBRARIES=${Boost_LIBRARIES}")
Modified: xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp 2011-12-19 21:35:14 UTC (rev 601)
@@ -15,8 +15,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <cstdio>
@@ -125,16 +123,14 @@
void deviceManagerClass::processConfigList( const xPLMessagePtr message )
{
- std::string source = extractSourceFromXplMessage(message);
+ std::string source = message->getSourceVDI();
xPLDevice device = getDevice( source );
writeLog( "deviceManagerClass::processConfigList("+source+") - found ["+device.VDI+"]", logLevel::debug );
if( "" == device.VDI ) {
// A config list turned up that we haven't asked for...
// create a new device...
int interval = 5;
- //\TODO: implement xPL_getMessageNamedValue
-// ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
- ptime expires = calculateExpireTime("5", &interval);
+ ptime expires = calculateExpireTime(message->getNamedValue("interval"), &interval);
device.VDI = source; // vendor / device / instance = unique id
device.ConfigDone = false; // false = new waiting check, true = sent/not required
device.ConfigMissing = false; // true = no config file, no response from device, false = have/waiting config
@@ -178,18 +174,16 @@
// try to get at least the current config
xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
- message->vendor,
- message->deviceID,
- message->instanceID,
+ source,
"config", "current",
command_request) );
m_sigSendXplMessage(msg);
}
}
-ptime deviceManagerClass::calculateExpireTime(const char* string_interval, int *pInterval)
+ptime deviceManagerClass::calculateExpireTime(const std::string& string_interval, int *pInterval)
{
- int interval = string_interval ? atoi(string_interval) : 5; // default to 5 minutes
+ int interval = string_interval.empty() ? atoi(string_interval.c_str()) : 5; // default to 5 minutes
if (pInterval) {
*pInterval = interval;
}
@@ -203,7 +197,7 @@
void deviceManagerClass::processConfigHeartBeat( const xPLMessagePtr message )
{
- std::string source = extractSourceFromXplMessage(message);
+ std::string source = message->getSourceVDI();
xPLDevice device = getDevice( source );
writeLog( "deviceManagerClass::processConfigHeartBeat("+source+") - found ["+device.VDI+"]", logLevel::debug );
@@ -211,9 +205,7 @@
// this handles a new application that identifies itself with a hbeat straight away.
// it must either be storing it's config locally, can't be configured, or is configured somewhere else.
int interval = 5;
- //\TODO
-// ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
- ptime expires = calculateExpireTime("5", &interval);
+ ptime expires = calculateExpireTime(message->getNamedValue("interval"), &interval);
device.VDI = source; // vendor / device / instance = unique id
device.ConfigDone = false; // false = new waiting check, true = sent/not required
device.ConfigMissing = true; // true = no config file, no response from device, false = have/waiting config
@@ -237,9 +229,7 @@
if( !device.ConfigListSent ) {
xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
- message->vendor,
- message->deviceID,
- message->instanceID,
+ source,
"config", "list",
command_request) );
m_sigSendXplMessage(msg);
@@ -249,7 +239,7 @@
void deviceManagerClass::processCurrentConfig( const xPLMessagePtr message )
{
- std::string source = extractSourceFromXplMessage(message);
+ std::string source = message->getSourceVDI();
xPLDevice device = getDevice( source );
writeLog( "deviceManagerClass::processCurrentConfig("+source+") - found ["+device.VDI+"]", logLevel::debug );
if( "" == device.VDI ) {
@@ -286,29 +276,13 @@
}
}
-std::string deviceManagerClass::extractSourceFromXplMessage( xPL_MessagePtr message )
-{
- return std::string(xPL_getSourceVendor(message)) + "-"
- + xPL_getSourceDeviceID ( message ) + "."
- + xPL_getSourceInstanceID( message );
-}
-
-std::string deviceManagerClass::extractSourceFromXplMessage( xPLMessagePtr message )
-{
- return std::string(message->vendor + "-"
- + message->deviceID + "."
- + message->instanceID);
-}
-
void deviceManagerClass::processHeartbeat( xPLMessagePtr message )
{
- std::string source = extractSourceFromXplMessage(message);
+ std::string source = message->getSourceVDI();
xPLDevice device = getDevice( source );
int interval = 5;
- //\TODO
-// ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
- ptime expires = calculateExpireTime("5", &interval);
+ ptime expires = calculateExpireTime(message->getNamedValue("interval"), &interval);
writeLog( "deviceManagerClass::processHeartbeat("+source+") - found ["+device.VDI+"]", logLevel::debug );
if( "" == device.VDI ) {
@@ -330,9 +304,7 @@
// Throw it a config request anyway, see what turns up..
xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
- message->vendor,
- message->deviceID,
- message->instanceID,
+ source,
"config", "list",
command_request) );
m_sigSendXplMessage(msg);
@@ -349,7 +321,7 @@
void deviceManagerClass::processRemove( xPLMessagePtr message )
{
- std::string source = extractSourceFromXplMessage(message);
+ std::string source = message->getSourceVDI();
remove( source );
removeConfig( source );
@@ -371,15 +343,8 @@
}
if( list.size() > 0 ) {
- size_t marker1 = source.find( "-" );
- size_t marker2 = source.find( "." );
- std::string vendor = source.substr( 0, marker1 );
- std::string device = source.substr( marker1+1, marker2 - (marker1+1) );
- std::string instance = source.substr( marker2+1 );
xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
- vendor,
- device,
- instance,
+ source,
"config", "response",
list) );
m_sigSendXplMessage(msg);
@@ -442,7 +407,3 @@
return m_xPLCache->childNodes( "config." + configTag ).size() > 0;
}
-boost::signals2::connection deviceManagerClass::connect(const xPLHandler::signal_t::slot_type &subscriber)
-{
- return m_sigSendXplMessage.connect(subscriber);
-}
Modified: xPLHAL/branches/thomas_s_dev/src/devicemanager.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/devicemanager.h 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/src/devicemanager.h 2011-12-19 21:35:14 UTC (rev 601)
@@ -32,8 +32,6 @@
public:
deviceManagerClass(IxPLCacheClass* xplcache);
- boost::signals2::connection connect(const xPLHandler::signal_t::slot_type &subscriber);
-
/** \brief Looks if the device deviceTag is known. */
bool contains( const std::string& deviceTag ) const;
@@ -68,16 +66,12 @@
/** \brief A new configuration arrived via XHCP, handle it... */
bool storeNewConfig( const std::string& source, const std::string& config );
-
+
+ xPLHandler::signal_t m_sigSendXplMessage;
private:
- /*! \TODO: move to correct class, maybe xplMessage */
- std::string extractSourceFromXplMessage( xPL_MessagePtr message );
- std::string extractSourceFromXplMessage( xPLMessagePtr message );
-
boost::posix_time::ptime calculateExpireTime(int interval);
- boost::posix_time::ptime calculateExpireTime(const char* string_interval, int *pInterval = 0);
+ boost::posix_time::ptime calculateExpireTime(const std::string& string_interval, int *pInterval = 0);
IxPLCacheClass* m_xPLCache;
std::map<std::string, xPLDevice> mDeviceMap;
- xPLHandler::signal_t m_sigSendXplMessage;
};
Modified: xPLHAL/branches/thomas_s_dev/src/main.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/main.cpp 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/src/main.cpp 2011-12-19 21:35:14 UTC (rev 601)
@@ -108,7 +108,8 @@
XHCPServer *xhcpServer = new XHCPServer();
xPL = new xPLHandler( boost::asio::ip::host_name() ); //xPL->start();
deviceManager = new deviceManagerClass(xPLCache);
- xPL->connect(boost::bind(&deviceManagerClass::processXplMessage, deviceManager, _1));
+ deviceManager->m_sigSendXplMessage.connect(boost::bind(&xPLMessageQueueClass::add, xPLMessageQueue, _1));
+ xPL->m_sigRceivedXplMessage.connect(boost::bind(&deviceManagerClass::processXplMessage, deviceManager, _1));
writeLog( "started", logLevel::all );
// force everyone to send their configuration so that we start up to date...
Modified: xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp 2011-12-19 21:35:14 UTC (rev 601)
@@ -152,83 +152,6 @@
xPLMessageQueue->add( xPLMessagePtr( new xPLMessage( type, vendor, device, instance, msgClass, msgType, namedValues ) ) );
}
-void xPLHandler::printXPLMessage( xPL_MessagePtr theMessage )
-{
- std::string result;
-
- /* Source Info */
- result += xPL_getSourceVendor(theMessage) + std::string("-");
- result += xPL_getSourceDeviceID(theMessage) + std::string(".");
- result += xPL_getSourceInstanceID(theMessage);
-
- result += " -> ";
- /* Handle various target types */
- if (xPL_isBroadcastMessage(theMessage)) {
- result += "*";
- } else {
- if (xPL_isGroupMessage(theMessage)) {
- result += "XPL-GROUP.";
- result += xPL_getTargetGroup(theMessage);
- } else {
- result += xPL_getTargetVendor(theMessage) + std::string("-");
- result += xPL_getTargetDeviceID(theMessage) + std::string(".");
- result += xPL_getTargetInstanceID(theMessage);
- }
- }
-
- /* Print hop count */
- result += " (";
- result += lexical_cast<std::string>(xPL_getHopCount(theMessage));
- result += " hops) ";
-
- result += "[";
- switch(xPL_getMessageType(theMessage))
- {
- case xPL_MESSAGE_COMMAND:
- result += "xpl-cmnd";
- break;
- case xPL_MESSAGE_STATUS:
- result += "xpl-stat";
- break;
- case xPL_MESSAGE_TRIGGER:
- result += "xpl-trig";
- break;
- default:
- result += "!UNKNOWN!";
- break;
- }
- result += "] ";
-
- /* Echo Schema Info */
- result += xPL_getSchemaClass(theMessage) + std::string(".");
- result += xPL_getSchemaType(theMessage) + std::string(": ");
-
- xPL_NameValueListPtr nvList = xPL_getMessageBody(theMessage);
- xPL_NameValuePairPtr nvPair = NULL;
- int nvIndex = 0;
- int nvCount = xPL_getNamedValueCount(nvList);
- /* Write Name/Value Pairs out */
- for (nvIndex = 0; nvIndex < nvCount; nvIndex++) {
- nvPair = xPL_getNamedValuePairAt(nvList, nvIndex);
- result += nvPair->itemName; //WRITE_TEXT(nvPair->itemName);
- result += "="; //WRITE_TEXT("=");
-
- /* Write data content out */
- if (nvPair->itemValue != NULL) {
- if (nvPair->isBinary)
- ;//writeBinaryValue(nvPair->itemValue, nvPair->binaryLength);
- else
- result += nvPair->itemValue; //WRITE_TEXT(nvPair->itemValue);
- }
-
- /* Terminate line/entry */
- result += "\n"; //WRITE_TEXT("\n");
- }
- replace_all( result, "\n", ";" );
-
- writeLog( result, logLevel::debug );
-}
-
void xPLHandler::xpl_message_callback( xPL_MessagePtr theMessage, void *userValue )
{
xPLHandler* obj = static_cast<xPLHandler*>(userValue);
@@ -237,8 +160,6 @@
void xPLHandler::handleXPLMessage( xPL_MessagePtr theMessage)
{
- printXPLMessage( theMessage );
-
xPLMessage::namedValueList values;
xPL_NameValueListPtr nvList = xPL_getMessageBody(theMessage);
xPL_NameValuePairPtr nvPair = NULL;
@@ -260,12 +181,18 @@
xPL_getSchemaType(theMessage),
values) );
- m_sigRceivedXplMessage(msg);
+ msg->isBroadcastMessage = xPL_isBroadcastMessage(theMessage);
+ msg->isGroupMessage = xPL_isGroupMessage(theMessage);
+ if (!msg->isBroadcastMessage) {
+ msg->targetVendor = xPL_getTargetVendor(theMessage);
+ msg->targetDevice = xPL_getTargetDeviceID(theMessage);
+ msg->targetInstance = xPL_getTargetInstanceID(theMessage);
+ }
+ if (msg->isGroupMessage) {
+ msg->targetGroup = xPL_getTargetGroup(theMessage);
+ }
+
+ writeLog(msg->printXPLMessage(), logLevel::debug );
+ m_sigRceivedXplMessage(msg);
}
-
-boost::signals2::connection xPLHandler::connect(const signal_t::slot_type &subscriber)
-{
- return m_sigRceivedXplMessage.connect(subscriber);
-}
-
Modified: xPLHAL/branches/thomas_s_dev/src/xplhandler.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplhandler.h 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/src/xplhandler.h 2011-12-19 21:35:14 UTC (rev 601)
@@ -42,8 +42,6 @@
xPLHandler( const std::string& host_name);
~xPLHandler();
- boost::signals2::connection connect(const signal_t::slot_type &subscriber);
-
void run();
/** \brief Broadcast one message to the xPL network. */
@@ -57,11 +55,11 @@
/** \brief Send a directed message to the xPL network. */
void sendMessage( const xPL_MessageType type, const std::string& VDI,
const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues ) const;
+
+ public:
+ signal_t m_sigRceivedXplMessage;
private:
- /** \brief Print via the logging facility the whole content of a xPL message. */
- static void printXPLMessage( xPL_MessagePtr theMessage );
-
/** \brief Handle an incomming xPL message. */
void handleXPLMessage( xPL_MessagePtr theMessage);
@@ -75,5 +73,4 @@
boost::thread* m_thread;
static int m_refcount;
bool m_exit_thread;
- signal_t m_sigRceivedXplMessage;
};
Added: xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp 2011-12-19 21:35:14 UTC (rev 601)
@@ -0,0 +1,119 @@
+/*
+ xPLHAL implementation in C++
+ Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "xplmessage.h"
+#include <boost/algorithm/string/replace.hpp>
+#include <boost/lexical_cast.hpp>
+#include <algorithm>
+
+using namespace boost::algorithm;
+using boost::lexical_cast;
+
+std::string xPLMessage::getTypeString() const
+{
+ switch(type)
+ {
+ case xPL_MESSAGE_COMMAND: return "xpl-cmnd";
+ case xPL_MESSAGE_STATUS: return "xpl-stat";
+ case xPL_MESSAGE_TRIGGER: return "xpl-trig";
+ default: return "!UNKNOWN!";
+ }
+}
+
+std::string xPLMessage::getSourceVDI() const
+{
+ return vendor + std::string("-") + deviceID + std::string(".") + instanceID;
+}
+
+std::string xPLMessage::getTargetVDI() const
+{
+ return targetVendor + std::string("-") + targetDevice + std::string(".") + targetInstance;
+}
+
+bool xPLMessage::setSourceFromVDI(const std::string& source)
+{
+ size_t marker1 = source.find( "-" );
+ size_t marker2 = source.find( "." );
+ vendor = source.substr( 0, marker1 );
+ deviceID = source.substr( marker1+1, marker2 - (marker1+1) );
+ instanceID = source.substr( marker2+1 );
+
+ return true;
+}
+
+bool xPLMessage::setTargetFromVDI(const std::string& target)
+{
+ size_t marker1 = target.find( "-" );
+ size_t marker2 = target.find( "." );
+ targetVendor = target.substr( 0, marker1 );
+ targetDevice = target.substr( marker1+1, marker2 - (marker1+1) );
+ targetInstance = target.substr( marker2+1 );
+
+ return true;
+}
+
+std::string xPLMessage::getNamedValue(const std::string& tag) const
+{
+ for (auto entry : namedValues) {
+ if (entry.first == tag) {
+ return entry.second;
+ }
+ }
+ return "";
+}
+
+std::string xPLMessage::printXPLMessage() const
+{
+ std::string result;
+ result += "<" + getTypeString() + " ";
+
+ /* Source Info */
+ result += getSourceVDI();
+ result += " -> ";
+ /* Handle various target types */
+ if (isBroadcastMessage) {
+ result += "*";
+ } else {
+ if (isGroupMessage) {
+ result += "XPL-GROUP." + targetGroup;
+ } else {
+ result += getTargetVDI();
+ }
+ }
+
+ /* Print hop count */
+ result += " (" + lexical_cast<std::string>(hopcount) + " hops) ";
+
+ /* Echo Schema Info */
+ result += "[" + msgClass + "." + msgType + "]: ";
+
+ for (auto entry : namedValues) {
+ result += entry.first + "=" + entry.second + "\n";
+ }
+ replace_all(result, "\n", ";");
+
+ result += ">";
+
+ return result;
+}
+
+std::ostream& operator<<(std::ostream& os, const xPLMessage& msg)
+{
+ os << msg.printXPLMessage();
+ return os;
+}
+
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessage.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2011-12-19 21:35:14 UTC (rev 601)
@@ -33,30 +33,67 @@
*/
class xPLMessage
{
- public:
- /** \brief Type that contains all name-value pairs of one xPL message.
- * This type has to preserve the order of it's items and must support
- * multiple entries with the same key. So a map or multimap wan't sufficient.
- */
- typedef std::vector<std::pair<std::string,std::string> > namedValueList;
+ public:
+ /** \brief Type that contains all name-value pairs of one xPL message.
+ * This type has to preserve the order of it's items and must support
+ * multiple entries with the same key. So a map or multimap wan't sufficient.
+ */
+ typedef std::vector<std::pair<std::string,std::string> > namedValueList;
- xPL_MessageType type;
- std::string vendor;
- std::string deviceID;
- std::string instanceID;
- std::string msgClass;
- std::string msgType;
- namedValueList namedValues;
+ public:
+ xPL_MessageType type;
+ std::string vendor;
+ std::string deviceID;
+ std::string instanceID;
+ std::string msgClass;
+ std::string msgType;
- xPLMessage(
- const xPL_MessageType _type,
- const std::string& _vendor,
- const std::string& _deviceID,
- const std::string& _instanceID,
- const std::string& _msgClass,
- const std::string& _msgType,
- const namedValueList& _namedValues
- ) : type(_type), vendor(_vendor), deviceID(_deviceID), instanceID(_instanceID),
- msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues) {}
+ namedValueList namedValues;
+
+ bool isBroadcastMessage;
+ bool isGroupMessage;
+
+ std::string targetVendor;
+ std::string targetDevice;
+ std::string targetInstance;
+ std::string targetGroup;
+
+ int hopcount;
+
+ xPLMessage(
+ const xPL_MessageType _type,
+ const std::string& _vendor,
+ const std::string& _deviceID,
+ const std::string& _instanceID,
+ const std::string& _msgClass,
+ const std::string& _msgType,
+ const namedValueList& _namedValues
+ ) : type(_type), vendor(_vendor), deviceID(_deviceID), instanceID(_instanceID),
+ msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues)
+ {
+ }
+
+ xPLMessage(
+ const xPL_MessageType _type,
+ const std::string& _vdi,
+ const std::string& _msgClass,
+ const std::string& _msgType,
+ const namedValueList& _namedValues
+ ) : type(_type), msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues)
+ {
+ setSourceFromVDI(_vdi);
+ }
+
+ std::string printXPLMessage() const;
+ std::string getTypeString() const;
+ std::string getSourceVDI() const;
+ std::string getTargetVDI() const;
+
+ bool setSourceFromVDI(const std::string& vdi);
+ bool setTargetFromVDI(const std::string& vdi);
+
+ std::string getNamedValue(const std::string& tag) const;
};
typedef boost::shared_ptr<xPLMessage> xPLMessagePtr;
+
+std::ostream& operator<<(std::ostream& os, const xPLMessage& msg);
Modified: xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt 2011-12-19 21:35:14 UTC (rev 601)
@@ -23,11 +23,11 @@
file(GLOB_RECURSE UnitTests_sources *.cpp)
#set(UnitTest_tsrc ../src/devicemanager.cpp ../src/xplcache.cpp ../src/xplhandler.cpp ../src/xplmessagequeue.cpp)
-set(UnitTest_tsrc ../src/devicemanager.cpp)
+set(UnitTest_tsrc ../src/devicemanager.cpp ../src/xplmessage.cpp)
add_executable(test_runner ${UnitTests_sources} ${UnitTest_tsrc})
-include_directories(../src)
+include_directories(../src /usr/local/include)
enable_testing()
@@ -38,7 +38,7 @@
#message(STATUS "LIBRARIES=${LIBS}")
#message(STATUS "SOURCE=${SOURCES}")
#target_link_libraries(xPLHAL ${Boost_LIBRARIES} -dynamic xPL pthread -static)
-target_link_libraries(test_runner ${LIBS})
+target_link_libraries(test_runner ${LIBS} mockpp)
add_test(UnitTests test_runner)
Added: xPLHAL/branches/thomas_s_dev/test/mock_xplhandler.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/mock_xplhandler.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/test/mock_xplhandler.h 2011-12-19 21:35:14 UTC (rev 601)
@@ -0,0 +1,62 @@
+#include <mockpp/visiting/CountedVisitableMethod.h>
+#include "i_xplhandler.h"
+
+using namespace mockpp;
+
+class MockXplHandler : public IxPLHandler, public VisitableMockObject
+{
+ public:
+ MockXplHandler()
+ : VisitableMockObject("MockXplHandler", 0)
+ , sendBroadcastMessage_mocker("sendBroadcastMessage", this)
+ , sendMessage_mocker("sendMessage", this)
+ , sendMessage2_mocker("sendMessage", this)
+ {}
+
+ void sendBroadcastMessage( const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues ) const
+ {
+#if 0
+ std::cout << "sendBroadcastMessage(";
+ std::cout << msgClass << ",";
+ std::cout << msgType << ",";
+ std::cout << std::endl;
+#endif
+ sendBroadcastMessage_mocker.forward(msgClass, msgType);
+ }
+// VisitableMockMethod<void, std::string, xPLMessage::namedValueList> sendBroadcastMessage_mocker;
+ VisitableMockMethod<void, std::string, std::string> sendBroadcastMessage_mocker;
+
+ /** \brief Send a directed message to the xPL network. */
+ void sendMessage( const xPL_MessageType type, const std::string& tgtVendor, const std::string& tgtDeviceID,
+ const std::string& tgtInstanceID, const std::string& msgClass, const std::string& msgType,
+ const xPLMessage::namedValueList& namedValues ) const
+ {
+#if 0
+ std::cout << "sendMessage(";
+ std::cout << type << ",";
+ std::cout << tgtVendor << "-" << tgtDeviceID << "." << tgtInstanceID << ",";
+ std::cout << msgClass << "," << msgType;
+ std::cout << std::endl;
+#endif
+ sendMessage_mocker.forward(type, tgtVendor, tgtDeviceID, tgtInstanceID, msgClass, msgType);
+ }
+// VisitableMockMethod<void, std::string, std::string, std::string, std::string, std::string, xPLMessage::namedValueList> sendMessage_mocker;
+ VisitableMockMethod<void, xPL_MessageType, std::string, std::string, std::string, std::string, std::string> sendMessage_mocker;
+
+ /** \brief Send a directed message to the xPL network. */
+ void sendMessage( const xPL_MessageType type, const std::string& VDI,
+ const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues ) const
+ {
+#if 0
+ std::cout << "sendMessage2(";
+ std::cout << type << ",";
+ std::cout << VDI << ",";
+ std::cout << msgClass << "," << msgType;
+ std::cout << std::endl;
+#endif
+ sendMessage2_mocker.forward(type, VDI, msgClass, msgType);
+ }
+// VisitableMockMethod<void, std::string, std::string, std::string, xPLMessage::namedValueList> sendMessage2_mocker;
+ VisitableMockMethod<void, xPL_MessageType, std::string, std::string, std::string> sendMessage2_mocker;
+};
+
Modified: xPLHAL/branches/thomas_s_dev/test/test_devicemanager.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/test_devicemanager.cpp 2011-12-19 17:29:18 UTC (rev 600)
+++ xPLHAL/branches/thomas_s_dev/test/test_devicemanager.cpp 2011-12-19 21:35:14 UTC (rev 601)
@@ -1,10 +1,13 @@
#include "../src/devicemanager.h"
#define BOOST_TEST_MODULE "DeviceManager"
#include <boost/test/unit_test.hpp>
+//#include "mock_xplhandler.h"
//#include "xplcache.h"
#include "devicemanager.h"
+#include <boost/regex.hpp>
+
// load globas and give them their space to live
//#include "globals.h"
@@ -17,6 +20,7 @@
#endif
+#if 0
class MockXplHandler: public IxPLHandler
{
public:
@@ -43,6 +47,7 @@
std::cerr << std::endl;
}
};
+#endif
class MockXplCache: public IxPLCacheClass
{
@@ -83,10 +88,26 @@
virtual void saveCache( void ) const { }
};
+class MockSignalReceiver
+{
+ public:
+ void handleSignal(const xPLMessagePtr message)
+ {
+ std::cout << "received signal" << *message << std::endl;
+ }
+};
+
BOOST_AUTO_TEST_SUITE(DeviceManagerSuite);
BOOST_AUTO_TEST_CASE( add_device )
{
+ xPLMessage::namedValueList values;
+ values.push_back( std::make_pair( "tag", "value" ) );
+ xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_TRIGGER,
+ "pnxs", "hs485", "default1",
+ "blah", "blub",
+ values) );
+#if 0
xPL_MessagePtr msg = new xPL_Message;
msg->messageType = xPL_MESSAGE_TRIGGER;
msg->hopCount = 0;
@@ -103,18 +124,73 @@
msg->schemaClass = "blah";
msg->schemaType = "blub";
xPL_addMessageNamedValue(msg, "tag", "value");
+#endif
- MockXplHandler mockHandler;
+// MockXplHandler mockHandler;
MockXplCache mockCache;
- deviceManagerClass dm(&mockHandler, &mockCache);
+ deviceManagerClass dm(&mockCache);
BOOST_CHECK( dm.contains("pnxs-hs485.default1") == false);
dm.processHeartbeat(msg);
BOOST_CHECK( dm.contains("pnxs-hs485.default1") == true);
}
+#define m2s(match, group) std::string(match[group].first, match[group].second)
+
+//xPL_MessagePtr createXplMessage(const char* srcVDI, const char* dstVDI, const char* schema, std::map<std::string, std::string> tags)
+xPL_MessagePtr createXplMessage(xPL_MessageType msgType, const std::string& srcVDI, const std::string& dstVDI, const char* schema)
+{
+ std::string regex = R"(^([\w\d]+)-([\w\d]+)\.([\w\d]+)$)";
+ xPL_MessagePtr msg = new xPL_Message;
+ msg->messageType = msgType;
+ msg->hopCount = 0;
+ msg->receivedMessage = TRUE; /* TRUE if received, FALSE if being sent */
+ msg->isGroupMessage = FALSE;
+ msg->groupName = 0;
+ msg->isBroadcastMessage = TRUE;
+ msg->schemaClass = "blah";
+ msg->schemaType = "blub";
+// xPL_addMessageNamedValue(msg, "tag", "value");
+
+
+ boost::regex re_vdi(regex);
+ boost::smatch match;
+ if( ! boost::regex_match(srcVDI, match, re_vdi) ) {
+ delete msg;
+ return 0;
+ }
+ msg->sourceVendor = m2s(match, 1).c_str();
+ msg->sourceDeviceID = m2s(match, 2).c_str();
+ msg->sourceInstanceID = m2s(match, 3).c_str();
+
+ if( dstVDI == "*") {
+ msg->targetVendor = "*";
+ msg->targetDeviceID = "";
+ msg->targetInstanceID = "";
+ }
+ else {
+ if( ! boost::regex_match(dstVDI, match, re_vdi) ) {
+ delete msg;
+ return 0;
+ }
+ }
+ msg->targetVendor = m2s(match, 1).c_str();
+ msg->targetDeviceID = m2s(match, 2).c_str();
+ msg->targetInstanceID = m2s(match, 3).c_str();
+
+ return 0;
+}
+
BOOST_AUTO_TEST_CASE( remove_device )
{
+// xPL_MessagePtr mymsg = createXplMessage(xPL_MESSAGE_TRIGGER, "pnxs-hs485.default1", "*", "blah.blub");
+ xPLMessage::namedValueList values;
+ values.push_back( std::make_pair( "tag", "value" ) );
+ xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_TRIGGER,
+ "pnxs", "hs485", "default1",
+ "blah", "blub",
+ values) );
+#if 0
xPL_MessagePtr msg = new xPL_Message;
msg->messageType = xPL_MESSAGE_TRIGGER;
msg->hopCount = 0;
@@ -131,17 +207,27 @@
msg->schemaClass = "blah";
msg->schemaType = "blub";
xPL_addMessageNamedValue(msg, "tag", "value");
+#endif
- MockXplHandler mockHandler;
+// MockXplHandler mockHandler;
MockXplCache mockCache;
+ MockSignalReceiver sigrecv;
- deviceManagerClass dm(&mockHandler, &mockCache);
+// xPLMessage::namedValueList nvl;
+// mockHandler.sendMessage(xPL_MESSAGE_COMMAND, "pnxs", "hs485", "default1", "config", "list", nvl);
+// mockHandler.activate();
+
+ deviceManagerClass dm(&mockCache);
+ dm.m_sigSendXplMessage.connect(boost::bind(&MockSignalReceiver::handleSignal, &sigrecv, _1));
+
BOOST_CHECK( dm.contains("pnxs-hs485.default1") == false);
dm.processHeartbeat(msg);
BOOST_CHECK( dm.contains("pnxs-hs485.default1") == true);
dm.processRemove(msg);
BOOST_CHECK( dm.contains("pnxs-hs485.default1") == false);
+
+ //mockHandler.verify();
}
BOOST_AUTO_TEST_SUITE_END();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2011-12-19 17:29:24
|
Revision: 600
http://openautomation.svn.sourceforge.net/openautomation/?rev=600&view=rev
Author: j-n-k
Date: 2011-12-19 17:29:18 +0000 (Mon, 19 Dec 2011)
Log Message:
-----------
Changed name of jsonfeedview plugin, fix rendering problems otherd design coming
Modified Paths:
--------------
CometVisu/trunk/visu/designs/discreet_slim/basic.css
CometVisu/trunk/visu/plugins/jsonfeedview/structure_plugin.js
Added Paths:
-----------
CometVisu/trunk/visu/plugins/jsonfeedview/
Removed Paths:
-------------
CometVisu/trunk/visu/plugins/jsonviewer/
Modified: CometVisu/trunk/visu/designs/discreet_slim/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_slim/basic.css 2011-12-19 16:42:30 UTC (rev 599)
+++ CometVisu/trunk/visu/designs/discreet_slim/basic.css 2011-12-19 17:29:18 UTC (rev 600)
@@ -131,7 +131,22 @@
white-space: pre-wrap;
}
+.jsonfeedview {
+ line-height: 2em;
+ text-align:left;
+ overflow:hidden;
+ display:table;
+}
+.jsonfeedview .table {
+ display:table;
+ padding-left: 1em;
+}
+
+.jsonfeedview > div .tr {
+ display:table-row;
+}
+
.green.switchPressed div, .green.switchUnpressed div{
background: transparent url(images/dot_green.png) no-repeat center center;
color: white !important;
Modified: CometVisu/trunk/visu/plugins/jsonfeedview/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js 2011-12-18 21:37:40 UTC (rev 598)
+++ CometVisu/trunk/visu/plugins/jsonfeedview/structure_plugin.js 2011-12-19 17:29:18 UTC (rev 600)
@@ -18,29 +18,35 @@
/**
* This plugins views json-feeds
*/
-
- VisuDesign_Custom.prototype.addCreator('jsonviewer', {
+
+VisuDesign_Custom.prototype.addCreator('jsonfeedview', {
maturity: Maturity.development,
- create: function( page, path ) {
+ create: function (page, path) {
var $p = $(page);
- var ret_val = $('<div class="widget clearfix text" />');
- var style = '';
-
- if( style != '' ) style = 'style="' + style + '"';
- var json = $('<div class="value">-</div>');
+ var viewnum = parseFloat($p.attr('view')) || 1;
+
+ var dummy = $('<div class="widget text" />').appendTo($("body"));
+ dummy.css({'float': 'left', 'visibility': 'hidden', 'display': 'inline'});
+ var h = dummy.outerHeight();
+ var fontsize = parseFloat(dummy.css("font-size"));
+ var margin = parseFloat(dummy.css("marginTop"));
+ var padding = parseFloat(dummy.css("paddingTop"));
+ var minheight = parseFloat(dummy.css("min-height"));
+ dummy.remove();
+
+ var ourheight = ((viewnum-1)*(2*margin+2*padding)+viewnum*minheight)/fontsize;
+ var ret_val = $('<div class="widget clearfix jsonfeedview" style="height:'+ourheight+'em" ><div class="table" /></div>');
+
var refresh = $p.attr('refresh') || 30; // default 30s
+
+ ret_val.data("src", $p.attr('src'));
+ ret_val.data("refresh", refresh);
+ ret_val.data("view", viewnum); // default alles
+ ret_val.data("idx", 0);
- json.data("src", $p.attr('src'));
- json.data("refresh", refresh);
- json.data("view", $p.attr('view')); // default alles
- json.data("idx", 0);
-
- var data = jQuery.extend({}, json.data());
- ret_val.append(json);
-
-
-
- refreshjson(json, data);
+ var data = jQuery.extend({}, ret_val.data());
+
+ refreshjson(ret_val, data);
return ret_val;
},
attributes: {
@@ -54,30 +60,33 @@
function refreshjson(e,data) {
var element = $(e);
+
var tmp = $.getJSON(data.src, function(json) {
- var content = '';
+ var content = '<div class="table">';
var feed = json.responseData.feed;
var feedlength = feed.entries.length;
var viewnum = data.view;
+
if (viewnum > feedlength) { // max is number of entries
viewnum = feedlength;
}
- for (var i=0; i<viewnum; i++) {
+
+ for (var i=0; i<viewnum; i++) { //
var showidx = i + data.idx;
if (showidx >= feedlength) {
showidx = showidx - feedlength;
}
- content += ""+feed.entries[showidx].content + "<br>";
+ content += "<div class ='tr'>"+feed.entries[showidx].content+"</div>";
};
- element.html(content);
+ element.find('.table').replaceWith($(content+"</div")); //html(content);
if (data.idx >= feedlength) {
data.idx=0;
} else {
data.idx = data.idx+1;
}
});
- var tmp2=0;
+
window.setTimeout(function(element, data) {
refreshjson(element, data)
}, data.refresh * 1000, element, data);
-};
\ No newline at end of file
+};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-19 16:42:39
|
Revision: 599
http://openautomation.svn.sourceforge.net/openautomation/?rev=599&view=rev
Author: mayerch
Date: 2011-12-19 16:42:30 +0000 (Mon, 19 Dec 2011)
Log Message:
-----------
Document the used XML structure of the config file.
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 21:37:40 UTC (rev 598)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-19 16:42:30 UTC (rev 599)
@@ -24,8 +24,112 @@
/**
* The JSFLOORPLAN3D object is the single global object created by the
* JSFloorPlan 3D library.
- * @module JSFloorPlan3D
- * @title JS Floor Plan 3D
+ * <p/>
+ * The definition of the config file is:
+ * <pre>
+ * <?xml version="1.0" encoding="UTF-8"?>
+ * <building name="MyBuilding" orientation="45">
+ * <floor name="UG" height="2.44">
+ * <nodes>
+ * <node id="1" x="5.51" y="0" z="0.9" />
+ * ...
+ * </nodes>
+ * <walls>
+ * <wall start="1" end="2" thickness=".24" texture="wall">
+ * <hole id="door01" distance="0.3" width="0.88" paparet="0.0" lintel="0.2" />
+ * ...
+ * </wall>
+ * ...
+ * </walls>
+ * <rooms>
+ * <room name="Bad">
+ * <zone name="all" onclick="alert('Bad')">
+ * <corner nodeid="1" />
+ * ...
+ * </zone>
+ * ...
+ * </room>
+ * </rooms>
+ * </floor>
+ * ...
+ * <textues>
+ * <texture />
+ * ...
+ * </textures>
+ * </building>
+ * </pre>
+ *
+ * The elements used are:
+ * <dl>
+ * <dt><code><b><building></b></code></dt>
+ * <dd>The attribute <code>orientation</code> defines a rotation of the local
+ * coordinate system to north.
+ * <ul>
+ * <li><code>orientation="0"</code> means that the x axis is looking
+ * north and the y axis is looking east.</li>
+ * <li><code>orientation="90"</code> means that the x axis is looking
+ * west and the y axis is looking south.</li>
+ * </ul>
+ * </dd>
+ * <dt><code><b><floor></b></code></dt>
+ * <dd>The <code>floor</code> element contains all relevant information
+ * about one floor of the building. The <code>name</code> attribute
+ * gives this floor its name and the <code>height</code> attribute
+ * defines the (maximum) height.
+ * </dd>
+ * <dt><code><b><nodes></b></code></dt>
+ * <dd>The contianer to contain all <code>node</code> elements of the floor.
+ * </dd>
+ * <dt><code><b><node></b></code></dt>
+ * <dd>A <code>node</code> is a point in x/y space where walls meet. It's the
+ * middle of all walls. If the walls have different thicknesses it might
+ * be necessary got define an offset in the corresponding <code>wall</code>
+ * element.<br />
+ * The <code>z</code> is optional and needed if this point of meeting
+ * walls is lower than the usual wall height. This might be used for a
+ * balustrade.
+ * </dd>
+ * <dt><code><b><walls></b></code></dt>
+ * <dd>The contianer to contain all <code>wall</code> elements of the floor.
+ * </dd>
+ * <dt><code><b><wall></b></code></dt>
+ * <dd>The <code>wall</code> element defines one visible wall that is spanned
+ * between the nodes with the IDs defined by the attributes
+ * <code>start</code> and <code>end</code>. The wall thickness is
+ * defined by the attribute <code>thickness</code>
+ * </dd>
+ * <dt><code><b><hole></b></code></dt>
+ * <dd>The <code>hole</code> element defines a hole in the wall, e.g. for a
+ * door or a window. It starts from the start node after
+ * <code>distance</code> meters and has a width as defined by the
+ * <code>width</code> attribute. The bottom is defined by the
+ * <code>paparet</code> attribute (so it's usually 0.0 for a door) and
+ * the top is defined by the <code>lintel</code> attribute.
+ * </dd>
+ * <dt><code><b><rooms></b></code></dt>
+ * <dd>The contianer of all rooms in this floor.
+ * </dd>
+ * <dt><code><b><room></b></code></dt>
+ * <dd>The contianer to hold all information about a room. The name of the
+ * room is defined by the <code>name</code> attribute.
+ * </dd>
+ * <dt><code><b><zone></b></code></dt>
+ * <dd>A room might consist out of multiple zones. But at least one is needed.
+ * </dd>
+ * <dt><code><b><corner></b></code></dt>
+ * <dd>Defining the corners of the zone by having the node IDs in the
+ * <code>nodeid</code> attribute.
+ * </dd>
+ * <dt><code><b><textues></b></code></dt>
+ * <dd>Container for the <code>texture</code> Elements.
+ * </dd>
+ * <dt><code><b><texture></b></code></dt>
+ * <dd>Currently unsued. In future the definition of the texture files.
+ * </dd>
+ * </dl>
+ *
+ * @module JavaScript FloorPlan 3D
+ * @title JS FloorPlan 3D
* @reqires jQuery, Three.js
*/
if (typeof JSFLOORPLAN3D == 'undefined' || !JSFLOORPLAN3D)
@@ -42,7 +146,7 @@
* @class JSFLOORPLAN3D
* @constructor FOO
*/
-JSFLOORPLAN3D= function () {
+JSFLOORPLAN3D = function () {
////////////////////////////////////////////////////////////////////////////
// Definition of the private variables
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 21:37:46
|
Revision: 598
http://openautomation.svn.sourceforge.net/openautomation/?rev=598&view=rev
Author: mayerch
Date: 2011-12-18 21:37:40 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Sorting that private variables are at the top
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 21:09:00 UTC (rev 597)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 21:37:40 UTC (rev 598)
@@ -26,7 +26,7 @@
* JSFloorPlan 3D library.
* @module JSFloorPlan3D
* @title JS Floor Plan 3D
- * @reqires jQuery
+ * @reqires jQuery, Three.js
*/
if (typeof JSFLOORPLAN3D == 'undefined' || !JSFLOORPLAN3D)
{
@@ -43,9 +43,52 @@
* @constructor FOO
*/
JSFLOORPLAN3D= function () {
+ ////////////////////////////////////////////////////////////////////////////
+ // Definition of the private variables
+
var JSFloorPlan3D = this;
+ var floor;
+ // this array will contain all vertices to show in the svg
+ var vertices = Array();
+ // infos about the building
+ JSFloorPlan3D.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+ var imageCenter = new Object;
+ var noFloorplan = true;
+
/**
+ * Store all nodes. This is an hash of points.
+ * @property floorNodes
+ * @type Hash
+ * @private
+ */
+ var floorNodes = new Object();
+
+ /**
+ * Store all walls. This is an arry of <code>wall</code> objects.
+ * @property floorWalls
+ * @type Array
+ * @private
+ */
+ var floorWalls = new Array();
+
+ /**
+ * Store all rooms. This is an array of arrays of Objects.
+ * @property rooms
+ * @type Array
+ * @private
+ */
+ var rooms = new Array;
+
+ /**
+ * Status if the 3D setup was done.
+ * @property noSetup
+ * @type Bool
+ * @private
+ */
+ var noSetup = true;
+
+ /**
* Constant representing the ID of an ELEMENT_NODE
* @property ELEMENT_NODE
* @private
@@ -55,6 +98,9 @@
*/
var ELEMENT_NODE = 1;
+ ////////////////////////////////////////////////////////////////////////////
+ // Definition of the private methods
+
/**
* Calculate the distance between two cartesian 2D points.
* @method calcLength2D
@@ -137,16 +183,6 @@
return pseudoangle_a - pseudoangle_b;
}
- var floor;
-
- // this array will contain all vertices to show in the svg
- var vertices = Array();
- // infos about the building
- JSFloorPlan3D.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
- var imageCenter = new Object;
-
- var noFloorplan = true;
-
/**
* Parse and create internal structure for the floor plan.
* @method parseXMLFloorPlan
@@ -544,13 +580,6 @@
};
/**
- * Store all nodes. This is an hash of points.
- * @property floorNodes
- * @type Hash
- * @private
- */
- var floorNodes = new Object();
- /**
* Fill the <code>floorNodes</code> structure with the nodes from the
* config file.
* @method parseFloorNodes
@@ -595,14 +624,6 @@
}
/**
- * Store all walls. This is an arry of <code>wall</code> objects.
- * @property floorWalls
- * @type Array
- * @private
- */
- var floorWalls = new Array();
-
- /**
* Fill the <code>floorWalls</code> structure with the wall elements from the
* config file.
* @method parseFloorWalls
@@ -688,13 +709,6 @@
}
/**
- * Store all rooms. This is an array of arrays of Objects.
- * @property rooms
- * @type Array
- * @private
- */
- var rooms = new Array;
- /**
* Fill the <code>rooms</code> array with the room elements from the
* config file.
* @method parseFloorRooms
@@ -754,7 +768,6 @@
}
}
- var noSetup = true;
/**
* Setup the whole scene
* @method setup3D
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 21:09:06
|
Revision: 597
http://openautomation.svn.sourceforge.net/openautomation/?rev=597&view=rev
Author: mayerch
Date: 2011-12-18 21:09:00 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Inital set of comments
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 20:39:17 UTC (rev 596)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 21:09:00 UTC (rev 597)
@@ -26,32 +26,57 @@
* JSFloorPlan 3D library.
* @module JSFloorPlan3D
* @title JS Floor Plan 3D
+ * @reqires jQuery
*/
if (typeof JSFLOORPLAN3D == 'undefined' || !JSFLOORPLAN3D)
{
- /**
+ /*
* The JSFLOORPLAN3D global namespace object. If JSFLOORPLAN3D is already
- * defined, the existing JSFLOORPLAN4D object will not be overwritten so
+ * defined, the existing JSFLOORPLAN3D object will not be overwritten so
* that defined namespaces are preserved.
- * @class JSFLOORPLAN3D
- * @static
*/
var JSFLOORPLAN3D = {};
}
+/**
+ * @class JSFLOORPLAN3D
+ * @constructor FOO
+ */
JSFLOORPLAN3D= function () {
var JSFloorPlan3D = this;
- // don't change anything below:
+
+ /**
+ * Constant representing the ID of an ELEMENT_NODE
+ * @property ELEMENT_NODE
+ * @private
+ * @static
+ * @final
+ * @type Enum
+ */
var ELEMENT_NODE = 1;
- // calculate the distance between two cartesian 2D points
+ /**
+ * Calculate the distance between two cartesian 2D points.
+ * @method calcLength2D
+ * @private
+ * @param {Point} start
+ * @param {Point} end
+ */
function calcLength2D( start, end )
{
return Math.sqrt( (end.x-start.x)*(end.x-start.x) +
(end.y-start.y)*(end.y-start.y) );
}
- // calculate the rotation of a cartesian 2D point around the center
+ /**
+ * calculate the rotation of a cartesian 2D point around the center
+ * @method rotate2D
+ * @private
+ * @param {Float} angle Rotation angle
+ * @param {Point} point
+ * @param {Point} center
+ * @return {Point} new point containing the turned coordinates
+ */
function rotate2D( angle, point, center )
{
var s = Math.sin( angle );
@@ -62,8 +87,17 @@
return ret;
}
- // calculate the rotation of a cartesian 2D point around the center
- // but with given sin and cos of the angle
+ /**
+ * Calculate the rotation of a cartesian 2D point around the center
+ * but with given sin and cos of the angle.
+ * @method rotate2D
+ * @private
+ * @param {Float} s Sin of the rotation angle
+ * @param {Float} c Cos of the rotation angle
+ * @param {Point} point
+ * @param {Point} center
+ * @return {Point} new point containing the turned coordinates
+ */
function rotate2D( s, c, point, center )
{
var ret = new Object;
@@ -72,7 +106,14 @@
return ret;
}
- // calculate the translation of a cartesian 2D point
+ /**
+ * Calculate the translation of a cartesian 2D point.
+ * @method translate2D
+ * @private
+ * @param {Point} point
+ * @param {Point} translation vector
+ * @return {Point} new point containing the turned coordinates
+ */
function translate2D( point, translation )
{
var ret = new Object;
@@ -81,7 +122,14 @@
return ret;
}
- // sort two 2D unit(!) vectors clockwise
+ /**
+ * Sort two 2D unit(!) vectors clockwise
+ * @method vecSort
+ * @private
+ * @param {Point} a Unit vector
+ * @param {Point} b Unit vector
+ * @return {Float} Order
+ */
function vecSort( a, b )
{
var pseudoangle_a = a.y>=0 ? (1-a.x) : (a.x+3);
@@ -99,7 +147,11 @@
var noFloorplan = true;
- //return { parseXMLFloorPlan: function( xmlDoc )
+ /**
+ * Parse and create internal structure for the floor plan.
+ * @method parseXMLFloorPlan
+ * @param {XMLDom} xmlDoc
+ */
JSFloorPlan3D.parseXMLFloorPlan = function( xmlDoc )
{
noFloorplan = false;
@@ -491,7 +543,22 @@
//}
};
+ /**
+ * Store all nodes. This is an hash of points.
+ * @property floorNodes
+ * @type Hash
+ * @private
+ */
var floorNodes = new Object();
+ /**
+ * Fill the <code>floorNodes</code> structure with the nodes from the
+ * config file.
+ * @method parseFloorNodes
+ * @private
+ * @param {XMLDom} node
+ * @param {Float} floorheight The generic height of this floor that might be
+ * overwritten by individual nodes.
+ */
function parseFloorNodes( nodes, floorheight )
{
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -527,7 +594,21 @@
}
}
+ /**
+ * Store all walls. This is an arry of <code>wall</code> objects.
+ * @property floorWalls
+ * @type Array
+ * @private
+ */
var floorWalls = new Array();
+
+ /**
+ * Fill the <code>floorWalls</code> structure with the wall elements from the
+ * config file.
+ * @method parseFloorWalls
+ * @private
+ * @param {XMLDom} nodeGroup
+ */
function parseFloorWalls( nodes )
{
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -535,17 +616,58 @@
node = nodes.childNodes[i];
if (node.nodeType != ELEMENT_NODE) continue;
+ /**
+ * Contain all informations known about a wall.
+ * @class wall
+ * @for JSFLOORPLAN3D
+ */
var wall = new Object;
+ /**
+ * @property start ID of the start node
+ * @type ID-String
+ */
wall.start = node.getAttribute('start' );
+ /**
+ * @property startVertex
+ * @type Array
+ */
wall.startVertex = new Array;
+ /**
+ * @property startOffset Offset at the start node
+ * @type Array
+ */
wall.startOffset = Number( node.getAttribute('startoffset') );
+ /**
+ * @property end ID of the end node
+ * @type ID-String
+ */
wall.end = node.getAttribute('end' );
+ /**
+ * @property endVertex
+ * @type Array
+ */
wall.endVertex = new Array;
+ /**
+ * @property endOffset Offset at the end node
+ * @type Float
+ */
wall.endOffset = Number( node.getAttribute('endoffset' ) );
+ /**
+ * @property thickness Thickness of the wall
+ * @type Float
+ */
wall.thickness = Number( node.getAttribute('thickness' ) );
+ /**
+ * @property texture ID of the texture
+ * @type ID-String
+ */
wall.texture = node.getAttribute('texture' );
if( !wall.texture ) wall.texture = 0;
+ /**
+ * @property holes Array containing all holes in the wall
+ * @type Array
+ */
wall.holes = new Array;
for( var j=0; j < node.childNodes.length; j++ )
{
@@ -565,7 +687,22 @@
}
}
+ /**
+ * Store all rooms. This is an array of arrays of Objects.
+ * @property rooms
+ * @type Array
+ * @private
+ */
var rooms = new Array;
+ /**
+ * Fill the <code>rooms</code> array with the room elements from the
+ * config file.
+ * @method parseFloorRooms
+ * @for JSFLOORPLAN3D
+ * @private
+ * @param {XMLDom} nodeGroup
+ * @param {Integer} floor The floor number.
+ */
function parseFloorRooms( nodes, floor )
{
rooms[floor] = new Array;
@@ -601,6 +738,12 @@
}
//var textures = new Object();
+ /**
+ * Dummy routine to handle textures.
+ * @method parseTextures
+ * @private
+ * @param {XMLDom} nodes
+ */
function parseTextures( nodes )
{
return;
@@ -612,6 +755,11 @@
}
var noSetup = true;
+ /**
+ * Setup the whole scene
+ * @method setup3D
+ * @private
+ */
function setup3D()
{
if( noFloorplan ) return;
@@ -636,6 +784,15 @@
selectChange( 'showFloor' );
}
+ /**
+ * Show the floor plan by updating the relevant view parameters and calling
+ * the render() method
+ * @method show3D
+ * @param {Integer} rotation The direction to look at. 0° = North, 180° =
+ * South
+ * @param {Integer} tilt The amount of tilting the vire. 0° = no tilt,
+ * 90° = bird eyes view
+ */
JSFloorPlan3D.show3D = function( rotation, tilt )
{
if( noSetup ) setup3D();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tho...@us...> - 2011-12-18 20:39:24
|
Revision: 596
http://openautomation.svn.sourceforge.net/openautomation/?rev=596&view=rev
Author: thomas_s
Date: 2011-12-18 20:39:17 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
- now using pragma once for header files
- added boost::signals2 for better seperation of classes
- use xPLMessage (C++-Version) for internal use
Modified Paths:
--------------
xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp
xPLHAL/branches/thomas_s_dev/src/devicemanager.h
xPLHAL/branches/thomas_s_dev/src/globals.h
xPLHAL/branches/thomas_s_dev/src/i_properties.h
xPLHAL/branches/thomas_s_dev/src/i_xplcache.h
xPLHAL/branches/thomas_s_dev/src/log.h
xPLHAL/branches/thomas_s_dev/src/main.cpp
xPLHAL/branches/thomas_s_dev/src/response_codes.h
xPLHAL/branches/thomas_s_dev/src/xhcp.h
xPLHAL/branches/thomas_s_dev/src/xhcpthread.h
xPLHAL/branches/thomas_s_dev/src/xplcache.h
xPLHAL/branches/thomas_s_dev/src/xpldevice.h
xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp
xPLHAL/branches/thomas_s_dev/src/xplhandler.h
xPLHAL/branches/thomas_s_dev/src/xplmessage.h
xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h
Removed Paths:
-------------
xPLHAL/branches/thomas_s_dev/src/i_devicemanager.h
xPLHAL/branches/thomas_s_dev/src/i_xplhandler.h
Modified: xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp 2011-12-18 20:39:17 UTC (rev 596)
@@ -29,12 +29,12 @@
using namespace boost::posix_time;
-deviceManagerClass::deviceManagerClass(IxPLHandler* xplhandler, IxPLCacheClass* xplcache)
-:m_xPL(xplhandler)
-,m_xPLCache(xplcache)
+deviceManagerClass::deviceManagerClass(IxPLCacheClass* xplcache)
+:m_xPLCache(xplcache)
{
}
+
void deviceManagerClass::add( const xPLDevice& device )
{
writeLog("deviceManagerClass::add(" + device.VDI + ")", logLevel::debug);
@@ -90,8 +90,40 @@
}
return retval;
}
+
+void deviceManagerClass::processXplMessage( const xPLMessagePtr message )
+{
+ std::string schema = message->msgClass + std::string(".") + message->msgType;
+ if( message->type != xPL_MESSAGE_COMMAND )
+ {
+ if( "config.list" == schema )
+ {
+ // someone (probably we) have asked for the config list - handle it now...
+ processConfigList( message );
+ } else if( "config.current" == schema )
+ {
+ // someone requested the device to send it's current configuration
+ processCurrentConfig( message );
+ } else if( "config.app" == schema || "config.basic" == schema )
+ {
+ // a new device poped up and wants to be configured
+ processConfigHeartBeat( message );
+ } else if( "hbeat.basic" == schema || "hbeat.app" == schema )
+ {
+ /*
+ If msgSource = MySourceTag Then
+ RaiseEvent AddtoCache("xplhal." & msgSource & ".alive", Now.ToString, False)
+ End If
+ */
+ processHeartbeat( message );
+ } else if( "hbeat.end" == schema )
+ {
+ processRemove( message );
+ }
+ }
+}
-void deviceManagerClass::processConfigList( const xPL_MessagePtr message )
+void deviceManagerClass::processConfigList( const xPLMessagePtr message )
{
std::string source = extractSourceFromXplMessage(message);
xPLDevice device = getDevice( source );
@@ -100,7 +132,9 @@
// A config list turned up that we haven't asked for...
// create a new device...
int interval = 5;
- ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
+ //\TODO: implement xPL_getMessageNamedValue
+// ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
+ ptime expires = calculateExpireTime("5", &interval);
device.VDI = source; // vendor / device / instance = unique id
device.ConfigDone = false; // false = new waiting check, true = sent/not required
device.ConfigMissing = false; // true = no config file, no response from device, false = have/waiting config
@@ -115,14 +149,12 @@
mDeviceMap[device.VDI] = device;
}
- xPL_NameValueListPtr nvList = xPL_getMessageBody( message );
- xPL_NameValuePairPtr nvPair = NULL;
- int nvCount = xPL_getNamedValueCount(nvList);
- for (int nvIndex = 0; nvIndex < nvCount; nvIndex++ ) {
+ for( auto entry : message->namedValues) {
std::string newtag = "config." + source + ".options.";
- nvPair = xPL_getNamedValuePairAt( nvList, nvIndex );
- std::string value = nvPair->itemValue; to_lower( value );
- std::string key = nvPair->itemName ; to_lower( key );
+ std::string value = entry.first;
+ to_lower(value);
+ std::string key = entry.second;
+ to_lower(key);
boost::regex re( "([a-z0-9]{1,16})\\[(\\d{1,3})\\]" );
boost::smatch matches;
if (boost::regex_match(value, matches, re)) {
@@ -145,9 +177,13 @@
else {
// try to get at least the current config
xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
- m_xPL->sendMessage( xPL_MESSAGE_COMMAND,
- xPL_getSourceVendor( message ), xPL_getSourceDeviceID( message ), xPL_getSourceInstanceID( message ),
- "config", "current", command_request );
+ xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
+ message->vendor,
+ message->deviceID,
+ message->instanceID,
+ "config", "current",
+ command_request) );
+ m_sigSendXplMessage(msg);
}
}
@@ -165,7 +201,7 @@
return second_clock::local_time() + minutes( 2* interval + 1 );
}
-void deviceManagerClass::processConfigHeartBeat( const xPL_MessagePtr message )
+void deviceManagerClass::processConfigHeartBeat( const xPLMessagePtr message )
{
std::string source = extractSourceFromXplMessage(message);
@@ -175,7 +211,9 @@
// this handles a new application that identifies itself with a hbeat straight away.
// it must either be storing it's config locally, can't be configured, or is configured somewhere else.
int interval = 5;
- ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
+ //\TODO
+// ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
+ ptime expires = calculateExpireTime("5", &interval);
device.VDI = source; // vendor / device / instance = unique id
device.ConfigDone = false; // false = new waiting check, true = sent/not required
device.ConfigMissing = true; // true = no config file, no response from device, false = have/waiting config
@@ -198,14 +236,18 @@
// ask device for configuration (if haven't asked it before...)
if( !device.ConfigListSent ) {
xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
- m_xPL->sendMessage( xPL_MESSAGE_COMMAND,
- xPL_getSourceVendor( message ), xPL_getSourceDeviceID( message ), xPL_getSourceInstanceID( message ),
- "config", "list", command_request );
+ xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
+ message->vendor,
+ message->deviceID,
+ message->instanceID,
+ "config", "list",
+ command_request) );
+ m_sigSendXplMessage(msg);
mDeviceMap[device.VDI].ConfigListSent = true;
}
}
-void deviceManagerClass::processCurrentConfig( const xPL_MessagePtr message )
+void deviceManagerClass::processCurrentConfig( const xPLMessagePtr message )
{
std::string source = extractSourceFromXplMessage(message);
xPLDevice device = getDevice( source );
@@ -220,16 +262,14 @@
// m_xPLCache->updateEntry( "config." + source + ".expires", timeConverter(calculateExpireTime(device.Interval), false ));
m_xPLCache->updateEntry( "config." + source + ".current", "true", false );
}
-
- xPL_NameValueListPtr nvList = xPL_getMessageBody( message );
- xPL_NameValuePairPtr nvPair = NULL;
- int nvCount = xPL_getNamedValueCount(nvList);
+
std::string multiKey;
- int multiCount = 0;
- for( int nvIndex = 0; nvIndex < nvCount; nvIndex++ ) {
- nvPair = xPL_getNamedValuePairAt( nvList, nvIndex );
- std::string value = nvPair->itemValue; to_lower( value );
- std::string key = nvPair->itemName ; to_lower( key );
+ int multiCount = 0;
+ for( auto entry : message->namedValues) {
+ std::string value = entry.first;
+ to_lower(value);
+ std::string key = entry.second;
+ to_lower(key);
std::string count = m_xPLCache->objectValue( "config." + source + ".options." + key + ".count" );
if( "" != count ) {
if( multiKey == key ) {
@@ -253,14 +293,22 @@
+ xPL_getSourceInstanceID( message );
}
+std::string deviceManagerClass::extractSourceFromXplMessage( xPLMessagePtr message )
+{
+ return std::string(message->vendor + "-"
+ + message->deviceID + "."
+ + message->instanceID);
+}
-void deviceManagerClass::processHeartbeat( xPL_MessagePtr message )
+void deviceManagerClass::processHeartbeat( xPLMessagePtr message )
{
std::string source = extractSourceFromXplMessage(message);
xPLDevice device = getDevice( source );
int interval = 5;
- ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
+ //\TODO
+// ptime expires = calculateExpireTime(xPL_getMessageNamedValue(message, "interval"), &interval);
+ ptime expires = calculateExpireTime("5", &interval);
writeLog( "deviceManagerClass::processHeartbeat("+source+") - found ["+device.VDI+"]", logLevel::debug );
if( "" == device.VDI ) {
@@ -281,9 +329,13 @@
// Throw it a config request anyway, see what turns up..
xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
- m_xPL->sendMessage( xPL_MESSAGE_COMMAND,
- xPL_getSourceVendor( message ), xPL_getSourceDeviceID( message ), xPL_getSourceInstanceID( message ),
- "config", "list" , command_request );
+ xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
+ message->vendor,
+ message->deviceID,
+ message->instanceID,
+ "config", "list",
+ command_request) );
+ m_sigSendXplMessage(msg);
/* // that code below was from the VB - but we don't need it as processConfigList will
// itself send the config.current request...
m_xPL->sendMessage( xPL_MESSAGE_COMMAND,
@@ -295,7 +347,7 @@
}
}
-void deviceManagerClass::processRemove( xPL_MessagePtr message )
+void deviceManagerClass::processRemove( xPLMessagePtr message )
{
std::string source = extractSourceFromXplMessage(message);
@@ -319,7 +371,18 @@
}
if( list.size() > 0 ) {
- m_xPL->sendMessage( xPL_MESSAGE_COMMAND, source, "config", "response", list );
+ size_t marker1 = source.find( "-" );
+ size_t marker2 = source.find( "." );
+ std::string vendor = source.substr( 0, marker1 );
+ std::string device = source.substr( marker1+1, marker2 - (marker1+1) );
+ std::string instance = source.substr( marker2+1 );
+ xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
+ vendor,
+ device,
+ instance,
+ "config", "response",
+ list) );
+ m_sigSendXplMessage(msg);
m_xPLCache->updateEntry( "config." + source + ".configmissing", "false", false );
m_xPLCache->updateEntry( "config." + source + ".waitingconfig", "false", false );
m_xPLCache->updateEntry( "config." + source + ".configdone" , "true" , false ); // FIXME the VB code says "false"...
@@ -379,3 +442,7 @@
return m_xPLCache->childNodes( "config." + configTag ).size() > 0;
}
+boost::signals2::connection deviceManagerClass::connect(const xPLHandler::signal_t::slot_type &subscriber)
+{
+ return m_sigSendXplMessage.connect(subscriber);
+}
Modified: xPLHAL/branches/thomas_s_dev/src/devicemanager.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/devicemanager.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/devicemanager.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,27 +17,22 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DEVICEMANAGER_H
-#define DEVICEMANAGER_H
-
#include <string>
#include <map>
-// this is also including the xPL.h with its data structures:
-#include "xplhandler.h"
-
-class IxPLHandler;
class IxPLCacheClass;
+#include "xplhandler.h"
#include "xplcache.h"
#include "globals.h"
#include "xpldevice.h"
-#include "i_devicemanager.h"
-class deviceManagerClass: public IdeviceManagerClass
+class deviceManagerClass
{
public:
- deviceManagerClass(IxPLHandler* xplhandler, IxPLCacheClass* xplcache);
+ deviceManagerClass(IxPLCacheClass* xplcache);
+
+ boost::signals2::connection connect(const xPLHandler::signal_t::slot_type &subscriber);
/** \brief Looks if the device deviceTag is known. */
bool contains( const std::string& deviceTag ) const;
@@ -54,16 +50,19 @@
/** \brief Returns all known device names */
std::vector<std::string> getAllDeviceNames() const;
+ /** \brief process incoming xpl messages and check if they are for us */
+ void processXplMessage( const xPLMessagePtr message );
+
/** \brief Handle the returned config list that someone (porbably we) have asked for */
- void processConfigList ( const xPL_MessagePtr message );
+ void processConfigList ( const xPLMessagePtr message );
/** \brief Called when a new device poped up and is waiting to be configured */
- void processConfigHeartBeat( const xPL_MessagePtr message );
+ void processConfigHeartBeat( const xPLMessagePtr message );
/** \brief Called when a device sends its configuration */
- void processCurrentConfig ( const xPL_MessagePtr message );
- void processHeartbeat ( const xPL_MessagePtr message );
- void processRemove ( const xPL_MessagePtr message );
+ void processCurrentConfig ( const xPLMessagePtr message );
+ void processHeartbeat ( const xPLMessagePtr message );
+ void processRemove ( const xPLMessagePtr message );
void sendConfigResponse( const std::string& source, const bool removeOldValue );
@@ -73,12 +72,12 @@
private:
/*! \TODO: move to correct class, maybe xplMessage */
std::string extractSourceFromXplMessage( xPL_MessagePtr message );
+ std::string extractSourceFromXplMessage( xPLMessagePtr message );
+
boost::posix_time::ptime calculateExpireTime(int interval);
boost::posix_time::ptime calculateExpireTime(const char* string_interval, int *pInterval = 0);
- IxPLHandler* m_xPL;
IxPLCacheClass* m_xPLCache;
std::map<std::string, xPLDevice> mDeviceMap;
+ xPLHandler::signal_t m_sigSendXplMessage;
};
-
-#endif // DEVICEMANAGER_H
Modified: xPLHAL/branches/thomas_s_dev/src/globals.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/globals.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/globals.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GLOBALS_H
-#define GLOBALS_H
-
#include "boost/filesystem.hpp"
/**
@@ -44,5 +42,3 @@
extern boost::filesystem::path DataFileFolder;
extern boost::filesystem::path ScriptEngineFolder;
extern boost::filesystem::path rulesFolder;
-
-#endif // GLOBALS_H
Deleted: xPLHAL/branches/thomas_s_dev/src/i_devicemanager.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/i_devicemanager.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/i_devicemanager.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,42 +0,0 @@
-/*
- xPLHAL implementation in C++
- Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef IDEVICEMANAGER_H
-#define IDEVICEMANAGER_H
-
-// this is also including the xPL.h with its data structures:
-#include "xplhandler.h"
-
-class IdeviceManagerClass
-{
- public:
- virtual ~IdeviceManagerClass() {}
-
- /** \brief Handle the returned config list that someone (porbably we) have asked for */
- virtual void processConfigList ( const xPL_MessagePtr message ) = 0;
-
- /** \brief Called when a new device poped up and is waiting to be configured */
- virtual void processConfigHeartBeat( const xPL_MessagePtr message ) = 0;
-
- /** \brief Called when a device sends its configuration */
- virtual void processCurrentConfig ( const xPL_MessagePtr message ) = 0;
- virtual void processHeartbeat ( const xPL_MessagePtr message ) = 0;
- virtual void processRemove ( const xPL_MessagePtr message ) = 0;
-};
-
-#endif // IDEVICEMANAGER_H
Modified: xPLHAL/branches/thomas_s_dev/src/i_properties.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/i_properties.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/i_properties.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,5 +1,4 @@
-#ifndef __I_PROPERTIES_H__
-#define __I_PROPERTIES_H__
+#pragma once
//! \brief Properties Interface
class IProperties
@@ -19,5 +18,3 @@
/** \brief deletes property */
virtual void deleteProperty(const std::string& name) = 0;
};
-
-#endif
Modified: xPLHAL/branches/thomas_s_dev/src/i_xplcache.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/i_xplcache.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/i_xplcache.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef IXPLCACHE_H
-#define IXPLCACHE_H
-
#include <string>
#include <vector>
#include <boost/regex.hpp>
@@ -62,5 +60,3 @@
/** \brief Save object cache to file system */
virtual void saveCache( void ) const = 0;
};
-
-#endif // IXPLCACHE_H
Deleted: xPLHAL/branches/thomas_s_dev/src/i_xplhandler.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/i_xplhandler.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/i_xplhandler.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,50 +0,0 @@
-/*
- xPLHAL implementation in C++
- Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#ifndef IXPLHANDLER_H
-#define IXPLHANDLER_H
-
-#include <string>
-
-// this is also including the xPL.h
-#include "xplmessagequeue.h"
-
-/**
- * \brief Handle all xPL communication.
- */
-class IxPLHandler
-{
- public:
- virtual ~IxPLHandler() {}
-
- /** \brief Broadcast one message to the xPL network. */
- virtual void sendBroadcastMessage( const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues ) const = 0;
-
- /** \brief Send a directed message to the xPL network. */
- virtual void sendMessage( const xPL_MessageType type, const std::string& tgtVendor, const std::string& tgtDeviceID,
- const std::string& tgtInstanceID, const std::string& msgClass, const std::string& msgType,
- const xPLMessage::namedValueList& namedValues ) const = 0;
-
- /** \brief Send a directed message to the xPL network. */
- virtual void sendMessage( const xPL_MessageType type, const std::string& VDI,
- const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues ) const = 0;
-
-};
-
-#endif // IXPLHANDLER_H
Modified: xPLHAL/branches/thomas_s_dev/src/log.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/log.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/log.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef LOG_H
-#define LOG_H
-
#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/lexical_cast.hpp>
@@ -119,5 +117,3 @@
doLog( m, level );
}
} static writeLog;
-
-#endif // LOG_H
Modified: xPLHAL/branches/thomas_s_dev/src/main.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/main.cpp 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/main.cpp 2011-12-18 20:39:17 UTC (rev 596)
@@ -107,8 +107,8 @@
xPLCache = new xPLCacheClass;
XHCPServer *xhcpServer = new XHCPServer();
xPL = new xPLHandler( boost::asio::ip::host_name() ); //xPL->start();
- deviceManager = new deviceManagerClass(xPL, xPLCache);
- xPL->setDeviceManager(deviceManager);
+ deviceManager = new deviceManagerClass(xPLCache);
+ xPL->connect(boost::bind(&deviceManagerClass::processXplMessage, deviceManager, _1));
writeLog( "started", logLevel::all );
// force everyone to send their configuration so that we start up to date...
Modified: xPLHAL/branches/thomas_s_dev/src/response_codes.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/response_codes.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/response_codes.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RESPONSE_CODES_H
-#define RESPONSE_CODES_H
-
#include <map>
#include <string>
@@ -108,4 +106,3 @@
std::string operator()( int code ) { return std::string(codes[code]); }
} static responseCode;
-#endif /* RESPONSE_CODES_H */
\ No newline at end of file
Modified: xPLHAL/branches/thomas_s_dev/src/xhcp.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xhcp.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xhcp.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef XHCP_H
-#define XHCP_H
-
#include <boost/asio.hpp>
#include <boost/thread.hpp>
@@ -46,5 +44,3 @@
void handleAccept(socket_ptr sockPtr);
void startAccept();
};
-
-#endif // XHCP_H
Modified: xPLHAL/branches/thomas_s_dev/src/xhcpthread.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xhcpthread.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xhcpthread.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef XHCPTHREAD_H
-#define XHCPTHREAD_H
-
#include <map>
#include <boost/smart_ptr.hpp>
@@ -87,5 +85,3 @@
boost::thread m_thread;
};
-
-#endif // XHCPTHREAD_H
Modified: xPLHAL/branches/thomas_s_dev/src/xplcache.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplcache.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xplcache.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef XPLCACHE_H
-#define XPLCACHE_H
-
#include <string>
#include <vector>
#include <map>
@@ -155,5 +153,3 @@
/** \brief Save object cache to file system */
void saveCache( void ) const;
};
-
-#endif // XPLCACHE_H
Modified: xPLHAL/branches/thomas_s_dev/src/xpldevice.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xpldevice.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xpldevice.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __XPLDEVICE_H__
-#define __XPLDEVICE_H__
-
#include <string>
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -36,5 +34,3 @@
bool Suspended; /** \brief lost heartbeat */
bool Current; /** \brief asked for current */
};
-
-#endif
Modified: xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp 2011-12-18 20:39:17 UTC (rev 596)
@@ -21,7 +21,6 @@
using namespace boost::algorithm;
#include "log.h"
-#include "i_devicemanager.h"
#include "xplhandler.h"
#include "globals.h"
@@ -32,13 +31,12 @@
int xPLHandler::m_refcount = 0;
-xPLHandler::xPLHandler( const std::string& host_name, IdeviceManagerClass* devManager )
+xPLHandler::xPLHandler( const std::string& host_name)
: xPLService(0)
, m_exit_thread(false)
, vendor( "CHRISM" )
, deviceID( "xplhalqt" )
, instanceID( host_name )
-, m_deviceManager(devManager)
{
writeLog( "xPLHandler::xPLHandler( "+host_name+" )", logLevel::debug );
//xPL_setDebugging(TRUE);
@@ -102,11 +100,6 @@
}
}
-void xPLHandler::setDeviceManager(IdeviceManagerClass* devManager)
-{
- m_deviceManager = devManager;
-}
-
void xPLHandler::run()
{
writeLog( "xPLHandler::run()", logLevel::debug );
@@ -164,11 +157,9 @@
std::string result;
/* Source Info */
- result += xPL_getSourceVendor(theMessage);
- result += "-";
- result += xPL_getSourceDeviceID(theMessage);
- result += ".",
- result += xPL_getSourceInstanceID(theMessage);
+ result += xPL_getSourceVendor(theMessage) + std::string("-");
+ result += xPL_getSourceDeviceID(theMessage) + std::string(".");
+ result += xPL_getSourceInstanceID(theMessage);
result += " -> ";
/* Handle various target types */
@@ -179,10 +170,8 @@
result += "XPL-GROUP.";
result += xPL_getTargetGroup(theMessage);
} else {
- result += xPL_getTargetVendor(theMessage);
- result += "-";
- result += xPL_getTargetDeviceID(theMessage);
- result += ".";
+ result += xPL_getTargetVendor(theMessage) + std::string("-");
+ result += xPL_getTargetDeviceID(theMessage) + std::string(".");
result += xPL_getTargetInstanceID(theMessage);
}
}
@@ -211,10 +200,8 @@
result += "] ";
/* Echo Schema Info */
- result += xPL_getSchemaClass(theMessage);
- result += ".";
- result += xPL_getSchemaType(theMessage);
- result += ": ";
+ result += xPL_getSchemaClass(theMessage) + std::string(".");
+ result += xPL_getSchemaType(theMessage) + std::string(": ");
xPL_NameValueListPtr nvList = xPL_getMessageBody(theMessage);
xPL_NameValuePairPtr nvPair = NULL;
@@ -251,36 +238,34 @@
void xPLHandler::handleXPLMessage( xPL_MessagePtr theMessage)
{
printXPLMessage( theMessage );
-
- //RaiseEvent ParseMessageForCache(e.XplMsg)
- //RaiseEvent ParseMessageForRules(e.XplMsg)
-
- std::string schema = xPL_getSchemaClass(theMessage) + std::string(".") + xPL_getSchemaType(theMessage);
- if( xPL_getMessageType(theMessage) != xPL_MESSAGE_COMMAND )
- {
- if( "config.list" == schema )
- {
- // someone (probably we) have asked for the config list - handle it now...
- m_deviceManager->processConfigList( theMessage );
- } else if( "config.current" == schema )
- {
- // someone requested the device to send it's current configuration
- m_deviceManager->processCurrentConfig( theMessage );
- } else if( "config.app" == schema || "config.basic" == schema )
- {
- // a new device poped up and wants to be configured
- m_deviceManager->processConfigHeartBeat( theMessage );
- } else if( "hbeat.basic" == schema || "hbeat.app" == schema )
- {
- /*
- If msgSource = MySourceTag Then
- RaiseEvent AddtoCache("xplhal." & msgSource & ".alive", Now.ToString, False)
- End If
- */
- m_deviceManager->processHeartbeat( theMessage );
- } else if( "hbeat.end" == schema )
- {
- m_deviceManager->processRemove( theMessage );
+
+ xPLMessage::namedValueList values;
+ xPL_NameValueListPtr nvList = xPL_getMessageBody(theMessage);
+ xPL_NameValuePairPtr nvPair = NULL;
+ int nvIndex = 0;
+ int nvCount = xPL_getNamedValueCount(nvList);
+ /* Write Name/Value Pairs out */
+ for (nvIndex = 0; nvIndex < nvCount; nvIndex++) {
+ nvPair = xPL_getNamedValuePairAt(nvList, nvIndex);
+
+ if (nvPair->itemValue != NULL) {
+ values.push_back( std::make_pair( nvPair->itemName, nvPair->itemValue ) );
}
}
+ xPLMessagePtr msg( new xPLMessage( xPL_getMessageType(theMessage),
+ xPL_getSourceVendor(theMessage),
+ xPL_getSourceDeviceID(theMessage),
+ xPL_getSourceInstanceID(theMessage),
+ xPL_getSchemaClass(theMessage),
+ xPL_getSchemaType(theMessage),
+ values) );
+
+ m_sigRceivedXplMessage(msg);
+
}
+
+boost::signals2::connection xPLHandler::connect(const signal_t::slot_type &subscriber)
+{
+ return m_sigRceivedXplMessage.connect(subscriber);
+}
+
Modified: xPLHAL/branches/thomas_s_dev/src/xplhandler.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplhandler.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xplhandler.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,36 +17,32 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-#ifndef XPLHANDLER_H
-#define XPLHANDLER_H
-
#include <vector>
#include <string>
#include <boost/thread.hpp>
#include <boost/thread/locks.hpp>
+#include <boost/signals2/signal.hpp>
// this is also including the xPL.h
-#include "i_xplhandler.h"
#include "xplmessagequeue.h"
-class IdeviceManagerClass;
-
/**
* \brief Handle all xPL communication.
*/
-class xPLHandler: public IxPLHandler
+class xPLHandler
{
/** \brief variable to ensure that the xPL library is only called at the same time... */
//mutable boost::mutex xPLLock;
//typedef boost::lock_guard<boost::mutex> lock_guard;
+ public:
+ typedef boost::signals2::signal<void (xPLMessagePtr)> signal_t;
public:
- xPLHandler( const std::string& host_name, IdeviceManagerClass* devManager = 0);
+ xPLHandler( const std::string& host_name);
~xPLHandler();
- void setDeviceManager(IdeviceManagerClass* devManager);
+ boost::signals2::connection connect(const signal_t::slot_type &subscriber);
void run();
@@ -78,7 +75,5 @@
boost::thread* m_thread;
static int m_refcount;
bool m_exit_thread;
- IdeviceManagerClass* m_deviceManager;
+ signal_t m_sigRceivedXplMessage;
};
-
-#endif // XPLHANDLER_H
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessage.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef XPLMESSAGE_H
-#define XPLMESSAGE_H
-
#include <vector>
#include <string>
#include <boost/shared_ptr.hpp>
@@ -62,5 +60,3 @@
msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues) {}
};
typedef boost::shared_ptr<xPLMessage> xPLMessagePtr;
-
-#endif // XPLMESSAGEQUEUE_H
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h 2011-12-18 16:24:30 UTC (rev 595)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h 2011-12-18 20:39:17 UTC (rev 596)
@@ -1,3 +1,4 @@
+#pragma once
/*
xPLHAL implementation in C++
Copyright (C) 2009 by Christian Mayer - xpl at ChristianMayer dot de
@@ -16,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef XPLMESSAGEQUEUE_H
-#define XPLMESSAGEQUEUE_H
-
#include <vector>
#include <queue>
#include <string>
@@ -50,5 +48,3 @@
\returns Returns 0 if no message available or the message. */
xPL_MessagePtr consume( const xPL_ServicePtr& service );
};
-
-#endif // XPLMESSAGEQUEUE_H
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <net...@us...> - 2011-12-18 16:24:36
|
Revision: 595
http://openautomation.svn.sourceforge.net/openautomation/?rev=595&view=rev
Author: netzkind
Date: 2011-12-18 16:24:30 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
corrected Content-type to application/json
Modified Paths:
--------------
CometVisu/trunk/visu/edit/get_addresses.php
CometVisu/trunk/visu/edit/get_widget_diagram.php
Modified: CometVisu/trunk/visu/edit/get_addresses.php
===================================================================
--- CometVisu/trunk/visu/edit/get_addresses.php 2011-12-18 16:24:02 UTC (rev 594)
+++ CometVisu/trunk/visu/edit/get_addresses.php 2011-12-18 16:24:30 UTC (rev 595)
@@ -39,6 +39,7 @@
);
}
+Header("Content-type: application/json");
print json_encode($arrAdresses);
exit;
Modified: CometVisu/trunk/visu/edit/get_widget_diagram.php
===================================================================
--- CometVisu/trunk/visu/edit/get_widget_diagram.php 2011-12-18 16:24:02 UTC (rev 594)
+++ CometVisu/trunk/visu/edit/get_widget_diagram.php 2011-12-18 16:24:30 UTC (rev 595)
@@ -28,6 +28,7 @@
}
+Header("Content-type: application/json");
print json_encode($arrAdresses);
exit;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <net...@us...> - 2011-12-18 16:24:09
|
Revision: 594
http://openautomation.svn.sourceforge.net/openautomation/?rev=594&view=rev
Author: netzkind
Date: 2011-12-18 16:24:02 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
force the user to select a design on startup; includes a "preview" of the available designs;
changed order of JS-files as compatibility.js needs jquery now.
Modified Paths:
--------------
CometVisu/trunk/visu/designs/alaska/basic.css
CometVisu/trunk/visu/designs/alaska_slim/basic.css
CometVisu/trunk/visu/designs/discreet/basic.css
CometVisu/trunk/visu/designs/discreet_sand/basic.css
CometVisu/trunk/visu/designs/discreet_slim/basic.css
CometVisu/trunk/visu/designs/pure/basic.css
CometVisu/trunk/visu/edit_config.html
CometVisu/trunk/visu/index.html
CometVisu/trunk/visu/lib/compatibility.js
CometVisu/trunk/visu/lib/templateengine.js
Added Paths:
-----------
CometVisu/trunk/visu/designs/design_preview.html
CometVisu/trunk/visu/edit/get_designs.php
CometVisu/trunk/visu/media/arrow.png
Modified: CometVisu/trunk/visu/designs/alaska/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska/basic.css 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/designs/alaska/basic.css 2011-12-18 16:24:02 UTC (rev 594)
@@ -384,3 +384,34 @@
width: 100%;
text-decoration: none;
}
+
+
+/* styles for the preview */
+div#demo_1, div#demo_2, div#demo_3 {
+ width: 100%;
+}
+
+div#demo_container {
+ position: relative;
+}
+
+div#demo_1 {
+ height: 90px;
+ background: #fff;
+ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
+ background: -moz-linear-gradient(top, #fff, #ededed);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
+ z-index: 1;
+}
+
+div#demo_2 {
+ height: 2px;
+ position: absolute;
+ top: 44px;
+ z-index: 2;
+ background-color: #686868;
+}
+
+div#demo_3 {
+ display: none;
+}
\ No newline at end of file
Modified: CometVisu/trunk/visu/designs/alaska_slim/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska_slim/basic.css 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/designs/alaska_slim/basic.css 2011-12-18 16:24:02 UTC (rev 594)
@@ -364,3 +364,33 @@
width: 100%;
text-decoration: none;
}
+
+/* styles for the preview */
+div#demo_1, div#demo_2, div#demo_3 {
+ width: 100%;
+}
+
+div#demo_container {
+ position: relative;
+}
+
+div#demo_1 {
+ height: 90px;
+ background: #fff;
+ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
+ background: -moz-linear-gradient(top, #fff, #ededed);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
+ z-index: 1;
+}
+
+div#demo_2 {
+ height: 2px;
+ position: absolute;
+ top: 44px;
+ z-index: 2;
+ background-color: #686868;
+}
+
+div#demo_3 {
+ display: none;
+}
Added: CometVisu/trunk/visu/designs/design_preview.html
===================================================================
--- CometVisu/trunk/visu/designs/design_preview.html (rev 0)
+++ CometVisu/trunk/visu/designs/design_preview.html 2011-12-18 16:24:02 UTC (rev 594)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CometVisu Design-Preview</title>
+ <link rel="icon" href="../icon/comet_16x16_000000.png" type="image/png" />
+ <meta name="viewport" content="width=260, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, webkit-user-select: none" />
+ <meta name="apple-mobile-web-app-capable" content="yes" />
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
+ <script src="../lib/jquery.js" type="text/javascript"></script>
+ <script src="../lib/compatibility.js" type="text/javascript"></script>
+ </head>
+ <body>
+ <div id="demo_container" style="width: 100%; height: 90px;">
+ <div id="demo_1"></div>
+ <div id="demo_2"></div>
+ <div id="demo_3"></div>
+ </div>
+
+ <script type="text/javascript">
+ var design = $.getUrlVar("design");
+ $( 'head' ).append( '<link rel="stylesheet" type="text/css" href="' + design + '/basic.css" />' );
+ $( 'head' ).append( '<link rel="stylesheet" type="text/css" href="' + design + '/mobile.css" media="only screen and (max-device-width: 480px)" />' );
+ </script>
+ </body>
+</html>
Modified: CometVisu/trunk/visu/designs/discreet/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet/basic.css 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/designs/discreet/basic.css 2011-12-18 16:24:02 UTC (rev 594)
@@ -387,4 +387,23 @@
padding: 2px;
background-color: #fee;
opacity: 0.80;
-}
\ No newline at end of file
+}
+
+/* styles for the preview */
+div#demo_1, div#demo_2 {
+ width: 100%;
+ height: 44px;
+}
+
+div#demo_1 {
+ background-color: black;
+}
+
+div#demo_2 {
+ height: 2px;
+ background-color: white;
+}
+
+div#demo_3 {
+ background-color: #1d1d1d;
+}
Modified: CometVisu/trunk/visu/designs/discreet_sand/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_sand/basic.css 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/designs/discreet_sand/basic.css 2011-12-18 16:24:02 UTC (rev 594)
@@ -380,4 +380,22 @@
padding: 2px;
background-color: #fee;
opacity: 0.80;
-}
\ No newline at end of file
+}
+
+/* styles for the preview */
+div#demo_1, div#demo_2, div#demo_3 {
+ width: 100%;
+ height: 30px;
+}
+
+div#demo_1 {
+ background-color: #165d7e;
+}
+
+div#demo_2 {
+ background-color: #cfc8b5;
+}
+
+div#demo_3 {
+ background-color: #baaf98;
+}
Modified: CometVisu/trunk/visu/designs/discreet_slim/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_slim/basic.css 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/designs/discreet_slim/basic.css 2011-12-18 16:24:02 UTC (rev 594)
@@ -380,4 +380,24 @@
padding: 2px;
background-color: #fee;
opacity: 0.80;
-}
\ No newline at end of file
+}
+
+/* styles for the preview */
+div#demo_1, div#demo_2 {
+ width: 100%;
+ height: 44px;
+}
+
+div#demo_1 {
+ background-color: black;
+}
+
+div#demo_2 {
+ height: 2px;
+ background-color: white;
+}
+
+div#demo_3 {
+ background-color: #1d1d1d;
+}
+
Modified: CometVisu/trunk/visu/designs/pure/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/basic.css 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/designs/pure/basic.css 2011-12-18 16:24:02 UTC (rev 594)
@@ -466,3 +466,23 @@
border: #ff8000 1px solid;
}
+/* styles for the preview */
+div#demo_1, div#demo_2, div#demo_3 {
+ width: 100%;
+}
+
+div#demo_1 {
+ height: 30px;
+ background-color: black;
+}
+
+div#demo_2 {
+ height: 2px;
+ background-color: #ff8000;
+}
+
+div#demo_3 {
+ height: 58px;
+ background-color: black;
+}
+
Added: CometVisu/trunk/visu/edit/get_designs.php
===================================================================
--- CometVisu/trunk/visu/edit/get_designs.php (rev 0)
+++ CometVisu/trunk/visu/edit/get_designs.php 2011-12-18 16:24:02 UTC (rev 594)
@@ -0,0 +1,24 @@
+<?php
+define('FOLDER_DESIGNS', "../designs/");
+
+$arrDesigns = array();
+
+if (false !== ($handle = opendir(FOLDER_DESIGNS))) {
+ while (false !== ($strFile = readdir($handle))) {
+ if ($strFile == "." || $strFile == "..") {
+ continue;
+ }
+
+ if (true === is_dir(FOLDER_DESIGNS . $strFile) && true === file_exists(FOLDER_DESIGNS . $strFile . "/basic.css")) {
+ $arrDesigns[] = $strFile;
+ }
+ }
+}
+
+sort($arrDesigns);
+
+Header("Content-type: application/json");
+print json_encode($arrDesigns);
+exit;
+
+?>
Modified: CometVisu/trunk/visu/edit_config.html
===================================================================
--- CometVisu/trunk/visu/edit_config.html 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/edit_config.html 2011-12-18 16:24:02 UTC (rev 594)
@@ -8,8 +8,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="edit/style_edit.css" />
<link rel="stylesheet" type="text/css" href="edit/jquery-ui.css" />
- <script src="lib/compatibility.js" type="text/javascript"></script>
<script src="lib/jquery.js" type="text/javascript"></script>
+ <script src="lib/compatibility.js" type="text/javascript"></script>
<script src="lib/jquery-ui.js" type="text/javascript"></script>
<script src="lib/scrollable.js" type="text/javascript"></script>
<script src="lib/cometvisu-client.js" type="text/javascript"></script>
@@ -43,7 +43,6 @@
<div id="bottom" class="loading">
<hr />
<div class="footer"></div>
- </div>
</div>
<div id="addMaster">
Modified: CometVisu/trunk/visu/index.html
===================================================================
--- CometVisu/trunk/visu/index.html 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/index.html 2011-12-18 16:24:02 UTC (rev 594)
@@ -8,8 +8,8 @@
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0; webkit-user-select: none;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
- <script src="lib/compatibility.js" type="text/javascript"></script>
<script src="lib/jquery.js" type="text/javascript"></script>
+ <script src="lib/compatibility.js" type="text/javascript"></script>
<script src="lib/jquery-ui.js" type="text/javascript"></script>
<script src="lib/scrollable.js" type="text/javascript"></script>
<script src="lib/cometvisu-client.js" type="text/javascript"></script>
@@ -34,7 +34,6 @@
<div id="bottom" class="loading">
<hr />
<div class="footer"></div>
- </div>
</div>
<div id="loading" style="text-align: center; width: 200px; height: 30px; margin: auto;">
Loading ...
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/lib/compatibility.js 2011-12-18 16:24:02 UTC (rev 594)
@@ -134,4 +134,24 @@
}
}
-sprintf = sprintfWrapper.init;
\ No newline at end of file
+sprintf = sprintfWrapper.init;
+
+/**
+ * be able to access GET-Params
+ */
+$.extend({
+ getUrlVars: function(){
+ var vars = [], hash;
+ var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+ for(var i = 0; i < hashes.length; i++)
+ {
+ hash = hashes[i].split('=');
+ vars.push(hash[0]);
+ vars[hash[0]] = hash[1];
+ }
+ return vars;
+ },
+ getUrlVar: function(name){
+ return $.getUrlVars()[name];
+ }
+});
\ No newline at end of file
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2011-12-18 15:59:22 UTC (rev 593)
+++ CometVisu/trunk/visu/lib/templateengine.js 2011-12-18 16:24:02 UTC (rev 594)
@@ -35,28 +35,16 @@
}
visu.user = 'demo_user'; // example for setting a user
-$.extend({
- getUrlVars: function(){
- var vars = [], hash;
- var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- for(var i = 0; i < hashes.length; i++)
- {
- hash = hashes[i].split('=');
- vars.push(hash[0]);
- vars[hash[0]] = hash[1];
- }
- return vars;
- },
- getUrlVar: function(name){
- return $.getUrlVars()[name];
- }
-});
-
var configSuffix = "";
if ($.getUrlVar("config")) {
configSuffix = "_" + $.getUrlVar("config");
}
+var clientDesign = "";
+if ($.getUrlVar("design")) {
+ clientDesign = $.getUrlVar("design");
+}
+
if (typeof forceReload == "undefined") {
var forceReload = false;
}
@@ -88,22 +76,16 @@
}
$(document).ready(function() {
- // get the data once the page was loaded
- $.ajaxSetup({cache: !forceReload});
- window.setTimeout("$.get( 'visu_config" + configSuffix + ".xml', parseXML );", 200);
+
+ // only load the config and stuff if a design was specified
+ if (clientDesign != "") {
+ // get the data once the page was loaded
+ $.ajaxSetup({cache: !forceReload});
+ window.setTimeout("$.get( 'visu_config" + configSuffix + ".xml', parseXML );", 200);
+ } else {
+ selectDesign();
+ }
- // disable text selection - it's annoying on a touch screen!
- /*
- * Now in the CSS!
- if($.browser.mozilla)
- {//Firefox
- $('body').css('MozUserSelect','none');
- } else if($.browser.msie) {//IE
- $(document).bind('selectstart',function(){return false;});
- } else {//Opera, etc.
- $(document).mousedown(function(){return false;});
- }
- */
} );
$(window).unload(function() {
@@ -173,9 +155,8 @@
// erst mal den Cache für AJAX-Requests wieder aktivieren
$.ajaxSetup({cache: true});
- var design = $( 'pages', xml ).attr('design');
- $( 'head' ).append( '<link rel="stylesheet" type="text/css" href="designs/' + design + '/basic.css" />' );
- $( 'head' ).append( '<link rel="stylesheet" type="text/css" href="designs/' + design + '/mobile.css" media="only screen and (max-device-width: 480px)" />' );
+ $( 'head' ).append( '<link rel="stylesheet" type="text/css" href="designs/' + clientDesign + '/basic.css" />' );
+ $( 'head' ).append( '<link rel="stylesheet" type="text/css" href="designs/' + clientDesign + '/mobile.css" media="only screen and (max-device-width: 480px)" />' );
// start with the plugins
var pluginsToLoad = 0;
@@ -427,3 +408,61 @@
$(this).data('interval', setInterval( function(){refreshAction(target, src);}, refresh ) );
}
}
+
+
+function selectDesign() {
+
+ $body = $("body");
+
+ $("body > *").hide();
+ $body.css({backgroundColor: "black"});
+
+ $div = $("<div id=\"designSelector\" />");
+ $div.css({background: "#808080", width: "400px", color: "white", margin: "auto", padding: "0.5em"});
+ $div.html("Loading ...");
+
+ $body.append($div);
+
+ $.getJSON("edit/get_designs.php", function(data) {
+ $div.empty();
+
+ $div.append("<h1>Please select design</h1>");
+ $div.append("<p>The Location/URL will change after you have chosen your design. Please bookmark the new URL if you do not want to select the design every time.</p>");
+
+ $.each(data, function(i, element) {
+ var $myDiv = $("<div />");
+
+ $myDiv.css({cursor: "pointer", padding: "0.5em 1em", borderBottom: "1px solid black", margin: "auto", width: "262px", position: "relative"});
+
+ $myDiv.append("<div style=\"font-weight: bold; margin: 1em 0 .5em;\">Design: " + element + "</div>");
+ $myDiv.append("<iframe src=\"designs/design_preview.html?design=" + element + "\" width=\"160\" height=\"90\" border=\"0\" scrolling=\"auto\" frameborder=\"0\" style=\"z-index: 1;\"></iframe>");
+ $myDiv.append("<img width=\"60\" height=\"30\" src=\"media/arrow.png\" alt=\"select\" border=\"0\" style=\"margin: 60px 10px 10px 30px;\"/>");
+
+ $div.append($myDiv);
+
+ var $tDiv = $("<div />");
+ $tDiv.css({background: "transparent", position: "absolute", height: "90px", width: "160px", zIndex: 2})
+ var pos = $myDiv.find("iframe").position();
+ $tDiv.css({left: pos.left + "px", top: pos.top + "px"});
+ $myDiv.append($tDiv);
+
+ $myDiv.hover(function() {
+ // over
+ $myDiv.css({background: "#bbbbbb"});
+ },
+ function() {
+ // out
+ $myDiv.css({background: "transparent"});
+ });
+
+ $myDiv.click(function() {
+ if (document.location.search == "") {
+ document.location.href = document.location.href + "?design=" + element;
+ } else {
+ document.location.href = document.location.href + "&design=" + element;
+ }
+ })
+
+ })
+ })
+}
\ No newline at end of file
Added: CometVisu/trunk/visu/media/arrow.png
===================================================================
(Binary files differ)
Property changes on: CometVisu/trunk/visu/media/arrow.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 15:59:30
|
Revision: 593
http://openautomation.svn.sourceforge.net/openautomation/?rev=593&view=rev
Author: mayerch
Date: 2011-12-18 15:59:22 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Whitespace (only!) fix
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 15:45:26 UTC (rev 592)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 15:59:22 UTC (rev 593)
@@ -31,7 +31,7 @@
{
/**
* The JSFLOORPLAN3D global namespace object. If JSFLOORPLAN3D is already
- * defined, the existing JSFLOORPLAN3D object will not be overwritten so
+ * defined, the existing JSFLOORPLAN4D object will not be overwritten so
* that defined namespaces are preserved.
* @class JSFLOORPLAN3D
* @static
@@ -40,665 +40,661 @@
}
JSFLOORPLAN3D= function () {
-var JSFloorPlan3D = this;
-// don't change anything below:
-var ELEMENT_NODE = 1;
-
-// calculate the distance between two cartesian 2D points
-function calcLength2D( start, end )
-{
- return Math.sqrt( (end.x-start.x)*(end.x-start.x) +
- (end.y-start.y)*(end.y-start.y) );
-}
-
-// calculate the rotation of a cartesian 2D point around the center
-function rotate2D( angle, point, center )
-{
- var s = Math.sin( angle );
- var c = Math.cos( angle );
- var ret = new Object;
- ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
- ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
- return ret;
-}
-
-// calculate the rotation of a cartesian 2D point around the center
-// but with given sin and cos of the angle
-function rotate2D( s, c, point, center )
-{
- var ret = new Object;
- ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
- ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
- return ret;
-}
-
-// calculate the translation of a cartesian 2D point
-function translate2D( point, translation )
-{
- var ret = new Object;
- ret.x = point.x + translation.x;
- ret.y = point.y + translation.y;
- return ret;
-}
-
-// sort two 2D unit(!) vectors clockwise
-function vecSort( a, b )
-{
- var pseudoangle_a = a.y>=0 ? (1-a.x) : (a.x+3);
- var pseudoangle_b = b.y>=0 ? (1-b.x) : (b.x+3);
- return pseudoangle_a - pseudoangle_b;
-}
-
-//function loadFloorplan()
-//{
-// $.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
-//}
-var floor;
-
-// this array will contain all vertices to show in the svg
-var vertices = Array();
-// infos about the building
-JSFloorPlan3D.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
-var imageCenter = new Object;
-
-var noFloorplan = true;
-
-//return { parseXMLFloorPlan: function( xmlDoc )
-JSFloorPlan3D.parseXMLFloorPlan = function( xmlDoc )
-{
- noFloorplan = false;
-
- var floorCount = -1;
- var heightOfGround = 0; // the base level of the current floor
+ var JSFloorPlan3D = this;
+ // don't change anything below:
+ var ELEMENT_NODE = 1;
- // basic check if the document seems right
- // this could be avoided if the XML file would be validated
- // with a DTD
- var building;
- if( 'building' == xmlDoc.documentElement.tagName )
- building = xmlDoc.documentElement;
- else
- return alert( "ERROR: Not a valid floor plan! " +
- "Expected: 'building', found '" + xmlDoc.documentElement.tagName + "'" );
-
- // now we are sure to have a sensible file
- // => iterate over all floors
- for( var i=0; i < building.childNodes.length; i++ )
+ // calculate the distance between two cartesian 2D points
+ function calcLength2D( start, end )
{
- floor = building.childNodes[i];
- if (floor.nodeType != ELEMENT_NODE) continue;
-
- if( floor.tagName == 'textures' )
- {
- parseTextures( floor );
- continue;
- }
-
- if( floor.tagName != 'floor' )
- return alert( "ERROR: Not a valid floor plan! " +
- "Expected: 'floor', found '" + floor.tagName + "'" );
+ return Math.sqrt( (end.x-start.x)*(end.x-start.x) +
+ (end.y-start.y)*(end.y-start.y) );
+ }
+
+ // calculate the rotation of a cartesian 2D point around the center
+ function rotate2D( angle, point, center )
+ {
+ var s = Math.sin( angle );
+ var c = Math.cos( angle );
+ var ret = new Object;
+ ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
+ ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
+ return ret;
+ }
+
+ // calculate the rotation of a cartesian 2D point around the center
+ // but with given sin and cos of the angle
+ function rotate2D( s, c, point, center )
+ {
+ var ret = new Object;
+ ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
+ ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
+ return ret;
+ }
+
+ // calculate the translation of a cartesian 2D point
+ function translate2D( point, translation )
+ {
+ var ret = new Object;
+ ret.x = point.x + translation.x;
+ ret.y = point.y + translation.y;
+ return ret;
+ }
+
+ // sort two 2D unit(!) vectors clockwise
+ function vecSort( a, b )
+ {
+ var pseudoangle_a = a.y>=0 ? (1-a.x) : (a.x+3);
+ var pseudoangle_b = b.y>=0 ? (1-b.x) : (b.x+3);
+ return pseudoangle_a - pseudoangle_b;
+ }
+
+ var floor;
+
+ // this array will contain all vertices to show in the svg
+ var vertices = Array();
+ // infos about the building
+ JSFloorPlan3D.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+ var imageCenter = new Object;
+
+ var noFloorplan = true;
+
+ //return { parseXMLFloorPlan: function( xmlDoc )
+ JSFloorPlan3D.parseXMLFloorPlan = function( xmlDoc )
+ {
+ noFloorplan = false;
- floorCount++;
- JSFloorPlan3D.buildingProperties.floor[floorCount] = {};
+ var floorCount = -1;
+ var heightOfGround = 0; // the base level of the current floor
- var floorName = floor.getAttribute('name');
- JSFloorPlan3D.buildingProperties.floor[floorCount].name = floorName;
+ // basic check if the document seems right
+ // this could be avoided if the XML file would be validated
+ // with a DTD
+ var building;
+ if( 'building' == xmlDoc.documentElement.tagName )
+ building = xmlDoc.documentElement;
+ else
+ return alert( "ERROR: Not a valid floor plan! " +
+ "Expected: 'building', found '" + xmlDoc.documentElement.tagName + "'" );
- var floorheight = Number( floor.getAttribute('height') );
- JSFloorPlan3D.buildingProperties.floor[floorCount].height = floorheight;
- JSFloorPlan3D.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
-
- var floorWallsStart = 0;// floorWalls.length; <- not defined here yet...
-
- // iterate over the content of this floor
- for( var j=0; j < floor.childNodes.length; j++ )
+ // now we are sure to have a sensible file
+ // => iterate over all floors
+ for( var i=0; i < building.childNodes.length; i++ )
{
- floorNode = floor.childNodes[j];
- if (floorNode.nodeType != ELEMENT_NODE) continue;
-
- switch( floorNode.tagName )
+ floor = building.childNodes[i];
+ if (floor.nodeType != ELEMENT_NODE) continue;
+
+ if( floor.tagName == 'textures' )
{
- case 'nodes':
- parseFloorNodes( floorNode, floorheight );
- break;
-
- case 'walls':
- parseFloorWalls( floorNode );
- break;
-
- case 'rooms':
- parseFloorRooms( floorNode, floorCount );
- break;
- }
- }
-
- // now the content of the floor is stored in easily
- // accessable objects
- // => derive the necessary information
-
- // group all elements on this floor
- var Object3D = new THREE.Object3D();
-
- // add the information to each node to which nodes it's connected to
- for( var j = floorWallsStart; j < floorWalls.length; j++ )
- {
- // note: the ID is shifted by one to avoid an ID of zero
- // as that wouldn't allow me anymore to distinguish
- // start and stop
- floorNodes[ floorWalls[j].start ].neighbour.push( j+1 );
- floorNodes[ floorWalls[j].end ].neighbour.push( -j-1 );
- }
-
- var nodeGroup = new THREE.Object3D(); nodeGroup.name = 'nodeGroup';
- for( var id in floorNodes )
- {
- // calculate the vectors showing to the neighbours
- var vectors = new Array();
- var start = floorNodes[id];
+ parseTextures( floor );
+ continue;
+ }
- // show them on request as spheres
- var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
- sphere.position = new THREE.Vector3( start.x, start.y, heightOfGround );
- nodeGroup.add(sphere);
+ if( floor.tagName != 'floor' )
+ return alert( "ERROR: Not a valid floor plan! " +
+ "Expected: 'floor', found '" + floor.tagName + "'" );
- for( var j=0; j<floorNodes[id].neighbour.length; j++ )
- {
- var vec = new Object;
- vec.id = floorNodes[id].neighbour[j];
- var end;
- if( vec.id < 0 )
- end = floorNodes[ floorWalls[ -vec.id-1 ].start ];
- else
- end = floorNodes[ floorWalls[ vec.id-1 ].end ];
-
- length = calcLength2D( start, end );
- vec.x = (end.x - start.x) / length;
- vec.y = (end.y - start.y) / length;
- vectors.push( vec );
- }
-
- // sort them clockwise
- vectors.sort( vecSort );
-
- // calculate the cutting points of the walls at this node id
- for( var j=0; j<vectors.length; j++ )
- {
- var jj = (j+1) % vectors.length;
- var wj = Math.abs(vectors[j ].id)-1;
- var wjj = Math.abs(vectors[jj].id)-1;
- var dj = floorWalls[wj ].thickness/2;
- var djj = floorWalls[wjj].thickness/2;
- if( floorWalls[wj ].startOffset && vectors[j ].id > 0 )
- dj += floorWalls[wj].startOffset;
- if( floorWalls[wj ].endOffset && vectors[j ].id < 0 )
- dj += floorWalls[wj].endOffset;
- if( floorWalls[wjj].startOffset && vectors[jj].id > 0 )
- djj += -floorWalls[wjj].startOffset;
- if( floorWalls[wjj].endOffset && vectors[jj].id < 0 )
- djj += -floorWalls[wjj].endOffset;
-
- vertex = new Object;
- vertex.x = vectors[j].x*djj + vectors[jj].x*dj;
- vertex.y = vectors[j].y*djj + vectors[jj].y*dj;
- var l = vectors[j].x*vectors[jj].y - vectors[j].y*vectors[jj].x;
- if( Math.abs( l ) < 1e-5 )
- { // the angle between the two vectors is exactly 180°
- // i.e. a straight wall...
- if( Math.abs( dj - djj ) < 1e-5 )
- { // at least the walls have the same thickness...
- vertex.x = start.x - vectors[j].y*dj;
- vertex.y = start.y + vectors[j].x*dj;
- } else {
- alert( "ERROR: A straight wall with different thicknesses " +
- "is currently not supported!" );
- // but we still try our best...
- vertex.x = start.x - vectors[j].y*(dj+djj)/2;
- vertex.y = start.y + vectors[j].x*(dj+djj)/2;
- }
- } else {
- vertex.x = start.x + vertex.x / l;
- vertex.y = start.y + vertex.y / l;
- }
-
- if( vectors[j ].id < 0 )
- floorWalls[wj ].startVertex.push( vertices.length );
- else
- floorWalls[wj ].endVertex.push( vertices.length );
-
- if( 1 == vectors.length )
- {
- var additional = new Object;
- additional.x = 2 * start.x - vertex.x;
- additional.y = 2 * start.y - vertex.y;
- vertices.push( additional );
- }
-
- if( vectors[jj].id < 0 )
- floorWalls[wjj].startVertex.push( vertices.length );
- else
- floorWalls[wjj].endVertex.push( vertices.length );
-
- vertices.push( vertex );
- }
- } // end for( var id in floorNodes )
- Object3D.add( nodeGroup );
-
- // show walls
- var lineGroup = new THREE.Object3D(); lineGroup.name = 'lineGroup';
- var wallGroup = new THREE.Object3D(); wallGroup.name = 'wallGroup';
- for( var j = floorWallsStart; j<floorWalls.length; j++ )
- {
- var vs = floorNodes[ floorWalls[j].start ];
- var ve = floorNodes[ floorWalls[j].end ];
- var lineGeo = new THREE.Geometry();
- lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( vs.x, vs.y, heightOfGround ) ) );
- lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( ve.x, ve.y, heightOfGround ) ) );
- lineGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
+ floorCount++;
+ JSFloorPlan3D.buildingProperties.floor[floorCount] = {};
- var s1 = vertices[ floorWalls[j].startVertex[0] ];
- var e1 = vertices[ floorWalls[j].endVertex [0] ];
- var s2 = vertices[ floorWalls[j].startVertex[1] ];
- var e2 = vertices[ floorWalls[j].endVertex [1] ];
+ var floorName = floor.getAttribute('name');
+ JSFloorPlan3D.buildingProperties.floor[floorCount].name = floorName;
- // check that the start and end points aren't twisted
- var v1 = new Object; v1.x = s1.x-s2.x; v1.y = s1.y-s2.y;
- var v2 = new Object; v2.x = e1.x-s2.x; v2.y = e1.y-s2.y;
- var v3 = new Object; v3.x = e1.x-e2.x; v3.y = e1.y-e2.y;
- if( (v1.x*v2.y - v1.y*v2.x)*(v2.x*v3.y - v2.y*v3.x) > 0 )
+ var floorheight = Number( floor.getAttribute('height') );
+ JSFloorPlan3D.buildingProperties.floor[floorCount].height = floorheight;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+
+ var floorWallsStart = 0;// floorWalls.length; <- not defined here yet...
+
+ // iterate over the content of this floor
+ for( var j=0; j < floor.childNodes.length; j++ )
{
- e1 = vertices [ floorWalls[j].endVertex[1] ];
- e2 = vertices [ floorWalls[j].endVertex[0] ];
+ floorNode = floor.childNodes[j];
+ if (floorNode.nodeType != ELEMENT_NODE) continue;
+
+ switch( floorNode.tagName )
+ {
+ case 'nodes':
+ parseFloorNodes( floorNode, floorheight );
+ break;
+
+ case 'walls':
+ parseFloorWalls( floorNode );
+ break;
+
+ case 'rooms':
+ parseFloorRooms( floorNode, floorCount );
+ break;
+ }
}
- var sm = floorNodes[ floorWalls[j].start ];
- var em = floorNodes[ floorWalls[j].end ];
- var sh = floorNodes[ floorWalls[j].start ].z ;
- var eh = floorNodes[ floorWalls[j].end ].z ;
- var wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
- var geometry = new THREE.Geometry();
- var normal1 = new THREE.Vector3(sm.y-em.y,-sm.x+em.x,0); // fixme? normalize
- var normal2 = new THREE.Vector3(1,0,0);
+ // now the content of the floor is stored in easily
+ // accessable objects
+ // => derive the necessary information
- var sourrounding = [ new poly2tri.Point(0,0), new poly2tri.Point(0,1), new poly2tri.Point(1,1), new poly2tri.Point(1,0) ];
- sourrounding[1].startEndMarker = 'start';
- sourrounding[2].startEndMarker = 'end';
- var holesToAdd = [];
+ // group all elements on this floor
+ var Object3D = new THREE.Object3D();
- if( floorWalls[j].holes.length )
+ // add the information to each node to which nodes it's connected to
+ for( var j = floorWallsStart; j < floorWalls.length; j++ )
{
- var holes = floorWalls[j].holes;
- for( var h = 0; h < holes.length; h++ )
+ // note: the ID is shifted by one to avoid an ID of zero
+ // as that wouldn't allow me anymore to distinguish
+ // start and stop
+ floorNodes[ floorWalls[j].start ].neighbour.push( j+1 );
+ floorNodes[ floorWalls[j].end ].neighbour.push( -j-1 );
+ }
+
+ var nodeGroup = new THREE.Object3D(); nodeGroup.name = 'nodeGroup';
+ for( var id in floorNodes )
+ {
+ // calculate the vectors showing to the neighbours
+ var vectors = new Array();
+ var start = floorNodes[id];
+
+ // show them on request as spheres
+ var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
+ sphere.position = new THREE.Vector3( start.x, start.y, heightOfGround );
+ nodeGroup.add(sphere);
+
+ for( var j=0; j<floorNodes[id].neighbour.length; j++ )
{
- var wallLength = calcLength2D( sm, em );
- var fLeft = holes[h].distance / wallLength;
- var fRight = (holes[h].distance + holes[h].width) / wallLength;
- if( fLeft <= 0.0 ) fLeft = 0.001; //// FIXME - actually the config file is bad. Leave at least 1mm wall
- if( fRight >= 1.0 ) fRight = 0.999; //// FIXME - actually the config file is bad. Leave at least 1mm wall
- var lintel = (sh - holes[h].lintel) / sh;
- var paparet = holes[h].paparet / sh;
- if( 1 == lintel )
- {
- // not a hole, the sourrounding goes to the groud...
-
- if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
-
- sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
- continue;
+ var vec = new Object;
+ vec.id = floorNodes[id].neighbour[j];
+ var end;
+ if( vec.id < 0 )
+ end = floorNodes[ floorWalls[ -vec.id-1 ].start ];
+ else
+ end = floorNodes[ floorWalls[ vec.id-1 ].end ];
+
+ length = calcLength2D( start, end );
+ vec.x = (end.x - start.x) / length;
+ vec.y = (end.y - start.y) / length;
+ vectors.push( vec );
+ }
+
+ // sort them clockwise
+ vectors.sort( vecSort );
+
+ // calculate the cutting points of the walls at this node id
+ for( var j=0; j<vectors.length; j++ )
+ {
+ var jj = (j+1) % vectors.length;
+ var wj = Math.abs(vectors[j ].id)-1;
+ var wjj = Math.abs(vectors[jj].id)-1;
+ var dj = floorWalls[wj ].thickness/2;
+ var djj = floorWalls[wjj].thickness/2;
+ if( floorWalls[wj ].startOffset && vectors[j ].id > 0 )
+ dj += floorWalls[wj].startOffset;
+ if( floorWalls[wj ].endOffset && vectors[j ].id < 0 )
+ dj += floorWalls[wj].endOffset;
+ if( floorWalls[wjj].startOffset && vectors[jj].id > 0 )
+ djj += -floorWalls[wjj].startOffset;
+ if( floorWalls[wjj].endOffset && vectors[jj].id < 0 )
+ djj += -floorWalls[wjj].endOffset;
+
+ vertex = new Object;
+ vertex.x = vectors[j].x*djj + vectors[jj].x*dj;
+ vertex.y = vectors[j].y*djj + vectors[jj].y*dj;
+ var l = vectors[j].x*vectors[jj].y - vectors[j].y*vectors[jj].x;
+ if( Math.abs( l ) < 1e-5 )
+ { // the angle between the two vectors is exactly 180°
+ // i.e. a straight wall...
+ if( Math.abs( dj - djj ) < 1e-5 )
+ { // at least the walls have the same thickness...
+ vertex.x = start.x - vectors[j].y*dj;
+ vertex.y = start.y + vectors[j].x*dj;
+ } else {
+ alert( "ERROR: A straight wall with different thicknesses " +
+ "is currently not supported!" );
+ // but we still try our best...
+ vertex.x = start.x - vectors[j].y*(dj+djj)/2;
+ vertex.y = start.y + vectors[j].x*(dj+djj)/2;
}
- if( 0 == paparet )
+ } else {
+ vertex.x = start.x + vertex.x / l;
+ vertex.y = start.y + vertex.y / l;
+ }
+
+ if( vectors[j ].id < 0 )
+ floorWalls[wj ].startVertex.push( vertices.length );
+ else
+ floorWalls[wj ].endVertex.push( vertices.length );
+
+ if( 1 == vectors.length )
{
- // not a hole, the sourrounding goes to the groud...
-
- // lintel == 1 can't happen, it's checked in the if clause above
-
- sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
- continue;
+ var additional = new Object;
+ additional.x = 2 * start.x - vertex.x;
+ additional.y = 2 * start.y - vertex.y;
+ vertices.push( additional );
}
- holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
+ if( vectors[jj].id < 0 )
+ floorWalls[wjj].startVertex.push( vertices.length );
+ else
+ floorWalls[wjj].endVertex.push( vertices.length );
+
+ vertices.push( vertex );
}
- } // if( floorWalls[j].holes.length )
- var swctx = new poly2tri.SweepContext( sourrounding.slice(0) ); // pass a copy of sourrounding
- for( var htA = 0; htA < holesToAdd.length; htA++ )
- swctx.AddHole( holesToAdd[htA] );
+ } // end for( var id in floorNodes )
+ Object3D.add( nodeGroup );
- // Do the triangulation - FIXME: handle exceptions, don't ignore them...
- try {
- poly2tri.sweep.Triangulate(swctx);
- }catch(err){}
-
- // mark all points to make sure that we don't need to double vertices
- for( var tp = 0; tp < swctx.point_count(); tp++ )
- swctx.GetPoint( tp ).id = tp;
-
- // translate poly2tri triangles to THREE.js faces:
- var p2tF = [];
- $.each(swctx.GetTriangles(), function(idx, val) {
- p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
- });
-
- Tvertices = swctx.points_;
- Tfaces = p2tF;
- var wall1vertices = [];
- var wall2vertices = [];
- var sId, eId;
- for( var v = 0; v < Tvertices.length; v++ )
+ // show walls
+ var lineGroup = new THREE.Object3D(); lineGroup.name = 'lineGroup';
+ var wallGroup = new THREE.Object3D(); wallGroup.name = 'wallGroup';
+ for( var j = floorWallsStart; j<floorWalls.length; j++ )
{
- // project s1, e1 and s2, e2 onto line sm->em
- var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
- var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var e1f = 1-((e1.x-sm.x)*(em.x-sm.x) + (e1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var s2f = 1-((s2.x-sm.x)*(em.x-sm.x) + (s2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var e2f = 1-((e2.x-sm.x)*(em.x-sm.x) + (e2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var vs = floorNodes[ floorWalls[j].start ];
+ var ve = floorNodes[ floorWalls[j].end ];
+ var lineGeo = new THREE.Geometry();
+ lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( vs.x, vs.y, heightOfGround ) ) );
+ lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( ve.x, ve.y, heightOfGround ) ) );
+ lineGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
- var tv = Tvertices[v];
- var tvx1 = Math.min( 1.0, Math.max( 0.0, (tv.x - s1f) * (e1f - s1f) ) ); // map between s1 and e1
- var tvx2 = Math.min( 1.0, Math.max( 0.0, (tv.x - s2f) * (e2f - s2f) ) ); // map between s2 and e2
- var x1 = s1.x * tvx1 + e1.x * (1 - tvx1);
- var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
- var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
- var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
- //console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
- var z = heightOfGround + sh*tv.y;
- if( wallSideOrder > 0 )
+ var s1 = vertices[ floorWalls[j].startVertex[0] ];
+ var e1 = vertices[ floorWalls[j].endVertex [0] ];
+ var s2 = vertices[ floorWalls[j].startVertex[1] ];
+ var e2 = vertices[ floorWalls[j].endVertex [1] ];
+
+ // check that the start and end points aren't twisted
+ var v1 = new Object; v1.x = s1.x-s2.x; v1.y = s1.y-s2.y;
+ var v2 = new Object; v2.x = e1.x-s2.x; v2.y = e1.y-s2.y;
+ var v3 = new Object; v3.x = e1.x-e2.x; v3.y = e1.y-e2.y;
+ if( (v1.x*v2.y - v1.y*v2.x)*(v2.x*v3.y - v2.y*v3.x) > 0 )
{
- wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
- wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
- } else {
- wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
- wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
+ e1 = vertices [ floorWalls[j].endVertex[1] ];
+ e2 = vertices [ floorWalls[j].endVertex[0] ];
}
- if( 'startEndMarker' in tv )
+ var sm = floorNodes[ floorWalls[j].start ];
+ var em = floorNodes[ floorWalls[j].end ];
+ var sh = floorNodes[ floorWalls[j].start ].z ;
+ var eh = floorNodes[ floorWalls[j].end ].z ;
+ var wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
+ var geometry = new THREE.Geometry();
+
+ var normal1 = new THREE.Vector3(sm.y-em.y,-sm.x+em.x,0); // fixme? normalize
+ var normal2 = new THREE.Vector3(1,0,0);
+
+ var sourrounding = [ new poly2tri.Point(0,0), new poly2tri.Point(0,1), new poly2tri.Point(1,1), new poly2tri.Point(1,0) ];
+ sourrounding[1].startEndMarker = 'start';
+ sourrounding[2].startEndMarker = 'end';
+ var holesToAdd = [];
+
+ if( floorWalls[j].holes.length )
{
- if( 'start' == tv.startEndMarker )
+ var holes = floorWalls[j].holes;
+ for( var h = 0; h < holes.length; h++ )
{
- sId = wall1vertices.length - 1;
+ var wallLength = calcLength2D( sm, em );
+ var fLeft = holes[h].distance / wallLength;
+ var fRight = (holes[h].distance + holes[h].width) / wallLength;
+ if( fLeft <= 0.0 ) fLeft = 0.001; //// FIXME - actually the config file is bad. Leave at least 1mm wall
+ if( fRight >= 1.0 ) fRight = 0.999; //// FIXME - actually the config file is bad. Leave at least 1mm wall
+ var lintel = (sh - holes[h].lintel) / sh;
+ var paparet = holes[h].paparet / sh;
+ if( 1 == lintel )
+ {
+ // not a hole, the sourrounding goes to the groud...
+
+ if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
+
+ sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
+ continue;
+ }
+ if( 0 == paparet )
+ {
+ // not a hole, the sourrounding goes to the groud...
+
+ // lintel == 1 can't happen, it's checked in the if clause above
+
+ sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
+ continue;
+ }
+
+ holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
+ }
+ } // if( floorWalls[j].holes.length )
+ var swctx = new poly2tri.SweepContext( sourrounding.slice(0) ); // pass a copy of sourrounding
+ for( var htA = 0; htA < holesToAdd.length; htA++ )
+ swctx.AddHole( holesToAdd[htA] );
+
+ // Do the triangulation - FIXME: handle exceptions, don't ignore them...
+ try {
+ poly2tri.sweep.Triangulate(swctx);
+ }catch(err){}
+
+ // mark all points to make sure that we don't need to double vertices
+ for( var tp = 0; tp < swctx.point_count(); tp++ )
+ swctx.GetPoint( tp ).id = tp;
+
+ // translate poly2tri triangles to THREE.js faces:
+ var p2tF = [];
+ $.each(swctx.GetTriangles(), function(idx, val) {
+ p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
+ });
+
+ Tvertices = swctx.points_;
+ Tfaces = p2tF;
+ var wall1vertices = [];
+ var wall2vertices = [];
+ var sId, eId;
+ for( var v = 0; v < Tvertices.length; v++ )
+ {
+ // project s1, e1 and s2, e2 onto line sm->em
+ var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
+ var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e1f = 1-((e1.x-sm.x)*(em.x-sm.x) + (e1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var s2f = 1-((s2.x-sm.x)*(em.x-sm.x) + (s2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e2f = 1-((e2.x-sm.x)*(em.x-sm.x) + (e2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+
+ var tv = Tvertices[v];
+ var tvx1 = Math.min( 1.0, Math.max( 0.0, (tv.x - s1f) * (e1f - s1f) ) ); // map between s1 and e1
+ var tvx2 = Math.min( 1.0, Math.max( 0.0, (tv.x - s2f) * (e2f - s2f) ) ); // map between s2 and e2
+ var x1 = s1.x * tvx1 + e1.x * (1 - tvx1);
+ var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
+ var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
+ var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
+ //console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
+ var z = heightOfGround + sh*tv.y;
+ if( wallSideOrder > 0 )
+ {
+ wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
+ wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
} else {
- eId = wall1vertices.length - 1;
+ wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
+ wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
}
+ if( 'startEndMarker' in tv )
+ {
+ if( 'start' == tv.startEndMarker )
+ {
+ sId = wall1vertices.length - 1;
+ } else {
+ eId = wall1vertices.length - 1;
+ }
+ }
}
- }
- var wall1verticesLength = wall1vertices.length;
- geometry.vertices = wall1vertices.concat( wall2vertices );
- var s1id = sId, s2id = sId + wall1verticesLength, e1id = eId, e2id = eId + wall1verticesLength;
- //geometry.faces = Tfaces;
- for( var f = 0; f < Tfaces.length; f++ )
- {
- var uv_a1 = new THREE.UV( Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
- var uv_b1 = new THREE.UV( Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
- var uv_c1 = new THREE.UV( Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
- var uv_a2 = new THREE.UV( 1-Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
- var uv_b2 = new THREE.UV( 1-Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
- var uv_c2 = new THREE.UV( 1-Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
+ var wall1verticesLength = wall1vertices.length;
+ geometry.vertices = wall1vertices.concat( wall2vertices );
+ var s1id = sId, s2id = sId + wall1verticesLength, e1id = eId, e2id = eId + wall1verticesLength;
+ //geometry.faces = Tfaces;
+ for( var f = 0; f < Tfaces.length; f++ )
+ {
+ var uv_a1 = new THREE.UV( Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
+ var uv_b1 = new THREE.UV( Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
+ var uv_c1 = new THREE.UV( Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
+ var uv_a2 = new THREE.UV( 1-Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
+ var uv_b2 = new THREE.UV( 1-Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
+ var uv_c2 = new THREE.UV( 1-Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
+
+ // wall side 1
+ geometry.faces.push( Tfaces[f] );
+ geometry.faceVertexUvs[0].push([ uv_a1, uv_b1, uv_c1 ]);
+ // wall side 2
+ geometry.faces.push(new THREE.Face3(Tfaces[f].c+wall1verticesLength, Tfaces[f].b+wall1verticesLength, Tfaces[f].a+wall1verticesLength ) );
+ geometry.faceVertexUvs[0].push([ uv_a2, uv_b2, uv_c2 ]);
+ }
+ // wall top
+ var mId = geometry.vertices.length;
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround )));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround+sh)));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround )));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround+eh)));
+ geometry.faces.push(new THREE.Face3(s1id, s2id, mId+1) );
+ geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
- // wall side 1
- geometry.faces.push( Tfaces[f] );
- geometry.faceVertexUvs[0].push([ uv_a1, uv_b1, uv_c1 ]);
- // wall side 2
- geometry.faces.push(new THREE.Face3(Tfaces[f].c+wall1verticesLength, Tfaces[f].b+wall1verticesLength, Tfaces[f].a+wall1verticesLength ) );
- geometry.faceVertexUvs[0].push([ uv_a2, uv_b2, uv_c2 ]);
- }
- // wall top
- var mId = geometry.vertices.length;
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround+sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround+eh)));
- geometry.faces.push(new THREE.Face3(s1id, s2id, mId+1) );
- geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
-
- for( var e = 0; e < sourrounding.length; e++ )
- {
- var id1 = sourrounding[e ].id;
- var id2 = sourrounding[(e+1)%sourrounding.length].id;
- geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
- geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
- }
-
- // hole sides
- for( var hta = 0; hta < holesToAdd.length; hta++ )
- {
- for( var e = 0; e < holesToAdd[hta].length; e++ )
+ for( var e = 0; e < sourrounding.length; e++ )
{
- var id1 = holesToAdd[hta][e ].id;
- var id2 = holesToAdd[hta][(e+1)%sourrounding.length].id;
+ var id1 = sourrounding[e ].id;
+ var id2 = sourrounding[(e+1)%sourrounding.length].id;
geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
}
- }
+
+ // hole sides
+ for( var hta = 0; hta < holesToAdd.length; hta++ )
+ {
+ for( var e = 0; e < holesToAdd[hta].length; e++ )
+ {
+ var id1 = holesToAdd[hta][e ].id;
+ var id2 = holesToAdd[hta][(e+1)%sourrounding.length].id;
+ geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
+ geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
+ }
+ }
+
+ geometry.computeFaceNormals();
+ var mesh = new THREE.Mesh(geometry, cubeMaterial);
+ mesh.castShadow = true;
+ mesh.receiveShadow = true;
+ wallGroup.add(mesh);
+ } // end for( j=0; j<floorWalls.length; j++ )
+ Object3D.add( lineGroup );
+ Object3D.add( wallGroup );
- geometry.computeFaceNormals();
- var mesh = new THREE.Mesh(geometry, cubeMaterial);
- mesh.castShadow = true;
- mesh.receiveShadow = true;
- wallGroup.add(mesh);
- } // end for( j=0; j<floorWalls.length; j++ )
- Object3D.add( lineGroup );
- Object3D.add( wallGroup );
+ JSFloorPlan3D.buildingProperties.floor[floorCount].Object3D = Object3D;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].lineGroup = lineGroup;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].wallGroup = wallGroup;
+ JSFloorPlan3D.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
+
+ heightOfGround += floorheight;
+ } // end floor
- JSFloorPlan3D.buildingProperties.floor[floorCount].Object3D = Object3D;
- JSFloorPlan3D.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
- JSFloorPlan3D.buildingProperties.floor[floorCount].lineGroup = lineGroup;
- JSFloorPlan3D.buildingProperties.floor[floorCount].wallGroup = wallGroup;
- JSFloorPlan3D.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
+ JSFloorPlan3D.buildingProperties.x_center = (JSFloorPlan3D.buildingProperties.x_max - JSFloorPlan3D.buildingProperties.x_min) / 2;
+ JSFloorPlan3D.buildingProperties.y_center = (JSFloorPlan3D.buildingProperties.y_max - JSFloorPlan3D.buildingProperties.y_min) / 2;
+ imageCenter.x = JSFloorPlan3D.buildingProperties.x_center;
+ imageCenter.y = JSFloorPlan3D.buildingProperties.y_center;
+ imageCenter.z = JSFloorPlan3D.buildingProperties.z_max / 2;
- heightOfGround += floorheight;
- } // end floor
-
- JSFloorPlan3D.buildingProperties.x_center = (JSFloorPlan3D.buildingProperties.x_max - JSFloorPlan3D.buildingProperties.x_min) / 2;
- JSFloorPlan3D.buildingProperties.y_center = (JSFloorPlan3D.buildingProperties.y_max - JSFloorPlan3D.buildingProperties.y_min) / 2;
- imageCenter.x = JSFloorPlan3D.buildingProperties.x_center;
- imageCenter.y = JSFloorPlan3D.buildingProperties.y_center;
- imageCenter.z = JSFloorPlan3D.buildingProperties.z_max / 2;
-
- JSFloorPlan3D.show3D( 35*Math.PI/180, 30*Math.PI/180 );
-//}
-};
-
-var floorNodes = new Object();
-function parseFloorNodes( nodes, floorheight )
-{
- for( var i=0; i < nodes.childNodes.length; i++ )
+ JSFloorPlan3D.show3D( 35*Math.PI/180, 30*Math.PI/180 );
+ //}
+ };
+
+ var floorNodes = new Object();
+ function parseFloorNodes( nodes, floorheight )
{
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var id = node.getAttribute('id');
- var point = new Object;
- point.x = Number( node.getAttribute('x') );
- point.y = Number( node.getAttribute('y') );
- point.z = Number( node.hasAttribute('z') ? node.getAttribute('z') : floorheight );
- point.neighbour = new Array;
-
- floorNodes[id] = point;
-
- if( undefined == JSFloorPlan3D.buildingProperties.x_min )
+ for( var i=0; i < nodes.childNodes.length; i++ )
{
- JSFloorPlan3D.buildingProperties.x_min = point.x;
- JSFloorPlan3D.buildingProperties.x_max = point.x;
- JSFloorPlan3D.buildingProperties.y_min = point.y;
- JSFloorPlan3D.buildingProperties.y_max = point.y;
- JSFloorPlan3D.buildingProperties.z_min = point.z;
- JSFloorPlan3D.buildingProperties.z_max = point.z;
- } else {
- if( JSFloorPlan3D.buildingProperties.x_min > point.x ) JSFloorPlan3D.buildingProperties.x_min = point.x;
- if( JSFloorPlan3D.buildingProperties.x_max < point.x ) JSFloorPlan3D.buildingProperties.x_max = point.x;
- if( JSFloorPlan3D.buildingProperties.y_min > point.y ) JSFloorPlan3D.buildingProperties.y_min = point.y;
- if( JSFloorPlan3D.buildingProperties.y_max < point.y ) JSFloorPlan3D.buildingProperties.y_max = point.y;
- if( JSFloorPlan3D.buildingProperties.z_min > point.z ) JSFloorPlan3D.buildingProperties.z_min = point.z;
- if( JSFloorPlan3D.buildingProperties.z_max < point.z ) JSFloorPlan3D.buildingProperties.z_max = point.z;
+ node = nodes.childNodes[i];
+ if (node.nodeType != ELEMENT_NODE) continue;
+
+ var id = node.getAttribute('id');
+ var point = new Object;
+ point.x = Number( node.getAttribute('x') );
+ point.y = Number( node.getAttribute('y') );
+ point.z = Number( node.hasAttribute('z') ? node.getAttribute('z') : floorheight );
+ point.neighbour = new Array;
+
+ floorNodes[id] = point;
+
+ if( undefined == JSFloorPlan3D.buildingProperties.x_min )
+ {
+ JSFloorPlan3D.buildingProperties.x_min = point.x;
+ JSFloorPlan3D.buildingProperties.x_max = point.x;
+ JSFloorPlan3D.buildingProperties.y_min = point.y;
+ JSFloorPlan3D.buildingProperties.y_max = point.y;
+ JSFloorPlan3D.buildingProperties.z_min = point.z;
+ JSFloorPlan3D.buildingProperties.z_max = point.z;
+ } else {
+ if( JSFloorPlan3D.buildingProperties.x_min > point.x ) JSFloorPlan3D.buildingProperties.x_min = point.x;
+ if( JSFloorPlan3D.buildingProperties.x_max < point.x ) JSFloorPlan3D.buildingProperties.x_max = point.x;
+ if( JSFloorPlan3D.buildingProperties.y_min > point.y ) JSFloorPlan3D.buildingProperties.y_min = point.y;
+ if( JSFloorPlan3D.buildingProperties.y_max < point.y ) JSFloorPlan3D.buildingProperties.y_max = point.y;
+ if( JSFloorPlan3D.buildingProperties.z_min > point.z ) JSFloorPlan3D.buildingProperties.z_min = point.z;
+ if( JSFloorPlan3D.buildingProperties.z_max < point.z ) JSFloorPlan3D.buildingProperties.z_max = point.z;
+ }
}
}
-}
-
-var floorWalls = new Array();
-function parseFloorWalls( nodes )
-{
- for( var i=0; i < nodes.childNodes.length; i++ )
+
+ var floorWalls = new Array();
+ function parseFloorWalls( nodes )
{
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var wall = new Object;
- wall.start = node.getAttribute('start' );
- wall.startVertex = new Array;
- wall.startOffset = Number( node.getAttribute('startoffset') );
- wall.end = node.getAttribute('end' );
- wall.endVertex = new Array;
- wall.endOffset = Number( node.getAttribute('endoffset' ) );
- wall.thickness = Number( node.getAttribute('thickness' ) );
- wall.texture = node.getAttribute('texture' );
- if( !wall.texture ) wall.texture = 0;
-
- wall.holes = new Array;
- for( var j=0; j < node.childNodes.length; j++ )
+ for( var i=0; i < nodes.childNodes.length; i++ )
{
- var hole = node.childNodes[j];
- if (hole.nodeType != ELEMENT_NODE) continue;
-
- var thishole = new Object;
- thishole.id = hole.getAttribute('id');
- thishole.distance = Number( hole.getAttribute('distance') );
- thishole.width = Number( hole.getAttribute('width' ) );
- thishole.paparet = Number( hole.getAttribute('paparet' ) );
- thishole.lintel = Number( hole.getAttribute('lintel' ) );
- wall.holes.push( thishole );
+ node = nodes.childNodes[i];
+ if (node.nodeType != ELEMENT_NODE) continue;
+
+ var wall = new Object;
+ wall.start = node.getAttribute('start' );
+ wall.startVertex = new Array;
+ wall.startOffset = Number( node.getAttribute('startoffset') );
+ wall.end = node.getAttribute('end' );
+ wall.endVertex = new Array;
+ wall.endOffset = Number( node.getAttribute('endoffset' ) );
+ wall.thickness = Number( node.getAttribute('thickness' ) );
+ wall.texture = node.getAttribute('texture' );
+ if( !wall.texture ) wall.texture = 0;
+
+ wall.holes = new Array;
+ for( var j=0; j < node.childNodes.length; j++ )
+ {
+ var hole = node.childNodes[j];
+ if (hole.nodeType != ELEMENT_NODE) continue;
+
+ var thishole = new Object;
+ thishole.id = hole.getAttribute('id');
+ thishole.distance = Number( hole.getAttribute('distance') );
+ thishole.width = Number( hole.getAttribute('width' ) );
+ thishole.paparet = Number( hole.getAttribute('paparet' ) );
+ thishole.lintel = Number( hole.getAttribute('lintel' ) );
+ wall.holes.push( thishole );
+ }
+
+ floorWalls[floorWalls.length] = wall;
}
-
- floorWalls[floorWalls.length] = wall;
}
-}
-
-var rooms = new Array;
-function parseFloorRooms( nodes, floor )
-{
- rooms[floor] = new Array;
- for( var i=0; i < nodes.childNodes.length; i++ )
+
+ var rooms = new Array;
+ function parseFloorRooms( nodes, floor )
{
- var node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var room = new Object;
- room.name = node.getAttribute('name');
- room.zones = new Array;
-
- for( var j=0; j < node.childNodes.length; j++ )
+ rooms[floor] = new Array;
+ for( var i=0; i < nodes.childNodes.length; i++ )
{
- var zone = node.childNodes[j];
- if (zone.nodeType != ELEMENT_NODE) continue;
-
- var thiszone = new Object;
- thiszone.onclick = zone.getAttribute('onclick');
- thiszone.name = zone.getAttribute('name' );
- thiszone.corners = new Array;
-
- for( var k=0; k < zone.childNodes.length; k++ )
+ var node = nodes.childNodes[i];
+ if (node.nodeType != ELEMENT_NODE) continue;
+
+ var room = new Object;
+ room.name = node.getAttribute('name');
+ room.zones = new Array;
+
+ for( var j=0; j < node.childNodes.length; j++ )
{
- var corner = zone.childNodes[k];
- if (corner.nodeType != ELEMENT_NODE) continue;
- thiszone.corners.push( corner.getAttribute('nodeid') );
+ var zone = node.childNodes[j];
+ if (zone.nodeType != ELEMENT_NODE) continue;
+
+ var thiszone = new Object;
+ thiszone.onclick = zone.getAttribute('onclick');
+ thiszone.name = zone.getAttribute('name' );
+ thiszone.corners = new Array;
+
+ for( var k=0; k < zone.childNodes.length; k++ )
+ {
+ var corner = zone.childNodes[k];
+ if (corner.nodeType != ELEMENT_NODE) continue;
+ thiszone.corners.push( corner.getAttribute('nodeid') );
+ }
+ room.zones.push( thiszone );
}
- room.zones.push( thiszone );
+ rooms[floor].push( room );
}
- rooms[floor].push( room );
}
-}
-
-//var textures = new Object();
-function parseTextures( nodes )
-{
- return;
- for( var i=0; i < nodes.childNodes.length; i++ )
+
+ //var textures = new Object();
+ function parseTextures( nodes )
{
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
+ return;
+ for( var i=0; i < nodes.childNodes.length; i++ )
+ {
+ node = nodes.childNodes[i];
+ if (node.nodeType != ELEMENT_NODE) continue;
+ }
}
-}
-
-var noSetup = true;
-function setup3D()
-{
- if( noFloorplan ) return;
- noSetup = false;
- scene.add( JSFloorPlan3D.buildingProperties.Object3D );
-
- var showFloor = showStates.showFloor;
-
- ///////////
- scene.add(sunLight);
- //scene.add(pointLight);
- scene.add(ambientLight);
- //scene.add( camera );
- var $container = $('#top_level');
- // attach the render-supplied DOM element
- $container.append(renderer.domElement);
-
- // Init after the scene was set up
- selectChange( 'showNodes' );
- selectChange( 'showWallLines' );
- selectChange( 'showFloor' );
-}
-
-JSFloorPlan3D.show3D = function( rotation, tilt )
-{
- if( noSetup ) setup3D();
-
- // set up camera
- var cx = -Math.cos(rotation) * Math.cos(tilt);
- var cy = Math.sin(rotation) * Math.cos(tilt);
- var cz = Math.sin(tilt);
- var heightOfGround = JSFloorPlan3D.buildingProperties.floor[ showStates.showFloor ].heightOfGround;
- var target = new THREE.Vector3( JSFloorPlan3D.buildingProperties.x_center, JSFloorPlan3D.buildingProperties.y_center, heightOfGround);
- camera.up = new THREE.Vector3( Math.cos(rotation) * Math.sin(tilt), -Math.sin(rotation) * Math.sin(tilt), Math.cos(tilt) );
- camera.position = new THREE.Vector3( cx*dist + JSFloorPlan3D.buildingProperties.x_center, cy*dist + JSFloorPlan3D.buildingProperties.y_center, dist * cz + heightOfGround);
- camera.lookAt( target );
- pointLight.position = camera.position;
-
- // set up sun
- var sx = -Math.cos(lightDirection) * Math.cos(lightHeight);
- var sy = Math.sin(lightDirection) * Math.cos(lightHeight);
- var sz = Math.sin(lightHeight);
- sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance );
- sunLight.intensity = lightStrength / 100.0;
- sunLightViewLine.geometry.vertices[0].position = sunLight.position;
- sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
- sunLightViewLine.geometry.__dirtyVertices = true;
-
- if( showStates.showLightView )
+ var noSetup = true;
+ function setup3D()
{
- camera.position = sunLight.position;
- camera.lookAt( sunLight.target.position );
+ if( noFloorplan ) return;
+ noSetup = false;
+
+ scene.add( JSFloorPlan3D.buildingProperties.Object3D );
+
+ var showFloor = showStates.showFloor;
+
+ ///////////
+ scene.add(sunLight);
+ //scene.add(pointLight);
+ scene.add(ambientLight);
+ //scene.add( camera );
+ var $container = $('#top_level');
+ // attach the render-supplied DOM element
+ $container.append(renderer.domElement);
+
+ // Init after the scene was set up
+ selectChange( 'showNodes' );
+ selectChange( 'showWallLines' );
+ selectChange( 'showFloor' );
}
- // update opacity
- cubeMaterial.opacity = showStates.fillOpacity;
-
- // update color
- switch( showStates.fillColor )
+ JSFloorPlan3D.show3D = function( rotation, tilt )
{
- case 'black':
- cubeMaterial.color.setRGB( 0.1, 0.1, 0.1 );
- break;
- case 'grey':
- cubeMaterial.color.setRGB( 0.5, 0.5, 0.5 );
- break;
- case 'white':
- cubeMaterial.color.setRGB( 1.0, 1.0, 1.0 );
- break;
- case 'blue':
- cubeMaterial.color.setRGB( 0.0, 0.0, 0.8 );
- break;
- case 'red':
- cubeMaterial.color.setRGB( 0.8, 0.0, 0.0 );
- break;
- case 'green':
- cubeMaterial.color.setRGB( 0.0, 0.8, 0.0 );
- break;
- };
+ if( noSetup ) setup3D();
+
+ // set up camera
+ var cx = -Math.cos(rotation) * Math.cos(tilt);
+ var cy = Math.sin(rotation) * Math.cos(tilt);
+ var cz = Math.sin(tilt);
+ var heightOfGround = JSFloorPlan3D.buildingProperties.floor[ showStates.showFloor ].heightOfGround;
+ var target = new THREE.Vector3( JSFloorPlan3D.buildingProperties.x_center, JSFloorPlan3D.buildingProperties.y_center, heightOfGround);
+ camera.up = new THREE.Vector3( Math.cos(rotation) * Math.sin(tilt), -Math.sin(rotation) * Math.sin(tilt), Math.cos(tilt) );
+ camera.position = new THREE.Vector3( cx*dist + JSFloorPlan3D.buildingProperties.x_center, cy*dist + JSFloorPlan3D.buildingProperties.y_center, dist * cz + heightOfGround);
+ camera.lookAt( target );
+ pointLight.position = camera.position;
+
+ // set up sun
+ var sx = -Math.cos(lightDirection) * Math.cos(lightHeight);
+ var sy = Math.sin(lightDirection) * Math.cos(lightHeight);
+ var sz = Math.sin(lightHeight);
+ sunLight.target.position = target;
+ sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance );
+ sunLight.intensity = lightStrength / 100.0;
+ sunLightViewLine.geometry.vertices[0].position = sunLight.position;
+ sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
+ sunLightViewLine.geometry.__dirtyVertices = true;
+
+ if( showStates.showLightView )
+ {
+ camera.position = sunLight.position;
+ camera.lookAt( sunLight.target.position );
+ }
+
+ // update opacity
+ cubeMaterial.opacity = showStates.fillOpacity;
+
+ // update color
+ switch( showStates.fillColor )
+ {
+ case 'black':
+ cubeMaterial.color.setRGB( 0.1, 0.1, 0.1 );
+ break;
+ case 'grey':
+ cubeMaterial.color.setRGB( 0.5, 0.5, 0.5 );
+ break;
+ case 'white':
+ cubeMaterial.color.setRGB( 1.0, 1.0, 1.0 );
+ break;
+ case 'blue':
+ cubeMaterial.color.setRGB( 0.0, 0.0, 0.8 );
+ break;
+ case 'red':
+ cubeMaterial.color.setRGB( 0.8, 0.0, 0.0 );
+ break;
+ case 'green':
+ cubeMaterial.color.setRGB( 0.0, 0.8, 0.0 );
+ break;
+ };
+
+ render();
+ }
- render();
-}
-
};//());
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 15:45:33
|
Revision: 592
http://openautomation.svn.sourceforge.net/openautomation/?rev=592&view=rev
Author: mayerch
Date: 2011-12-18 15:45:26 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Initial encapsualting the whole JSFloorPlan3D functionality.
(=> Commit to prepare a big whitespace chage)
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-18 14:39:40 UTC (rev 591)
+++ JSFloorPlan/trunk/index.html 2011-12-18 15:45:26 UTC (rev 592)
@@ -14,8 +14,8 @@
<script src="lib/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="lib/poly2tri.js" type="text/javascript"></script>
<script src="lib/Three.js" type="text/javascript"></script>
+<script src="src/jsfloorplan.js" type="text/javascript"></script>
<script src="src/jsfloorplan_example_helper.js" type="text/javascript"></script>
-<script src="src/jsfloorplan.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="demo.css" />
<!-- -->
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 14:39:40 UTC (rev 591)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 15:45:26 UTC (rev 592)
@@ -39,6 +39,8 @@
var JSFLOORPLAN3D = {};
}
+JSFLOORPLAN3D= function () {
+var JSFloorPlan3D = this;
// don't change anything below:
var ELEMENT_NODE = 1;
@@ -87,20 +89,22 @@
return pseudoangle_a - pseudoangle_b;
}
-function loadFloorplan()
-{
- $.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
-}
+//function loadFloorplan()
+//{
+// $.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
+//}
var floor;
// this array will contain all vertices to show in the svg
var vertices = Array();
// infos about the building
-var buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+JSFloorPlan3D.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
var imageCenter = new Object;
var noFloorplan = true;
-function parseXMLFloorPlan( xmlDoc )
+
+//return { parseXMLFloorPlan: function( xmlDoc )
+JSFloorPlan3D.parseXMLFloorPlan = function( xmlDoc )
{
noFloorplan = false;
@@ -135,16 +139,16 @@
"Expected: 'floor', found '" + floor.tagName + "'" );
floorCount++;
- buildingProperties.floor[floorCount] = {};
+ JSFloorPlan3D.buildingProperties.floor[floorCount] = {};
var floorName = floor.getAttribute('name');
- buildingProperties.floor[floorCount].name = floorName;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].name = floorName;
var floorheight = Number( floor.getAttribute('height') );
- buildingProperties.floor[floorCount].height = floorheight;
- buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].height = floorheight;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
- var floorWallsStart = floorWalls.length;
+ var floorWallsStart = 0;// floorWalls.length; <- not defined here yet...
// iterate over the content of this floor
for( var j=0; j < floor.childNodes.length; j++ )
@@ -472,23 +476,24 @@
Object3D.add( lineGroup );
Object3D.add( wallGroup );
- buildingProperties.floor[floorCount].Object3D = Object3D;
- buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
- buildingProperties.floor[floorCount].lineGroup = lineGroup;
- buildingProperties.floor[floorCount].wallGroup = wallGroup;
- buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
+ JSFloorPlan3D.buildingProperties.floor[floorCount].Object3D = Object3D;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].lineGroup = lineGroup;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].wallGroup = wallGroup;
+ JSFloorPlan3D.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
heightOfGround += floorheight;
} // end floor
- buildingProperties.x_center = (buildingProperties.x_max - buildingProperties.x_min) / 2;
- buildingProperties.y_center = (buildingProperties.y_max - buildingProperties.y_min) / 2;
- imageCenter.x = buildingProperties.x_center;
- imageCenter.y = buildingProperties.y_center;
- imageCenter.z = buildingProperties.z_max / 2;
+ JSFloorPlan3D.buildingProperties.x_center = (JSFloorPlan3D.buildingProperties.x_max - JSFloorPlan3D.buildingProperties.x_min) / 2;
+ JSFloorPlan3D.buildingProperties.y_center = (JSFloorPlan3D.buildingProperties.y_max - JSFloorPlan3D.buildingProperties.y_min) / 2;
+ imageCenter.x = JSFloorPlan3D.buildingProperties.x_center;
+ imageCenter.y = JSFloorPlan3D.buildingProperties.y_center;
+ imageCenter.z = JSFloorPlan3D.buildingProperties.z_max / 2;
- show3D( 35*Math.PI/180, 30*Math.PI/180 );
-}
+ JSFloorPlan3D.show3D( 35*Math.PI/180, 30*Math.PI/180 );
+//}
+};
var floorNodes = new Object();
function parseFloorNodes( nodes, floorheight )
@@ -507,21 +512,21 @@
floorNodes[id] = point;
- if( undefined == buildingProperties.x_min )
+ if( undefined == JSFloorPlan3D.buildingProperties.x_min )
{
- buildingProperties.x_min = point.x;
- buildingProperties.x_max = point.x;
- buildingProperties.y_min = point.y;
- buildingProperties.y_max = point.y;
- buildingProperties.z_min = point.z;
- buildingProperties.z_max = point.z;
+ JSFloorPlan3D.buildingProperties.x_min = point.x;
+ JSFloorPlan3D.buildingProperties.x_max = point.x;
+ JSFloorPlan3D.buildingProperties.y_min = point.y;
+ JSFloorPlan3D.buildingProperties.y_max = point.y;
+ JSFloorPlan3D.buildingProperties.z_min = point.z;
+ JSFloorPlan3D.buildingProperties.z_max = point.z;
} else {
- if( buildingProperties.x_min > point.x ) buildingProperties.x_min = point.x;
- if( buildingProperties.x_max < point.x ) buildingProperties.x_max = point.x;
- if( buildingProperties.y_min > point.y ) buildingProperties.y_min = point.y;
- if( buildingProperties.y_max < point.y ) buildingProperties.y_max = point.y;
- if( buildingProperties.z_min > point.z ) buildingProperties.z_min = point.z;
- if( buildingProperties.z_max < point.z ) buildingProperties.z_max = point.z;
+ if( JSFloorPlan3D.buildingProperties.x_min > point.x ) JSFloorPlan3D.buildingProperties.x_min = point.x;
+ if( JSFloorPlan3D.buildingProperties.x_max < point.x ) JSFloorPlan3D.buildingProperties.x_max = point.x;
+ if( JSFloorPlan3D.buildingProperties.y_min > point.y ) JSFloorPlan3D.buildingProperties.y_min = point.y;
+ if( JSFloorPlan3D.buildingProperties.y_max < point.y ) JSFloorPlan3D.buildingProperties.y_max = point.y;
+ if( JSFloorPlan3D.buildingProperties.z_min > point.z ) JSFloorPlan3D.buildingProperties.z_min = point.z;
+ if( JSFloorPlan3D.buildingProperties.z_max < point.z ) JSFloorPlan3D.buildingProperties.z_max = point.z;
}
}
}
@@ -616,7 +621,7 @@
if( noFloorplan ) return;
noSetup = false;
- scene.add( buildingProperties.Object3D );
+ scene.add( JSFloorPlan3D.buildingProperties.Object3D );
var showFloor = showStates.showFloor;
@@ -635,7 +640,7 @@
selectChange( 'showFloor' );
}
-function show3D( rotation, tilt )
+JSFloorPlan3D.show3D = function( rotation, tilt )
{
if( noSetup ) setup3D();
@@ -643,10 +648,10 @@
var cx = -Math.cos(rotation) * Math.cos(tilt);
var cy = Math.sin(rotation) * Math.cos(tilt);
var cz = Math.sin(tilt);
- var heightOfGround = buildingProperties.floor[ showStates.showFloor ].heightOfGround;
- var target = new THREE.Vector3( buildingProperties.x_center, buildingProperties.y_center, heightOfGround);
+ var heightOfGround = JSFloorPlan3D.buildingProperties.floor[ showStates.showFloor ].heightOfGround;
+ var target = new THREE.Vector3( JSFloorPlan3D.buildingProperties.x_center, JSFloorPlan3D.buildingProperties.y_center, heightOfGround);
camera.up = new THREE.Vector3( Math.cos(rotation) * Math.sin(tilt), -Math.sin(rotation) * Math.sin(tilt), Math.cos(tilt) );
- camera.position = new THREE.Vector3( cx*dist + buildingProperties.x_center, cy*dist + buildingProperties.y_center, dist * cz + heightOfGround);
+ camera.position = new THREE.Vector3( cx*dist + JSFloorPlan3D.buildingProperties.x_center, cy*dist + JSFloorPlan3D.buildingProperties.y_center, dist * cz + heightOfGround);
camera.lookAt( target );
pointLight.position = camera.position;
@@ -694,4 +699,6 @@
};
render();
-}
\ No newline at end of file
+}
+
+};//());
\ No newline at end of file
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 14:39:40 UTC (rev 591)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 15:45:26 UTC (rev 592)
@@ -21,7 +21,13 @@
//
//////////////////////////////////////////////////////////////////////////////
+j = new JSFLOORPLAN3D();
+function loadFloorplan()
+{
+ $.get('floorplan01.xml', j.parseXMLFloorPlan, 'xml');
+}
+
function three_init()
{
return;
@@ -183,7 +189,7 @@
function animate() {
requestAnimationFrame( animate );
//render();
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
//stats.update();
}
@@ -238,14 +244,14 @@
$('input').change(function(e){
showStates[ e.target.name ] = e.target.checked;
selectChange( e.target.name );
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}).each(function(){
showStates[ this.name ] = this.checked; // init
});
$('select').change(function(e){
showStates[ e.target.name ] = e.target.value;
selectChange( e.target.name );
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}).each(function(){
showStates[ this.name ] = this.value; // init
});
@@ -259,7 +265,7 @@
switch( name )
{
case 'showNodes':
- $( buildingProperties.floor ).each( function(){
+ $( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.nodeGroup, function( object ) {
object.visible = showStates['showNodes'];
});
@@ -267,7 +273,7 @@
break;
case 'showWallLines':
- $( buildingProperties.floor ).each( function(){
+ $( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.lineGroup, function( object ) {
object.visible = showStates['showWallLines'];
});
@@ -275,7 +281,7 @@
break;
case 'showFloor':
- $( buildingProperties.floor ).each( function( number ){
+ $( j.buildingProperties.floor ).each( function( number ){
THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
object.visible = ( showStates['showFloor'] == number );
});
@@ -316,7 +322,7 @@
if( tilt < 0 )
tilt_dir = 1;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
//////
var middle = new Date();
@@ -397,7 +403,7 @@
if( redraw )
{
- show3D( roll, tilt, plan );
+ j.show3D( roll, tilt, plan );
}
}
*/
@@ -421,7 +427,7 @@
if( redraw )
{
- show3D( roll, tilt, plan );
+ j.show3D( roll, tilt, plan );
}
}
*/
@@ -462,49 +468,49 @@
{
if( globalInUpdateSlider ) return true;
roll = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function tiltChange( event, ui )
{
if( globalInUpdateSlider ) return true;
tilt = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function distChange( event, ui )
{
if( globalInUpdateSlider ) return true;
dist = ui.value;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightDirectionChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightDirection = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightHeightChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightHeight = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightStrengthChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightStrength = ui.value;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightDistanceChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightDistance = ui.value;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 14:39:46
|
Revision: 591
http://openautomation.svn.sourceforge.net/openautomation/?rev=591&view=rev
Author: mayerch
Date: 2011-12-18 14:39:40 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Set up files to start conversion to a clean library and document in at the same time
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 14:29:20 UTC (rev 590)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 14:39:40 UTC (rev 591)
@@ -1,29 +1,43 @@
-/***************************************************************************
- * *
- * JavaScript FloorPlan 3D *
- * *
- * Copyright (C) 2009, 2010 by Christian Mayer *
- * jsfloorplan (at) ChristianMayer.de *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- * @module JSFloorPlan3D *
- ***************************************************************************/
+//
+// JavaScript FloorPlan 3D.
+//
+// Copyright (C) 2009, 2010 by Christian Mayer
+// jsfloorplan (at) ChristianMayer.de
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//////////////////////////////////////////////////////////////////////////////
-// setup script here:
+/**
+ * The JSFLOORPLAN3D object is the single global object created by the
+ * JSFloorPlan 3D library.
+ * @module JSFloorPlan3D
+ * @title JS Floor Plan 3D
+ */
+if (typeof JSFLOORPLAN3D == 'undefined' || !JSFLOORPLAN3D)
+{
+ /**
+ * The JSFLOORPLAN3D global namespace object. If JSFLOORPLAN3D is already
+ * defined, the existing JSFLOORPLAN3D object will not be overwritten so
+ * that defined namespaces are preserved.
+ * @class JSFLOORPLAN3D
+ * @static
+ */
+ var JSFLOORPLAN3D = {};
+}
// don't change anything below:
var ELEMENT_NODE = 1;
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 14:29:20 UTC (rev 590)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 14:39:40 UTC (rev 591)
@@ -1,28 +1,25 @@
-/***************************************************************************
- * *
- * JavaScript FloorPlan 3D - helper functions for the example *
- * *
- * Copyright (C) 2009 by Christian Mayer *
- * jsfloorplan (at) ChristianMayer.de *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- * @module JSFloorPlan3D *
- * @submodule JSFloorPlan3D_example *
- ***************************************************************************/
+//
+// JavaScript FloorPlan 3D.
+//
+// Copyright (C) 2009, 2010 by Christian Mayer
+// jsfloorplan (at) ChristianMayer.de
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//////////////////////////////////////////////////////////////////////////////
function three_init()
@@ -168,8 +165,7 @@
/**
* Provides requestAnimationFrame in a cross browser way.
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
- * @class window
- * @method requestAnimationFrame
+ * @class requestAnimationFrame
*/
if ( !window.requestAnimationFrame ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <net...@us...> - 2011-12-18 14:29:27
|
Revision: 590
http://openautomation.svn.sourceforge.net/openautomation/?rev=590&view=rev
Author: netzkind
Date: 2011-12-18 14:29:20 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
attribute "variant" for address is now a select-list on a per-widget-basis; will no longer be displayed when not available (declutter UI)
Modified Paths:
--------------
CometVisu/trunk/visu/edit/cometeditor.js
CometVisu/trunk/visu/edit/visuconfig_edit.js
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/edit/cometeditor.js
===================================================================
--- CometVisu/trunk/visu/edit/cometeditor.js 2011-12-18 14:19:21 UTC (rev 589)
+++ CometVisu/trunk/visu/edit/cometeditor.js 2011-12-18 14:29:20 UTC (rev 590)
@@ -90,6 +90,11 @@
// we've got elements we need to addit :)
container.append(set = jQuery("<fieldset />").addClass("elements"));
jQuery.each(elements, function(index, e) {
+ // Fallback if no options are specified
+ if (typeof e.options == "undefined") {
+ e.options = {};
+ }
+
var $line = $("<div />").addClass("add_input")
.append($("<label />").attr("for", "add_" + index).html(index))
.append($("<div class=\"input\" />"));
@@ -113,14 +118,14 @@
objData._attributes.variant = "";
objData._attributes.readonly = false;
- var elementDiv = HTMLLayer.createAddressEditorElement(objData);
+ var elementDiv = HTMLLayer.createAddressEditorElement(objData, e.options);
$input.find("div.multi_element").append(elementDiv);
});
if (typeof values._elements != "undefined"
&& typeof values._elements[index] != "undefined") {
- $.each(values._elements[index], function(i, e) {
- var elementDiv = HTMLLayer.createAddressEditorElement(e);
+ $.each(values._elements[index], function(i, myE) {
+ var elementDiv = HTMLLayer.createAddressEditorElement(myE, e.options);
$input.find("div.multi_element").append(elementDiv);
});
}
@@ -628,7 +633,8 @@
/**
* Create a sub-element for the multi-editor to edit an address-entry.
*/
- Layer.createAddressEditorElement = function(elementData) {
+ Layer.createAddressEditorElement = function(elementData, options) {
+
var elementDiv = jQuery("<div class=\"element clearfix\" />");
elementDiv.append("<div class=\"title\" />")
.append("<div class=\"value editable\" />")
@@ -652,6 +658,13 @@
.data("readonly", elementData._attributes.readonly == "true" ? true : false)
.data("address", elementData.textContent);
+ if (typeof options == "undefined" || typeof options.variant == "undefined" || options.variant == false) {
+ // if this element does not support variants, then remove them from the HTML.
+ elementDiv.find("div.variant").remove();
+ }
+
+ elementDiv.data("options", options);
+
return elementDiv;
}
}
\ No newline at end of file
Modified: CometVisu/trunk/visu/edit/visuconfig_edit.js
===================================================================
--- CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-18 14:19:21 UTC (rev 589)
+++ CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-18 14:29:20 UTC (rev 590)
@@ -179,6 +179,7 @@
$this.addClass("inedit");
$edit = jQuery("<div class=\"clearfix edit\" />");
$this.append($edit);
+ var options = $this.data("options");
$this.find(".editable").hide().each(function(index, e) {
$e = jQuery(e);
@@ -267,14 +268,24 @@
}
}
- if ($e.hasClass("variant")) {
+ if ($e.hasClass("variant") && typeof options.variant != "undefined") {
+ // variants can be selected from a pre-defined list ONLY.
element.find("label").html("variant");
- myElement.append($("<input class=\"add_variant\" />"));
- if (typeof $e.text() != "undefined") {
- // pre-set the value
- myElement.find(":input").val($e.text());
- }
+
+ // variants can be selected from a pre-defined list ONLY.
+ var variantList = $("<select name=\"variant\" />");
+ // go through list of available variants and display as select-list
+ $.each(options.variant, function (i, element) {
+ if (typeof $e.text() != "undefined"
+ && $e.text() == element) {
+ variantList.append("<option value=\"" + element + "\" label=\"" + element + "\" selected>" + element + "</option>");
+ } else {
+ variantList.append("<option value=\"" + element + "\" label=\"" + element + "\">" + element + "</option>");
+ }
+ });
+
+ myElement.append(variantList);
}
if (element.find("select")[0]) {
@@ -308,8 +319,10 @@
objData._attributes.variant = $e.find(".add_variant").val();
objData._attributes.readonly = $e.find(".add_readonly:checked").val();
+ var options = $e.data("options");
+
// remove this item and insert a new one instead
- var elementDiv = HTMLLayer.createAddressEditorElement(objData);
+ var elementDiv = HTMLLayer.createAddressEditorElement(objData, options);
$this.closest(".element").replaceWith(elementDiv);
}))
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-12-18 14:19:21 UTC (rev 589)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-12-18 14:29:20 UTC (rev 590)
@@ -166,7 +166,7 @@
},
elements: {
label: { type: 'string', required: true, multi: false },
- address: { type: 'address', required: true, multi: true }
+ address: { type: 'address', required: true, multi: true, options: {variant: ['r', 'g', 'b']} }
},
content: false
});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 14:19:27
|
Revision: 589
http://openautomation.svn.sourceforge.net/openautomation/?rev=589&view=rev
Author: mayerch
Date: 2011-12-18 14:19:21 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Make it work again (although the hole fix isn't correct at the moment and things look worse...).
Also some initial commets to make YUI Doc work.
NOTE: YUI Doc has to be a newer version than the published release as that has a problem with UTF-8 chars...
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 13:27:38 UTC (rev 588)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 14:19:21 UTC (rev 589)
@@ -20,6 +20,7 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
+ * @module JSFloorPlan3D *
***************************************************************************/
// setup script here:
@@ -365,7 +366,6 @@
var sId, eId;
for( var v = 0; v < Tvertices.length; v++ )
{
- /* prepare for later...
// project s1, e1 and s2, e2 onto line sm->em
var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
@@ -380,8 +380,7 @@
var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
- console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
- */
+ //console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
var z = heightOfGround + sh*tv.y;
if( wallSideOrder > 0 )
{
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 13:27:38 UTC (rev 588)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 14:19:21 UTC (rev 589)
@@ -20,6 +20,8 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
+ * @module JSFloorPlan3D *
+ * @submodule JSFloorPlan3D_example *
***************************************************************************/
@@ -166,6 +168,8 @@
/**
* Provides requestAnimationFrame in a cross browser way.
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+ * @class window
+ * @method requestAnimationFrame
*/
if ( !window.requestAnimationFrame ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 13:27:46
|
Revision: 588
http://openautomation.svn.sourceforge.net/openautomation/?rev=588&view=rev
Author: mayerch
Date: 2011-12-18 13:27:38 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Clean up structure by moving source to src
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
Added Paths:
-----------
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Removed Paths:
-------------
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-18 13:24:06 UTC (rev 587)
+++ JSFloorPlan/trunk/index.html 2011-12-18 13:27:38 UTC (rev 588)
@@ -14,8 +14,8 @@
<script src="lib/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="lib/poly2tri.js" type="text/javascript"></script>
<script src="lib/Three.js" type="text/javascript"></script>
-<script src="jsfloorplan_example_helper.js" type="text/javascript"></script>
-<script src="jsfloorplan.js" type="text/javascript"></script>
+<script src="src/jsfloorplan_example_helper.js" type="text/javascript"></script>
+<script src="src/jsfloorplan.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="demo.css" />
<!-- -->
Deleted: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:24:06 UTC (rev 587)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:27:38 UTC (rev 588)
@@ -1,684 +0,0 @@
-/***************************************************************************
- * *
- * JavaScript FloorPlan 3D *
- * *
- * Copyright (C) 2009, 2010 by Christian Mayer *
- * jsfloorplan (at) ChristianMayer.de *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- ***************************************************************************/
-
-// setup script here:
-
-// don't change anything below:
-var ELEMENT_NODE = 1;
-
-// calculate the distance between two cartesian 2D points
-function calcLength2D( start, end )
-{
- return Math.sqrt( (end.x-start.x)*(end.x-start.x) +
- (end.y-start.y)*(end.y-start.y) );
-}
-
-// calculate the rotation of a cartesian 2D point around the center
-function rotate2D( angle, point, center )
-{
- var s = Math.sin( angle );
- var c = Math.cos( angle );
- var ret = new Object;
- ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
- ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
- return ret;
-}
-
-// calculate the rotation of a cartesian 2D point around the center
-// but with given sin and cos of the angle
-function rotate2D( s, c, point, center )
-{
- var ret = new Object;
- ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
- ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
- return ret;
-}
-
-// calculate the translation of a cartesian 2D point
-function translate2D( point, translation )
-{
- var ret = new Object;
- ret.x = point.x + translation.x;
- ret.y = point.y + translation.y;
- return ret;
-}
-
-// sort two 2D unit(!) vectors clockwise
-function vecSort( a, b )
-{
- var pseudoangle_a = a.y>=0 ? (1-a.x) : (a.x+3);
- var pseudoangle_b = b.y>=0 ? (1-b.x) : (b.x+3);
- return pseudoangle_a - pseudoangle_b;
-}
-
-function loadFloorplan()
-{
- $.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
-}
-var floor;
-
-// this array will contain all vertices to show in the svg
-var vertices = Array();
-// infos about the building
-var buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
-var imageCenter = new Object;
-
-var noFloorplan = true;
-function parseXMLFloorPlan( xmlDoc )
-{
- noFloorplan = false;
-
- var floorCount = -1;
- var heightOfGround = 0; // the base level of the current floor
-
- // basic check if the document seems right
- // this could be avoided if the XML file would be validated
- // with a DTD
- var building;
- if( 'building' == xmlDoc.documentElement.tagName )
- building = xmlDoc.documentElement;
- else
- return alert( "ERROR: Not a valid floor plan! " +
- "Expected: 'building', found '" + xmlDoc.documentElement.tagName + "'" );
-
- // now we are sure to have a sensible file
- // => iterate over all floors
- for( var i=0; i < building.childNodes.length; i++ )
- {
- floor = building.childNodes[i];
- if (floor.nodeType != ELEMENT_NODE) continue;
-
- if( floor.tagName == 'textures' )
- {
- parseTextures( floor );
- continue;
- }
-
- if( floor.tagName != 'floor' )
- return alert( "ERROR: Not a valid floor plan! " +
- "Expected: 'floor', found '" + floor.tagName + "'" );
-
- floorCount++;
- buildingProperties.floor[floorCount] = {};
-
- var floorName = floor.getAttribute('name');
- buildingProperties.floor[floorCount].name = floorName;
-
- var floorheight = Number( floor.getAttribute('height') );
- buildingProperties.floor[floorCount].height = floorheight;
- buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
-
- var floorWallsStart = floorWalls.length;
-
- // iterate over the content of this floor
- for( var j=0; j < floor.childNodes.length; j++ )
- {
- floorNode = floor.childNodes[j];
- if (floorNode.nodeType != ELEMENT_NODE) continue;
-
- switch( floorNode.tagName )
- {
- case 'nodes':
- parseFloorNodes( floorNode, floorheight );
- break;
-
- case 'walls':
- parseFloorWalls( floorNode );
- break;
-
- case 'rooms':
- parseFloorRooms( floorNode, floorCount );
- break;
- }
- }
-
- // now the content of the floor is stored in easily
- // accessable objects
- // => derive the necessary information
-
- // group all elements on this floor
- var Object3D = new THREE.Object3D();
-
- // add the information to each node to which nodes it's connected to
- for( var j = floorWallsStart; j < floorWalls.length; j++ )
- {
- // note: the ID is shifted by one to avoid an ID of zero
- // as that wouldn't allow me anymore to distinguish
- // start and stop
- floorNodes[ floorWalls[j].start ].neighbour.push( j+1 );
- floorNodes[ floorWalls[j].end ].neighbour.push( -j-1 );
- }
-
- var nodeGroup = new THREE.Object3D(); nodeGroup.name = 'nodeGroup';
- for( var id in floorNodes )
- {
- // calculate the vectors showing to the neighbours
- var vectors = new Array();
- var start = floorNodes[id];
-
- // show them on request as spheres
- var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
- sphere.position = new THREE.Vector3( start.x, start.y, heightOfGround );
- nodeGroup.add(sphere);
-
- for( var j=0; j<floorNodes[id].neighbour.length; j++ )
- {
- var vec = new Object;
- vec.id = floorNodes[id].neighbour[j];
- var end;
- if( vec.id < 0 )
- end = floorNodes[ floorWalls[ -vec.id-1 ].start ];
- else
- end = floorNodes[ floorWalls[ vec.id-1 ].end ];
-
- length = calcLength2D( start, end );
- vec.x = (end.x - start.x) / length;
- vec.y = (end.y - start.y) / length;
- vectors.push( vec );
- }
-
- // sort them clockwise
- vectors.sort( vecSort );
-
- // calculate the cutting points of the walls at this node id
- for( var j=0; j<vectors.length; j++ )
- {
- var jj = (j+1) % vectors.length;
- var wj = Math.abs(vectors[j ].id)-1;
- var wjj = Math.abs(vectors[jj].id)-1;
- var dj = floorWalls[wj ].thickness/2;
- var djj = floorWalls[wjj].thickness/2;
- if( floorWalls[wj ].startOffset && vectors[j ].id > 0 )
- dj += floorWalls[wj].startOffset;
- if( floorWalls[wj ].endOffset && vectors[j ].id < 0 )
- dj += floorWalls[wj].endOffset;
- if( floorWalls[wjj].startOffset && vectors[jj].id > 0 )
- djj += -floorWalls[wjj].startOffset;
- if( floorWalls[wjj].endOffset && vectors[jj].id < 0 )
- djj += -floorWalls[wjj].endOffset;
-
- vertex = new Object;
- vertex.x = vectors[j].x*djj + vectors[jj].x*dj;
- vertex.y = vectors[j].y*djj + vectors[jj].y*dj;
- var l = vectors[j].x*vectors[jj].y - vectors[j].y*vectors[jj].x;
- if( Math.abs( l ) < 1e-5 )
- { // the angle between the two vectors is exactly 180°
- // i.e. a straight wall...
- if( Math.abs( dj - djj ) < 1e-5 )
- { // at least the walls have the same thickness...
- vertex.x = start.x - vectors[j].y*dj;
- vertex.y = start.y + vectors[j].x*dj;
- } else {
- alert( "ERROR: A straight wall with different thicknesses " +
- "is currently not supported!" );
- // but we still try our best...
- vertex.x = start.x - vectors[j].y*(dj+djj)/2;
- vertex.y = start.y + vectors[j].x*(dj+djj)/2;
- }
- } else {
- vertex.x = start.x + vertex.x / l;
- vertex.y = start.y + vertex.y / l;
- }
-
- if( vectors[j ].id < 0 )
- floorWalls[wj ].startVertex.push( vertices.length );
- else
- floorWalls[wj ].endVertex.push( vertices.length );
-
- if( 1 == vectors.length )
- {
- var additional = new Object;
- additional.x = 2 * start.x - vertex.x;
- additional.y = 2 * start.y - vertex.y;
- vertices.push( additional );
- }
-
- if( vectors[jj].id < 0 )
- floorWalls[wjj].startVertex.push( vertices.length );
- else
- floorWalls[wjj].endVertex.push( vertices.length );
-
- vertices.push( vertex );
- }
- } // end for( var id in floorNodes )
- Object3D.add( nodeGroup );
-
- // show walls
- var lineGroup = new THREE.Object3D(); lineGroup.name = 'lineGroup';
- var wallGroup = new THREE.Object3D(); wallGroup.name = 'wallGroup';
- for( var j = floorWallsStart; j<floorWalls.length; j++ )
- {
- var vs = floorNodes[ floorWalls[j].start ];
- var ve = floorNodes[ floorWalls[j].end ];
- var lineGeo = new THREE.Geometry();
- lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( vs.x, vs.y, heightOfGround ) ) );
- lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( ve.x, ve.y, heightOfGround ) ) );
- lineGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
-
- var s1 = vertices[ floorWalls[j].startVertex[0] ];
- var e1 = vertices[ floorWalls[j].endVertex [0] ];
- var s2 = vertices[ floorWalls[j].startVertex[1] ];
- var e2 = vertices[ floorWalls[j].endVertex [1] ];
-
- // check that the start and end points aren't twisted
- var v1 = new Object; v1.x = s1.x-s2.x; v1.y = s1.y-s2.y;
- var v2 = new Object; v2.x = e1.x-s2.x; v2.y = e1.y-s2.y;
- var v3 = new Object; v3.x = e1.x-e2.x; v3.y = e1.y-e2.y;
- if( (v1.x*v2.y - v1.y*v2.x)*(v2.x*v3.y - v2.y*v3.x) > 0 )
- {
- e1 = vertices [ floorWalls[j].endVertex[1] ];
- e2 = vertices [ floorWalls[j].endVertex[0] ];
- }
- var sm = floorNodes[ floorWalls[j].start ];
- var em = floorNodes[ floorWalls[j].end ];
- var sh = floorNodes[ floorWalls[j].start ].z ;
- var eh = floorNodes[ floorWalls[j].end ].z ;
- var wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
- var geometry = new THREE.Geometry();
-
- var normal1 = new THREE.Vector3(sm.y-em.y,-sm.x+em.x,0); // fixme? normalize
- var normal2 = new THREE.Vector3(1,0,0);
-
- var sourrounding = [ new poly2tri.Point(0,0), new poly2tri.Point(0,1), new poly2tri.Point(1,1), new poly2tri.Point(1,0) ];
- sourrounding[1].startEndMarker = 'start';
- sourrounding[2].startEndMarker = 'end';
- var holesToAdd = [];
-
- if( floorWalls[j].holes.length )
- {
- var holes = floorWalls[j].holes;
- for( var h = 0; h < holes.length; h++ )
- {
- var wallLength = calcLength2D( sm, em );
- var fLeft = holes[h].distance / wallLength;
- var fRight = (holes[h].distance + holes[h].width) / wallLength;
- if( fLeft <= 0.0 ) fLeft = 0.001; //// FIXME - actually the config file is bad. Leave at least 1mm wall
- if( fRight >= 1.0 ) fRight = 0.999; //// FIXME - actually the config file is bad. Leave at least 1mm wall
- var lintel = (sh - holes[h].lintel) / sh;
- var paparet = holes[h].paparet / sh;
- if( 1 == lintel )
- {
- // not a hole, the sourrounding goes to the groud...
-
- if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
-
- sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
- continue;
- }
- if( 0 == paparet )
- {
- // not a hole, the sourrounding goes to the groud...
-
- // lintel == 1 can't happen, it's checked in the if clause above
-
- sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
- continue;
- }
-
- holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
- }
- } // if( floorWalls[j].holes.length )
- var swctx = new poly2tri.SweepContext( sourrounding.slice(0) ); // pass a copy of sourrounding
- for( var htA = 0; htA < holesToAdd.length; htA++ )
- swctx.AddHole( holesToAdd[htA] );
-
- // Do the triangulation - FIXME: handle exceptions, don't ignore them...
- try {
- poly2tri.sweep.Triangulate(swctx);
- }catch(err){}
-
- // mark all points to make sure that we don't need to double vertices
- for( var tp = 0; tp < swctx.point_count(); tp++ )
- swctx.GetPoint( tp ).id = tp;
-
- // translate poly2tri triangles to THREE.js faces:
- var p2tF = [];
- $.each(swctx.GetTriangles(), function(idx, val) {
- p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
- });
-
- Tvertices = swctx.points_;
- Tfaces = p2tF;
- var wall1vertices = [];
- var wall2vertices = [];
- var sId, eId;
- for( var v = 0; v < Tvertices.length; v++ )
- {
- /* prepare for later...
- // project s1, e1 and s2, e2 onto line sm->em
- var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
- var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var e1f = 1-((e1.x-sm.x)*(em.x-sm.x) + (e1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var s2f = 1-((s2.x-sm.x)*(em.x-sm.x) + (s2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
- var e2f = 1-((e2.x-sm.x)*(em.x-sm.x) + (e2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
-
- var tv = Tvertices[v];
- var tvx1 = Math.min( 1.0, Math.max( 0.0, (tv.x - s1f) * (e1f - s1f) ) ); // map between s1 and e1
- var tvx2 = Math.min( 1.0, Math.max( 0.0, (tv.x - s2f) * (e2f - s2f) ) ); // map between s2 and e2
- var x1 = s1.x * tvx1 + e1.x * (1 - tvx1);
- var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
- var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
- var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
- console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
- */
- var z = heightOfGround + sh*tv.y;
- if( wallSideOrder > 0 )
- {
- wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
- wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
- } else {
- wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
- wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
- }
- if( 'startEndMarker' in tv )
- {
- if( 'start' == tv.startEndMarker )
- {
- sId = wall1vertices.length - 1;
- } else {
- eId = wall1vertices.length - 1;
- }
- }
- }
- var wall1verticesLength = wall1vertices.length;
- geometry.vertices = wall1vertices.concat( wall2vertices );
- var s1id = sId, s2id = sId + wall1verticesLength, e1id = eId, e2id = eId + wall1verticesLength;
- //geometry.faces = Tfaces;
- for( var f = 0; f < Tfaces.length; f++ )
- {
- var uv_a1 = new THREE.UV( Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
- var uv_b1 = new THREE.UV( Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
- var uv_c1 = new THREE.UV( Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
- var uv_a2 = new THREE.UV( 1-Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
- var uv_b2 = new THREE.UV( 1-Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
- var uv_c2 = new THREE.UV( 1-Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
-
- // wall side 1
- geometry.faces.push( Tfaces[f] );
- geometry.faceVertexUvs[0].push([ uv_a1, uv_b1, uv_c1 ]);
- // wall side 2
- geometry.faces.push(new THREE.Face3(Tfaces[f].c+wall1verticesLength, Tfaces[f].b+wall1verticesLength, Tfaces[f].a+wall1verticesLength ) );
- geometry.faceVertexUvs[0].push([ uv_a2, uv_b2, uv_c2 ]);
- }
- // wall top
- var mId = geometry.vertices.length;
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround+sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround+eh)));
- geometry.faces.push(new THREE.Face3(s1id, s2id, mId+1) );
- geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
-
- for( var e = 0; e < sourrounding.length; e++ )
- {
- var id1 = sourrounding[e ].id;
- var id2 = sourrounding[(e+1)%sourrounding.length].id;
- geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
- geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
- }
-
- // hole sides
- for( var hta = 0; hta < holesToAdd.length; hta++ )
- {
- for( var e = 0; e < holesToAdd[hta].length; e++ )
- {
- var id1 = holesToAdd[hta][e ].id;
- var id2 = holesToAdd[hta][(e+1)%sourrounding.length].id;
- geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
- geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
- }
- }
-
- geometry.computeFaceNormals();
- var mesh = new THREE.Mesh(geometry, cubeMaterial);
- mesh.castShadow = true;
- mesh.receiveShadow = true;
- wallGroup.add(mesh);
- } // end for( j=0; j<floorWalls.length; j++ )
- Object3D.add( lineGroup );
- Object3D.add( wallGroup );
-
- buildingProperties.floor[floorCount].Object3D = Object3D;
- buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
- buildingProperties.floor[floorCount].lineGroup = lineGroup;
- buildingProperties.floor[floorCount].wallGroup = wallGroup;
- buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
-
- heightOfGround += floorheight;
- } // end floor
-
- buildingProperties.x_center = (buildingProperties.x_max - buildingProperties.x_min) / 2;
- buildingProperties.y_center = (buildingProperties.y_max - buildingProperties.y_min) / 2;
- imageCenter.x = buildingProperties.x_center;
- imageCenter.y = buildingProperties.y_center;
- imageCenter.z = buildingProperties.z_max / 2;
-
- show3D( 35*Math.PI/180, 30*Math.PI/180 );
-}
-
-var floorNodes = new Object();
-function parseFloorNodes( nodes, floorheight )
-{
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var id = node.getAttribute('id');
- var point = new Object;
- point.x = Number( node.getAttribute('x') );
- point.y = Number( node.getAttribute('y') );
- point.z = Number( node.hasAttribute('z') ? node.getAttribute('z') : floorheight );
- point.neighbour = new Array;
-
- floorNodes[id] = point;
-
- if( undefined == buildingProperties.x_min )
- {
- buildingProperties.x_min = point.x;
- buildingProperties.x_max = point.x;
- buildingProperties.y_min = point.y;
- buildingProperties.y_max = point.y;
- buildingProperties.z_min = point.z;
- buildingProperties.z_max = point.z;
- } else {
- if( buildingProperties.x_min > point.x ) buildingProperties.x_min = point.x;
- if( buildingProperties.x_max < point.x ) buildingProperties.x_max = point.x;
- if( buildingProperties.y_min > point.y ) buildingProperties.y_min = point.y;
- if( buildingProperties.y_max < point.y ) buildingProperties.y_max = point.y;
- if( buildingProperties.z_min > point.z ) buildingProperties.z_min = point.z;
- if( buildingProperties.z_max < point.z ) buildingProperties.z_max = point.z;
- }
- }
-}
-
-var floorWalls = new Array();
-function parseFloorWalls( nodes )
-{
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var wall = new Object;
- wall.start = node.getAttribute('start' );
- wall.startVertex = new Array;
- wall.startOffset = Number( node.getAttribute('startoffset') );
- wall.end = node.getAttribute('end' );
- wall.endVertex = new Array;
- wall.endOffset = Number( node.getAttribute('endoffset' ) );
- wall.thickness = Number( node.getAttribute('thickness' ) );
- wall.texture = node.getAttribute('texture' );
- if( !wall.texture ) wall.texture = 0;
-
- wall.holes = new Array;
- for( var j=0; j < node.childNodes.length; j++ )
- {
- var hole = node.childNodes[j];
- if (hole.nodeType != ELEMENT_NODE) continue;
-
- var thishole = new Object;
- thishole.id = hole.getAttribute('id');
- thishole.distance = Number( hole.getAttribute('distance') );
- thishole.width = Number( hole.getAttribute('width' ) );
- thishole.paparet = Number( hole.getAttribute('paparet' ) );
- thishole.lintel = Number( hole.getAttribute('lintel' ) );
- wall.holes.push( thishole );
- }
-
- floorWalls[floorWalls.length] = wall;
- }
-}
-
-var rooms = new Array;
-function parseFloorRooms( nodes, floor )
-{
- rooms[floor] = new Array;
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- var node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var room = new Object;
- room.name = node.getAttribute('name');
- room.zones = new Array;
-
- for( var j=0; j < node.childNodes.length; j++ )
- {
- var zone = node.childNodes[j];
- if (zone.nodeType != ELEMENT_NODE) continue;
-
- var thiszone = new Object;
- thiszone.onclick = zone.getAttribute('onclick');
- thiszone.name = zone.getAttribute('name' );
- thiszone.corners = new Array;
-
- for( var k=0; k < zone.childNodes.length; k++ )
- {
- var corner = zone.childNodes[k];
- if (corner.nodeType != ELEMENT_NODE) continue;
- thiszone.corners.push( corner.getAttribute('nodeid') );
- }
- room.zones.push( thiszone );
- }
- rooms[floor].push( room );
- }
-}
-
-//var textures = new Object();
-function parseTextures( nodes )
-{
- return;
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
- }
-}
-
-var noSetup = true;
-function setup3D()
-{
- if( noFloorplan ) return;
- noSetup = false;
-
- scene.add( buildingProperties.Object3D );
-
- var showFloor = showStates.showFloor;
-
- ///////////
- scene.add(sunLight);
- //scene.add(pointLight);
- scene.add(ambientLight);
- //scene.add( camera );
- var $container = $('#top_level');
- // attach the render-supplied DOM element
- $container.append(renderer.domElement);
-
- // Init after the scene was set up
- selectChange( 'showNodes' );
- selectChange( 'showWallLines' );
- selectChange( 'showFloor' );
-}
-
-function show3D( rotation, tilt )
-{
- if( noSetup ) setup3D();
-
- // set up camera
- var cx = -Math.cos(rotation) * Math.cos(tilt);
- var cy = Math.sin(rotation) * Math.cos(tilt);
- var cz = Math.sin(tilt);
- var heightOfGround = buildingProperties.floor[ showStates.showFloor ].heightOfGround;
- var target = new THREE.Vector3( buildingProperties.x_center, buildingProperties.y_center, heightOfGround);
- camera.up = new THREE.Vector3( Math.cos(rotation) * Math.sin(tilt), -Math.sin(rotation) * Math.sin(tilt), Math.cos(tilt) );
- camera.position = new THREE.Vector3( cx*dist + buildingProperties.x_center, cy*dist + buildingProperties.y_center, dist * cz + heightOfGround);
- camera.lookAt( target );
- pointLight.position = camera.position;
-
- // set up sun
- var sx = -Math.cos(lightDirection) * Math.cos(lightHeight);
- var sy = Math.sin(lightDirection) * Math.cos(lightHeight);
- var sz = Math.sin(lightHeight);
- sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance );
- sunLight.intensity = lightStrength / 100.0;
- sunLightViewLine.geometry.vertices[0].position = sunLight.position;
- sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
- sunLightViewLine.geometry.__dirtyVertices = true;
-
- if( showStates.showLightView )
- {
- camera.position = sunLight.position;
- camera.lookAt( sunLight.target.position );
- }
-
- // update opacity
- cubeMaterial.opacity = showStates.fillOpacity;
-
- // update color
- switch( showStates.fillColor )
- {
- case 'black':
- cubeMaterial.color.setRGB( 0.1, 0.1, 0.1 );
- break;
- case 'grey':
- cubeMaterial.color.setRGB( 0.5, 0.5, 0.5 );
- break;
- case 'white':
- cubeMaterial.color.setRGB( 1.0, 1.0, 1.0 );
- break;
- case 'blue':
- cubeMaterial.color.setRGB( 0.0, 0.0, 0.8 );
- break;
- case 'red':
- cubeMaterial.color.setRGB( 0.8, 0.0, 0.0 );
- break;
- case 'green':
- cubeMaterial.color.setRGB( 0.0, 0.8, 0.0 );
- break;
- };
-
- render();
-}
\ No newline at end of file
Deleted: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-18 13:24:06 UTC (rev 587)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-18 13:27:38 UTC (rev 588)
@@ -1,510 +0,0 @@
-/***************************************************************************
- * *
- * JavaScript FloorPlan 3D - helper functions for the example *
- * *
- * Copyright (C) 2009 by Christian Mayer *
- * jsfloorplan (at) ChristianMayer.de *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- ***************************************************************************/
-
-
-function three_init()
-{
- return;
- // get the DOM element to attach to
- // - assume we've got jQuery to hand
- //var $container = $('#container');
- var $container = $('#top_level');
- // attach the render-supplied DOM element
- $container.append(renderer.domElement);
- // draw!
- //scene.add( camera );
- //renderer.render(scene, camera);
- //render();
- animate();
-}
-// set the scene size
-var WIDTH = 800,
- HEIGHT = 400;
-
-// set some camera attributes
-var VIEW_ANGLE = 45,
- ASPECT = WIDTH / HEIGHT,
- NEAR = 0.1,
- FAR = 10000;
-
-
-// create a WebGL renderer, camera
-// and a scene
-var renderer = new THREE.WebGLRenderer({antialias: true});
-var camera = new THREE.PerspectiveCamera(
- VIEW_ANGLE,
- ASPECT,
- NEAR,
- FAR );
-/*
-var controls = new THREE.TrackballControls( camera );
-//controls.rotateSpeed = 1.0;
-//controls.zoomSpeed = 1.2;
-//controls.panSpeed = 0.8;
-
-controls.noZoom = false;
-controls.noPan = false;
-
-controls.staticMoving = true;
-controls.dynamicDampingFactor = 0.3;
-
-controls.keys = [ 65, 83, 68 ];
-*/
-var scene = new THREE.Scene();
-scene.add( camera );
-// the camera starts at 0,0,0 so pull it back
-camera.position.z = 300;
-
-// start the renderer
-renderer.setSize(WIDTH, HEIGHT);
-
-// enable shadows
-var SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
-renderer.shadowCameraNear = 0.1;
-renderer.shadowCameraFar = 100;
-renderer.shadowCameraFov = 45;
-
-renderer.shadowMapBias = 0.0039;
-renderer.shadowMapDarkness = 0.5;
-renderer.shadowMapWidth = SHADOW_MAP_WIDTH;
-renderer.shadowMapHeight = SHADOW_MAP_HEIGHT;
-renderer.shadowMapEnabled = true;
-//renderer.shadowMapSoft = true;
-
-
-// set up the sphere vars
-var radius = 50, segments = 16, rings = 16;
-
-// create the sphere's material
-var sphereMaterial = new THREE.MeshLambertMaterial(
-{
- color: 0xCC0000
-});
-// create a new mesh with sphere geometry -
-// we will cover the sphereMaterial next!
-var sphere = new THREE.Mesh(
- new THREE.SphereGeometry(radius,
- segments,
- rings),
-
- sphereMaterial);
-
-// add the sphere to the scene
-//scene.add(sphere);
-
-var cubeMaterial = new THREE.MeshLambertMaterial(
-{
- color: 0x0000CC
-});
-var cube = new THREE.Mesh(
- new THREE.CubeGeometry(
- 10, 20, 30,
- 2, 2),
- cubeMaterial
-);
-cube.position = new THREE.Vector3(50,50,50);
-//scene.add( cube );
-
-cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
-//cubeMaterial = new THREE.MeshPhongMaterial( { color: 0xff0000, specular: 0xffffff, ambient: 0xaa0000 } );
-
-var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
-
-// create a point light
-var pointLight = new THREE.PointLight( 0xFFFFFF );
-
-var ambientLight = new THREE.AmbientLight( 0xFFFFFF );
-// set its position
-pointLight.position.x = 10;
-pointLight.position.y = 50;
-pointLight.position.z = 130;
-
-// add to the scene
-//scene.add(pointLight);
-
-var lightDirection = 3.9;
-var lightHeight = 0.25;
-var lightStrength = 80;
-var lightDistance = 50;
-//var sunLight = new THREE.PointLight( 0xFFFFFF );
-//var sunLight = new THREE.DirectionalLight( 0xFFFFFF );
-var sunLight = new THREE.SpotLight( 0xffffff );
-sunLight.position.set( 0, 1500, 1000 );
-sunLight.target.position.set( 0, 0, 0 );
-sunLight.castShadow = true;
-var sunLightView = new THREE.Geometry();
-sunLightView.vertices.push( new THREE.Vertex( sunLight.position ) );
-sunLightView.vertices.push( new THREE.Vertex( sunLight.target.position ) );
-var sunLightViewLine = new THREE.Line( sunLightView, lineMaterial );
-scene.add( sunLightViewLine );
-//var dlight = new THREE.DirectionalLight( 0xffffff, 0.1 );
-// dlight.position.set( 0.5, -1, 0 ).normalize();
-// scene.add( dlight );
-
-
-/**
- * Provides requestAnimationFrame in a cross browser way.
- * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
- */
-
-if ( !window.requestAnimationFrame ) {
- window.requestAnimationFrame = ( function() {
- return window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
- window.setTimeout( callback, 1000 / 60 );
- };
-} )();
-
-}
-function animate() {
- requestAnimationFrame( animate );
- //render();
- show3D( roll, tilt );
- //stats.update();
-}
-
-function render() {
- //controls.update();
- renderer.render( scene, camera );
-}
-
-//}
-
-/////////////////////////////////////////////////////////////////////////////
-$(function() {
- three_init();
-});
-/////////////////////////////////////////////////////////////////////////////
-// setup script here:
-var sc = 40; // overall scaling
-var showStates = {};
-/*
-var showWallSides = true;
-var showWallTop = true;
-var showSideLines = true;
-var showTopLines = true;
-var showBackside = true;
-var showHoles = true;
-var showZones = true;
-var showVisibleZones = false;
-var showFloor = 1;
-var wallMouseOver = true;
-var fillOpacity = 0.5;
-var fillColor = 'black';
-*/
-var redrawInterval = 50; // in milliseconds; = 20 fps
-
-var roll = 35*Math.PI/180;
-var tilt = 30*Math.PI/180;
-var tilt_dir = 1;
-var dist = 10;
- //var plan = createSVGElement( "g" );
-var f_avr = 0;
-var m_avr = 0;
-var avr_factor = 0.1;
-var fps_history = new Array();
-var fps_current = 0;
-
-var t_25d_start;
-var t_25d_after_sort;
-var t_25d_end;
-
-function init()
-{
- $('input').change(function(e){
- showStates[ e.target.name ] = e.target.checked;
- selectChange( e.target.name );
- show3D( roll, tilt );
- }).each(function(){
- showStates[ this.name ] = this.checked; // init
- });
- $('select').change(function(e){
- showStates[ e.target.name ] = e.target.value;
- selectChange( e.target.name );
- show3D( roll, tilt );
- }).each(function(){
- showStates[ this.name ] = this.value; // init
- });
-
- loadFloorplan();
- createSlider();
-}
-
-function selectChange( name )
-{
- switch( name )
- {
- case 'showNodes':
- $( buildingProperties.floor ).each( function(){
- THREE.SceneUtils.traverseHierarchy( this.nodeGroup, function( object ) {
- object.visible = showStates['showNodes'];
- });
- });
- break;
-
- case 'showWallLines':
- $( buildingProperties.floor ).each( function(){
- THREE.SceneUtils.traverseHierarchy( this.lineGroup, function( object ) {
- object.visible = showStates['showWallLines'];
- });
- });
- break;
-
- case 'showFloor':
- $( buildingProperties.floor ).each( function( number ){
- THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
- object.visible = ( showStates['showFloor'] == number );
- });
- });
- break;
-
- case 'showWireframe':
- cubeMaterial.wireframe = showStates['showWireframe'];
- break;
- }
-}
-
-var toggle = false;
-var animation;
-function my_click()
-{
- if( toggle )
- {
- clearInterval( animation );
- toggle = false;
- } else {
- animation = setInterval(move, redrawInterval);
- toggle = true;
- }
- return true;
-}
-
-function move()
-{
- var pre = new Date();
-
- //////
- roll += 0.5*Math.PI/180;
- if( roll > 2*Math.PI ) roll -= 2*Math.PI;
- tilt += tilt_dir*0.5*Math.PI/180;
- if( tilt > 60*Math.PI/180 )
- tilt_dir = -1;
- if( tilt < 0 )
- tilt_dir = 1;
-
- show3D( roll, tilt );
- //////
-
- var middle = new Date();
-
- var post = new Date();
-
- //////
- var f = post - pre ; f_avr = f_avr * (1-avr_factor) + f*avr_factor;
- var m = post - middle; m_avr = m_avr * (1-avr_factor) + m*avr_factor;
-
- var fps = Math.floor( 1000/(f>0 ? f:0.1) );
- fps_history[fps_current++] = fps;
- if( fps_current > 10 ) fps_current = 0;
- var fps_min = Math.min.apply( Math, fps_history );
- var fps_max = Math.max.apply( Math, fps_history );
-
- var calc1 = t_25d_after_sort - t_25d_start;
- var calc2 = t_25d_end - t_25d_after_sort;
-
- delete pre;
- delete middle;
- delete post;
- //delete t_25d_start;
- //delete t_25d_after_sort;
- //delete t_25d_end;
-
- var txt = '';//"c1: " + calc1 + "; c2: " + calc2;
-
- var text = "roll: " + roll + "; tilt: " + tilt + " (" + (tilt*180/Math.PI) + "; " + tilt_dir + ")\n" +
- (m_avr<10?"0":"")+Math.floor(m_avr)+" Millisekunden zum Neuzeichnen verwendet\n"
- + Math.floor(f_avr)+" Millisekunden inklusive Neuberechnung verwendet (von " + redrawInterval + " Millisekunden)\n"
- + "Aktuelle, maximale Rate wären "+fps+" fps (aktuell festgesetzt sind "+Math.floor(1000/redrawInterval)+" FPS)\n"
-+ "Die letzten 10 Schritte wären mindestes " + fps_min + " FPS und höchstens " + fps_max + " FPS möglich gewesen.\n"
-+ txt;
- //window.status = (post - pre);//.getMilliseconds();
- var timeout = setTimeout( showStats, 1, text );
-///
-updateSlider();
-}
-
-function showStats( text )
-{
- document.getElementById('status').firstChild.data = text;
-}
-
-/*
-function set_color( event )
-{
- if( 'blue' != fillColor )
- event.setAttribute( 'fill', 'blue' );
- else
- event.setAttribute( 'fill', 'red' );
-}
-
-function unset_color( event )
-{
- event.setAttribute( 'fill', fillColor );
-}
-*/
-/*
-function check( what, redraw )
-{
- eval( what +' = document.forms[0].elements[what].checked' );
-
- switch( what )
- {
- case 'wallMouseOver':
- if( wallMouseOver )
- {
- wrapper.setAttribute( "onmouseover", 'set_color(this);' );
- wrapper.setAttribute( "onmouseout", 'unset_color(this);' );
- } else {
- wrapper.setAttribute( "onmouseover", '' );
- wrapper.setAttribute( "onmouseout", '' );
- }
- break;
- }
-
- if( redraw )
- {
- show3D( roll, tilt, plan );
- }
-}
-*/
-
-/*
-function selectValue( what, redraw )
-{
- var val = document.forms[0].elements[what].options[ document.forms[0].elements[what].selectedIndex ].value;
- eval( what + ' = val' );
-
- switch( what )
- {
- case 'fillOpacity':
- wrapper.setAttribute( "fill-opacity", fillOpacity );
- break;
-
- case 'fillColor':
- wrapper.setAttribute( "fill", fillColor );
- break;
- }
-
- if( redraw )
- {
- show3D( roll, tilt, plan );
- }
-}
-*/
-
-// Create the little graphics for the roll and the tilt angle
-// as well as the buttons to manipulate them
-function createSlider()
-{
- $( "#rollSlider" ).slider({ min: 0, max: 360, change: rollChange, slide: rollChange});
- $( "#tiltSlider" ).slider({ min: 0, max: 90, change: tiltChange, slide: tiltChange});
- $( "#distSlider" ).slider({ min: 5, max: 30, change: distChange, slide: distChange});
- $( "#lightDirectionSlider" ).slider({ min: 0, max: 360, change: lightDirectionChange, slide: lightDirectionChange});
- $( "#lightHeightSlider" ).slider({ min: 0, max: 90, change: lightHeightChange , slide: lightHeightChange });
- $( "#lightStrengthSlider" ).slider({ min: 0, max: 100, change: lightStrengthChange , slide: lightStrengthChange });
- $( "#lightDistanceSlider" ).slider({ min:10, max: 100, change: lightDistanceChange , slide: lightDistanceChange });
- updateSlider();
-}
-
-var globalInUpdateSlider = false;
-function updateSlider()
-{
- globalInUpdateSlider = true;
- var rollAngle = (roll * 180/Math.PI);
- var tiltAngle = (tilt * 180/Math.PI);
- var lightDirectionAngle = (lightDirection * 180/Math.PI);
- var lightHeightAngle = (lightHeight * 180/Math.PI);
- $( "#rollSlider" ).slider( "option", "value", rollAngle );
- $( "#tiltSlider" ).slider( "option", "value", tiltAngle );
- $( "#distSlider" ).slider( "option", "value", dist );
- $( "#lightDirectionSlider" ).slider( "option", "value", lightDirectionAngle );
- $( "#lightHeightSlider" ).slider( "option", "value", lightHeightAngle );
- $( "#lightStrengthSlider" ).slider( "option", "value", lightStrength );
- $( "#lightDistanceSlider" ).slider( "option", "value", lightDistance );
- globalInUpdateSlider = false;
-}
-
-function rollChange( event, ui )
-{
- if( globalInUpdateSlider ) return true;
- roll = ui.value * Math.PI / 180;
- show3D( roll, tilt );
-}
-
-function tiltChange( event, ui )
-{
- if( globalInUpdateSlider ) return true;
- tilt = ui.value * Math.PI / 180;
- show3D( roll, tilt );
-}
-
-function distChange( event, ui )
-{
- if( globalInUpdateSlider ) return true;
- dist = ui.value;
- show3D( roll, tilt );
-}
-
-function lightDirectionChange( event, ui )
-{
- if( globalInUpdateSlider ) return true;
- lightDirection = ui.value * Math.PI / 180;
- show3D( roll, tilt );
-}
-
-function lightHeightChange( event, ui )
-{
- if( globalInUpdateSlider ) return true;
- lightHeight = ui.value * Math.PI / 180;
- show3D( roll, tilt );
-}
-
-function lightStrengthChange( event, ui )
-{
- if( globalInUpdateSlider ) return true;
- lightStrength = ui.value;
- show3D( roll, tilt );
-}
-
-function lightDistanceChange( event, ui )
-{
- if( globalInUpdateSlider ) return true;
- lightDistance = ui.value;
- show3D( roll, tilt );
-}
-
-
Copied: JSFloorPlan/trunk/src/jsfloorplan.js (from rev 587, JSFloorPlan/trunk/jsfloorplan.js)
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js (rev 0)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 13:27:38 UTC (rev 588)
@@ -0,0 +1,684 @@
+/***************************************************************************
+ * *
+ * JavaScript FloorPlan 3D *
+ * *
+ * Copyright (C) 2009, 2010 by Christian Mayer *
+ * jsfloorplan (at) ChristianMayer.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+// setup script here:
+
+// don't change anything below:
+var ELEMENT_NODE = 1;
+
+// calculate the distance between two cartesian 2D points
+function calcLength2D( start, end )
+{
+ return Math.sqrt( (end.x-start.x)*(end.x-start.x) +
+ (end.y-start.y)*(end.y-start.y) );
+}
+
+// calculate the rotation of a cartesian 2D point around the center
+function rotate2D( angle, point, center )
+{
+ var s = Math.sin( angle );
+ var c = Math.cos( angle );
+ var ret = new Object;
+ ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
+ ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
+ return ret;
+}
+
+// calculate the rotation of a cartesian 2D point around the center
+// but with given sin and cos of the angle
+function rotate2D( s, c, point, center )
+{
+ var ret = new Object;
+ ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
+ ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
+ return ret;
+}
+
+// calculate the translation of a cartesian 2D point
+function translate2D( point, translation )
+{
+ var ret = new Object;
+ ret.x = point.x + translation.x;
+ ret.y = point.y + translation.y;
+ return ret;
+}
+
+// sort two 2D unit(!) vectors clockwise
+function vecSort( a, b )
+{
+ var pseudoangle_a = a.y>=0 ? (1-a.x) : (a.x+3);
+ var pseudoangle_b = b.y>=0 ? (1-b.x) : (b.x+3);
+ return pseudoangle_a - pseudoangle_b;
+}
+
+function loadFloorplan()
+{
+ $.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
+}
+var floor;
+
+// this array will contain all vertices to show in the svg
+var vertices = Array();
+// infos about the building
+var buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+var imageCenter = new Object;
+
+var noFloorplan = true;
+function parseXMLFloorPlan( xmlDoc )
+{
+ noFloorplan = false;
+
+ var floorCount = -1;
+ var heightOfGround = 0; // the base level of the current floor
+
+ // basic check if the document seems right
+ // this could be avoided if the XML file would be validated
+ // with a DTD
+ var building;
+ if( 'building' == xmlDoc.documentElement.tagName )
+ building = xmlDoc.documentElement;
+ else
+ return alert( "ERROR: Not a valid floor plan! " +
+ "Expected: 'building', found '" + xmlDoc.documentElement.tagName + "'" );
+
+ // now we are sure to have a sensible file
+ // => iterate over all floors
+ for( var i=0; i < building.childNodes.length; i++ )
+ {
+ floor = building.childNodes[i];
+ if (floor.nodeType != ELEMENT_NODE) continue;
+
+ if( floor.tagName == 'textures' )
+ {
+ parseTextures( floor );
+ continue;
+ }
+
+ if( floor.tagName != 'floor' )
+ return alert( "ERROR: Not a valid floor plan! " +
+ "Expected: 'floor', found '" + floor.tagName + "'" );
+
+ floorCount++;
+ buildingProperties.floor[floorCount] = {};
+
+ var floorName = floor.getAttribute('name');
+ buildingProperties.floor[floorCount].name = floorName;
+
+ var floorheight = Number( floor.getAttribute('height') );
+ buildingProperties.floor[floorCount].height = floorheight;
+ buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+
+ var floorWallsStart = floorWalls.length;
+
+ // iterate over the content of this floor
+ for( var j=0; j < floor.childNodes.length; j++ )
+ {
+ floorNode = floor.childNodes[j];
+ if (floorNode.nodeType != ELEMENT_NODE) continue;
+
+ switch( floorNode.tagName )
+ {
+ case 'nodes':
+ parseFloorNodes( floorNode, floorheight );
+ break;
+
+ case 'walls':
+ parseFloorWalls( floorNode );
+ break;
+
+ case 'rooms':
+ parseFloorRooms( floorNode, floorCount );
+ break;
+ }
+ }
+
+ // now the content of the floor is stored in easily
+ // accessable objects
+ // => derive the necessary information
+
+ // group all elements on this floor
+ var Object3D = new THREE.Object3D();
+
+ // add the information to each node to which nodes it's connected to
+ for( var j = floorWallsStart; j < floorWalls.length; j++ )
+ {
+ // note: the ID is shifted by one to avoid an ID of zero
+ // as that wouldn't allow me anymore to distinguish
+ // start and stop
+ floorNodes[ floorWalls[j].start ].neighbour.push( j+1 );
+ floorNodes[ floorWalls[j].end ].neighbour.push( -j-1 );
+ }
+
+ var nodeGroup = new THREE.Object3D(); nodeGroup.name = 'nodeGroup';
+ for( var id in floorNodes )
+ {
+ // calculate the vectors showing to the neighbours
+ var vectors = new Array();
+ var start = floorNodes[id];
+
+ // show them on request as spheres
+ var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
+ sphere.position = new THREE.Vector3( start.x, start.y, heightOfGround );
+ nodeGroup.add(sphere);
+
+ for( var j=0; j<floorNodes[id].neighbour.length; j++ )
+ {
+ var vec = new Object;
+ vec.id = floorNodes[id].neighbour[j];
+ var end;
+ if( vec.id < 0 )
+ end = floorNodes[ floorWalls[ -vec.id-1 ].start ];
+ else
+ end = floorNodes[ floorWalls[ vec.id-1 ].end ];
+
+ length = calcLength2D( start, end );
+ vec.x = (end.x - start.x) / length;
+ vec.y = (end.y - start.y) / length;
+ vectors.push( vec );
+ }
+
+ // sort them clockwise
+ vectors.sort( vecSort );
+
+ // calculate the cutting points of the walls at this node id
+ for( var j=0; j<vectors.length; j++ )
+ {
+ var jj = (j+1) % vectors.length;
+ var wj = Math.abs(vectors[j ].id)-1;
+ var wjj = Math.abs(vectors[jj].id)-1;
+ var dj = floorWalls[wj ].thickness/2;
+ var djj = floorWalls[wjj].thickness/2;
+ if( floorWalls[wj ].startOffset && vectors[j ].id > 0 )
+ dj += floorWalls[wj].startOffset;
+ if( floorWalls[wj ].endOffset && vectors[j ].id < 0 )
+ dj += floorWalls[wj].endOffset;
+ if( floorWalls[wjj].startOffset && vectors[jj].id > 0 )
+ djj += -floorWalls[wjj].startOffset;
+ if( floorWalls[wjj].endOffset && vectors[jj].id < 0 )
+ djj += -floorWalls[wjj].endOffset;
+
+ vertex = new Object;
+ vertex.x = vectors[j].x*djj + vectors[jj].x*dj;
+ vertex.y = vectors[j].y*djj + vectors[jj].y*dj;
+ var l = vectors[j].x*vectors[jj].y - vectors[j].y*vectors[jj].x;
+ if( Math.abs( l ) < 1e-5 )
+ { // the angle between the two vectors is exactly 180°
+ // i.e. a straight wall...
+ if( Math.abs( dj - djj ) < 1e-5 )
+ { // at least the walls have the same thickness...
+ vertex.x = start.x - vectors[j].y*dj;
+ vertex.y = start.y + vectors[j].x*dj;
+ } else {
+ alert( "ERROR: A straight wall with different thicknesses " +
+ "is currently not supported!" );
+ // but we still try our best...
+ vertex.x = start.x - vectors[j].y*(dj+djj)/2;
+ vertex.y = start.y + vectors[j].x*(dj+djj)/2;
+ }
+ } else {
+ vertex.x = start.x + vertex.x / l;
+ vertex.y = start.y + vertex.y / l;
+ }
+
+ if( vectors[j ].id < 0 )
+ floorWalls[wj ].startVertex.push( vertices.length );
+ else
+ floorWalls[wj ].endVertex.push( vertices.length );
+
+ if( 1 == vectors.length )
+ {
+ var additional = new Object;
+ additional.x = 2 * start.x - vertex.x;
+ additional.y = 2 * start.y - vertex.y;
+ vertices.push( additional );
+ }
+
+ if( vectors[jj].id < 0 )
+ floorWalls[wjj].startVertex.push( vertices.length );
+ else
+ floorWalls[wjj].endVertex.push( vertices.length );
+
+ vertices.push( vertex );
+ }
+ } // end for( var id in floorNodes )
+ Object3D.add( nodeGroup );
+
+ // show walls
+ var lineGroup = new THREE.Object3D(); lineGroup.name = 'lineGroup';
+ var wallGroup = new THREE.Object3D(); wallGroup.name = 'wallGroup';
+ for( var j = floorWallsStart; j<floorWalls.length; j++ )
+ {
+ var vs = floorNodes[ floorWalls[j].start ];
+ var ve = floorNodes[ floorWalls[j].end ];
+ var lineGeo = new THREE.Geometry();
+ lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( vs.x, vs.y, heightOfGround ) ) );
+ lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( ve.x, ve.y, heightOfGround ) ) );
+ lineGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
+
+ var s1 = vertices[ floorWalls[j].startVertex[0] ];
+ var e1 = vertices[ floorWalls[j].endVertex [0] ];
+ var s2 = vertices[ floorWalls[j].startVertex[1] ];
+ var e2 = vertices[ floorWalls[j].endVertex [1] ];
+
+ // check that the start and end points aren't twisted
+ var v1 = new Object; v1.x = s1.x-s2.x; v1.y = s1.y-s2.y;
+ var v2 = new Object; v2.x = e1.x-s2.x; v2.y = e1.y-s2.y;
+ var v3 = new Object; v3.x = e1.x-e2.x; v3.y = e1.y-e2.y;
+ if( (v1.x*v2.y - v1.y*v2.x)*(v2.x*v3.y - v2.y*v3.x) > 0 )
+ {
+ e1 = vertices [ floorWalls[j].endVertex[1] ];
+ e2 = vertices [ floorWalls[j].endVertex[0] ];
+ }
+ var sm = floorNodes[ floorWalls[j].start ];
+ var em = floorNodes[ floorWalls[j].end ];
+ var sh = floorNodes[ floorWalls[j].start ].z ;
+ var eh = floorNodes[ floorWalls[j].end ].z ;
+ var wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
+ var geometry = new THREE.Geometry();
+
+ var normal1 = new THREE.Vector3(sm.y-em.y,-sm.x+em.x,0); // fixme? normalize
+ var normal2 = new THREE.Vector3(1,0,0);
+
+ var sourrounding = [ new poly2tri.Point(0,0), new poly2tri.Point(0,1), new poly2tri.Point(1,1), new poly2tri.Point(1,0) ];
+ sourrounding[1].startEndMarker = 'start';
+ sourrounding[2].startEndMarker = 'end';
+ var holesToAdd = [];
+
+ if( floorWalls[j].holes.length )
+ {
+ var holes = floorWalls[j].holes;
+ for( var h = 0; h < holes.length; h++ )
+ {
+ var wallLength = calcLength2D( sm, em );
+ var fLeft = holes[h].distance / wallLength;
+ var fRight = (holes[h].distance + holes[h].width) / wallLength;
+ if( fLeft <= 0.0 ) fLeft = 0.001; //// FIXME - actually the config file is bad. Leave at least 1mm wall
+ if( fRight >= 1.0 ) fRight = 0.999; //// FIXME - actually the config file is bad. Leave at least 1mm wall
+ var lintel = (sh - holes[h].lintel) / sh;
+ var paparet = holes[h].paparet / sh;
+ if( 1 == lintel )
+ {
+ // not a hole, the sourrounding goes to the groud...
+
+ if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
+
+ sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
+ continue;
+ }
+ if( 0 == paparet )
+ {
+ // not a hole, the sourrounding goes to the groud...
+
+ // lintel == 1 can't happen, it's checked in the if clause above
+
+ sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
+ continue;
+ }
+
+ holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
+ }
+ } // if( floorWalls[j].holes.length )
+ var swctx = new poly2tri.SweepContext( sourrounding.slice(0) ); // pass a copy of sourrounding
+ for( var htA = 0; htA < holesToAdd.length; htA++ )
+ swctx.AddHole( holesToAdd[htA] );
+
+ // Do the triangulation - FIXME: handle exceptions, don't ignore them...
+ try {
+ poly2tri.sweep.Triangulate(swctx);
+ }catch(err){}
+
+ // mark all points to make sure that we don't need to double vertices
+ for( var tp = 0; tp < swctx.point_count(); tp++ )
+ swctx.GetPoint( tp ).id = tp;
+
+ // translate poly2tri triangles to THREE.js faces:
+ var p2tF = [];
+ $.each(swctx.GetTriangles(), function(idx, val) {
+ p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
+ });
+
+ Tvertices = swctx.points_;
+ Tfaces = p2tF;
+ var wall1vertices = [];
+ var wall2vertices = [];
+ var sId, eId;
+ for( var v = 0; v < Tvertices.length; v++ )
+ {
+ /* prepare for later...
+ // project s1, e1 and s2, e2 onto line sm->em
+ var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
+ var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e1f = 1-((e1.x-sm.x)*(em.x-sm.x) + (e1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var s2f = 1-((s2.x-sm.x)*(em.x-sm.x) + (s2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e2f = 1-((e2.x-sm.x)*(em.x-sm.x) + (e2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+
+ var tv = Tvertices[v];
+ var tvx1 = Math.min( 1.0, Math.max( 0.0, (tv.x - s1f) * (e1f - s1f) ) ); // map between s1 and e1
+ var tvx2 = Math.min( 1.0, Math.max( 0.0, (tv.x - s2f) * (e2f - s2f) ) ); // map between s2 and e2
+ var x1 = s1.x * tvx1 + e1.x * (1 - tvx1);
+ var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
+ var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
+ var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
+ console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
+ */
+ var z = heightOfGround + sh*tv.y;
+ if( wallSideOrder > 0 )
+ {
+ wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
+ wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
+ } else {
+ wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
+ wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
+ }
+ if( 'startEndMarker' in tv )
+ {
+ if( 'start' == tv.startEndMarker )
+ {
+ sId = wall1vertices.length - 1;
+ } else {
+ eId = wall1vertices.length - 1;
+ }
+ }
+ }
+ var wall1verticesL...
[truncated message content] |
|
From: <ma...@us...> - 2011-12-18 13:24:12
|
Revision: 587
http://openautomation.svn.sourceforge.net/openautomation/?rev=587&view=rev
Author: mayerch
Date: 2011-12-18 13:24:06 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Prepare for later fix of holes
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:23:11 UTC (rev 586)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:24:06 UTC (rev 587)
@@ -365,11 +365,23 @@
var sId, eId;
for( var v = 0; v < Tvertices.length; v++ )
{
+ /* prepare for later...
+ // project s1, e1 and s2, e2 onto line sm->em
+ var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
+ var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e1f = 1-((e1.x-sm.x)*(em.x-sm.x) + (e1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var s2f = 1-((s2.x-sm.x)*(em.x-sm.x) + (s2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e2f = 1-((e2.x-sm.x)*(em.x-sm.x) + (e2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+
var tv = Tvertices[v];
- var x1 = s1.x * tv.x + e1.x * (1 - tv.x);
- var x2 = s2.x * tv.x + e2.x * (1 - tv.x);
- var y1 = s1.y * tv.x + e1.y * (1 - tv.x);
- var y2 = s2.y * tv.x + e2.y * (1 - tv.x);
+ var tvx1 = Math.min( 1.0, Math.max( 0.0, (tv.x - s1f) * (e1f - s1f) ) ); // map between s1 and e1
+ var tvx2 = Math.min( 1.0, Math.max( 0.0, (tv.x - s2f) * (e2f - s2f) ) ); // map between s2 and e2
+ var x1 = s1.x * tvx1 + e1.x * (1 - tvx1);
+ var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
+ var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
+ var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
+ console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
+ */
var z = heightOfGround + sh*tv.y;
if( wallSideOrder > 0 )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 13:23:17
|
Revision: 586
http://openautomation.svn.sourceforge.net/openautomation/?rev=586&view=rev
Author: mayerch
Date: 2011-12-18 13:23:11 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Prepare for restructuring
Added Paths:
-----------
JSFloorPlan/trunk/build/
JSFloorPlan/trunk/docs/
JSFloorPlan/trunk/release/
JSFloorPlan/trunk/src/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <net...@us...> - 2011-12-18 12:50:34
|
Revision: 585
http://openautomation.svn.sourceforge.net/openautomation/?rev=585&view=rev
Author: netzkind
Date: 2011-12-18 12:50:28 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
rearranged settings to make sense to the user
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-12-18 12:49:54 UTC (rev 584)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-12-18 12:50:28 UTC (rev 585)
@@ -109,9 +109,9 @@
return ret_val;
},
attributes: {
+ name: { type: 'string', required: true },
align: { type: 'string', required: false },
flavour: { type: 'string', required: false },
- name: { type: 'string', required: true },
ga: { type: 'addr', required: false },
visible: { type: 'string', required: false },
type: { type: 'string', required: false },
@@ -227,9 +227,9 @@
styling: { type: 'styling', required: false }
},
elements: {
- layout: { type: 'layout', required: false, multi: false },
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
});
@@ -342,9 +342,9 @@
styling: { type: 'styling', required: false }
},
elements: {
- layout: { type: 'layout', required: false, multi: false },
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
});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <net...@us...> - 2011-12-18 12:50:00
|
Revision: 584
http://openautomation.svn.sourceforge.net/openautomation/?rev=584&view=rev
Author: netzkind
Date: 2011-12-18 12:49:54 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
made Editor work with UI-fixes from #583
Modified Paths:
--------------
CometVisu/trunk/visu/edit/cometeditor.js
CometVisu/trunk/visu/edit/style_edit.css
CometVisu/trunk/visu/edit/visuconfig_edit.js
Modified: CometVisu/trunk/visu/edit/cometeditor.js
===================================================================
--- CometVisu/trunk/visu/edit/cometeditor.js 2011-12-18 11:21:22 UTC (rev 583)
+++ CometVisu/trunk/visu/edit/cometeditor.js 2011-12-18 12:49:54 UTC (rev 584)
@@ -175,7 +175,7 @@
if (typeof values._attributes != "undefined"
&& typeof values._attributes[index] != "undefined") {
- $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ $input.find("option[value='" + values._attributes[index] + "']").attr("selected", "selected");
}
break;
@@ -189,7 +189,7 @@
if (typeof values._attributes != "undefined"
&& typeof values._attributes[index] != "undefined") {
- $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ $input.find("option[value='" + values._attributes[index] + "']").attr("selected", "selected");
}
break;
@@ -204,7 +204,7 @@
if (typeof values._attributes != "undefined"
&& typeof values._attributes[index] != "undefined") {
- $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ $input.find("option[value='" + values._attributes[index] + "']").attr("selected", "selected");
}
break;
@@ -356,7 +356,7 @@
$("#" + path + ".page").insertAfter($(".page:visible:last"));
if ($("#pages .inedit").is(".widget")) {
- $("#pages .inedit").replaceWith(newWidget);
+ $("#pages .inedit").closest(".widget_container").replaceWith(newWidget);
} else {
jQuery(".page:visible:last > div").append(newWidget);
}
@@ -463,6 +463,11 @@
var myObj = {};
var e = $(element);
+
+ // if this is a widget-container, get its widget
+ if (e.is(".widget_container")) {
+ e = e.children(".widget");
+ }
myObj._type = e.data("nodeName");
myObj.textContent = e.data("textContent");
@@ -632,7 +637,7 @@
.append("<div class=\"readonly editable\" />");
//myDiv.find(".title").append();
var t = Editor.getAddressesObject();
- elementDiv.find(".title").append(t.find("option[value=" + elementData.textContent + "]").text());
+ elementDiv.find(".title").append(t.find("option[value='" + elementData.textContent + "']").text());
elementDiv.find(".value").append(elementData.textContent);
elementDiv.find(".transform").append(elementData._attributes.transform);
if (elementData._attributes.variant != "undefined" && elementData._attributes.variant != "") {
Modified: CometVisu/trunk/visu/edit/style_edit.css
===================================================================
--- CometVisu/trunk/visu/edit/style_edit.css 2011-12-18 11:21:22 UTC (rev 583)
+++ CometVisu/trunk/visu/edit/style_edit.css 2011-12-18 12:49:54 UTC (rev 584)
@@ -1,5 +1,5 @@
/* Editor-Stuff */
-.widget {position: relative;}
+.widget_container, .widget {position: relative;}
.editcontrol, .movecontrol, .removecontrol {
position: absolute;
@@ -181,8 +181,8 @@
padding-left: 120px;
}
-div.line {
- width: 97%;
+.widget_container.line {
+ width: 100%;
}
div.line hr {
Modified: CometVisu/trunk/visu/edit/visuconfig_edit.js
===================================================================
--- CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-18 11:21:22 UTC (rev 583)
+++ CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-18 12:49:54 UTC (rev 584)
@@ -71,36 +71,46 @@
});
jQuery("#pages").bind("done", function() {
+ // wrap hr and br into "widgets", so they can be moved + removed
$("#pages hr, #pages br").each(function() {
if ($(this).closest(".widget").length == 0) {
- $(this).wrap("<div class=\"widget clearfix line\" />");
+ $(this).wrap("<div class=\"widget clearfix\" />");
+ $(this).closest(".widget").wrap("<div class=\"widget_container line\" />");
var d = $.extend({}, $(this).data());
$(this).closest("div.widget").data(d);
}
});
+ // init "sortable"
jQuery(".page div").sortable({
handle: ".movecontrol",
- items: '.widget',
+ items: '.widget_container',
stop: function(event, ui) {
//console.log(jQuery(this).sortable("toArray"));
// hier haben wir eine neue Config
}
});
- jQuery(".widget").unbind("mouseenter.edit").bind("mouseenter.edit", function() {
+ // create buttons for edit, move, remove
+ jQuery(".widget_container").unbind("mouseenter.edit").bind("mouseenter.edit", function() {
jQuery(this).data("background-color-old", jQuery(this).css("background-color"));
- $(this).prepend(jQuery("<div />").attr("class", "movecontrol"));
- $(this).prepend(jQuery("<div />").attr("class", "editcontrol").html("edit"));
- $(this).prepend(jQuery("<div />").attr("class", "removecontrol").html("x"));
+ if ($(this).find("div.movecontrol").is("div")) {
+ jQuery(this).find("div.editcontrol, div.movecontrol, div.removecontrol").show();
+ } else {
+ $(this).prepend(jQuery("<div />").attr("class", "movecontrol"));
+ $(this).prepend(jQuery("<div />").attr("class", "editcontrol").html("edit"));
+ $(this).prepend(jQuery("<div />").attr("class", "removecontrol").html("x"));
+ }
});
- jQuery(".widget").unbind("mouseleave.edit").bind("mouseleave.edit", function() {
+ // remove buttons when cursor leaves
+ jQuery(".widget_container").unbind("mouseleave.edit").bind("mouseleave.edit", function() {
jQuery(this).css("background-color", jQuery(this).data("background-color-old"));
- jQuery(this).find("div.editcontrol, div.movecontrol, div.removecontrol").remove();
+ jQuery(this).find("div.editcontrol, div.movecontrol, div.removecontrol").hide();
});
+ // create list of widgets to be insertable/editable
var options = {};
$("#addMaster").find("select#add_type").empty();
jQuery.each(design.creators, function (index, e) {
@@ -120,8 +130,9 @@
});
});
+ // act on "remove"-Clicks
jQuery(".removecontrol").live("click", function() {
- var widget = $(this).parents("div.widget");
+ var widget = $(this).siblings("div.widget");
var data = Editor.getWidgetData(widget, true);
var t;
@@ -132,15 +143,16 @@
}
var b = confirm(lingua("confirm_delete", t));
if (b) {
- widget.remove();
+ widget.closest(".widget_container").remove();
}
});
+ // act on "edit"-clicks
jQuery(".editcontrol").live("click", function() {
$("#addMaster").triggerHandler("cleanup");
- var widget = $(this).parents("div.widget");
+ var widget = $(this).siblings("div.widget");
if (widget.is(".pagelink")) {
return renamePage(widget);
}
@@ -152,11 +164,12 @@
$("#addMaster").data("widgetdata", data);
- $("#addMaster #add_type").find("option[value=" + data._type + "]").attr("selected", "selected");
+ $("#addMaster #add_type").find("option[value='" + data._type + "']").attr("selected", "selected");
$("#addMaster").triggerHandler("show");
});
+ // multi-element edits, like "address"
jQuery(".multi_element .element").live("click", function() {
$this = jQuery(this);
if ($this.is(".inedit")) {
@@ -214,12 +227,12 @@
if ($dptField.is("input")) {
$dptField.val(dpt);
} else if ($dptField.is("select")) {
- $dptField.find("option[value=" + dpt + "]").attr("selected", "selected");
+ $dptField.find("option[value='" + dpt + "']").attr("selected", "selected");
}
});
if (typeof $e.text() != "undefined") {
- myElement.find("option[value=" + $e.text() + "]").attr("selected", "selected");
+ myElement.find("option[value='" + $e.text() + "']").attr("selected", "selected");
}
}
@@ -241,7 +254,7 @@
myElement.find("select:first").append(Editor.getDPTObject());
if (typeof $e.text() != "undefined") {
- myElement.find("option[value=" + $e.text() + "]").attr("selected", "selected");
+ myElement.find("option[value='" + $e.text() + "']").attr("selected", "selected");
}
}
@@ -314,7 +327,9 @@
);
});
+ // edit-"window"
jQuery("#addMaster")
+ // act on "show"
.bind("show", function() {
if ($("#pages .inedit").is(".widget")) {
$(this).find(".create").hide().end().find(".edit").show();
@@ -325,7 +340,7 @@
// if we have widget-specific data, we must be in edit-mode
var widgetdata = $(this).data("widgetdata");
if (typeof widgetdata != "undefined") {
- $(this).find("#add_type").find("option[value=" + widgetdata._type + "]").attr("selected", "selected").trigger("change");
+ $(this).find("#add_type").find("option[value='" + widgetdata._type + "']").attr("selected", "selected").trigger("change");
}
$(this).show()
@@ -333,20 +348,24 @@
jQuery(".page div").sortable("destroy");
jQuery(".widget").unbind("mouseenter.edit").trigger("mouseleave.edit").unbind("mouseleave.edit");
})
+ // act on "hide"
.bind("hide", function() {
$(this).hide();
$("#pages").triggerHandler("done");
})
+ // cleanup
.bind("cleanup", function() {
$(this).removeData("widgetdata");
jQuery(this).find("input[type=text]").val("");
$("#addMaster div.inputs").empty();
$("#pages").find(".inedit").removeClass("inedit");
})
+ // cancel: hide and cleanup
.find("#add_cancel").click(function() {
jQuery("#addMaster").trigger("hide").trigger("cleanup")
})
.end()
+ // act on changes of widget-type (the select-list)
.find("#add_type").change(function() {
// the type has been changed
// we need to change the input-field accordingly to match
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <net...@us...> - 2011-12-18 11:21:31
|
Revision: 583
http://openautomation.svn.sourceforge.net/openautomation/?rev=583&view=rev
Author: netzkind
Date: 2011-12-18 11:21:22 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
correct width for widgets on small-screen devices, no longer css-calc widths; Tested on Windows (FF8, Chrome 15), Built-in browsers of: Samsung Galaxy S2 (Gingerbread), Samsung Galaxy Tab 10.1 (Honeycomb), iPhone 3GS (iOS 5), Samsung Galaxy S (Gingerbread)
Modified Paths:
--------------
CometVisu/trunk/visu/designs/alaska/basic.css
CometVisu/trunk/visu/designs/alaska/mobile.css
CometVisu/trunk/visu/designs/alaska_slim/basic.css
CometVisu/trunk/visu/designs/alaska_slim/mobile.css
CometVisu/trunk/visu/designs/discreet/basic.css
CometVisu/trunk/visu/designs/discreet/mobile.css
CometVisu/trunk/visu/designs/discreet_sand/basic.css
CometVisu/trunk/visu/designs/discreet_sand/mobile.css
CometVisu/trunk/visu/designs/discreet_slim/basic.css
CometVisu/trunk/visu/designs/discreet_slim/mobile.css
CometVisu/trunk/visu/designs/pure/basic.css
CometVisu/trunk/visu/designs/pure/mobile.css
CometVisu/trunk/visu/designs/structure_custom.js
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/edit/visuconfig_edit.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
CometVisu/trunk/visu/plugins/gweather/structure_plugin.js
CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js
CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js
CometVisu/trunk/visu/plugins/rss/structure_plugin.js
Modified: CometVisu/trunk/visu/designs/alaska/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska/basic.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/alaska/basic.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -87,10 +87,17 @@
text-decoration: none;
}
+.widget_container {
+ width: 50%;
+ float: left;
+}
+
+.widget_container .widget_container {
+ width: 100%;
+}
+
.widget
{
- float:left;
- width:48%;
margin: 0.2em;
padding: 0.2em;
border-style: solid none none none; /* oben rechts unten links */
@@ -99,11 +106,6 @@
background: transparent;
}
-.widget .widget
-{
- width:98%;
-}
-
.text > div, .link > a
{
float:left;
Modified: CometVisu/trunk/visu/designs/alaska/mobile.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska/mobile.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/alaska/mobile.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,14 +1,11 @@
-.widget
-{
- width:98%;
-}
-
-#bottom
-{
- display: none;
-}
-
-.page
-{
- overflow: visible;
-}
+.widget_container {
+ width: 98%;
+}
+
+#bottom {
+ display: none;
+}
+
+.page {
+ overflow: visible;
+}
Modified: CometVisu/trunk/visu/designs/alaska_slim/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska_slim/basic.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/alaska_slim/basic.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -82,10 +82,17 @@
text-decoration: none;
}
+.widget_container {
+ width: 33%;
+ float: left;
+}
+
+.widget_container .widget_container {
+ width: 100%;
+}
+
.widget
{
- float:left;
- width:32%;
margin: 0.2em;
padding: 0.2em;
border-style: solid none none none; /* oben rechts unten links */
@@ -94,11 +101,6 @@
background: transparent;
}
-.widget .widget
-{
- width:98%;
-}
-
.text > div, .link > a {
float:left;
text-align:left;
Modified: CometVisu/trunk/visu/designs/alaska_slim/mobile.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska_slim/mobile.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/alaska_slim/mobile.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,14 +1,11 @@
-.widget
-{
- width:98%;
-}
-
-#bottom
-{
- display: none;
-}
-
-.page
-{
- overflow: visible;
-}
+.widget_container {
+ width: 98%;
+}
+
+#bottom {
+ display: none;
+}
+
+.page {
+ overflow: visible;
+}
Modified: CometVisu/trunk/visu/designs/discreet/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet/basic.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/discreet/basic.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -81,10 +81,17 @@
vertical-align: middle;
}
+.widget_container {
+ width: 50%;
+ float: left;
+}
+
+.widget_container .widget_container {
+ width: 100%;
+}
+
.widget
{
- float:left;
- width:48%;
margin: .2em;
padding: 0.3em;
/* border:yellow 1px solid; */
@@ -98,11 +105,6 @@
background-color: #101010;
}
-.widget .widget
-{
- width:98%;
-}
-
.text > div,
.link > a {
float:left;
Modified: CometVisu/trunk/visu/designs/discreet/mobile.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet/mobile.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/discreet/mobile.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,12 +1,11 @@
-.widget
-{
- width:98%;
-}
-
-#bottom {
- display: none;
-}
-
-.page {
- overflow: visible;
-}
+.widget_container {
+ width: 98%;
+}
+
+#bottom {
+ display: none;
+}
+
+.page {
+ overflow: visible;
+}
Modified: CometVisu/trunk/visu/designs/discreet_sand/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_sand/basic.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/discreet_sand/basic.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,377 +1,383 @@
-@font-face { font-family: Liberation; src:url(fonts/liberationsans.ttf); }
-@font-face { font-family: Liberation; font-weight: bold; src:url(fonts/liberationsans-bold.ttf); }
-
-body
-{
- color: #453420; /*#2F2A20;*/
- font-family: Arial, Liberation;
- font-size: 5.5mm;
- overflow: hidden;
- margin:0;
- background: #CFC8B5; /* url(images/body_bg.png) repeat-x; */
-}
-
-h1
-{
- font-size: 2em;
- padding-left: 15px;
-}
-
-body hr
-{
- clear:both;
- color: #7F735F;
- background-color: #7F735F;
- height: 1px;
- border:none;
- padding:0px;
- margin:0.1em;
-}
-
-#pages hr {
- border: 0; height: 30px; margin: 0 .5%;
- background: transparent url(images/hr_bg.png) 50% repeat-x;
- clear: both;
-}
-
-
-body br
-{
- clear:both;
-}
-
-div#top {
- padding-top: 8px;
- border-top: 3px solid #BAAF98;
- background: #165D7E url(images/nav_bg.png) bottom repeat-x;
- padding-bottom: 8px;
-}
-
-.page h1 {
- margin-top: 0;
- padding-top: .1em;
- background: #CFC8B5;
- color: #2F2A20;
- /*background: #7F735F url(images/head_bg.png) scroll repeat-x bottom;*/
-}
-
-.nav_path
-{
- color: #EFEBE0; /*#81664b;*/
- margin-left: 15px;
-}
-.nav_path a
-{
- color: #EFEBE0; /*#3F3327;*/
- text-decoration:none;
-}
-
-.footer,
-.footer *
-{
- color: #000000;
- font-size: 0.9em;
- vertical-align: middle;
-}
-
-.widget
-{
- float:left;
- width:48%;
- margin: .2em;
- padding: 0.3em;
- /* border:yellow 1px solid; */
- border-color: #7F735F;
- border-style: solid;
- border-width: 2px 0px 0px 2px;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- border-radius: 8px;
- min-height: 2em;
- background-color: #BAAF98;
-}
-
-.text > div,
-.link > a {
- float:left;
- text-align:left;
- padding-left: 1em;
-}
-
-.widget .label,
-.widget.info .actor,
-.text > div,
-.link > a {
- line-height: 2em;
-}
-
-.widget .label
-{
- float:left;
- width:49%;
-/* color:red; */
-/* padding-right:0.25em; */
- text-align:left;
- padding-left: 1em;
-/* border:blue 1px solid; */
-}
-.widget .actor
-{
- float:left;
- margin-left:1em;
- text-align:left;
-}
-.widget .actor div
-{
- float:left;
- white-space: pre-wrap;
-}
-
-
-.green.switchPressed div, .green.switchUnpressed div{
- background: transparent url(images/dot_green.png) no-repeat center center;
- color: #3F2F1F !important;
-}
-.red.switchPressed div, .red.switchUnpressed div{
- background: transparent url(images/dot_red.png) no-repeat center center;
- color: #3F2F1F !important;
-}
-
-
-.red
-{
- color:#f44;
- font-weight:bold;
-}
-
-.green
-{
- color:#4f4;
-}
-
-.blue
-{
- color:#44f;
-}
-
-.purple
-{
- color:#f4f;
-}
-
-.link a
-{
- color: #165d7e; /*#3F2F1F;*/
- width: 49%;
-}
-
-.page
-{
- float:left;
- width: 900px;
- overflow: auto;
- position: relative;
-}
-
-.switchPressed, .switchUnpressed {
- border-style: solid;
- -moz-border-radius: 12px;
- -webkit-border-radius: 12px;
- border-radius: 12px;
- padding: 1px;
- background: url(images/button_bg.png) #A79367 repeat-x;
-}
-
-.switchUnpressed
-{
- border-width: 1px 2px 2px 1px;
- border-color: #6C6251 #4F483B #4F483B #6C6251;
- margin-top: 0px;
- background-color: #EFE6D1;
- background-position: center +2px;
-}
-.switchUnpressed div, .switchPressed div
-{
- padding: 5px;
- width: 5em;
- float: left;
- background: transparent;
- text-align: center;
- cursor: pointer;
-}
-
-.switchPressed
-{
- border-width: 2px 1px 1px 2px;
- border-color: #4F483B #6C6251 #6C6251 #4F483B;
- margin-top: 1px;
- background-position: center -2px;
-}
-
-.switchUnpressed div {
- margin-left: -1px;
-}
-
-.switchPressed div {
- margin-top: -1px;
-}
-
-.ui-slider { position: relative; text-align: left; }
-.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.6em; height: 1.6em; cursor: default; }
-.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
-
-.ui-slider-horizontal { height: .8em; }
-.ui-slider-horizontal .ui-slider-handle { top: -.5em; margin-left: -.8em; }
-.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
-.ui-slider-horizontal .ui-slider-range-min { left: 0; }
-.ui-slider-horizontal .ui-slider-range-max { right: 0; }
-
-.ui-slider-vertical { width: .8em; height: 100px; }
-.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
-.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
-.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
-.ui-slider-vertical .ui-slider-range-max { top: 0; }
-.ui-widget-content { border: 1px solid #dddddd; background: #000 ; color: #000; }
-.ui-widget-content a { color: #333333; }
-.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
-.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
-.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
-
-.dim .actor
-{
- width: 3em;
-}
-.widget .ui-slider
-{
- width: 30%;
- float: left;
- margin-left: 10px;
- margin-left: 1em;
- margin-top: 0.5em;
- border-color: #4F483B #6C6251 #6C6251 #4F483B;
- background: url(images/gradient.png) #F8EFC6 repeat-y;
-}
-
-.widget .ui-slider-handle
-{
- border-style: solid;
- -moz-border-radius: 12px;
- -webkit-border-radius: 12px;
- border-radius: 12px;
- padding: 1px;
- background: url(images/button_bg.png) #A79367 repeat-x;
- border-width: 1px 2px 2px 1px;
- border-color: #6C6251 #4F483B #4F483B #6C6251;
-}
-/* Clearfix */
-.clearfix:after {
- content: ".";
- display: block;
- clear: both;
- visibility: hidden;
- line-height: 0;
- height: 0;
-}
-
-.clearfix {
- display: inline-block;
-}
-
-html[xmlns] .clearfix {
- display: block;
-}
-
-*:first-child+html .clearfix {
- min-height: 0;
-}
-
-* html .clearfix {
- height: 1%;
-}
-
-* html>body .clearfix {
- display: inline-block;
- width: 100%;
-}
-
-* html .clearfix {
- /* Hides from IE-mac \*/
- height: 1%;
- /* End hide from IE-mac */
-}
-
-.loading {
- display: block !important;
-}
-
-div#loading {
- display: none !important;
-}
-
-
-.popup,
-.popup_background {
- position: absolute;
- width: 90%;
- height: 90%;
- top: 5%;
- left: 5%;
-}
-
-.popup {
- z-index: 101;
- background: transparent;
-}
-
-
-.popup_background {
- z-index: 100;
- border-color: #7F735F;
- border-style: solid;
- border-width: 2px 0px 0px 2px;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- border-radius: 8px;
- background: #BAAF98;
- opacity: .98;
-}
-
-.popup div {
- margin: 4px;
-}
-
-.popup div.head {
- border-bottom: 1px solid;
-}
-
-.popup_background.error {
- background: #800000;
- border: #f00;
-}
-
-.clickable {
- cursor: pointer;
-}
-
-.diagram_inline {
- width: 320px;
- height: 180px;
-}
-
-.diagram_preview {
- width: 320px;
- height: 2em;
-}
-
-.tickLabel {
- color: #453420;
-}
-
-#diagramTooltip {
- z-index: 1000;
- color: black;
- border: 1px solid #fdd;
- padding: 2px;
- background-color: #fee;
- opacity: 0.80;
+@font-face { font-family: Liberation; src:url(fonts/liberationsans.ttf); }
+@font-face { font-family: Liberation; font-weight: bold; src:url(fonts/liberationsans-bold.ttf); }
+
+body
+{
+ color: #453420; /*#2F2A20;*/
+ font-family: Arial, Liberation;
+ font-size: 5.5mm;
+ overflow: hidden;
+ margin:0;
+ background: #CFC8B5; /* url(images/body_bg.png) repeat-x; */
+}
+
+h1
+{
+ font-size: 2em;
+ padding-left: 15px;
+}
+
+body hr
+{
+ clear:both;
+ color: #7F735F;
+ background-color: #7F735F;
+ height: 1px;
+ border:none;
+ padding:0px;
+ margin:0.1em;
+}
+
+#pages hr {
+ border: 0; height: 30px; margin: 0 .5%;
+ background: transparent url(images/hr_bg.png) 50% repeat-x;
+ clear: both;
+}
+
+
+body br
+{
+ clear:both;
+}
+
+div#top {
+ padding-top: 8px;
+ border-top: 3px solid #BAAF98;
+ background: #165D7E url(images/nav_bg.png) bottom repeat-x;
+ padding-bottom: 8px;
+}
+
+.page h1 {
+ margin-top: 0;
+ padding-top: .1em;
+ background: #CFC8B5;
+ color: #2F2A20;
+ /*background: #7F735F url(images/head_bg.png) scroll repeat-x bottom;*/
+}
+
+.nav_path
+{
+ color: #EFEBE0; /*#81664b;*/
+ margin-left: 15px;
+}
+.nav_path a
+{
+ color: #EFEBE0; /*#3F3327;*/
+ text-decoration:none;
+}
+
+.footer,
+.footer *
+{
+ color: #000000;
+ font-size: 0.9em;
+ vertical-align: middle;
+}
+
+.widget_container {
+ width: 50%;
+ float: left;
+}
+
+.widget_container .widget_container {
+ width: 100%;
+}
+
+.widget
+{
+ margin: .2em;
+ padding: 0.3em;
+ border-color: #7F735F;
+ border-style: solid;
+ border-width: 2px 0px 0px 2px;
+ -moz-border-radius: 8px;
+ -webkit-border-radius: 8px;
+ border-radius: 8px;
+ min-height: 2em;
+ background-color: #BAAF98;
+}
+
+.text > div,
+.link > a {
+ float:left;
+ text-align:left;
+ padding-left: 1em;
+}
+
+.widget .label,
+.widget.info .actor,
+.text > div,
+.link > a {
+ line-height: 2em;
+}
+
+.widget .label
+{
+ float:left;
+ width:49%;
+/* color:red; */
+/* padding-right:0.25em; */
+ text-align:left;
+ padding-left: 1em;
+/* border:blue 1px solid; */
+}
+.widget .actor
+{
+ float:left;
+ margin-left:1em;
+ text-align:left;
+}
+.widget .actor div
+{
+ float:left;
+ white-space: pre-wrap;
+}
+
+
+.green.switchPressed div, .green.switchUnpressed div{
+ background: transparent url(images/dot_green.png) no-repeat center center;
+ color: #3F2F1F !important;
+}
+.red.switchPressed div, .red.switchUnpressed div{
+ background: transparent url(images/dot_red.png) no-repeat center center;
+ color: #3F2F1F !important;
+}
+
+
+.red
+{
+ color:#f44;
+ font-weight:bold;
+}
+
+.green
+{
+ color:#4f4;
+}
+
+.blue
+{
+ color:#44f;
+}
+
+.purple
+{
+ color:#f4f;
+}
+
+.link a
+{
+ color: #165d7e; /*#3F2F1F;*/
+ width: 49%;
+}
+
+.page
+{
+ float:left;
+ width: 900px;
+ overflow: auto;
+ position: relative;
+}
+
+.switchPressed, .switchUnpressed {
+ border-style: solid;
+ -moz-border-radius: 12px;
+ -webkit-border-radius: 12px;
+ border-radius: 12px;
+ padding: 1px;
+ background: url(images/button_bg.png) #A79367 repeat-x;
+}
+
+.switchUnpressed
+{
+ border-width: 1px 2px 2px 1px;
+ border-color: #6C6251 #4F483B #4F483B #6C6251;
+ margin-top: 0px;
+ background-color: #EFE6D1;
+ background-position: center +2px;
+}
+.switchUnpressed div, .switchPressed div
+{
+ padding: 5px;
+ width: 5em;
+ float: left;
+ background: transparent;
+ text-align: center;
+ cursor: pointer;
+}
+
+.switchPressed
+{
+ border-width: 2px 1px 1px 2px;
+ border-color: #4F483B #6C6251 #6C6251 #4F483B;
+ margin-top: 1px;
+ background-position: center -2px;
+}
+
+.switchUnpressed div {
+ margin-left: -1px;
+}
+
+.switchPressed div {
+ margin-top: -1px;
+}
+
+.ui-slider { position: relative; text-align: left; }
+.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.6em; height: 1.6em; cursor: default; }
+.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
+
+.ui-slider-horizontal { height: .8em; }
+.ui-slider-horizontal .ui-slider-handle { top: -.5em; margin-left: -.8em; }
+.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
+.ui-slider-horizontal .ui-slider-range-min { left: 0; }
+.ui-slider-horizontal .ui-slider-range-max { right: 0; }
+
+.ui-slider-vertical { width: .8em; height: 100px; }
+.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
+.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
+.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
+.ui-slider-vertical .ui-slider-range-max { top: 0; }
+.ui-widget-content { border: 1px solid #dddddd; background: #000 ; color: #000; }
+.ui-widget-content a { color: #333333; }
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
+.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
+
+.dim .actor
+{
+ width: 3em;
+}
+.widget .ui-slider
+{
+ width: 30%;
+ float: left;
+ margin-left: 10px;
+ margin-left: 1em;
+ margin-top: 0.5em;
+ border-color: #4F483B #6C6251 #6C6251 #4F483B;
+ background: url(images/gradient.png) #F8EFC6 repeat-y;
+}
+
+.widget .ui-slider-handle
+{
+ border-style: solid;
+ -moz-border-radius: 12px;
+ -webkit-border-radius: 12px;
+ border-radius: 12px;
+ padding: 1px;
+ background: url(images/button_bg.png) #A79367 repeat-x;
+ border-width: 1px 2px 2px 1px;
+ border-color: #6C6251 #4F483B #4F483B #6C6251;
+}
+/* Clearfix */
+.clearfix:after {
+ content: ".";
+ display: block;
+ clear: both;
+ visibility: hidden;
+ line-height: 0;
+ height: 0;
+}
+
+.clearfix {
+ display: inline-block;
+}
+
+html[xmlns] .clearfix {
+ display: block;
+}
+
+*:first-child+html .clearfix {
+ min-height: 0;
+}
+
+* html .clearfix {
+ height: 1%;
+}
+
+* html>body .clearfix {
+ display: inline-block;
+ width: 100%;
+}
+
+* html .clearfix {
+ /* Hides from IE-mac \*/
+ height: 1%;
+ /* End hide from IE-mac */
+}
+
+.loading {
+ display: block !important;
+}
+
+div#loading {
+ display: none !important;
+}
+
+
+.popup,
+.popup_background {
+ position: absolute;
+ width: 90%;
+ height: 90%;
+ top: 5%;
+ left: 5%;
+}
+
+.popup {
+ z-index: 101;
+ background: transparent;
+}
+
+
+.popup_background {
+ z-index: 100;
+ border-color: #7F735F;
+ border-style: solid;
+ border-width: 2px 0px 0px 2px;
+ -moz-border-radius: 8px;
+ -webkit-border-radius: 8px;
+ border-radius: 8px;
+ background: #BAAF98;
+ opacity: .98;
+}
+
+.popup div {
+ margin: 4px;
+}
+
+.popup div.head {
+ border-bottom: 1px solid;
+}
+
+.popup_background.error {
+ background: #800000;
+ border: #f00;
+}
+
+.clickable {
+ cursor: pointer;
+}
+
+.diagram_inline {
+ width: 320px;
+ height: 180px;
+}
+
+.diagram_preview {
+ width: 320px;
+ height: 2em;
+}
+
+.tickLabel {
+ color: #453420;
+}
+
+#diagramTooltip {
+ z-index: 1000;
+ color: black;
+ border: 1px solid #fdd;
+ padding: 2px;
+ background-color: #fee;
+ opacity: 0.80;
}
\ No newline at end of file
Modified: CometVisu/trunk/visu/designs/discreet_sand/mobile.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_sand/mobile.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/discreet_sand/mobile.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,12 +1,11 @@
-.widget
-{
- width:98%;
-}
-
-#bottom {
- display: none;
-}
-
-.page {
- overflow: visible;
-}
+.widget_container {
+ width: 98%;
+}
+
+#bottom {
+ display: none;
+}
+
+.page {
+ overflow: visible;
+}
Modified: CometVisu/trunk/visu/designs/discreet_slim/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_slim/basic.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/discreet_slim/basic.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -74,10 +74,17 @@
vertical-align: middle;
}
+.widget_container {
+ width: 33%;
+ float: left;
+}
+
+.widget_container .widget_container {
+ width: 100%;
+}
+
.widget
{
- float:left;
- width:32%;
margin: .1em;
padding: 0.15em;
/* border:yellow 1px solid; */
@@ -88,11 +95,6 @@
background-color: #101010;
}
-.widget .widget
-{
- width:98%;
-}
-
.text > div,
.link > a {
float:left;
Modified: CometVisu/trunk/visu/designs/discreet_slim/mobile.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_slim/mobile.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/discreet_slim/mobile.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,12 +1,11 @@
-.widget
-{
- width:98%;
-}
-
-#bottom {
- display: none;
-}
-
-.page {
- overflow: visible;
-}
+.widget_container {
+ width: 98%;
+}
+
+#bottom {
+ display: none;
+}
+
+.page {
+ overflow: visible;
+}
Modified: CometVisu/trunk/visu/designs/pure/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/basic.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/pure/basic.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,475 +1,468 @@
-body
-{
- background-color: black;
- color: white;
- font-family: Verdana, Helvetica, sans-serif;
- font-family: 'URW Gothic L','Century Gothic','Apple Gothic',Arial,sans-serif;
- font-size: 5mm;
- overflow: hidden;
- margin:0;
- -moz-user-select: none;
- -khtml-user-select: none;
- -webkit-user-select: none;
- user-select: none;
-}
-
-h1
-{
- font-size: 2em;
- margin-left: 15px;
-}
-
-h2
-{
- font-size: 1.25em;
- margin-left: 15px;
- margin-top: 5px;
- margin-bottom: 5px;
-}
-
-body hr
-{
- clear:both;
- color: #ff8000;
- background-color: #ff8000;
- height: 1px;
- border:none;
- padding:0px;
- margin:0.1em;
-}
-
-body br
-{
- clear:both;
-}
-
-.nav_path
-{
- color: #ff8000;
- margin-left: 15px;
-}
-.nav_path a
-{
- color: white;
- text-decoration:none;
-}
-
-.footer,
-.footer *
-{
- color: #ff8000;
- font-size: 0.9em;
- vertical-align: middle;
-}
-
-.widget
-{
- float:left;
- width:48%; /* dumb fallback */
- width: -moz-calc(50% - 0.6em);
- width: -webkit-calc(50% - 0.6em);
- width: -o-calc(50% - 0.6em);
- width: calc(50% - 0.6em);
- margin:0.10em;
- padding:0.1em;
- /* border:yellow 1px solid; */
- border: none;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- border-radius: 5px;
- min-height: 2em;
-}
-
-.editmode .widget
-{
- border: 1px solid #444;
-}
-
-.widget .widget
-{
- width:98%; /* dumb fallback */
- width: -moz-calc(100% - 0.6em);
- width: -webkit-calc(100% - 0.6em);
- width: -o-calc(100% - 0.6em);
- width: calc(100% - 0.6em);
-}
-
-.widget .label,
-.widget.info .actor,
-.text > div,
-.link > a {
- padding: 5px;
-}
-
-.widget .label
-{
- float:left;
- width:49%;
-/* color:red; */
-/* padding-right:0.25em; */
- text-align:right;
-/* border:blue 1px solid; */
-}
-
-.widget .actor
-{
- float:left;
- margin-left:1em;
-}
-
-.widget .actor div
-{
- float:left;
- white-space: pre-wrap;
-}
-
-.center
-{
- text-align:center;
-}
-
-.left
-{
- text-align:left;
-}
-
-.right
-{
- text-align:right;
-}
-
-.red
-{
- color:#f44;
-
-}
-
-.green
-{
- color:#4f4;
-}
-
-.blue
-{
- color:#44f;
-}
-
-.purple
-{
- color:#f4f;
-}
-
-.link a
-{
- color: #ff8000;
- text-align: right;
- width: 49%;
- padding: 5px;
-}
-
-.page
-{
- float:left;
- width: 900px;
- overflow: auto;
- position: relative;
-}
-
-.switchUnpressed
-{
- border-style: solid;
- border-width: 1px;
- border-color: #666 #444 #444 #666;
- -moz-border-radius: 7px;
- -webkit-border-radius: 7px;
- border-radius: 7px;
- padding: 1px;
-}
-.switchUnpressed div
-{
- border-style: solid;
- border-width: 1px;
- border-color: #fff #666 #666 #fff;
- padding: 3px;
- width: 5em;
- float: left;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- border-radius: 5px;
-}
-
-.switchPressed
-{
- border-style: solid;
- border-width: 1px;
- border-color: #666 #fff #fff #666;
- -moz-border-radius: 7px;
- -webkit-border-radius: 7px;
- border-radius: 7px;
- padding: 1px;
-}
-.switchPressed div
-{
- border-style: solid;
- border-width: 1px;
- border-color: #444 #666 #666 #444;
- padding: 3px;
- width: 5em;
- float: left;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- border-radius: 5px;
-}
-
-.switchInvisible
-{
- border: none;
- padding: 1px;
-}
-
-.switchInvisible div
-{
- border: none;
- padding: 5px;
- width: 5em;
- float: left;
-}
-
-.ui-slider { position: relative; text-align: left; }
-.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.6em; height: 1.6em; cursor: default; }
-.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
-
-.ui-slider-horizontal { height: .8em; }
-.ui-slider-horizontal .ui-slider-handle { top: -.5em; margin-left: -.8em; }
-.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
-.ui-slider-horizontal .ui-slider-range-min { left: 0; }
-.ui-slider-horizontal .ui-slider-range-max { right: 0; }
-
-.ui-slider-vertical { width: .8em; height: 100px; }
-.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
-.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
-.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
-.ui-slider-vertical .ui-slider-range-max { top: 0; }
-.ui-widget-content { border: 1px solid #dddddd; background: #000 ; color: #000; }
-.ui-widget-content a { color: #333333; }
-.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
-.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
-.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
-
-.dim .actor
-{
- width: 3em;
-}
-.widget .ui-slider
-{
- width: 30%;
- float: left;
- margin-left: 10px;
- margin-left: 1em;
- margin-top: 0.5em;
- border-color: #666 #fff #fff #666;
-}
-
-.widget .ui-slider-handle
-{
- border-color: #fff #666 #666 #fff;
-}
-/* Clearfix */
-.clearfix:after {
- content: ".";
- display: block;
- clear: both;
- visibility: hidden;
- line-height: 0;
- height: 0;
-}
-
-.clearfix {
- display: inline-block;
-}
-
-html[xmlns] .clearfix {
- display: block;
-}
-
-*:first-child+html .clearfix {
- min-height: 0;
-}
-
-* html .clearfix {
- height: 1%;
-}
-
-* html>body .clearfix {
- display: inline-block;
- width: 100%;
-}
-
-* html .clearfix {
- /* Hides from IE-mac \*/
- height: 1%;
- /* End hide from IE-mac */
-}
-
-.loading {
- display: block !important;
-}
-
-div#loading {
- display: none !important;
-}
-
-.popup,
-.popup_background {
- position: absolute;
- width: 90%;
- height: 90%;
- top: 5%;
- left: 5%;
-}
-
-.popup {
- z-index: 101;
- background: transparent;
-}
-
-
-.popup_background {
- z-index: 100;
- -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
- background: #000;
- border: 1px solid #fff;
- opacity: 0.75;
-}
-
-.popup div {
- margin: 4px;
-}
-
-.popup div.head {
- border-bottom: 1px solid;
-}
-
-.popup_background.error {
- background: #800000;
- border: #f00;
-}
-
-.clickable {
- cursor: pointer;
-}
-
-.diagram_inline {
- width: 320px;
- height: 180px;
-}
-
-.diagram_preview {
- width: 240px;
- height: 2em;
-}
-
-#diagramTooltip {
- z-index: 1000;
- color: black;
- border: 1px solid #fdd;
- padding: 2px;
- background-color: #fee;
- opacity: 0.80;
-}
-
-/*****************************************************************************/
-/* The definition of the flavours - overwrite the generic settings */
-/*****************************************************************************/
-
-.flavour_black hr
-{
- background-color: #000000;
-}
-.flavour_black .link a
-{
- color: #000000;
-}
-.flavour_black.group
-{
- border: #000000 1px solid;
-}
-
-.flavour_white hr
-{
- background-color: #ffffff;
-}
-.flavour_white .link a
-{
- color: #ffffff;
-}
-.flavour_white.group
-{
- border: #ffffff 1px solid;
-}
-
-.flavour_antimony hr
-{
- background-color: #00ddff;
-}
-.flavour_antimony .link a
-{
- color: #00ddff;
-}
-.flavour_antimony.group
-{
- border: #00ddff 1px solid;
-}
-
-.flavour_boron hr
-{
- background-color: #00ff11;
-}
-.flavour_boron .link a
-{
- color: #00ff11;
-}
-.flavour_boron.group
-{
- border: #00ff11 1px solid;
-}
-
-.flavour_lithium hr
-{
- background-color: #ff0000;
-}
-.flavour_lithium .link a
-{
- color: #ff0000;
-}
-.flavour_lithium.group
-{
- border: #ff0000 1px solid;
-}
-
-.flavour_potassium hr
-{
- background-color: #d00055;
-}
-.flavour_potassium .link a
-{
- color: #d00055;
-}
-.flavour_potassium.group
-{
- border: #d00055 1px solid;
-}
-
-.flavour_sodium hr
-{
- background-color: #ff8000;
-}
-.flavour_sodium .link a
-{
- color: #ff8000;
-}
-.flavour_sodium.group
-{
- border: #ff8000 1px solid;
-}
-
+body
+{
+ background-color: black;
+ color: white;
+ font-family: Verdana, Helvetica, sans-serif;
+ font-family: 'URW Gothic L','Century Gothic','Apple Gothic',Arial,sans-serif;
+ font-size: 5mm;
+ overflow: hidden;
+ margin:0;
+ -moz-user-select: none;
+ -khtml-user-select: none;
+ -webkit-user-select: none;
+ user-select: none;
+}
+
+h1
+{
+ font-size: 2em;
+ margin-left: 15px;
+}
+
+h2
+{
+ font-size: 1.25em;
+ margin-left: 15px;
+ margin-top: 5px;
+ margin-bottom: 5px;
+}
+
+body hr
+{
+ clear:both;
+ color: #ff8000;
+ background-color: #ff8000;
+ height: 1px;
+ border:none;
+ padding:0px;
+ margin:0.1em;
+}
+
+body br
+{
+ clear:both;
+}
+
+.nav_path
+{
+ color: #ff8000;
+ margin-left: 15px;
+}
+.nav_path a
+{
+ color: white;
+ text-decoration:none;
+}
+
+.footer,
+.footer *
+{
+ color: #ff8000;
+ font-size: 0.9em;
+ vertical-align: middle;
+}
+
+.widget_container {
+ width: 50%;
+ float: left;
+}
+
+.widget_container .widget_container {
+ width: 100%;
+}
+
+.widget
+{
+ margin:0.10em;
+ padding:0.1em;
+ border: none;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ min-height: 2em;
+}
+
+.editmode .widget
+{
+ border: 1px solid #444;
+}
+
+.widget .label,
+.widget.info .actor,
+.text > div,
+.link > a {
+ padding: 5px;
+}
+
+.widget .label
+{
+ float:left;
+ width:49%;
+/* color:red; */
+/* padding-right:0.25em; */
+ text-align:right;
+/* border:blue 1px solid; */
+}
+
+.widget .actor
+{
+ float:left;
+ margin-left:1em;
+}
+
+.widget .actor div
+{
+ float:left;
+ white-space: pre-wrap;
+}
+
+.center
+{
+ text-align:center;
+}
+
+.left
+{
+ text-align:left;
+}
+
+.right
+{
+ text-align:right;
+}
+
+.red
+{
+ color:#f44;
+
+}
+
+.green
+{
+ color:#4f4;
+}
+
+.blue
+{
+ color:#44f;
+}
+
+.purple
+{
+ color:#f4f;
+}
+
+.link a
+{
+ color: #ff8000;
+ text-align: right;
+ width: 49%;
+ padding: 5px;
+}
+
+.page
+{
+ float:left;
+ width: 900px;
+ overflow: auto;
+ position: relative;
+}
+
+.switchUnpressed
+{
+ border-style: solid;
+ border-width: 1px;
+ border-color: #666 #444 #444 #666;
+ -moz-border-radius: 7px;
+ -webkit-border-radius: 7px;
+ border-radius: 7px;
+ padding: 1px;
+}
+.switchUnpressed div
+{
+ border-style: solid;
+ border-width: 1px;
+ border-color: #fff #666 #666 #fff;
+ padding: 3px;
+ width: 5em;
+ float: left;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+}
+
+.switchPressed
+{
+ border-style: solid;
+ border-width: 1px;
+ border-color: #666 #fff #fff #666;
+ -moz-border-radius: 7px;
+ -webkit-border-radius: 7px;
+ border-radius: 7px;
+ padding: 1px;
+}
+.switchPressed div
+{
+ border-style: solid;
+ border-width: 1px;
+ border-color: #444 #666 #666 #444;
+ padding: 3px;
+ width: 5em;
+ float: left;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+}
+
+.switchInvisible
+{
+ border: none;
+ padding: 1px;
+}
+
+.switchInvisible div
+{
+ border: none;
+ padding: 5px;
+ width: 5em;
+ float: left;
+}
+
+.ui-slider { position: relative; text-align: left; }
+.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.6em; height: 1.6em; cursor: default; }
+.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
+
+.ui-slider-horizontal { height: .8em; }
+.ui-slider-horizontal .ui-slider-handle { top: -.5em; margin-left: -.8em; }
+.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
+.ui-slider-horizontal .ui-slider-range-min { left: 0; }
+.ui-slider-horizontal .ui-slider-range-max { right: 0; }
+
+.ui-slider-vertical { width: .8em; height: 100px; }
+.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
+.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
+.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
+.ui-slider-vertical .ui-slider-range-max { top: 0; }
+.ui-widget-content { border: 1px solid #dddddd; background: #000 ; color: #000; }
+.ui-widget-content a { color: #333333; }
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
+.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
+
+.dim .actor
+{
+ width: 3em;
+}
+.widget .ui-slider
+{
+ width: 30%;
+ float: left;
+ margin-left: 10px;
+ margin-left: 1em;
+ margin-top: 0.5em;
+ border-color: #666 #fff #fff #666;
+}
+
+.widget .ui-slider-handle
+{
+ border-color: #fff #666 #666 #fff;
+}
+/* Clearfix */
+.clearfix:after {
+ content: ".";
+ display: block;
+ clear: both;
+ visibility: hidden;
+ line-height: 0;
+ height: 0;
+}
+
+.clearfix {
+ display: inline-block;
+}
+
+html[xmlns] .clearfix {
+ display: block;
+}
+
+*:first-child+html .clearfix {
+ min-height: 0;
+}
+
+* html .clearfix {
+ height: 1%;
+}
+
+* html>body .clearfix {
+ display: inline-block;
+ width: 100%;
+}
+
+* html .clearfix {
+ /* Hides from IE-mac \*/
+ height: 1%;
+ /* End hide from IE-mac */
+}
+
+.loading {
+ display: block !important;
+}
+
+div#loading {
+ display: none !important;
+}
+
+.popup,
+.popup_background {
+ position: absolute;
+ width: 90%;
+ height: 90%;
+ top: 5%;
+ left: 5%;
+}
+
+.popup {
+ z-index: 101;
+ background: transparent;
+}
+
+
+.popup_background {
+ z-index: 100;
+ -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
+ background: #000;
+ border: 1px solid #fff;
+ opacity: 0.75;
+}
+
+.popup div {
+ margin: 4px;
+}
+
+.popup div.head {
+ border-bottom: 1px solid;
+}
+
+.popup_background.error {
+ background: #800000;
+ border: #f00;
+}
+
+.clickable {
+ cursor: pointer;
+}
+
+.diagram_inline {
+ width: 320px;
+ height: 180px;
+}
+
+.diagram_preview {
+ width: 240px;
+ height: 2em;
+}
+
+#diagramTooltip {
+ z-index: 1000;
+ color: black;
+ border: 1px solid #fdd;
+ padding: 2px;
+ background-color: #fee;
+ opacity: 0.80;
+}
+
+/*****************************************************************************/
+/* The definition of the flavours - overwrite the generic settings */
+/*****************************************************************************/
+
+.flavour_black hr
+{
+ background-color: #000000;
+}
+.flavour_black .link a
+{
+ color: #000000;
+}
+.flavour_black.group
+{
+ border: #000000 1px solid;
+}
+
+.flavour_white hr
+{
+ background-color: #ffffff;
+}
+.flavour_white .link a
+{
+ color: #ffffff;
+}
+.flavour_white.group
+{
+ border: #ffffff 1px solid;
+}
+
+.flavour_antimony hr
+{
+ background-color: #00ddff;
+}
+.flavour_antimony .link a
+{
+ color: #00ddff;
+}
+.flavour_antimony.group
+{
+ border: #00ddff 1px solid;
+}
+
+.flavour_boron hr
+{
+ background-color: #00ff11;
+}
+.flavour_boron .link a
+{
+ color: #00ff11;
+}
+.flavour_boron.group
+{
+ border: #00ff11 1px solid;
+}
+
+.flavour_lithium hr
+{
+ background-color: #ff0000;
+}
+.flavour_lithium .link a
+{
+ color: #ff0000;
+}
+.flavour_lithium.group
+{
+ border: #ff0000 1px solid;
+}
+
+.flavour_potassium hr
+{
+ background-color: #d00055;
+}
+.flavour_potassium .link a
+{
+ color: #d00055;
+}
+.flavour_potassium.group
+{
+ border: #d00055 1px solid;
+}
+
+.flavour_sodium hr
+{
+ background-color: #ff8000;
+}
+.flavour_sodium .link a
+{
+ color: #ff8000;
+}
+.flavour_sodium.group
+{
+ border: #ff8000 1px solid;
+}
+
Modified: CometVisu/trunk/visu/designs/pure/mobile.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/mobile.css 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/pure/mobile.css 2011-12-18 11:21:22 UTC (rev 583)
@@ -1,12 +1,11 @@
-.widget
-{
- width:98%;
-}
-
-#bottom {
- display: none;
-}
-
-.page {
- overflow: visible;
-}
+.widget_container {
+ width: 98%;
+}
+
+#bottom {
+ display: none;
+}
+
+.page {
+ overflow: visible;
+}
Modified: CometVisu/trunk/visu/designs/structure_custom.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_custom.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/structure_custom.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -42,7 +42,7 @@
*/
VisuDesign_Custom.prototype.addCreator("designtoggle", {
create: function( page, path ) {
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'switch' );
var label = '<div class="label">' + page.textContent + '</div>';
var actor = '<div class="actor switchUnpressed">';
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -82,7 +82,7 @@
if ($p.attr('visible')=='false') {
ret_val=$('');
} else { // default is visible
- ret_val = $('<div class="widget"/>');
+ ret_val = $('<div class="widget clearfix"/>');
ret_val.addClass( 'link' ).addClass('pagelink');
ret_val.append( '<div ' + wstyle + '><a href="javascript:scrollToPage(\''+path+'\')">' + name + '</a></div>' );
}
@@ -132,7 +132,7 @@
maturity: Maturity.development,
create: function( page, path, flavour ) {
var $p = $(page);
- var ret_val = $('<div class="widget group" />');
+ var ret_val = $('<div class="widget clearfix group" />');
if( $p.attr('flavour') ) flavour = $p.attr('flavour');// sub design choice
var hstyle = ''; // heading style
if( $p.attr('align') ) hstyle += 'text-align:' + $p.attr('align') + ';';
@@ -180,7 +180,7 @@
this.addCreator('text', {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget text" />');
+ var ret_val = $('<div class="widget clearfix text" />');
var style = '';
if( $p.attr('align') ) style += 'text-align:' + $p.attr('align') + ';';
if( style != '' ) style = 'style="' + style + '"';
@@ -200,7 +200,7 @@
var $p = $(page);
var layout = $p.find('layout')[0];
var style = layout ? 'style="' + extractLayout( layout ) + '"' : '';
- var ret_val = $('<div class="widget info" ' + style + ' />');
+ var ret_val = $('<div class="widget clearfix info" ' + style + ' />');
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
var address = {};
@@ -239,7 +239,7 @@
var $p = $(page);
var layout = $p.find('layout')[0];
var style = layout ? 'style="' + extractLayout( layout ) + '"' : '';
- var ret_val = $('<div class="widget slide" ' + style + ' />');
+ var ret_val = $('<div class="widget clearfix slide" ' + style + ' />');
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
var address = {};
@@ -352,7 +352,7 @@
this.addCreator('switch', {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget switch" />');
+ var ret_val = $('<div class="widget clearfix switch" />');
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
var address = {};
@@ -409,7 +409,7 @@
this.addCreator('toggle', {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget toggle" />');
+ var ret_val = $('<div class="widget clearfix toggle" />');
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
var address = {};
@@ -473,7 +473,7 @@
this.addCreator('multitrigger', {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget switch" />');
+ var ret_val = $('<div class="widget clearfix switch" />');
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
var address = {};
@@ -605,7 +605,7 @@
create: function( page, path ) {
var $p = $(page);
var value = $p.attr('value') ? $p.attr('value') : 0;
- var ret_val = $('<div class="widget switch" />');
+ var ret_val = $('<div class="widget clearfix switch" />');
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
var address = {};
@@ -665,7 +665,7 @@
this.addCreator('image', {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget image" />');
+ var ret_val = $('<div class="widget clearfix image" />');
var labelElement = $p.find('label')[0];
ret_val.append( labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '' );
var style = '';
@@ -698,7 +698,7 @@
this.addCreator('video', {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget video" />');
+ var ret_val = $('<div class="widget clearfix video" />');
var labelElement = $p.find('label')[0];
ret_val.append( labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '' );
var autoplay = ($p.attr('autoplay') && $p.attr('autoplay')=='true') ? ' autoplay="autoplay"' : '';
@@ -763,7 +763,7 @@
this.addCreator('infotrigger', {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget switch" />');
+ var ret_val = $('<div class="widget clearfix switch" />');
// handle label
var labelElement = $p.find('label')[0];
@@ -912,7 +912,7 @@
this.addCreator('unknown', {
create: function( page, path ) {
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.append( '<pre>unknown: ' + page.nodeName + '</pre>' );
return ret_val;
},
Modified: CometVisu/trunk/visu/edit/visuconfig_edit.js
===================================================================
--- CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -73,7 +73,7 @@
jQuery("#pages").bind("done", function() {
$("#pages hr, #pages br").each(function() {
if ($(this).closest(".widget").length == 0) {
- $(this).wrap("<div class=\"widget line\" />");
+ $(this).wrap("<div class=\"widget clearfix line\" />");
var d = $.extend({}, $(this).data());
$(this).closest("div.widget").data(d);
}
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/lib/templateengine.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -337,7 +337,12 @@
.data("path", path)
.data("nodeName", page.nodeName)
.data("textContent", page.textContent);
- return retval;
+
+ if (jQuery(retval).is(".widget")) {
+ retval = jQuery("<div class='widget_container' />").append(retval);
+ }
+
+ return retval;
}
function scrollToPage( page_id, speed )
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -23,7 +23,7 @@
VisuDesign_Custom.prototype.addCreator("colorchooser", {
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'colorChooser' );
var labelElement = $p.find('label')[0];
Modified: CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -32,7 +32,7 @@
var id = "diagram_" + uniqid();
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'diagram' );
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
@@ -92,7 +92,7 @@
var id = "diagram_" + uniqid();
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'diagram' );
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
@@ -211,7 +211,7 @@
var id = "diagram_" + uniqid();
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'diagram' );
var labelElement = $p.find('label')[0];
Modified: CometVisu/trunk/visu/plugins/gweather/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/gweather/structure_plugin.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/plugins/gweather/structure_plugin.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -32,7 +32,7 @@
var id = "gweather_" + uniqid();
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'gweather' );
var label = '<div class="label">' + page.textContent + '</div>';
var actor = $("<div class=\"actor\"><div class=\"gweather\" id=\"" + id + "\">loading</div></div>");
Modified: CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -31,7 +31,7 @@
}
var id = "jqclock_" + uniqid();
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'jqclock' );
var label = '<div class="label">' + page.textContent + '</div>';
var actor = $("<div class=\"actor\"><div class=\"jqclock_inline\" id=\"" + id + "\"></div></div>");
Modified: CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -23,7 +23,7 @@
maturity: Maturity.development,
create: function( page, path ) {
var $p = $(page);
- var ret_val = $('<div class="widget text" />');
+ var ret_val = $('<div class="widget clearfix text" />');
var style = '';
if( style != '' ) style = 'style="' + style + '"';
Modified: CometVisu/trunk/visu/plugins/rss/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/rss/structure_plugin.js 2011-12-16 23:02:51 UTC (rev 582)
+++ CometVisu/trunk/visu/plugins/rss/structure_plugin.js 2011-12-18 11:21:22 UTC (rev 583)
@@ -32,7 +32,7 @@
var id = "rss_" + uniqid();
- var ret_val = $('<div class="widget" />');
+ var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'rss' );
var label = '<div class="label">' + page.textContent + '</div>';
var actor = $("<div class=\"actor\"><div class=\"rss_inline\" id=\"" + id + "\">loading...</div></div>");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-16 23:02:57
|
Revision: 582
http://openautomation.svn.sourceforge.net/openautomation/?rev=582&view=rev
Author: mayerch
Date: 2011-12-16 23:02:51 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Fix texture orientation (up<->down; left<->right)
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 22:44:03 UTC (rev 581)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 23:02:51 UTC (rev 582)
@@ -395,16 +395,19 @@
//geometry.faces = Tfaces;
for( var f = 0; f < Tfaces.length; f++ )
{
- var uv_a = new THREE.UV( Tvertices[Tfaces[f].a].x, Tvertices[Tfaces[f].a].y );
- var uv_b = new THREE.UV( Tvertices[Tfaces[f].b].x, Tvertices[Tfaces[f].b].y );
- var uv_c = new THREE.UV( Tvertices[Tfaces[f].c].x, Tvertices[Tfaces[f].c].y );
+ var uv_a1 = new THREE.UV( Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
+ var uv_b1 = new THREE.UV( Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
+ var uv_c1 = new THREE.UV( Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
+ var uv_a2 = new THREE.UV( 1-Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
+ var uv_b2 = new THREE.UV( 1-Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
+ var uv_c2 = new THREE.UV( 1-Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
// wall side 1
geometry.faces.push( Tfaces[f] );
- geometry.faceVertexUvs[0].push([ uv_a, uv_b, uv_c ]);
+ geometry.faceVertexUvs[0].push([ uv_a1, uv_b1, uv_c1 ]);
// wall side 2
geometry.faces.push(new THREE.Face3(Tfaces[f].c+wall1verticesLength, Tfaces[f].b+wall1verticesLength, Tfaces[f].a+wall1verticesLength ) );
- geometry.faceVertexUvs[0].push([ uv_c, uv_b, uv_a ]);
+ geometry.faceVertexUvs[0].push([ uv_a2, uv_b2, uv_c2 ]);
}
// wall top
var mId = geometry.vertices.length;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-16 22:44:09
|
Revision: 581
http://openautomation.svn.sourceforge.net/openautomation/?rev=581&view=rev
Author: mayerch
Date: 2011-12-16 22:44:03 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Lighting and finally add the faces in the wall holes
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-16 22:43:35 UTC (rev 580)
+++ JSFloorPlan/trunk/index.html 2011-12-16 22:44:03 UTC (rev 581)
@@ -39,7 +39,24 @@
</td>
<td>
Entfernung</td><td><div style="width:150px;" height="100" id="distSlider"></div>
- </td></tr>
+ </td>
+ <td>
+ </td>
+ </tr>
+ <tr style="border: 1px black;">
+ <td>
+ Licht Richtung</td><td><div style="width:150px;" height="100" id="lightDirectionSlider"></div>
+ </td>
+ <td>
+ Licht Höhe</td><td><div style="width:150px;" height="100" id="lightHeightSlider"></div>
+ </td>
+ <td>
+ Licht Stärke</td><td><div style="width:150px;" height="100" id="lightStrengthSlider"></div>
+ </td>
+ <td>
+ Licht Entfernung</td><td><div style="width:150px;" height="100" id="lightDistanceSlider"></div>
+ </td>
+ </tr>
</table>
<hr />
<h2>Status Infos:</h2>
@@ -90,6 +107,7 @@
</td><td>
Zeige Wireframe: <input type="checkbox" name="showWireframe" />
</td><td>
+ Licht-Sicht: <input type="checkbox" name="showLightView" />
</td><td>
</td><td>
</td>
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 22:43:35 UTC (rev 580)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 22:44:03 UTC (rev 581)
@@ -313,8 +313,8 @@
var wallLength = calcLength2D( sm, em );
var fLeft = holes[h].distance / wallLength;
var fRight = (holes[h].distance + holes[h].width) / wallLength;
- if( fLeft < 0.0 ) fLeft = 0.01; //// FIXME
- if( fRight > 1.0 ) fRight = 0.99; //// FIXME
+ if( fLeft <= 0.0 ) fLeft = 0.001; //// FIXME - actually the config file is bad. Leave at least 1mm wall
+ if( fRight >= 1.0 ) fRight = 0.999; //// FIXME - actually the config file is bad. Leave at least 1mm wall
var lintel = (sh - holes[h].lintel) / sh;
var paparet = holes[h].paparet / sh;
if( 1 == lintel )
@@ -323,12 +323,9 @@
if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
- console.log( sourrounding );
sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
- console.log( sourrounding );
continue;
}
- //if( 0 == paparet ) paparet = 0.01; //// FIXME
if( 0 == paparet )
{
// not a hole, the sourrounding goes to the groud...
@@ -342,7 +339,7 @@
holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
}
} // if( floorWalls[j].holes.length )
- var swctx = new poly2tri.SweepContext( sourrounding );
+ var swctx = new poly2tri.SweepContext( sourrounding.slice(0) ); // pass a copy of sourrounding
for( var htA = 0; htA < holesToAdd.length; htA++ )
swctx.AddHole( holesToAdd[htA] );
@@ -416,10 +413,28 @@
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround )));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround+eh)));
geometry.faces.push(new THREE.Face3(s1id, s2id, mId+1) );
- geometry.faces.push(new THREE.Face3(s2id, s1id, e1id ) );
- geometry.faces.push(new THREE.Face3(e2id, s2id, e1id ) );
geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
- //console.log(geometry, cubeMaterial);
+
+ for( var e = 0; e < sourrounding.length; e++ )
+ {
+ var id1 = sourrounding[e ].id;
+ var id2 = sourrounding[(e+1)%sourrounding.length].id;
+ geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
+ geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
+ }
+
+ // hole sides
+ for( var hta = 0; hta < holesToAdd.length; hta++ )
+ {
+ for( var e = 0; e < holesToAdd[hta].length; e++ )
+ {
+ var id1 = holesToAdd[hta][e ].id;
+ var id2 = holesToAdd[hta][(e+1)%sourrounding.length].id;
+ geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
+ geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
+ }
+ }
+
geometry.computeFaceNormals();
var mesh = new THREE.Mesh(geometry, cubeMaterial);
mesh.castShadow = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|