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.8 2000/07/22 15:45:33 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 (ny, nx, 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 : wxPanel(frame, -1, pos, size, style)
350 PhantomCanvas::OnDraw(wxDC& dc)
353 m_pView->OnDraw(& dc);
358 IMPLEMENT_DYNAMIC_CLASS(PhantomView, wxView)
360 BEGIN_EVENT_TABLE(PhantomView, wxView)
361 EVT_MENU(PHMMENU_FILE_PROPERTIES, PhantomView::OnProperties)
362 EVT_MENU(PHMMENU_PROCESS_RASTERIZE, PhantomView::OnRasterize)
363 EVT_MENU(PHMMENU_PROCESS_PROJECTIONS, PhantomView::OnProjections)
366 PhantomView::PhantomView(void)
367 : wxView(), m_canvas(NULL), m_frame(NULL)
371 PhantomView::~PhantomView(void)
376 PhantomView::OnProperties (wxCommandEvent& event)
378 const int idPhantom = GetDocument()->getPhantomID();
379 const string& namePhantom = GetDocument()->getPhantomName();
381 os << "Phantom " << namePhantom << " (" << idPhantom << ")\n";
382 *theApp->getLog() << os.str().c_str();
384 const Phantom& rPhantom = GetDocument()->getPhantom();
391 PhantomView::OnProjections (wxCommandEvent& event)
393 DialogGetProjectionParameters dialogProjection (m_frame, 367, 320, 1, 1., Scanner::GEOMETRY_PARALLEL);
394 int retVal = dialogProjection.ShowModal();
395 if (retVal == wxID_OK) {
396 int nDet = dialogProjection.getNDet();
397 int nView = dialogProjection.getNView();
398 int nSamples = dialogProjection.getNSamples();
399 double dRotAngle = dialogProjection.getRotAngle();
400 wxString sGeometry = dialogProjection.getGeometry();
401 if (nDet > 0 && nView > 0 && sGeometry != "") {
402 const Phantom& rPhantom = GetDocument()->getPhantom();
403 ProjectionFileDocument* pProjectionDoc = dynamic_cast<ProjectionFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT));
404 Projections& rProj = pProjectionDoc->getProjections();
405 Scanner theScanner (rPhantom, sGeometry.c_str(), nDet, nView, nSamples, dRotAngle);
406 rProj.initFromScanner (theScanner);
407 theScanner.collectProjections (rProj, rPhantom, 0, TRACE_NONE);
408 pProjectionDoc->Modify(true);
409 pProjectionDoc->UpdateAllViews(this);
411 os << "Projections for " << rPhantom.name() << ": nDet=" << nDet << ", nView=" << nView << ", nSamples=" << nSamples << ", RotAngle=" << dRotAngle << ", Geometry=" << sGeometry.c_str() << "\n";
412 *theApp->getLog() << os.str().c_str();
419 PhantomView::OnRasterize (wxCommandEvent& event)
421 DialogGetRasterParameters dialogRaster (m_frame, 256, 256, 1);
422 int retVal = dialogRaster.ShowModal();
423 if (retVal == wxID_OK) {
424 int xSize = dialogRaster.getXSize();
425 int ySize = dialogRaster.getYSize();
426 int nSamples = dialogRaster.getNSamples();
429 if (xSize > 0 && ySize > 0) {
430 const Phantom& rPhantom = GetDocument()->getPhantom();
431 ImageFileDocument* pRasterDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));
432 ImageFile& imageFile = pRasterDoc->getImageFile();
434 imageFile.setArraySize (xSize, ySize);
435 rPhantom.convertToImagefile (imageFile, nSamples, TRACE_NONE);
436 pRasterDoc->Modify(true);
437 pRasterDoc->UpdateAllViews(this);
440 os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << xSize << ", YSize=" << ySize << ", nSamples=" << nSamples << "\n";
441 *theApp->getLog() << os.str().c_str();
448 PhantomView::CreateCanvas (wxView *view, wxFrame *parent)
450 PhantomCanvas* pCanvas;
452 parent->GetClientSize(&width, &height);
454 pCanvas = new PhantomCanvas (dynamic_cast<PhantomView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
456 pCanvas->SetBackgroundColour(*wxWHITE);
463 PhantomView::CreateChildFrame(wxDocument *doc, wxView *view)
465 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE);
467 wxMenu *file_menu = new wxMenu;
469 file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
470 file_menu->Append(wxID_OPEN, "&Open...");
471 file_menu->Append(wxID_CLOSE, "&Close");
473 file_menu->AppendSeparator();
474 file_menu->Append(PHMMENU_FILE_PROPERTIES, "P&roperties");
476 file_menu->AppendSeparator();
477 file_menu->Append(wxID_PRINT, "&Print...");
478 file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
479 file_menu->Append(wxID_PREVIEW, "Print Pre&view");
481 wxMenu *process_menu = new wxMenu;
482 process_menu->Append(PHMMENU_PROCESS_RASTERIZE, "&Rasterize...");
483 process_menu->Append(PHMMENU_PROCESS_PROJECTIONS, "&Projections...");
485 wxMenu *help_menu = new wxMenu;
486 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
487 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
489 wxMenuBar *menu_bar = new wxMenuBar;
491 menu_bar->Append(file_menu, "&File");
492 menu_bar->Append(process_menu, "&Process");
493 menu_bar->Append(help_menu, "&Help");
495 subframe->SetMenuBar(menu_bar);
497 subframe->Centre(wxBOTH);
504 PhantomView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
506 m_frame = CreateChildFrame(doc, this);
509 m_frame->GetClientSize(&width, &height);
510 m_frame->SetTitle("PhantomView");
511 m_canvas = CreateCanvas(this, m_frame);
514 int x, y; // X requires a forced resize
515 m_frame->GetSize(&x, &y);
516 m_frame->SetSize(-1, -1, x, y);
526 PhantomView::OnDraw (wxDC* dc)
528 // if (m_bitmap.Ok())
529 // dc->DrawBitmap (m_bitmap, 0, 0, false);
534 PhantomView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
541 PhantomView::OnClose (bool deleteWindow)
543 if (!GetDocument()->Close())
547 m_canvas->m_pView = NULL;
549 wxString s(wxTheApp->GetAppName());
551 m_frame->SetTitle(s);
566 ProjectionFileCanvas::ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
567 : wxScrolledWindow(frame, -1, pos, size, style)
573 ProjectionFileCanvas::OnDraw(wxDC& dc)
576 m_pView->OnDraw(& dc);
579 // ProjectionFileView
581 IMPLEMENT_DYNAMIC_CLASS(ProjectionFileView, wxView)
583 BEGIN_EVENT_TABLE(ProjectionFileView, wxView)
584 EVT_MENU(PJMENU_FILE_PROPERTIES, ProjectionFileView::OnProperties)
585 EVT_MENU(PJMENU_PROCESS_RECONSTRUCT, ProjectionFileView::OnReconstruct)
588 ProjectionFileView::ProjectionFileView(void)
589 : wxView(), m_canvas(NULL), m_frame(NULL)
593 ProjectionFileView::~ProjectionFileView(void)
598 ProjectionFileView::OnProperties (wxCommandEvent& event)
600 const Projections& rProj = GetDocument()->getProjections();
602 os << "ProjectionFile " << rProj.getFilename() << ": Number of Detectors = " << rProj.nDet() << ", Number of Views = " << rProj.nView() << "\n";
603 *theApp->getLog() << os.str().c_str();
608 ProjectionFileView::OnReconstruct (wxCommandEvent& event)
610 DialogGetReconstructionParameters dialogReconstruction (m_frame, 256, 256, SignalFilter::FILTER_ABS_BANDLIMIT, 1., SignalFilter::FILTER_METHOD_CONVOLUTION, 3, Backprojector::INTERP_LINEAR, 1, Backprojector::BPROJ_IDIFF3);
611 int retVal = dialogReconstruction.ShowModal();
612 if (retVal == wxID_OK) {
613 int xSize = dialogReconstruction.getXSize();
614 int ySize = dialogReconstruction.getYSize();
615 wxString optFilterName = dialogReconstruction.getFilterName();
616 double optFilterParam = dialogReconstruction.getFilterParam();
617 wxString optFilterMethodName = dialogReconstruction.getFilterMethodName();
618 int optZeropad = dialogReconstruction.getZeropad();
619 wxString optInterpName = dialogReconstruction.getInterpName();
620 int optInterpParam = dialogReconstruction.getInterpParam();
621 wxString optBackprojectName = dialogReconstruction.getBackprojectName();
622 if (xSize > 0 && ySize > 0) {
623 ImageFileDocument* pReconDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));
624 ImageFile& imageFile = pReconDoc->getImageFile();
625 const Projections& rProj = GetDocument()->getProjections();
626 imageFile.setArraySize (xSize, ySize);
627 rProj.reconstruct (imageFile, optFilterName.c_str(), optFilterParam, optFilterMethodName.c_str(), optZeropad, optInterpName.c_str(), optInterpParam, optBackprojectName.c_str(), TRACE_NONE);
628 pReconDoc->Modify(true);
629 pReconDoc->UpdateAllViews(this);
631 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";
632 *theApp->getLog() << os.str().c_str();
638 ProjectionFileCanvas*
639 ProjectionFileView::CreateCanvas (wxView *view, wxFrame *parent)
641 ProjectionFileCanvas* pCanvas;
643 parent->GetClientSize(&width, &height);
645 pCanvas = new ProjectionFileCanvas (dynamic_cast<ProjectionFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
647 pCanvas->SetScrollbars(20, 20, 50, 50);
648 pCanvas->SetBackgroundColour(*wxWHITE);
655 ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
657 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
659 wxMenu *file_menu = new wxMenu;
661 file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
662 file_menu->Append(wxID_OPEN, "&Open...");
663 file_menu->Append(wxID_CLOSE, "&Close");
665 file_menu->AppendSeparator();
666 file_menu->Append(PJMENU_FILE_PROPERTIES, "P&roperties");
668 file_menu->AppendSeparator();
669 file_menu->Append(wxID_PRINT, "&Print...");
670 file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
671 file_menu->Append(wxID_PREVIEW, "Print Pre&view");
673 wxMenu *process_menu = new wxMenu;
674 process_menu->Append(PJMENU_PROCESS_RECONSTRUCT, "R&econstruct...");
676 wxMenu *help_menu = new wxMenu;
677 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
678 help_menu->AppendSeparator();
679 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
681 wxMenuBar *menu_bar = new wxMenuBar;
683 menu_bar->Append(file_menu, "&File");
684 menu_bar->Append(process_menu, "&Process");
685 menu_bar->Append(help_menu, "&Help");
687 subframe->SetMenuBar(menu_bar);
689 subframe->Centre(wxBOTH);
696 ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
698 m_frame = CreateChildFrame(doc, this);
701 m_frame->GetClientSize(&width, &height);
702 m_frame->SetTitle("ProjectionFileView");
703 m_canvas = CreateCanvas(this, m_frame);
706 int x, y; // X requires a forced resize
707 m_frame->GetSize(&x, &y);
708 m_frame->SetSize(-1, -1, x, y);
718 ProjectionFileView::OnDraw (wxDC* dc)
721 dc->DrawBitmap (m_bitmap, 0, 0, false);
726 ProjectionFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
728 const Projections& rProj = GetDocument()->getProjections();
729 const int nDet = rProj.nDet();
730 const int nView = rProj.nView();
731 if (nDet != 0 && nView != 0) {
732 const DetectorArray& detarray = rProj.getDetectorArray(0);
733 const DetectorValue* detval = detarray.detValues();
734 double min = detval[0];
735 double max = detval[0];
736 for (int iy = 0; iy < nView; iy++) {
737 const DetectorArray& detarray = rProj.getDetectorArray(iy);
738 const DetectorValue* detval = detarray.detValues();
739 for (int ix = 0; ix < nDet; ix++) {
740 if (min > detval[ix])
742 else if (max < detval[ix])
747 unsigned char* imageData = new unsigned char [nDet * nView * 3];
748 double scale = (max - min) / 255;
749 for (int iy = 0; iy < nView; iy++) {
750 const DetectorArray& detarray = rProj.getDetectorArray(iy);
751 const DetectorValue* detval = detarray.detValues();
752 for (int ix = 0; ix < nDet; ix++) {
753 int intensity = static_cast<int>(((detval[ix] - min) / scale) + 0.5);
754 intensity = clamp(intensity, 0, 255);
755 int baseAddr = (iy * nDet + ix) * 3;
756 imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
759 wxImage image (nDet, nView, imageData, true);
760 m_bitmap = image.ConvertToBitmap();
764 xSize = clamp (xSize, 0, 800);
765 ySize = clamp (ySize, 0, 800);
766 m_frame->SetClientSize (xSize, ySize);
767 m_canvas->SetScrollbars (20, 20, nDet/20, nView/20);
775 ProjectionFileView::OnClose (bool deleteWindow)
777 if (!GetDocument()->Close())
781 m_canvas->m_pView = NULL;
783 wxString s(wxTheApp->GetAppName());
785 m_frame->SetTitle(s);