r486: no message
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 4 Feb 2001 21:28:19 +0000 (21:28 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 4 Feb 2001 21:28:19 +0000 (21:28 +0000)
libctsim/scanner.cpp
msvc/ctsim/ctsim.plg
src/ctsim.h
src/graph3dview.cpp
src/graph3dview.h
src/views.cpp

index 120ddb515dc44080148cb054984befe2d0f543e0..6e2e57ad48bf962af80a9219c9638947f21bc713 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: scanner.cpp,v 1.28 2001/02/02 00:46:38 kevin Exp $
+**  $Id: scanner.cpp,v 1.29 2001/02/04 21:28:19 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -132,7 +132,7 @@ Scanner::Scanner (const Phantom& phm, const char* const geometryName, int nDet,
     m_initPos.yd2 = m_dYCenter - m_dFocalLength;
     m_initPos.angle = 0.0;
   } else if (m_idGeometry == GEOMETRY_EQUILINEAR) {
-
+#if 0
     double dAngle1 = atan ((m_dFieldOfView / 2) / m_dFocalLength);
     double dHalfSquare = m_dFieldOfView / SQRT2 / 2;
     double dFocalPastPhm = m_dFocalLength - dHalfSquare;
@@ -143,8 +143,14 @@ Scanner::Scanner (const Phantom& phm, const char* const geometryName, int nDet,
     }
     double dAngle2 = atan( dHalfSquare / dFocalPastPhm );
     double dAngle = maxValue<double> (dAngle1, dAngle2);
-#if 0
-    double dAngle = (m_dFieldOfView / 2) / cos (asin (m_dFieldOfView / 2 / m_dFocalLength));
+    //double dAngle = (m_dFieldOfView / 2) / cos (asin (m_dFieldOfView / 2 / m_dFocalLength));
+#else
+    if (m_dFieldOfView/2 >= m_dFocalLength) {
+      m_fail = true;
+      m_failMessage = "Invalid geometry: Focal length must be larger than field of view";
+      return;
+    }
+    double dAngle = asin ((m_dFieldOfView/2) / m_dFocalLength);
 #endif    
 
     double dHalfDetLen = 2 * m_dFocalLength * tan (dAngle);
@@ -165,17 +171,12 @@ Scanner::Scanner (const Phantom& phm, const char* const geometryName, int nDet,
     m_initPos.yd2 = m_dYCenter - m_dFocalLength;
     m_initPos.angle = 0.0;
   } else if (m_idGeometry == GEOMETRY_EQUIANGULAR) {
-    double dAngle1 = atan ((m_dFieldOfView / 2) / m_dFocalLength);
-
-    double dHalfSquare = m_dFieldOfView / SQRT2 / 2;
-    double dFocalPastPhm = m_dFocalLength - dHalfSquare;
-    if (dFocalPastPhm <= 0.) {
+    if (m_dFieldOfView/2 > m_dFocalLength) {
       m_fail = true;
-      m_failMessage = "Focal Point inside of phantom";
+      m_failMessage = "Invalid geometry: Focal length must be larger than field of view";
       return;
     }
-    double dAngle2 =  atan ( dHalfSquare / dFocalPastPhm ); 
-    double dAngle = maxValue<double> (dAngle1, dAngle2);
+    double dAngle = asin ((m_dFieldOfView/2) / m_dFocalLength);
 
     m_detLen = 2 * dAngle;
     m_detInc = m_detLen / m_nDet;
index 268e5bdf356e44ef65326f6341a60b6c702dd0d6..f7919e4cbaf7924f69dd00d193733b8d75154df7 100644 (file)
@@ -6,13 +6,13 @@
 --------------------Configuration: ctsim - Win32 Debug--------------------
 </h3>
 <h3>Command Lines</h3>
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP35.tmp" with contents
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP18A.tmp" with contents
 [
 /nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.0.0beta1\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c 
 "C:\ctsim\src\graph3dview.cpp"
 ]
-Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP35.tmp" 
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP36.tmp" with contents
+Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP18A.tmp" 
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP18B.tmp" with contents
 [
 comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libctsim/Debug/libctsim.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib wxd.lib xpmd.lib tiffd.lib zlibd.lib pngd.lib opengl32.lib glu32.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"\wx2.2.5\lib" 
 .\Debug\ctsim.obj
@@ -33,28 +33,16 @@ comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib w
 \wx2.2.5\lib\zlibd.lib
 \wx2.2.5\lib\tiffd.lib
 ]
-Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP36.tmp"
+Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP18B.tmp"
 <h3>Output Window</h3>
 Compiling...
 graph3dview.cpp
-C:\ctsim\src\graph3dview.cpp(288) : warning C4101: 'n2' : unreferenced local variable
-C:\ctsim\src\graph3dview.cpp(288) : warning C4101: 'n3' : unreferenced local variable
-C:\ctsim\src\graph3dview.cpp(288) : warning C4101: 'n4' : unreferenced local variable
-C:\ctsim\src\graph3dview.cpp(426) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(426) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(426) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(435) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(435) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(435) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(436) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(436) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
-C:\ctsim\src\graph3dview.cpp(436) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
 Linking...
 
 
 
 <h3>Results</h3>
-ctsim.exe - 0 error(s), 12 warning(s)
+ctsim.exe - 0 error(s), 0 warning(s)
 </pre>
 </body>
 </html>
index e33c05cd2f914f3661b9a1a74c5cff21a6c0c9f9..f2bac543d00c82144bca305c4c8a69c0a9a607c2 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: ctsim.h,v 1.40 2001/02/02 00:46:38 kevin Exp $
+**  $Id: ctsim.h,v 1.41 2001/02/04 21:28:19 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -315,6 +315,9 @@ enum {
     GRAPH3D_VIEW_COLOR,
     GRAPH3D_VIEW_LIGHTING,
     GRAPH3D_VIEW_SMOOTH,
+    GRAPH3D_VIEW_SCALE_AUTO,
+    GRAPH3D_VIEW_SCALE_MINMAX,
+    GRAPH3D_VIEW_SCALE_FULL,
 };
 
 #endif
index fee78aa84c77c21d021d19221aa468981343e75e..d0d53edeb839b0293cd1e40b5147b0a7e0a7213c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: graph3dview.cpp,v 1.9 2001/02/03 18:43:43 kevin Exp $
+**  $Id: graph3dview.cpp,v 1.10 2001/02/04 21:28:19 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 #include <sstream_subst>
 #endif
 
-// Rainbow: Purple->Blue->Cyan->Green->Yellow->Red = (1,0,1)-(0,0,1)-(0,1,1)-(0,1,0)-(1,1,0)-(1,0,0)
-static void 
-intensityToColor (double dIntensity, float vecColor[3])
+void 
+Graph3dFileView::intensityToColor (double dIntensity, GLfloat* vecColor)
 {
-  double dRange = dIntensity * 5;
-  int iRange = static_cast<int>(floor (dRange));
-  double dFrac = dRange - iRange;
+  if (dIntensity < 0 || dIntensity > 1) {
+    vecColor[0] = vecColor[1] = vecColor[2] = 1;
+    return;
+  }
+  
+  float fRange = dIntensity * 5;
+  int iRange = static_cast<int>(floor (fRange));
+  float fFrac = fRange - iRange;
   
+  // Rainbow: Purple->Blue->Cyan->Green->Yellow->Red = (1,0,1)-(0,0,1)-(0,1,1)-(0,1,0)-(1,1,0)-(1,0,0)
   switch (iRange) {
   case 0:
-    vecColor[0] = 1 - dFrac; vecColor[1] = 0; vecColor[2] = 1;
+    vecColor[0] = 1.0f - fFrac; vecColor[1] = 0.0f; vecColor[2] = 1.0f;
     break;
   case 1:
-    vecColor[0] = 0; vecColor[1] = dFrac; vecColor[2] = 1;
+    vecColor[0] = 0.0f; vecColor[1] = fFrac; vecColor[2] = 1.0f;
     break;
   case 2:
-    vecColor[0] = 0; vecColor[1] = 1; vecColor[2] = 1 - dFrac;
+    vecColor[0] = 0.0f; vecColor[1] = 1.0f; vecColor[2] = 1.0f - fFrac;
     break;
   case 3:
-    vecColor[0] = dFrac; vecColor[1] = 1; vecColor[2] = 0;
+    vecColor[0] = fFrac; vecColor[1] = 1.0f; vecColor[2] = 0.0f;
     break;
   case 4:
-    vecColor[0] = 0; vecColor[1] = 1 - dFrac; vecColor[2] = 0;
+    vecColor[0] = 1.0f; vecColor[1] = 1.0f - fFrac; vecColor[2] = 0.0f;
     break;
   case 5:
-    vecColor[0] = 1; vecColor[1] = 0; vecColor[2] = 0;
+    vecColor[0] = 1.0f; vecColor[1] = 0.0f; vecColor[2] = 0.0f;
     break;
   }
 }
@@ -117,10 +122,10 @@ intensityToColor (double dIntensity, float vecColor[3])
 //     fNormalZ   == Z vector for the normal vector
 //*************************************************************************
 
-
-GLvoid CalculateVectorNormal (GLfloat fVert1[], GLfloat fVert2[], 
-                              GLfloat fVert3[], GLfloat *fNormalX,
-                              GLfloat *fNormalY, GLfloat *fNormalZ)
+void 
+CalculateVectorNormal (GLfloat fVert1[], GLfloat fVert2[], 
+                       GLfloat fVert3[], GLfloat *fNormalX,
+                       GLfloat *fNormalY, GLfloat *fNormalZ)
 {
   GLfloat Qx = fVert2[0] - fVert1[0];
   GLfloat Qy = fVert2[1] - fVert1[1];
@@ -135,6 +140,24 @@ GLvoid CalculateVectorNormal (GLfloat fVert1[], GLfloat fVert2[],
   
 } 
 
+void 
+CalculateVectorNormal (GLdouble fVert1[], GLdouble fVert2[], 
+                       GLdouble fVert3[], GLdouble *fNormalX,
+                       GLdouble *fNormalY, GLdouble *fNormalZ)
+{
+  GLdouble Qx = fVert2[0] - fVert1[0];
+  GLdouble Qy = fVert2[1] - fVert1[1];
+  GLdouble Qz = fVert2[2] - fVert1[2];
+  GLdouble Px = fVert3[0] - fVert1[0];
+  GLdouble Py = fVert3[1] - fVert1[1];
+  GLdouble Pz = fVert3[2] - fVert1[2];
+  
+  *fNormalX = Py*Qz - Pz*Qy;
+  *fNormalY = Pz*Qx - Px*Qz;
+  *fNormalZ = Px*Qy - Py*Qx;
+  
+} 
+
 IMPLEMENT_DYNAMIC_CLASS(Graph3dFileView, wxView)
 
 BEGIN_EVENT_TABLE(Graph3dFileView, wxView)
@@ -143,12 +166,14 @@ EVT_MENU(GRAPH3D_VIEW_LIGHTING, Graph3dFileView::OnLighting)
 EVT_MENU(GRAPH3D_VIEW_COLOR, Graph3dFileView::OnColor)
 EVT_MENU(GRAPH3D_VIEW_SMOOTH, Graph3dFileView::OnSmooth)
 EVT_MENU(GRAPH3D_VIEW_SURFACE, Graph3dFileView::OnSurface)
+EVT_MENU(GRAPH3D_VIEW_SCALE_MINMAX, Graph3dFileView::OnScaleSet)
+EVT_MENU(GRAPH3D_VIEW_SCALE_AUTO, Graph3dFileView::OnScaleAuto)
+EVT_MENU(GRAPH3D_VIEW_SCALE_FULL, Graph3dFileView::OnScaleFull)
 END_EVENT_TABLE()
 
 Graph3dFileView::Graph3dFileView ()
 : m_pFileMenu(NULL), m_pViewMenu(NULL)
 {
-  m_bUseVertexArrays = false;
   m_bDoubleBuffer = true;
   m_bSmooth = true;
   m_bLighting = true;
@@ -158,12 +183,14 @@ Graph3dFileView::Graph3dFileView ()
   m_dXRotate = -45;
   m_dYRotate = 0;
   m_dZRotate = -45;
+  m_bColorScaleMinSet = false;
+  m_bColorScaleMaxSet = false;
 }
 
 Graph3dFileView::~Graph3dFileView()
 {
   GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
-  GetDocumentManager()->ActivateView(this, FALSE, TRUE);
+  GetDocumentManager()->ActivateView(this, false, true);
 }
 
 bool 
@@ -177,7 +204,7 @@ Graph3dFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
   m_pFrame->SetTitle("Graph3dFileView");
   m_pCanvas = CreateCanvas (m_pFrame);
   
-  m_pFrame->Show(TRUE);
+  m_pFrame->Show (true);
   m_pCanvas->SetCurrent();
   
   InitGL();
@@ -225,120 +252,114 @@ Graph3dFileView::CreateCanvas (wxFrame* parent)
 }
 
 
-
 void
 Graph3dFileView::DrawSurface()
 {
-#ifdef GL_EXT_vertex_array
-  if (m_bUseVertexArrays) {
-    //    glDrawArraysEXT( GL_TRIANGLE_STRIP, 0, nVertices );
+  if (m_bSmooth) {
+    glShadeModel (GL_SMOOTH);
+  } else {
+    glShadeModel (GL_FLAT);
   }
-  else {
-#endif
-    double edge = 1.;  
-    unsigned int nx = GetDocument()->nx();
-    unsigned int ny = GetDocument()->ny();
-    const ImageFileArrayConst v = GetDocument()->getArray();
-    if (nx == 0 || ny == 0 || ! v)
-      return;
-    
-    InitMaterials(); 
-    
-    glRotatef( m_dXRotate, 1.0, 0.0, 0.0 );
-    glRotatef( m_dZRotate, 0.0, 1.0, 0.0 );
-    glRotatef( m_dYRotate, 0.0, 0.0, 1.0 );
-    glTranslatef (-static_cast<double>(nx) / 2., 0., -static_cast<double>(ny) / 2.);
-    
-    
-    if (m_bSmooth) {
-      glShadeModel (GL_SMOOTH);
-    } else {
-      glShadeModel (GL_FLAT);
+  
+  if (m_bLighting) {
+    glEnable (GL_LIGHTING);
+  } else {
+    glDisable (GL_LIGHTING);
+  }
+  
+  if (m_bSurface)
+    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+  else
+    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+  
+  InitMaterials(); 
+  
+  if (! GetDocument())
+    return;
+  
+  unsigned int nx = GetDocument()->nx();
+  unsigned int ny = GetDocument()->ny();
+  glRotated (m_dZRotate, 0.0, 1.0, 0.0);
+  glTranslated (-static_cast<double>(nx) / 2, 0.0, -static_cast<double>(ny) / 2);
+  glRotated (m_dYRotate, 1.0, 0.0, 0.0);
+  glRotated (m_dXRotate, 0.0, 0.0, 1.0);
+  
+  glCallList (DISPLAYLIST_SURFACE);
+}
+
+void
+Graph3dFileView::CreateDisplayList()
+{
+  if (! GetDocument())
+    return;
+  
+  unsigned int nx = GetDocument()->nx();
+  unsigned int ny = GetDocument()->ny();
+  const ImageFileArrayConst v = GetDocument()->getArray();
+  if (nx == 0 || ny == 0 || ! v)
+    return;
+  
+  glNewList (DISPLAYLIST_SURFACE, GL_COMPILE);
+  
+  double dMin = m_dColorScaleMin;
+  double dIntensityScale = m_dColorScaleMax - m_dColorScaleMin;
+  double actOffset = m_dGraphMin;
+  double actScale = 0.4 * sqrt(nx*nx+ny*ny) / (m_dGraphMax - m_dGraphMin);
+  
+  if (! m_bColor)
+    glColor3f (1.0f, 1.0f, 1.0f);
+  
+  for (unsigned ix = 0; ix < nx - 1; ix++) {
+    glBegin(GL_QUAD_STRIP);
+    double p1[3], p2[3], p3[3];
+    double n1[3]; 
+    p1[0] = ix;  p1[1] = actScale * (v[ix][0] + actOffset); p1[2] = 0;
+    p2[0] = ix+1; p2[1] = actScale * (v[ix+1][0] + actOffset); p2[2] = 0; 
+    p3[0] = ix; p3[1] = actScale * (v[ix][1] + actOffset); p3[2] = 1;
+    CalculateVectorNormal (p1, p2, p3, &n1[0], &n1[1], &n1[2]);
+    double dIntensity1, dIntensity2;
+    if (m_bColor) {
+      dIntensity1 = (v[ix][0] - dMin) / dIntensityScale;
+      dIntensity2 = (v[ix+1][0] - dMin) / dIntensityScale;
     }
-    
-    if (m_bLighting) {
-      glEnable (GL_LIGHTING);
-    } else {
-      glDisable (GL_LIGHTING);
+    float vecColor[3];
+    if (m_bColor) {
+      intensityToColor (dIntensity1, vecColor);
+      glColor3fv (vecColor);
     }
-    
-    double dMin = v[0][0];
-    double dMax = dMin;
-    unsigned int ix;
-    for (ix = 0; ix < nx; ix++)
-      for (unsigned int iy = 0; iy < ny; iy++)
-        if (v[ix][iy] < dMin)
-          dMin = v[ix][iy];
-        else if (v[ix][iy] > dMax)
-          dMax = v[ix][iy];
-        
-        double dIntensityScale = dMax - dMin;
-        double actOffset = dMin;
-        double actScale = 0.3 * sqrt(nx*nx+ny*ny) / (dMax - dMin);
-        
-        //     glNewList(opnListNum++,GL_COMPILE);             
-        if (! m_bColor)
-          glColor3f (1.0, 1.0, 1.0);
-        
-        glDisable (GL_CULL_FACE);
-        for (ix = 0; ix < nx-1; ix++) {                        
-          for (unsigned int iy = 0; iy < ny-1; iy++) {                 
-            
-            float p1[3], p2[3], p3[3], p4[3];
-            float n1[3], n2[3], n3[3], n4[3];
-            if (m_bSurface)
-              glBegin(GL_QUADS);
-            else
-              glBegin(GL_LINE_LOOP);
-            
-            p1[0] = ix;  p1[1] = actScale * (v[ix][iy] + actOffset); p1[2] = iy;
-            p2[0] = ix+1; p2[1] = actScale * (v[ix+1][iy] + actOffset); p2[2] = iy; 
-            p3[0] = ix+1; p3[1] = actScale * (v[ix+1][iy+1] + actOffset); p3[2] = iy+1;
-            p4[0] = ix;  p4[1] = actScale * (v[ix][iy+1] + actOffset); p4[2] = iy+1;
-            
-            //                         n1[0] = -(p2[1] - p1[1])*(p3[2] - p1[2]) + (p2[2] - p1[2])*(p3[1] - p2[1]);
-            //                         n1[1] = -(p2[2] - p1[2])*(p3[0] - p2[0]) + (p2[0] - p1[0])*(p3[2] - p2[2]);
-            //                         n1[2] = -(p2[0] - p1[0])*(p3[1] - p2[1]) + (p2[1] - p1[1])*(p3[0] - p2[0]);
-            CalculateVectorNormal (p1, p2, p4, &n1[0], &n1[1], &n1[2]);
-            //CalculateVectorNormal (p2, p1, p3, &n2[0], &n2[1], &n2[2])
-            //CalculateVectorNormal (p3, p2, p4, &n1[0], &n1[1], &n1[2])
-            double dIntensity1, dIntensity2, dIntensity3, dIntensity4;
-            if (m_bColor) {
-              dIntensity1 =    (v[ix][iy] - dMin) / dIntensityScale;
-              dIntensity2 =    (v[ix+1][iy] - dMin) / dIntensityScale;
-              dIntensity3 =    (v[ix+1][iy+1] - dMin) / dIntensityScale;
-              dIntensity4 =    (v[ix][iy+1] - dMin) / dIntensityScale;
-            }
-            float vecColor[3];
-            if (m_bColor) {
-              intensityToColor (dIntensity1, vecColor);
-              glColor3fv (vecColor);
-            }
-            glVertex3fv (p1); glNormal3fv (n1);                                        
-            if (m_bColor) {
-              intensityToColor (dIntensity2, vecColor);
-              glColor3fv (vecColor);
-            }
-            glVertex3fv (p2); glNormal3fv (n1);                                        
-            if (m_bColor) {
-              intensityToColor (dIntensity3, vecColor);
-              glColor3fv (vecColor);
-            }
-            glVertex3fv (p3); glNormal3fv (n1);                                        
-            if (m_bColor) {
-              intensityToColor (dIntensity4, vecColor);
-              glColor3fv (vecColor);
-            }
-            glVertex3fv (p4); glNormal3fv (n1);                                                                                                                                                
-            glEnd();                           
-          }                    
-          
-        }
-        glEndList();
-        
-#ifdef GL_EXT_vertex_array
+    glVertex3dv (p1); 
+    glNormal3dv (n1);                                  
+    if (m_bColor) {
+      intensityToColor (dIntensity2, vecColor);
+      glColor3fv (vecColor);
+    }
+    glVertex3dv (p2); 
+    glNormal3dv (n1);                                  
+    double lastP[3];
+    lastP[0] = ix; lastP[1] = actScale * (v[ix][0] + actOffset); lastP[2] = 0; 
+    for (unsigned int iy = 1; iy < ny - 1; iy++) {       
+      p1[0] = ix; p1[1] = actScale * (v[ix][iy] + actOffset); p1[2] = iy;
+      p2[0] = ix+1;  p2[1] = actScale * (v[ix+1][iy] + actOffset); p2[2] = iy;
+      CalculateVectorNormal (p1, p2, lastP, &n1[0], &n1[1], &n1[2]);
+      lastP[0] = p1[0]; lastP[1] = p1[1]; lastP[2] = p1[2];
+      if (m_bColor) {
+        dIntensity1 = (v[ix][iy] - dMin) / dIntensityScale;
+        dIntensity2 = (v[ix+1][iy] - dMin) / dIntensityScale;
+      }
+      if (m_bColor) {
+        intensityToColor (dIntensity1, vecColor);
+        glColor3fv (vecColor);
+      }
+      glVertex3dv (p1); glNormal3dv (n1);                                      
+      if (m_bColor) {
+        intensityToColor (dIntensity2, vecColor);
+        glColor3fv (vecColor);
+      }
+      glVertex3dv (p2); glNormal3dv (n1);                                      
+    }                  
+    glEnd(); // QUAD_STRIP
   }
-#endif
+  glEndList();
 }
 
 
@@ -373,7 +394,7 @@ Graph3dFileView::OnColor (wxCommandEvent& event)
 {
   m_bColor = ! m_bColor;
   m_pViewMenu->Check (GRAPH3D_VIEW_COLOR, m_bColor);
-  m_pCanvas->Refresh();
+  OnUpdate (this, NULL);
 }
 
 void
@@ -407,8 +428,7 @@ Graph3dFileView::Draw ()
 {
   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
   glPushMatrix();
-  DrawSurface();
-  
+  DrawSurface();  
   glPopMatrix();
   glFlush();
 }
@@ -423,23 +443,23 @@ Graph3dFileView::InitMaterials()
   int ny = GetDocument()->ny();
   
 #if 1
-  static float ambient[] = {0.1, 0.1, 0.1, 1.0};
-  static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
-  static float position0[] = {-nx/2, -ny/2, -ny/2, 0, 0.0};
-  static float position1[] = {-nx/2, -ny/2, ny/2, 0.0};
-  static float ambient1[] = {0.5, 0.5, 0.5, 1.0};
-  static float diffuse1[] = {1.0, 1.0, 1.0, 1.0};
-  //  static float position0[] = {0.0, 0.0, 20.0, 0.0};
-  //  static float position1[] = {0.0, 0.0, -20.0, 0.0};
-  static float front_mat_shininess[] = {5.0};
-  static float front_mat_specular[] = {0.1, 0.1, 0.1, 1.0};
-  static float front_mat_diffuse[] = {0.3, 0.3, 0.3, 1.0};
+  static float ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
+  static float diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
+  static float position0[] = {-nx/2, -ny/2, -ny/2, 0.0f, 0.0f};
+  static float position1[] = {-nx/2, -ny/2, ny/2, 0.0f};
+  static float ambient1[] = {0.5f, 0.5f, 0.5f, 1.0f};
+  static float diffuse1[] = {1.0f, 1.0f, 1.0f, 1.0f};
+  //  static float position0[] = {0.0f, 0.0f, 20.0f, 0.0f};
+  //  static float position1[] = {0.0f, 0.0f, -20.0f, 0.0f};
+  static float front_mat_shininess[] = {5.0f};
+  static float front_mat_specular[] = {0.1f, 0.1f, 0.1f, 1.0f};
+  static float front_mat_diffuse[] = {0.3f, 0.3f, 0.3f, 1.0f};
   /*
-  static float back_mat_shininess[] = {60.0};
-  static float back_mat_specular[] = {0.2, 0.2, 0.2, 1.0};
-  static float back_mat_diffuse[] = {1.0, 1.0, 1.0, 1.0};
+  static float back_mat_shininess[] = {60.0f};
+  static float back_mat_specular[] = {0.2f, 0.2f, 0.2f, 1.0f};
+  static float back_mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
   */
-  static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
+  static float lmodel_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
   static float lmodel_twoside[] = {GL_FALSE};
   
   glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
@@ -467,34 +487,34 @@ Graph3dFileView::InitMaterials()
   //  glColorMaterial (GL_FRONT_AND_BACK, GL_SPECULAR);
   glEnable(GL_COLOR_MATERIAL);
 #else
-  GLfloat impLPos[]  = {1.0, 1.0, 1.0, 0.0};
+  GLfloat impLPos[]  = {1.0f, 1.0f, 1.0f, 0.0f};
   
-  GLfloat defaultLightAmb   [] = {.2, .2, .2, 1.0};
-  GLfloat defaultLightDiff  [] = {.2, .2, .2, 1.0};
-  GLfloat defaultLightSpec  [] = { .3, .3, .3, 1.0};
+  GLfloat defaultLightAmb   [] = {.2f, .2f, .2f, 1.0f};
+  GLfloat defaultLightDiff  [] = {.2f, .2f, .2f, 1.0f};
+  GLfloat defaultLightSpec  [] = { .3f, .3f, .3f, 1.0f};
   
-  GLfloat defaultGlobalAmb [] = {.3, .3, .3, 1.0};
-  GLfloat defaultGlobalDiff[] = {.3, .3, .3, 1.0};
+  GLfloat defaultGlobalAmb [] = {.3f, .3f, .3f, 1.0f};
+  GLfloat defaultGlobalDiff[] = {.3f, .3f, .3f, 1.0f};
   
-  GLfloat defaultMatShine[] = {  30.0 };
-  GLfloat defaultMatSpec[]  = { .4, .4, .4, 1.0};
-  GLfloat defaultMatAmb[]   = { .3, .3, .3, 1.0};
-  GLfloat defaultMatDiff[]  = { .5, .5, .5, 1.0};
+  GLfloat defaultMatShine[] = {  30.0f };
+  GLfloat defaultMatSpec[]  = { .4f, .4f, .4f, 1.0f};
+  GLfloat defaultMatAmb[]   = { .3f, .3f, .3f, 1.0f};
+  GLfloat defaultMatDiff[]  = { .5f, .5f, .5f, 1.0f};
   
-  GLfloat brassMatAmb[]   = { .33, .22, .03, 1.0};
-  GLfloat brassMatDiff[]  = { .78, .57, .11, 1.0};
-  GLfloat brassMatSpec[]  = { .99, .91, .81, 1.0};
-  GLfloat brassMatShine[] = {  27.8 };
+  GLfloat brassMatAmb[]   = { .33f, .22f, .03f, 1.0f};
+  GLfloat brassMatDiff[]  = { .78f, .57f, .11f, 1.0f};
+  GLfloat brassMatSpec[]  = { .99f, .91f, .81f, 1.0f};
+  GLfloat brassMatShine[] = {  27.8f };
   
-  GLfloat emeraldMatAmb[]   = { .021, .1745 , .021, 1.0};
-  GLfloat emeraldMatDiff[]  = { .075, .6142 , .075, 1.0 };
-  GLfloat emeraldMatSpec[]  = { .633, .7278 , .633, 1.0 };
-  GLfloat emeraldMatShine[] = {  76.8 };
+  GLfloat emeraldMatAmb[]   = { .02f1, .1745f , .021f, 1.0f };
+  GLfloat emeraldMatDiff[]  = { .075f, .6142f , .075f, 1.0f };
+  GLfloat emeraldMatSpec[]  = { .633f, .7278f , .633f, 1.0f };
+  GLfloat emeraldMatShine[] = {  76.8f };
   
-  GLfloat slateMatAmb[]   = { .02, .02 , .02, 1.0 };
-  GLfloat slateMatDiff[]  = { .02, .01 , .01, 1.0 };
-  GLfloat slateMatSpec[]  = { .4,  .4 ,  .4 , 1.0 };
-  GLfloat slateMatShine[] = { .768 };
+  GLfloat slateMatAmb[]   = { .02f, .02f , .02f, 1.0f };
+  GLfloat slateMatDiff[]  = { .02f, .01f , .01f, 1.0f };
+  GLfloat slateMatSpec[]  = { .4f,  .4f ,  .4f , 1.0f };
+  GLfloat slateMatShine[] = { .768f };
   
   //       double opnX = nx, opnY = ny, opnZ = z;
   //       eyeX = 1; eyeY = 1, eyeZ = 1;
@@ -508,7 +528,7 @@ Graph3dFileView::InitMaterials()
   //  glutInitWindowPosition (100, 100);
   //       glutCreateWindow ("- imp3D graphics -" );
   
-  glClearColor(0.0, 0.0, 0.0, 0.0);
+  glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
   
   glShadeModel (GL_SMOOTH);
   glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
@@ -557,46 +577,58 @@ Graph3dFileView::InitMaterials()
 void 
 Graph3dFileView::InitGL ()
 {
-  glClearColor(0.0, 0.0, 0.0, 0.0);
+  glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
   
-  glEnable(GL_DEPTH_TEST);
+  glDisable (GL_CULL_FACE);
+  glEnable (GL_DEPTH_TEST);
   
 }
 
 void 
 Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
 {
-  int nVertices = GetDocument()->m_nVertices;
-  glTripleFloat* pVertices = GetDocument()->m_pVertices;
-  glTripleFloat* pNormals = GetDocument()->m_pNormals;
-  
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
   if (! GetDocument())
     return;
+  
   int nx = GetDocument()->nx();
   int ny = GetDocument()->ny();
-  int maxDim = maxValue<int> (nx, ny);
+  const ImageFileArrayConst v = GetDocument()->getArray();
+  if (v != NULL && nx != 0 && ny != 0) {
+    double min = v[0][0];
+    double max = min;
+    for (unsigned int ix = 0; ix < nx; ix++)
+      for (unsigned int iy = 0; iy < ny; iy++) {
+        double dVal = v[ix][iy];
+        if (min > dVal)
+          min = dVal;
+        else if (max < dVal)
+          max = dVal;
+      }
+      m_dGraphMin = min;
+      m_dGraphMax = max;
+      if (! m_bColorScaleMinSet)
+        m_dColorScaleMin = min;
+      if (! m_bColorScaleMaxSet)
+        m_dColorScaleMax = max;  
+  }
+  
+  double dRadius = maxValue<int> (nx, ny) * SQRT2 / 2;
+  glMatrixMode(GL_PROJECTION);
+  glLoadIdentity();
+  glOrtho (-dRadius, dRadius, -dRadius, dRadius, dRadius*5, -dRadius*5);
   
-  glOrtho (-maxDim * 0.71, maxDim * 0.71, -maxDim * 0.71, maxDim * 0.71, maxDim * 0.71, -maxDim * 0.71);
+  glMatrixMode(GL_MODELVIEW);
+  glLoadIdentity();
+#if 1
   GLfloat eyep[3], lookp[3], up[3];
   eyep[0] = -nx/2; eyep[1] = 0; eyep[2] = -ny/2;
-  lookp[1] = 0; lookp[1] = 0, lookp[2] = 0;
+  lookp[0] = 0; lookp[1] = 0, lookp[2] = 0;
   up[0] = 0; up[1] = 1; up[2] = 0;
-  //gluLookAt (eyep[0], eyep[1], eyep[2], lookp[0], lookp[1], lookp[2], up[0], up[1], up[2]);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-  
-  
-#ifdef GL_EXT_vertex_array
-  if (m_bUseVertexArrays) {
-    //  glVertexPointerEXT( 3, GL_FLOAT, 0, nVertices, pVertices );
-    //  glNormalPointerEXT( GL_FLOAT, 0, nVertices, pNormals );
-    glEnable( GL_VERTEX_ARRAY_EXT );
-    glEnable( GL_NORMAL_ARRAY_EXT );
-  }
+  gluLookAt (eyep[0], eyep[1], eyep[2], lookp[0], lookp[1], lookp[2], up[0], up[1], up[2]);
 #endif
   
+  CreateDisplayList();
+  
   if (m_pCanvas)
     m_pCanvas->Refresh();
 }
@@ -609,7 +641,6 @@ Graph3dFileView::OnClose (bool deleteWindow)
   
   Activate (false);
   if (m_pCanvas) {
-    //    m_pCanvas->Show(false);
     m_pCanvas->setView(NULL);
     m_pCanvas = NULL;
   }
@@ -620,16 +651,81 @@ Graph3dFileView::OnClose (bool deleteWindow)
   SetFrame(NULL);
   
   if (deleteWindow) {
-    //    m_pFrame->Show(false);
     delete m_pFrame;
     m_pFrame = NULL;
-    //    if (GetDocument() && GetDocument()->getBadFileOpen())
-    //      ::wxYield();  // wxWindows bug workaround
   }
   
   return true;
 }
 
+void 
+Graph3dFileView::OnScaleAuto (wxCommandEvent& event)
+{
+#if 0
+  const ImageFile& rIF = GetDocument()->getImageFile();
+  double min, max, mean, mode, median, stddev;
+  rIF.statistics(min, max, mean, mode, median, stddev);
+  DialogAutoScaleParameters dialogAutoScale (getFrameForChild(), mean, mode, median, stddev, m_dAutoScaleFactor);
+  int iRetVal = dialogAutoScale.ShowModal();
+  if (iRetVal == wxID_OK) {
+    m_bMinSpecified = true;
+    m_bMaxSpecified = true;
+    double dMin, dMax;
+    if (dialogAutoScale.getMinMax (&dMin, &dMax)) {
+      m_dMinPixel = dMin;
+      m_dMaxPixel = dMax;
+      m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
+      OnUpdate (this, NULL);
+    }
+  }
+#endif
+}
+
+void 
+Graph3dFileView::OnScaleSet (wxCommandEvent& event)
+{
+  if (! GetDocument())
+    return;
+  
+  unsigned int nx = GetDocument()->nx();
+  unsigned int ny = GetDocument()->ny();
+  const ImageFileArrayConst v = GetDocument()->getArray();
+  double dMin, dMax;
+  if (! m_bColorScaleMinSet && ! m_bColorScaleMaxSet) {
+    dMax = dMin = v[0][0];
+    for (unsigned ix = 0; ix < nx; ix++)
+      for (unsigned int iy = 0; iy < ny; iy++)
+        if (v[ix][iy] < dMin)
+          dMin = v[ix][iy];
+        else if (v[ix][iy] > dMax)
+          dMax = v[ix][iy];
+  }
+  if (m_bColorScaleMinSet)
+    dMin = m_dColorScaleMin;
+  if (m_bColorScaleMaxSet)
+    dMax = m_dColorScaleMax;
+  
+  DialogGetMinMax dialogMinMax (getFrameForChild(), "Set Color Scale Minimum & Maximum", dMin, dMax);
+  int retVal = dialogMinMax.ShowModal();
+  if (retVal == wxID_OK) {
+    m_bColorScaleMinSet = true;
+    m_bColorScaleMaxSet = true;
+    m_dColorScaleMin = dialogMinMax.getMinimum();
+    m_dColorScaleMax = dialogMinMax.getMaximum();
+    OnUpdate (this, NULL);
+  }
+}
+
+void 
+Graph3dFileView::OnScaleFull (wxCommandEvent& event)
+{
+  if (m_bColorScaleMinSet || m_bColorScaleMaxSet) {
+    m_bColorScaleMinSet = false;
+    m_bColorScaleMaxSet = false;
+    OnUpdate (this, NULL);
+  }
+}
+
 #if CTSIM_MDI
 wxDocMDIChildFrame*
 #else
@@ -669,10 +765,15 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view)
   GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
   
   m_pViewMenu = new wxMenu;
-  m_pViewMenu->Append(GRAPH3D_VIEW_SURFACE, "&Surface\tCtrl-U", "", true);
-  m_pViewMenu->Append(GRAPH3D_VIEW_SMOOTH, "&Smooth\tCtrl-M", "", true);
-  m_pViewMenu->Append(GRAPH3D_VIEW_COLOR, "&Color\tCtrl-R", "", true);
-  m_pViewMenu->Append(GRAPH3D_VIEW_LIGHTING, "&Lighting\tCtrl-L", "", true);
+  m_pViewMenu->Append(GRAPH3D_VIEW_SURFACE, "Su&rface\tCtrl-R", "", true);
+  m_pViewMenu->Append(GRAPH3D_VIEW_SMOOTH, "S&mooth\tCtrl-M", "", true);
+  m_pViewMenu->Append(GRAPH3D_VIEW_COLOR, "Co&lor\tCtrl-L", "", true);
+  m_pViewMenu->Append(GRAPH3D_VIEW_LIGHTING, "Li&ghting\tCtrl-G", "", true);
+  m_pViewMenu->AppendSeparator();
+  m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_MINMAX, "Color Scale S&et Min/Max...\tCtrl-E");
+  m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_AUTO, "Color Scale &Auto...\tCtrl-A");
+  m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_FULL, "Color F&ull Scale\tCtrl-U");
+  
   
   wxMenu *help_menu = new wxMenu;
   help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
@@ -689,17 +790,20 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view)
   
   subframe->Centre(wxBOTH);
   
-  wxAcceleratorEntry accelEntries[10];
+  wxAcceleratorEntry accelEntries[12];
   accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('O'), wxID_OPEN);
   accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('H'), MAINMENU_HELP_TOPICS);
   accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('P'), MAINMENU_FILE_CREATE_PHANTOM);
   accelEntries[3].Set (wxACCEL_CTRL, static_cast<int>('F'), MAINMENU_FILE_CREATE_FILTER);
   accelEntries[4].Set (wxACCEL_NORMAL, WXK_F1, MAINMENU_HELP_CONTENTS);
