** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.154 2002/05/05 05:31:16 kevin Exp $
+** $Id$
**
** 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
}
ImageFileCanvas::~ImageFileCanvas()
-{
- m_pView = NULL;
-}
+{}
void
ImageFileCanvas::OnDraw(wxDC& dc)
if (m_pView)
m_pView->OnUpdate (NULL);
} else
- wxScrolledWindow::OnChar (event);
+ event.Skip();
}
wxSize
ImageFileCanvas::GetBestSize() const
{
- if (! m_pView)
- return wxSize(0,0);
+ const int iMinX = 50;
+ const int iMinY = 20;
+ wxSize bestSize (iMinX,iMinY);
+
+ if (m_pView) {
+ const ImageFile& rIF = m_pView->GetDocument()->getImageFile();
+ bestSize.Set (rIF.nx(), rIF.ny());
+ }
+
+ if (bestSize.x > 800)
+ bestSize.x = 800;
+ if (bestSize.y > 800)
+ bestSize.y = 800;
- const ImageFile& rIF = m_pView->GetDocument()->getImageFile();
- return wxSize (rIF.nx(), rIF.ny());
+ if (bestSize.y < iMinY)
+ bestSize.y = iMinY;
+ if (bestSize.x < iMinX)
+ bestSize.x = iMinX;
+
+ return bestSize;
}
END_EVENT_TABLE()
ImageFileView::ImageFileView()
-: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0), m_pFilterMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
-{
- m_iDefaultExportFormatID = ImageFile::EXPORT_FORMAT_PNG;
-}
+ : wxView(), m_pBitmap(0), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0),
+ m_pFilterMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false),
+ m_iDefaultExportFormatID(ImageFile::EXPORT_FORMAT_PNG)
+{}
ImageFileView::~ImageFileView()
{
m_dMinPixel = dMin;
m_dMaxPixel = dMax;
m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
}
}
m_bMaxSpecified = true;
m_dMinPixel = dialogMinMax.getMinimum();
m_dMaxPixel = dialogMinMax.getMaximum();
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
}
GetDocument()->Activate();
if (m_bMinSpecified || m_bMaxSpecified) {
m_bMinSpecified = false;
m_bMaxSpecified = false;
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
}
GetDocument()->Activate();
pDifferenceImage->labelAdd (os.str().c_str());
if (theApp->getAskDeleteNewDocs())
pDifferenceDoc->Modify (true);
+ OnUpdate(this, NULL);
pDifferenceDoc->UpdateAllViews(this);
pDifferenceDoc->getView()->setInitialClientSize();
pDifferenceDoc->Activate();
rIF.labelAdd ("Invert Pixel Values");
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
rIF.labelAdd ("Square Pixel Values");
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
rIF.labelAdd ("Square-root Pixel Values");
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
rIF.labelAdd ("Logrithm base-e Pixel Values");
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
rIF.labelAdd ("Exponent base-e Pixel Values");
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
*theApp->getLog() << os.str().c_str() << "\n";
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
+ OnUpdate(this, NULL);
pNewDoc->UpdateAllViews (this);
pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
*theApp->getLog() << os.str().c_str() << "\n";
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
+ OnUpdate(this, NULL);
pNewDoc->UpdateAllViews (this);
pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
*theApp->getLog() << os.str().c_str() << "\n";
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
+ OnUpdate(this, NULL);
pNewDoc->UpdateAllViews (this);
pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
*theApp->getLog() << os.str().c_str() << "\n";
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
+ OnUpdate(this, NULL);
pNewDoc->UpdateAllViews (this);
pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
GetDocument()->Activate();
}
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
}
GetDocument()->Activate();
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
}
GetDocument()->Activate();
m_bMaxSpecified = false;
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
+ OnUpdate(this, NULL);
GetDocument()->UpdateAllViews (this);
}
GetDocument()->Activate();
ImageFileCanvas*
ImageFileView::CreateCanvas (wxFrame* parent)
{
- ImageFileCanvas* pCanvas;
- int width, height;
- parent->GetClientSize(&width, &height);
-
- pCanvas = new ImageFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
-
- pCanvas->SetScrollbars(20, 20, 50, 50);
+ ImageFileCanvas* pCanvas = new ImageFileCanvas (this, parent, wxPoint(-1,-1),
+ wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile 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_PREVIEW, "Print Preview");
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);
#if wxUSE_GLCANVAS
accelEntries[iEntry++].Set (wxACCEL_CTRL, static_cast<int>('3'), IFMENU_IMAGE_CONVERT3D);
#endif
+
wxAcceleratorTable accelTable (iEntry, accelEntries);
-
subframe->SetAcceleratorTable (accelTable);
return subframe;
bool
ImageFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
- m_pFrame = CreateChildFrame(doc, this);
-
m_bMinSpecified = false;
m_bMaxSpecified = false;
m_dAutoScaleFactor = 1.;
- // int width, height;
- // m_pFrame->GetClientSize (&width, &height);
- m_pFrame->SetTitle("ImageFileView");
+ m_pFrame = CreateChildFrame(doc, this);
+ SetFrame (m_pFrame);
m_pCanvas = CreateCanvas (m_pFrame);
-
- // int x, y; // X requires a forced resize
- // m_pFrame->GetSize(&x, &y);
- // m_pFrame->SetSize(-1, -1, x, y);
- m_pFrame->SetFocus();
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle("ImageFileView");
+
m_pFrame->Show(true);
- // Activate(true);
+ Activate(true);
return true;
}
{
if (m_pFrame && m_pCanvas) {
wxSize bestSize = m_pCanvas->GetBestSize();
-
- if (bestSize.x > 800)
- bestSize.x = 800;
- if (bestSize.y > 800)
- bestSize.y = 800;
m_pFrame->SetClientSize (bestSize);
m_pFrame->Show (true);
void
ImageFileView::OnDraw (wxDC* dc)
{
- if (m_bitmap.Ok())
- dc->DrawBitmap(m_bitmap, 0, 0, false);
+ if (m_pBitmap && m_pBitmap->Ok()) {
+#ifdef DEBUG
+ *theApp->getLog() << "Drawing bitmap\n";
+#endif
+ dc->DrawBitmap(*m_pBitmap, 0, 0, false);
+ }
int xCursor, yCursor;
if (m_pCanvas->GetCurrentCursor (xCursor, yCursor))
}
}
wxImage image (nx, ny, imageData, true);
- m_bitmap = image.ConvertToBitmap();
+ if (m_pBitmap) {
+ delete m_pBitmap;
+ m_pBitmap = NULL;
+ }
+#ifdef DEBUG
+ *theApp->getLog() << "Making new bitmap\n";
+#endif
+ m_pBitmap = new wxBitmap (image);
delete imageData;
m_pCanvas->SetScrollbars(20, 20, nx/20, ny/20);
m_pCanvas->SetBackgroundColour(*wxWHITE);
bool
ImageFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
ImageFileView::OnEditCopy (wxCommandEvent& event)
{
wxBitmapDataObject *pBitmapObject = new wxBitmapDataObject;
-
- pBitmapObject->SetBitmap (m_bitmap);
+
+ if (m_pBitmap)
+ pBitmapObject->SetBitmap (*m_pBitmap);
if (wxTheClipboard->Open()) {
wxTheClipboard->SetData (pBitmapObject);
bool bMonochrome = false;
if (bitmap.Ok() == true && bitmap.GetWidth() == nx && bitmap.GetHeight() == ny) {
- wxImage image (bitmap);
+ wxImage image (bitmap.ConvertToImage());
double dScale3 = 3 * 255;
unsigned char* pixels = image.GetData();
ImageFileArray v = rIF.getArray();
*theApp->getLog() << os.str().c_str() << "\n";
if (theApp->getAskDeleteNewDocs())
pScaledDoc->Modify (true);
+ OnUpdate(this, NULL);
pScaledDoc->UpdateAllViews (this);
pScaledDoc->getView()->setInitialClientSize();
pScaledDoc->Activate();
{
ImageFile& rIF = GetDocument()->getImageFile();
Graph3dFileDocument* pGraph3d = theApp->newGraph3dDoc();
+ pGraph3d->getView()->getFrame()->Show (false);
pGraph3d->setBadFileOpen();
pGraph3d->createFromImageFile (rIF);
- pGraph3d->getView()->OnUpdate (this, NULL);
pGraph3d->UpdateAllViews();
- pGraph3d->getView()->getFrame()->SetClientSize (400, 400);
pGraph3d->getView()->getFrame()->Show (true);
- GetDocumentManager()->ActivateView (pGraph3d->getView(), true, false);
+ pGraph3d->getView()->Activate(true);
::wxYield();
pGraph3d->getView()->getCanvas()->SetFocus();
}
int ny = rIF.ny();
if (v != NULL && yCursor < ny) {
- fftw_complex* pcIn = new fftw_complex [nx];
+ fftw_complex* pcIn = static_cast<fftw_complex*>(fftw_malloc (sizeof(fftw_complex) * nx));
int i;
for (i = 0; i < nx; i++) {
- pcIn[i].re = v[i][yCursor];
+ pcIn[i][0] = v[i][yCursor];
if (rIF.isComplex())
- pcIn[i].im = vImag[i][yCursor];
+ pcIn[i][1] = vImag[i][yCursor];
else
- pcIn[i].im = 0;
+ pcIn[i][1] = 0;
}
- fftw_plan plan = fftw_create_plan (nx, FFTW_FORWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM);
- fftw_one (plan, pcIn, NULL);
+ fftw_plan plan = fftw_plan_dft_1d (nx, pcIn, pcIn, FFTW_FORWARD, FFTW_ESTIMATE);
+ fftw_execute (plan);
fftw_destroy_plan (plan);
double* pX = new double [nx];
double* pYMag = new double [nx];
for (i = 0; i < nx; i++) {
pX[i] = i;
- pYReal[i] = pcIn[i].re / nx;
- pYImag[i] = pcIn[i].im / nx;
- pYMag[i] = ::sqrt (pcIn[i].re * pcIn[i].re + pcIn[i].im * pcIn[i].im);
+ pYReal[i] = pcIn[i][0] / nx;
+ pYImag[i] = pcIn[i][1] / nx;
+ pYMag[i] = ::sqrt (pcIn[i][0] * pcIn[i][0] + pcIn[i][1] * pcIn[i][1]);
}
Fourier::shuffleFourierToNaturalOrder (pYReal, nx);
Fourier::shuffleFourierToNaturalOrder (pYImag, nx);
delete pYReal;
delete pYImag;
delete pYMag;
- delete [] pcIn;
+ fftw_free(pcIn);
if (theApp->getAskDeleteNewDocs())
pPlotDoc->Modify (true);
pdTemp[i] = v[xCursor][i];
Fourier::shuffleNaturalToFourierOrder (pdTemp, ny);
for (i = 0; i < ny; i++)
- pcIn[i].re = pdTemp[i];
+ pcIn[i][0] = pdTemp[i];
for (i = 0; i < ny; i++) {
if (rIF.isComplex())
}
Fourier::shuffleNaturalToFourierOrder (pdTemp, ny);
for (i = 0; i < ny; i++)
- pcIn[i].im = pdTemp[i];
+ pcIn[i][1] = pdTemp[i];
- fftw_plan plan = fftw_create_plan (ny, FFTW_BACKWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM);
- fftw_one (plan, pcIn, NULL);
+ fftw_plan plan = fftw_plan_dft_1d (ny, pcIn, pcIn, FFTW_BACKWARD, FFTW_ESTIMATE);
+ fftw_execute (plan);
fftw_destroy_plan (plan);
double* pX = new double [ny];
double* pYMag = new double [ny];
for (i = 0; i < ny; i++) {
pX[i] = i;
- pYReal[i] = pcIn[i].re / ny;
- pYImag[i] = pcIn[i].im / ny;
- pYMag[i] = ::sqrt (pcIn[i].re * pcIn[i].re + pcIn[i].im * pcIn[i].im);
+ pYReal[i] = pcIn[i][0] / ny;
+ pYImag[i] = pcIn[i][1] / ny;
+ pYMag[i] = ::sqrt (pcIn[i][0] * pcIn[i][0] + pcIn[i][1] * pcIn[i][1]);
}
PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
// PhantomCanvas
PhantomCanvas::PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
-: wxScrolledWindow(frame, -1, pos, size, style)
+ : wxScrolledWindow(frame, -1, pos, size, style), m_pView(v)
{
- m_pView = v;
}
PhantomCanvas::~PhantomCanvas ()
#ifdef CTSIM_MDI
ySize = xSize = (xSize / 4);
#else
- ySize = xSize;
+ xSize = ySize = static_cast<int>(ySize * .7);
#endif
+
return wxSize (xSize, ySize);
}
pProjectionDoc->setProjections (pProj);
if (theApp->getAskDeleteNewDocs())
pProjectionDoc-> Modify(true);
+ OnUpdate(this, NULL);
pProjectionDoc->UpdateAllViews (this);
pProjectionDoc->getView()->setInitialClientSize();
pProjectionDoc->Activate();
PhantomCanvas*
PhantomFileView::CreateCanvas (wxFrame *parent)
{
- PhantomCanvas* pCanvas;
-
- pCanvas = new PhantomCanvas (this, parent, wxPoint(0, 0), wxSize(0,0), 0);
+ PhantomCanvas* pCanvas = new PhantomCanvas (this, parent, wxPoint(-1,-1),
+ wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ 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(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ 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->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);
bool
PhantomFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
wxSize
ProjectionFileCanvas::GetBestSize () const
{
- wxSize best (0, 0);
- if (! m_pView)
- return best;
+ const int iMinX = 50;
+ const int iMinY = 20;
+ wxSize bestSize (iMinX,iMinY);
if (m_pView) {
Projections& rProj = m_pView->GetDocument()->getProjections();
- best.Set (rProj.nDet(), rProj.nView());
+ bestSize.Set (rProj.nDet(), rProj.nView());
}
- return best;
+ if (bestSize.x > 800)
+ bestSize.x = 800;
+ if (bestSize.y > 800)
+ bestSize.y = 800;
+
+ if (bestSize.x < iMinX)
+ bestSize.x = iMinX;
+ if (bestSize.y < iMinY)
+ bestSize.y = iMinY;
+
+ return bestSize;
}
ProjectionFileView::ProjectionFileView()
-: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0)
+ : wxView(), m_pBitmap(0), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0)
{
#ifdef DEBUG
m_iDefaultNX = 115;
m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_CONVOLUTION;
m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_DIRECT;
#endif
- m_iDefaultZeropad = 1;
+ m_iDefaultZeropad = 2;
m_iDefaultBackprojector = Backprojector::BPROJ_IDIFF;
m_iDefaultInterpolation = Backprojector::INTERP_LINEAR;
m_iDefaultInterpParam = 1;
m_iDefaultPolarNX = 256;
m_iDefaultPolarNY = 256;
m_iDefaultPolarInterpolation = Projections::POLAR_INTERP_BILINEAR;
- m_iDefaultPolarZeropad = 1;
+ m_iDefaultPolarZeropad = 2;
}
ProjectionFileView::~ProjectionFileView()
wxString strInterpolation (dialogPolar.getInterpolationName());
m_iDefaultPolarNX = dialogPolar.getXSize();
m_iDefaultPolarNY = dialogPolar.getYSize();
- ImageFileDocument* pPolarDoc = theApp->newImageDoc();
ImageFile* pIF = new ImageFile (m_iDefaultPolarNX, m_iDefaultPolarNY);
m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str());
return;
}
- pPolarDoc = theApp->newImageDoc ();
+ ImageFileDocument* pPolarDoc = theApp->newImageDoc();
if (! pPolarDoc) {
sys_error (ERR_SEVERE, "Unable to create image file");
return;
int width, height;
parent->GetClientSize(&width, &height);
- pCanvas = new ProjectionFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
+ pCanvas = new ProjectionFileCanvas (this, parent, wxPoint(-1,-1), wxSize(width, height), 0);
pCanvas->SetScrollbars(20, 20, 50, 50);
pCanvas->SetBackgroundColour(*wxWHITE);
ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#ifdef CTSIM_MDI
- wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
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 *convert_menu = new wxMenu;
- convert_menu->Append (PJMENU_CONVERT_RECTANGULAR, "&Rectangular Image");
- convert_menu->Append (PJMENU_CONVERT_POLAR, "&Polar Image...\tCtrl-L");
- convert_menu->Append (PJMENU_CONVERT_FFT_POLAR, "FF&T->Polar Image...\tCtrl-T");
- convert_menu->AppendSeparator();
- convert_menu->Append (PJMENU_CONVERT_PARALLEL, "&Interpolate to Parallel");
+ m_pConvertMenu = new wxMenu;
+ m_pConvertMenu->Append (PJMENU_CONVERT_RECTANGULAR, "&Rectangular Image");
+ m_pConvertMenu->Append (PJMENU_CONVERT_POLAR, "&Polar Image...\tCtrl-L");
+ m_pConvertMenu->Append (PJMENU_CONVERT_FFT_POLAR, "FF&T->Polar Image...\tCtrl-T");
+ m_pConvertMenu->AppendSeparator();
+ m_pConvertMenu->Append (PJMENU_CONVERT_PARALLEL, "&Interpolate to Parallel");
// wxMenu* filter_menu = new wxMenu;
// filter_menu->Append (PJMENU_ARTIFACT_REDUCTION, "&Artifact Reduction");
analyze_menu->Append (PJMENU_PLOT_HISTOGRAM, "&Plot Histogram");
analyze_menu->Append (PJMENU_PLOT_TTHETA_SAMPLING, "Plot T-T&heta Sampling...\tCtrl-H");
- wxMenu *reconstruct_menu = new wxMenu;
- reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection");
- reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP_REBIN, "Filtered &Backprojection (Rebin to Parallel)...\tCtrl-B", "Reconstruct image using filtered backprojection");
- // still buggy
- // reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier");
+ m_pReconstructMenu = new wxMenu;
+ m_pReconstructMenu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection");
+ m_pReconstructMenu->Append (PJMENU_RECONSTRUCT_FBP_REBIN, "Filtered &Backprojection (Rebin to Parallel)...\tCtrl-B", "Reconstruct image using filtered backprojection");
+ m_pReconstructMenu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Inverse Fourier...\tCtrl-E", "Direct inverse Fourier");
wxMenu *help_menu = new wxMenu;
help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append (m_pFileMenu, "&File");
- menu_bar->Append (convert_menu, "&Convert");
+ menu_bar->Append (m_pConvertMenu, "&Convert");
// menu_bar->Append (filter_menu, "Fi<er");
menu_bar->Append (analyze_menu, "&Analyze");
- menu_bar->Append (reconstruct_menu, "&Reconstruct");
+ menu_bar->Append (m_pReconstructMenu, "&Reconstruct");
menu_bar->Append (help_menu, "&Help");
subframe->SetMenuBar(menu_bar);
{
m_pFrame = CreateChildFrame(doc, this);
SetFrame(m_pFrame);
-
- int width, height;
- m_pFrame->GetClientSize (&width, &height);
- m_pFrame->SetTitle ("ProjectionFileView");
m_pCanvas = CreateCanvas (m_pFrame);
-
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle ("ProjectionFileView");
+
m_pFrame->Show(true);
Activate(true);
void
ProjectionFileView::OnDraw (wxDC* dc)
{
- if (m_bitmap.Ok())
- dc->DrawBitmap (m_bitmap, 0, 0, false);
+ if (m_pBitmap && m_pBitmap->Ok())
+ dc->DrawBitmap (*m_pBitmap, 0, 0, false);
}
void
ProjectionFileView::setInitialClientSize ()
{
- wxSize bestSize = m_pCanvas->GetBestSize();
-
- if (bestSize.x > 800)
- bestSize.x = 800;
- if (bestSize.y > 800)
- bestSize.y = 800;
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
- m_pFrame->SetClientSize (bestSize);
- m_pFrame->Show (true);
- m_pFrame->SetFocus();
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
}
void
const Projections& rProj = GetDocument()->getProjections();
const int nDet = rProj.nDet();
const int nView = rProj.nView();
+ if (rProj.geometry() == Scanner::GEOMETRY_PARALLEL) {
+ m_pReconstructMenu->Enable (PJMENU_RECONSTRUCT_FBP_REBIN, false);
+ m_pConvertMenu->Enable (PJMENU_CONVERT_PARALLEL, false);
+ } else {
+ m_pReconstructMenu->Enable (PJMENU_RECONSTRUCT_FBP_REBIN, true);
+ m_pConvertMenu->Enable (PJMENU_CONVERT_PARALLEL, true);
+ }
+
if (nDet != 0 && nView != 0) {
const DetectorArray& detarray = rProj.getDetectorArray(0);
const DetectorValue* detval = detarray.detValues();
}
}
wxImage image (nDet, nView, imageData, true);
- m_bitmap = image.ConvertToBitmap();
+ if (m_pBitmap) {
+ delete m_pBitmap;
+ m_pBitmap = NULL;
+ }
+ m_pBitmap = new wxBitmap (image);
delete imageData;
}
// PlotFileCanvas
PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
-: wxScrolledWindow(frame, -1, pos, size, style)
+ : wxScrolledWindow(frame, -1, pos, size, style), m_pView(v)
{
- m_pView = v;
}
-wxSize
-PlotFileCanvas::GetBestSize() const
+PlotFileCanvas::~PlotFileCanvas ()
{
- 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
- ySize = xSize;
-#endif
- return wxSize (xSize, ySize);
}
-PlotFileCanvas::~PlotFileCanvas ()
+wxSize
+PlotFileCanvas::GetBestSize() const
{
- m_pView = NULL;
+ return wxSize (500, 300);
}
+
void
PlotFileCanvas::OnDraw(wxDC& dc)
{
END_EVENT_TABLE()
PlotFileView::PlotFileView()
-: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pEZPlot(NULL), m_pFileMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
+: wxView(), m_pFrame(0), m_pCanvas(0), m_pEZPlot(0), m_pFileMenu(0),
+ m_bMinSpecified(false), m_bMaxSpecified(false)
{
}
delete m_pEZPlot;
GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
+ GetDocumentManager()->ActivateView(this, FALSE, TRUE);
}
void
PlotFileView::CreateCanvas (wxFrame* parent)
{
PlotFileCanvas* pCanvas;
- int width, height;
- parent->GetClientSize(&width, &height);
-
- pCanvas = new PlotFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
+ pCanvas = new PlotFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#ifdef CTSIM_MDI
- wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
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);
bool
PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
- m_pFrame = CreateChildFrame(doc, this);
- SetFrame(m_pFrame);
-
m_bMinSpecified = false;
m_bMaxSpecified = false;
m_dAutoScaleFactor = 1.;
- int width, height;
- m_pFrame->GetClientSize(&width, &height);
- m_pFrame->SetTitle ("Plot File");
+ m_pFrame = CreateChildFrame(doc, this);
+ SetFrame(m_pFrame);
m_pCanvas = CreateCanvas (m_pFrame);
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle ("Plot File");
m_pFrame->Show(true);
Activate(true);
return true;
}
+void
+PlotFileView::setInitialClientSize ()
+{
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
+
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
+}
+
+
void
PlotFileView::OnDraw (wxDC* dc)
{
bool
PlotFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
int width, height;
m_pFrame->GetClientSize(&width, &height);
m_pFrame->SetTitle("TextFile");
- m_pCanvas = new TextFileCanvas (this, m_pFrame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE | wxTE_READONLY);
+ m_pCanvas = new TextFileCanvas (this, m_pFrame, wxPoint(-1,-1), wxSize(width, height), wxTE_MULTILINE | wxTE_READONLY);
m_pFrame->SetTitle("Log");
m_pFrame->Show (true);
TextFileView::CreateChildFrame (wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(0,0), wxDEFAULT_FRAME_STYLE, "Log");
+ wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE, "Log");
#else
wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(300, 150), wxDEFAULT_FRAME_STYLE, "Log");
#endif
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);