Index: trunk/vizservers/nanovis/Command.cpp
===================================================================
--- trunk/vizservers/nanovis/Command.cpp	(revision 836)
+++ trunk/vizservers/nanovis/Command.cpp	(revision 837)
@@ -1052,12 +1052,25 @@
 	    x = - 10 + i%20;
 	    data[i] = exp(- (x * x)/(2 * sigma * sigma)) / 
-		(sigma * sqrt(2.0)) / mean;
-	}
+		(sigma * sqrt(2.0)) / mean * 2;
+	}
+
 	HeightMap* heightMap = new HeightMap();
-	heightMap->setHeight(0.0f, 0.0f, 1.0f, 1.0f, 20, 20, data);
+    float minx = 0.0f;
+    float maxx = 1.0f;
+    float miny = 0.5f;
+    float maxy = 3.5f;
+	heightMap->setHeight(minx, miny, maxx, maxy, 20, 20, data);
 	heightMap->setColorMap(NanoVis::get_transfunc("default"));
 	heightMap->setVisible(true);
 	heightMap->setLineContourVisible(true);
 	NanoVis::g_heightMap.push_back(heightMap);
+
+
+    Vector3 min(minx, (float) heightMap->range_min(), miny);
+    Vector3 max(maxx, (float) heightMap->range_max(), maxy);
+
+    g_grid->setMinMax(min, max);
+    g_grid->setVisible(true);
+
 	return TCL_OK;
     }
@@ -1251,5 +1264,5 @@
 	}
 	if (g_grid) {
-	    g_grid->setAxisColor(r, g, b);
+	    g_grid->setAxisColor(r, g, b, 1.0f);
 	}
     } else if ((c == 'l') && (strcmp(argv[1],"linecolor") == 0)) {
@@ -1261,5 +1274,5 @@
 	}
 	if (g_grid) {
-	    g_grid->setGridLineColor(r, g, b);
+	    g_grid->setGridLineColor(r, g, b, 1.0f);
 	}
     } else if ((c == 'm') && (strcmp(argv[1],"minmax") == 0)) {
Index: trunk/vizservers/nanovis/Grid.cpp
===================================================================
--- trunk/vizservers/nanovis/Grid.cpp	(revision 836)
+++ trunk/vizservers/nanovis/Grid.cpp	(revision 837)
@@ -4,6 +4,6 @@
 
 Grid::Grid()
-: _axisColor(1.0f, 1.0f, 1.0f), _font(0), _axisGridLineCount(5.0f, 5.0f, 5.0f),
-_axisMin(0.0f, 0.0f, 0.0f), _axisMax(1.0f, 1.0f, 1.0f), _gridLineColor(1.0f, 1.0f, 1.0f), _visible(false)
+: _axisColor(1.0f, 1.0f, 1.0f, 1.0f), _font(0), _axisGridLineCount(5.0f, 5.0f, 5.0f),
+_axisMin(0.0f, 0.0f, 0.0f), _axisMax(1.0f, 1.0f, 1.0f), _gridLineColor(1.0f, 1.0f, 1.0f, 1.0f), _visible(false)
 {
 	__axisScale = _axisMax - _axisMin;
@@ -18,6 +18,6 @@
 	glEnable(GL_DEPTH_TEST);
 
-	//glTranslatef(0.5f, 0.5f, 0.5f);
-	glScalef(1.0f, __axisScale.y / __axisScale.x, __axisScale.z / __axisScale.x);
+	glScalef(1.0 / __axisScale.x, __axisScale.y / __axisScale.x, __axisScale.z / __axisScale.x);
+
 	glTranslatef(-0.5f, -0.5f, -0.5f);
 	glLineWidth(2.0f);
@@ -121,5 +121,5 @@
 				glLoadIdentity();
 				glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f);
-				sprintf(buff, "%0.2f", __axisScale.y / _axisGridLineCount.y * i);
+				sprintf(buff, "%0.2f", __axisScale.y / _axisGridLineCount.y * i + _axisMin.y);
 				_font->draw(buff);
 			}
@@ -132,5 +132,5 @@
 				glLoadIdentity();
 				glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f);
-				sprintf(buff, "%0.2f", __axisScale.z / _axisGridLineCount.z * i);
+				sprintf(buff, "%0.2f", __axisScale.z / _axisGridLineCount.z * i + _axisMin.z);
 				_font->draw(buff);
 			}
@@ -143,5 +143,5 @@
 				glLoadIdentity();
 				glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f);
-				sprintf(buff, "%0.2f", __axisScale.x / _axisGridLineCount.x * i);
+				sprintf(buff, "%0.2f", __axisScale.x / _axisGridLineCount.x * i + _axisMin.x);
 				_font->draw(buff);
 			}
Index: trunk/vizservers/nanovis/Grid.h
===================================================================
--- trunk/vizservers/nanovis/Grid.h	(revision 836)
+++ trunk/vizservers/nanovis/Grid.h	(revision 837)
@@ -4,10 +4,11 @@
 #include <R2/R2Fonts.h>
 #include "Vector3.h"