-  accelEntries[5].Set (wxACCEL_CTRL, static_cast<int>('U'), GRAPH3D_VIEW_SURFACE);
-  accelEntries[6].Set (wxACCEL_CTRL, static_cast<int>('R'), GRAPH3D_VIEW_COLOR);
-  accelEntries[7].Set (wxACCEL_CTRL, static_cast<int>('L'), GRAPH3D_VIEW_LIGHTING);
+  accelEntries[5].Set (wxACCEL_CTRL, static_cast<int>('R'), GRAPH3D_VIEW_SURFACE);
+  accelEntries[6].Set (wxACCEL_CTRL, static_cast<int>('L'), GRAPH3D_VIEW_COLOR);
+  accelEntries[7].Set (wxACCEL_CTRL, static_cast<int>('G'), GRAPH3D_VIEW_LIGHTING);
   accelEntries[8].Set (wxACCEL_CTRL, static_cast<int>('M'), GRAPH3D_VIEW_SMOOTH);
-  wxAcceleratorTable accelTable (9, accelEntries);
+  accelEntries[9].Set (wxACCEL_CTRL, static_cast<int>('E'), GRAPH3D_VIEW_SCALE_MINMAX);
+  accelEntries[10].Set (wxACCEL_CTRL, static_cast<int>('A'), GRAPH3D_VIEW_SCALE_AUTO);
+  accelEntries[11].Set (wxACCEL_CTRL, static_cast<int>('U'), GRAPH3D_VIEW_SCALE_FULL);
+  wxAcceleratorTable accelTable (12, accelEntries);
   subframe->SetAcceleratorTable (accelTable);
   
   return subframe;
