** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.38 2000/12/25 21:54:26 kevin Exp $
+** $Id: views.cpp,v 1.42 2000/12/29 20:18:59 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
ImageFileCanvas::DrawRubberBandCursor (wxDC& dc, int x, int y)\r
{\r
const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
- ImageFileArrayConst v = rIF.getArray();\r
int nx = rIF.nx();\r
int ny = rIF.ny();\r
\r
+ int yPt = ny - y - 1;\r
dc.SetLogicalFunction (wxINVERT);\r
dc.SetPen (*wxGREEN_PEN);\r
- dc.DrawLine (0, y, nx, y);\r
+ dc.DrawLine (0, yPt, nx, yPt);\r
dc.DrawLine (x, 0, x, ny);\r
dc.SetLogicalFunction (wxCOPY);\r
}\r
wxPoint pt(event.GetLogicalPosition(dc));
\r
+ const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
+ ImageFileArrayConst v = rIF.getArray();\r
+ int nx = rIF.nx();\r
+ int ny = rIF.ny();\r
+ const int yPt = ny - 1 - pt.y;\r
if (event.RightIsDown()) {\r
- const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
- ImageFileArrayConst v = rIF.getArray();\r
- int nx = rIF.nx();\r
- int ny = rIF.ny();\r
- \r
if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
std::ostringstream os;\r
- os << "Image value (" << pt.x << "," << pt.y << ") = " << v[pt.x][ny - 1 - pt.y] << "\n";\r
+ os << "Image value (" << pt.x << "," << yPt << ") = " << v[pt.x][yPt] << "\n";\r
*theApp->getLog() << os.str().c_str();\r
} else\r
- *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
+ *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n";\r
}\r
- else if (event.LeftIsDown() || event.LeftUp()) {\r
- const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
- ImageFileArrayConst v = rIF.getArray();\r
- int nx = rIF.nx();\r
- int ny = rIF.ny();\r
- \r
+ else if (event.LeftIsDown() || event.LeftUp() || event.RightUp()) {\r
if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
if (m_xCursor >= 0 && m_yCursor >= 0) {\r
DrawRubberBandCursor (dc, m_xCursor, m_yCursor);\r
}\r
- DrawRubberBandCursor (dc, pt.x, pt.y);\r
+ DrawRubberBandCursor (dc, pt.x, yPt);\r
m_xCursor = pt.x;\r
- m_yCursor = pt.y;\r
+ m_yCursor = yPt;\r
} else\r
- *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
+ *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n";\r
}\r
if (event.LeftUp()) {\r
std::ostringstream os;\r
- os << "Selected column " << pt.x << " , row " << pt.y << "\n";\r
+ os << "Selected column " << pt.x << " , row " << yPt << "\n";\r
*theApp->getLog() << os.str().c_str();\r
}\r
}
EVT_MENU(IFMENU_COMPARE_IMAGES, ImageFileView::OnCompare)\r
EVT_MENU(IFMENU_COMPARE_ROW, ImageFileView::OnCompareRow)\r
EVT_MENU(IFMENU_COMPARE_COL, ImageFileView::OnCompareCol)\r
+EVT_MENU(IFMENU_PROCESS_INVERTVALUES, ImageFileView::OnInvertValues)\r
+EVT_MENU(IFMENU_PROCESS_SQUARE, ImageFileView::OnSquare)\r
+EVT_MENU(IFMENU_PROCESS_SQRT, ImageFileView::OnSquareRoot)\r
+EVT_MENU(IFMENU_PROCESS_LOG, ImageFileView::OnLog)\r
+EVT_MENU(IFMENU_PROCESS_EXP, ImageFileView::OnExp)\r
+EVT_MENU(IFMENU_PROCESS_FOURIER, ImageFileView::OnFourier)\r
+EVT_MENU(IFMENU_PROCESS_INVERSE_FOURIER, ImageFileView::OnInverseFourier)\r
+EVT_MENU(IFMENU_PROCESS_MAGNITUDE, ImageFileView::OnMagnitude)\r
+EVT_MENU(IFMENU_PROCESS_PHASE, ImageFileView::OnPhase)\r
EVT_MENU(IFMENU_PLOT_ROW, ImageFileView::OnPlotRow)\r
EVT_MENU(IFMENU_PLOT_COL, ImageFileView::OnPlotCol)\r
END_EVENT_TABLE()
void
ImageFileView::OnProperties (wxCommandEvent& event)
{
- double min, max, mean, mode, median, stddev;
const ImageFile& rIF = GetDocument()->getImageFile();
if (rIF.nx() == 0 || rIF.ny() == 0)
*theApp->getLog() << "Properties: empty imagefile\n";
else {
const std::string& rFilename = rIF.getFilename();
- rIF.statistics (min, max, mean, mode, median, stddev);
std::ostringstream os;
- os << "file: " << rFilename << "\nmin: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmedian: "<<median<<"\nmode: "<<mode<<"\nstddev: "<<stddev << "\n";
+ double min, max, mean, mode, median, stddev;\r
+ rIF.statistics (min, max, mean, mode, median, stddev);\r
+ os << "Filename: " << rFilename << "\n";\r
+ os << "Size: (" << rIF.nx() << "," << rIF.ny() << ")\n";\r
+ os << "Data type: ";\r
+ if (rIF.dataType() == Array2dFile::DATA_TYPE_COMPLEX)\r
+ os << "Complex\n";\r
+ else\r
+ os << "Real\n";\r
+ os << "\nMinimum: "<<min<<"\nMaximum: "<<max<<"\nMean: "<<mean<<"\nMedian: "<<median<<"\nMode: "<<mode<<"\nStandard Deviation: "<<stddev << "\n";
+ if (rIF.dataType() == Array2dFile::DATA_TYPE_COMPLEX) {\r
+ rIF.statistics (rIF.getImaginaryArray(), min, max, mean, mode, median, stddev);\r
+ os << "\nImaginary: min: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmedian: "<<median<<"\nmode: "<<mode<<"\nstddev: "<<stddev << "\n";\r
+ }\r
*theApp->getLog() << os.str().c_str();
wxMessageDialog dialogMsg (m_frame, os.str().c_str(), "Imagefile Properties", wxOK | wxICON_INFORMATION);
dialogMsg.ShowModal();
{\r
std::vector<ImageFileDocument*> vecIF;\r
theApp->getCompatibleImages (GetDocument(), vecIF);\r
-\r
+ \r
if (vecIF.size() == 0) {\r
wxMessageBox("There are no compatible image files open for comparision", "No comparison images");\r
} else {\r
DialogGetComparisonImage dialogGetCompare(m_frame, "Get Comparison Image", vecIF, true);\r
-\r
+ \r
if (dialogGetCompare.ShowModal() == wxID_OK) {\r
- ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();\r
const ImageFile& rIF = GetDocument()->getImageFile();\r
+ ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();\r
const ImageFile& rCompareIF = pCompareDoc->getImageFile();\r
std::ostringstream os;\r
double min, max, mean, mode, median, stddev;\r
return;\r
}\r
ImageFile& differenceImage = pDifferenceDoc->getImageFile();\r
- \r
+ \r
differenceImage.setArraySize (rIF.nx(), rIF.ny());\r
if (! rIF.subtractImages (rCompareIF, differenceImage)) {\r
pDifferenceDoc->DeleteAllViews();\r
return;\r
}\r
-\r
+ \r
if (theApp->getSetModifyNewDocs())\r
pDifferenceDoc->Modify(true);\r
pDifferenceDoc->UpdateAllViews(this);\r
}\r
}
+void\r
+ImageFileView::OnInvertValues (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.invertPixelValues (rIF);\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnSquare (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.square (rIF);\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnSquareRoot (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.sqrt (rIF);\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnLog (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.log (rIF);\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnExp (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.exp (rIF);\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnFourier (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.fourier (rIF);\r
+ m_bMinSpecified = false;\r
+ m_bMaxSpecified = false;\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnInverseFourier (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.inverseFourier (rIF);\r
+ m_bMinSpecified = false;\r
+ m_bMaxSpecified = false;\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnMagnitude (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.magnitude (rIF);\r
+ m_bMinSpecified = false;\r
+ m_bMaxSpecified = false;\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+void\r
+ImageFileView::OnPhase (wxCommandEvent& event)\r
+{\r
+ ImageFile& rIF = GetDocument()->getImageFile();\r
+ rIF.phase (rIF);\r
+ m_bMinSpecified = false;\r
+ m_bMaxSpecified = false;\r
+ if (theApp->getSetModifyNewDocs())\r
+ GetDocument()->Modify(TRUE);\r
+ GetDocument()->UpdateAllViews(this);\r
+}\r
+\r
+\r
ImageFileCanvas*
ImageFileView::CreateCanvas (wxView *view, wxFrame *parent)
{
view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set...");
view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...");
\r
+ wxMenu* process_menu = new wxMenu;\r
+ process_menu->Append (IFMENU_PROCESS_INVERTVALUES, "&Invert Values");\r
+ process_menu->Append (IFMENU_PROCESS_SQUARE, "&Square");\r
+ process_menu->Append (IFMENU_PROCESS_SQRT, "Square &Root");\r
+ process_menu->Append (IFMENU_PROCESS_LOG, "&Log");\r
+ process_menu->Append (IFMENU_PROCESS_EXP, "&Exp");\r
+ process_menu->AppendSeparator();\r
+ process_menu->Append (IFMENU_PROCESS_FOURIER, "&Fourier");\r
+ process_menu->Append (IFMENU_PROCESS_INVERSE_FOURIER, "&Inverse Fourier");\r
+ process_menu->Append (IFMENU_PROCESS_MAGNITUDE, "&Magnitude");\r
+ process_menu->Append (IFMENU_PROCESS_PHASE, "&Phase");\r
+\r
wxMenu *plot_menu = new wxMenu;\r
plot_menu->Append (IFMENU_PLOT_ROW, "Plot &Row");\r
plot_menu->Append (IFMENU_PLOT_COL, "Plot &Column");\r
compare_menu->Append (IFMENU_COMPARE_IMAGES, "Compare &Images...");\r
compare_menu->Append (IFMENU_COMPARE_ROW, "Compare &Row");\r
compare_menu->Append (IFMENU_COMPARE_COL, "Compare &Column");\r
-\r
+ \r
wxMenu *help_menu = new wxMenu;
help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
menu_bar->Append(file_menu, "&File");
menu_bar->Append(view_menu, "&View");\r
- menu_bar->Append(plot_menu, "&Plot");\r
+ menu_bar->Append(process_menu, "&Process");\r
+ menu_bar->Append(plot_menu, "P&lot");\r
menu_bar->Append(compare_menu, "&Compare");
menu_bar->Append(help_menu, "&Help");
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Column");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("box");\r
rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (2, nx);\r
delete pX;\r
delete pY;\r
if (theApp->getSetModifyNewDocs())\r
- pPlotDoc->Modify(true);\r
+ pPlotDoc->Modify(true);\r
+ pPlotDoc->UpdateAllViews();\r
}\r
- \r
}\r
void\r
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Row");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("box");\r
rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (2, nx);\r
delete pY;\r
if (theApp->getSetModifyNewDocs())\r
pPlotDoc->Modify(true);\r
+ pPlotDoc->UpdateAllViews();\r
}\r
}\r
\r
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Row");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("curve 1");\r
rPlotFile.addEzsetCommand ("color 2");\r
rPlotFile.addEzsetCommand ("curve 2");\r
delete pY2;\r
if (theApp->getSetModifyNewDocs())\r
pPlotDoc->Modify(true);\r
+ pPlotDoc->UpdateAllViews();\r
}\r
}\r
}\r
wxMessageBox ("No compatible images for Row Comparison", "Error");\r
return;\r
}\r
-\r
+ \r
DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false);\r
\r
if (dialogGetCompare.ShowModal() == wxID_OK) {\r
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Column");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("curve 1");\r
rPlotFile.addEzsetCommand ("color 2");\r
rPlotFile.addEzsetCommand ("curve 2");\r
delete pY2;\r
if (theApp->getSetModifyNewDocs())\r
pPlotDoc->Modify(true);\r
+ pPlotDoc->UpdateAllViews();\r
}\r
}\r
}\r
END_EVENT_TABLE()
PlotFileView::PlotFileView(void)
-: wxView(), m_canvas(NULL), m_frame(NULL)
+: wxView(), m_canvas(NULL), m_frame(NULL), m_pEZPlot(NULL)
{
}
PlotFileView::~PlotFileView(void)
-{
+{\r
+ if (m_pEZPlot)\r
+ delete m_pEZPlot;
}
void
bool
-PlotFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
+PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
m_frame = CreateChildFrame(doc, this);
SetFrame(m_frame);
m_frame->Show(true);
Activate(true);
-
+
return true;
}
m_canvas->GetClientSize (&xsize, &ysize);\r
SGPDriver driver (dc, xsize, ysize);\r
SGP sgp (driver);\r
- const PlotFile& rPhantom = GetDocument()->getPlotFile();\r
- EZPlot plot (sgp);\r
-\r
- for (int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++)\r
- plot.ezset (rPlotFile.getEzsetCommand (iEzset));\r
-\r
- if (m_bMinSpecified) {\r
- std::ostringstream os;\r
- os << "ymin " << m_dMinPixel;\r
- plot.ezset (os.str());\r
- }\r
- \r
- if (m_bMaxSpecified) {\r
- std::ostringstream os;\r
- os << "ymax " << m_dMaxPixel;\r
- plot.ezset (os.str());\r
- }\r
- \r
- plot.ezset("box");\r
- plot.ezset("grid");\r
- \r
- double* pdXaxis = new double [iNRecords];\r
- rPlotFile.getColumn (0, pdXaxis);\r
- \r
- double* pdY = new double [iNRecords];\r
- for (int iCol = 1; iCol < iNColumns; iCol++) {\r
- rPlotFile.getColumn (iCol, pdY);\r
- plot.addCurve (pdXaxis, pdY, iNRecords);\r
- }\r
- \r
- delete pdXaxis;\r
- delete pdY;\r
- \r
- plot.plot();\r
+ if (m_pEZPlot)\r
+ m_pEZPlot->plot (&sgp);\r
}\r
}
void
-PlotFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
+PlotFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
{
- if (m_canvas)
- m_canvas->Refresh();
+ if (m_canvas) {
+ const PlotFile& rPlotFile = GetDocument()->getPlotFile();\r
+ const int iNColumns = rPlotFile.getNumColumns();\r
+ const int iNRecords = rPlotFile.getNumRecords();\r
+ \r
+ if (iNColumns > 0 && iNRecords > 0) {\r
+ if (m_pEZPlot)\r
+ delete m_pEZPlot;\r
+ m_pEZPlot = new EZPlot;\r
+ \r
+ for (unsigned int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++)\r
+ m_pEZPlot->ezset (rPlotFile.getEzsetCommand (iEzset));\r
+ \r
+ if (m_bMinSpecified) {\r
+ std::ostringstream os;\r
+ os << "ymin " << m_dMinPixel;\r
+ m_pEZPlot->ezset (os.str());\r
+ }\r
+ \r
+ if (m_bMaxSpecified) {\r
+ std::ostringstream os;\r
+ os << "ymax " << m_dMaxPixel;\r
+ m_pEZPlot->ezset (os.str());\r
+ }\r
+ \r
+ m_pEZPlot->ezset("box");\r
+ m_pEZPlot->ezset("grid");\r
+ \r
+ double* pdXaxis = new double [iNRecords];\r
+ rPlotFile.getColumn (0, pdXaxis);\r
+ \r
+ double* pdY = new double [iNRecords];\r
+ for (int iCol = 1; iCol < iNColumns; iCol++) {\r
+ rPlotFile.getColumn (iCol, pdY);\r
+ m_pEZPlot->addCurve (pdXaxis, pdY, iNRecords);\r
+ }\r
+ \r
+ delete pdXaxis;\r
+ delete pdY;\r
+ }\r
+ \r
+ m_canvas->Refresh();\r
+ }
}
bool