X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fdlgreconstruct.cpp;h=7ec1d326d03135e7d0a372bc1e3b680d6a3f3804;hb=77903f8d4c716e076aa0639b71c2e954fb69a2e3;hp=5a6d46ab628a3bc49cd9bec4b7788fff216594c4;hpb=3147cd44cff6132e51eac1a179c1fc3d405faacc;p=ctsim.git diff --git a/src/dlgreconstruct.cpp b/src/dlgreconstruct.cpp index 5a6d46a..7ec1d32 100644 --- a/src/dlgreconstruct.cpp +++ b/src/dlgreconstruct.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: dlgreconstruct.cpp,v 1.3 2000/09/04 09:06:46 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 @@ -57,6 +55,13 @@ static const int LAYOUT_X_MARGIN = 4; static const int LAYOUT_Y_MARGIN = 4; + + +const int ReconstructDialog::ID_BTN_PAUSE = 19998; +const int ReconstructDialog::ID_BTN_STEP = 19999; +const int ReconstructDialog::MAX_IMAGE_X = 400; +const int ReconstructDialog::MAX_IMAGE_Y = 400; + BEGIN_EVENT_TABLE(ReconstructDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, ReconstructDialog::OnCancel) @@ -70,7 +75,7 @@ IMPLEMENT_CLASS(ReconstructDialog, wxDialog) ReconstructDialog::ReconstructDialog (Reconstructor& rReconstruct, const Projections& rProj, ImageFile& rIF, const int iTrace, wxWindow *parent) - : wxDialog(parent, -1, "Reconstruction"), m_rReconstructor(rReconstruct), m_rProjections(rProj), m_rImageFile(rIF), m_pSGPDriver(NULL), m_pSGP(NULL), m_iTrace(iTrace), m_pDC(NULL), m_btnAbort(0), m_btnPause(0), m_btnStep(0) + : wxDialog(parent, -1, "Reconstruction", wxDefaultPosition), m_rReconstructor(rReconstruct), m_rProjections(rProj), m_rImageFile(rIF), m_pSGPDriver(NULL), m_pSGP(NULL), m_iTrace(iTrace), m_pDC(NULL), m_btnAbort(0), m_btnPause(0), m_btnStep(0) { m_state = Continue; m_iLastView = -1; @@ -125,23 +130,27 @@ ReconstructDialog::ReconstructDialog (Reconstructor& rReconstruct, const Project m_iClientY = sizeDlg.y; SetClientSize (sizeDlg); + Centre(wxCENTER_FRAME | wxBOTH); + + if ( m_parentTop ) + m_parentTop->Enable(FALSE); + + Show(TRUE); + Enable(TRUE); // enable this window + m_bitmap.Create (m_iClientX, m_iClientY); // save a copy of screen + int x, y; + this->GetClientSize(&x, &y); +#if OLD 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(m_pDC), x, y); + m_pSGPDriver = new SGPDriver (dynamic_cast(m_pDC), x, y); +#else + m_pDC = dynamic_cast (new wxClientDC (this)); + m_pSGPDriver = new SGPDriver (m_pDC, x, y); +#endif 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(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; } } @@ -211,10 +220,13 @@ ReconstructDialog::showView (int iViewNumber) bool ReconstructDialog::reconstructView (int iViewNumber) { - ::wxYield(); // update the display - showView (iViewNumber); - ::wxYield(); // update the display + if (iViewNumber <= m_iLastView) // have already done this view + return true; + if (iViewNumber < m_rProjections.nView()) { + ::wxYield(); // update the display + showView (iViewNumber, true); + ::wxYield(); // update the display if (m_iTrace >= Trace::TRACE_PLOT) { ::wxUsleep(250); } @@ -259,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) { +#ifndef OLD + m_memoryDC.SelectObject (m_bitmap); // in memoryDC + m_pSGP->setDC (&m_memoryDC); + m_memoryDC.SetFont (*wxSWISS_FONT); + showView (m_iLastView, false); + m_pSGP->setDC (m_pDC); + m_memoryDC.SelectObject(wxNullBitmap); +#endif m_state = Paused; m_btnPause->SetLabel (wxString("Resume")); } else if (m_state == Paused) { @@ -275,7 +295,15 @@ ReconstructDialog::OnStep (wxCommandEvent& event) if ( m_state == Finished ) { event.Skip(); } else { - if (m_state == Continue) { + if (m_state == Continue) { +#ifndef OLD + m_memoryDC.SelectObject (m_bitmap); // in memoryDC + m_pSGP->setDC (&m_memoryDC); + m_memoryDC.SetFont (*wxSWISS_FONT); + m_rReconstructor.reconstructView (m_iLastView, 1, m_pSGP, false); + m_pSGP->setDC (m_pDC); + m_memoryDC.SelectObject(wxNullBitmap); +#endif m_state = Paused; m_btnPause->SetLabel (wxString("Resume")); } else if (m_state == Paused) { @@ -297,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); + if (m_state == Paused) + paintDC.DrawBitmap(m_bitmap, 0, 0, false); }