@@ -722,30 +826,31 @@ Graph3dFileCanvas::Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, c
                                       const wxSize& size, long style, int* gl_attrib):
 wxGLCanvas (parent, -1, pos, size, style, _T("Graph3dCanvas"), gl_attrib), m_pView(view)
 {
-  parent->Show(TRUE);
+  parent->Show (true);
   SetCurrent();
-  /* Make sure server supports the vertex array extension */
+#if 0
+  // Make sure server supports the vertex array extension 
   char* extensions = (char *) glGetString( GL_EXTENSIONS );
   if (!extensions || !strstr( extensions, "GL_EXT_vertex_array" )) {
     m_pView->m_bUseVertexArrays = GL_FALSE;
   }
+#endif
 }
 
 
-Graph3dFileCanvas::~Graph3dFileCanvas(void)
+Graph3dFileCanvas::~Graph3dFileCanvas()
 {
-  m_pView = NULL;
 }
 
 void 
-Graph3dFileCanvas::OnDraw(wxDC& dc)
+Graph3dFileCanvas::OnDraw (wxDC& dc)
 {
   if (m_pView)
     m_pView->OnDraw(& dc);
 }
 
 void 
-Graph3dFileCanvas::OnSize(wxSizeEvent& event)
+Graph3dFileCanvas::OnSize (wxSizeEvent& event)
 {
 #ifndef __WXMOTIF__
   if (!GetContext()) return;
@@ -766,22 +871,31 @@ Graph3dFileCanvas::OnChar(wxKeyEvent& event)
   wxCommandEvent dummyEvent;
   switch (event.KeyCode()) {
   case WXK_LEFT:
-       m_pView->m_dYRotate -= 15.0;
+       m_pView->m_dZRotate += 15.0;
+    Refresh (false);
     break;
   case WXK_RIGHT:
-    m_pView->m_dYRotate += 15.0;
+    m_pView->m_dZRotate -= 15.0;
+    Refresh (false);
     break;
   case WXK_UP:
     m_pView->m_dXRotate += 15.0;
+    Refresh (false);
     break;
   case WXK_DOWN:
     m_pView->m_dXRotate -= 15.0;
+    Refresh (false);
     break;
-  case 'z': case 'Z':
-    m_pView->m_dZRotate += 15.0;
+  case 'y': case 'Y':
+    m_pView->m_dYRotate += 15.0;
+    Refresh (false);
     break;
-  case 'x': case 'X':
-    m_pView->m_dZRotate -= 15.0;
+  case 't': case 'T':
+    m_pView->m_dYRotate -= 15.0;
+    Refresh (false);
+    break;
+  case 'r': case 'R':
+    m_pView->OnSurface (dummyEvent);
     break;
   case 's': case 'S':
     m_pView->OnSmooth (dummyEvent);
@@ -793,13 +907,9 @@ Graph3dFileCanvas::OnChar(wxKeyEvent& event)
     m_pView->OnColor (dummyEvent);
     break;
   default:
-    {
-      event.Skip();
-      return;
-    }
+    event.Skip();
+    return;
   }
-  
-  Refresh (false);
 }
 
 void
