Skip to content

Commit

Permalink
Merge pull request #262 from AnalyticalGraphicsInc/demo-highlight
Browse files Browse the repository at this point in the history
Demo and highlight fixes
  • Loading branch information
mramato committed Sep 26, 2012
2 parents 8efc9c6 + 4b43116 commit 90be092
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
16 changes: 15 additions & 1 deletion Apps/Sandcastle/CesiumSandcastle.js
Expand Up @@ -559,7 +559,6 @@ require({
galleryErrorMsg.style.display = 'inline-block';
}

registry.byId('demosContainer').scrollTo({x:0, y:0});
showGallery();
scheduleHintNoChange();
});
Expand Down Expand Up @@ -609,6 +608,21 @@ require({
}
});

var demosContainer = dom.byId('demosContainer');
if (typeof document.onmousewheel !== 'undefined') {
demosContainer.addEventListener('mousewheel', function (e) {
if (typeof e.wheelDelta !== 'undefined' && e.wheelDelta) {
demosContainer.scrollLeft -= e.wheelDelta * 70/120;
}
}, false);
} else {
demosContainer.addEventListener('DOMMouseScroll', function (e) {
if (typeof e.detail !== 'undefined' && e.detail) {
demosContainer.scrollLeft += e.detail * 70/3;
}
}, false);
}

var galleryContainer = registry.byId('galleryContainer');
galleryContainer.demoTileHeightRule = demoTileHeightRule;
galleryContainer.originalResize = galleryContainer.resize;
Expand Down
21 changes: 9 additions & 12 deletions Apps/Sandcastle/gallery/Sensors.html
Expand Up @@ -83,12 +83,12 @@
"use strict";

function addRectangularSensor(sensors, ellipsoid, scene) {
Sandcastle.declare(addRectangularSensor); // For highlighting in Sandcastle.
var rectangularPyramidSensor = sensors.addRectangularPyramid();
Sandcastle.declare(rectangularPyramidSensor); // For highlighting in Sandcastle.

var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-90.0, 0.0)));
modelMatrix = modelMatrix.multiply(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(3000000.0, 0.0, -3000000.0)));

var rectangularPyramidSensor = sensors.addRectangularPyramid();
rectangularPyramidSensor.modelMatrix = modelMatrix;
rectangularPyramidSensor.radius = 20000000.0;
rectangularPyramidSensor.xHalfAngle = Cesium.Math.toRadians(40.0);
Expand All @@ -104,7 +104,8 @@
}

function addCustomSensor(sensors, ellipsoid, scene) {
Sandcastle.declare(addCustomSensor); // For highlighting in Sandcastle.
var customSensor = sensors.addCustom();
Sandcastle.declare(customSensor); // For highlighting in Sandcastle.

var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-90.0, 0.0)));
modelMatrix = modelMatrix.multiply(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(3000000.0, 0.0, -3000000.0)));
Expand All @@ -116,17 +117,16 @@
});
}

var customSensor = sensors.addCustom();
customSensor.modelMatrix = modelMatrix;
customSensor.radius = 20000000.0;
customSensor.setDirections(directions);
}

function addComplexConicSensor(sensors, ellipsoid, scene) {
Sandcastle.declare(addComplexConicSensor); // For highlighting in Sandcastle.
var complexConicSensor = sensors.addComplexConic();
Sandcastle.declare(complexConicSensor); // For highlighting in Sandcastle.

// Complex conic sensor - Works with ANGLE turned off.
var complexConicSensor = sensors.addComplexConic();
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-90.0, 0.0)));
modelMatrix = modelMatrix.multiply(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(3000000.0, 0.0, -3000000.0)));
complexConicSensor.modelMatrix = modelMatrix;
Expand Down Expand Up @@ -171,13 +171,13 @@
}

