X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=8c53e4ced61bf734570a557db7ee14d1fd75f7ff;hp=465990360c18f9dc160ff598a4e48bca40db67ac;hb=5c6b29ab4885308cc3381af6e0a68f4804956d2e;hpb=c24c1c0721df40e77822ad2b9ec01a944012ff42 diff --git a/src/views.cpp b/src/views.cpp index 4659903..8c53e4c 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.39 2000/12/27 03:16:02 kevin Exp $ +** $Id: views.cpp,v 1.40 2000/12/29 15:45:06 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 @@ -164,6 +164,13 @@ EVT_MENU(IFMENU_VIEW_SCALE_AUTO, ImageFileView::OnScaleAuto) EVT_MENU(IFMENU_COMPARE_IMAGES, ImageFileView::OnCompare) EVT_MENU(IFMENU_COMPARE_ROW, ImageFileView::OnCompareRow) EVT_MENU(IFMENU_COMPARE_COL, ImageFileView::OnCompareCol) +EVT_MENU(IFMENU_PROCESS_INVERTVALUES, ImageFileView::OnInvertValues) +EVT_MENU(IFMENU_PROCESS_SQUARE, ImageFileView::OnSquare) +EVT_MENU(IFMENU_PROCESS_SQRT, ImageFileView::OnSquareRoot) +EVT_MENU(IFMENU_PROCESS_LOG, ImageFileView::OnLog) +EVT_MENU(IFMENU_PROCESS_EXP, ImageFileView::OnExp) +EVT_MENU(IFMENU_PROCESS_FFT_MAGNITUDE, ImageFileView::OnFFTMagnitude) +EVT_MENU(IFMENU_PROCESS_FFT_PHASE, ImageFileView::OnFFTPhase) EVT_MENU(IFMENU_PLOT_ROW, ImageFileView::OnPlotRow) EVT_MENU(IFMENU_PLOT_COL, ImageFileView::OnPlotCol) END_EVENT_TABLE() @@ -245,15 +252,15 @@ ImageFileView::OnCompare (wxCommandEvent& event) { std::vector vecIF; theApp->getCompatibleImages (GetDocument(), vecIF); - + if (vecIF.size() == 0) { wxMessageBox("There are no compatible image files open for comparision", "No comparison images"); } else { DialogGetComparisonImage dialogGetCompare(m_frame, "Get Comparison Image", vecIF, true); - + if (dialogGetCompare.ShowModal() == wxID_OK) { - ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument(); const ImageFile& rIF = GetDocument()->getImageFile(); + ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument(); const ImageFile& rCompareIF = pCompareDoc->getImageFile(); std::ostringstream os; double min, max, mean, mode, median, stddev; @@ -273,13 +280,13 @@ ImageFileView::OnCompare (wxCommandEvent& event) return; } ImageFile& differenceImage = pDifferenceDoc->getImageFile(); - + differenceImage.setArraySize (rIF.nx(), rIF.ny()); if (! rIF.subtractImages (rCompareIF, differenceImage)) { pDifferenceDoc->DeleteAllViews(); return; } - + if (theApp->getSetModifyNewDocs()) pDifferenceDoc->Modify(true); pDifferenceDoc->UpdateAllViews(this); @@ -290,6 +297,77 @@ ImageFileView::OnCompare (wxCommandEvent& event) } } +void +ImageFileView::OnInvertValues (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + rIF.invertPixelValues (rIF); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(TRUE); + GetDocument()->UpdateAllViews(this); +} + +void +ImageFileView::OnSquare (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + rIF.square (rIF); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(TRUE); + GetDocument()->UpdateAllViews(this); +} + +void +ImageFileView::OnSquareRoot (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + rIF.sqrt (rIF); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(TRUE); + GetDocument()->UpdateAllViews(this); +} + +void +ImageFileView::OnLog (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + rIF.log (rIF); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(TRUE); + GetDocument()->UpdateAllViews(this); +} + +void +ImageFileView::OnExp (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + rIF.exp (rIF); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(TRUE); + GetDocument()->UpdateAllViews(this); +} + +void +ImageFileView::OnFFTMagnitude (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + rIF.FFTMagnitude (rIF); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(TRUE); + GetDocument()->UpdateAllViews(this); +} + +void +ImageFileView::OnFFTPhase (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + rIF.FFTPhase (rIF); + if (theApp->getSetModifyNewDocs()) + GetDocument()->Modify(TRUE); + GetDocument()->UpdateAllViews(this); +} + + ImageFileCanvas* ImageFileView::CreateCanvas (wxView *view, wxFrame *parent) { @@ -331,6 +409,15 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set..."); view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto..."); + wxMenu* process_menu = new wxMenu; + process_menu->Append (IFMENU_PROCESS_INVERTVALUES, "&Invert Values"); + process_menu->Append (IFMENU_PROCESS_SQUARE, "&Square"); + process_menu->Append (IFMENU_PROCESS_SQRT, "Square &Root"); + process_menu->Append (IFMENU_PROCESS_LOG, "&Log"); + process_menu->Append (IFMENU_PROCESS_EXP, "&Exp"); + process_menu->Append (IFMENU_PROCESS_FFT_MAGNITUDE, "&FFT Magnitude"); + process_menu->Append (IFMENU_PROCESS_FFT_PHASE, "FFT &Phase"); + wxMenu *plot_menu = new wxMenu; plot_menu->Append (IFMENU_PLOT_ROW, "Plot &Row"); plot_menu->Append (IFMENU_PLOT_COL, "Plot &Column"); @@ -339,7 +426,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) 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 *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); @@ -347,7 +434,8 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) menu_bar->Append(file_menu, "&File"); menu_bar->Append(view_menu, "&View"); - menu_bar->Append(plot_menu, "&Plot"); + menu_bar->Append(process_menu, "&Process"); + menu_bar->Append(plot_menu, "P&lot"); menu_bar->Append(compare_menu, "&Compare"); menu_bar->Append(help_menu, "&Help"); @@ -507,9 +595,9 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) delete pX; delete pY; if (theApp->getSetModifyNewDocs()) - pPlotDoc->Modify(true); + pPlotDoc->Modify(true); + pPlotDoc->UpdateAllViews(); } - } void @@ -556,6 +644,7 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) delete pY; if (theApp->getSetModifyNewDocs()) pPlotDoc->Modify(true); + pPlotDoc->UpdateAllViews(); } } @@ -625,6 +714,7 @@ ImageFileView::OnCompareCol (wxCommandEvent& event) delete pY2; if (theApp->getSetModifyNewDocs()) pPlotDoc->Modify(true); + pPlotDoc->UpdateAllViews(); } } } @@ -645,7 +735,7 @@ ImageFileView::OnCompareRow (wxCommandEvent& event) wxMessageBox ("No compatible images for Row Comparison", "Error"); return; } - + DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false); if (dialogGetCompare.ShowModal() == wxID_OK) { @@ -697,6 +787,7 @@ ImageFileView::OnCompareRow (wxCommandEvent& event) delete pY2; if (theApp->getSetModifyNewDocs()) pPlotDoc->Modify(true); + pPlotDoc->UpdateAllViews(); } } } @@ -1371,12 +1462,14 @@ EVT_MENU(PLOTMENU_VIEW_SCALE_AUTO, PlotFileView::OnScaleAuto) 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) -{ +{ + if (m_pEZPlot) + delete m_pEZPlot; } void @@ -1502,7 +1595,7 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) bool -PlotFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) +PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) { m_frame = CreateChildFrame(doc, this); SetFrame(m_frame); @@ -1524,7 +1617,7 @@ PlotFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) m_frame->Show(true); Activate(true); - + return true; } @@ -1540,48 +1633,58 @@ PlotFileView::OnDraw (wxDC* dc) m_canvas->GetClientSize (&xsize, &ysize); SGPDriver driver (dc, xsize, ysize); SGP sgp (driver); - EZPlot plot (sgp); - - for (int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++) - plot.ezset (rPlotFile.getEzsetCommand (iEzset)); - - if (m_bMinSpecified) { - std::ostringstream os; - os << "ymin " << m_dMinPixel; - plot.ezset (os.str()); - } - - if (m_bMaxSpecified) { - std::ostringstream os; - os << "ymax " << m_dMaxPixel; - plot.ezset (os.str()); - } - - plot.ezset("box"); - plot.ezset("grid"); - - double* pdXaxis = new double [iNRecords]; - rPlotFile.getColumn (0, pdXaxis); - - double* pdY = new double [iNRecords]; - for (int iCol = 1; iCol < iNColumns; iCol++) { - rPlotFile.getColumn (iCol, pdY); - plot.addCurve (pdXaxis, pdY, iNRecords); - } - - delete pdXaxis; - delete pdY; - - plot.plot(); + if (m_pEZPlot) + m_pEZPlot->plot (&sgp); } } 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(); + const int iNColumns = rPlotFile.getNumColumns(); + const int iNRecords = rPlotFile.getNumRecords(); + + if (iNColumns > 0 && iNRecords > 0) { + if (m_pEZPlot) + delete m_pEZPlot; + m_pEZPlot = new EZPlot; + + for (int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++) + m_pEZPlot->ezset (rPlotFile.getEzsetCommand (iEzset)); + + if (m_bMinSpecified) { + std::ostringstream os; + os << "ymin " << m_dMinPixel; + m_pEZPlot->ezset (os.str()); + } + + if (m_bMaxSpecified) { + std::ostringstream os; + os << "ymax " << m_dMaxPixel; + m_pEZPlot->ezset (os.str()); + } + + m_pEZPlot->ezset("box"); + m_pEZPlot->ezset("grid"); + + double* pdXaxis = new double [iNRecords]; + rPlotFile.getColumn (0, pdXaxis); + + double* pdY = new double [iNRecords]; + for (int iCol = 1; iCol < iNColumns; iCol++) { + rPlotFile.getColumn (iCol, pdY); + m_pEZPlot->addCurve (pdXaxis, pdY, iNRecords); + } + + delete pdXaxis; + delete pdY; + } + + m_canvas->Refresh(); + } } bool