@@ -822,9 +932,9 @@ Graph3dFileCanvas::OnMouseEvent(wxMouseEvent& event)
     if(! dragging) {
       dragging = 1;
     } else {
-      m_pView->m_dXRotate += (event.GetX() - last_x)*1.0;
-      m_pView->m_dYRotate += (event.GetY() - last_y)*1.0;
-      Refresh(FALSE);
+      m_pView->m_dXRotate -= (event.GetY() - last_y)*1.0;
+      m_pView->m_dZRotate += (event.GetX() - last_x)*1.0;
+      Refresh (false);
     }
     last_x = event.GetX();
     last_y = event.GetY();
@@ -835,10 +945,8 @@ Graph3dFileCanvas::OnMouseEvent(wxMouseEvent& event)
 void 
 Graph3dFileCanvas::OnEraseBackground(wxEraseEvent& event)
 {
-//  wxGLCanvas::OnEraseBackground(event); // Do nothing: avoid flashing.
+  // Do nothing: avoid flashing.
 }
 
 
-
-
 #endif // wxUSE_GLCANVAS
index ed438154ce9c6f4f296b1cf1dd5e3118af17d1a5..702309e19edbe9c31365e1c2571800d423ee7833 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: graph3dview.h,v 1.4 2001/02/02 23:04:06 kevin Exp $
+**  $Id: graph3dview.h,v 1.5 2001/02/04 21:28:19 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -58,9 +58,20 @@ private:
   bool m_bLighting;
   bool m_bSurface;
   bool m_bColor;
