r3884: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 30 Jan 2003 21:53:16 +0000 (21:53 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 30 Jan 2003 21:53:16 +0000 (21:53 +0000)
debian/changelog
include/interpolator.h
msvc/ctsim/ctsim.vcproj
src/docs.cpp
src/graph3dview.cpp
src/graph3dview.h
src/views.cpp

index fa53edaf9c2813321ba9cc0a730511710b10d133..353a2bd564cf89e53c2e1a69ad8034e6eee4c03d 100644 (file)
@@ -2,7 +2,8 @@ ctsim (4.0.2-1) unstable; urgency=low
 
   * Remove debugging statement
   * Add support for --with-cpu configuration option
-
+  * Fix OpenGL frames from endlessly repainting
+       
  -- Kevin M. Rosenberg <kmr@debian.org>  Wed, 29 Jan 2003 19:25:11 -0700
 
 ctsim (4.0.1-1) unstable; urgency=low
index 267c937d609dbd2bb1932e7e700c4cfc73160f93..6b3469ba01a4e4674352473beff7024880dfd5c1 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: interpolator.h,v 1.7 2002/06/27 03:19:23 kevin Exp $
+**  $Id: interpolator.h,v 1.8 2003/01/30 21:53:16 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
@@ -73,16 +73,16 @@ public:
     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 = m_ppMatrix[m_nx-1][m_ny-1];
+      result = static_cast<T>(m_ppMatrix[m_nx-1][m_ny-1]);
     else if (iFloorX == m_nx - 1)
-      result = m_ppMatrix[iFloorX][iFloorY] + dYFrac * (m_ppMatrix[iFloorX][iFloorY+1] - m_ppMatrix[iFloorX][iFloorY]);
+      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 = m_ppMatrix[iFloorX][iFloorY] + dXFrac * (m_ppMatrix[iFloorX+1][iFloorY] - m_ppMatrix[iFloorX][iFloorY]);
+      result = static_cast<T>(m_ppMatrix[iFloorX][iFloorY] + dXFrac * (m_ppMatrix[iFloorX+1][iFloorY] - m_ppMatrix[iFloorX][iFloorY]));
     else
-      result = (1 - dXFrac) * (1 - dYFrac) * m_ppMatrix[iFloorX][iFloorY] + 
+      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];
+        dXFrac * dYFrac * m_ppMatrix[iFloorX+1][iFloorY+1]);
 
     return result;
   }
index 8e35f63e9497e4c54111abff4b853defc1ddeaa0..f813b1bc25876edc0a88791960e554a9c4862efb 100755 (executable)
@@ -44,7 +44,6 @@
                                Name="VCCustomBuildTool"/>\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalOptions="/MACHINE:I386"\r
                                AdditionalDependencies="ctn_lib.lib winmm.lib wxmsw.lib png.lib tiff.lib jpeg.lib zlib.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib fftw2st.lib rfftw2st.lib opengl32.lib wsock32.lib htmlhelp.lib"\r
                                OutputFile=".\Release/ctsim.exe"\r
                                LinkIncremental="1"\r
                        <File\r
                                RelativePath="..\..\src\dlgreconstruct.h">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\src\graph3dview.h">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\src\threadraster.h">\r
                        </File>\r
