** 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
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)
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...");
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");
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);
}
}
+static int NUMBER_HISTOGRAM_BINS = 256;
+
+void
+ImageFileView::OnPlotHistogram (wxCommandEvent& event)
+{
+ const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(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<PlotFileDocument*>(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<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, nx);
+ rPlotFile.addColumn (0, pX);
+ rPlotFile.addColumn (1, pY);
+ delete pX;
+ delete pY;
+ if (theApp->getSetModifyNewDocs())
+ pPlotDoc->Modify(true);
+ pPlotDoc->UpdateAllViews();
+ }
+}
+
// PhantomCanvas
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)
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);
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();
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);
PlotFileView::PlotFileView(void)
: wxView(), m_canvas(NULL), m_frame(NULL), m_pEZPlot(NULL)
{
+ m_bMinSpecified = false;
+ m_bMaxSpecified = false;
}
PlotFileView::~PlotFileView(void)