-ReconstructDialog::showView (int iViewNumber)
-{
- if ( iViewNumber < m_rProjections.nView() ) {
- wxYield(); // update the display
- m_iLastView = iViewNumber;
- m_pSGP->eraseWindow();
- if (m_iTrace >= Trace::TRACE_PLOT)
- m_pSGP->setViewport (0, 0, 1, 1);
- char szProgress [256];
- snprintf (szProgress, sizeof(szProgress), "Reconstructing View %d (%.1f%%)", iViewNumber, 100 * iViewNumber / static_cast<double>(m_rProjections.nView()));
- double wText, hText;
- m_pSGP->setTextColor (C_LTRED, -1);
- m_pSGP->getTextExtent (szProgress, &wText, &hText);
- double xw_max, xw_min, yw_max, yw_min;
- m_pSGP->getWindow (xw_min, yw_min, xw_max, yw_max);
- m_pSGP->moveAbs ((xw_max - xw_min) / 2 + xw_min - wText / 2, yw_max - hText);
- m_pSGP->drawText (szProgress);
- if (m_iTrace >= Trace::TRACE_PLOT)
- m_pSGP->setViewport (0, .1, 0.66, 1);
- m_rReconstructor.reconstructView (iViewNumber, 1, m_pSGP);
-
- ::wxYield();
- m_pDC->SelectObject (wxNullBitmap);
- Refresh();
- m_pDC->SelectObject (m_bitmap);
- ::wxYield();
- }
+ReconstructDialog::showView (int iViewNumber, bool bBackprojectView)
+{\r
+ if ( iViewNumber < m_rProjections.nView() ) {
+ m_iLastView = iViewNumber;
+ ::wxYield(); // update the display\r
+ m_pSGP->eraseWindow();\r
+ m_btnPause->Refresh();
+ m_btnStep->Refresh();
+ m_btnAbort->Refresh();
+
+ char szProgress [256];
+ snprintf (szProgress, sizeof(szProgress), "Reconstructing View %d (%.1f%%)", iViewNumber, 100 * iViewNumber / static_cast<double>(m_rProjections.nView()));
+ m_pSGP->setViewport (0, 0, 1, 1);
+ m_pSGP->setWindow (0, 0, 1, 1);
+ m_pSGP->setTextColor (C_LTRED, -1);
+ double dCharHeight = m_pSGP->getCharHeight();
+ m_pSGP->setTextSize (dCharHeight * 2);
+ m_pSGP->moveAbs(0., m_pSGP->getCharHeight());
+ m_pSGP->drawText (szProgress);
+ m_pSGP->setTextSize (dCharHeight);
+
+ m_pSGP->setViewport (0.0, 0.1, 0.66, 1.);
+ m_rReconstructor.reconstructView (iViewNumber, 1, m_pSGP, bBackprojectView);
+
+ ImageFileArrayConst v = m_rImageFile.getArray();
+ int xBase = m_nxGraph;
+ int yBase = 0;
+ if (m_nyGraph > m_nyImage)
+ yBase = (m_nyGraph - m_nyImage) / 2;
+ double minValue = v[0][0];
+ double maxValue = v[0][0];
+ for (int ix = 0; ix < m_nxImage; ix++) {
+ for (int iy = 0; iy < m_nyImage; iy++) {
+ double dPixel = v[ix][iy];
+ if (dPixel < minValue)
+ minValue = dPixel;
+ else if (dPixel > maxValue)
+ maxValue = dPixel;
+ }
+ }
+ unsigned char* imageData = new unsigned char [m_nxImage * m_nyImage * 3];
+ double dScale = 255 / (maxValue - minValue);
+ for (int ix2 = 0; ix2 < m_nxImage; ix2++) {
+ for (int iy = 0; iy < m_nyImage; 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 + ix2) * 3;
+ imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
+ }
+ }\r
+ wxImage image (m_nxImage, m_nyImage, imageData, true);
+ wxBitmap bitmap = image.ConvertToBitmap();
+ m_pSGP->getDriver().idWX()->DrawBitmap(bitmap, xBase, yBase, false);
+ delete imageData;
+ }