index 672124dfd7a5b2237ce8212944c2fc800ef75773..685f23c5b7aa18260de67a1ac2497d86f77cbaba 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: docs.cpp,v 1.45 2003/01/23 23:35:58 kevin Exp $
+**  $Id: docs.cpp,v 1.46 2003/01/30 21:53:16 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
@@ -500,6 +500,7 @@ Graph3dFileDocument::OnOpenDocument(const wxString& filename)
 {
   SetFilename (filename, true);
   Modify (false);
+  getView()->setInitialClientSize();
   UpdateAllViews();
   m_bBadFileOpen = false;
   return true;
index 01e17bb843c966c5e02ed14932ff575d2e4e7d6c..f704e7992b60ad11a0dc04db59279144b70f1aed 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: graph3dview.cpp,v 1.32 2003/01/23 23:35:58 kevin Exp $
+**  $Id: graph3dview.cpp,v 1.33 2003/01/30 21:53:16 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
@@ -161,34 +161,33 @@ bool
 Graph3dFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
 {
   m_pFrame = CreateChildFrame(doc, this);
+  SetFrame (m_pFrame);
   m_pCanvas = CreateCanvas (m_pFrame);
 
   m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
-  SetFrame (m_pFrame);
   m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
   m_pFrame->SetTitle("Graph3dFileView");
 
-  m_pCanvas->SetCurrent();
-  
-  InitGL();
-  
-  m_pFrame->SetFocus();
-  m_pFrame->Show(true);
-  Activate(true);
-  
+  m_pCanvas->SetCurrent();  
+  InitGL();  
+  m_pCanvas->SwapBuffers();
+
   m_pViewMenu->Check (GRAPH3D_VIEW_COLOR, m_bColor);
   m_pViewMenu->Check (GRAPH3D_VIEW_LIGHTING, m_bLighting);
   m_pViewMenu->Check (GRAPH3D_VIEW_SMOOTH, m_bSmooth);
   m_pViewMenu->Check (GRAPH3D_VIEW_WIREFRAME, m_bWireframe);
+
+  m_pFrame->SetFocus();
+  m_pFrame->Show(true);
+  Activate(true);
+  
   return true;
 } 
 
 Graph3dFileCanvas* 
 Graph3dFileView::CreateCanvas (wxFrame* parent)
 {
-  Graph3dFileCanvas* pCanvas;
-  
-  pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
+  Graph3dFileCanvas* pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
   
   pCanvas->SetBackgroundColour(*wxWHITE);
   pCanvas->Clear();
@@ -403,6 +402,9 @@ Graph3dFileView::OnDraw (wxDC* dc)
 {
   if (m_pCanvas) {
     m_pCanvas->SetCurrent();
+//#ifdef DEBUG
+       *theApp->getLog() << "Drawing 3d surface\n";
+//#endif
     Draw();
     m_pCanvas->SwapBuffers();
   }
@@ -605,6 +607,10 @@ Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
         m_dColorScaleMax = max;  
   }
   double dRadius = maxValue<int> (nx, ny) * SQRT2 / 2;
+
+  if (m_pCanvas)
+    m_pCanvas->SetCurrent();
+
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho (-dRadius, dRadius, -dRadius, dRadius, dRadius*5, -dRadius*5);
@@ -620,9 +626,11 @@ Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
 #endif
   
   CreateDisplayList();
-  
-  if (m_pCanvas)
+
+  if (m_pCanvas) {
+       m_pCanvas->SwapBuffers();
     m_pCanvas->Refresh();
+  }
 }
 
 bool 
@@ -645,11 +653,25 @@ Graph3dFileView::OnClose (bool deleteWindow)
   if (deleteWindow) {
     delete m_pFrame;
     m_pFrame = NULL;
+    if (GetDocument() && GetDocument()->getBadFileOpen())
+      ::wxYield();  // wxWindows bug workaround
   }
   
   return true;
 }
 
+void 
+Graph3dFileView::setInitialClientSize ()
+{
+  if (m_pFrame && m_pCanvas) {
+    wxSize bestSize = m_pCanvas->GetBestSize();
+
+    m_pFrame->SetClientSize (bestSize);
+    m_pFrame->Show (true);
+    m_pFrame->SetFocus();
+  }
+}  
+
 void 
 Graph3dFileView::OnScaleAuto (wxCommandEvent& event)
 {
@@ -803,7 +825,7 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view)
 
 
 BEGIN_EVENT_TABLE(Graph3dFileCanvas, wxGLCanvas)