+  enum {
+    DISPLAYLIST_SURFACE = 1,
+  };
+
+  double m_dGraphMin;
+  double m_dGraphMax;
+  double m_dColorScaleMin;
+  double m_dColorScaleMax;
+  bool m_bColorScaleMinSet;
+  bool m_bColorScaleMaxSet;
 
   void Draw();
   void DrawSurface();
+  void CreateDisplayList();
   void InitMaterials();
   void InitGL();
 
@@ -82,6 +93,8 @@ private:
   { return m_pFrame; }
 #endif
 
+  void intensityToColor (double dIntensity, GLfloat* vecColor);
+
 public:
   Graph3dFileView();
   virtual ~Graph3dFileView();
@@ -97,6 +110,9 @@ public:
   void OnSurface (wxCommandEvent& event);
   void OnColor (wxCommandEvent& event);
   void OnSmooth (wxCommandEvent& event);
+  void OnScaleSet (wxCommandEvent& event);
+  void OnScaleAuto (wxCommandEvent& event);
+  void OnScaleFull (wxCommandEvent& event);
 
 #if CTSIM_MDI
   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
index a41efaa2fd91a3b5f6a66a53ee079f09cece6d51..9d2af66574be0219347e110b2edd811c2e2489d5 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.97 2001/02/03 18:42:21 kevin Exp $
+**  $Id: views.cpp,v 1.98 2001/02/04 21:28:19 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -1850,7 +1850,10 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
       Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, 
                           m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView);
       if (theScanner.fail()) {
-        *theApp->getLog() << "Failed making scanner: " << theScanner.failMessage().c_str() << "\n";
+        wxString msg = "Failed making scanner\n";
+        msg += theScanner.failMessage().c_str();
+        *theApp->getLog() << msg << "\n";
+        wxMessageBox (msg, "Error");
         return;
       }
       pProj->initFromScanner (theScanner);
@@ -2169,7 +2172,7 @@ EVT_MENU(PJMENU_CONVERT_FFT_POLAR, ProjectionFileView::OnConvertFFTPolar)
 END_EVENT_TABLE()
 
 ProjectionFileView::ProjectionFileView() 
-: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0)
+: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0)
 {
 #ifdef DEBUG
   m_iDefaultNX = 115;