+#include "Vector4.h"
 
 class Grid {
 	Vector3 __axisScale;
 
-	Vector3 _axisColor;
-	Vector3 _gridLineColor;
+	Vector4 _axisColor;
+	Vector4 _gridLineColor;
 	Vector3 _axisMax;
 	Vector3 _axisMin;
@@ -32,6 +33,6 @@
 
     void setGridLineCount(int x, int y, int z);
-    void setAxisColor(float r, float g, float b);
-    void setGridLineColor(float r, float g, float b);
+    void setAxisColor(float r, float g, float b, float a);
+    void setGridLineColor(float r, float g, float b, float a);
     void setMinMax(const Vector3& min, const Vector3& max);
     void setAxisName(int axisID, const char* name);
@@ -67,16 +68,18 @@
 }
 
-inline void Grid::setAxisColor(float r, float g, float b)
+inline void Grid::setAxisColor(float r, float g, float b, float a)
 {
     _axisColor.x = r;
     _axisColor.y = g;
     _axisColor.z = b;
+    _axisColor.w = a;
 }
 
-inline void Grid::setGridLineColor(float r, float g, float b)
+inline void Grid::setGridLineColor(float r, float g, float b, float a)
 {
     _gridLineColor.x = r;
     _gridLineColor.y = g;
     _gridLineColor.z = b;
+    _gridLineColor.w = a;
 }
 
@@ -85,5 +88,7 @@
     _axisMin = min;
     _axisMax = max;
-	__axisScale = _axisMax - _axisMin;
+	__axisScale.x = _axisMax.x - _axisMin.x;
+	__axisScale.y = _axisMax.y - _axisMin.y;
+	__axisScale.z = _axisMax.z - _axisMin.z;
 }
 
Index: trunk/vizservers/nanovis/HeightMap.cpp
===================================================================
--- trunk/vizservers/nanovis/HeightMap.cpp	(revision 836)
+++ trunk/vizservers/nanovis/HeightMap.cpp	(revision 837)
@@ -15,6 +15,7 @@
 
 HeightMap::HeightMap()
-: _contour(0), _colorMap(0), _indexBuffer(0), _vertexBufferObjectID(0), _vertexCount(0), _textureBufferObjectID(0),
-  _contourVisible(true), _scale(1.0f, 1.0f, 1.0f), _contourColor(1.0f, 0.0f, 0.0f)
+: _contour(0), _colorMap(0), _indexBuffer(0), _indexCount(0), _vertexBufferObjectID(0), _vertexCount(0), 
+    _textureBufferObjectID(0), _contourVisible(true), _scale(1.0f, 1.0f, 1.0f), _contourColor(1.0f, 0.0f, 0.0f), _visible(false),
+    _vmin(0.0f), _vmax(0.0f), _centerPoint(0.0f, 0.0f, 0.0f)
 {
 	_shader = new NvShader();
@@ -42,6 +43,12 @@
 {
     glPushMatrix();
-    glScalef(_scale.x, _scale.y, _scale.z);
-    glTranslatef(-0.5f, -0.5f, -0.5f);
+
+    if (_scale.x != 0)
+    {
+        glScalef(1 / _scale.x, 1 / _scale.x , 1 / _scale.x);
+    }
+
+    glTranslatef(-_centerPoint.x, - _centerPoint.y, - _centerPoint.z);
+
 	if (_contour)
 	{
@@ -208,8 +215,15 @@
 	    if (_vmin > heights[i].y) {
 		_vmin = heights[i].y;
-	    } else if (_vmax < heights[i].y) {
+	    } 
+        if (_vmax < heights[i].y) {
 		_vmax = heights[i].y;
 	    }
 	}
+
+    _scale.x = 1.0f;
+    _scale.z = _vmax - _vmin;
+    _scale.y = 1.0f;
+
+    _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + _vmin, _scale.y * 0.5);
 
 	Vector3* texcoord = (Vector3*) malloc(count * sizeof(Vector3));
@@ -259,4 +273,5 @@
 {
 	_vertexCount = xCount * yCount;
+
 	reset();
 
@@ -266,14 +281,20 @@
 	    if (_vmin > heights[i]) {
 		_vmin = heights[i];
-	    } else if (_vmax < heights[i]) {
+	    } 
+
+        if (_vmax < heights[i]) {
 		_vmax = heights[i];
 	    }
 	}
-    //_scale.x = endX - startX;
-    //_scale.y = (endY - startY) / _scale.x;
-    //_scale.z = max / _scale.z;
+
+    _scale.x = endX - startX;
+    _scale.y = _vmax - _vmin;
+    _scale.z = endY - startY;
+
+    _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + _vmin, _scale.z * 0.5 + startY);
 
 	Vector3* texcoord = (Vector3*) malloc(count * sizeof(Vector3));
-	for (int i = 0; i < count; ++i) {
+	for (int i = 0; i < count; ++i) 
+    {
 	    texcoord[i].set(0, 0, heights[i]);
 	}
Index: trunk/vizservers/nanovis/HeightMap.h
===================================================================
--- trunk/vizservers/nanovis/HeightMap.h	(revision 836)
+++ trunk/vizservers/nanovis/HeightMap.h	(revision 837)
@@ -30,4 +30,5 @@
     
     Vector3 _scale;
+    Vector3 _centerPoint;
 
     double _vmin;		// minimum (unscaled) value in data
