+}
+
+bool
+ImageFileView::OnClose (bool deleteWindow)
+{
+ if (!GetDocument()->Close())
+ return false;
+
+ m_canvas->Clear();
+ m_canvas->m_pView = NULL;
+ m_canvas = NULL;
+ wxString s(theApp->GetAppName());
+ if (m_frame)
+ m_frame->SetTitle(s);
+ SetFrame(NULL);
+
+ Activate(false);
+
+ if (deleteWindow) {
+ delete m_frame;
+ return true;
+ }
+ return true;
+}
+
+
+
+// PhantomCanvas
+
+PhantomCanvas::PhantomCanvas (PhantomView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
+ : wxScrolledWindow(frame, -1, pos, size, style)
+{
+ m_pView = v;
+}
+
+void
+PhantomCanvas::OnDraw(wxDC& dc)
+{
+ if (m_pView)
+ m_pView->OnDraw(& dc);
+}
+
+
+// PhantomView
+
+IMPLEMENT_DYNAMIC_CLASS(PhantomView, wxView)
+
+BEGIN_EVENT_TABLE(PhantomView, wxView)
+ EVT_MENU(PHMMENU_FILE_PROPERTIES, PhantomView::OnProperties)
+ EVT_MENU(PHMMENU_PROCESS_RASTERIZE, PhantomView::OnRasterize)
+ EVT_MENU(PHMMENU_PROCESS_PROJECTIONS, PhantomView::OnProjections)
+END_EVENT_TABLE()
+
+PhantomView::PhantomView(void)
+ : wxView(), m_canvas(NULL), m_frame(NULL)
+{
+}
+
+PhantomView::~PhantomView(void)
+{
+}
+
+void
+PhantomView::OnProperties (wxCommandEvent& event)
+{
+ const int idPhantom = GetDocument()->getPhantomID();
+ const string& namePhantom = GetDocument()->getPhantomName();
+ ostringstream os;
+ os << "Phantom " << namePhantom << " (" << idPhantom << ")\n";
+ *theApp->getLog() << os.str().c_str();
+#if DEBUG
+ const Phantom& rPhantom = GetDocument()->getPhantom();
+ rPhantom.print();
+#endif
+}
+
+
+void
+PhantomView::OnProjections (wxCommandEvent& event)
+{
+ DialogGetProjectionParameters dialogProjection (m_frame, 367, 320, 1, 1., Scanner::GEOMETRY_PARALLEL);
+ int retVal = dialogProjection.ShowModal();
+ if (retVal == wxID_OK) {
+ int nDet = dialogProjection.getNDet();
+ int nView = dialogProjection.getNView();
+ int nSamples = dialogProjection.getNSamples();
+ double dRotAngle = dialogProjection.getRotAngle();
+ wxString sGeometry = dialogProjection.getGeometry();
+ if (nDet > 0 && nView > 0 && sGeometry != "") {
+ const Phantom& rPhantom = GetDocument()->getPhantom();
+ ProjectionFileDocument* pProjectionDoc = dynamic_cast<ProjectionFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT));
+ Projections& rProj = pProjectionDoc->getProjections();
+ Scanner theScanner (rPhantom, sGeometry.c_str(), nDet, nView, nSamples, dRotAngle);
+ rProj.initFromScanner (theScanner);
+ theScanner.collectProjections (rProj, rPhantom, 0, TRACE_NONE);
+ pProjectionDoc->Modify(true);
+ pProjectionDoc->UpdateAllViews(this);
+ ostringstream os;
+ os << "Projections for " << rPhantom.name() << ": nDet=" << nDet << ", nView=" << nView << ", nSamples=" << nSamples << ", RotAngle=" << dRotAngle << ", Geometry=" << sGeometry.c_str() << "\n";
+ *theApp->getLog() << os.str().c_str();