[Opengeoscience-developers] OpenGeoscience branch, add_timestamp_support, created. 6d2f4e860997c3bbc13b13fe3d004863db07b477

Aashish Chaudhary aashish.chaudhary at kitware.com
Sat Mar 9 19:59:52 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, add_timestamp_support has been created
        at  6d2f4e860997c3bbc13b13fe3d004863db07b477 (commit)

- Log -----------------------------------------------------------------
http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=6d2f4e860997c3bbc13b13fe3d004863db07b477
commit 6d2f4e860997c3bbc13b13fe3d004863db07b477
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 9 19:59:02 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 9 19:59:02 2013 -0500

    Fixed point sprite image not loaded initially

diff --git a/web/lib/app.js b/web/lib/app.js
index 631bcce..4f0117c 100644
--- a/web/lib/app.js
+++ b/web/lib/app.js
@@ -65,14 +65,18 @@ function main() {
           }
         }
 
-        var pointLayer = ogs.geo.featureLayer({
-          "opacity" : 1,
-          "showAttribution" : 1,
-          "visible" : 1
-        }, ogs.geo.pointSpritesFeature('/data/assets/spark.png', citieslatlon,
-                                       colors));
-
-        myMap.addLayer(pointLayer);
+        // Load image to be used for drawing dots
+        var image = new Image();
+        image.src = '/data/assets/spark.png';
+        image.onload = function() {
+          var pointLayer = ogs.geo.featureLayer({
+            "opacity" : 1,
+            "showAttribution" : 1,
+            "visible" : 1
+          }, ogs.geo.pointSpritesFeature(image, citieslatlon, colors));
+
+          myMap.addLayer(pointLayer);
+        };
       }
     }
   });
diff --git a/web/lib/geo/feature.js b/web/lib/geo/feature.js
index 268efdc..24edfe0 100644
--- a/web/lib/geo/feature.js
+++ b/web/lib/geo/feature.js
@@ -102,17 +102,16 @@ inherit(geoModule.pointFeature, geoModule.feature);
  * @param colors
  * @returns {geoModule.pointFeature}
  */
