[Opengeoscience-developers] OpenGeoscience branch, enhance_map_api, created. 18ff87b9f943a659be590098e2ac674161ccfcb4
Aashish Chaudhary
aashish.chaudhary at kitware.com
Fri Mar 1 00:30:43 EST 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenGeoscience".
The branch, enhance_map_api has been created
at 18ff87b9f943a659be590098e2ac674161ccfcb4 (commit)
- Log -----------------------------------------------------------------
http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=18ff87b9f943a659be590098e2ac674161ccfcb4
commit 18ff87b9f943a659be590098e2ac674161ccfcb4
Author: Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Fri Mar 1 00:30:11 2013 -0500
Commit: Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Fri Mar 1 00:30:11 2013 -0500
Added support to feature layer to the map
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abbf47d..88ef489 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,9 +42,10 @@ set(JS_LINT_FILES
${CMAKE_SOURCE_DIR}/web/lib/jsHelper.js
${CMAKE_SOURCE_DIR}/web/lib/core/init.js
${CMAKE_SOURCE_DIR}/web/lib/geo/init.js
+ ${CMAKE_SOURCE_DIR}/web/lib/geo/latlng.js
${CMAKE_SOURCE_DIR}/web/lib/geo/layer.js
${CMAKE_SOURCE_DIR}/web/lib/geo/map.js
- ${CMAKE_SOURCE_DIR}/web/lib/vgl/actor.js
+ ${CMAKE_SOURCE_DIR}/web/lib/geo/feature.js
${CMAKE_SOURCE_DIR}/web/lib/vgl/boundingObject.js
${CMAKE_SOURCE_DIR}/web/lib/vgl/camera.js
${CMAKE_SOURCE_DIR}/web/lib/vgl/geomData.js
@@ -95,8 +96,10 @@ set(JS_UGLIFY_FILES
${CMAKE_SOURCE_DIR}/web/lib/vgl/planeSource.js
${CMAKE_SOURCE_DIR}/web/lib/vgl/utils.js
${CMAKE_SOURCE_DIR}/web/lib/geo/init.js
+ ${CMAKE_SOURCE_DIR}/web/lib/geo/latlng.js
${CMAKE_SOURCE_DIR}/web/lib/geo/layer.js
${CMAKE_SOURCE_DIR}/web/lib/geo/map.js
+ ${CMAKE_SOURCE_DIR}/web/lib/geo/feature.js
)
# These files should have documentation generated for them.
diff --git a/web/lib/app.js b/web/lib/app.js
index f1abf1f..eb34b6f 100644
--- a/web/lib/app.js
+++ b/web/lib/app.js
@@ -28,10 +28,15 @@ function main() {
};
var myMap = ogs.geo.map(document.getElementById("glcanvas"), mapOptions);
+ var planeLayer = ogs.geo.featureLayer(
+ {"opacity":1, "showAttribution":1, "visible":1},
+ ogs.geo.planeFeature(ogs.geo.latlng(-90.0, 0.0), ogs.geo.latlng(90.0, 180.0)));
+
+ myMap.addLayer(planeLayer);
$(myMap).on('CameraEvent', function() {
// For test purposes only
console.log("Yohoo.....camera has been moved or something");
});
-}
\ No newline at end of file
+}
diff --git a/web/lib/geo/layer.js b/web/lib/geo/layer.js
index 58bc80f..c5e3105 100644
--- a/web/lib/geo/layer.js
+++ b/web/lib/geo/layer.js
@@ -22,7 +22,6 @@
//
//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
/**
* Layer options object specification
*
@@ -41,9 +40,11 @@ geoModule.layerOptions = function() {
return this;
};
-//////////////////////////////////////////////////////////////////////////////
/**
- * Create a later provided layer options
+ * Base class for all layer types
+ *
+ * ogs.geo.layer represents any object that be rendered on top of the map base.
+ * This could include image, points, line, and polygons.
*
*/
geoModule.layer = function(options) {
@@ -52,13 +53,11 @@ geoModule.layer = function(options) {
return new geoModule.layer(options);
}
- // Register with base class
- vgl.actor.call(this);
+ /// Register with base class
+ ogs.vgl.object.call(this);
/// Members initialization
var m_opacity = options.opacity || 1.0;
-
- // Check
if (m_opacity > 1.0) {
m_opacity = 1.0;
console.log("[warning] Opacity cannot be greater than 1.0");
@@ -70,7 +69,64 @@ geoModule.layer = function(options) {
var m_showAttribution = options.showAttribution || true;
var m_visible = options.visible || true;
+ /**
+ * Return the underlying renderable entity
+ *
+ * This function should be implemented by the derived classes
+ */
+ this.actor = function() {
+ return null;
+ }
+
+ return this;
+};
+
+inherit(geoModule.layer, ogs.vgl.object);
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// featureLayer class
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Layer to draw points, lines, and polygons on the map
+ *
+ * The polydata layer provide mechanisms to create and draw geometrical
+ * shapes such as points, lines, and polygons.
+ *
+ */
+geoModule.featureLayer = function(options, feature) {
+
+ if (!(this instanceof geoModule.featureLayer)) {
+ return new geoModule.featureLayer(options, feature);
+ }
+
+ /// Register with base class
+ geoModule.layer.call(this, options);
+
+ /// Initialize member variables
+ var m_opacity = options.opacity || 1.0;
+ var m_actor = feature;
+
+ /**
+ * Return the underlying renderable entity
+ *
+ * This function should be implemented by the derived classes
+ */
+ this.actor = function() {
+ return m_actor;
+ }
+
+ /**
+ * Set feature (points, lines, or polygons)
+ *
+ */
+ this.setFeature = function(feature) {
+ this.m_actor = feature;
+ }
+
return this;
};
-inherit(geoModule.layer, vglModule.object);
+inherit(geoModule.featureLayer, geoModule.layer);
diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index 20d4edc..759ed6d 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -27,20 +27,21 @@ geoModule.latlng = function(lat, lng) {
return new geoModule.latlng(lat, lng);
}
+ /// Initialize member varibles
var m_lat = lat;
var m_lng = lng;
- return {
- lat : function() {
+ this.lat = function() {
return m_lat;
- },
- lng : function() {
- return m_lng;
- }
};
+
+ this.lng = function() {
+ return m_lng;
+ };
+
+ return this;
};
-///////////////////////////////////////////////////////////////////////////////
/**
* Map options object specification
*
@@ -55,19 +56,17 @@ geoModule.mapOptions = function() {
this.center = geoModule.latlng(0.0, 0.0);
};
-///////////////////////////////////////////////////////////////////////////////
/**
* Creates a new map inside of the given HTML container (Typically DIV)
*
*/
geoModule.map = function(node, options) {
- // Check against no use of new()
if (!(this instanceof geoModule.map)) {
return new geoModule.map(node, options);
}
- /// Private member variables
+ /// Initialize member variables
var m_that = this;
var m_node = node;
var m_leftMouseButtonDown = false;
@@ -92,7 +91,6 @@ geoModule.map = function(node, options) {
var m_renderer = new ogs.vgl.renderer();
var m_camera = m_renderer.camera();
- /////////////////////////////////////////////////////////////////////////////
/**
* Initialize the scene
*
@@ -112,7 +110,6 @@ geoModule.map = function(node, options) {
m_initialized = true;
}
- /////////////////////////////////////////////////////////////////////////////
/**
* Initialize the scene (if not initialized) and then render the map
*
@@ -125,7 +122,6 @@ geoModule.map = function(node, options) {
m_renderer.render();
}
- /////////////////////////////////////////////////////////////////////////////
/**
* Handle mouse events
*
@@ -149,8 +145,8 @@ geoModule.map = function(node, options) {
return {x:canvasX, y:canvasY};
}
- /////////////////////////////////////////////////////////////////////////////
/**
+ * Handle mouse event
*
*/
function handleMouseMove(event) {
@@ -215,7 +211,6 @@ geoModule.map = function(node, options) {
m_mouseLastPos.y = currentMousePos.y;
}
- /////////////////////////////////////////////////////////////////////////////
/**
*
*/
@@ -249,8 +244,8 @@ geoModule.map = function(node, options) {
return false;
}
- /////////////////////////////////////////////////////////////////////////////
/**
+ * Handle mouse up event
*
*/
function handleMouseUp(event) {
@@ -299,9 +294,6 @@ geoModule.map = function(node, options) {
return mapActor;
})();
- /// Public member functions
-
- /////////////////////////////////////////////////////////////////////////////
/**
* Add layer to the map
*
@@ -310,10 +302,14 @@ geoModule.map = function(node, options) {
* @return {Boolean}
*/
this.addLayer = function(layer) {
- if (!layer) {
+
+ console.log('layer is ' + layer);
+
+ if (layer != null) {
// TODO Check if the layer already exists
// TODO Set the rendering order correctly
- m_renderer.addActor(layer);
+ m_renderer.addActor(layer.actor());
+ m_renderer.render();
return true;
}
@@ -321,7 +317,6 @@ geoModule.map = function(node, options) {
return false;
};
- /////////////////////////////////////////////////////////////////////////////
/**
* Remove layer from the map
*
diff --git a/web/lib/vgl/actor.js b/web/lib/vgl/actor.js
index 423497d..e454d53 100644
--- a/web/lib/vgl/actor.js
+++ b/web/lib/vgl/actor.js
@@ -15,14 +15,6 @@
See the License for the specific language governing permissions and
limitations under the License.
========================================================================*/
-/// \class actor
-/// \ingroup vgl
-/// \brief Transform node that contains a drawable entity
-///
-/// actor is a placeholder transform node that contains a drawable entity.
-/// One actor can contain only one drawable entity (mapper).
-/// A mapper however can be set to multiple actors.
-/// \see vglTransformNode mapper
//////////////////////////////////////////////////////////////////////////////
//
@@ -31,122 +23,167 @@
//////////////////////////////////////////////////////////////////////////////
vglModule.actor = function() {
+
+ if (!(this instanceof vglModule.actor)) {
+ return new vglModule.actor();
+ }
+
vglModule.node.call(this);
+
+ /// Initialize member variables
this.m_center = new Array(3);
this.m_rotation = new Array(4);
this.m_scale = new Array(3);
this.m_translation = new Array(3);
this.m_referenceFrame = 0;
-
this.m_mapper = 0;
-};
-inherit(vglModule.actor, vglModule.node);
-
-/// Get center of transformations
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.center = function() {
- return m_center;
-};
-/// Set center of transformations
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.setCenter = function(x, y, z) {
- this.m_center[0] = x;
- this.m_center[1] = y;
- this.m_center[2] = z;
+ /**
+ * Get center of transformations
+ *
+ */
+ this.center = function() {
+ return m_center;
+ };
+
+ /**
+ * Set center of transformations
+ *
+ */
+ this.setCenter = function(x, y, z) {
+ this.m_center[0] = x;
+ this.m_center[1] = y;
+ this.m_center[2] = z;
+ };
+
+ /**
+ * Get rotation defined by angle (radians) and axis (axis(x, y, z), angle)
+ *
+ */
+
+ this.rotation = function() {
+ };
+
+ /**
+ * Set rotation defined by angle (radians) and axis (axis(x, y, z), angle)
+ *
+ */
+ this.setRotation = function(angle, x, y, z) {
+ };
+
+ /**
+ * Get scale in x, y and z directions
+ *
+ */
+ this.scale = function() {
+ };
+
+ /**
+ * Set scale in x, y and z directions
+ *
+ */
+ this.setScale = function(x, y, z) {
+ };
+
+ /**
+ * Get translation in x, y and z directions
+ *
+ */
+ this.translation = function() {
+ };
+
+ /**
+ * Set translation in x, y and z directions
+ *
+ */
+ this.setTranslation = function(x, y, z) {
+ };
+
+ /**
+ * Get reference frame for the transformations. Possible values
+ * are Absolute and Relative.
+ *
+ */
+ this.referenceFrame = function() {
+ };
+
+ /**
+ * Set reference frame for the transformations. Possible values
+ * are Absolute and Relative.
+ *
+ */
+ this.setReferenceFrame = function(referenceFrame) {
+ };
+
+ /**
+ * Evaluate the transform associated with the vtkvglModule.actor.
+ *
+ * @returns Affine transformation for the vglModule.actor.
+ */
+ this.modelViewMatrix = function() {
+ var mat = mat4.create();
+ mat4.identity(mat);
+ return mat;
+ };
+
+ /**
+ *
+ *
+ */
+ this.matrix = function() {
+ return this.modelViewMatrix();
+ };
+
+ /**
+ * Get mapper of the actor
+ *
+ */
+ this.mapper = function() {
+ return this.m_mapper;
+ };
+
+ /**
+ * Set mapper on the actor
+ *
+ */
+ this.setMapper = function(mapper) {
+ this.m_mapper = mapper;
+ };
+
+ /**
+ * TODO Implement this
+ *
+ */
+ this.accept = function(visitor) {
+ };
+
+ /**
+ * TODO Implement this
+ *
+ */
+ this.ascend = function(visitor) {
+ };
+
+ /**
+ * Compute object space to world space matrix
+ *
+ */
+ this.computeLocalToWorldMatrix = function(matrix, visitor) {
+ };
+
+ /**
+ * Compute world space to object space matrix
+ *
+ */
+ this.computeWorldToLocalMatrix = function(matrix, visitor) {
+ };
+
+ /**
+ * Compute actor bounds
+ *
+ */
+ this.computeBounds = function() {
+ };
};
-/// Get rotation as described by angle (in radians) and axis
-/// ( axis(x, y, z), angle )
-///---------------------------------------------------------------------------
-vglModule.actor.prototype.rotation = function() {
-};
-/// Set rotation as described by angle (in radians) and axis
-/// ( axis(x, y, z), angle )
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.setRotation = function(angle, x, y, z) {
-};
-
-/// Get scale in x, y and z directions
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.scale = function() {
-};
-/// Set scale in x, y and z directions
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.setScale = function(x, y, z) {
-};
-
-/// Get translation in x, y and z directions
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.translation = function() {
-};
-/// Set translation in x, y and z directions
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.setTranslation = function(x, y, z) {
-};
-
-/// Get reference frame for the transformations. Possible values
-/// are Absolute and Relative.
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.referenceFrame = function() {
-};
-/// Set reference frame for the transformations. Possible values
-/// are Absolute and Relative.
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.setReferenceFrame = function(referenceFrame) {
-};
-
-/// Evaluate the transform associated with the vtkvglModule.actor.
-/// Return affine transformation for the vglModule.actor.
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.modelViewMatrix = function() {
- var mat = mat4.create();
- mat4.identity(mat);
- return mat;
-};
-
-/// \copydoc vesTransformInterace::matrix
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.matrix = function() {
- return this.modelViewMatrix();
-};
-
-/// Get mapper of the actor
-/// \sa mapper
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.mapper = function() {
- return this.m_mapper;
-};
-/// Set mapper for the actor
-/// \sa mapper
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.setMapper = function(mapper) {
- this.m_mapper = mapper;
-};
-
-/// \copydoc node::accept()
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.accept = function(visitor) {
- // TODO
-};
-
-/// \copydoc node::ascend()
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.ascend = function(visitor) {
- // TODO
-};
-
-/// Compute object space to world space matrix
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.computeLocalToWorldMatrix = function(matrix, visitor) {
-};
-
-/// Compute world space to object space matrix
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.computeWorldToLocalMatrix = function(matrix, visitor) {
-};
-
-/// Compute actor bounds
-//----------------------------------------------------------------------------
-vglModule.actor.prototype.computeBounds = function() {
-};
+inherit(vglModule.actor, vglModule.node);
diff --git a/web/lib/vgl/material.js b/web/lib/vgl/material.js
index 34facfb..32a53b1 100644
--- a/web/lib/vgl/material.js
+++ b/web/lib/vgl/material.js
@@ -94,6 +94,11 @@ vglModule.material.prototype.render = function(renderState) {
};
///---------------------------------------------------------------------------
+vglModule.material.prototype.remove = function(renderState) {
+ this.undoBind(renderState);
+};
+
+///---------------------------------------------------------------------------
vglModule.material.prototype.bind = function(renderState) {
for (var key in this.m_attributes) {
@@ -102,9 +107,9 @@ vglModule.material.prototype.bind = function(renderState) {
}
}
- for (var index in this.m_textureAttributes) {
- if (this.m_textureAttributes.hasOwnProperty(index)) {
- this.m_textureAttributes[index].bind(renderState);
+ for (var key in this.m_textureAttributes) {
+ if (this.m_textureAttributes.hasOwnProperty(key)) {
+ this.m_textureAttributes[key].bind(renderState);
}
}
};
@@ -113,13 +118,13 @@ vglModule.material.prototype.undoBind = function(renderState) {
var key = null;
for (key in this.m_attributes) {
if (this.m_attributes.hasOwnProperty(key)) {
- this.m_attributes.undoBind(renderState);
+ this.m_attributes[key].undoBind(renderState);
}
}
for (key in this.m_textureAttributes) {
if (this.m_textureAttributes.hasOwnProperty(key)) {
- this.m_textureAttributes.undoBind(renderState);
+ this.m_textureAttributes[key].undoBind(renderState);
}
}
};
diff --git a/web/lib/vgl/planeSource.js b/web/lib/vgl/planeSource.js
index 5fed283..ce9f051 100644
--- a/web/lib/vgl/planeSource.js
+++ b/web/lib/vgl/planeSource.js
@@ -41,6 +41,7 @@ vglModule.planeSource = function() {
m_origin[2] = z;
}
+ /////////////////////////////////////////////////////////////////////////////
/**
* Set point that defines the first axis of the plane
*
@@ -51,6 +52,7 @@ vglModule.planeSource = function() {
m_point1[2] = z;
}
+ /////////////////////////////////////////////////////////////////////////////
/**
* Set point that defines the first axis of the plane
*
@@ -61,11 +63,13 @@ vglModule.planeSource = function() {
m_point2[2] = z;
}
+ /////////////////////////////////////////////////////////////////////////////
/**
* Create a plane geometry given input parameters
*
*/
this.create = function() {
+ m_geom = new vglModule.geometryData();
var x = [], tc = [], v1 = [], v2 = [];
x.length = 3, tc.length = 2, v1.length = 3, v2.length = 3;
@@ -88,7 +92,6 @@ vglModule.planeSource = function() {
}
// TODO Compute center and normal
- m_geom = new vglModule.geometryData();
// Set things up; allocate memory
numPts = (m_xresolution + 1) * (m_yresolution + 1);
diff --git a/web/lib/vgl/renderer.js b/web/lib/vgl/renderer.js
index df62d49..a5ea7e2 100644
--- a/web/lib/vgl/renderer.js
+++ b/web/lib/vgl/renderer.js
@@ -91,7 +91,6 @@ vglModule.renderer.prototype.render = function() {
var renSt = new vglModule.renderState();
renSt.m_projectionMatrix = perspectiveMatrix;
-
var children = this.m_sceneRoot.children();
for (var i = 0; i < children.length; ++i) {
var actor = children[i];
@@ -99,9 +98,10 @@ vglModule.renderer.prototype.render = function() {
renSt.m_material = actor.material();
renSt.m_mapper = actor.mapper();
- // NOTE For now we are taking a shortcut because of lack of time
+ // TODO Fix this shortcut
renSt.m_material.render(renSt);
renSt.m_mapper.render(renSt);
+ renSt.m_material.remove(renSt);
}
};
diff --git a/web/lib/vgl/texture.js b/web/lib/vgl/texture.js
index 3fac8be..13afc70 100644
--- a/web/lib/vgl/texture.js
+++ b/web/lib/vgl/texture.js
@@ -87,15 +87,12 @@ vglModule.texture.prototype.bind = function(renderState) {
this.setup(renderState);
}
-// gl.activeTexture(gl.TEXTURE0);
-// gl.bindTexture(gl.TEXTURE_2D, worldTexture);
-
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, this.m_textureHandle);
};
///---------------------------------------------------------------------------
vglModule.texture.prototype.undoBind = function(renderState) {
- gl.bindTexture(gl.TEXTURE_2D, 0);
+ gl.bindTexture(gl.TEXTURE_2D, null);
};
///---------------------------------------------------------------------------
diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index 98b37fe..ffd51a0 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -16,8 +16,9 @@
limitations under the License.
========================================================================*/
+///////////////////////////////////////////////////////////////////////////////
/**
- *
+ * Utility class provides helper functions to create geometry objects
*
*/
vglModule.utils = function() {
@@ -32,11 +33,13 @@ vglModule.utils = function() {
inherit(vglModule.utils, vglModule.object);
+///////////////////////////////////////////////////////////////////////////////
/**
-*
-* @param context
-* @returns {vglModule.shader}
-*/
+ * Helper function to create default fragment shader
+ *
+ * @param context
+ * @returns {vglModule.shader}
+ */
vglModule.utils.createDefaultFragmentShader = function(context) {
var fragmentShaderSource = [
'varying highp vec3 vTextureCoord;',
@@ -51,11 +54,13 @@ vglModule.utils.createDefaultFragmentShader = function(context) {
return shader;
};
+///////////////////////////////////////////////////////////////////////////////
/**
-*
-* @param context
-* @returns {vglModule.shader}
-*/
+ * Helper function to create default vertex shader
+ *
+ * @param context
+ * @returns {vglModule.shader}
+ */
vglModule.utils.createDefaultVertexShader = function(context) {
var vertexShaderSource = [
'attribute vec3 aVertexPosition;',
@@ -75,8 +80,9 @@ vglModule.utils.createDefaultVertexShader = function(context) {
return shader;
};
+///////////////////////////////////////////////////////////////////////////////
/**
- * Create a plane actor
+ * Helper function to create a plane node
*
* This method will create a plane actor with texture coordinates,
* eventually normal, and plane material.
@@ -117,6 +123,7 @@ vglModule.utils.createPlane = function(originX, originY, originZ,
mat.addAttribute(prog);
var actor = new vglModule.actor();
+ console.log(actor);
actor.setMapper(mapper);
actor.setMaterial(mat);
-----------------------------------------------------------------------
hooks/post-receive
--
OpenGeoscience
More information about the Opengeoscience-developers
mailing list