X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fviews.cpp;h=f7d8a1f1407469442860b4d9657c150f6fa68563;hb=0eb095f799dd4222e6eb9b1db9e8c6f2831a1540;hp=1ba30cd9f821f42db4b34513a10652ef61344b8d;hpb=7aa9fa8966a8ff45125fd1f5e10fbdbcd3a7f9cb;p=ctsim.git diff --git a/src/views.cpp b/src/views.cpp index 1ba30cd..f7d8a1f 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.47 2001/01/02 13:32:51 kevin Exp $ +** $Id: views.cpp,v 1.50 2001/01/03 22:00:46 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 @@ -195,6 +195,7 @@ EVT_MENU(IFMENU_FILTER_MAGNITUDE, ImageFileView::OnMagnitude) EVT_MENU(IFMENU_FILTER_PHASE, ImageFileView::OnPhase) EVT_MENU(IFMENU_PLOT_ROW, ImageFileView::OnPlotRow) EVT_MENU(IFMENU_PLOT_COL, ImageFileView::OnPlotCol) +EVT_MENU(IFMENU_PLOT_HISTOGRAM, ImageFileView::OnPlotHistogram) END_EVENT_TABLE() ImageFileView::ImageFileView(void) @@ -739,7 +740,6 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) filter_menu->Append (IFMENU_FILTER_PHASE, "&Phase"); wxMenu* image_menu = new wxMenu; - filter_menu->AppendSeparator(); image_menu->Append (IFMENU_IMAGE_ADD, "&Add..."); image_menu->Append (IFMENU_IMAGE_SUBTRACT, "&Subtract..."); image_menu->Append (IFMENU_IMAGE_MULTIPLY, "&Multiply..."); @@ -747,14 +747,14 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) image_menu->AppendSeparator(); image_menu->Append (IFMENU_IMAGE_SCALESIZE, "S&cale Size..."); - wxMenu *plot_menu = new wxMenu; - plot_menu->Append (IFMENU_PLOT_ROW, "Plot &Row"); - plot_menu->Append (IFMENU_PLOT_COL, "Plot &Column"); - - wxMenu *compare_menu = new wxMenu; - compare_menu->Append (IFMENU_COMPARE_IMAGES, "Compare &Images..."); - compare_menu->Append (IFMENU_COMPARE_ROW, "Compare &Row"); - compare_menu->Append (IFMENU_COMPARE_COL, "Compare &Column"); + wxMenu *analyze_menu = new wxMenu; + analyze_menu->Append (IFMENU_PLOT_ROW, "Plot &Row"); + analyze_menu->Append (IFMENU_PLOT_COL, "Plot &Column"); + analyze_menu->Append (IFMENU_PLOT_HISTOGRAM, "Plot &Histogram"); + analyze_menu->AppendSeparator(); + analyze_menu->Append (IFMENU_COMPARE_IMAGES, "Compare &Images..."); + analyze_menu->Append (IFMENU_COMPARE_ROW, "Compare &Row"); + analyze_menu->Append (IFMENU_COMPARE_COL, "Compare &Column"); wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); @@ -765,8 +765,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) menu_bar->Append(view_menu, "&View"); menu_bar->Append(image_menu, "&Image"); menu_bar->Append(filter_menu, "Fi<er"); - menu_bar->Append(plot_menu, "P&lot"); - menu_bar->Append(compare_menu, "&Compare"); + menu_bar->Append(analyze_menu, "&Analyze"); menu_bar->Append(help_menu, "&Help"); subframe->SetMenuBar(menu_bar); @@ -1196,6 +1195,61 @@ ImageFileView::OnCompareRow (wxCommandEvent& event) } } +static int NUMBER_HISTOGRAM_BINS = 256; + +void +ImageFileView::OnPlotHistogram (wxCommandEvent& event) +{ + const ImageFile& rIF = dynamic_cast(GetDocument())->getImageFile(); + ImageFileArrayConst v = rIF.getArray(); + int nx = rIF.nx(); + int ny = rIF.ny(); + + if (v != NULL && nx > 0 && ny > 0) { + PlotFileDocument* pPlotDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT)); + 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 ((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, nx); + rPlotFile.addColumn (0, pX); + rPlotFile.addColumn (1, pY); + delete pX; + delete pY; + if (theApp->getSetModifyNewDocs()) + pPlotDoc->Modify(true); + pPlotDoc->UpdateAllViews(); + } +} + // PhantomCanvas @@ -1539,7 +1593,9 @@ IMPLEMENT_DYNAMIC_CLASS(ProjectionFileView, wxView) BEGIN_EVENT_TABLE(ProjectionFileView, wxView) EVT_MENU(PJMENU_FILE_PROPERTIES, ProjectionFileView::OnProperties) -EVT_MENU(PJMENU_PROCESS_RECONSTRUCT, ProjectionFileView::OnReconstruct) +EVT_MENU(PJMENU_RECONSTRUCT_FBP, ProjectionFileView::OnReconstructFBP) +EVT_MENU(PJMENU_CONVERT_POLAR, ProjectionFileView::OnConvertPolar) +EVT_MENU(PJMENU_CONVERT_FFT_POLAR, ProjectionFileView::OnConvertFFTPolar) END_EVENT_TABLE() ProjectionFileView::ProjectionFileView(void) @@ -1580,7 +1636,35 @@ ProjectionFileView::OnProperties (wxCommandEvent& event) void -ProjectionFileView::OnReconstruct (wxCommandEvent& event) +ProjectionFileView::OnConvertPolar (wxCommandEvent& event) +{ + Projections& rProj = GetDocument()->getProjections(); +} + +void +ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event) +{ + Projections& rProj = GetDocument()->getProjections(); + wxMessageBox ("Polar conversion not yet implemented", "Unimplemented function"); +#if 0 + rProj.convertPolar (); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(true); + GetDocument()->UpdateAllViews(); +#ifndef HAVE_FFT + wxMessageBox ("FFT support has not been compiled into this version of CTSim", "Error"); +#endif +#endif +} + +void +ProjectionFileView::OnReconstructFourier (wxCommandEvent& event) +{ + wxMessageBox ("Fourier Reconstruction is not yet supported", "Unimplemented function"); +} + +void +ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) { DialogGetReconstructionParameters dialogReconstruction (m_frame, m_iDefaultNX, m_iDefaultNY, m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration, m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector, m_iDefaultTrace); @@ -1707,9 +1791,14 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) file_menu->Append(wxID_PRINT_SETUP, "Print &Setup..."); file_menu->Append(wxID_PREVIEW, "Print Pre&view"); - wxMenu *process_menu = new wxMenu; - process_menu->Append(PJMENU_PROCESS_RECONSTRUCT, "R&econstruct..."); + wxMenu *convert_menu = new wxMenu; + convert_menu->Append (PJMENU_CONVERT_POLAR, "&Polar Image..."); + convert_menu->Append (PJMENU_CONVERT_FFT_POLAR, "&FFT->Polar Image..."); + wxMenu *reconstruct_menu = new wxMenu; + reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection..."); + reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier..."); + wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents"); help_menu->AppendSeparator(); @@ -1717,9 +1806,10 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenuBar *menu_bar = new wxMenuBar; - menu_bar->Append(file_menu, "&File"); - menu_bar->Append(process_menu, "&Process"); - menu_bar->Append(help_menu, "&Help"); + menu_bar->Append (file_menu, "&File"); + menu_bar->Append (convert_menu, "&Convert"); + menu_bar->Append (reconstruct_menu, "&Reconstruct"); + menu_bar->Append (help_menu, "&Help"); subframe->SetMenuBar(menu_bar); @@ -1862,6 +1952,8 @@ END_EVENT_TABLE() PlotFileView::PlotFileView(void) : wxView(), m_canvas(NULL), m_frame(NULL), m_pEZPlot(NULL) { + m_bMinSpecified = false; + m_bMaxSpecified = false; } PlotFileView::~PlotFileView(void)