-EVT_PAINT(Graph3dFileCanvas::OnDraw)
+EVT_PAINT(Graph3dFileCanvas::OnPaint)
 EVT_SIZE(Graph3dFileCanvas::OnSize)
 EVT_CHAR(Graph3dFileCanvas::OnChar)
 EVT_MOUSE_EVENTS(Graph3dFileCanvas::OnMouseEvent)
@@ -812,14 +834,11 @@ END_EVENT_TABLE()
 
 
 
-
 Graph3dFileCanvas::Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, const wxPoint& pos, 
-                                      const wxSize& size, long style):
-wxGLCanvas (parent, -1, pos, size, style, _T("Graph3dCanvas")
-                       ), m_pView(view)
+                                      const wxSize& size, long style)
+  : wxGLCanvas (parent, -1, pos, size, style), m_pView(view)
 {
-  parent->Show (true);
-  SetCurrent();
+//  parent->Show (true);
 #if 0
   // Make sure server supports the vertex array extension 
   char* extensions = (char *) glGetString( GL_EXTENSIONS );
@@ -835,8 +854,9 @@ Graph3dFileCanvas::~Graph3dFileCanvas()
 }
 
 void 
-Graph3dFileCanvas::OnDraw (wxDC& dc)
+Graph3dFileCanvas::OnPaint (wxPaintEvent& event)
 {
+  wxPaintDC dc(this);
   if (m_pView)
     m_pView->OnDraw(& dc);
 }
@@ -852,10 +872,9 @@ void
 Graph3dFileCanvas::OnSize (wxSizeEvent& event)
 {
 #ifndef __WXMOTIF__
-  if (!GetContext()) return;
+  // if (!GetContext()) return;
 #endif
   
-  SetCurrent();
   int width, height;
   GetClientSize (&width, &height);
   Reshape (width, height);
@@ -914,7 +933,9 @@ Graph3dFileCanvas::OnChar(wxKeyEvent& event)
 void
 Graph3dFileCanvas::Reshape (int width, int height)
 {
+  SetCurrent();
   glViewport (0, 0, (GLint)width, (GLint)height);
+  SwapBuffers();
 }
 
 
index ec53d03a469e81f5f7c8d987fff736362efc15d3..d2dd6a4565f1b300d72c5d1d209f1ea40afaa21c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: graph3dview.h,v 1.11 2002/06/03 16:57:22 kevin Exp $
+**  $Id: graph3dview.h,v 1.12 2003/01/30 21:53:16 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
@@ -115,6 +115,8 @@ public:
   void OnScaleAuto (wxCommandEvent& event);
   void OnScaleFull (wxCommandEvent& event);
   
+  void setInitialClientSize();
+
 #if CTSIM_MDI
   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
 #else
@@ -139,7 +141,7 @@ public:
       const wxSize& size = wxDefaultSize, long style = 0);
    virtual ~Graph3dFileCanvas();
 
-   virtual void OnDraw(wxDC& dc);
+   void OnPaint(wxPaintEvent& event);
    virtual wxSize GetBestSize() const;
    void OnSize(wxSizeEvent& event);
    void OnEraseBackground(wxEraseEvent& event);
index 22c5e1234f1742a0c3eb9292f56e983aaae6b803..e3922dafce711ee8e7c1c44a01ed10e76aa8bb50 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.169 2003/01/30 02:25:22 kevin Exp $
+**  $Id: views.cpp,v 1.170 2003/01/30 21:53:16 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
@@ -2289,7 +2289,6 @@ PhantomFileView::OnRasterize (wxCommandEvent& event)
     *theApp->getLog() << os.str().c_str() << "\n";
     pImageFile->labelAdd (os.str().c_str(), timer.timerEnd());
 
-    OnUpdate(this, NULL);
     pRasterDoc->UpdateAllViews(this);
     pRasterDoc->getView()->setInitialClientSize();
     pRasterDoc->Activate();