1 /*****************************************************************************
5 ** Purpose: View & Canvas routines for CTSim program
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: views.cpp,v 1.13 2000/08/02 18:06:00 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
29 // #pragma implementation
32 // For compilers that support precompilation, includes "wx/wx.h".
33 #include "wx/wxprec.h"
43 #if !wxUSE_DOC_VIEW_ARCHITECTURE
44 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
55 #include "backprojectors.h"
59 BEGIN_EVENT_TABLE(ImageFileCanvas, wxScrolledWindow)
60 EVT_MOUSE_EVENTS(ImageFileCanvas::OnMouseEvent)
64 ImageFileCanvas::ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
65 : wxScrolledWindow(frame, -1, pos, size, style)
71 ImageFileCanvas::OnDraw(wxDC& dc)
74 m_pView->OnDraw(& dc);
78 ImageFileCanvas::OnMouseEvent(wxMouseEvent& event)
86 wxPoint pt(event.GetLogicalPosition(dc));
88 if (event.LeftIsDown()) {
89 const ImageFile& rIF = m_pView->GetDocument()->getImageFile();
90 ImageFileArrayConst v = rIF.getArray();
94 if (pt.x >= 0 && pt.x < nx && pt.y >= 0 & pt.y < ny) {
96 os << "Image value (" << pt.x << "," << pt.y << ") = " << v[pt.x][ny - 1 - pt.y] << "\n";
97 *theApp->getLog() << os.str().c_str();
99 *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";
107 IMPLEMENT_DYNAMIC_CLASS(ImageFileView, wxView)
109 BEGIN_EVENT_TABLE(ImageFileView, wxView)
110 EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties)
111 EVT_MENU(IFMENU_VIEW_WINDOW_MINMAX, ImageFileView::OnWindowMinMax)
112 EVT_MENU(IFMENU_VIEW_WINDOW_AUTO, ImageFileView::OnWindowAuto)
115 ImageFileView::ImageFileView(void)
116 : wxView(), m_canvas(NULL), m_frame(NULL), m_bMinSpecified(false), m_bMaxSpecified(false)
120 ImageFileView::~ImageFileView(void)
125 ImageFileView::OnProperties (wxCommandEvent& event)
127 double min, max, mean, mode, median, stddev;
128 const ImageFile& rIF = GetDocument()->getImageFile();
129 if (rIF.nx() == 0 || rIF.ny() == 0)
130 *theApp->getLog() << "Properties: empty imagefile\n";
132 const string& rFilename = rIF.getFilename();
133 rIF.statistics (min, max, mean, mode, median, stddev);
135 os << "file: " << rFilename << "\nmin: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmode: "<<mode<<"\nstddev: "<<stddev << "\n";
136 *theApp->getLog() << os.str().c_str();
139 ostringstream osSize;
140 m_frame->GetSize (&xSize, &ySize);
141 osSize << "Frame size: (" << xSize << "," << ySize << ")\n";
142 m_frame->GetClientSize (&xSize, &ySize);
143 osSize << "Frame Client size: (" << xSize << "," << ySize << ")\n";
144 m_canvas->GetSize (&xSize, &ySize);
145 osSize << "Canvas size: (" << xSize << "," << ySize << ")\n";
146 *theApp->getLog() << osSize.str().c_str();
151 ImageFileView::OnWindowAuto (wxCommandEvent& event)
153 *theApp->getLog() << "ImageFile: Window Auto\n";
157 ImageFileView::OnWindowMinMax (wxCommandEvent& event)
159 const ImageFile& rIF = GetDocument()->getImageFile();
161 if (! m_bMinSpecified && ! m_bMaxSpecified)
162 rIF.getMinMax (min, max);
169 DialogGetImageMinMax dialogMinMax (m_frame, rIF, min, max);
170 int retVal = dialogMinMax.ShowModal();
171 if (retVal == wxID_OK) {
172 m_bMinSpecified = true;
173 m_bMaxSpecified = true;
174 m_dMinPixel = dialogMinMax.getMinimum();
175 m_dMaxPixel = dialogMinMax.getMaximum();
176 OnUpdate (this, NULL);
182 ImageFileView::CreateCanvas (wxView *view, wxFrame *parent)
184 ImageFileCanvas* pCanvas;
186 parent->GetClientSize(&width, &height);
188 pCanvas = new ImageFileCanvas (dynamic_cast<ImageFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
190 pCanvas->SetScrollbars(20, 20, 50, 50);
191 pCanvas->SetBackgroundColour(*wxWHITE);
198 ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
200 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
202 wxMenu *file_menu = new wxMenu;
204 file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
205 file_menu->Append(wxID_OPEN, "&Open...");
206 file_menu->Append(wxID_CLOSE, "&Close");
207 file_menu->Append(wxID_SAVE, "&Save");
208 file_menu->Append(wxID_SAVEAS, "Save &As...");
210 file_menu->AppendSeparator();
211 file_menu->Append(IFMENU_FILE_PROPERTIES, "P&roperties");
213 file_menu->AppendSeparator();
214 file_menu->Append(wxID_PRINT, "&Print...");
215 file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
216 file_menu->Append(wxID_PREVIEW, "Print Pre&view");
218 wxMenu *view_menu = new wxMenu;
219 view_menu->Append(IFMENU_VIEW_WINDOW_MINMAX, "&Set Window Min/Max");
220 view_menu->Append(IFMENU_VIEW_WINDOW_AUTO, "&Auto Window...");
222 wxMenu *help_menu = new wxMenu;
223 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
225 wxMenuBar *menu_bar = new wxMenuBar;
227 menu_bar->Append(file_menu, "&File");
228 menu_bar->Append(view_menu, "&View");
229 menu_bar->Append(help_menu, "&Help");
231 subframe->SetMenuBar(menu_bar);
233 subframe->Centre(wxBOTH);
240 ImageFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
242 m_frame = CreateChildFrame(doc, this);
244 m_bMinSpecified = false;
245 m_bMaxSpecified = false;
248 m_frame->GetClientSize(&width, &height);
249 m_frame->SetTitle("ImageFileView");
250 m_canvas = CreateCanvas(this, m_frame);
253 int x, y; // X requires a forced resize
254 m_frame->GetSize(&x, &y);
255 m_frame->SetSize(-1, -1, x, y);
265 ImageFileView::OnDraw (wxDC* dc)
268 dc->DrawBitmap(m_bitmap, 0, 0, false);
273 ImageFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
275 const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(GetDocument())->getImageFile();
276 ImageFileArrayConst v = rIF.getArray();
279 if (v != NULL && nx != 0 && ny != 0) {
280 if (! m_bMinSpecified || ! m_bMaxSpecified) {
282 rIF.getMinMax (min, max);
283 if (! m_bMinSpecified)
285 if (! m_bMaxSpecified)
288 double scaleWidth = m_dMaxPixel - m_dMinPixel;
290 unsigned char* imageData = new unsigned char [nx * ny * 3];
291 for (int ix = 0; ix < nx; ix++) {
292 for (int iy = 0; iy < ny; iy++) {
293 double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255;
294 int intensity = static_cast<int>(scaleValue + 0.5);
295 intensity = clamp (intensity, 0, 255);
296 int baseAddr = ((ny - 1 - iy) * nx + ix) * 3;
297 imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
300 wxImage image (nx, ny, imageData, true);
301 m_bitmap = image.ConvertToBitmap();
305 xSize = clamp (xSize, 0, 800);
306 ySize = clamp (ySize, 0, 800);
307 m_frame->SetClientSize (xSize, ySize);
308 m_canvas->SetScrollbars(20, 20, nx/20, ny/20);
309 m_canvas->SetBackgroundColour(*wxWHITE);
317 ImageFileView::OnClose (bool deleteWindow)
319 if (!GetDocument()->Close())
323 m_canvas->m_pView = NULL;
325 wxString s(theApp->GetAppName());
327 m_frame->SetTitle(s);
343 PhantomCanvas::PhantomCanvas (PhantomView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
344 : wxScrolledWindow(frame, -1, pos, size, style)
350 PhantomCanvas::OnDraw(wxDC& dc)
353 m_pView->OnDraw(& dc);
359 IMPLEMENT_DYNAMIC_CLASS(PhantomView, wxView)
361 BEGIN_EVENT_TABLE(PhantomView, wxView)
362 EVT_MENU(PHMMENU_FILE_PROPERTIES, PhantomView::OnProperties)
363 EVT_MENU(PHMMENU_PROCESS_RASTERIZE, PhantomView::OnRasterize)
364 EVT_MENU(PHMMENU_PROCESS_PROJECTIONS, PhantomView::OnProjections)
367 PhantomView::PhantomView(void)
368 : wxView(), m_canvas(NULL), m_frame(NULL)
372 PhantomView::~PhantomView(void)
377 PhantomView::OnProperties (wxCommandEvent& event)
379 const int idPhantom = GetDocument()->getPhantomID();
380 const string& namePhantom = GetDocument()->getPhantomName();
382 os << "Phantom " << namePhantom << " (" << idPhantom << ")\n";
383 *theApp->getLog() << os.str().c_str();
385 const Phantom& rPhantom = GetDocument()->getPhantom();
392 PhantomView::OnProjections (wxCommandEvent& event)
394 DialogGetProjectionParameters dialogProjection (m_frame, 367, 320, 1, 1., Scanner::GEOMETRY_PARALLEL);
395 int retVal = dialogProjection.ShowModal();
396 if (retVal == wxID_OK) {
397 int nDet = dialogProjection.getNDet();
398 int nView = dialogProjection.getNView();
399 int nSamples = dialogProjection.getNSamples();
400 double dRotAngle = dialogProjection.getRotAngle();
401 wxString sGeometry = dialogProjection.getGeometry();
402 if (nDet > 0 && nView > 0 && sGeometry != "") {
403 const Phantom& rPhantom = GetDocument()->getPhantom();
404 ProjectionFileDocument* pProjectionDoc = dynamic_cast<ProjectionFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT));
405 Projections& rProj = pProjectionDoc->getProjections();
406 Scanner theScanner (rPhantom, sGeometry.c_str(), nDet, nView, nSamples, dRotAngle);
407 rProj.initFromScanner (theScanner);
410 wxFrame frame (m_frame, -1, "", wxDefaultPosition, wxSize(500,500));
412 wxClientDC dc (&frame);
414 frame.GetClientSize(&x, &y);
415 SGPDriver driver (dynamic_cast<wxDC*>(&dc), x, y);
417 theScanner.collectProjections (rProj, rPhantom, 0, TRACE_PHM, &sgp);
419 theScanner.collectProjections (rProj, rPhantom);
422 pProjectionDoc->Modify(true);
423 pProjectionDoc->UpdateAllViews(this);
425 os << "Projections for " << rPhantom.name() << ": nDet=" << nDet << ", nView=" << nView << ", nSamples=" << nSamples << ", RotAngle=" << dRotAngle << ", Geometry=" << sGeometry.c_str() << "\n";
426 *theApp->getLog() << os.str().c_str();
433 PhantomView::OnRasterize (wxCommandEvent& event)
435 DialogGetRasterParameters dialogRaster (m_frame, 256, 256, 1);
436 int retVal = dialogRaster.ShowModal();
437 if (retVal == wxID_OK) {
438 int xSize = dialogRaster.getXSize();
439 int ySize = dialogRaster.getYSize();
440 int nSamples = dialogRaster.getNSamples();
443 if (xSize > 0 && ySize > 0) {
444 const Phantom& rPhantom = GetDocument()->getPhantom();
445 ImageFileDocument* pRasterDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));
446 ImageFile& imageFile = pRasterDoc->getImageFile();
448 imageFile.setArraySize (xSize, ySize);
449 rPhantom.convertToImagefile (imageFile, nSamples, TRACE_NONE);
450 pRasterDoc->Modify(true);
451 pRasterDoc->UpdateAllViews(this);
454 os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << xSize << ", YSize=" << ySize << ", nSamples=" << nSamples << "\n";
455 *theApp->getLog() << os.str().c_str();
462 PhantomView::CreateCanvas (wxView *view, wxFrame *parent)
464 PhantomCanvas* pCanvas;
466 parent->GetClientSize(&width, &height);
468 pCanvas = new PhantomCanvas (dynamic_cast<PhantomView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
470 pCanvas->SetBackgroundColour(*wxWHITE);
477 PhantomView::CreateChildFrame(wxDocument *doc, wxView *view)
479 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE);
481 wxMenu *file_menu = new wxMenu;
483 file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
484 file_menu->Append(wxID_OPEN, "&Open...");
485 file_menu->Append(wxID_CLOSE, "&Close");
487 file_menu->AppendSeparator();
488 file_menu->Append(PHMMENU_FILE_PROPERTIES, "P&roperties");
490 file_menu->AppendSeparator();
491 file_menu->Append(wxID_PRINT, "&Print...");
492 file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
493 file_menu->Append(wxID_PREVIEW, "Print Pre&view");
495 wxMenu *process_menu = new wxMenu;
496 process_menu->Append(PHMMENU_PROCESS_RASTERIZE, "&Rasterize...");
497 process_menu->Append(PHMMENU_PROCESS_PROJECTIONS, "&Projections...");
499 wxMenu *help_menu = new wxMenu;
500 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
501 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
503 wxMenuBar *menu_bar = new wxMenuBar;
505 menu_bar->Append(file_menu, "&File");
506 menu_bar->Append(process_menu, "&Process");
507 menu_bar->Append(help_menu, "&Help");
509 subframe->SetMenuBar(menu_bar);
511 subframe->Centre(wxBOTH);
518 PhantomView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
520 m_frame = CreateChildFrame(doc, this);
523 m_frame->GetClientSize(&width, &height);
524 m_frame->SetTitle("PhantomView");
525 m_canvas = CreateCanvas(this, m_frame);
528 int x, y; // X requires a forced resize
529 m_frame->GetSize(&x, &y);
530 m_frame->SetSize(-1, -1, x, y);
541 PhantomView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
548 PhantomView::OnClose (bool deleteWindow)
550 if (!GetDocument()->Close())
554 m_canvas->m_pView = NULL;
556 wxString s(wxTheApp->GetAppName());
558 m_frame->SetTitle(s);
571 PhantomView::OnDraw (wxDC* dc)
574 m_canvas->GetClientSize (&xsize, &ysize);
575 SGPDriver driver (dc, xsize, ysize);
577 const Phantom& rPhantom = GetDocument()->getPhantom();
578 sgp.setColor (C_RED);
584 ProjectionFileCanvas::ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
585 : wxScrolledWindow(frame, -1, pos, size, style)
591 ProjectionFileCanvas::OnDraw(wxDC& dc)
594 m_pView->OnDraw(& dc);
597 // ProjectionFileView
599 IMPLEMENT_DYNAMIC_CLASS(ProjectionFileView, wxView)
601 BEGIN_EVENT_TABLE(ProjectionFileView, wxView)
602 EVT_MENU(PJMENU_FILE_PROPERTIES, ProjectionFileView::OnProperties)
603 EVT_MENU(PJMENU_PROCESS_RECONSTRUCT, ProjectionFileView::OnReconstruct)
606 ProjectionFileView::ProjectionFileView(void)
607 : wxView(), m_canvas(NULL), m_frame(NULL)
611 ProjectionFileView::~ProjectionFileView(void)
616 ProjectionFileView::OnProperties (wxCommandEvent& event)
618 const Projections& rProj = GetDocument()->getProjections();
620 os << "ProjectionFile " << rProj.getFilename() << ": Number of Detectors = " << rProj.nDet() << ", Number of Views = " << rProj.nView() << "\n";
621 *theApp->getLog() << os.str().c_str();
626 ProjectionFileView::OnReconstruct (wxCommandEvent& event)
628 DialogGetReconstructionParameters dialogReconstruction (m_frame, 256, 256, SignalFilter::FILTER_ABS_BANDLIMIT, 1., SignalFilter::FILTER_METHOD_CONVOLUTION, 3, Backprojector::INTERP_LINEAR, 1, Backprojector::BPROJ_IDIFF3);
629 int retVal = dialogReconstruction.ShowModal();
630 if (retVal == wxID_OK) {
631 int xSize = dialogReconstruction.getXSize();
632 int ySize = dialogReconstruction.getYSize();
633 wxString optFilterName = dialogReconstruction.getFilterName();
634 double optFilterParam = dialogReconstruction.getFilterParam();
635 wxString optFilterMethodName = dialogReconstruction.getFilterMethodName();
636 int optZeropad = dialogReconstruction.getZeropad();
637 wxString optInterpName = dialogReconstruction.getInterpName();
638 int optInterpParam = dialogReconstruction.getInterpParam();
639 wxString optBackprojectName = dialogReconstruction.getBackprojectName();
640 if (xSize > 0 && ySize > 0) {
641 ImageFileDocument* pReconDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));
642 ImageFile& imageFile = pReconDoc->getImageFile();
643 const Projections& rProj = GetDocument()->getProjections();
644 imageFile.setArraySize (xSize, ySize);
645 rProj.reconstruct (imageFile, optFilterName.c_str(), optFilterParam, optFilterMethodName.c_str(), optZeropad, optInterpName.c_str(), optInterpParam, optBackprojectName.c_str(), TRACE_NONE);
646 pReconDoc->Modify(true);
647 pReconDoc->UpdateAllViews(this);
649 os << "Reconstruct " << rProj.getFilename() << ": xSize=" << xSize << ", ySize=" << ySize << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << optFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", Zeropad=" << optZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << optInterpParam << ", Backprojection=" << optBackprojectName.c_str() << "\n";
650 *theApp->getLog() << os.str().c_str();
656 ProjectionFileCanvas*
657 ProjectionFileView::CreateCanvas (wxView *view, wxFrame *parent)
659 ProjectionFileCanvas* pCanvas;
661 parent->GetClientSize(&width, &height);
663 pCanvas = new ProjectionFileCanvas (dynamic_cast<ProjectionFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
665 pCanvas->SetScrollbars(20, 20, 50, 50);
666 pCanvas->SetBackgroundColour(*wxWHITE);
673 ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
675 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
677 wxMenu *file_menu = new wxMenu;
679 file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
680 file_menu->Append(wxID_OPEN, "&Open...");
681 file_menu->Append(wxID_CLOSE, "&Close");
683 file_menu->AppendSeparator();
684 file_menu->Append(PJMENU_FILE_PROPERTIES, "P&roperties");
686 file_menu->AppendSeparator();
687 file_menu->Append(wxID_PRINT, "&Print...");
688 file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
689 file_menu->Append(wxID_PREVIEW, "Print Pre&view");
691 wxMenu *process_menu = new wxMenu;
692 process_menu->Append(PJMENU_PROCESS_RECONSTRUCT, "R&econstruct...");
694 wxMenu *help_menu = new wxMenu;
695 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
696 help_menu->AppendSeparator();
697 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
699 wxMenuBar *menu_bar = new wxMenuBar;
701 menu_bar->Append(file_menu, "&File");
702 menu_bar->Append(process_menu, "&Process");
703 menu_bar->Append(help_menu, "&Help");
705 subframe->SetMenuBar(menu_bar);
707 subframe->Centre(wxBOTH);
714 ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
716 m_frame = CreateChildFrame(doc, this);
719 m_frame->GetClientSize(&width, &height);
720 m_frame->SetTitle("ProjectionFileView");
721 m_canvas = CreateCanvas(this, m_frame);
724 int x, y; // X requires a forced resize
725 m_frame->GetSize(&x, &y);
726 m_frame->SetSize(-1, -1, x, y);
736 ProjectionFileView::OnDraw (wxDC* dc)
739 dc->DrawBitmap (m_bitmap, 0, 0, false);
744 ProjectionFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
746 const Projections& rProj = GetDocument()->getProjections();
747 const int nDet = rProj.nDet();
748 const int nView = rProj.nView();
749 if (nDet != 0 && nView != 0) {
750 const DetectorArray& detarray = rProj.getDetectorArray(0);
751 const DetectorValue* detval = detarray.detValues();
752 double min = detval[0];
753 double max = detval[0];
754 for (int iy = 0; iy < nView; iy++) {
755 const DetectorArray& detarray = rProj.getDetectorArray(iy);
756 const DetectorValue* detval = detarray.detValues();
757 for (int ix = 0; ix < nDet; ix++) {
758 if (min > detval[ix])
760 else if (max < detval[ix])
765 unsigned char* imageData = new unsigned char [nDet * nView * 3];
766 double scale = (max - min) / 255;
767 for (int iy = 0; iy < nView; iy++) {
768 const DetectorArray& detarray = rProj.getDetectorArray(iy);
769 const DetectorValue* detval = detarray.detValues();
770 for (int ix = 0; ix < nDet; ix++) {
771 int intensity = static_cast<int>(((detval[ix] - min) / scale) + 0.5);
772 intensity = clamp(intensity, 0, 255);
773 int baseAddr = (iy * nDet + ix) * 3;
774 imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
777 wxImage image (nDet, nView, imageData, true);
778 m_bitmap = image.ConvertToBitmap();
782 xSize = clamp (xSize, 0, 800);
783 ySize = clamp (ySize, 0, 800);
784 m_frame->SetClientSize (xSize, ySize);
785 m_canvas->SetScrollbars (20, 20, nDet/20, nView/20);
793 ProjectionFileView::OnClose (bool deleteWindow)
795 if (!GetDocument()->Close())
799 m_canvas->m_pView = NULL;
801 wxString s(wxTheApp->GetAppName());
803 m_frame->SetTitle(s);