-geoModule.pointSpritesFeature = function(imageFilename, positions, colors) {
+geoModule.pointSpritesFeature = function(image, positions, colors) {
 
   if (!(this instanceof geoModule.pointSpritesFeature)) {
-    return new geoModule.pointSpritesFeature(imageFilename, positions, colors);
+    return new geoModule.pointSpritesFeature(image, positions, colors);
   }
 
   ogs.vgl.actor.call(this);
 
   // Initialize
-  var actor = ogs.vgl.utils
-      .createPointSprites(imageFilename, positions, colors);
+  var actor = ogs.vgl.utils.createPointSprites(image, positions, colors);
   this.setMapper(actor.mapper());
   this.setMaterial(actor.material());
 
diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index 49a8536..f32efc4 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -66,6 +66,7 @@ geoModule.map = function(node, options) {
   if (!(this instanceof geoModule.map)) {
     return new geoModule.map(node, options);
   }
+  ogs.vgl.object.call(this);
 
   // Member variables
   this.events = {
@@ -326,7 +327,7 @@ geoModule.map = function(node, options) {
       // TODO Set the rendering order correctly
       m_renderer.addActor(layer.actor());
       m_renderer.render();
-
+      this.modified();
       return true;
     }
 
@@ -369,3 +370,5 @@ geoModule.map = function(node, options) {
 
   return this;
 };
+
+inherit(geoModule.map, ogs.vgl.object);
diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index 438c035..a91279d 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -250,7 +250,7 @@ vglModule.utils.createGeometryMaterial = function() {
  *
  * @returns {vglModule.material}
  */
-vglModule.utils.createPointSpritesMaterial = function(imageFilename) {
+vglModule.utils.createPointSpritesMaterial = function(image) {
   var mat = new vglModule.material();
   var blend = new vglModule.blend();
   var prog = new vglModule.shaderProgram();
@@ -279,9 +279,7 @@ vglModule.utils.createPointSpritesMaterial = function(imageFilename) {
   mat.addAttribute(prog);
   mat.addAttribute(blend);
 
-  // Load the texture
-  var image = new Image();
-  image.src = imageFilename;
+  // Create and set the texture
   var texture = new vglModule.texture();
   texture.setImage(image);
   mat.addAttribute(texture);
@@ -371,7 +369,7 @@ vglModule.utils.createPoints = function(positions, colors, texcoords) {
 
   mapper.setGeometryData(pointSource.create());
 
-  var mat = vglModule.utils.createGeometryMaterial(imageFilename);
+  var mat = vglModule.utils.createGeometryMaterial();
 
   var actor = new vglModule.actor();
   actor.setMapper(mapper);
@@ -388,9 +386,9 @@ vglModule.utils.createPoints = function(positions, colors, texcoords) {
  *
  * @returns {vglModule.actor}
  */
-vglModule.utils.createPointSprites = function(imageFilename, positions, colors,
+vglModule.utils.createPointSprites = function(image, positions, colors,
                                               texcoords) {
-  if (!imageFilename) {
+  if (!image) {
     console.log("[ERROR] Point sprites requires an image");
     return null;
   }
@@ -414,7 +412,7 @@ vglModule.utils.createPointSprites = function(imageFilename, positions, colors,
 
   mapper.setGeometryData(pointSource.create());
 
-  var mat = vglModule.utils.createPointSpritesMaterial(imageFilename);
+  var mat = vglModule.utils.createPointSpritesMaterial(image);
   var actor = new vglModule.actor();
   actor.setMapper(mapper);
   actor.setMaterial(mat);

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=c38a69d95e5d9da499e7d25087488a937144d4ab
commit c38a69d95e5d9da499e7d25087488a937144d4ab
Merge: 5187966 2ed35dd
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 9 19:50:49 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 9 19:50:49 2013 -0500

    Merge remote-tracking branch 'origin/update_data_ref' into add_timestamp_support
    
    * origin/update_data_ref:
      Removed debug message
      Updated location of data in the source code
      Added custom command to copy data and rm data
      Added custom command to copy data and rm data
      Updated pointer to the raw data


http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=5187966d12b544113dfdeceaf86b6ab52f5362ef
commit 5187966d12b544113dfdeceaf86b6ab52f5362ef
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 9 19:24:27 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 9 19:49:33 2013 -0500

    Added support to use timestmap based modification

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0dfd70e..c933a50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ set(JS_LINT_FILES
     ${CMAKE_SOURCE_DIR}/web/lib/init.js
     ${CMAKE_SOURCE_DIR}/web/lib/jsHelper.js
     ${CMAKE_SOURCE_DIR}/web/lib/core/init.js
+    ${CMAKE_SOURCE_DIR}/web/lib/core/timestamp.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
@@ -77,6 +78,7 @@ set(JS_UGLIFY_FILES
   ${CMAKE_SOURCE_DIR}/web/lib/init.js
   ${CMAKE_SOURCE_DIR}/web/lib/jsHelper.js
   ${CMAKE_SOURCE_DIR}/web/lib/core/init.js
+  ${CMAKE_SOURCE_DIR}/web/lib/core/timestamp.js
   ${CMAKE_SOURCE_DIR}/web/lib/vgl/init.js
   ${CMAKE_SOURCE_DIR}/web/lib/vgl/object.js
   ${CMAKE_SOURCE_DIR}/web/lib/vgl/boundingObject.js
diff --git a/web/lib/core/timestamp.js b/web/lib/core/timestamp.js
new file mode 100644
index 0000000..0a2bc70
--- /dev/null
+++ b/web/lib/core/timestamp.js
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// timestamp class
+//
+//////////////////////////////////////////////////////////////////////////////
+
+m_globalModifiedTime = 0;
+
+coreModule.timestamp = function() {
+
+  if (!(this instanceof coreModule.timestamp)) {
+    return new coreModule.timestamp();
+  }
+
+  var m_modifiedTime = 0;
+
+  this.modified = function() {
+    ++m_globalModifiedTime;
+    m_modifiedTime = m_globalModifiedTime;
+  };
+
+  this.getMTime = function() {
+    return m_modifiedTime;
+  };
+};
\ No newline at end of file
diff --git a/web/lib/vgl/boundingObject.js b/web/lib/vgl/boundingObject.js
index ebddde5..6d7a790 100644
--- a/web/lib/vgl/boundingObject.js
+++ b/web/lib/vgl/boundingObject.js
@@ -21,7 +21,6 @@
 // boundingObject class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.boundingObject = function() {
 
   if (!(this instanceof vglModule.boundingObject)) {
@@ -32,30 +31,41 @@ vglModule.boundingObject = function() {
   var m_boundsDirty = true;
   var m_bounds = new Array(6);
 
-  /// Return dirty state of bounds
+  /**
+   * Return true if bounds are dirty otherwise false
+   *
+   */
   this.boundsDirty = function() {
     return m_boundsDirty;
   };
 
-  /// Set bounds dirty
+  /**
+   * Mark bounds dirty for the object
+   *
+   */
   this.setBoundsDirty = function(flag) {
     if (m_boundsDirty !== flag) {
       m_boundsDirty = flag;
-      this.modifiedOn();
+      this.modified();
       return true;
     }
 
     return false;
   };
 
-  /// Return current bounds
-  this.bounds  = function() {
+  /**
+   * Get current bounds of the object
+   *
+   */
+  this.bounds = function() {
     return m_bounds;
   };
 
-  /// Set current bounds
-  this.setBounds = function(minX, maxX, minY, maxY,
-                                                    minZ, maxZ) {
+  /**
+   * Set current bounds of the object
+   *
+   */
+  this.setBounds = function(minX, maxX, minY, maxY, minZ, maxZ) {
     m_bounds[0] = minX;
     m_bounds[1] = maxX;
     m_bounds[2] = minY;
@@ -63,12 +73,12 @@ vglModule.boundingObject = function() {
     m_bounds[4] = minZ;
     m_bounds[5] = maxZ;
 
-    this.modifiedOn();
+    this.modified();
 
     return true;
   };
 
-  /// Request computing bounds. Should be implemented by the concrete class
+  // / Request computing bounds. Should be implemented by the concrete class
   this.computeBounds = function() {
   };
 
diff --git a/web/lib/vgl/material.js b/web/lib/vgl/material.js
index 48a05c9..79999b9 100644
--- a/web/lib/vgl/material.js
+++ b/web/lib/vgl/material.js
@@ -21,14 +21,13 @@
 // material class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.material = function() {
 
   this.RenderBin = {
-    "Default"     : 0,
-    "Opaque"      : 1,
+    "Default" : 0,
+    "Opaque" : 1,
     "Transparent" : 10,
-    "Overlay"     : 20
+    "Overlay" : 20
   };
 
   if (!(this instanceof vglModule.material)) {
@@ -36,26 +35,27 @@ vglModule.material = function() {
   }
   vglModule.object.call(this);
 
-  /// Private member variables
+  // / Private member variables
   var m_shaderProgram = new vglModule.shaderProgram();
   var m_binNumber = 0;
   var m_textureAttributes = {};
   var m_attributes = {};
 
-  /// Public member methods
+  // / Public member methods
   this.binNumber = function() {
     return m_binNumber;
   };
 
   this.setBinNumber = function(binNo) {
     m_binNumber = binNo;
-    this.modifiedOn();
+    this.modified();
   };
 
   this.exists = function(attr) {
     if (attr.type() === vglModule.materialAttribute.Texture) {
       return m_textureAttributes.hasOwnProperty(attr);
-    } else {
+    }
+    else {
       return m_attributes.hasOwnProperty(attr);
     }
   };
@@ -68,15 +68,17 @@ vglModule.material = function() {
 
     if (attr.type() === materialAttributeType.Texture) {
       m_textureAttributes[attr.textureUnit()] = attr;
-      this.modifiedOn();
+      this.modified();
       return true;
-    } else {
+    }
+    else {
       // Shader is a very special attribute
       if (attr.type() === materialAttributeType.ShaderProgram) {
         m_shaderProgram = attr;
       }
 
       m_attributes[attr.type()] = attr;
+      this.modified();
       return true;
     }
 
@@ -97,13 +99,13 @@ vglModule.material = function() {
 
   this.bind = function(renderState) {
 
-    for (var key in m_attributes) {
+    for ( var key in m_attributes) {
       if (m_attributes.hasOwnProperty(key)) {
         m_attributes[key].bind(renderState);
       }
     }
 
-    for (var key in m_textureAttributes) {
+    for ( var key in m_textureAttributes) {
       if (m_textureAttributes.hasOwnProperty(key)) {
         m_textureAttributes[key].bind(renderState);
       }
@@ -127,7 +129,7 @@ vglModule.material = function() {
 
   this.bindVertexData = function(renderState, key) {
 
-    for (var i in m_attributes) {
+    for ( var i in m_attributes) {
       if (m_attributes.hasOwnProperty(i)) {
         m_attributes[i].bindVertexData(renderState, key);
       }
@@ -135,7 +137,7 @@ vglModule.material = function() {
   };
 
   this.undoBindVertexData = function(renderState, key) {
-    for (var i in m_attributes) {
+    for ( var i in m_attributes) {
       if (m_attributes.hasOwnProperty(i)) {
         m_attributes.undoBindVertexData(renderState, key);
       }
diff --git a/web/lib/vgl/node.js b/web/lib/vgl/node.js
index 82b42ae..3cb9b63 100644
--- a/web/lib/vgl/node.js
+++ b/web/lib/vgl/node.js
@@ -21,7 +21,6 @@
 // node class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.node = function() {
 
   if (!(this instanceof vglModule.node)) {
@@ -29,13 +28,13 @@ vglModule.node = function() {
   }
   vglModule.boundingObject.call(this);
 
-  /// Private member variables
+  // / Private member variables
   var m_parent = null;
   var m_material = null;
   var m_visible = true;
   var m_overlay = false;
 
-  /// Public member methods
+  // / Public member methods
 
   /**
    * Accept visitor for scene traversal
@@ -58,10 +57,9 @@ vglModule.node = function() {
    *
    */
   this.setMaterial = function(material) {
-    if (material !== m_material)
-    {
+    if (material !== m_material) {
       m_material = material;
-      this.modifiedOn();
+      this.modified();
       return true;
     }
 
@@ -81,9 +79,9 @@ vglModule.node = function() {
    *
    */
   this.setVisible = function(flag) {
-    if (flag !== m_visible)   {
+    if (flag !== m_visible) {
       m_visible = flag;
-      this.modifiedOn();
+      this.modified();
       return true;
     }
 
@@ -108,7 +106,7 @@ vglModule.node = function() {
         m_parent.removeChild(this);
       }
       m_parent = parent;
-      this.modifiedOn();
+      this.modified();
       return true;
     }
 
@@ -128,9 +126,9 @@ vglModule.node = function() {
    *
    */
   this.setOverlay = function(flag) {
-    if (m_overlay !== flag)   {
+    if (m_overlay !== flag) {
       m_overlay = flag;
-      this.modifiedOn();
+      this.modified();
       return true;
     }
 
@@ -156,7 +154,7 @@ vglModule.node = function() {
    *
    */
   this.computeBounds = function() {
-    if (this.boundsDirty())   {
+    if (this.boundsDirty()) {
       this.resetBounds();
     }
   };
diff --git a/web/lib/vgl/object.js b/web/lib/vgl/object.js
index 34e2615..1f1ef65 100644
--- a/web/lib/vgl/object.js
+++ b/web/lib/vgl/object.js
@@ -21,28 +21,24 @@
 // vglObject class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.object = function() {
-  /// TODO Switch to time based modifications
+  // / TODO Switch to time based modifications
 
   if (!(this instanceof vglModule.object)) {
     return new vglModule.object();
   }
 
-  /// Private variables
-  var m_modified = false;
+  // Private variables
+  var m_modifiedTime = coreModule.timestamp();
+  m_modifiedTime.modified();
 
-  /// Public member methods
+  // Public member methods
   this.modified = function() {
-    return m_modified;
-  };
-
-  this.modifiedOn = function() {
-    m_modified = true;
+    m_modifiedTime.modified();
   };
 
-  this.modifiedOff = function() {
-    m_modified = false;
+  this.getMTime = function() {
+    return m_modifiedTime.getMTime();
   };
 
   return this;
diff --git a/web/lib/vgl/shader.js b/web/lib/vgl/shader.js
index d0adb84..5e8284a 100644
--- a/web/lib/vgl/shader.js
+++ b/web/lib/vgl/shader.js
@@ -29,6 +29,7 @@ vglModule.shader = function(type) {
   vglModule.object.call(this);
 
   var m_shaderHandle = null;
+  var m_compileTimestmap = coreModule.timestamp();
   var m_shaderType = type;
   var m_shaderSource = "";
   var m_fileName = "";
@@ -46,7 +47,7 @@ vglModule.shader = function(type) {
 
   this.setFileName = function(fileName) {
     m_fileName = fileName;
-    this.modifiedOn();
+    this.modified();
   };
 
   this.shaderSource = function() {
@@ -55,11 +56,11 @@ vglModule.shader = function(type) {
 
   this.setShaderSource = function(source) {
     m_shaderSource = source;
-    this.modifiedOn();
+    this.modified();
   };
 
   this.compile = function() {
-    if (this.modified() === false) {
+    if (this.getMTime() < m_compileTimestmap.getMTime()) {
       return m_shaderHandle;
     }
 
@@ -77,7 +78,7 @@ vglModule.shader = function(type) {
       return null;
     }
 
-    this.modifiedOff();
+    m_compileTimestmap.modified();
 
     return m_shaderHandle;
   };
diff --git a/web/lib/vgl/shaderProgram.js b/web/lib/vgl/shaderProgram.js
index ae5cb1b..6504ce9 100644
--- a/web/lib/vgl/shaderProgram.js
+++ b/web/lib/vgl/shaderProgram.js
@@ -30,6 +30,7 @@ vglModule.shaderProgram = function() {
 
   // / Private member variables
   var m_programHandle = 0;
+  var m_compileTimestamp = coreModule.timestamp();
   var m_shaders = [];
   var m_uniforms = [];
   var m_vertexAttributes = {};
@@ -59,7 +60,7 @@ vglModule.shaderProgram = function() {
 
     m_shaders.push(shader);
 
-    this.modifiedOn();
+    this.modified();
     return true;
   };
 
@@ -69,13 +70,13 @@ vglModule.shaderProgram = function() {
     }
 
     m_uniforms.push(uniform);
-    this.modifiedOn();
+    this.modified();
   };
 
   this.addVertexAttribute = function(attr, key) {
     m_vertexAttributes[key] = attr;
 
-    this.modifiedOn();
+    this.modified();
   };
 
   this.uniformLocation = function(name) {
@@ -144,7 +145,8 @@ vglModule.shaderProgram = function() {
   this.bind = function(renderState) {
     var i = 0;
 
-    if (m_programHandle === 0 || this.modified()) {
+    if (m_programHandle === 0
+        || (m_compileTimestamp.getMTime() < this.getMTime())) {
       m_programHandle = gl.createProgram();
 
       if (m_programHandle === 0) {
@@ -168,7 +170,7 @@ vglModule.shaderProgram = function() {
 
       this.use();
       this.bindUniforms();
-      this.modifiedOff();
+      m_compileTimestamp.modified();
     }
     else {
       this.use();
diff --git a/web/lib/vgl/texture.js b/web/lib/vgl/texture.js
index 448d8f2..c378430 100644
--- a/web/lib/vgl/texture.js
+++ b/web/lib/vgl/texture.js
@@ -28,7 +28,7 @@ vglModule.texture = function() {
   }
   vglModule.materialAttribute.call(this, materialAttributeType.Texture);
 
-  // / Private member variables
+  // Private member variables
   this.m_width = 0;
   this.m_height = 0;
   this.m_depth = 0;
@@ -43,7 +43,7 @@ vglModule.texture = function() {
 
   this.m_image = null;
 
-  this.modifiedOn();
+  var m_setupTimestamp = coreModule.timestamp();
 
   // / Public member methods
   this.setup = function(renderState) {
@@ -75,12 +75,12 @@ vglModule.texture = function() {
     }
 
     gl.bindTexture(gl.TEXTURE_2D, null);
-    this.modifiedOff();
+    m_setupTimestamp.modified();
   };
 
   this.bind = function(renderState) {
     // TODO Call setup via material setup
-    if (this.modified()) {
+    if (this.getMTime() > m_setupTimestamp.getMTime()) {
       this.setup(renderState);
     }
 
@@ -100,7 +100,7 @@ vglModule.texture = function() {
     if (image !== null) {
       this.m_image = image;
       this.updateDimensions();
-      this.modifiedOn(true);
+      this.modified();
       return true;
     }
 
@@ -117,7 +117,7 @@ vglModule.texture = function() {
     }
 
     this.m_textureUnit = unit;
-    this.modifiedOn(true);
+    this.modified();
     return true;
   };
 
@@ -131,7 +131,7 @@ vglModule.texture = function() {
     }
 
     this.m_width = width;
-    this.modifiedOn();
+    this.modified();
 
     return true;
   };
@@ -146,7 +146,7 @@ vglModule.texture = function() {
     }
 
     this.m_depth = depth;
-    this.modifiedOn();
+    this.modified();
     return true;
   };
 
@@ -161,7 +161,7 @@ vglModule.texture = function() {
   this.setInternalFormat = function(internalFormat) {
     if (this.m_internalFormat !== internalFormat) {
       this.m_internalFormat = internalFormat;
-      this.modifiedOn(true);
+      this.modified();
 
       return true;
     }
@@ -179,7 +179,7 @@ vglModule.texture = function() {
     }
 
     this.m_pixelFormat = pixelFormat;
-    this.modifiedOn();
+    this.modified();
     return true;
   };
 
@@ -194,7 +194,7 @@ vglModule.texture = function() {
 
     this.m_pixelDataTYpe = pixelDataType;
 
-    this.modifiedOn();
+    this.modified();
 
     return true;
   };

-----------------------------------------------------------------------


hooks/post-receive
-- 
OpenGeoscience



More information about the Opengeoscience-developers mailing list