X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fviews.cpp;h=c1debac9f66427f8f1718f5113e8791f75876840;hb=c5e7140bd08b8c8f527713e8dc861bcb7ee5f633;hp=a41efaa2fd91a3b5f6a66a53ee079f09cece6d51;hpb=806a6ed49930ae2bd8028eb7e3ffb79f017ef7f1;p=ctsim.git diff --git a/src/views.cpp b/src/views.cpp index a41efaa..c1debac 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: views.cpp,v 1.97 2001/02/03 18:42:21 kevin Exp $ +** $Id: views.cpp,v 1.99 2001/02/08 06:25:07 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -1766,6 +1766,20 @@ PhantomCanvas::OnDraw (wxDC& dc) 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 (xSize, ySize); + ySize = xSize = (xSize / 3); + return wxSize (xSize, ySize); +} + + // PhantomFileView @@ -1790,7 +1804,8 @@ PhantomFileView::PhantomFileView() m_iDefaultNSample = 1; m_dDefaultRotation = 1; m_dDefaultFocalLength = 2; - m_dDefaultFieldOfView = 1; + m_dDefaultViewRatio = 1; + m_dDefaultScanRatio = 1; m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL; m_iDefaultTrace = Trace::TRACE_NONE; @@ -1803,6 +1818,7 @@ PhantomFileView::PhantomFileView() m_iDefaultRasterNY = 256; m_iDefaultRasterNSamples = 2; #endif + m_dDefaultRasterViewRatio = 1; } PhantomFileView::~PhantomFileView() @@ -1831,7 +1847,10 @@ PhantomFileView::OnProperties (wxCommandEvent& event) void PhantomFileView::OnProjections (wxCommandEvent& event) { - DialogGetProjectionParameters dialogProjection (getFrameForChild(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView, m_iDefaultGeometry, m_iDefaultTrace); + DialogGetProjectionParameters dialogProjection (getFrameForChild(), + m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, + m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio, m_iDefaultGeometry, + m_iDefaultTrace); int retVal = dialogProjection.ShowModal(); if (retVal == wxID_OK) { m_iDefaultNDet = dialogProjection.getNDet(); @@ -1840,7 +1859,8 @@ PhantomFileView::OnProjections (wxCommandEvent& event) m_iDefaultTrace = dialogProjection.getTrace(); m_dDefaultRotation = dialogProjection.getRotAngle(); m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio(); - m_dDefaultFieldOfView = dialogProjection.getFieldOfViewRatio(); + m_dDefaultViewRatio = dialogProjection.getViewRatio(); + m_dDefaultScanRatio = dialogProjection.getScanRatio(); wxString sGeometry = dialogProjection.getGeometry(); m_iDefaultGeometry = Scanner::convertGeometryNameToID (sGeometry.c_str()); @@ -1848,9 +1868,12 @@ PhantomFileView::OnProjections (wxCommandEvent& event) const Phantom& rPhantom = GetDocument()->getPhantom(); Projections* pProj = new Projections; Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, - m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView); + m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio); if (theScanner.fail()) { - *theApp->getLog() << "Failed making scanner: " << theScanner.failMessage().c_str() << "\n"; + wxString msg = "Failed making scanner\n"; + msg += theScanner.failMessage().c_str(); + *theApp->getLog() << msg << "\n"; + wxMessageBox (msg, "Error"); return; } pProj->initFromScanner (theScanner); @@ -1883,7 +1906,12 @@ PhantomFileView::OnProjections (wxCommandEvent& event) } std::ostringstream os; - os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength << ", FieldOfViewRatio=" << m_dDefaultFieldOfView << ", Geometry=" << sGeometry.c_str(); + os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet + << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample + << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength + << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio + << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << + convertRadiansToDegrees (theScanner.fanBeamAngle()); pProj->setCalcTime (timer.timerEnd()); pProj->setRemark (os.str()); *theApp->getLog() << os.str().c_str() << "\n"; @@ -1918,14 +1946,18 @@ PhantomFileView::OnProjections (wxCommandEvent& event) void PhantomFileView::OnRasterize (wxCommandEvent& event) { - DialogGetRasterParameters dialogRaster (getFrameForChild(), m_iDefaultRasterNX, m_iDefaultRasterNY, m_iDefaultRasterNSamples); + DialogGetRasterParameters dialogRaster (getFrameForChild(), m_iDefaultRasterNX, m_iDefaultRasterNY, + m_iDefaultRasterNSamples, m_dDefaultRasterViewRatio); int retVal = dialogRaster.ShowModal(); if (retVal == wxID_OK) { 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) { const Phantom& rPhantom = GetDocument()->getPhantom(); @@ -1936,7 +1968,8 @@ PhantomFileView::OnRasterize (wxCommandEvent& event) pImageFile->nx() + 1, getFrameForChild(), wxPD_CAN_ABORT); Timer timer; for (unsigned int i = 0; i < pImageFile->nx(); i++) { - rPhantom.convertToImagefile (*pImageFile, m_iDefaultRasterNSamples, Trace::TRACE_NONE, i, 1, true); + rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio, m_iDefaultRasterNSamples, + Trace::TRACE_NONE, i, 1, true); if (! dlgProgress.Update (i+1)) { delete pImageFile; return; @@ -1955,7 +1988,8 @@ PhantomFileView::OnRasterize (wxCommandEvent& event) pRasterDoc->getView()->getFrame()->Show(true); std::ostringstream os; os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << m_iDefaultRasterNX << ", YSize=" - << m_iDefaultRasterNY << ", nSamples=" << m_iDefaultRasterNSamples; + << m_iDefaultRasterNY << ", ViewRatio=" << m_dDefaultRasterViewRatio << ", nSamples=" + << m_iDefaultRasterNSamples;; *theApp->getLog() << os.str().c_str() << "\n"; pImageFile->labelAdd (os.str().c_str(), timer.timerEnd()); ImageFileView* rasterView = pRasterDoc->getView(); @@ -1973,11 +2007,8 @@ PhantomCanvas* PhantomFileView::CreateCanvas (wxFrame *parent) { PhantomCanvas* pCanvas; - int width, height; - parent->GetClientSize(&width, &height); - - pCanvas = new PhantomCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0); + pCanvas = new PhantomCanvas (this, parent, wxPoint(0, 0), wxSize(0,0), 0); pCanvas->SetBackgroundColour(*wxWHITE); pCanvas->Clear(); @@ -1992,9 +2023,9 @@ wxDocChildFrame* PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view) { #if CTSIM_MDI - wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE); + wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE); #else - wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE); + wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE); #endif theApp->setIconForFrame (subframe); @@ -2059,11 +2090,11 @@ PhantomFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { m_pFrame = CreateChildFrame(doc, this); SetFrame(m_pFrame); - - int width, height; - m_pFrame->GetClientSize(&width, &height); - m_pFrame->SetTitle("PhantomFileView"); m_pCanvas = CreateCanvas (m_pFrame); + m_pFrame->SetClientSize (m_pCanvas->GetBestSize()); + m_pCanvas->SetClientSize (m_pCanvas->GetBestSize()); + + m_pFrame->SetTitle ("PhantomFileView"); #ifdef __X__ int x, y; // X requires a forced resize @@ -2169,7 +2200,7 @@ EVT_MENU(PJMENU_CONVERT_FFT_POLAR, ProjectionFileView::OnConvertFFTPolar) END_EVENT_TABLE() ProjectionFileView::ProjectionFileView() -: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0) +: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0) { #ifdef DEBUG m_iDefaultNX = 115;