+ if (theApp->getAskDeleteNewDocs())
+ pPlotDoc->Modify (true);
+ pPlotDoc->getView()->getFrame()->Show(true);
+ pPlotDoc->UpdateAllViews ();
+ pPlotDoc->Activate();
+ }
+}
+#endif
+
+void
+ImageFileView::OnCompareCol (wxCommandEvent& event)
+{
+ int xCursor, yCursor;
+ if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
+ wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");
+ return;
+ }
+
+ std::vector<ImageFileDocument*> vecIFDoc;
+ theApp->getCompatibleImages (GetDocument(), vecIFDoc);
+ if (vecIFDoc.size() == 0) {
+ wxMessageBox ("No compatible images for Column Comparison", "Error");
+ return;
+ }
+ DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Comparison Image", vecIFDoc, false);
+
+ if (dialogGetCompare.ShowModal() == wxID_OK) {
+ ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();
+ const ImageFile& rIF = GetDocument()->getImageFile();
+ const ImageFile& rCompareIF = pCompareDoc->getImageFile();
+
+ ImageFileArrayConst v1 = rIF.getArray();
+ ImageFileArrayConst v2 = rCompareIF.getArray();
+ int nx = rIF.nx();
+ int ny = rIF.ny();
+
+ if (v1 != NULL && xCursor < nx) {
+ double* pX = new double [ny];
+ double* pY1 = new double [ny];
+ double* pY2 = new double [ny];
+ for (int i = 0; i < ny; i++) {
+ pX[i] = i;
+ pY1[i] = v1[xCursor][i];
+ pY2[i] = v2[xCursor][i];
+ }
+ PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
+ if (! pPlotDoc) {
+ sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
+ } else {
+ PlotFile& rPlotFile = pPlotDoc->getPlotFile();
+ std::ostringstream os;
+ os << "Column " << xCursor << " Comparison";
+ std::string title("title ");
+ title += os.str();
+ rPlotFile.addEzsetCommand (title.c_str());
+ rPlotFile.addEzsetCommand ("xlabel Row");
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");
+ rPlotFile.addEzsetCommand ("lxfrac 0");
+ rPlotFile.addEzsetCommand ("curve 1");
+ rPlotFile.addEzsetCommand ("color 2");
+ rPlotFile.addEzsetCommand ("curve 2");
+ rPlotFile.addEzsetCommand ("color 4");
+ rPlotFile.addEzsetCommand ("dash 5");
+ rPlotFile.addEzsetCommand ("box");
+ rPlotFile.addEzsetCommand ("grid");
+ rPlotFile.setCurveSize (3, ny);
+ rPlotFile.addColumn (0, pX);
+ rPlotFile.addColumn (1, pY1);
+ rPlotFile.addColumn (2, pY2);
+
+ unsigned int iL;
+ for (iL = 0; iL < rIF.nLabels(); iL++) {
+ std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
+ s += ": ";
+ s += rIF.labelGet(iL).getLabelString();
+ rPlotFile.addDescription (s.c_str());
+ }
+ for (iL = 0; iL < rCompareIF.nLabels(); iL++) {
+ std::string s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
+ s += ": ";
+ s += rCompareIF.labelGet(iL).getLabelString();
+ rPlotFile.addDescription (s.c_str());
+ }
+ os << " Between " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and "
+ << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
+ *theApp->getLog() << os.str().c_str() << "\n";
+ rPlotFile.addDescription (os.str().c_str());
+ }
+ delete pX;
+ delete pY1;
+ delete pY2;
+ if (theApp->getAskDeleteNewDocs())
+ pPlotDoc->Modify (true);
+ pPlotDoc->getView()->getFrame()->Show(true);
+ pPlotDoc->UpdateAllViews ();
+ pPlotDoc->Activate();
+ }
+ }
+}
+
+void
+ImageFileView::OnCompareRow (wxCommandEvent& event)
+{
+ int xCursor, yCursor;
+ if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
+ wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");
+ return;
+ }
+
+ std::vector<ImageFileDocument*> vecIFDoc;
+ theApp->getCompatibleImages (GetDocument(), vecIFDoc);
+
+ if (vecIFDoc.size() == 0) {
+ wxMessageBox ("No compatible images for Row Comparison", "Error");
+ return;
+ }
+
+ DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Comparison Image", vecIFDoc, false);
+
+ if (dialogGetCompare.ShowModal() == wxID_OK) {
+ ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();
+ const ImageFile& rIF = GetDocument()->getImageFile();
+ const ImageFile& rCompareIF = pCompareDoc->getImageFile();
+
+ ImageFileArrayConst v1 = rIF.getArray();
+ ImageFileArrayConst v2 = rCompareIF.getArray();
+ int nx = rIF.nx();
+ int ny = rIF.ny();
+
+ if (v1 != NULL && yCursor < ny) {
+ double* pX = new double [nx];
+ double* pY1 = new double [nx];
+ double* pY2 = new double [nx];
+ for (int i = 0; i < nx; i++) {
+ pX[i] = i;
+ pY1[i] = v1[i][yCursor];
+ pY2[i] = v2[i][yCursor];
+ }
+ PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
+ if (! pPlotDoc) {
+ sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
+ } else {
+ PlotFile& rPlotFile = pPlotDoc->getPlotFile();
+ std::ostringstream os;
+ os << "Row " << yCursor << " Comparison";
+ std::string title("title ");
+ title += os.str();
+ rPlotFile.addEzsetCommand (title.c_str());
+ rPlotFile.addEzsetCommand ("xlabel Column");
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");
+ rPlotFile.addEzsetCommand ("lxfrac 0");
+ rPlotFile.addEzsetCommand ("curve 1");
+ rPlotFile.addEzsetCommand ("color 2");
+ rPlotFile.addEzsetCommand ("curve 2");
+ rPlotFile.addEzsetCommand ("color 4");
+ rPlotFile.addEzsetCommand ("dash 5");
+ rPlotFile.addEzsetCommand ("box");
+ rPlotFile.addEzsetCommand ("grid");
+ rPlotFile.setCurveSize (3, nx);
+ rPlotFile.addColumn (0, pX);
+ rPlotFile.addColumn (1, pY1);
+ rPlotFile.addColumn (2, pY2);
+ unsigned int iL;
+ for (iL = 0; iL < rIF.nLabels(); iL++) {
+ std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
+ s += ": ";
+ s += rIF.labelGet(iL).getLabelString();
+ rPlotFile.addDescription (s.c_str());
+ }
+ for (iL = 0; iL < rCompareIF.nLabels(); iL++) {
+ std::string s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
+ s += ": ";
+ s += rCompareIF.labelGet(iL).getLabelString();
+ rPlotFile.addDescription (s.c_str());
+ }
+ os << " Between " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and "
+ << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
+ *theApp->getLog() << os.str().c_str() << "\n";
+ rPlotFile.addDescription (os.str().c_str());
+ }
+ delete pX;
+ delete pY1;
+ delete pY2;
+ if (theApp->getAskDeleteNewDocs())
+ pPlotDoc->Modify (true);
+ pPlotDoc->getView()->getFrame()->Show(true);
+ pPlotDoc->UpdateAllViews ();
+ pPlotDoc->Activate();
+ }
+ }
+}
+
+static int NUMBER_HISTOGRAM_BINS = 256;
+
+void
+ImageFileView::OnPlotHistogram (wxCommandEvent& event)
+{
+ const ImageFile& rIF = GetDocument()->getImageFile();
+ ImageFileArrayConst v = rIF.getArray();
+ int nx = rIF.nx();
+ int ny = rIF.ny();
+
+ if (v != NULL && nx > 0 && ny > 0) {
+ PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
+ if (! pPlotDoc) {
+ sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
+ return;
+ }
+
+ double* pX = new double [NUMBER_HISTOGRAM_BINS];
+ double* pY = new double [NUMBER_HISTOGRAM_BINS];
+ double dMin, dMax;
+ rIF.getMinMax (dMin, dMax);
+ double dBinWidth = (dMax - dMin) / NUMBER_HISTOGRAM_BINS;
+
+ for (int i = 0; i < NUMBER_HISTOGRAM_BINS; i++) {
+ pX[i] = dMin + (i + 0.5) * dBinWidth;
+ pY[i] = 0;
+ }
+ for (int ix = 0; ix < nx; ix++)
+ for (int iy = 0; iy < ny; iy++) {
+ int iBin = nearest<int> ((v[ix][iy] - dMin) / dBinWidth);
+ if (iBin >= 0 && iBin < NUMBER_HISTOGRAM_BINS)
+ pY[iBin] += 1;
+ }
+
+ PlotFile& rPlotFile = pPlotDoc->getPlotFile();
+ std::ostringstream os;
+ os << "Histogram";
+ std::string title("title ");
+ title += os.str();
+ rPlotFile.addEzsetCommand (title.c_str());
+ rPlotFile.addEzsetCommand ("xlabel Pixel Value");
+ rPlotFile.addEzsetCommand ("ylabel Count");
+ rPlotFile.addEzsetCommand ("box");
+ rPlotFile.addEzsetCommand ("grid");
+ rPlotFile.setCurveSize (2, NUMBER_HISTOGRAM_BINS);
+ rPlotFile.addColumn (0, pX);
+ rPlotFile.addColumn (1, pY);
+ for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) {
+ std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
+ s += ": ";
+ s += rIF.labelGet(iL).getLabelString();
+ rPlotFile.addDescription (s.c_str());
+ }
+ os << " plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
+ *theApp->getLog() << os.str().c_str() << "\n";
+ rPlotFile.addDescription (os.str().c_str());
+ delete pX;
+ delete pY;
+ if (theApp->getAskDeleteNewDocs())
+ pPlotDoc->Modify (true);
+ pPlotDoc->getView()->getFrame()->Show(true);
+ pPlotDoc->UpdateAllViews ();
+ pPlotDoc->Activate();
+ }
+}
+
+
+// PhantomCanvas
+
+PhantomCanvas::PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
+ : wxScrolledWindow(frame, -1, pos, size, style), m_pView(v)
+{
+}
+
+PhantomCanvas::~PhantomCanvas ()
+{
+ m_pView = NULL;
+}
+
+void
+PhantomCanvas::OnDraw (wxDC& dc)
+{
+ if (m_pView)
+ m_pView->OnDraw(& dc);
+}
+
+wxSize
+PhantomCanvas::GetBestSize() const
+{
+ if (! m_pView)
+ return wxSize(0,0);
+
+ int xSize, ySize;
+ theApp->getMainFrame()->GetClientSize (&xSize, &ySize);
+ xSize = maxValue<int> (xSize, ySize);
+#ifdef CTSIM_MDI
+ ySize = xSize = (xSize / 4);
+#else
+ xSize = ySize = static_cast<int>(ySize * .7);
+#endif
+
+ return wxSize (xSize, ySize);
+}
+
+
+
+// PhantomFileView
+
+IMPLEMENT_DYNAMIC_CLASS(PhantomFileView, wxView)
+
+BEGIN_EVENT_TABLE(PhantomFileView, wxView)
+EVT_MENU(PHMMENU_FILE_PROPERTIES, PhantomFileView::OnProperties)
+EVT_MENU(PHMMENU_PROCESS_RASTERIZE, PhantomFileView::OnRasterize)
+EVT_MENU(PHMMENU_PROCESS_PROJECTIONS, PhantomFileView::OnProjections)
+END_EVENT_TABLE()
+
+PhantomFileView::PhantomFileView()
+: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0)
+{
+#if defined(DEBUG) || defined(_DEBUG)
+ m_iDefaultNDet = 165;
+ m_iDefaultNView = 180;
+ m_iDefaultNSample = 1;
+#else
+ m_iDefaultNDet = 367;
+ m_iDefaultNView = 320;
+ m_iDefaultNSample = 2;
+#endif
+ m_iDefaultOffsetView = 0;
+ m_dDefaultRotation = 1;
+ m_dDefaultFocalLength = 2;
+ m_dDefaultCenterDetectorLength = 2;
+ m_dDefaultViewRatio = 1;
+ m_dDefaultScanRatio = 1;
+ m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL;
+ m_iDefaultTrace = Trace::TRACE_NONE;
+
+#ifdef DEBUG
+ m_iDefaultRasterNX = 115;
+ m_iDefaultRasterNY = 115;
+ m_iDefaultRasterNSamples = 1;
+#else
+ m_iDefaultRasterNX = 256;
+ m_iDefaultRasterNY = 256;
+ m_iDefaultRasterNSamples = 2;
+#endif
+ m_dDefaultRasterViewRatio = 1;
+}
+
+PhantomFileView::~PhantomFileView()
+{
+ GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
+ GetDocumentManager()->ActivateView(this, FALSE, TRUE);
+}
+
+void
+PhantomFileView::OnProperties (wxCommandEvent& event)
+{
+ const int idPhantom = GetDocument()->getPhantomID();
+ const wxString& namePhantom = GetDocument()->getPhantomName();
+ std::ostringstream os;
+ os << "Phantom " << namePhantom.c_str() << " (" << idPhantom << ")" << "\n";
+ const Phantom& rPhantom = GetDocument()->getPhantom();
+ rPhantom.printDefinitions (os);
+#if DEBUG
+ rPhantom.print (os);
+#endif
+ *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<\n";
+ wxMessageBox (os.str().c_str(), "Phantom Properties");
+ GetDocument()->Activate();
+}
+
+
+void
+PhantomFileView::OnProjections (wxCommandEvent& event)
+{
+ DialogGetProjectionParameters dialogProjection (getFrameForChild(),
+ m_iDefaultNDet, m_iDefaultNView, m_iDefaultOffsetView, m_iDefaultNSample, m_dDefaultRotation,
+ m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio,
+ m_iDefaultGeometry, m_iDefaultTrace);
+ int retVal = dialogProjection.ShowModal();
+ if (retVal != wxID_OK)
+ return;
+
+ m_iDefaultNDet = dialogProjection.getNDet();
+ m_iDefaultNView = dialogProjection.getNView();
+ m_iDefaultOffsetView = dialogProjection.getOffsetView();
+ m_iDefaultNSample = dialogProjection.getNSamples();
+ m_iDefaultTrace = dialogProjection.getTrace();
+ m_dDefaultRotation = dialogProjection.getRotAngle();
+ m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio();
+ m_dDefaultCenterDetectorLength = dialogProjection.getCenterDetectorLengthRatio();
+ m_dDefaultViewRatio = dialogProjection.getViewRatio();
+ m_dDefaultScanRatio = dialogProjection.getScanRatio();
+ wxString sGeometry = dialogProjection.getGeometry();
+ m_iDefaultGeometry = Scanner::convertGeometryNameToID (sGeometry.c_str());
+ double dRotationRadians = m_dDefaultRotation;
+ m_dDefaultRotation /= TWOPI; // convert back to fraction of a circle
+
+ if (m_iDefaultNDet <= 0 || m_iDefaultNView <= 0 || sGeometry == "")
+ return;
+
+ const Phantom& rPhantom = GetDocument()->getPhantom();
+ Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultOffsetView, m_iDefaultNSample,
+ dRotationRadians, m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio);
+ if (theScanner.fail()) {
+ wxString msg = "Failed making scanner\n";
+ msg += theScanner.failMessage().c_str();
+ *theApp->getLog() << msg << "\n";
+ wxMessageBox (msg, "Error");
+ return;
+ }
+
+ std::ostringstream os;
+ os << "Projections for " << rPhantom.name()
+ << ": nDet=" << m_iDefaultNDet
+ << ", nView=" << m_iDefaultNView
+ << ", gantry offset=" << m_iDefaultOffsetView
+ << ", nSamples=" << m_iDefaultNSample
+ << ", RotAngle=" << m_dDefaultRotation
+ << ", FocalLengthRatio=" << m_dDefaultFocalLength
+ << ", CenterDetectorLengthRatio=" << m_dDefaultCenterDetectorLength
+ << ", ViewRatio=" << m_dDefaultViewRatio
+ << ", ScanRatio=" << m_dDefaultScanRatio
+ << ", Geometry=" << sGeometry.c_str()
+ << ", FanBeamAngle=" << convertRadiansToDegrees (theScanner.fanBeamAngle());
+
+ Timer timer;
+ Projections* pProj = NULL;
+ if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
+ pProj = new Projections;
+ pProj->initFromScanner (theScanner);
+
+ ProjectionsDialog dialogProjections (theScanner, *pProj, rPhantom, m_iDefaultTrace, dynamic_cast<wxWindow*>(getFrameForChild()));
+ for (int iView = 0; iView < pProj->nView(); iView++) {
+ ::wxYield();
+ if (dialogProjections.isCancelled() || ! dialogProjections.projectView (iView)) {
+ delete pProj;
+ return;
+ }
+ ::wxYield();
+ while (dialogProjections.isPaused()) {
+ ::wxYield();
+ ::wxUsleep(50);
+ }
+ }
+ } else {
+#if HAVE_WXTHREADS
+ if (theApp->getUseBackgroundTasks()) {
+ ProjectorSupervisorThread* pProjector = new ProjectorSupervisorThread (this, m_iDefaultNDet,
+ m_iDefaultNView, m_iDefaultOffsetView, sGeometry.c_str(), m_iDefaultNSample, dRotationRadians,
+ m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio, os.str().c_str());
+ if (pProjector->Create() != wxTHREAD_NO_ERROR) {
+ sys_error (ERR_SEVERE, "Error creating projector thread");
+ delete pProjector;
+ return;
+ }
+ pProjector->SetPriority(60);
+ pProjector->Run();
+ return;
+ } else
+#endif // HAVE_WXTHREADS
+ {
+ pProj = new Projections;
+ pProj->initFromScanner (theScanner);
+ wxProgressDialog dlgProgress (wxString("Projection"), wxString("Projection Progress"), pProj->nView() + 1, getFrameForChild(), wxPD_CAN_ABORT );
+ for (int i = 0; i < pProj->nView(); i++) {
+ //theScanner.collectProjections (*pProj, rPhantom, i, 1, true, m_iDefaultTrace);
+ theScanner.collectProjections (*pProj, rPhantom, i, 1, theScanner.offsetView(), true, m_iDefaultTrace);
+ if ((i + 1) % ITER_PER_UPDATE == 0)
+ if (! dlgProgress.Update (i+1)) {
+ delete pProj;
+ return;
+ }
+ }
+ }
+ }
+
+ *theApp->getLog() << os.str().c_str() << "\n";
+ pProj->setRemark (os.str());
+ pProj->setCalcTime (timer.timerEnd());
+
+ ProjectionFileDocument* pProjectionDoc = theApp->newProjectionDoc();
+ if (! pProjectionDoc) {
+ sys_error (ERR_SEVERE, "Unable to create projection document");
+ return;
+ }
+ pProjectionDoc->setProjections (pProj);
+ if (theApp->getAskDeleteNewDocs())
+ pProjectionDoc-> Modify(true);
+ pProjectionDoc->UpdateAllViews (this);
+ pProjectionDoc->getView()->setInitialClientSize();
+ pProjectionDoc->Activate();
+}
+
+
+void
+PhantomFileView::OnRasterize (wxCommandEvent& event)
+{
+ DialogGetRasterParameters dialogRaster (getFrameForChild(), m_iDefaultRasterNX, m_iDefaultRasterNY,
+ m_iDefaultRasterNSamples, m_dDefaultRasterViewRatio);
+ int retVal = dialogRaster.ShowModal();
+ if (retVal != wxID_OK)
+ return;
+
+ m_iDefaultRasterNX = dialogRaster.getXSize();
+ m_iDefaultRasterNY = dialogRaster.getYSize();
+ m_iDefaultRasterNSamples = dialogRaster.getNSamples();
+ m_dDefaultRasterViewRatio = dialogRaster.getViewRatio();
+ if (m_iDefaultRasterNSamples < 1)
+ m_iDefaultRasterNSamples = 1;
+ if (m_dDefaultRasterViewRatio < 0)
+ m_dDefaultRasterViewRatio = 0;
+ if (m_iDefaultRasterNX <= 0 || m_iDefaultRasterNY <= 0)
+ return;
+
+ const Phantom& rPhantom = GetDocument()->getPhantom();
+ std::ostringstream os;
+ os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << m_iDefaultRasterNX << ", YSize="
+ << m_iDefaultRasterNY << ", ViewRatio=" << m_dDefaultRasterViewRatio << ", nSamples="
+ << m_iDefaultRasterNSamples;;
+
+#if HAVE_WXTHREADS
+ if (theApp->getUseBackgroundTasks()) {
+ RasterizerSupervisorThread* pThread = new RasterizerSupervisorThread (this, m_iDefaultRasterNX, m_iDefaultRasterNY,
+ m_iDefaultRasterNSamples, m_dDefaultRasterViewRatio, os.str().c_str());
+ if (pThread->Create() != wxTHREAD_NO_ERROR) {
+ *theApp->getLog() << "Error creating rasterizer thread\n";
+ return;
+ }
+ pThread->SetPriority (60);
+ pThread->Run();
+ } else
+#endif
+ {
+ ImageFile* pImageFile = new ImageFile (m_iDefaultRasterNX, m_iDefaultRasterNY);
+
+ wxProgressDialog dlgProgress (wxString("Rasterize"),
+ wxString("Rasterization Progress"),
+ pImageFile->nx() + 1,
+ getFrameForChild(),
+ wxPD_CAN_ABORT );
+ Timer timer;
+ for (unsigned int i = 0; i < pImageFile->nx(); i++) {
+ rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio,
+ m_iDefaultRasterNSamples, Trace::TRACE_NONE,
+ i, 1, true);
+ if ((i + 1) % ITER_PER_UPDATE == 0)
+ if (! dlgProgress.Update (i+1)) {
+ delete pImageFile;
+ return;
+ }
+ }
+
+ ImageFileDocument* pRasterDoc = theApp->newImageDoc();
+ if (! pRasterDoc) {
+ sys_error (ERR_SEVERE, "Unable to create image file");
+ return;
+ }
+ pRasterDoc->setImageFile (pImageFile);
+ if (theApp->getAskDeleteNewDocs())
+ pRasterDoc->Modify (true);
+ *theApp->getLog() << os.str().c_str() << "\n";
+ pImageFile->labelAdd (os.str().c_str(), timer.timerEnd());
+
+ pRasterDoc->UpdateAllViews(this);
+ pRasterDoc->getView()->setInitialClientSize();
+ pRasterDoc->Activate();
+ }
+}
+
+
+PhantomCanvas*
+PhantomFileView::CreateCanvas (wxFrame *parent)
+{
+ PhantomCanvas* pCanvas = new PhantomCanvas (this, parent, wxPoint(-1,-1),
+ wxSize(-1,-1), 0);
+ pCanvas->SetBackgroundColour(*wxWHITE);
+ pCanvas->Clear();
+
+ return pCanvas;
+}
+
+#if CTSIM_MDI
+wxDocMDIChildFrame*
+#else
+wxDocChildFrame*
+#endif
+PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
+{
+#if CTSIM_MDI
+ wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
+#else
+ wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
+#endif
+ theApp->setIconForFrame (subframe);
+
+ m_pFileMenu = new wxMenu;
+
+ m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
+ m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
+ m_pFileMenu->Append(wxID_OPEN, "&Open...\tCtrl-O");
+ m_pFileMenu->Append(wxID_SAVEAS, "Save &As...");
+ m_pFileMenu->Append(wxID_CLOSE, "&Close");
+
+ m_pFileMenu->AppendSeparator();
+ m_pFileMenu->Append(PHMMENU_FILE_PROPERTIES, "P&roperties\tCtrl-I");
+
+ m_pFileMenu->AppendSeparator();
+ m_pFileMenu->Append(wxID_PRINT, "&Print...");
+ m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
+ m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
+ m_pFileMenu->AppendSeparator();
+ m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
+#ifdef CTSIM_MDI
+ m_pFileMenu->AppendSeparator();
+ m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
+ m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
+#endif
+ GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
+ GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
+
+ wxMenu *process_menu = new wxMenu;
+ process_menu->Append(PHMMENU_PROCESS_RASTERIZE, "&Rasterize...\tCtrl-R");
+ process_menu->Append(PHMMENU_PROCESS_PROJECTIONS, "&Projections...\tCtrl-J");
+
+ wxMenu *help_menu = new wxMenu;
+ help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
+ help_menu->Append (MAINMENU_HELP_TIPS, "&Tips");
+ help_menu->Append (IDH_QUICKSTART, "&Quick Start");
+ help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
+
+ wxMenuBar *menu_bar = new wxMenuBar;
+
+ menu_bar->Append(m_pFileMenu, "&File");
+ menu_bar->Append(process_menu, "&Process");
+ menu_bar->Append(help_menu, "&Help");
+
+ subframe->SetMenuBar(menu_bar);
+ subframe->Centre(wxBOTH);
+
+ wxAcceleratorEntry accelEntries[3];
+ accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('J'), PHMMENU_PROCESS_PROJECTIONS);
+ accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('R'), PHMMENU_PROCESS_RASTERIZE);
+ accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('I'), PHMMENU_FILE_PROPERTIES);
+ wxAcceleratorTable accelTable (3, accelEntries);
+ subframe->SetAcceleratorTable (accelTable);
+
+ return subframe;