function addComplexConicWithClockAngles(sensors, ellipsoid, scene) {
Sandcastle.declare(addComplexConicWithClockAngles); // For highlighting in Sandcastle.
var complexConicSensor2 = sensors.addComplexConic();
Sandcastle.declare(complexConicSensor2); // For highlighting in Sandcastle.

// Draw a complex conic sensor with clock angles
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-90.0, 0.0)));
modelMatrix = modelMatrix.multiply(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(3000000.0, 0.0, -3000000.0)));

var complexConicSensor2 = sensors.addComplexConic();
complexConicSensor2.modelMatrix = modelMatrix;
complexConicSensor2.outerHalfAngle = Cesium.Math.toRadians(30.0);
complexConicSensor2.innerHalfAngle = Cesium.Math.toRadians(20.0);
Expand All @@ -199,7 +199,6 @@
onClick: function() {
sensors.removeAll();
addRectangularSensor(sensors, ellipsoid, scene);
Sandcastle.highlight(addRectangularSensor);
}
}));

Expand All @@ -208,7 +207,6 @@
onClick: function() {
sensors.removeAll();
addCustomSensor(sensors, ellipsoid, scene);
Sandcastle.highlight(addCustomSensor);
}
}));

Expand All @@ -217,7 +215,6 @@
onClick: function() {
sensors.removeAll();
addComplexConicSensor(sensors, ellipsoid, scene);
Sandcastle.highlight(addComplexConicSensor);
}
}));

Expand All @@ -226,7 +223,6 @@
onClick: function() {
sensors.removeAll();
addComplexConicWithClockAngles(sensors, ellipsoid, scene);
Sandcastle.highlight(addComplexConicWithClockAngles);
}
}));

Expand All @@ -251,6 +247,7 @@

dom.byId('toolbar').innerHTML = '';
});

</script>
</body>
</html>
6 changes: 5 additions & 1 deletion Apps/Sandcastle/templates/bucket.html
Expand Up @@ -90,7 +90,11 @@
window.onerror = function (errorMsg, url, lineNumber) {
var rawErrorMsg = errorMsg;
if (typeof lineNumber !== 'undefined') {
errorMsg += ' (on line ' + lineNumber + ')';
if (typeof url !== 'undefined' && url && url.indexOf('bucket.html') < 0) {
errorMsg += ' (on line ' + lineNumber + ' of ' + url + ')';
} else {
errorMsg += ' (on line ' + lineNumber + ')';
}
window.parent.postMessage({ 'error': errorMsg, 'url': url, 'lineNumber': lineNumber, 'rawErrorMsg': rawErrorMsg }, '*');
} else {
window.parent.postMessage({ 'error': errorMsg, 'url': url }, '*');
Expand Down
6 changes: 3 additions & 3 deletions Source/Widgets/Dojo/CesiumViewerWidget.js
Expand Up @@ -1039,12 +1039,12 @@ define([
*/
highlightObject : function(selectedObject) {
if (this.highlightedObject !== selectedObject) {
if (typeof this.highlightedObject !== 'undefined') {
if (typeof this.highlightedObject !== 'undefined' && !this.highlightedObject.isDestroyed()) {
if (typeof this.highlightedObject.material !== 'undefined') {
this.highlightedObject.material = this._originalMaterial;
} else if (typeof this.highlightedObject.outerMaterial !== 'undefined') {
this.highlightedObject.outerMaterial = this._originalMaterial;
} else {
} else if (typeof this.highlightedObject.setColor !== 'undefined') {
this.highlightedObject.setColor(this._originalColor);
}
}
Expand All @@ -1056,7 +1056,7 @@ define([
} else if (typeof selectedObject.outerMaterial !== 'undefined') {
this._originalMaterial = selectedObject.outerMaterial;
selectedObject.outerMaterial = this.highlightMaterial;
} else {
} else if (typeof this.highlightedObject.setColor !== 'undefined') {
this._originalColor = Color.clone(selectedObject.getColor(), this._originalColor);
selectedObject.setColor(this.highlightColor);
}
Expand Down

0 comments on commit 90be092

Please sign in to comment.