From a26d9ef353fb52405ca9bbd7aff56416e2ec0847 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 24 Apr 2015 16:49:18 +0200 Subject: [PATCH 1/3] Fix ShapeType/String conversion --- .../entities/src/EntityItemProperties.cpp | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 7d5a40f6fd..734f7897bb 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -192,31 +192,34 @@ void EntityItemProperties::setLastEdited(quint64 usecTime) { _lastEdited = usecTime > _created ? usecTime : _created; } -const char* shapeTypeNames[] = {"none", "box", "sphere", "ellipsoid", "convex-hull", "plane", "compound", "capsule-x", +const char* shapeTypeNames[] = {"none", "box", "sphere", "ellipsoid", "plane", "compound", "capsule-x", "capsule-y", "capsule-z", "cylinder-x", "cylinder-y", "cylinder-z"}; QHash stringToShapeTypeLookup; +void addShapeType(ShapeType type) { + stringToShapeTypeLookup[shapeTypeNames[type]] = type; +} + void buildStringToShapeTypeLookup() { - stringToShapeTypeLookup["none"] = SHAPE_TYPE_NONE; - stringToShapeTypeLookup["box"] = SHAPE_TYPE_BOX; - stringToShapeTypeLookup["sphere"] = SHAPE_TYPE_SPHERE; - stringToShapeTypeLookup["ellipsoid"] = SHAPE_TYPE_ELLIPSOID; - stringToShapeTypeLookup["convex-hull"] = SHAPE_TYPE_COMPOUND; - stringToShapeTypeLookup["plane"] = SHAPE_TYPE_PLANE; - stringToShapeTypeLookup["compound"] = SHAPE_TYPE_COMPOUND; - stringToShapeTypeLookup["capsule-x"] = SHAPE_TYPE_CAPSULE_X; - stringToShapeTypeLookup["capsule-y"] = SHAPE_TYPE_CAPSULE_Y; - stringToShapeTypeLookup["capsule-z"] = SHAPE_TYPE_CAPSULE_Z; - stringToShapeTypeLookup["cylinder-x"] = SHAPE_TYPE_CYLINDER_X; - stringToShapeTypeLookup["cylinder-y"] = SHAPE_TYPE_CYLINDER_Y; - stringToShapeTypeLookup["cylinder-z"] = SHAPE_TYPE_CYLINDER_Z; + addShapeType(SHAPE_TYPE_NONE); + addShapeType(SHAPE_TYPE_BOX); + addShapeType(SHAPE_TYPE_SPHERE); + addShapeType(SHAPE_TYPE_ELLIPSOID); + addShapeType(SHAPE_TYPE_PLANE); + addShapeType(SHAPE_TYPE_COMPOUND); + addShapeType(SHAPE_TYPE_CAPSULE_X); + addShapeType(SHAPE_TYPE_CAPSULE_Y); + addShapeType(SHAPE_TYPE_CAPSULE_Z); + addShapeType(SHAPE_TYPE_CYLINDER_X); + addShapeType(SHAPE_TYPE_CYLINDER_Y); + addShapeType(SHAPE_TYPE_CYLINDER_Z); } QString EntityItemProperties::getShapeTypeAsString() const { if (_shapeType < sizeof(shapeTypeNames) / sizeof(char *)) return QString(shapeTypeNames[_shapeType]); - return QString("none"); + return QString(shapeTypeNames[SHAPE_TYPE_NONE]); } void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) { From 32b78f02b46171902d44dcb9bb7192f66ac7b03b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 24 Apr 2015 16:52:51 +0200 Subject: [PATCH 2/3] Group ShapeType and CompoundShapeURL + add it to Zones --- examples/html/entityProperties.html | 33 ++++++++++--------- examples/libraries/ToolTip.js | 1 + examples/libraries/entityPropertyDialogBox.js | 3 ++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index a8290dc3fa..352ffebaa9 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -162,6 +162,7 @@ var elModelSections = document.querySelectorAll(".model-section"); var elModelURL = document.getElementById("property-model-url"); + var elShapeType = document.getElementById("property-shape-type"); var elCompoundShapeURL = document.getElementById("property-compound-shape-url"); var elModelAnimationURL = document.getElementById("property-model-animation-url"); var elModelAnimationPlaying = document.getElementById("property-model-animation-playing"); @@ -170,7 +171,6 @@ var elModelAnimationSettings = document.getElementById("property-model-animation-settings"); var elModelTextures = document.getElementById("property-model-textures"); var elModelOriginalTextures = document.getElementById("property-model-original-textures"); - var elModelShapeType = document.getElementById("property-model-shape"); var elTextSections = document.querySelectorAll(".text-section"); var elTextText = document.getElementById("property-text-text"); @@ -323,6 +323,7 @@ } elModelURL.value = properties.modelURL; + elShapeType.value = properties.shapeType; elCompoundShapeURL.value = properties.compoundShapeURL; elModelAnimationURL.value = properties.animationURL; elModelAnimationPlaying.checked = properties.animationIsPlaying; @@ -331,7 +332,6 @@ elModelAnimationSettings.value = properties.animationSettings; elModelTextures.value = properties.textures; elModelOriginalTextures.value = properties.originalTextures; - elModelShapeType.value = properties.shapeType; } if (properties.type != "Text") { @@ -397,6 +397,8 @@ elZoneStageAltitude.value = properties.stageAltitude.toFixed(2); elZoneStageDay.value = properties.stageDay; elZoneStageHour.value = properties.stageHour; + elShapeType.value = properties.shapeType; + elCompoundShapeURL.value = properties.compoundShapeURL; } if (selected) { @@ -487,6 +489,7 @@ elLightCutoff.addEventListener('change', createEmitNumberPropertyUpdateFunction('cutoff')); elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL')); + elShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType')); elCompoundShapeURL.addEventListener('change', createEmitTextPropertyUpdateFunction('compoundShapeURL')); elModelAnimationURL.addEventListener('change', createEmitTextPropertyUpdateFunction('animationURL')); elModelAnimationPlaying.addEventListener('change', createEmitCheckedPropertyUpdateFunction('animationIsPlaying')); @@ -494,7 +497,6 @@ elModelAnimationFrame.addEventListener('change', createEmitNumberPropertyUpdateFunction('animationFrameIndex')); elModelAnimationSettings.addEventListener('change', createEmitTextPropertyUpdateFunction('animationSettings')); elModelTextures.addEventListener('change', createEmitTextPropertyUpdateFunction('textures')); - elModelShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType')); elTextText.addEventListener('change', createEmitTextPropertyUpdateFunction('text')); elTextLineHeight.addEventListener('change', createEmitNumberPropertyUpdateFunction('lineHeight')); @@ -774,7 +776,18 @@ -
+
+
Shape Type
+
+ +
+
+
Compound Shape URL
@@ -823,18 +836,6 @@
-
-
Shape Type
-
- -
-
- -
Text
diff --git a/examples/libraries/ToolTip.js b/examples/libraries/ToolTip.js index 2b0e125d4b..f6f14d7f2b 100644 --- a/examples/libraries/ToolTip.js +++ b/examples/libraries/ToolTip.js @@ -53,6 +53,7 @@ function Tooltip() { text += "ID: " + properties.id + "\n" if (properties.type == "Model") { text += "Model URL: " + properties.modelURL + "\n" + text += "Shape Type: " + properties.shapeType + "\n" text += "Compound Shape URL: " + properties.compoundShapeURL + "\n" text += "Animation URL: " + properties.animationURL + "\n" text += "Animation is playing: " + properties.animationIsPlaying + "\n" diff --git a/examples/libraries/entityPropertyDialogBox.js b/examples/libraries/entityPropertyDialogBox.js index 255cec4265..5c6c688f0d 100644 --- a/examples/libraries/entityPropertyDialogBox.js +++ b/examples/libraries/entityPropertyDialogBox.js @@ -52,6 +52,8 @@ EntityPropertyDialogBox = (function () { if (properties.type == "Model") { array.push({ label: "Model URL:", value: properties.modelURL }); index++; + array.push({ label: "Shape Type:", value: properties.shapeType }); + index++; array.push({ label: "Compound Shape URL:", value: properties.compoundShapeURL }); index++; array.push({ label: "Animation URL:", value: properties.animationURL }); @@ -284,6 +286,7 @@ EntityPropertyDialogBox = (function () { properties.locked = array[index++].value; if (properties.type == "Model") { properties.modelURL = array[index++].value; + properties.shapeType = array[index++].value; properties.compoundShapeURL = array[index++].value; properties.animationURL = array[index++].value; From 82a53c91398166be361ac2e1e20cbed5d520f84c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 24 Apr 2015 16:53:39 +0200 Subject: [PATCH 3/3] Turn off all sections then turn on selected one This fixes the issue of properties present in a couple sections but not all that are going to only be displayed for the last section the are in that is being processed. --- examples/html/entityProperties.html | 48 ++++++++++------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 352ffebaa9..c01b2a6d10 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -95,6 +95,7 @@ }; function loaded() { + var allSections = []; var elID = document.getElementById("property-id"); var elType = document.getElementById("property-type"); var elLocked = document.getElementById("property-locked"); @@ -146,11 +147,13 @@ var elUserData = document.getElementById("property-user-data"); var elBoxSections = document.querySelectorAll(".box-section"); + allSections.push(elBoxSections); var elBoxColorRed = document.getElementById("property-box-red"); var elBoxColorGreen = document.getElementById("property-box-green"); var elBoxColorBlue = document.getElementById("property-box-blue"); var elLightSections = document.querySelectorAll(".light-section"); + allSections.push(elLightSections); var elLightSpotLight = document.getElementById("property-light-spot-light"); var elLightColorRed = document.getElementById("property-light-color-red"); var elLightColorGreen = document.getElementById("property-light-color-green"); @@ -161,6 +164,7 @@ var elLightCutoff = document.getElementById("property-light-cutoff"); var elModelSections = document.querySelectorAll(".model-section"); + allSections.push(elModelSections); var elModelURL = document.getElementById("property-model-url"); var elShapeType = document.getElementById("property-shape-type"); var elCompoundShapeURL = document.getElementById("property-compound-shape-url"); @@ -173,6 +177,7 @@ var elModelOriginalTextures = document.getElementById("property-model-original-textures"); var elTextSections = document.querySelectorAll(".text-section"); + allSections.push(elTextSections); var elTextText = document.getElementById("property-text-text"); var elTextLineHeight = document.getElementById("property-text-line-height"); var elTextTextColorRed = document.getElementById("property-text-text-color-red"); @@ -183,6 +188,7 @@ var elTextBackgroundColorBlue = document.getElementById("property-text-background-color-blue"); var elZoneSections = document.querySelectorAll(".zone-section"); + allSections.push(elZoneSections); var elZoneStageSunModelEnabled = document.getElementById("property-zone-stage-sun-model-enabled"); var elZoneKeyLightColorRed = document.getElementById("property-zone-key-light-color-red"); var elZoneKeyLightColorGreen = document.getElementById("property-zone-key-light-color-green"); @@ -299,11 +305,13 @@ elScriptURL.value = properties.script; elUserData.value = properties.userData; - if (properties.type != "Box") { - for (var i = 0; i < elBoxSections.length; i++) { - elBoxSections[i].style.display = 'none'; + for (var i = 0; i < allSections.length; i++) { + for (var j = 0; j < allSections[i].length; j++) { + allSections[i][j].style.display = 'none'; } - } else { + } + + if (properties.type == "Box") { for (var i = 0; i < elBoxSections.length; i++) { elBoxSections[i].style.display = 'block'; } @@ -311,13 +319,7 @@ elBoxColorRed.value = properties.color.red; elBoxColorGreen.value = properties.color.green; elBoxColorBlue.value = properties.color.blue; - } - - if (properties.type != "Model") { - for (var i = 0; i < elModelSections.length; i++) { - elModelSections[i].style.display = 'none'; - } - } else { + } else if (properties.type == "Model") { for (var i = 0; i < elModelSections.length; i++) { elModelSections[i].style.display = 'block'; } @@ -332,13 +334,7 @@ elModelAnimationSettings.value = properties.animationSettings; elModelTextures.value = properties.textures; elModelOriginalTextures.value = properties.originalTextures; - } - - if (properties.type != "Text") { - for (var i = 0; i < elTextSections.length; i++) { - elTextSections[i].style.display = 'none'; - } - } else { + } else if (properties.type == "Text") { for (var i = 0; i < elTextSections.length; i++) { elTextSections[i].style.display = 'block'; } @@ -351,13 +347,7 @@ elTextBackgroundColorRed.value = properties.backgroundColor.red; elTextBackgroundColorGreen.value = properties.backgroundColor.green; elTextBackgroundColorBlue.value = properties.backgroundColor.blue; - } - - if (properties.type != "Light") { - for (var i = 0; i < elLightSections.length; i++) { - elLightSections[i].style.display = 'none'; - } - } else { + } else if (properties.type == "Light") { for (var i = 0; i < elLightSections.length; i++) { elLightSections[i].style.display = 'block'; } @@ -371,13 +361,7 @@ elLightIntensity.value = properties.intensity; elLightExponent.value = properties.exponent; elLightCutoff.value = properties.cutoff; - } - - if (properties.type != "Zone") { - for (var i = 0; i < elZoneSections.length; i++) { - elZoneSections[i].style.display = 'none'; - } - } else { + } else if (properties.type == "Zone") { for (var i = 0; i < elZoneSections.length; i++) { elZoneSections[i].style.display = 'block'; }