X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=393e5f4f37fa1f046b03141a95866cccd5f91739;hp=f52b6116e37c99685b3c5f11cc87af252a789d33;hb=3195acb0c7c6e7a660fe27eb653a0aca56e91024;hpb=acd157c5e61e2eeba8308a49b4d7fc4a4aba9a84 diff --git a/src/views.cpp b/src/views.cpp index f52b611..393e5f4 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: views.cpp,v 1.53 2001/01/07 22:53:36 kevin Exp $ +** $Id: views.cpp,v 1.66 2001/01/18 21:30:22 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 @@ -765,17 +765,18 @@ wxFrame* ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) { #if CTSIM_MDI - wxMDIChildFrame *subframe = new wxMDIChildFrame(theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE); + wxMDIChildFrame *subframe = new wxMDIChildFrame (theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), 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(0, 0), wxDEFAULT_FRAME_STYLE); #endif - + theApp->setIconForFrame (subframe); + wxMenu *file_menu = new wxMenu; - file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom..."); - file_menu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter..."); - file_menu->Append(wxID_OPEN, "&Open..."); - file_menu->Append(wxID_SAVE, "&Save"); + file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P"); + file_menu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F"); + file_menu->Append(wxID_OPEN, "&Open...\tCtrl-O"); + file_menu->Append(wxID_SAVE, "&Save\tCtrl-S"); file_menu->Append(wxID_SAVEAS, "Save &As..."); file_menu->Append(wxID_CLOSE, "&Close"); @@ -789,9 +790,9 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) file_menu->Append(wxID_PREVIEW, "Print Pre&view"); wxMenu *view_menu = new wxMenu; - view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set..."); - view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto..."); - view_menu->Append(IFMENU_VIEW_SCALE_FULL, "Display &Full Scale"); + view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale S&et...\tCtrl-E"); + view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...\tCtrl-A"); + view_menu->Append(IFMENU_VIEW_SCALE_FULL, "Display F&ull Scale\tCtrl-U"); wxMenu* filter_menu = new wxMenu; filter_menu->Append (IFMENU_FILTER_INVERTVALUES, "&Invert Values"); @@ -839,6 +840,8 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) analyze_menu->Append (IFMENU_COMPARE_COL, "Compare &Column"); wxMenu *help_menu = new wxMenu; + help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1"); + help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics\tCtrl-T"); help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); wxMenuBar *menu_bar = new wxMenuBar; @@ -854,6 +857,19 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) subframe->Centre(wxBOTH); + wxAcceleratorEntry accelEntries[9]; + accelEntries[0].Set (wxACCEL_CTRL, static_cast('O'), wxID_OPEN); + accelEntries[1].Set (wxACCEL_CTRL, static_cast('S'), wxID_SAVE); + accelEntries[2].Set (wxACCEL_CTRL, static_cast('T'), MAINMENU_HELP_TOPICS); + accelEntries[3].Set (wxACCEL_CTRL, static_cast('P'), MAINMENU_FILE_CREATE_PHANTOM); + accelEntries[4].Set (wxACCEL_CTRL, static_cast('F'), MAINMENU_FILE_CREATE_FILTER); + accelEntries[5].Set (wxACCEL_NORMAL, WXK_F1, MAINMENU_HELP_CONTENTS); + accelEntries[6].Set (wxACCEL_CTRL, static_cast('A'), IFMENU_VIEW_SCALE_AUTO); + accelEntries[7].Set (wxACCEL_CTRL, static_cast('U'), IFMENU_VIEW_SCALE_FULL); + accelEntries[8].Set (wxACCEL_CTRL, static_cast('E'), IFMENU_VIEW_SCALE_MINMAX); + wxAcceleratorTable accelTable (9, accelEntries); + subframe->SetAcceleratorTable (accelTable); + return subframe; } @@ -1056,7 +1072,8 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) if (v != NULL && yCursor < ny) { double* pX = new double [nx]; double* pYReal = new double [nx]; - double *pYImag, *pYMag; + double *pYImag = NULL; + double *pYMag = NULL; if (rIF.isComplex()) { pYImag = new double [nx]; pYMag = new double [nx]; @@ -1103,7 +1120,7 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) rPlotFile.addColumn (2, pYImag); rPlotFile.addColumn (3, pYMag); } - for (int iL = 0; iL < rIF.nLabels(); iL++) + for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str()); os << " Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str(); *theApp->getLog() << os.str().c_str() << "\n"; @@ -1138,11 +1155,12 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) if (v != NULL && xCursor < nx) { double* pX = new double [ny]; - double* pYReal = new double [nx]; - double *pYImag, *pYMag; + double* pYReal = new double [ny]; + double* pYImag = NULL; + double* pYMag = NULL; if (rIF.isComplex()) { - pYImag = new double [nx]; - pYMag = new double [nx]; + pYImag = new double [ny]; + pYMag = new double [ny]; } for (int i = 0; i < ny; i++) { pX[i] = i; @@ -1177,16 +1195,16 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) rPlotFile.addEzsetCommand ("curve 3"); rPlotFile.addEzsetCommand ("color 0"); rPlotFile.addEzsetCommand ("solid"); - rPlotFile.setCurveSize (4, nx); + rPlotFile.setCurveSize (4, ny); } else - rPlotFile.setCurveSize (2, nx); + rPlotFile.setCurveSize (2, ny); rPlotFile.addColumn (0, pX); rPlotFile.addColumn (1, pYReal); if (rIF.isComplex()) { rPlotFile.addColumn (2, pYImag); rPlotFile.addColumn (3, pYMag); } - for (int iL = 0; iL < rIF.nLabels(); iL++) + for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str()); os << " Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str(); *theApp->getLog() << os.str().c_str() << "\n"; @@ -1272,7 +1290,6 @@ ImageFileView::OnPlotFFTRow (wxCommandEvent& event) rPlotFile.addEzsetCommand ("curve 3"); rPlotFile.addEzsetCommand ("color 0"); rPlotFile.addEzsetCommand ("solid"); - rPlotFile.setCurveSize (4, nx); rPlotFile.addEzsetCommand ("box"); rPlotFile.addEzsetCommand ("grid"); rPlotFile.setCurveSize (4, nx); @@ -1309,16 +1326,46 @@ ImageFileView::OnPlotFFTCol (wxCommandEvent& event) const ImageFile& rIF = dynamic_cast(GetDocument())->getImageFile(); ImageFileArrayConst v = rIF.getArray(); + ImageFileArrayConst vImag = rIF.getImaginaryArray(); int nx = rIF.nx(); int ny = rIF.ny(); if (v != NULL && xCursor < nx) { + fftw_complex* pcIn = new fftw_complex [ny]; + double *pdTemp = new double [ny]; + + int i; + for (i = 0; i < ny; i++) + pdTemp[i] = v[xCursor][i]; + Fourier::shuffleNaturalToFourierOrder (pdTemp, ny); + for (i = 0; i < ny; i++) + pcIn[i].re = pdTemp[i]; + + for (i = 0; i < ny; i++) { + if (rIF.isComplex()) + pdTemp[i] = vImag[xCursor][i]; + else + pdTemp[i] = 0; + } + Fourier::shuffleNaturalToFourierOrder (pdTemp, ny); + for (i = 0; i < ny; i++) + pcIn[i].im = pdTemp[i]; + + fftw_plan plan = fftw_create_plan (ny, FFTW_BACKWARD, FFTW_IN_PLACE); + fftw_one (plan, pcIn, NULL); + fftw_destroy_plan (plan); + double* pX = new double [ny]; - double* pY = new double [ny]; - for (int i = 0; i < ny; i++) { + double* pYReal = new double [ny]; + double* pYImag = new double [ny]; + double* pYMag = new double [ny]; + for (i = 0; i < ny; i++) { pX[i] = i; - pY[i] = v[xCursor][i]; + pYReal[i] = pcIn[i].re; + pYImag[i] = pcIn[i].im; + pYMag[i] = ::sqrt (pcIn[i].re * pcIn[i].re + pcIn[i].im * pcIn[i].im); } + PlotFileDocument* pPlotDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT)); if (! pPlotDoc) { sys_error (ERR_SEVERE, "Internal error: unable to create Plot file"); @@ -1329,17 +1376,38 @@ ImageFileView::OnPlotFFTCol (wxCommandEvent& event) std::string title("title "); title += os.str(); rPlotFile.addEzsetCommand (title.c_str()); - rPlotFile.addEzsetCommand ("xlabel Row"); + rPlotFile.addEzsetCommand ("xlabel Column"); rPlotFile.addEzsetCommand ("ylabel Pixel Value"); rPlotFile.addEzsetCommand ("lxfrac 0"); - rPlotFile.addEzsetCommand ("box"); + rPlotFile.addEzsetCommand ("curve 1"); + rPlotFile.addEzsetCommand ("color 1"); + rPlotFile.addEzsetCommand ("dash 1"); + rPlotFile.addEzsetCommand ("curve 2"); + rPlotFile.addEzsetCommand ("color 4"); + rPlotFile.addEzsetCommand ("dash 3"); + rPlotFile.addEzsetCommand ("curve 3"); + rPlotFile.addEzsetCommand ("color 0"); + rPlotFile.addEzsetCommand ("solid"); + rPlotFile.addEzsetCommand ("box"); rPlotFile.addEzsetCommand ("grid"); - rPlotFile.setCurveSize (2, nx); + rPlotFile.setCurveSize (4, ny); rPlotFile.addColumn (0, pX); - rPlotFile.addColumn (1, pY); + rPlotFile.addColumn (1, pYReal); + rPlotFile.addColumn (2, pYImag); + rPlotFile.addColumn (3, pYMag); + for (int iL = 0; iL < rIF.nLabels(); iL++) + rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str()); + os << " FFT 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; + delete pYReal; + delete pYImag; + delete pYMag; + delete pdTemp; + delete [] pcIn; + if (theApp->getSetModifyNewDocs()) pPlotDoc->Modify(true); pPlotDoc->UpdateAllViews(); @@ -1403,26 +1471,26 @@ ImageFileView::OnCompareCol (wxCommandEvent& event) rPlotFile.addEzsetCommand ("dash 5"); rPlotFile.addEzsetCommand ("box"); rPlotFile.addEzsetCommand ("grid"); - rPlotFile.setCurveSize (3, nx); + 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(); + std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str(); s += ": "; s += rIF.labelGet(iL).getLabelString(); rPlotFile.addDescription (s.c_str()); } - for (iL = 0; iL < rIF.nLabels(); iL++) { - std::string s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle(); + 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() << " and " - << pCompareDoc->GetFirstView()->GetFrame()->GetTitle(); + 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()); } @@ -1494,25 +1562,25 @@ ImageFileView::OnCompareRow (wxCommandEvent& event) rPlotFile.addEzsetCommand ("dash 5"); rPlotFile.addEzsetCommand ("box"); rPlotFile.addEzsetCommand ("grid"); - rPlotFile.setCurveSize (3, ny); + 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(); + std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str(); s += ": "; s += rIF.labelGet(iL).getLabelString(); rPlotFile.addDescription (s.c_str()); } - for (iL = 0; iL < rIF.nLabels(); iL++) { - std::string s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle(); + 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() << " and " - << pCompareDoc->GetFirstView()->GetFrame()->GetTitle(); + 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()); } @@ -1570,16 +1638,16 @@ ImageFileView::OnPlotHistogram (wxCommandEvent& event) rPlotFile.addEzsetCommand ("ylabel Count"); rPlotFile.addEzsetCommand ("box"); rPlotFile.addEzsetCommand ("grid"); - rPlotFile.setCurveSize (2, nx); + 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(); + 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(); + os << " Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str(); *theApp->getLog() << os.str().c_str() << "\n"; rPlotFile.addDescription (os.str().c_str()); delete pX; @@ -1816,6 +1884,7 @@ PhantomView::CreateChildFrame(wxDocument *doc, wxView *view) #else wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE); #endif + theApp->setIconForFrame (subframe); wxMenu *file_menu = new wxMenu; @@ -1839,6 +1908,7 @@ PhantomView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents"); + help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics"); help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); wxMenuBar *menu_bar = new wxMenuBar; @@ -2095,11 +2165,6 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) const Projections& rProj = GetDocument()->getProjections(); imageFile.setArraySize (m_iDefaultNX, m_iDefaultNY); - if (m_iDefaultFilterMethod != ProcessSignal::FILTER_METHOD_CONVOLUTION && m_iDefaultFilterGeneration == ProcessSignal::FILTER_GENERATION_DIRECT && rProj.geometry() != Scanner::GEOMETRY_PARALLEL) { - wxMessageBox ("Sorry!\nCurrently, frequency-based filtering with direct filter generation is not support for geometries other than parallel.\nAborting command.", "Not Supported", wxOK | wxICON_WARNING, m_frame); - return; - } - Reconstructor* pReconstruct = new Reconstructor (rProj, imageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); Timer timerRecon; @@ -2176,6 +2241,7 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) #else wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE); #endif + theApp->setIconForFrame (subframe); wxMenu *file_menu = new wxMenu; @@ -2204,7 +2270,7 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents"); - help_menu->AppendSeparator(); + help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics"); help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); wxMenuBar *menu_bar = new wxMenuBar; @@ -2464,6 +2530,7 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) #else wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE); #endif + theApp->setIconForFrame (subframe); wxMenu *file_menu = new wxMenu; @@ -2489,7 +2556,7 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents"); - help_menu->AppendSeparator(); + help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics"); help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); wxMenuBar *menu_bar = new wxMenuBar;