r273: *** empty log message ***
[ctsim.git] / src / dlgreconstruct.cpp
index e9831843568d87a90af89727ac465c0ae928efc2..7ec1d326d03135e7d0a372bc1e3b680d6a3f3804 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: dlgreconstruct.cpp,v 1.5 2000/09/07 14:29:05 kevin Exp $
+**  $Id: dlgreconstruct.cpp,v 1.8 2000/12/17 22:30:34 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
@@ -36,7 +36,6 @@
     #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
     #include "wx/utils.h"
     #include "wx/frame.h"
     #include "wx/button.h"
@@ -48,7 +47,6 @@
     #include "wx/dcclient.h"
     #include "wx/timer.h"
     #include "wx/image.h"
-#endif
 
 #include "dlgreconstruct.h"
 #include <algorithm>
 
 static const int LAYOUT_X_MARGIN = 4;
 static const int LAYOUT_Y_MARGIN = 4;
+\r
+\r
+const int ReconstructDialog::ID_BTN_PAUSE = 19998;\r
+const int ReconstructDialog::ID_BTN_STEP = 19999;\r
+const int ReconstructDialog::MAX_IMAGE_X = 400;\r
+const int ReconstructDialog::MAX_IMAGE_Y = 400;\r
+\r
 
 BEGIN_EVENT_TABLE(ReconstructDialog, wxDialog)
    EVT_BUTTON(wxID_CANCEL, ReconstructDialog::OnCancel)
@@ -125,23 +130,27 @@ ReconstructDialog::ReconstructDialog (Reconstructor& rReconstruct, const Project
     m_iClientY = sizeDlg.y;
     SetClientSize (sizeDlg);
 
+    Centre(wxCENTER_FRAME | wxBOTH);\r
+\r
+    if ( m_parentTop )\r
+      m_parentTop->Enable(FALSE);\r
+\r
+    Show(TRUE);\r
+    Enable(TRUE); // enable this window\r
+\r
     m_bitmap.Create (m_iClientX, m_iClientY); // save a copy of screen
+    int x, y;\r
+    this->GetClientSize(&x, &y);\r
+#if OLD\r
     m_pDC = new wxMemoryDC;
     m_pDC->SelectObject (m_bitmap);       // in memoryDC
-    m_pDC->SetFont (*wxSWISS_FONT);
-    int x, y;
-    this->GetClientSize(&x, &y);
-    m_pSGPDriver = new SGPDriver (dynamic_cast<wxDC*>(m_pDC), x, y);
+    m_pSGPDriver = new SGPDriver (dynamic_cast<wxDC*>(m_pDC), x, y);\r
+#else\r
+    m_pDC = dynamic_cast<wxDC*> (new wxClientDC (this));\r
+    m_pSGPDriver = new SGPDriver (m_pDC, x, y);\r
+#endif\r
     m_pSGP = new SGP (*m_pSGPDriver);
 
-    Centre(wxCENTER_FRAME | wxBOTH);
-
-    if ( m_parentTop )
-      m_parentTop->Enable(FALSE);
-
-    Show(TRUE);
-    Enable(TRUE); // enable this window
-
     wxYield();     // Update the display
 
     m_pSGPDriver->idWX()->SetFont(*wxSWISS_FONT);
@@ -151,7 +160,7 @@ ReconstructDialog::ReconstructDialog (Reconstructor& rReconstruct, const Project
 }
 
 void
-ReconstructDialog::showView (int iViewNumber)
+ReconstructDialog::showView (int iViewNumber, bool bBackprojectView)
 {
   if ( iViewNumber < m_rProjections.nView() ) {
     m_iLastView = iViewNumber;
@@ -169,7 +178,7 @@ ReconstructDialog::showView (int iViewNumber)
     m_pSGP->setTextSize (dCharHeight);
 
     m_pSGP->setViewport (0.0, 0.1, 0.66, 1.);
-    m_rReconstructor.reconstructView (iViewNumber, 1, m_pSGP);
+    m_rReconstructor.reconstructView (iViewNumber, 1, m_pSGP, bBackprojectView);
 
     ImageFileArrayConst v = m_rImageFile.getArray();
     int xBase = m_nxGraph;
@@ -189,13 +198,13 @@ ReconstructDialog::showView (int iViewNumber)
     }
     unsigned char* imageData = new unsigned char [m_nxImage * m_nyImage * 3];
     double dScale = 255 / (maxValue - minValue);
-    for (int ix = 0; ix < m_nxImage; ix++) {
+    for (int ix2 = 0; ix2 < m_nxImage; ix2++) {
        for (int iy = 0; iy < m_nyImage; iy++) {
-           double dPixel = v[ix][iy];
+           double dPixel = v[ix2][iy];
            dPixel = (dPixel - minValue) * dScale;
            int intensity = nearest<int>(dPixel);
            intensity = clamp (intensity, 0, 255);
-           int baseAddr = ((m_nyImage - 1 - iy) * m_nxImage + ix) * 3;
+           int baseAddr = ((m_nyImage - 1 - iy) * m_nxImage + ix2) * 3;
            imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
        }
     }
@@ -216,7 +225,7 @@ ReconstructDialog::reconstructView (int iViewNumber)
 
   if (iViewNumber < m_rProjections.nView()) {
     ::wxYield();        // update the display
-    showView (iViewNumber);
+    showView (iViewNumber, true);
     ::wxYield();        // update the display
     if (m_iTrace >= Trace::TRACE_PLOT) {
       ::wxUsleep(250);
@@ -262,7 +271,15 @@ ReconstructDialog::OnPause (wxCommandEvent& event)
     // shown as a modal dialog - so just let the default handler do the job
     event.Skip();
   } else {
-      if (m_state == Continue) {
+      if (m_state == Continue) {\r
+#ifndef OLD\r
+         m_memoryDC.SelectObject (m_bitmap);       // in memoryDC\r
+         m_pSGP->setDC (&m_memoryDC);\r
+         m_memoryDC.SetFont (*wxSWISS_FONT);\r
+         showView (m_iLastView, false);\r
+         m_pSGP->setDC (m_pDC);\r
+         m_memoryDC.SelectObject(wxNullBitmap);\r
+#endif
        m_state = Paused;
        m_btnPause->SetLabel (wxString("Resume"));
       } else if (m_state == Paused) {
@@ -278,7 +295,15 @@ ReconstructDialog::OnStep (wxCommandEvent& event)
   if ( m_state == Finished ) {
     event.Skip();
   } else {
-    if (m_state == Continue) {
+    if (m_state == Continue) {\r
+#ifndef OLD\r
+         m_memoryDC.SelectObject (m_bitmap);       // in memoryDC\r
+         m_pSGP->setDC (&m_memoryDC);\r
+         m_memoryDC.SetFont (*wxSWISS_FONT);\r
+      m_rReconstructor.reconstructView (m_iLastView, 1, m_pSGP, false);\r
+         m_pSGP->setDC (m_pDC);\r
+         m_memoryDC.SelectObject(wxNullBitmap);\r
+#endif
       m_state = Paused;
       m_btnPause->SetLabel (wxString("Resume"));
     } else if (m_state == Paused) {
@@ -300,8 +325,9 @@ void ReconstructDialog::OnClose(wxCloseEvent& event)
 void
 ReconstructDialog::OnPaint (wxPaintEvent& event)
 {
-  wxPaintDC paintDC (this);
-  paintDC.DrawBitmap(m_bitmap, 0, 0, false);
+  wxPaintDC paintDC (this);\r
+  if (m_state == Paused)
+    paintDC.DrawBitmap(m_bitmap, 0, 0, false);
 }