r4228: Interpolation fixes
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 23 Mar 2003 18:37:42 +0000 (18:37 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 23 Mar 2003 18:37:42 +0000 (18:37 +0000)
15 files changed:
ChangeLog
INSTALL
configure
configure.ac
debian/changelog
include/ct.h
include/ctsupport.h
include/interpolator.h
libctsim/backprojectors.cpp
libctsim/imagefile.cpp
libctsim/projections.cpp
libctsupport/interpolator.cpp
libctsupport/syserror.cpp
src/graph3dview.cpp
src/views.cpp

index 3e71b692f6b4651646e70622f92ebfd5bf39dc55..409b9e86c7d266ebdcf1519458d1f20d76503f41 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mar 22, 2003  Version 4.2.3
+
+       * Added Fourier reconstruction method
+
+       * Support gcc 3.2, wxWindows 2.4, and MacOS X
+
+       * Fix polar interpolation
+       
 Jun 26, 2002  Version 3.5.6
 
        * Fix minor color PNG image importing bug
diff --git a/INSTALL b/INSTALL
index c4f00ba55a1c51ad98985eaee36b28754e0a2fa2..d9ac974c8a2dd1b7594b4ed6c3e55905368cee63 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -18,7 +18,7 @@ fftw (http://www.fftw.org)
 
 wxWindows (http://www.wxwindows.org)
   Used by CTSim (src/*) graphic front-end. Platform independent for
-  GTK, Motif, and Windows32 API's. Requires version 2.3.x.
+  GTK, Motif, and Windows32 API's. Requires version 2.4.0 or later.
 
 ctn (http://www.erl.wustl.edu/DICOM/ctn.html)
   Used by CTSim for DICOM file import and export
index 26a4a05a6088875a0d74fd1ea1f40ad3102c7ded..3f8f09ffc6b6a9708ab91ba2e1ee1b9971a1fc46 100755 (executable)
--- a/configure
+++ b/configure
@@ -1492,7 +1492,7 @@ fi
 
 PACKAGE=ctsim
 
-VERSION=4.2.0
+VERSION=4.2.3
 
 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
   { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
@@ -7734,7 +7734,7 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 else
-  CFLAGS="$CFLAGS -O3 -DNDEBUG -fomit-frame-pointer -funroll-loops"
+  CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
 
 cat >>confdefs.h <<\_ACEOF
 #define NDEBUG 1
index b46a7f50984fe0508032a62a16d6c452b048e720..2db05ae830dd1d3f25fb4760181b922b18070309 100644 (file)
@@ -5,7 +5,7 @@ dnl CDPATH=
 
 AC_INIT
 AC_CONFIG_SRCDIR([src/ctsim.cpp])
-AM_INIT_AUTOMAKE(ctsim,4.2.1)
+AM_INIT_AUTOMAKE(ctsim,4.2.3)
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
@@ -120,7 +120,7 @@ if test "$debug" = "true" ; then
   CFLAGS="$CFLAGS -g -DDEBUG"
   AC_DEFINE(DEBUG,1,[turn on debugging])
 else
-  CFLAGS="$CFLAGS -O3 -DNDEBUG -fomit-frame-pointer -funroll-loops"
+  CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
   AC_DEFINE(NDEBUG,1,[no debugging])
 fi
 
index 31f3e2a9d521cf8d8432fe9b6b1af20c612d4f3f..86271a8fde1cc38951b8ce25dc4c71a2e1906bc8 100644 (file)
@@ -1,3 +1,9 @@
+ctsim (4.2.3-1) unstable; urgency=low
+
+  * New upstream version, fix polar interpolation
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Sun, 23 Mar 2003 01:27:10 -0700
+
 ctsim (4.2.2-1) unstable; urgency=low
 
   * Depend on mesa3g
index 72ca08b6f3b4e6b1adf451fe7b852e2b6a4cc735..97e52f188ab42a4972c93546085eec423af64e0c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: ct.h,v 1.59 2001/03/05 21:59:55 kevin Exp $
+**  $Id: ct.h,v 1.60 2003/03/23 18:37:42 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
@@ -164,7 +164,6 @@ extern "C" {
 #endif
 
 #include "ctsupport.h"
-#include "interpolator.h"
 #include "fnetorderstream.h"
 
 #ifdef HAVE_SGP
index 9df0c68db548251c05b63e4e97bc40ad6987d468..4b42791df6b770ad0d93d3fc95c88dae17563c44 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: ctsupport.h,v 1.25 2003/01/22 22:15:10 kevin Exp $
+**  $Id: ctsupport.h,v 1.26 2003/03/23 18:37:42 kevin Exp $
 **
 **
 **  This program is free software; you can redistribute it and/or modify
@@ -161,6 +161,7 @@ char *str_upper(char *str);
 void sys_error(int severity, const char *msg, ...);
 void sys_verror (std::string& strOutput, int severity, const char *msg, va_list arg);
 void sys_error_level(int severity);
+extern unsigned long int g_lSysErrorMaxCount;
 
 // Math Section
 
index 6b3469ba01a4e4674352473beff7024880dfd5c1..a3dd43a403ed64a82668f86307790864f8bdb2b5 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: interpolator.h,v 1.8 2003/01/30 21:53:16 kevin Exp $
+**  $Id: interpolator.h,v 1.9 2003/03/23 18:37:42 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
@@ -62,30 +62,98 @@ public:
   {}
   
   T interpolate (double dXPos, double dYPos)
-  {
-    int iFloorX = static_cast<int>(floor(dXPos));
-    int iFloorY = static_cast<int>(floor (dYPos));
-    double dXFrac = dXPos - iFloorX;
-    double dYFrac = dYPos - iFloorY;
-
-    T result = 0;
-
-    if (iFloorX < 0 || iFloorY < 0 || iFloorX > m_nx-1 || iFloorY > m_ny-1)
-      result = 0;
-    else if (iFloorX == m_nx - 1 && iFloorY == m_ny - 1)
+{
+  int iFloorX = static_cast<int>(floor(dXPos));
+  int iFloorY = static_cast<int>(floor (dYPos));
+  double dXFrac = dXPos - iFloorX;
+  double dYFrac = dYPos - iFloorY;
+  
+  T result = 0;
+  
+  if (iFloorX < 0 || iFloorY < 0 || iFloorX > m_nx-1 || iFloorY > m_ny-1)
+    result = 0;
+  else if (iFloorX == m_nx - 1 && iFloorY == m_ny - 1)
       result = static_cast<T>(m_ppMatrix[m_nx-1][m_ny-1]);
-    else if (iFloorX == m_nx - 1)
-      result = static_cast<T>(m_ppMatrix[iFloorX][iFloorY] + dYFrac * (m_ppMatrix[iFloorX][iFloorY+1] - m_ppMatrix[iFloorX][iFloorY]));
+  else if (iFloorX == m_nx - 1)
+    result = static_cast<T>(m_ppMatrix[iFloorX][iFloorY] + dYFrac * (m_ppMatrix[iFloorX][iFloorY+1] - m_ppMatrix[iFloorX][iFloorY]));
     else if (iFloorY == m_ny - 1)
       result = static_cast<T>(m_ppMatrix[iFloorX][iFloorY] + dXFrac * (m_ppMatrix[iFloorX+1][iFloorY] - m_ppMatrix[iFloorX][iFloorY]));
+  else
+    result = static_cast<T>
+      ((1 - dXFrac) * (1 - dYFrac) * m_ppMatrix[iFloorX][iFloorY] + 
+       dXFrac * (1 - dYFrac) * m_ppMatrix[iFloorX+1][iFloorY] + 
+       dYFrac * (1 - dXFrac) * m_ppMatrix[iFloorX][iFloorY+1] +
+       dXFrac * dYFrac * m_ppMatrix[iFloorX+1][iFloorY+1]);
+  
+  return result;
+}
+    };
+
+
+template<class T>
+class BilinearPolarInterpolator {
+private:
+  T** const m_ppMatrix;
+  const int m_nAngle;
+  const int m_nPos;
+  int m_nCenterPos;
+  
+public:
+  BilinearPolarInterpolator (T** ppMatrix, unsigned int nAngle,
+                            unsigned int nPos)
+  : m_ppMatrix(ppMatrix), m_nAngle(nAngle), m_nPos(nPos)
+  {
+    if (m_nPos %2)
+      m_nCenterPos = (m_nPos - 1) / 2;
     else
-      result = static_cast<T>((1 - dXFrac) * (1 - dYFrac) * m_ppMatrix[iFloorX][iFloorY] + 
-        dXFrac * (1 - dYFrac) * m_ppMatrix[iFloorX+1][iFloorY] + 
-        dYFrac * (1 - dXFrac) * m_ppMatrix[iFloorX][iFloorY+1] +
-        dXFrac * dYFrac * m_ppMatrix[iFloorX+1][iFloorY+1]);
+      m_nCenterPos = m_nPos / 2;
+  }
 
-    return result;
+  T interpolate (double dAngle, double dPos)
+{
+  int iFloorAngle = static_cast<int>(floor(dAngle));
+  int iFloorPos = static_cast<int>(floor (dPos));
+  double dAngleFrac = dAngle - iFloorAngle;
+  double dPosFrac = dPos - iFloorPos;
+  
+  T result = 0;
+  
+  if (iFloorAngle < -1 || iFloorPos < 0 || iFloorAngle > m_nAngle-1 || iFloorPos > m_nPos-1)
+    result = 0;
+  else if (iFloorAngle == -1 && iFloorPos == m_nPos-1)
+    result = static_cast<T>(m_ppMatrix[0][m_nPos-1] + dAngleFrac * (m_ppMatrix[m_nAngle-1][iFloorPos] - m_ppMatrix[0][iFloorPos]));
+  else if (iFloorAngle == m_nAngle - 1 && iFloorPos == m_nPos-1)
+    result = static_cast<T>(m_ppMatrix[m_nAngle-1][m_nPos-1] + dAngleFrac * (m_ppMatrix[0][iFloorPos] - m_ppMatrix[m_nAngle-1][iFloorPos]));
+  else if (iFloorPos == m_nPos - 1)
+    result = static_cast<T>(m_ppMatrix[iFloorAngle][iFloorPos] + dAngleFrac * (m_ppMatrix[iFloorAngle+1][iFloorPos] - m_ppMatrix[iFloorAngle][iFloorPos]));
+  else {
+    if (iFloorAngle == m_nAngle-1) {
+      int iUpperAngle = 0;
+      int iLowerPos = (m_nPos-1) - iFloorPos;
+      int iUpperPos = (m_nPos-1) - (iFloorPos+1);
+      result = static_cast<T>
+       ((1-dAngleFrac) * (1-dPosFrac) * m_ppMatrix[iFloorAngle][iFloorPos] + 
+        dAngleFrac * (1-dPosFrac) * m_ppMatrix[iUpperAngle][iLowerPos] + 
+        dPosFrac * (1-dAngleFrac) * m_ppMatrix[iFloorAngle][iFloorPos+1] +
+        dAngleFrac * dPosFrac * m_ppMatrix[iUpperAngle][iUpperPos]);
+    } else if (iFloorAngle == -1) {
+      int iLowerAngle = m_nAngle - 1;
+      int iLowerPos = (m_nPos-1) - iFloorPos;
+      int iUpperPos = (m_nPos-1) - (iFloorPos+1);
+      result = static_cast<T>
+       ((1-dAngleFrac) * (1-dPosFrac) * m_ppMatrix[iLowerAngle][iLowerPos] + 
+        dAngleFrac * (1-dPosFrac) * m_ppMatrix[iFloorAngle+1][iFloorPos] + 
+        dPosFrac * (1-dAngleFrac) * m_ppMatrix[iLowerAngle][iUpperPos] +
+        dAngleFrac * dPosFrac * m_ppMatrix[iFloorAngle+1][iFloorPos+1]);
+    } else
+      result = static_cast<T>
+       ((1-dAngleFrac) * (1-dPosFrac) * m_ppMatrix[iFloorAngle][iFloorPos] + 
+        dAngleFrac * (1-dPosFrac) * m_ppMatrix[iFloorAngle+1][iFloorPos] + 
+        dPosFrac * (1-dAngleFrac) * m_ppMatrix[iFloorAngle][iFloorPos+1] +
+        dAngleFrac * dPosFrac * m_ppMatrix[iFloorAngle+1][iFloorPos+1]);
   }
+  return result;
+}
 };
 
 
index 825b1e33195c59ab837694879dff4e4c8f6ade4a..7551ff9a1d1e99a1e65336b4e726af20c9f26a12 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: backprojectors.cpp,v 1.32 2001/03/18 18:08:25 kevin Exp $
+**  $Id: backprojectors.cpp,v 1.33 2003/03/23 18:37:42 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
@@ -25,6 +25,7 @@
 ******************************************************************************/
 
 #include "ct.h"
+#include "interpolator.h"
 
 const int Backprojector::BPROJ_INVALID = -1;
 const int Backprojector::BPROJ_TRIG = 0;
index 4a49465065257ba2f02dd5c4df6c20e2b1cd4ebc..c479adb42467e61b9e96e564833727f5e6f9be18 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: imagefile.cpp,v 1.46 2002/06/27 03:19:23 kevin Exp $
+**  $Id: imagefile.cpp,v 1.47 2003/03/23 18:37:42 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
@@ -29,6 +29,7 @@
 #ifdef HAVE_CTN_DICOM
 #include "ctndicom.h"
 #endif
+#include "interpolator.h"
 
 const double ImageFile::s_dRedGrayscaleFactor = 0.299;
 const double ImageFile::s_dGreenGrayscaleFactor = 0.587;
index db8fd0c3d60a63632acbea37bacdd08387d3b8d5..64730029714c60dac9fb70dcc9630ff81448e60d 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: projections.cpp,v 1.81 2003/03/15 10:27:30 kevin Exp $
+**  $Id: projections.cpp,v 1.82 2003/03/23 18:37:42 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
@@ -26,6 +26,7 @@
 
 #include "ct.h"
 #include <ctime>
+#include "interpolator.h"
 
 const kuint16 Projections::m_signature = ('P'*256 + 'J');
 
@@ -1091,7 +1092,6 @@ Projections::calcArrayPolarCoordinates (unsigned int nx, unsigned int ny, double
                                         int iNumDetWithZeros, double dZeropadRatio, double dDetInc)
 {
   double dLength = viewDiameter();
-//  double dLength = phmLen();
   double xMin = -dLength / 2;
   double xMax = xMin + dLength;
   double yMin = -dLength / 2;
@@ -1120,9 +1120,9 @@ Projections::calcArrayPolarCoordinates (unsigned int nx, unsigned int ny, double
       double r = ::sqrt (x * x + y * y);
       double phi = atan2 (y, x);
 
-      if (phi < 0)
+      if (phi <= -m_rotInc / 2)
         phi += TWOPI;
-      if (phi >= PI) {
+      if (phi >= PI - (m_rotInc / 2)) {
         phi -= PI;
         r = -r;
       }
@@ -1140,30 +1140,29 @@ Projections::interpolatePolar (ImageFileArray& v, ImageFileArray& vImag,
 {
   typedef std::complex<double> complexValue;
 
-  BilinearInterpolator<complexValue>* pBilinear =  NULL;  
+  BilinearPolarInterpolator<complexValue>* pBilinear = NULL;  
+  BicubicPolyInterpolator<complexValue>* pBicubic = NULL;  
   if (iInterpolationID == POLAR_INTERP_BILINEAR)
-    pBilinear = new BilinearInterpolator<complexValue> (ppcDetValue, nView, nDetWithZeros);
-
-  BicubicPolyInterpolator<complexValue>* pBicubic;  
-  if (iInterpolationID == POLAR_INTERP_BICUBIC)
+    pBilinear = new BilinearPolarInterpolator<complexValue> (ppcDetValue, nView, nDetWithZeros);
+  else if (iInterpolationID == POLAR_INTERP_BICUBIC)
     pBicubic = new BicubicPolyInterpolator<complexValue> (ppcDetValue, nView, nDetWithZeros);
-
+  
   for (unsigned int ix = 0; ix < ny; ix++) {
     for (unsigned int iy = 0; iy < ny; iy++) {
-
       if (iInterpolationID == POLAR_INTERP_NEAREST) {
         unsigned int iView = nearest<int> (ppdView[ix][iy]);
         unsigned int iDet = nearest<int> (ppdDet[ix][iy]);
-        if (iView == nView) {
-          iView = 0;
-          iDet = m_nDet - iDet;
-        }
+        if (iView == nView)
+         iView = 0;
         if (iDet >= 0 && iDet < nDetWithZeros && iView >= 0 && iView < nView) {
           v[ix][iy] = ppcDetValue[iView][iDet].real();
           if (vImag)
             vImag[ix][iy] = ppcDetValue[iView][iDet].imag();
-        } else
+        } else {
           v[ix][iy] = 0;
+          if (vImag)
+            vImag[ix][iy] = 0;
+       }
 
       } else if (iInterpolationID == POLAR_INTERP_BILINEAR) {
         std::complex<double> vInterp = pBilinear->interpolate (ppdView[ix][iy], ppdDet[ix][iy]);
index d5167ad3462917e9a03e44d08b0cf44074a41c7e..1e728cccf001cc6126e16cfc3e7090232d556f53 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: interpolator.cpp,v 1.3 2001/03/21 21:45:31 kevin Exp $
+**  $Id: interpolator.cpp,v 1.4 2003/03/23 18:37:42 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
@@ -134,8 +134,6 @@ CubicSplineInterpolator::interpolate (double x)
   return y;
 }
 
-
-
   
 
 
index 4aca18565d242a2256c89c1600488e8c66e15a30..4795349edaf25f021bfb3cb0302a294c10f23037 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: syserror.cpp,v 1.24 2003/03/15 14:52:36 kevin Exp $
+**  $Id: syserror.cpp,v 1.25 2003/03/23 18:37:42 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
@@ -57,9 +57,11 @@ void sys_error (int severity, const char *msg, ...)
     if (theApp) {
       wxCommandEvent eventLog (wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT );
       wxString msg (strOutput.c_str());
-      msg += "\n";
-      eventLog.SetString( msg );
-      wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event, thread safe
+      if (msg.length() > 0) {
+       msg += "\n";
+       eventLog.SetString( msg );
+       wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event, thread safe
+      }
     } else {
       wxMutexGuiEnter();
       wxLog::OnLog (wxLOG_Message, strOutput.c_str(), time(NULL));
@@ -67,14 +69,16 @@ void sys_error (int severity, const char *msg, ...)
     }
   }
   else
-#endif
     std::cout << strOutput << "\n";
+#else
+    std::cout << strOutput << "\n";
+#endif
 
   va_end(arg);
 }
 
-static int s_nErrorCount = 0;
-const static int MAX_ERROR_COUNT = 20;
+static unsigned long s_nErrorCount = 0;
+unsigned long int g_lSysErrorMaxCount = 2000;
 
 
 void sys_verror (std::string& strOutput, int severity, const char *msg, va_list arg)
@@ -88,9 +92,9 @@ void sys_verror (std::string& strOutput, int severity, const char *msg, va_list
     s_nErrorCount++;
 
   if (severity != ERR_FATAL) {
-    if (s_nErrorCount > MAX_ERROR_COUNT)
+    if (s_nErrorCount > g_lSysErrorMaxCount)
       return;
-    else if (s_nErrorCount == MAX_ERROR_COUNT) {
+    else if (s_nErrorCount == g_lSysErrorMaxCount) {
       os << "*****************************************************************\n";
       os << "***   M A X I M U M   E R R O R   C O U N T   R E A C H E D   ***\n";
       os << "***                                                           ***\n";
index 3a4221a2233abd0b16673865caefe7b40ff75365..002502959ff1387e7c299697f595db62955728f6 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: graph3dview.cpp,v 1.34 2003/01/30 22:02:30 kevin Exp $
+**  $Id: graph3dview.cpp,v 1.35 2003/03/23 18:37:42 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
@@ -145,7 +145,7 @@ Graph3dFileView::Graph3dFileView ()
   : m_pFileMenu(NULL), m_pViewMenu(NULL), m_pStatusBar(NULL), m_pCanvas(NULL), 
     m_dXRotate(-180), m_dYRotate(-210), m_dZRotate(195), 
     m_bDoubleBuffer(true), m_bSmooth(true), m_bWireframe(false), 
-    m_bLighting(true), m_bColor(true), m_bUseVertexArrays(false),
+    m_bLighting(false), m_bColor(true), m_bUseVertexArrays(false),
     m_bColorScaleMinSet(false), m_bColorScaleMaxSet(false),
     m_pFrame(NULL)
 {}
@@ -231,17 +231,23 @@ Graph3dFileView::DrawSurface()
     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
     glCallList (DISPLAYLIST_COLOR);
 
-    glColor3f (0.0f, 0.0f, 0.0f);
+    glEnable (GL_DEPTH_TEST);
+    glColor3f (1.0f, 1.0f, 1.0f);
     glPolygonOffset (0.0f, 0.0f);
     glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
     glCallList (DISPLAYLIST_NO_COLOR);
+
   } else {
     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
     if (! m_bColor) {
       glColor3f (1.0f, 1.0f, 1.0f);
       glCallList (DISPLAYLIST_NO_COLOR);
-    } else
+    } else {
+      glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
+      glEnable (GL_COLOR_MATERIAL);
+      glShadeModel (GL_FLAT);
       glCallList (DISPLAYLIST_COLOR);
+    }
   }
   
 }
@@ -342,7 +348,7 @@ Graph3dFileView::CreateDisplayList()
     for (unsigned int iy = 1; iy < ny - 1; iy++, dYPos++) {       
       p1[0] = dXPos; p1[1] = actScale * (v[ix][iy] + actOffset); p1[2] = dYPos;
       p2[0] = dXPos+1;  p2[1] = actScale * (v[ix+1][iy] + actOffset); p2[2] = dYPos;
-      CalculateVectorNormal (p1, p2, lastP, &n1[0], &n1[1], &n1[2]);
+       CalculateVectorNormal (p1, p2, lastP, &n1[0], &n1[1], &n1[2]);
       lastP[0] = p1[0]; lastP[1] = p1[1]; lastP[2] = p1[2];
       glVertex3dv (p1); glNormal3dv (n1);                                      
       glVertex3dv (p2); glNormal3dv (n1);                                      
@@ -438,31 +444,29 @@ Graph3dFileView::InitMaterials()
   int ny = GetDocument()->ny();
   
 #if 1
-  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 position0[] = {nx/2, ny*2, -ny*2, 0.0f,};
+  static float ambient0[] = {.1f, .1f, .1f, 1.0f};
+  static float diffuse0[] = {1.0f, 1.0f, 1.0f, 1.0f};
+  static float position1[] = {-nx/2, -ny*2, -ny*2, 0.0f,};
+  static float ambient1[] = {.1f, .1f, .1f, .1f};
   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_shininess[] = {60.0f};
+  static float front_mat_specular[] = {0.2f, 0.2f, 0.2f, 1.0f};
   static float front_mat_diffuse[] = {0.3f, 0.3f, 0.3f, 1.0f};
-  /*
-  static float back_mat_shininess[] = {60.0f};
-  static float back_mat_specular[] = {0.2f, 0.2f, 0.2f, 1.0f};
+  static float back_mat_shininess[] = {10.0f};
+  static float back_mat_specular[] = {0.1f, 0.1f, 0.1f, 1.0f};
   static float back_mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
-  */
   static float lmodel_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
-  static float lmodel_twoside[] = {GL_FALSE};
+  static float lmodel_twoside[] = {GL_TRUE};
   
-  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+  //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
   glHint(GL_LINE_SMOOTH, GL_DONT_CARE);
   glEnable(GL_NORMALIZE);
   
-  glLightfv (GL_LIGHT0, GL_AMBIENT, ambient);
-  glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
+  glLightfv (GL_LIGHT0, GL_AMBIENT, ambient0);
+  glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse0);
   glLightfv (GL_LIGHT0, GL_POSITION, position0);
   glEnable (GL_LIGHT0);
   
@@ -477,9 +481,12 @@ Graph3dFileView::InitMaterials()
   glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, front_mat_shininess);
   glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, front_mat_specular);
   glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, front_mat_diffuse);
+  glMaterialfv (GL_BACK, GL_SHININESS, back_mat_shininess);
+  glMaterialfv (GL_BACK, GL_SPECULAR, back_mat_specular);
+  glMaterialfv (GL_BACK, GL_DIFFUSE, back_mat_diffuse);
   
   glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
-  //  glColorMaterial (GL_FRONT_AND_BACK, GL_SPECULAR);
+  glColorMaterial (GL_FRONT_AND_BACK, GL_SPECULAR);
   glEnable(GL_COLOR_MATERIAL);
 #else
   GLfloat impLPos[]  = {1.0f, 1.0f, 1.0f, 0.0f};
@@ -775,10 +782,10 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PRINT, "&Print...");
   m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
   m_pFileMenu->Append(wxID_PREVIEW, "Print Preview");
-#ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
+  m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
+
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
   GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
   
index cb7663780813ec236fda07c4c46d4a647c7e58c4..2273a87fc089e2007a3bd90ad282f2ce8137e5f9 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.171 2003/03/15 10:27:30 kevin Exp $
+**  $Id: views.cpp,v 1.172 2003/03/23 18:37:42 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
@@ -2597,7 +2597,6 @@ ProjectionFileView::OnConvertPolar (wxCommandEvent& event)
     wxString strInterpolation (dialogPolar.getInterpolationName());
     m_iDefaultPolarNX = dialogPolar.getXSize();
     m_iDefaultPolarNY = dialogPolar.getYSize();
-    ImageFileDocument* pPolarDoc = theApp->newImageDoc();
     ImageFile* pIF = new ImageFile (m_iDefaultPolarNX, m_iDefaultPolarNY);
     m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str());
     
@@ -2607,7 +2606,7 @@ ProjectionFileView::OnConvertPolar (wxCommandEvent& event)
       return;
     }
     
-    pPolarDoc = theApp->newImageDoc ();
+    ImageFileDocument* pPolarDoc = theApp->newImageDoc();
     if (! pPolarDoc) {
       sys_error (ERR_SEVERE, "Unable to create image file");
       return;