1 /*****************************************************************************
5 ** Purpose: View & Canvas routines for CTSim program
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 2000
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
12 ** $Id: views.cpp,v 1.139 2001/03/18 18:08:26 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
28 #include "wx/wxprec.h"
33 #if !wxUSE_DOC_VIEW_ARCHITECTURE
34 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
38 #include "wx/progdlg.h"
39 #include "wx/clipbrd.h"
46 #include "dlgprojections.h"
47 #include "dlgreconstruct.h"
48 #include "backprojectors.h"
49 #include "reconstruct.h"
51 #include "threadproj.h"
52 #include "threadrecon.h"
53 #include "threadraster.h"
55 #if defined(MSVC) || HAVE_SSTREAM
58 #include <sstream_subst>
64 BEGIN_EVENT_TABLE(ImageFileCanvas, wxScrolledWindow)
65 EVT_MOUSE_EVENTS(ImageFileCanvas::OnMouseEvent)
66 EVT_CHAR(ImageFileCanvas::OnChar)
70 ImageFileCanvas::ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
71 : wxScrolledWindow(frame, -1, pos, size, style), m_pView(v), m_xCursor(-1), m_yCursor(-1)
75 ImageFileCanvas::~ImageFileCanvas()
81 ImageFileCanvas::OnDraw(wxDC& dc)
84 m_pView->OnDraw(& dc);
88 ImageFileCanvas::DrawRubberBandCursor (wxDC& dc, int x, int y)
90 const ImageFile& rIF = m_pView->GetDocument()->getImageFile();
95 dc.SetLogicalFunction (wxINVERT);
96 dc.SetPen (*wxGREEN_PEN);
97 dc.DrawLine (0, yPt, nx, yPt);
98 dc.DrawLine (x, 0, x, ny);
99 dc.SetLogicalFunction (wxCOPY);
103 ImageFileCanvas::GetCurrentCursor (int& x, int& y)
108 if (m_xCursor >= 0 && m_yCursor >= 0)
115 ImageFileCanvas::OnMouseEvent(wxMouseEvent& event)
124 wxPoint pt(event.GetLogicalPosition(dc));
126 const ImageFileDocument* pIFDoc = m_pView->GetDocument();
129 const ImageFile& rIF = pIFDoc->getImageFile();
130 ImageFileArrayConst v = rIF.getArray();
133 const int yPt = ny - 1 - pt.y;
134 if (event.RightIsDown()) {
135 if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {
136 std::ostringstream os;
137 os << "Image value (" << pt.x << "," << yPt << ") = " << v[pt.x][yPt];
138 if (rIF.isComplex()) {
139 double dImag = rIF.getImaginaryArray()[pt.x][yPt];
141 os << " - " << -dImag;
143 os << " + " << dImag;
147 *theApp->getLog() << os.str().c_str();
149 *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n";
151 else if (event.LeftIsDown() || event.LeftUp() || event.RightUp()) {
152 if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {
153 if (m_xCursor >= 0 && m_yCursor >= 0) {
154 DrawRubberBandCursor (dc, m_xCursor, m_yCursor);
156 DrawRubberBandCursor (dc, pt.x, yPt);
159 wxMenu* pMenu = m_pView->getMenuAnalyze();
160 if (pMenu && ! pMenu->IsEnabled(IFMENU_PLOT_ROW)) {
161 pMenu->Enable (IFMENU_PLOT_ROW, true);
162 pMenu->Enable (IFMENU_PLOT_COL, true);
163 pMenu->Enable (IFMENU_COMPARE_ROW, true);
164 pMenu->Enable (IFMENU_COMPARE_COL, true);
165 pMenu->Enable (IFMENU_PLOT_FFT_ROW, true);
166 pMenu->Enable (IFMENU_PLOT_FFT_COL, true);
169 *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n";
171 if (event.LeftUp()) {
172 std::ostringstream os;
173 os << "Selected column " << pt.x << " , row " << yPt << "\n";
174 *theApp->getLog() << os.str().c_str();
179 ImageFileCanvas::OnChar (wxKeyEvent& event)
181 if (event.GetKeyCode() == WXK_ESCAPE) {
185 m_pView->OnUpdate (NULL);
187 wxScrolledWindow::OnChar (event);
191 ImageFileCanvas::GetBestSize() const
196 const ImageFile& rIF = m_pView->GetDocument()->getImageFile();
197 return wxSize (rIF.nx(), rIF.ny());
203 IMPLEMENT_DYNAMIC_CLASS(ImageFileView, wxView)
205 BEGIN_EVENT_TABLE(ImageFileView, wxView)
206 EVT_MENU(IFMENU_FILE_EXPORT, ImageFileView::OnExport)
207 EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties)
208 EVT_MENU(IFMENU_EDIT_COPY, ImageFileView::OnEditCopy)
209 EVT_MENU(IFMENU_EDIT_CUT, ImageFileView::OnEditCut)
210 EVT_MENU(IFMENU_EDIT_PASTE, ImageFileView::OnEditPaste)
211 EVT_MENU(IFMENU_VIEW_SCALE_MINMAX, ImageFileView::OnScaleMinMax)
212 EVT_MENU(IFMENU_VIEW_SCALE_AUTO, ImageFileView::OnScaleAuto)
213 EVT_MENU(IFMENU_VIEW_SCALE_FULL, ImageFileView::OnScaleFull)
214 EVT_MENU(IFMENU_COMPARE_IMAGES, ImageFileView::OnCompare)
215 EVT_MENU(IFMENU_COMPARE_ROW, ImageFileView::OnCompareRow)
216 EVT_MENU(IFMENU_COMPARE_COL, ImageFileView::OnCompareCol)
217 EVT_MENU(IFMENU_FILTER_INVERTVALUES, ImageFileView::OnInvertValues)
218 EVT_MENU(IFMENU_FILTER_SQUARE, ImageFileView::OnSquare)
219 EVT_MENU(IFMENU_FILTER_SQRT, ImageFileView::OnSquareRoot)
220 EVT_MENU(IFMENU_FILTER_LOG, ImageFileView::OnLog)
221 EVT_MENU(IFMENU_FILTER_EXP, ImageFileView::OnExp)
222 EVT_MENU(IFMENU_FILTER_FOURIER, ImageFileView::OnFourier)
223 EVT_MENU(IFMENU_FILTER_INVERSE_FOURIER, ImageFileView::OnInverseFourier)
224 EVT_MENU(IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER, ImageFileView::OnShuffleFourierToNaturalOrder)
225 EVT_MENU(IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER, ImageFileView::OnShuffleNaturalToFourierOrder)
226 EVT_MENU(IFMENU_IMAGE_ADD, ImageFileView::OnAdd)
227 EVT_MENU(IFMENU_IMAGE_SUBTRACT, ImageFileView::OnSubtract)
228 EVT_MENU(IFMENU_IMAGE_MULTIPLY, ImageFileView::OnMultiply)
229 EVT_MENU(IFMENU_IMAGE_DIVIDE, ImageFileView::OnDivide)
230 EVT_MENU(IFMENU_IMAGE_SCALESIZE, ImageFileView::OnScaleSize)
232 EVT_MENU(IFMENU_IMAGE_CONVERT3D, ImageFileView::OnConvert3d)
235 EVT_MENU(IFMENU_FILTER_FFT, ImageFileView::OnFFT)
236 EVT_MENU(IFMENU_FILTER_IFFT, ImageFileView::OnIFFT)
237 EVT_MENU(IFMENU_FILTER_FFT_ROWS, ImageFileView::OnFFTRows)
238 EVT_MENU(IFMENU_FILTER_IFFT_ROWS, ImageFileView::OnIFFTRows)
239 EVT_MENU(IFMENU_FILTER_FFT_COLS, ImageFileView::OnFFTCols)
240 EVT_MENU(IFMENU_FILTER_IFFT_COLS, ImageFileView::OnIFFTCols)
242 EVT_MENU(IFMENU_FILTER_MAGNITUDE, ImageFileView::OnMagnitude)
243 EVT_MENU(IFMENU_FILTER_PHASE, ImageFileView::OnPhase)
244 EVT_MENU(IFMENU_PLOT_ROW, ImageFileView::OnPlotRow)
245 EVT_MENU(IFMENU_PLOT_COL, ImageFileView::OnPlotCol)
247 EVT_MENU(IFMENU_PLOT_FFT_ROW, ImageFileView::OnPlotFFTRow)
248 EVT_MENU(IFMENU_PLOT_FFT_COL, ImageFileView::OnPlotFFTCol)
250 EVT_MENU(IFMENU_PLOT_HISTOGRAM, ImageFileView::OnPlotHistogram)
253 ImageFileView::ImageFileView()
254 : wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
256 m_iDefaultExportFormatID = ImageFile::EXPORT_FORMAT_PNG;
259 ImageFileView::~ImageFileView()
261 GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
262 GetDocumentManager()->ActivateView(this, FALSE, TRUE);
267 ImageFileView::OnProperties (wxCommandEvent& event)
269 const ImageFile& rIF = GetDocument()->getImageFile();
270 if (rIF.nx() == 0 || rIF.ny() == 0)
271 *theApp->getLog() << "Properties: empty imagefile\n";
273 const std::string rFilename = m_pFrame->GetTitle().c_str();
274 std::ostringstream os;
275 double min, max, mean, mode, median, stddev;
276 rIF.statistics (rIF.getArray(), min, max, mean, mode, median, stddev);
277 os << "Filename: " << rFilename << "\n";
278 os << "Size: (" << rIF.nx() << "," << rIF.ny() << ")\n";
284 os << "Minimum: "<<min<<"\nMaximum: "<<max<<"\nMean: "<<mean<<"\nMedian: "<<median<<"\nMode: "<<mode<<"\nStandard Deviation: "<<stddev << "\n";
285 if (rIF.isComplex()) {
286 rIF.statistics (rIF.getImaginaryArray(), min, max, mean, mode, median, stddev);
287 os << "Imaginary: min: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmedian: "<<median<<"\nmode: "<<mode<<"\nstddev: "<<stddev << "\n";
289 if (rIF.nLabels() > 0) {
290 rIF.printLabelsBrief (os);
292 *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<\n";
293 wxMessageDialog dialogMsg (getFrameForChild(), os.str().c_str(), "Imagefile Properties", wxOK | wxICON_INFORMATION);
294 dialogMsg.ShowModal();
296 GetDocument()->Activate();
300 ImageFileView::OnScaleAuto (wxCommandEvent& event)
302 const ImageFile& rIF = GetDocument()->getImageFile();
303 double min, max, mean, mode, median, stddev;
304 rIF.statistics(min, max, mean, mode, median, stddev);
305 DialogAutoScaleParameters dialogAutoScale (getFrameForChild(), mean, mode, median, stddev, m_dAutoScaleFactor);
306 int iRetVal = dialogAutoScale.ShowModal();
307 if (iRetVal == wxID_OK) {
308 m_bMinSpecified = true;
309 m_bMaxSpecified = true;
311 if (dialogAutoScale.getMinMax (&dMin, &dMax)) {
314 m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
315 GetDocument()->UpdateAllViews (this);
318 GetDocument()->Activate();
322 ImageFileView::OnScaleMinMax (wxCommandEvent& event)
324 const ImageFile& rIF = GetDocument()->getImageFile();
326 if (! m_bMinSpecified && ! m_bMaxSpecified)
327 rIF.getMinMax (min, max);
334 DialogGetMinMax dialogMinMax (getFrameForChild(), "Set Image Minimum & Maximum", min, max);
335 int retVal = dialogMinMax.ShowModal();
336 if (retVal == wxID_OK) {
337 m_bMinSpecified = true;
338 m_bMaxSpecified = true;
339 m_dMinPixel = dialogMinMax.getMinimum();
340 m_dMaxPixel = dialogMinMax.getMaximum();
341 GetDocument()->UpdateAllViews (this);
343 GetDocument()->Activate();
347 ImageFileView::OnScaleFull (wxCommandEvent& event)
349 if (m_bMinSpecified || m_bMaxSpecified) {
350 m_bMinSpecified = false;
351 m_bMaxSpecified = false;
352 GetDocument()->UpdateAllViews (this);
354 GetDocument()->Activate();
358 ImageFileView::OnCompare (wxCommandEvent& event)
360 std::vector<ImageFileDocument*> vecIF;
361 theApp->getCompatibleImages (GetDocument(), vecIF);
363 if (vecIF.size() == 0) {
364 wxMessageBox("There are no compatible image files open for comparision", "No comparison images");
366 DialogGetComparisonImage dialogGetCompare(getFrameForChild(), "Get Comparison Image", vecIF, true);
368 if (dialogGetCompare.ShowModal() == wxID_OK) {
369 const ImageFile& rIF = GetDocument()->getImageFile();
370 ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();
371 const ImageFile& rCompareIF = pCompareDoc->getImageFile();
372 std::ostringstream os;
373 double min, max, mean, mode, median, stddev;
374 rIF.statistics (min, max, mean, mode, median, stddev);
375 os << GetFrame()->GetTitle().c_str() << ": minimum=" << min << ", maximum=" << max << ", mean=" << mean << ", mode=" << mode << ", median=" << median << ", stddev=" << stddev << "\n";
376 rCompareIF.statistics (min, max, mean, mode, median, stddev);
377 os << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str() << ": minimum=" << min << ", maximum=" << max << ", mean=" << mean << ", mode=" << mode << ", median=" << median << ", stddev=" << stddev << "\n";
379 rIF.comparativeStatistics (rCompareIF, d, r, e);
380 os << "Comparative Statistics: d=" << d << ", r=" << r << ", e=" << e << "\n";
381 *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<\n";
382 if (dialogGetCompare.getMakeDifferenceImage()) {
383 ImageFile* pDifferenceImage = new ImageFile;
385 pDifferenceImage->setArraySize (rIF.nx(), rIF.ny());
386 if (! rIF.subtractImages (rCompareIF, *pDifferenceImage)) {
387 *theApp->getLog() << "Unable to subtract images\n";
388 delete pDifferenceImage;
391 ImageFileDocument* pDifferenceDoc = theApp->newImageDoc();
392 if (! pDifferenceDoc) {
393 sys_error (ERR_SEVERE, "Unable to create image file");
396 pDifferenceDoc->setImageFile (pDifferenceImage);
398 wxString s = GetFrame()->GetTitle() + ": ";
399 pDifferenceImage->labelsCopy (rIF, s.c_str());
400 s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle() + ": ";
401 pDifferenceImage->labelsCopy (rCompareIF, s.c_str());
402 std::ostringstream osLabel;
403 osLabel << "Compare image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str()
404 << " and " << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str() << ": "
406 pDifferenceImage->labelAdd (os.str().c_str());
407 if (theApp->getAskDeleteNewDocs())
408 pDifferenceDoc->Modify (true);
409 pDifferenceDoc->UpdateAllViews (this);
410 pDifferenceDoc->getView()->OnUpdate (this, NULL);
411 pDifferenceDoc->getView()->getFrame()->Show(true);
412 pDifferenceDoc->Activate();
414 wxMessageBox(os.str().c_str(), "Image Comparison");
420 ImageFileView::OnInvertValues (wxCommandEvent& event)
422 ImageFile& rIF = GetDocument()->getImageFile();
423 rIF.invertPixelValues (rIF);
424 rIF.labelAdd ("Invert Pixel Values");
425 if (theApp->getAskDeleteNewDocs())
426 GetDocument()->Modify (true);
427 GetDocument()->UpdateAllViews (this);
428 GetDocument()->Activate();
432 ImageFileView::OnSquare (wxCommandEvent& event)
434 ImageFile& rIF = GetDocument()->getImageFile();
436 rIF.labelAdd ("Square Pixel Values");
437 if (theApp->getAskDeleteNewDocs())
438 GetDocument()->Modify (true);
439 GetDocument()->UpdateAllViews (this);
440 GetDocument()->Activate();
444 ImageFileView::OnSquareRoot (wxCommandEvent& event)
446 ImageFile& rIF = GetDocument()->getImageFile();
448 rIF.labelAdd ("Square-root Pixel Values");
449 if (theApp->getAskDeleteNewDocs())
450 GetDocument()->Modify (true);
451 GetDocument()->UpdateAllViews (this);
452 GetDocument()->Activate();
456 ImageFileView::OnLog (wxCommandEvent& event)
458 ImageFile& rIF = GetDocument()->getImageFile();
460 rIF.labelAdd ("Logrithm base-e Pixel Values");
461 if (theApp->getAskDeleteNewDocs())
462 GetDocument()->Modify (true);
463 GetDocument()->UpdateAllViews (this);
464 GetDocument()->Activate();
468 ImageFileView::OnExp (wxCommandEvent& event)
470 ImageFile& rIF = GetDocument()->getImageFile();
472 rIF.labelAdd ("Exponent base-e Pixel Values");
473 if (theApp->getAskDeleteNewDocs())
474 GetDocument()->Modify (true);
475 GetDocument()->UpdateAllViews (this);
476 GetDocument()->Activate();
480 ImageFileView::OnAdd (wxCommandEvent& event)
482 std::vector<ImageFileDocument*> vecIF;
483 theApp->getCompatibleImages (GetDocument(), vecIF);
485 if (vecIF.size() == 0) {
486 wxMessageBox ("There are no compatible image files open for comparision", "No comparison images");
488 DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Image to Add", vecIF, false);
490 if (dialogGetCompare.ShowModal() == wxID_OK) {
491 ImageFile& rIF = GetDocument()->getImageFile();
492 ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument();
493 const ImageFile& rRHSIF = pRHSDoc->getImageFile();
494 ImageFileDocument* pNewDoc = theApp->newImageDoc();
496 sys_error (ERR_SEVERE, "Unable to create image file");
499 ImageFile& newImage = pNewDoc->getImageFile();
500 newImage.setArraySize (rIF.nx(), rIF.ny());
501 rIF.addImages (rRHSIF, newImage);
502 std::ostringstream os;
503 os << "Add image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and "
504 << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
505 wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": ";
506 newImage.labelsCopy (rIF, s.c_str());
507 s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": ";
508 newImage.labelsCopy (rRHSIF, s.c_str());
509 newImage.labelAdd (os.str().c_str());
510 *theApp->getLog() << os.str().c_str() << "\n";
511 if (theApp->getAskDeleteNewDocs())
512 pNewDoc->Modify (true);
513 pNewDoc->UpdateAllViews (this);
514 pNewDoc->getView()->getFrame()->Show(true);
521 ImageFileView::OnSubtract (wxCommandEvent& event)
523 std::vector<ImageFileDocument*> vecIF;
524 theApp->getCompatibleImages (GetDocument(), vecIF);
526 if (vecIF.size() == 0) {
527 wxMessageBox ("There are no compatible image files open for comparision", "No comparison images");
529 DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Image to Subtract", vecIF, false);
531 if (dialogGetCompare.ShowModal() == wxID_OK) {
532 ImageFile& rIF = GetDocument()->getImageFile();
533 ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument();
534 const ImageFile& rRHSIF = pRHSDoc->getImageFile();
535 ImageFileDocument* pNewDoc = theApp->newImageDoc();
537 sys_error (ERR_SEVERE, "Unable to create image file");
540 ImageFile& newImage = pNewDoc->getImageFile();
541 newImage.setArraySize (rIF.nx(), rIF.ny());
542 rIF.subtractImages (rRHSIF, newImage);
543 std::ostringstream os;
544 os << "Subtract image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and "
545 << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
546 wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": ";
547 newImage.labelsCopy (rIF, s.c_str());
548 s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": ";
549 newImage.labelsCopy (rRHSIF, s.c_str());
550 newImage.labelAdd (os.str().c_str());
551 *theApp->getLog() << os.str().c_str() << "\n";
552 if (theApp->getAskDeleteNewDocs())
553 pNewDoc->Modify (true);
554 pNewDoc->UpdateAllViews (this);
555 pNewDoc->getView()->getFrame()->Show(true);
562 ImageFileView::OnMultiply (wxCommandEvent& event)
564 std::vector<ImageFileDocument*> vecIF;
565 theApp->getCompatibleImages (GetDocument(), vecIF);
567 if (vecIF.size() == 0) {
568 wxMessageBox ("There are no compatible image files open for comparision", "No comparison images");
570 DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Image to Multiply", vecIF, false);
572 if (dialogGetCompare.ShowModal() == wxID_OK) {
573 ImageFile& rIF = GetDocument()->getImageFile();
574 ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument();
575 const ImageFile& rRHSIF = pRHSDoc->getImageFile();
576 ImageFileDocument* pNewDoc = theApp->newImageDoc();
578 sys_error (ERR_SEVERE, "Unable to create image file");
581 ImageFile& newImage = pNewDoc->getImageFile();
582 newImage.setArraySize (rIF.nx(), rIF.ny());
583 rIF.multiplyImages (rRHSIF, newImage);
584 std::ostringstream os;
585 os << "Multiply image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and "
586 << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
587 wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": ";
588 newImage.labelsCopy (rIF, s.c_str());
589 s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": ";
590 newImage.labelsCopy (rRHSIF, s.c_str());
591 newImage.labelAdd (os.str().c_str());
592 *theApp->getLog() << os.str().c_str() << "\n";
593 if (theApp->getAskDeleteNewDocs())
594 pNewDoc->Modify (true);
595 pNewDoc->UpdateAllViews (this);
596 pNewDoc->getView()->getFrame()->Show(true);
603 ImageFileView::OnDivide (wxCommandEvent& event)
605 std::vector<ImageFileDocument*> vecIF;
606 theApp->getCompatibleImages (GetDocument(), vecIF);
608 if (vecIF.size() == 0) {
609 wxMessageBox ("There are no compatible image files open for comparision", "No comparison images");
611 DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Image to Divide", vecIF, false);
613 if (dialogGetCompare.ShowModal() == wxID_OK) {
614 ImageFile& rIF = GetDocument()->getImageFile();
615 ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument();
616 const ImageFile& rRHSIF = pRHSDoc->getImageFile();
617 ImageFileDocument* pNewDoc = theApp->newImageDoc();
619 sys_error (ERR_SEVERE, "Unable to create image file");
622 ImageFile& newImage = pNewDoc->getImageFile();
623 newImage.setArraySize (rIF.nx(), rIF.ny());
624 rIF.divideImages (rRHSIF, newImage);
625 std::ostringstream os;
626 os << "Divide image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " by "
627 << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
628 wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": ";
629 newImage.labelsCopy (rIF, s.c_str());
630 s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": ";
631 newImage.labelsCopy (rRHSIF, s.c_str());
632 newImage.labelAdd (os.str().c_str());
633 *theApp->getLog() << os.str().c_str() << "\n";
634 if (theApp->getAskDeleteNewDocs())
635 pNewDoc->Modify (true);
636 pNewDoc->UpdateAllViews (this);
637 pNewDoc->getView()->getFrame()->Show(true);
646 ImageFileView::OnFFT (wxCommandEvent& event)
648 ImageFile& rIF = GetDocument()->getImageFile();
650 rIF.labelAdd ("FFT Image");
651 m_bMinSpecified = false;
652 m_bMaxSpecified = false;
653 if (theApp->getAskDeleteNewDocs())
654 GetDocument()->Modify (true);
655 GetDocument()->UpdateAllViews (this);
656 GetDocument()->Activate();
660 ImageFileView::OnIFFT (wxCommandEvent& event)
662 ImageFile& rIF = GetDocument()->getImageFile();
664 rIF.labelAdd ("IFFT Image");
665 m_bMinSpecified = false;
666 m_bMaxSpecified = false;
667 if (theApp->getAskDeleteNewDocs())
668 GetDocument()->Modify (true);
669 GetDocument()->UpdateAllViews (this);
670 GetDocument()->Activate();
674 ImageFileView::OnFFTRows (wxCommandEvent& event)
676 ImageFile& rIF = GetDocument()->getImageFile();
678 rIF.labelAdd ("FFT Rows");
679 m_bMinSpecified = false;
680 m_bMaxSpecified = false;
681 if (theApp->getAskDeleteNewDocs())
682 GetDocument()->Modify (true);
683 GetDocument()->UpdateAllViews (this);
684 GetDocument()->Activate();
688 ImageFileView::OnIFFTRows (wxCommandEvent& event)
690 ImageFile& rIF = GetDocument()->getImageFile();
692 rIF.labelAdd ("IFFT Rows");
693 m_bMinSpecified = false;
694 m_bMaxSpecified = false;
695 if (theApp->getAskDeleteNewDocs())
696 GetDocument()->Modify (true);
697 GetDocument()->UpdateAllViews (this);
698 GetDocument()->Activate();
702 ImageFileView::OnFFTCols (wxCommandEvent& event)
704 ImageFile& rIF = GetDocument()->getImageFile();
706 rIF.labelAdd ("FFT Columns");
707 m_bMinSpecified = false;
708 m_bMaxSpecified = false;
709 if (theApp->getAskDeleteNewDocs())
710 GetDocument()->Modify (true);
711 GetDocument()->UpdateAllViews (this);
712 GetDocument()->Activate();
716 ImageFileView::OnIFFTCols (wxCommandEvent& event)
718 ImageFile& rIF = GetDocument()->getImageFile();
720 rIF.labelAdd ("IFFT Columns");
721 m_bMinSpecified = false;
722 m_bMaxSpecified = false;
723 if (theApp->getAskDeleteNewDocs())
724 GetDocument()->Modify (true);
725 GetDocument()->UpdateAllViews (this);
726 GetDocument()->Activate();
731 ImageFileView::OnFourier (wxCommandEvent& event)
733 ImageFile& rIF = GetDocument()->getImageFile();
734 wxProgressDialog dlgProgress (wxString("Fourier"), wxString("Fourier Progress"), 1, getFrameForChild(), wxPD_APP_MODAL);
736 rIF.labelAdd ("Fourier Image");
737 m_bMinSpecified = false;
738 m_bMaxSpecified = false;
739 if (theApp->getAskDeleteNewDocs())
740 GetDocument()->Modify (true);
741 GetDocument()->UpdateAllViews (this);
742 GetDocument()->Activate();
746 ImageFileView::OnInverseFourier (wxCommandEvent& event)
748 ImageFile& rIF = GetDocument()->getImageFile();
749 wxProgressDialog dlgProgress (wxString("Inverse Fourier"), wxString("Inverse Fourier Progress"), 1, getFrameForChild(), wxPD_APP_MODAL);
750 rIF.inverseFourier (rIF);
751 rIF.labelAdd ("Inverse Fourier Image");
752 m_bMinSpecified = false;
753 m_bMaxSpecified = false;
754 if (theApp->getAskDeleteNewDocs())
755 GetDocument()->Modify (true);
756 GetDocument()->UpdateAllViews (this);
757 GetDocument()->Activate();
761 ImageFileView::OnShuffleNaturalToFourierOrder (wxCommandEvent& event)
763 ImageFile& rIF = GetDocument()->getImageFile();
764 Fourier::shuffleNaturalToFourierOrder (rIF);
765 rIF.labelAdd ("Shuffle Natural To Fourier Order");
766 m_bMinSpecified = false;
767 m_bMaxSpecified = false;
768 if (theApp->getAskDeleteNewDocs())
769 GetDocument()->Modify (true);
770 GetDocument()->UpdateAllViews (this);
771 GetDocument()->Activate();
775 ImageFileView::OnShuffleFourierToNaturalOrder (wxCommandEvent& event)
777 ImageFile& rIF = GetDocument()->getImageFile();
778 Fourier::shuffleFourierToNaturalOrder (rIF);
779 rIF.labelAdd ("Shuffle Fourier To Natural Order");
780 m_bMinSpecified = false;
781 m_bMaxSpecified = false;
782 if (theApp->getAskDeleteNewDocs())
783 GetDocument()->Modify (true);
784 GetDocument()->UpdateAllViews (this);
785 GetDocument()->Activate();
789 ImageFileView::OnMagnitude (wxCommandEvent& event)
791 ImageFile& rIF = GetDocument()->getImageFile();
792 if (rIF.isComplex()) {
794 rIF.labelAdd ("Magnitude of complex-image");
795 m_bMinSpecified = false;
796 m_bMaxSpecified = false;
797 if (theApp->getAskDeleteNewDocs())
798 GetDocument()->Modify (true);
799 GetDocument()->UpdateAllViews (this);
801 GetDocument()->Activate();
805 ImageFileView::OnPhase (wxCommandEvent& event)
807 ImageFile& rIF = GetDocument()->getImageFile();
808 if (rIF.isComplex()) {
810 rIF.labelAdd ("Phase of complex-image");
811 m_bMinSpecified = false;
812 m_bMaxSpecified = false;
813 if (theApp->getAskDeleteNewDocs())
814 GetDocument()->Modify (true);
815 GetDocument()->UpdateAllViews (this);
817 GetDocument()->Activate();
822 ImageFileView::CreateCanvas (wxFrame* parent)
824 ImageFileCanvas* pCanvas;
826 parent->GetClientSize(&width, &height);
828 pCanvas = new ImageFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
830 pCanvas->SetScrollbars(20, 20, 50, 50);
831 pCanvas->SetBackgroundColour(*wxWHITE);
842 ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
845 wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
847 wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
849 theApp->setIconForFrame (subframe);
851 m_pFileMenu = new wxMenu;
853 m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
854 m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
855 m_pFileMenu->Append(wxID_OPEN, "&Open...\tCtrl-O");
856 m_pFileMenu->Append(wxID_SAVE, "&Save\tCtrl-S");
857 m_pFileMenu->Append(wxID_SAVEAS, "Save &As...");
858 m_pFileMenu->Append(wxID_CLOSE, "&Close\tCtrl-W");
859 m_pFileMenu->Append(wxID_REVERT, "Re&vert");
861 m_pFileMenu->AppendSeparator();
862 m_pFileMenu->Append(IFMENU_FILE_PROPERTIES, "P&roperties\tCtrl-I");
863 m_pFileMenu->Append(IFMENU_FILE_EXPORT, "Expor&t...");
865 m_pFileMenu->AppendSeparator();
866 m_pFileMenu->Append(wxID_PRINT, "&Print...");
867 m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
868 m_pFileMenu->Append(wxID_PREVIEW, "Print Preview");
869 m_pFileMenu->AppendSeparator();
870 m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
872 m_pFileMenu->AppendSeparator();
873 m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
874 m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
876 GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
877 GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
879 wxMenu* edit_menu = new wxMenu;
880 edit_menu->Append(IFMENU_EDIT_COPY, "Copy\tCtrl-C");
881 edit_menu->Append(IFMENU_EDIT_CUT, "Cut\tCtrl-X");
882 edit_menu->Append(IFMENU_EDIT_PASTE, "Paste\tCtrl-V");
884 wxMenu *view_menu = new wxMenu;
885 view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale S&et...\tCtrl-E");
886 view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...\tCtrl-A");
887 view_menu->Append(IFMENU_VIEW_SCALE_FULL, "Display F&ull Scale\tCtrl-U");
889 wxMenu* filter_menu = new wxMenu;
890 filter_menu->Append (IFMENU_FILTER_INVERTVALUES, "In&vert Values");
891 filter_menu->Append (IFMENU_FILTER_SQUARE, "&Square");
892 filter_menu->Append (IFMENU_FILTER_SQRT, "Square &Root");
893 filter_menu->Append (IFMENU_FILTER_LOG, "&Log");
894 filter_menu->Append (IFMENU_FILTER_EXP, "&Exp");
895 filter_menu->AppendSeparator();
897 filter_menu->Append (IFMENU_FILTER_FFT, "2-D &FFT");
898 filter_menu->Append (IFMENU_FILTER_IFFT, "2-D &IFFT");
899 filter_menu->Append (IFMENU_FILTER_FFT_ROWS, "FFT Rows");
900 filter_menu->Append (IFMENU_FILTER_IFFT_ROWS, "IFFT Rows");
901 filter_menu->Append (IFMENU_FILTER_FFT_COLS, "FFT Columns");
902 filter_menu->Append (IFMENU_FILTER_IFFT_COLS, "IFFT Columns");
903 filter_menu->Append (IFMENU_FILTER_FOURIER, "2-D F&ourier");
904 filter_menu->Append (IFMENU_FILTER_INVERSE_FOURIER, "2-D Inverse Fo&urier");
906 filter_menu->Append (IFMENU_FILTER_FOURIER, "&Fourier");
907 filter_menu->Append (IFMENU_FILTER_INVERSE_FOURIER, "&Inverse Fourier");
909 filter_menu->Append (IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER, "S&huffle Fourier to Natural Order");
910 filter_menu->Append (IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER, "Shu&ffle Natural to Fourier Order");
911 filter_menu->Append (IFMENU_FILTER_MAGNITUDE, "&Magnitude");
912 filter_menu->Append (IFMENU_FILTER_PHASE, "&Phase");
914 wxMenu* image_menu = new wxMenu;
915 image_menu->Append (IFMENU_IMAGE_ADD, "&Add...");
916 image_menu->Append (IFMENU_IMAGE_SUBTRACT, "&Subtract...");
917 image_menu->Append (IFMENU_IMAGE_MULTIPLY, "&Multiply...");
918 image_menu->Append (IFMENU_IMAGE_DIVIDE, "&Divide...");
919 image_menu->AppendSeparator();
920 image_menu->Append (IFMENU_IMAGE_SCALESIZE, "S&cale Size...");
922 image_menu->Append (IFMENU_IMAGE_CONVERT3D, "Convert &3-D\tCtrl-3");
925 m_pMenuAnalyze = new wxMenu;
926 m_pMenuAnalyze->Append (IFMENU_PLOT_ROW, "Plot &Row");
927 m_pMenuAnalyze->Append (IFMENU_PLOT_COL, "Plot &Column");
928 m_pMenuAnalyze->Append (IFMENU_PLOT_HISTOGRAM, "Plot &Histogram");
929 m_pMenuAnalyze->AppendSeparator();
930 m_pMenuAnalyze->Append (IFMENU_PLOT_FFT_ROW, "P&lot FFT Row");
931 m_pMenuAnalyze->Append (IFMENU_PLOT_FFT_COL, "Plo&t FFT Column");
932 m_pMenuAnalyze->AppendSeparator();
933 m_pMenuAnalyze->Append (IFMENU_COMPARE_IMAGES, "Compare &Images...");
934 m_pMenuAnalyze->Append (IFMENU_COMPARE_ROW, "Compare Ro&w");
935 m_pMenuAnalyze->Append (IFMENU_COMPARE_COL, "Compare Colu&mn");
936 m_pMenuAnalyze->Enable (IFMENU_PLOT_ROW, false);
937 m_pMenuAnalyze->Enable (IFMENU_PLOT_COL, false);
938 m_pMenuAnalyze->Enable (IFMENU_COMPARE_ROW, false);
939 m_pMenuAnalyze->Enable (IFMENU_COMPARE_COL, false);
940 m_pMenuAnalyze->Enable (IFMENU_PLOT_FFT_ROW, false);
941 m_pMenuAnalyze->Enable (IFMENU_PLOT_FFT_COL, false);
943 wxMenu *help_menu = new wxMenu;
944 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
945 help_menu->Append (MAINMENU_HELP_TIPS, "&Tips");
946 help_menu->Append (IDH_QUICKSTART, "&Quick Start");
947 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
949 wxMenuBar *menu_bar = new wxMenuBar;
951 menu_bar->Append(m_pFileMenu, "&File");
952 menu_bar->Append(edit_menu, "&Edit");
953 menu_bar->Append(view_menu, "&View");
954 menu_bar->Append(image_menu, "&Image");
955 menu_bar->Append(filter_menu, "Fi<er");
956 menu_bar->Append(m_pMenuAnalyze, "&Analyze");
957 menu_bar->Append(help_menu, "&Help");
959 subframe->SetMenuBar(menu_bar);
961 subframe->Centre(wxBOTH);
963 wxAcceleratorEntry accelEntries[8];
964 accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('A'), IFMENU_VIEW_SCALE_AUTO);
965 accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('U'), IFMENU_VIEW_SCALE_FULL);
966 accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('E'), IFMENU_VIEW_SCALE_MINMAX);
967 accelEntries[3].Set (wxACCEL_CTRL, static_cast<int>('I'), IFMENU_FILE_PROPERTIES);
968 accelEntries[4].Set (wxACCEL_CTRL, static_cast<int>('C'), IFMENU_EDIT_COPY);
969 accelEntries[5].Set (wxACCEL_CTRL, static_cast<int>('X'), IFMENU_EDIT_CUT);
970 accelEntries[6].Set (wxACCEL_CTRL, static_cast<int>('V'), IFMENU_EDIT_PASTE);
971 #ifdef wxUSE_GLCANVAS
972 accelEntries[7].Set (wxACCEL_CTRL, static_cast<int>('3'), IFMENU_IMAGE_CONVERT3D);
973 wxAcceleratorTable accelTable (8, accelEntries);
975 wxAcceleratorTable accelTable (7, accelEntries);
978 subframe->SetAcceleratorTable (accelTable);
985 ImageFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
987 m_pFrame = CreateChildFrame(doc, this);
989 m_bMinSpecified = false;
990 m_bMaxSpecified = false;
991 m_dAutoScaleFactor = 1.;
994 m_pFrame->GetClientSize (&width, &height);
995 m_pFrame->SetTitle("ImageFileView");
996 m_pCanvas = CreateCanvas (m_pFrame);
998 int x, y; // X requires a forced resize
999 m_pFrame->GetSize(&x, &y);
1000 m_pFrame->SetSize(-1, -1, x, y);
1001 m_pFrame->SetFocus();
1002 m_pFrame->Show(true);
1009 ImageFileView::OnDraw (wxDC* dc)
1011 wxSize sizeWindow = m_pFrame->GetClientSize();
1012 wxSize sizeBest = m_pCanvas->GetBestSize();
1013 if (sizeWindow.x > sizeBest.x || sizeWindow.y > sizeBest.y)
1014 m_pFrame->SetClientSize (sizeBest);
1017 dc->DrawBitmap(m_bitmap, 0, 0, false);
1019 int xCursor, yCursor;
1020 if (m_pCanvas->GetCurrentCursor (xCursor, yCursor))
1021 m_pCanvas->DrawRubberBandCursor (*dc, xCursor, yCursor);
1026 ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
1028 const ImageFile& rIF = GetDocument()->getImageFile();
1029 ImageFileArrayConst v = rIF.getArray();
1032 if (v != NULL && nx != 0 && ny != 0) {
1033 if (! m_bMinSpecified || ! m_bMaxSpecified) {
1035 rIF.getMinMax (min, max);
1036 if (! m_bMinSpecified)
1038 if (! m_bMaxSpecified)
1041 double scaleWidth = m_dMaxPixel - m_dMinPixel;
1043 unsigned char* imageData = new unsigned char [nx * ny * 3];
1045 sys_error (ERR_SEVERE, "Unable to allocate memory for Image display");
1048 for (int ix = 0; ix < nx; ix++) {
1049 for (int iy = 0; iy < ny; iy++) {
1050 double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255;
1051 int intensity = static_cast<int>(scaleValue + 0.5);
1052 intensity = clamp (intensity, 0, 255);
1053 int baseAddr = ((ny - 1 - iy) * nx + ix) * 3;
1054 imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
1057 wxImage image (nx, ny, imageData, true);
1058 m_bitmap = image.ConvertToBitmap();
1062 ySize = clamp (ySize, 0, 800);
1063 m_pFrame->SetClientSize (xSize, ySize);
1064 m_pCanvas->SetScrollbars(20, 20, nx/20, ny/20);
1065 m_pCanvas->SetBackgroundColour(*wxWHITE);
1069 m_pCanvas->Refresh();
1073 ImageFileView::OnClose (bool deleteWindow)
1075 //GetDocumentManager()->ActivateView (this, false, true);
1076 if (! GetDocument() || ! GetDocument()->Close())
1081 m_pCanvas->setView(NULL);
1084 wxString s(theApp->GetAppName());
1086 m_pFrame->SetTitle(s);
1093 if (GetDocument() && GetDocument()->getBadFileOpen())
1094 ::wxYield(); // wxWindows bug workaround
1101 ImageFileView::OnEditCopy (wxCommandEvent& event)
1103 wxBitmapDataObject *pBitmapObject = new wxBitmapDataObject;
1105 pBitmapObject->SetBitmap (m_bitmap);
1107 if (wxTheClipboard->Open()) {
1108 wxTheClipboard->SetData (pBitmapObject);
1109 wxTheClipboard->Close();
1114 ImageFileView::OnEditCut (wxCommandEvent& event)
1117 ImageFile& rIF = GetDocument()->getImageFile();
1120 ImageFile* pIF = new ImageFile (nx, ny);
1121 pIF->arrayDataClear();
1122 GetDocument()->setImageFile (pIF); // deletes old IF
1123 OnUpdate(this, NULL);
1124 GetDocument()->UpdateAllViews();
1125 if (theApp->getAskDeleteNewDocs())
1126 GetDocument()->Modify (true);
1130 ImageFileView::OnEditPaste (wxCommandEvent& event)
1132 ImageFile& rIF = GetDocument()->getImageFile();
1134 if (wxTheClipboard->Open()) {
1136 if (wxTheClipboard->IsSupported (wxDF_BITMAP)) {
1137 wxBitmapDataObject bitmapObject;
1138 wxTheClipboard->GetData (bitmapObject);
1139 bitmap = bitmapObject.GetBitmap ();
1141 wxTheClipboard->Close();
1145 if (bitmap.Ok() == true && bitmap.GetWidth() == nx && bitmap.GetHeight() == ny) {
1146 wxImage image (bitmap);
1147 unsigned char* pixels = image.GetData();
1148 ImageFileArray v = rIF.getArray();
1149 for (int ix = 0; ix < rIF.nx(); ix++) {
1150 for (int iy = 0; iy < rIF.ny(); iy++) {
1151 unsigned int iBase = 3 * (iy * nx + ix);
1152 double dR = pixels[iBase] / 255.;
1153 double dG = pixels[iBase+1] / 255.;
1154 double dB = pixels[iBase+2] / 255.;
1155 v[ix][ny - 1 - iy] = ImageFile::colorToGrayscale (dR, dG, dB);
1158 OnUpdate(this, NULL);
1159 GetDocument()->UpdateAllViews();
1160 if (theApp->getAskDeleteNewDocs())
1161 GetDocument()->Modify(true);
1167 ImageFileView::OnExport (wxCommandEvent& event)
1169 ImageFile& rIF = GetDocument()->getImageFile();
1170 ImageFileArrayConst v = rIF.getArray();
1173 if (v != NULL && nx != 0 && ny != 0) {
1174 if (! m_bMinSpecified || ! m_bMaxSpecified) {
1176 rIF.getMinMax (min, max);
1177 if (! m_bMinSpecified)
1179 if (! m_bMaxSpecified)
1183 DialogExportParameters dialogExport (getFrameForChild(), m_iDefaultExportFormatID);
1184 if (dialogExport.ShowModal() == wxID_OK) {
1185 wxString strFormatName (dialogExport.getFormatName ());
1186 m_iDefaultExportFormatID = ImageFile::convertExportFormatNameToID (strFormatName.c_str());
1189 wxString strWildcard;
1190 if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PGM || m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PGMASCII) {
1192 strWildcard = "PGM Files (*.pgm)|*.pgm";
1195 else if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PNG || m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PNG16) {
1197 strWildcard = "PNG Files (*.png)|*.png";
1200 #ifdef HAVE_CTN_DICOM
1201 else if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_DICOM) {
1203 strWildcard = "DICOM Files (*.*)|*.*";
1206 else if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_TEXT) {
1208 strWildcard = "Text (*.txt)|*.txt";
1212 strWildcard = "Miscellaneous (*.*)|*.*";
1215 const wxString& strFilename = wxFileSelector (wxString("Export Filename"), wxString(""),
1216 wxString(""), strExt, strWildcard, wxOVERWRITE_PROMPT | wxHIDE_READONLY | wxSAVE);
1218 rIF.exportImage (strFormatName.c_str(), strFilename.c_str(), 1, 1, m_dMinPixel, m_dMaxPixel);
1219 *theApp->getLog() << "Exported file " << strFilename << "\n";
1226 ImageFileView::OnScaleSize (wxCommandEvent& event)
1228 ImageFile& rIF = GetDocument()->getImageFile();
1229 unsigned int iOldNX = rIF.nx();
1230 unsigned int iOldNY = rIF.ny();
1232 DialogGetXYSize dialogGetXYSize (getFrameForChild(), "Set New X & Y Dimensions", iOldNX, iOldNY);
1233 if (dialogGetXYSize.ShowModal() == wxID_OK) {
1234 unsigned int iNewNX = dialogGetXYSize.getXSize();
1235 unsigned int iNewNY = dialogGetXYSize.getYSize();
1236 std::ostringstream os;
1237 os << "Scale Size from (" << iOldNX << "," << iOldNY << ") to (" << iNewNX << "," << iNewNY << ")";
1238 ImageFileDocument* pScaledDoc = theApp->newImageDoc();
1240 sys_error (ERR_SEVERE, "Unable to create image file");
1243 ImageFile& rScaledIF = pScaledDoc->getImageFile();
1244 rScaledIF.setArraySize (iNewNX, iNewNY);
1245 rScaledIF.labelsCopy (rIF);
1246 rScaledIF.labelAdd (os.str().c_str());
1247 rIF.scaleImage (rScaledIF);
1248 *theApp->getLog() << os.str().c_str() << "\n";
1249 if (theApp->getAskDeleteNewDocs())
1250 pScaledDoc->Modify (true);
1251 pScaledDoc->UpdateAllViews (this);
1252 pScaledDoc->getView()->getFrame()->Show(true);
1253 pScaledDoc->Activate();
1259 ImageFileView::OnConvert3d (wxCommandEvent& event)
1261 ImageFile& rIF = GetDocument()->getImageFile();
1262 Graph3dFileDocument* pGraph3d = theApp->newGraph3dDoc();
1263 pGraph3d->setBadFileOpen();
1264 pGraph3d->createFromImageFile (rIF);
1265 pGraph3d->getView()->OnUpdate (this, NULL);
1266 pGraph3d->UpdateAllViews();
1267 pGraph3d->getView()->getFrame()->SetClientSize (400, 400);
1268 pGraph3d->getView()->getFrame()->Show (true);
1269 GetDocumentManager()->ActivateView (pGraph3d->getView(), true, false);
1271 pGraph3d->getView()->getCanvas()->SetFocus();
1276 ImageFileView::OnPlotRow (wxCommandEvent& event)
1278 int xCursor, yCursor;
1279 if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
1280 wxMessageBox ("No row selected. Please use left mouse button on image to select column","Error");
1284 const ImageFile& rIF = GetDocument()->getImageFile();
1285 ImageFileArrayConst v = rIF.getArray();
1286 ImageFileArrayConst vImag = rIF.getImaginaryArray();
1290 if (v != NULL && yCursor < ny) {
1291 double* pX = new double [nx];
1292 double* pYReal = new double [nx];
1293 double *pYImag = NULL;
1294 double *pYMag = NULL;
1295 if (rIF.isComplex()) {
1296 pYImag = new double [nx];
1297 pYMag = new double [nx];
1299 for (int i = 0; i < nx; i++) {
1301 pYReal[i] = v[i][yCursor];
1302 if (rIF.isComplex()) {
1303 pYImag[i] = vImag[i][yCursor];
1304 pYMag[i] = ::sqrt (v[i][yCursor] * v[i][yCursor] + vImag[i][yCursor] * vImag[i][yCursor]);
1307 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
1309 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
1311 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
1312 std::ostringstream os;
1313 os << "Row " << yCursor;
1314 std::string title("title ");
1316 rPlotFile.addEzsetCommand (title.c_str());
1317 rPlotFile.addEzsetCommand ("xlabel Column");
1318 rPlotFile.addEzsetCommand ("ylabel Pixel Value");
1319 rPlotFile.addEzsetCommand ("lxfrac 0");
1320 rPlotFile.addEzsetCommand ("box");
1321 rPlotFile.addEzsetCommand ("grid");
1322 rPlotFile.addEzsetCommand ("curve 1");
1323 rPlotFile.addEzsetCommand ("color 1");
1324 if (rIF.isComplex()) {
1325 rPlotFile.addEzsetCommand ("dash 1");
1326 rPlotFile.addEzsetCommand ("curve 2");
1327 rPlotFile.addEzsetCommand ("color 4");
1328 rPlotFile.addEzsetCommand ("dash 3");
1329 rPlotFile.addEzsetCommand ("curve 3");
1330 rPlotFile.addEzsetCommand ("color 0");
1331 rPlotFile.addEzsetCommand ("solid");
1332 rPlotFile.setCurveSize (4, nx);
1334 rPlotFile.setCurveSize (2, nx);
1335 rPlotFile.addColumn (0, pX);
1336 rPlotFile.addColumn (1, pYReal);
1337 if (rIF.isComplex()) {
1338 rPlotFile.addColumn (2, pYImag);
1339 rPlotFile.addColumn (3, pYMag);
1341 for (unsigned int iL = 0; iL < rIF.nLabels(); iL++)
1342 rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str());
1343 os << " Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1344 *theApp->getLog() << os.str().c_str() << "\n";
1345 rPlotFile.addDescription (os.str().c_str());
1349 if (rIF.isComplex()) {
1353 if (theApp->getAskDeleteNewDocs())
1354 pPlotDoc->Modify (true);
1355 pPlotDoc->getView()->getFrame()->Show(true);
1356 pPlotDoc->UpdateAllViews ();
1357 pPlotDoc->Activate();
1362 ImageFileView::OnPlotCol (wxCommandEvent& event)
1364 int xCursor, yCursor;
1365 if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
1366 wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");
1370 const ImageFile& rIF = GetDocument()->getImageFile();
1371 ImageFileArrayConst v = rIF.getArray();
1372 ImageFileArrayConst vImag = rIF.getImaginaryArray();
1376 if (v != NULL && xCursor < nx) {
1377 double* pX = new double [ny];
1378 double* pYReal = new double [ny];
1379 double* pYImag = NULL;
1380 double* pYMag = NULL;
1381 if (rIF.isComplex()) {
1382 pYImag = new double [ny];
1383 pYMag = new double [ny];
1385 for (int i = 0; i < ny; i++) {
1387 pYReal[i] = v[xCursor][i];
1388 if (rIF.isComplex()) {
1389 pYImag[i] = vImag[xCursor][i];
1390 pYMag[i] = ::sqrt (v[xCursor][i] * v[xCursor][i] + vImag[xCursor][i] * vImag[xCursor][i]);
1393 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
1395 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
1397 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
1398 std::ostringstream os;
1399 os << "Column " << xCursor;
1400 std::string title("title ");
1402 rPlotFile.addEzsetCommand (title.c_str());
1403 rPlotFile.addEzsetCommand ("xlabel Row");
1404 rPlotFile.addEzsetCommand ("ylabel Pixel Value");
1405 rPlotFile.addEzsetCommand ("lxfrac 0");
1406 rPlotFile.addEzsetCommand ("box");
1407 rPlotFile.addEzsetCommand ("grid");
1408 rPlotFile.addEzsetCommand ("curve 1");
1409 rPlotFile.addEzsetCommand ("color 1");
1410 if (rIF.isComplex()) {
1411 rPlotFile.addEzsetCommand ("dash 1");
1412 rPlotFile.addEzsetCommand ("curve 2");
1413 rPlotFile.addEzsetCommand ("color 4");
1414 rPlotFile.addEzsetCommand ("dash 3");
1415 rPlotFile.addEzsetCommand ("curve 3");
1416 rPlotFile.addEzsetCommand ("color 0");
1417 rPlotFile.addEzsetCommand ("solid");
1418 rPlotFile.setCurveSize (4, ny);
1420 rPlotFile.setCurveSize (2, ny);
1421 rPlotFile.addColumn (0, pX);
1422 rPlotFile.addColumn (1, pYReal);
1423 if (rIF.isComplex()) {
1424 rPlotFile.addColumn (2, pYImag);
1425 rPlotFile.addColumn (3, pYMag);
1427 for (unsigned int iL = 0; iL < rIF.nLabels(); iL++)
1428 rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str());
1429 os << " Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1430 *theApp->getLog() << os.str().c_str() << "\n";
1431 rPlotFile.addDescription (os.str().c_str());
1435 if (rIF.isComplex()) {
1439 if (theApp->getAskDeleteNewDocs())
1440 pPlotDoc->Modify (true);
1441 pPlotDoc->getView()->getFrame()->Show(true);
1442 pPlotDoc->UpdateAllViews ();
1443 pPlotDoc->Activate();
1449 ImageFileView::OnPlotFFTRow (wxCommandEvent& event)
1451 int xCursor, yCursor;
1452 if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
1453 wxMessageBox ("No row selected. Please use left mouse button on image to select column","Error");
1457 const ImageFile& rIF = GetDocument()->getImageFile();
1458 ImageFileArrayConst v = rIF.getArray();
1459 ImageFileArrayConst vImag = rIF.getImaginaryArray();
1463 if (v != NULL && yCursor < ny) {
1464 fftw_complex* pcIn = new fftw_complex [nx];
1467 for (i = 0; i < nx; i++) {
1468 pcIn[i].re = v[i][yCursor];
1469 if (rIF.isComplex())
1470 pcIn[i].im = vImag[i][yCursor];
1475 fftw_plan plan = fftw_create_plan (nx, FFTW_FORWARD, FFTW_IN_PLACE);
1476 fftw_one (plan, pcIn, NULL);
1477 fftw_destroy_plan (plan);
1479 double* pX = new double [nx];
1480 double* pYReal = new double [nx];
1481 double* pYImag = new double [nx];
1482 double* pYMag = new double [nx];
1483 for (i = 0; i < nx; i++) {
1485 pYReal[i] = pcIn[i].re;
1486 pYImag[i] = pcIn[i].im;
1487 pYMag[i] = ::sqrt (pcIn[i].re * pcIn[i].re + pcIn[i].im * pcIn[i].im);
1489 Fourier::shuffleFourierToNaturalOrder (pYReal, nx);
1490 Fourier::shuffleFourierToNaturalOrder (pYImag, nx);
1491 Fourier::shuffleFourierToNaturalOrder (pYMag, nx);
1493 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
1495 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
1497 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
1498 std::ostringstream os;
1499 os << "Row " << yCursor;
1500 std::string title("title ");
1502 rPlotFile.addEzsetCommand (title.c_str());
1503 rPlotFile.addEzsetCommand ("xlabel Column");
1504 rPlotFile.addEzsetCommand ("ylabel Pixel Value");
1505 rPlotFile.addEzsetCommand ("lxfrac 0");
1506 rPlotFile.addEzsetCommand ("curve 1");
1507 rPlotFile.addEzsetCommand ("color 1");
1508 rPlotFile.addEzsetCommand ("dash 1");
1509 rPlotFile.addEzsetCommand ("curve 2");
1510 rPlotFile.addEzsetCommand ("color 4");
1511 rPlotFile.addEzsetCommand ("dash 3");
1512 rPlotFile.addEzsetCommand ("curve 3");
1513 rPlotFile.addEzsetCommand ("color 0");
1514 rPlotFile.addEzsetCommand ("solid");
1515 rPlotFile.addEzsetCommand ("box");
1516 rPlotFile.addEzsetCommand ("grid");
1517 rPlotFile.setCurveSize (4, nx);
1518 rPlotFile.addColumn (0, pX);
1519 rPlotFile.addColumn (1, pYReal);
1520 rPlotFile.addColumn (2, pYImag);
1521 rPlotFile.addColumn (3, pYMag);
1522 for (unsigned int iL = 0; iL < rIF.nLabels(); iL++)
1523 rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str());
1524 os << " FFT Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1525 *theApp->getLog() << os.str().c_str() << "\n";
1526 rPlotFile.addDescription (os.str().c_str());
1534 if (theApp->getAskDeleteNewDocs())
1535 pPlotDoc->Modify (true);
1536 pPlotDoc->getView()->getFrame()->Show(true);
1537 pPlotDoc->UpdateAllViews ();
1538 pPlotDoc->Activate();
1543 ImageFileView::OnPlotFFTCol (wxCommandEvent& event)
1545 int xCursor, yCursor;
1546 if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
1547 wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");
1551 const ImageFile& rIF = GetDocument()->getImageFile();
1552 ImageFileArrayConst v = rIF.getArray();
1553 ImageFileArrayConst vImag = rIF.getImaginaryArray();
1557 if (v != NULL && xCursor < nx) {
1558 fftw_complex* pcIn = new fftw_complex [ny];
1559 double *pdTemp = new double [ny];
1562 for (i = 0; i < ny; i++)
1563 pdTemp[i] = v[xCursor][i];
1564 Fourier::shuffleNaturalToFourierOrder (pdTemp, ny);
1565 for (i = 0; i < ny; i++)
1566 pcIn[i].re = pdTemp[i];
1568 for (i = 0; i < ny; i++) {
1569 if (rIF.isComplex())
1570 pdTemp[i] = vImag[xCursor][i];
1574 Fourier::shuffleNaturalToFourierOrder (pdTemp, ny);
1575 for (i = 0; i < ny; i++)
1576 pcIn[i].im = pdTemp[i];
1578 fftw_plan plan = fftw_create_plan (ny, FFTW_BACKWARD, FFTW_IN_PLACE);
1579 fftw_one (plan, pcIn, NULL);
1580 fftw_destroy_plan (plan);
1582 double* pX = new double [ny];
1583 double* pYReal = new double [ny];
1584 double* pYImag = new double [ny];
1585 double* pYMag = new double [ny];
1586 for (i = 0; i < ny; i++) {
1588 pYReal[i] = pcIn[i].re;
1589 pYImag[i] = pcIn[i].im;
1590 pYMag[i] = ::sqrt (pcIn[i].re * pcIn[i].re + pcIn[i].im * pcIn[i].im);
1593 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
1595 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
1597 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
1598 std::ostringstream os;
1599 os << "Column " << xCursor;
1600 std::string title("title ");
1602 rPlotFile.addEzsetCommand (title.c_str());
1603 rPlotFile.addEzsetCommand ("xlabel Column");
1604 rPlotFile.addEzsetCommand ("ylabel Pixel Value");
1605 rPlotFile.addEzsetCommand ("lxfrac 0");
1606 rPlotFile.addEzsetCommand ("curve 1");
1607 rPlotFile.addEzsetCommand ("color 1");
1608 rPlotFile.addEzsetCommand ("dash 1");
1609 rPlotFile.addEzsetCommand ("curve 2");
1610 rPlotFile.addEzsetCommand ("color 4");
1611 rPlotFile.addEzsetCommand ("dash 3");
1612 rPlotFile.addEzsetCommand ("curve 3");
1613 rPlotFile.addEzsetCommand ("color 0");
1614 rPlotFile.addEzsetCommand ("solid");
1615 rPlotFile.addEzsetCommand ("box");
1616 rPlotFile.addEzsetCommand ("grid");
1617 rPlotFile.setCurveSize (4, ny);
1618 rPlotFile.addColumn (0, pX);
1619 rPlotFile.addColumn (1, pYReal);
1620 rPlotFile.addColumn (2, pYImag);
1621 rPlotFile.addColumn (3, pYMag);
1622 for (unsigned int iL = 0; iL < rIF.nLabels(); iL++)
1623 rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str());
1624 os << " FFT Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1625 *theApp->getLog() << os.str().c_str() << "\n";
1626 rPlotFile.addDescription (os.str().c_str());
1635 if (theApp->getAskDeleteNewDocs())
1636 pPlotDoc->Modify (true);
1637 pPlotDoc->getView()->getFrame()->Show(true);
1638 pPlotDoc->UpdateAllViews ();
1639 pPlotDoc->Activate();
1645 ImageFileView::OnCompareCol (wxCommandEvent& event)
1647 int xCursor, yCursor;
1648 if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
1649 wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");
1653 std::vector<ImageFileDocument*> vecIFDoc;
1654 theApp->getCompatibleImages (GetDocument(), vecIFDoc);
1655 if (vecIFDoc.size() == 0) {
1656 wxMessageBox ("No compatible images for Column Comparison", "Error");
1659 DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Comparison Image", vecIFDoc, false);
1661 if (dialogGetCompare.ShowModal() == wxID_OK) {
1662 ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();
1663 const ImageFile& rIF = GetDocument()->getImageFile();
1664 const ImageFile& rCompareIF = pCompareDoc->getImageFile();
1666 ImageFileArrayConst v1 = rIF.getArray();
1667 ImageFileArrayConst v2 = rCompareIF.getArray();
1671 if (v1 != NULL && xCursor < nx) {
1672 double* pX = new double [ny];
1673 double* pY1 = new double [ny];
1674 double* pY2 = new double [ny];
1675 for (int i = 0; i < ny; i++) {
1677 pY1[i] = v1[xCursor][i];
1678 pY2[i] = v2[xCursor][i];
1680 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
1682 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
1684 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
1685 std::ostringstream os;
1686 os << "Column " << xCursor << " Comparison";
1687 std::string title("title ");
1689 rPlotFile.addEzsetCommand (title.c_str());
1690 rPlotFile.addEzsetCommand ("xlabel Row");
1691 rPlotFile.addEzsetCommand ("ylabel Pixel Value");
1692 rPlotFile.addEzsetCommand ("lxfrac 0");
1693 rPlotFile.addEzsetCommand ("curve 1");
1694 rPlotFile.addEzsetCommand ("color 2");
1695 rPlotFile.addEzsetCommand ("curve 2");
1696 rPlotFile.addEzsetCommand ("color 4");
1697 rPlotFile.addEzsetCommand ("dash 5");
1698 rPlotFile.addEzsetCommand ("box");
1699 rPlotFile.addEzsetCommand ("grid");
1700 rPlotFile.setCurveSize (3, ny);
1701 rPlotFile.addColumn (0, pX);
1702 rPlotFile.addColumn (1, pY1);
1703 rPlotFile.addColumn (2, pY2);
1706 for (iL = 0; iL < rIF.nLabels(); iL++) {
1707 std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1709 s += rIF.labelGet(iL).getLabelString();
1710 rPlotFile.addDescription (s.c_str());
1712 for (iL = 0; iL < rCompareIF.nLabels(); iL++) {
1713 std::string s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
1715 s += rCompareIF.labelGet(iL).getLabelString();
1716 rPlotFile.addDescription (s.c_str());
1718 os << " Between " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and "
1719 << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
1720 *theApp->getLog() << os.str().c_str() << "\n";
1721 rPlotFile.addDescription (os.str().c_str());
1726 if (theApp->getAskDeleteNewDocs())
1727 pPlotDoc->Modify (true);
1728 pPlotDoc->getView()->getFrame()->Show(true);
1729 pPlotDoc->UpdateAllViews ();
1730 pPlotDoc->Activate();
1736 ImageFileView::OnCompareRow (wxCommandEvent& event)
1738 int xCursor, yCursor;
1739 if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
1740 wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");
1744 std::vector<ImageFileDocument*> vecIFDoc;
1745 theApp->getCompatibleImages (GetDocument(), vecIFDoc);
1747 if (vecIFDoc.size() == 0) {
1748 wxMessageBox ("No compatible images for Row Comparison", "Error");
1752 DialogGetComparisonImage dialogGetCompare (getFrameForChild(), "Get Comparison Image", vecIFDoc, false);
1754 if (dialogGetCompare.ShowModal() == wxID_OK) {
1755 ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();
1756 const ImageFile& rIF = GetDocument()->getImageFile();
1757 const ImageFile& rCompareIF = pCompareDoc->getImageFile();
1759 ImageFileArrayConst v1 = rIF.getArray();
1760 ImageFileArrayConst v2 = rCompareIF.getArray();
1764 if (v1 != NULL && yCursor < ny) {
1765 double* pX = new double [nx];
1766 double* pY1 = new double [nx];
1767 double* pY2 = new double [nx];
1768 for (int i = 0; i < nx; i++) {
1770 pY1[i] = v1[i][yCursor];
1771 pY2[i] = v2[i][yCursor];
1773 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
1775 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
1777 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
1778 std::ostringstream os;
1779 os << "Row " << yCursor << " Comparison";
1780 std::string title("title ");
1782 rPlotFile.addEzsetCommand (title.c_str());
1783 rPlotFile.addEzsetCommand ("xlabel Column");
1784 rPlotFile.addEzsetCommand ("ylabel Pixel Value");
1785 rPlotFile.addEzsetCommand ("lxfrac 0");
1786 rPlotFile.addEzsetCommand ("curve 1");
1787 rPlotFile.addEzsetCommand ("color 2");
1788 rPlotFile.addEzsetCommand ("curve 2");
1789 rPlotFile.addEzsetCommand ("color 4");
1790 rPlotFile.addEzsetCommand ("dash 5");
1791 rPlotFile.addEzsetCommand ("box");
1792 rPlotFile.addEzsetCommand ("grid");
1793 rPlotFile.setCurveSize (3, nx);
1794 rPlotFile.addColumn (0, pX);
1795 rPlotFile.addColumn (1, pY1);
1796 rPlotFile.addColumn (2, pY2);
1798 for (iL = 0; iL < rIF.nLabels(); iL++) {
1799 std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1801 s += rIF.labelGet(iL).getLabelString();
1802 rPlotFile.addDescription (s.c_str());
1804 for (iL = 0; iL < rCompareIF.nLabels(); iL++) {
1805 std::string s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
1807 s += rCompareIF.labelGet(iL).getLabelString();
1808 rPlotFile.addDescription (s.c_str());
1810 os << " Between " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and "
1811 << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str();
1812 *theApp->getLog() << os.str().c_str() << "\n";
1813 rPlotFile.addDescription (os.str().c_str());
1818 if (theApp->getAskDeleteNewDocs())
1819 pPlotDoc->Modify (true);
1820 pPlotDoc->getView()->getFrame()->Show(true);
1821 pPlotDoc->UpdateAllViews ();
1822 pPlotDoc->Activate();
1827 static int NUMBER_HISTOGRAM_BINS = 256;
1830 ImageFileView::OnPlotHistogram (wxCommandEvent& event)
1832 const ImageFile& rIF = GetDocument()->getImageFile();
1833 ImageFileArrayConst v = rIF.getArray();
1837 if (v != NULL && nx > 0 && ny > 0) {
1838 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
1840 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
1844 double* pX = new double [NUMBER_HISTOGRAM_BINS];
1845 double* pY = new double [NUMBER_HISTOGRAM_BINS];
1847 rIF.getMinMax (dMin, dMax);
1848 double dBinWidth = (dMax - dMin) / NUMBER_HISTOGRAM_BINS;
1850 for (int i = 0; i < NUMBER_HISTOGRAM_BINS; i++) {
1851 pX[i] = dMin + (i + 0.5) * dBinWidth;
1854 for (int ix = 0; ix < nx; ix++)
1855 for (int iy = 0; iy < ny; iy++) {
1856 int iBin = nearest<int> ((v[ix][iy] - dMin) / dBinWidth);
1857 if (iBin >= 0 && iBin < NUMBER_HISTOGRAM_BINS)
1861 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
1862 std::ostringstream os;
1864 std::string title("title ");
1866 rPlotFile.addEzsetCommand (title.c_str());
1867 rPlotFile.addEzsetCommand ("xlabel Pixel Value");
1868 rPlotFile.addEzsetCommand ("ylabel Count");
1869 rPlotFile.addEzsetCommand ("box");
1870 rPlotFile.addEzsetCommand ("grid");
1871 rPlotFile.setCurveSize (2, NUMBER_HISTOGRAM_BINS);
1872 rPlotFile.addColumn (0, pX);
1873 rPlotFile.addColumn (1, pY);
1874 for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) {
1875 std::string s = GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1877 s += rIF.labelGet(iL).getLabelString();
1878 rPlotFile.addDescription (s.c_str());
1880 os << " plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
1881 *theApp->getLog() << os.str().c_str() << "\n";
1882 rPlotFile.addDescription (os.str().c_str());
1885 if (theApp->getAskDeleteNewDocs())
1886 pPlotDoc->Modify (true);
1887 pPlotDoc->getView()->getFrame()->Show(true);
1888 pPlotDoc->UpdateAllViews ();
1889 pPlotDoc->Activate();
1896 PhantomCanvas::PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
1897 : wxScrolledWindow(frame, -1, pos, size, style)
1902 PhantomCanvas::~PhantomCanvas ()
1908 PhantomCanvas::OnDraw (wxDC& dc)
1911 m_pView->OnDraw(& dc);
1915 PhantomCanvas::GetBestSize() const
1921 theApp->getMainFrame()->GetClientSize (&xSize, &ySize);
1922 xSize = maxValue<int> (xSize, ySize);
1923 ySize = xSize = (xSize / 4);
1924 return wxSize (xSize, ySize);
1931 IMPLEMENT_DYNAMIC_CLASS(PhantomFileView, wxView)
1933 BEGIN_EVENT_TABLE(PhantomFileView, wxView)
1934 EVT_MENU(PHMMENU_FILE_PROPERTIES, PhantomFileView::OnProperties)
1935 EVT_MENU(PHMMENU_PROCESS_RASTERIZE, PhantomFileView::OnRasterize)
1936 EVT_MENU(PHMMENU_PROCESS_PROJECTIONS, PhantomFileView::OnProjections)
1939 PhantomFileView::PhantomFileView()
1940 : wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0)
1942 #if defined(DEBUG) || defined(_DEBUG)
1943 m_iDefaultNDet = 165;
1944 m_iDefaultNView = 180;
1945 m_iDefaultNSample = 1;
1947 m_iDefaultNDet = 367;
1948 m_iDefaultNView = 320;
1949 m_iDefaultNSample = 2;
1951 m_dDefaultRotation = 1;
1952 m_dDefaultFocalLength = 2;
1953 m_dDefaultCenterDetectorLength = 2;
1954 m_dDefaultViewRatio = 1;
1955 m_dDefaultScanRatio = 1;
1956 m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL;
1957 m_iDefaultTrace = Trace::TRACE_NONE;
1960 m_iDefaultRasterNX = 115;
1961 m_iDefaultRasterNY = 115;
1962 m_iDefaultRasterNSamples = 1;
1964 m_iDefaultRasterNX = 256;
1965 m_iDefaultRasterNY = 256;
1966 m_iDefaultRasterNSamples = 2;
1968 m_dDefaultRasterViewRatio = 1;
1971 PhantomFileView::~PhantomFileView()
1973 GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
1974 GetDocumentManager()->ActivateView(this, FALSE, TRUE);
1978 PhantomFileView::OnProperties (wxCommandEvent& event)
1980 const int idPhantom = GetDocument()->getPhantomID();
1981 const wxString& namePhantom = GetDocument()->getPhantomName();
1982 std::ostringstream os;
1983 os << "Phantom " << namePhantom.c_str() << " (" << idPhantom << ")" << "\n";
1984 const Phantom& rPhantom = GetDocument()->getPhantom();
1985 rPhantom.printDefinitions (os);
1987 rPhantom.print (os);
1989 *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<\n";
1990 wxMessageBox (os.str().c_str(), "Phantom Properties");
1991 GetDocument()->Activate();
1996 PhantomFileView::OnProjections (wxCommandEvent& event)
1998 DialogGetProjectionParameters dialogProjection (getFrameForChild(),
1999 m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation,
2000 m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio,
2001 m_iDefaultGeometry, m_iDefaultTrace);
2002 int retVal = dialogProjection.ShowModal();
2003 if (retVal != wxID_OK)
2006 m_iDefaultNDet = dialogProjection.getNDet();
2007 m_iDefaultNView = dialogProjection.getNView();
2008 m_iDefaultNSample = dialogProjection.getNSamples();
2009 m_iDefaultTrace = dialogProjection.getTrace();
2010 m_dDefaultRotation = dialogProjection.getRotAngle();
2011 m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio();
2012 m_dDefaultCenterDetectorLength = dialogProjection.getCenterDetectorLengthRatio();
2013 m_dDefaultViewRatio = dialogProjection.getViewRatio();
2014 m_dDefaultScanRatio = dialogProjection.getScanRatio();
2015 wxString sGeometry = dialogProjection.getGeometry();
2016 m_iDefaultGeometry = Scanner::convertGeometryNameToID (sGeometry.c_str());
2017 double dRotationRadians = m_dDefaultRotation;
2018 m_dDefaultRotation /= TWOPI; // convert back to fraction of a circle
2020 if (m_iDefaultNDet <= 0 || m_iDefaultNView <= 0 || sGeometry == "")
2023 const Phantom& rPhantom = GetDocument()->getPhantom();
2024 Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample,
2025 dRotationRadians, m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio);
2026 if (theScanner.fail()) {
2027 wxString msg = "Failed making scanner\n";
2028 msg += theScanner.failMessage().c_str();
2029 *theApp->getLog() << msg << "\n";
2030 wxMessageBox (msg, "Error");
2034 std::ostringstream os;
2035 os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet
2036 << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample
2037 << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength
2038 << ", CenterDetectorLengthRatio=" << m_dDefaultCenterDetectorLength
2039 << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio
2040 << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" <<
2041 convertRadiansToDegrees (theScanner.fanBeamAngle());
2044 Projections* pProj = NULL;
2045 if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
2046 pProj = new Projections;
2047 pProj->initFromScanner (theScanner);
2049 ProjectionsDialog dialogProjections (theScanner, *pProj, rPhantom, m_iDefaultTrace, dynamic_cast<wxWindow*>(getFrameForChild()));
2050 for (int iView = 0; iView < pProj->nView(); iView++) {
2052 if (dialogProjections.isCancelled() || ! dialogProjections.projectView (iView)) {
2057 while (dialogProjections.isPaused()) {
2064 if (theApp->getUseBackgroundTasks()) {
2065 ProjectorSupervisorThread* pProjector = new ProjectorSupervisorThread (this, m_iDefaultNDet,
2066 m_iDefaultNView, sGeometry.c_str(), m_iDefaultNSample, dRotationRadians,
2067 m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio, os.str().c_str());
2068 if (pProjector->Create() != wxTHREAD_NO_ERROR) {
2069 sys_error (ERR_SEVERE, "Error creating projector thread");
2073 pProjector->SetPriority(60);
2077 #endif // HAVE_WXTHREADS
2079 pProj = new Projections;
2080 pProj->initFromScanner (theScanner);
2081 wxProgressDialog dlgProgress (wxString("Projection"), wxString("Projection Progress"), pProj->nView() + 1, getFrameForChild(), wxPD_CAN_ABORT );
2082 for (int i = 0; i < pProj->nView(); i++) {
2083 theScanner.collectProjections (*pProj, rPhantom, i, 1, true, m_iDefaultTrace);
2084 if (! dlgProgress.Update (i+1)) {
2092 *theApp->getLog() << os.str().c_str() << "\n";
2093 pProj->setRemark (os.str());
2094 pProj->setCalcTime (timer.timerEnd());
2096 ProjectionFileDocument* pProjectionDoc = theApp->newProjectionDoc();
2097 if (! pProjectionDoc) {
2098 sys_error (ERR_SEVERE, "Unable to create projection document");
2101 pProjectionDoc->setProjections (pProj);
2102 ProjectionFileView* projView = pProjectionDoc->getView();
2104 projView->OnUpdate (projView, NULL);
2105 if (projView->getCanvas())
2106 projView->getCanvas()->SetClientSize (m_iDefaultNDet, m_iDefaultNView);
2107 if (wxFrame* pFrame = projView->getFrame()) {
2112 GetDocumentManager()->ActivateView (projView, true, false);
2114 if (theApp->getAskDeleteNewDocs())
2115 pProjectionDoc-> Modify(true);
2116 pProjectionDoc->UpdateAllViews (this);
2117 pProjectionDoc->Activate();
2122 PhantomFileView::OnRasterize (wxCommandEvent& event)
2124 DialogGetRasterParameters dialogRaster (getFrameForChild(), m_iDefaultRasterNX, m_iDefaultRasterNY,
2125 m_iDefaultRasterNSamples, m_dDefaultRasterViewRatio);
2126 int retVal = dialogRaster.ShowModal();
2127 if (retVal != wxID_OK)
2130 m_iDefaultRasterNX = dialogRaster.getXSize();
2131 m_iDefaultRasterNY = dialogRaster.getYSize();
2132 m_iDefaultRasterNSamples = dialogRaster.getNSamples();
2133 m_dDefaultRasterViewRatio = dialogRaster.getViewRatio();
2134 if (m_iDefaultRasterNSamples < 1)
2135 m_iDefaultRasterNSamples = 1;
2136 if (m_dDefaultRasterViewRatio < 0)
2137 m_dDefaultRasterViewRatio = 0;
2138 if (m_iDefaultRasterNX <= 0 || m_iDefaultRasterNY <= 0)
2141 const Phantom& rPhantom = GetDocument()->getPhantom();
2142 std::ostringstream os;
2143 os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << m_iDefaultRasterNX << ", YSize="
2144 << m_iDefaultRasterNY << ", ViewRatio=" << m_dDefaultRasterViewRatio << ", nSamples="
2145 << m_iDefaultRasterNSamples;;
2148 if (theApp->getUseBackgroundTasks()) {
2149 RasterizerSupervisorThread* pThread = new RasterizerSupervisorThread (this, m_iDefaultRasterNX, m_iDefaultRasterNY,
2150 m_iDefaultRasterNSamples, m_dDefaultRasterViewRatio, os.str().c_str());
2151 if (pThread->Create() != wxTHREAD_NO_ERROR) {
2152 *theApp->getLog() << "Error creating rasterizer thread\n";
2155 pThread->SetPriority (60);
2160 ImageFile* pImageFile = new ImageFile (m_iDefaultRasterNX, m_iDefaultRasterNY);
2161 wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"),
2162 pImageFile->nx() + 1, getFrameForChild(), wxPD_CAN_ABORT );
2164 for (unsigned int i = 0; i < pImageFile->nx(); i++) {
2165 rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio, m_iDefaultRasterNSamples, Trace::TRACE_NONE, i, 1, true);
2166 if (! dlgProgress.Update (i+1)) {
2172 ImageFileDocument* pRasterDoc = theApp->newImageDoc();
2174 sys_error (ERR_SEVERE, "Unable to create image file");
2177 pRasterDoc->setImageFile (pImageFile);
2178 if (theApp->getAskDeleteNewDocs())
2179 pRasterDoc->Modify (true);
2180 pRasterDoc->UpdateAllViews (this);
2181 pRasterDoc->getView()->getFrame()->Show(true);
2182 *theApp->getLog() << os.str().c_str() << "\n";
2183 pImageFile->labelAdd (os.str().c_str(), timer.timerEnd());
2184 ImageFileView* rasterView = pRasterDoc->getView();
2186 rasterView->getFrame()->SetFocus();
2187 rasterView->OnUpdate (rasterView, NULL);
2189 pRasterDoc->Activate();
2195 PhantomFileView::CreateCanvas (wxFrame *parent)
2197 PhantomCanvas* pCanvas;
2199 pCanvas = new PhantomCanvas (this, parent, wxPoint(0, 0), wxSize(0,0), 0);
2200 pCanvas->SetBackgroundColour(*wxWHITE);
2211 PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
2214 wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
2216 wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
2218 theApp->setIconForFrame (subframe);
2220 m_pFileMenu = new wxMenu;
2222 m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
2223 m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
2224 m_pFileMenu->Append(wxID_OPEN, "&Open...\tCtrl-O");
2225 m_pFileMenu->Append(wxID_SAVEAS, "Save &As...");
2226 m_pFileMenu->Append(wxID_CLOSE, "&Close");
2228 m_pFileMenu->AppendSeparator();
2229 m_pFileMenu->Append(PHMMENU_FILE_PROPERTIES, "P&roperties\tCtrl-I");
2231 m_pFileMenu->AppendSeparator();
2232 m_pFileMenu->Append(wxID_PRINT, "&Print...");
2233 m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
2234 m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
2235 m_pFileMenu->AppendSeparator();
2236 m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
2238 m_pFileMenu->AppendSeparator();
2239 m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
2240 m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
2242 GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
2243 GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
2245 wxMenu *process_menu = new wxMenu;
2246 process_menu->Append(PHMMENU_PROCESS_RASTERIZE, "&Rasterize...\tCtrl-R");
2247 process_menu->Append(PHMMENU_PROCESS_PROJECTIONS, "&Projections...\tCtrl-J");
2249 wxMenu *help_menu = new wxMenu;
2250 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
2251 help_menu->Append (MAINMENU_HELP_TIPS, "&Tips");
2252 help_menu->Append (IDH_QUICKSTART, "&Quick Start");
2253 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
2255 wxMenuBar *menu_bar = new wxMenuBar;
2257 menu_bar->Append(m_pFileMenu, "&File");
2258 menu_bar->Append(process_menu, "&Process");
2259 menu_bar->Append(help_menu, "&Help");
2261 subframe->SetMenuBar(menu_bar);
2262 subframe->Centre(wxBOTH);
2264 wxAcceleratorEntry accelEntries[3];
2265 accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('J'), PHMMENU_PROCESS_PROJECTIONS);
2266 accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('R'), PHMMENU_PROCESS_RASTERIZE);
2267 accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('I'), PHMMENU_FILE_PROPERTIES);
2268 wxAcceleratorTable accelTable (3, accelEntries);
2269 subframe->SetAcceleratorTable (accelTable);
2276 PhantomFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
2278 m_pFrame = CreateChildFrame(doc, this);
2280 m_pCanvas = CreateCanvas (m_pFrame);
2281 m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
2282 m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
2284 m_pFrame->SetTitle ("PhantomFileView");
2287 int x, y; // X requires a forced resize
2288 m_pFrame->GetSize(&x, &y);
2289 m_pFrame->SetSize(-1, -1, x, y);
2292 m_pFrame->Show(true);
2299 PhantomFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
2302 m_pCanvas->Refresh();
2306 PhantomFileView::OnClose (bool deleteWindow)
2308 //GetDocumentManager()->ActivateView (this, false, true);
2309 if (! GetDocument() || ! GetDocument()->Close())
2314 m_pCanvas->setView(NULL);
2317 wxString s(wxTheApp->GetAppName());
2319 m_pFrame->SetTitle(s);
2326 if (GetDocument() && GetDocument()->getBadFileOpen())
2327 ::wxYield(); // wxWindows bug workaround
2334 PhantomFileView::OnDraw (wxDC* dc)
2337 m_pCanvas->GetClientSize (&xsize, &ysize);
2338 SGPDriver driver (dc, xsize, ysize);
2340 const Phantom& rPhantom = GetDocument()->getPhantom();
2341 sgp.setColor (C_RED);
2342 rPhantom.show (sgp);
2347 ProjectionFileCanvas::ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
2348 : wxScrolledWindow(frame, -1, pos, size, style)
2353 ProjectionFileCanvas::~ProjectionFileCanvas ()
2359 ProjectionFileCanvas::OnDraw(wxDC& dc)
2362 m_pView->OnDraw(& dc);
2366 ProjectionFileCanvas::GetBestSize () const
2370 Projections& rProj = m_pView->GetDocument()->getProjections();
2371 best.Set (rProj.nDet(), rProj.nView());
2378 // ProjectionFileView
2380 IMPLEMENT_DYNAMIC_CLASS(ProjectionFileView, wxView)
2382 BEGIN_EVENT_TABLE(ProjectionFileView, wxView)
2383 EVT_MENU(PJMENU_FILE_PROPERTIES, ProjectionFileView::OnProperties)
2384 EVT_MENU(PJMENU_RECONSTRUCT_FBP, ProjectionFileView::OnReconstructFBP)
2385 EVT_MENU(PJMENU_RECONSTRUCT_FBP_REBIN, ProjectionFileView::OnReconstructFBPRebin)
2386 EVT_MENU(PJMENU_RECONSTRUCT_FOURIER, ProjectionFileView::OnReconstructFourier)
2387 EVT_MENU(PJMENU_CONVERT_RECTANGULAR, ProjectionFileView::OnConvertRectangular)
2388 EVT_MENU(PJMENU_CONVERT_POLAR, ProjectionFileView::OnConvertPolar)
2389 EVT_MENU(PJMENU_CONVERT_FFT_POLAR, ProjectionFileView::OnConvertFFTPolar)
2390 EVT_MENU(PJMENU_CONVERT_PARALLEL, ProjectionFileView::OnConvertParallel)
2391 EVT_MENU(PJMENU_PLOT_TTHETA_SAMPLING, ProjectionFileView::OnPlotTThetaSampling)
2392 EVT_MENU(PJMENU_PLOT_HISTOGRAM, ProjectionFileView::OnPlotHistogram)
2393 EVT_MENU(PJMENU_ARTIFACT_REDUCTION, ProjectionFileView::OnArtifactReduction)
2397 ProjectionFileView::ProjectionFileView()
2398 : wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0)
2408 m_iDefaultFilter = SignalFilter::FILTER_ABS_BANDLIMIT;
2409 m_dDefaultFilterParam = 1.;
2411 m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_RFFTW;
2412 m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_INVERSE_FOURIER;
2414 m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_CONVOLUTION;
2415 m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_DIRECT;
2417 m_iDefaultZeropad = 1;
2418 m_iDefaultBackprojector = Backprojector::BPROJ_IDIFF;
2419 m_iDefaultInterpolation = Backprojector::INTERP_LINEAR;
2420 m_iDefaultInterpParam = 1;
2421 m_iDefaultTrace = Trace::TRACE_NONE;
2423 m_iDefaultPolarNX = 256;
2424 m_iDefaultPolarNY = 256;
2425 m_iDefaultPolarInterpolation = Projections::POLAR_INTERP_BILINEAR;
2426 m_iDefaultPolarZeropad = 1;
2429 ProjectionFileView::~ProjectionFileView()
2431 GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
2432 GetDocumentManager()->ActivateView(this, FALSE, TRUE);;
2436 ProjectionFileView::OnProperties (wxCommandEvent& event)
2438 const Projections& rProj = GetDocument()->getProjections();
2439 std::ostringstream os;
2440 rProj.printScanInfo(os);
2441 *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<\n";
2442 wxMessageDialog dialogMsg (getFrameForChild(), os.str().c_str(), "Projection File Properties", wxOK | wxICON_INFORMATION);
2443 dialogMsg.ShowModal();
2444 GetDocument()->Activate();
2449 ProjectionFileView::OnConvertRectangular (wxCommandEvent& event)
2451 Projections& rProj = GetDocument()->getProjections();
2453 int nDet = rProj.nDet();
2454 int nView = rProj.nView();
2455 ImageFile* pIF = new ImageFile (nDet, nView);
2456 ImageFileArray v = pIF->getArray();
2457 for (int iv = 0; iv < nView; iv++) {
2458 DetectorValue* detval = rProj.getDetectorArray(iv).detValues();
2460 for (int id = 0; id < nDet; id++)
2461 v[id][iv] = detval[id];
2464 ImageFileDocument* pRectDoc = theApp->newImageDoc ();
2466 sys_error (ERR_SEVERE, "Unable to create image file");
2469 pRectDoc->setImageFile (pIF);
2470 pIF->labelAdd (rProj.getLabel().getLabelString().c_str(), rProj.calcTime());
2471 std::ostringstream os;
2472 os << "Convert projection file " << GetFrame()->GetTitle().c_str() << " to rectangular image";
2473 *theApp->getLog() << os.str().c_str() << "\n";
2474 pIF->labelAdd (os.str().c_str());
2475 if (theApp->getAskDeleteNewDocs())
2476 pRectDoc->Modify (true);
2477 pRectDoc->getView()->getFrame()->Show(true);
2478 pRectDoc->UpdateAllViews ();
2479 pRectDoc->Activate();
2483 ProjectionFileView::OnConvertPolar (wxCommandEvent& event)
2485 Projections& rProj = GetDocument()->getProjections();
2486 DialogGetConvertPolarParameters dialogPolar (getFrameForChild(), "Convert Polar", m_iDefaultPolarNX, m_iDefaultPolarNY,
2487 m_iDefaultPolarInterpolation, -1);
2488 if (dialogPolar.ShowModal() == wxID_OK) {
2489 wxProgressDialog dlgProgress (wxString("Convert Polar"), wxString("Conversion Progress"), 1, getFrameForChild(), wxPD_APP_MODAL);
2490 wxString strInterpolation (dialogPolar.getInterpolationName());
2491 m_iDefaultPolarNX = dialogPolar.getXSize();
2492 m_iDefaultPolarNY = dialogPolar.getYSize();
2493 ImageFileDocument* pPolarDoc = theApp->newImageDoc();
2494 ImageFile* pIF = new ImageFile (m_iDefaultPolarNX, m_iDefaultPolarNY);
2495 m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str());
2497 if (! rProj.convertPolar (*pIF, m_iDefaultPolarInterpolation)) {
2499 *theApp->getLog() << "Error converting to Polar\n";
2503 pPolarDoc = theApp->newImageDoc ();
2505 sys_error (ERR_SEVERE, "Unable to create image file");
2508 pPolarDoc->setImageFile (pIF);
2509 pIF->labelAdd (rProj.getLabel().getLabelString().c_str(), rProj.calcTime());
2510 std::ostringstream os;
2511 os << "Convert projection file " << GetFrame()->GetTitle().c_str() << " to polar image: xSize="
2512 << m_iDefaultPolarNX << ", ySize=" << m_iDefaultPolarNY << ", interpolation="
2513 << strInterpolation.c_str();
2514 *theApp->getLog() << os.str().c_str() << "\n";
2515 pIF->labelAdd (os.str().c_str());
2516 if (theApp->getAskDeleteNewDocs())
2517 pPolarDoc->Modify (true);
2518 pPolarDoc->getView()->getFrame()->Show(true);
2519 pPolarDoc->UpdateAllViews ();
2520 pPolarDoc->Activate();
2525 ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event)
2527 Projections& rProj = GetDocument()->getProjections();
2528 DialogGetConvertPolarParameters dialogPolar (getFrameForChild(), "Convert to FFT Polar", m_iDefaultPolarNX, m_iDefaultPolarNY,
2529 m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad);
2530 if (dialogPolar.ShowModal() == wxID_OK) {
2531 wxProgressDialog dlgProgress (wxString("Convert FFT Polar"), wxString("Conversion Progress"), 1, getFrameForChild(), wxPD_APP_MODAL);
2532 wxString strInterpolation (dialogPolar.getInterpolationName());
2533 m_iDefaultPolarNX = dialogPolar.getXSize();
2534 m_iDefaultPolarNY = dialogPolar.getYSize();
2535 m_iDefaultPolarZeropad = dialogPolar.getZeropad();
2536 ImageFile* pIF = new ImageFile (m_iDefaultPolarNX, m_iDefaultPolarNY);
2538 m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str());
2539 if (! rProj.convertFFTPolar (*pIF, m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad)) {
2541 *theApp->getLog() << "Error converting to polar\n";
2544 ImageFileDocument* pPolarDoc = theApp->newImageDoc();
2546 sys_error (ERR_SEVERE, "Unable to create image file");
2549 pPolarDoc->setImageFile (pIF);
2550 pIF->labelAdd (rProj.getLabel().getLabelString().c_str(), rProj.calcTime());
2551 std::ostringstream os;
2552 os << "Convert projection file " << GetFrame()->GetTitle().c_str() << " to FFT polar image: xSize="
2553 << m_iDefaultPolarNX << ", ySize=" << m_iDefaultPolarNY << ", interpolation="
2554 << strInterpolation.c_str() << ", zeropad=" << m_iDefaultPolarZeropad;
2555 *theApp->getLog() << os.str().c_str() << "\n";
2556 pIF->labelAdd (os.str().c_str());
2557 if (theApp->getAskDeleteNewDocs())
2558 pPolarDoc->Modify (true);
2559 pPolarDoc->getView()->getFrame()->Show(true);
2560 pPolarDoc->UpdateAllViews ();
2561 pPolarDoc->Activate();
2566 ProjectionFileView::OnPlotTThetaSampling (wxCommandEvent& event)
2568 DialogGetThetaRange dlgTheta (this->getFrame(), ParallelRaysums::THETA_RANGE_UNCONSTRAINED);
2569 if (dlgTheta.ShowModal() != wxID_OK)
2572 int iThetaRange = dlgTheta.getThetaRange();
2574 Projections& rProj = GetDocument()->getProjections();
2575 ParallelRaysums parallel (&rProj, iThetaRange);
2576 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
2577 PlotFile& rPlot = pPlotDoc->getPlotFile();
2578 ParallelRaysums::CoordinateContainer& coordContainer = parallel.getCoordinates();
2579 double* pdT = new double [parallel.getNumCoordinates()];
2580 double* pdTheta = new double [parallel.getNumCoordinates()];
2582 for (int i = 0; i < parallel.getNumCoordinates(); i++) {
2583 pdT[i] = coordContainer[i]->m_dT;
2584 pdTheta[i] = coordContainer[i]->m_dTheta;
2586 rPlot.setCurveSize (2, parallel.getNumCoordinates(), true);
2587 rPlot.addEzsetCommand ("title T-Theta Sampling");
2588 rPlot.addEzsetCommand ("xlabel T");
2589 rPlot.addEzsetCommand ("ylabel Theta");
2590 rPlot.addEzsetCommand ("curve 1");
2591 if (rProj.nDet() < 50 && rProj.nView() < 50)
2592 rPlot.addEzsetCommand ("symbol 1"); // x symbol
2594 rPlot.addEzsetCommand ("symbol 6"); // point symbol
2595 rPlot.addEzsetCommand ("noline");
2596 rPlot.addColumn (0, pdT);
2597 rPlot.addColumn (1, pdTheta);
2600 if (theApp->getAskDeleteNewDocs())
2601 pPlotDoc->Modify (true);
2602 pPlotDoc->getView()->getFrame()->Show(true);
2603 pPlotDoc->UpdateAllViews ();
2604 pPlotDoc->Activate();
2609 ProjectionFileView::OnPlotHistogram (wxCommandEvent& event)
2611 Projections& rProj = GetDocument()->getProjections();
2612 int nDet = rProj.nDet();
2613 int nView = rProj.nView();
2615 if (nDet < 1 || nView < 1)
2618 PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
2620 sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
2624 DetectorValue* pdDetval = rProj.getDetectorArray(0).detValues();
2625 double dMin = pdDetval[0], dMax = pdDetval[0];
2627 for (int iv = 0; iv < nView; iv++) {
2628 pdDetval = rProj.getDetectorArray(iv).detValues();
2629 for (int id = 0; id < nDet; id++) {
2630 double dV = pdDetval[id];
2638 double* pX = new double [NUMBER_HISTOGRAM_BINS];
2639 double* pY = new double [NUMBER_HISTOGRAM_BINS];
2640 double dBinWidth = (dMax - dMin) / NUMBER_HISTOGRAM_BINS;
2642 for (int i = 0; i < NUMBER_HISTOGRAM_BINS; i++) {
2643 pX[i] = dMin + (i + 0.5) * dBinWidth;
2646 for (int j = 0; j < nView; j++) {
2647 pdDetval = rProj.getDetectorArray(j).detValues();
2648 for (int id = 0; id < nDet; id++) {
2649 int iBin = nearest<int> ((pdDetval[id] - dMin) / dBinWidth);
2650 if (iBin >= 0 && iBin < NUMBER_HISTOGRAM_BINS)
2654 PlotFile& rPlotFile = pPlotDoc->getPlotFile();
2655 std::ostringstream os;
2657 std::string title("title ");
2659 rPlotFile.addEzsetCommand (title.c_str());
2660 rPlotFile.addEzsetCommand ("xlabel Detector Value");
2661 rPlotFile.addEzsetCommand ("ylabel Count");
2662 rPlotFile.addEzsetCommand ("box");
2663 rPlotFile.addEzsetCommand ("grid");
2664 rPlotFile.setCurveSize (2, NUMBER_HISTOGRAM_BINS);
2665 rPlotFile.addColumn (0, pX);
2666 rPlotFile.addColumn (1, pY);
2667 rPlotFile.addDescription (rProj.remark());
2668 os << " plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
2669 *theApp->getLog() << os.str().c_str() << "\n";
2670 rPlotFile.addDescription (os.str().c_str());
2673 if (theApp->getAskDeleteNewDocs())
2674 pPlotDoc->Modify (true);
2675 pPlotDoc->getView()->getFrame()->Show(true);
2676 pPlotDoc->UpdateAllViews ();
2677 pPlotDoc->Activate();
2682 ProjectionFileView::OnConvertParallel (wxCommandEvent& event)
2684 Projections& rProj = GetDocument()->getProjections();
2685 if (rProj.geometry() == Scanner::GEOMETRY_PARALLEL) {
2686 wxMessageBox ("Projections are already parallel", "Error");
2689 wxProgressDialog dlgProgress (wxString("Convert to Parallel"), wxString("Conversion Progress"), 1, getFrameForChild(), wxPD_APP_MODAL);
2690 Projections* pProjNew = rProj.interpolateToParallel();
2691 ProjectionFileDocument* pProjDocNew = theApp->newProjectionDoc();
2692 pProjDocNew->setProjections (pProjNew);
2694 if (ProjectionFileView* projView = pProjDocNew->getView()) {
2695 projView->OnUpdate (projView, NULL);
2696 if (projView->getCanvas())
2697 projView->getCanvas()->SetClientSize (pProjNew->nDet(), pProjNew->nView());
2698 if (wxFrame* pFrame = projView->getFrame()) {
2703 GetDocumentManager()->ActivateView (projView, true, false);
2705 if (theApp->getAskDeleteNewDocs())
2706 pProjDocNew-> Modify(true);
2707 pProjDocNew->UpdateAllViews (this);
2708 pProjDocNew->Activate();
2712 ProjectionFileView::OnReconstructFourier (wxCommandEvent& event)
2714 wxMessageBox ("Fourier Reconstruction is not yet supported", "Unimplemented function");
2718 ProjectionFileView::OnReconstructFBPRebin (wxCommandEvent& event)
2720 Projections& rProj = GetDocument()->getProjections();
2721 doReconstructFBP (rProj, true);
2725 ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
2727 Projections& rProj = GetDocument()->getProjections();
2728 doReconstructFBP (rProj, false);
2732 ProjectionFileView::doReconstructFBP (const Projections& rProj, bool bRebinToParallel)
2734 ReconstructionROI defaultROI;
2735 defaultROI.m_dXMin = -rProj.phmLen() / 2;
2736 defaultROI.m_dXMax = defaultROI.m_dXMin + rProj.phmLen();
2737 defaultROI.m_dYMin = -rProj.phmLen() / 2;
2738 defaultROI.m_dYMax = defaultROI.m_dYMin + rProj.phmLen();
2740 DialogGetReconstructionParameters dialogReconstruction (getFrameForChild(), m_iDefaultNX, m_iDefaultNY,
2741 m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration,
2742 m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector,
2743 m_iDefaultTrace, &defaultROI);
2745 int retVal = dialogReconstruction.ShowModal();
2746 if (retVal != wxID_OK)
2749 m_iDefaultNX = dialogReconstruction.getXSize();
2750 m_iDefaultNY = dialogReconstruction.getYSize();
2751 wxString optFilterName = dialogReconstruction.getFilterName();
2752 m_iDefaultFilter = SignalFilter::convertFilterNameToID (optFilterName.c_str());
2753 m_dDefaultFilterParam = dialogReconstruction.getFilterParam();
2754 wxString optFilterMethodName = dialogReconstruction.getFilterMethodName();
2755 m_iDefaultFilterMethod = ProcessSignal::convertFilterMethodNameToID(optFilterMethodName.c_str());
2756 m_iDefaultZeropad = dialogReconstruction.getZeropad();
2757 wxString optFilterGenerationName = dialogReconstruction.getFilterGenerationName();
2758 m_iDefaultFilterGeneration = ProcessSignal::convertFilterGenerationNameToID (optFilterGenerationName.c_str());
2759 wxString optInterpName = dialogReconstruction.getInterpName();
2760 m_iDefaultInterpolation = Backprojector::convertInterpNameToID (optInterpName.c_str());
2761 m_iDefaultInterpParam = dialogReconstruction.getInterpParam();
2762 wxString optBackprojectName = dialogReconstruction.getBackprojectName();
2763 m_iDefaultBackprojector = Backprojector::convertBackprojectNameToID (optBackprojectName.c_str());
2764 m_iDefaultTrace = dialogReconstruction.getTrace();
2765 dialogReconstruction.getROI (&defaultROI);
2767 if (m_iDefaultNX <= 0 && m_iDefaultNY <= 0)
2770 std::ostringstream os;
2771 os << "Reconstruct " << rProj.getFilename() << ": xSize=" << m_iDefaultNX << ", ySize=" << m_iDefaultNY << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << m_dDefaultFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", FilterGeneration=" << optFilterGenerationName.c_str() << ", Zeropad=" << m_iDefaultZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << m_iDefaultInterpParam << ", Backprojection=" << optBackprojectName.c_str();
2772 if (bRebinToParallel)
2773 os << "; Interpolate to Parallel";
2776 ImageFile* pImageFile = NULL;
2777 if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
2778 pImageFile = new ImageFile (m_iDefaultNX, m_iDefaultNY);
2779 Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(),
2780 m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(),
2781 optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace,
2782 &defaultROI, bRebinToParallel);
2784 ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstructor, rProj, *pImageFile, m_iDefaultTrace, getFrameForChild());
2785 for (int iView = 0; iView < rProj.nView(); iView++) {
2787 if (pDlgReconstruct->isCancelled() || ! pDlgReconstruct->reconstructView (iView, true)) {
2788 delete pDlgReconstruct;
2789 delete pReconstructor;
2794 while (pDlgReconstruct->isPaused()) {
2799 pReconstructor->postProcessing();
2800 delete pDlgReconstruct;
2801 delete pReconstructor;
2804 if (theApp->getUseBackgroundTasks()) {
2805 ReconstructorSupervisorThread* pReconstructor = new ReconstructorSupervisorThread (this, m_iDefaultNX,
2806 m_iDefaultNY, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(),
2807 m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam,
2808 optBackprojectName.c_str(), os.str().c_str(), &defaultROI, bRebinToParallel);
2809 if (pReconstructor->Create() != wxTHREAD_NO_ERROR) {
2810 sys_error (ERR_SEVERE, "Error creating reconstructor thread");
2811 delete pReconstructor;
2814 pReconstructor->SetPriority (60);
2815 pReconstructor->Run();
2820 pImageFile = new ImageFile (m_iDefaultNX, m_iDefaultNY);
2821 wxProgressDialog dlgProgress (wxString("Reconstruction"), wxString("Reconstruction Progress"), rProj.nView() + 1, getFrameForChild(), wxPD_CAN_ABORT );
2822 Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(),
2823 m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(),
2824 optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace,
2825 &defaultROI, bRebinToParallel);
2827 for (int iView = 0; iView < rProj.nView(); iView++) {
2828 pReconstructor->reconstructView (iView, 1);
2829 if (! dlgProgress.Update (iView + 1)) {
2830 delete pReconstructor;
2831 return; // don't make new window, thread will do this
2834 pReconstructor->postProcessing();
2835 delete pReconstructor;
2838 ImageFileDocument* pReconDoc = theApp->newImageDoc();
2840 sys_error (ERR_SEVERE, "Unable to create image file");
2843 pReconDoc->setImageFile (pImageFile);
2844 if (theApp->getAskDeleteNewDocs())
2845 pReconDoc->Modify (true);
2846 pReconDoc->UpdateAllViews (this);
2847 pReconDoc->Activate();
2848 if (ImageFileView* rasterView = pReconDoc->getView()) {
2849 rasterView->OnUpdate (rasterView, NULL);
2850 rasterView->getFrame()->SetFocus();
2851 rasterView->getFrame()->Show(true);
2853 *theApp->getLog() << os.str().c_str() << "\n";
2854 pImageFile->labelAdd (rProj.getLabel());
2855 pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd());
2860 ProjectionFileView::OnArtifactReduction (wxCommandEvent& event)
2865 ProjectionFileCanvas*
2866 ProjectionFileView::CreateCanvas (wxFrame *parent)
2868 ProjectionFileCanvas* pCanvas;
2870 parent->GetClientSize(&width, &height);
2872 pCanvas = new ProjectionFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
2874 pCanvas->SetScrollbars(20, 20, 50, 50);
2875 pCanvas->SetBackgroundColour(*wxWHITE);
2886 ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
2889 wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
2891 wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
2893 theApp->setIconForFrame (subframe);
2895 m_pFileMenu = new wxMenu;
2897 m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
2898 m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
2899 m_pFileMenu->Append(wxID_OPEN, "&Open...\tCtrl-O");
2900 m_pFileMenu->Append(wxID_SAVE, "&Save\tCtrl-S");
2901 m_pFileMenu->Append(wxID_SAVEAS, "Save &As...");
2902 m_pFileMenu->Append(wxID_CLOSE, "&Close\tCtrl-W");
2904 m_pFileMenu->AppendSeparator();
2905 m_pFileMenu->Append(PJMENU_FILE_PROPERTIES, "P&roperties\tCtrl-I");
2907 m_pFileMenu->AppendSeparator();
2908 m_pFileMenu->Append(wxID_PRINT, "&Print...");
2909 m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
2910 m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
2911 m_pFileMenu->AppendSeparator();
2912 m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
2914 m_pFileMenu->AppendSeparator();
2915 m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
2916 m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
2918 GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
2919 GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
2921 wxMenu *convert_menu = new wxMenu;
2922 convert_menu->Append (PJMENU_CONVERT_RECTANGULAR, "&Rectangular Image");
2923 convert_menu->Append (PJMENU_CONVERT_POLAR, "&Polar Image...\tCtrl-L");
2924 convert_menu->Append (PJMENU_CONVERT_FFT_POLAR, "FF&T->Polar Image...\tCtrl-T");
2925 convert_menu->AppendSeparator();
2926 convert_menu->Append (PJMENU_CONVERT_PARALLEL, "&Interpolate to Parallel");
2928 wxMenu* filter_menu = new wxMenu;
2929 filter_menu->Append (PJMENU_ARTIFACT_REDUCTION, "&Artifact Reduction");
2931 wxMenu* analyze_menu = new wxMenu;
2932 analyze_menu->Append (PJMENU_PLOT_HISTOGRAM, "&Plot Histogram");
2933 analyze_menu->Append (PJMENU_PLOT_TTHETA_SAMPLING, "Plot T-T&heta Sampling...\tCtrl-H");
2935 wxMenu *reconstruct_menu = new wxMenu;
2936 reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection");
2937 reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP_REBIN, "Filtered &Backprojection (Rebin to Parallel)...\tCtrl-B", "Reconstruct image using filtered backprojection");
2938 reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier");
2939 reconstruct_menu->Enable (PJMENU_RECONSTRUCT_FOURIER, false);
2941 wxMenu *help_menu = new wxMenu;
2942 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
2943 help_menu->Append (MAINMENU_HELP_TIPS, "&Tips");
2944 help_menu->Append (IDH_QUICKSTART, "&Quick Start");
2945 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
2947 wxMenuBar *menu_bar = new wxMenuBar;
2949 menu_bar->Append (m_pFileMenu, "&File");
2950 menu_bar->Append (convert_menu, "&Convert");
2951 menu_bar->Append (filter_menu, "Fi<er");
2952 menu_bar->Append (analyze_menu, "&Analyze");
2953 menu_bar->Append (reconstruct_menu, "&Reconstruct");
2954 menu_bar->Append (help_menu, "&Help");
2956 subframe->SetMenuBar(menu_bar);
2957 subframe->Centre(wxBOTH);
2959 wxAcceleratorEntry accelEntries[7];
2960 accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('L'), PJMENU_CONVERT_POLAR);
2961 accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('T'), PJMENU_CONVERT_FFT_POLAR);
2962 accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('R'), PJMENU_RECONSTRUCT_FBP);
2963 accelEntries[3].Set (wxACCEL_CTRL, static_cast<int>('B'), PJMENU_RECONSTRUCT_FBP_REBIN);
2964 accelEntries[4].Set (wxACCEL_CTRL, static_cast<int>('E'), PJMENU_RECONSTRUCT_FOURIER);
2965 accelEntries[5].Set (wxACCEL_CTRL, static_cast<int>('I'), PJMENU_FILE_PROPERTIES);
2966 accelEntries[6].Set (wxACCEL_CTRL, static_cast<int>('H'), PJMENU_PLOT_TTHETA_SAMPLING);
2967 wxAcceleratorTable accelTable (7, accelEntries);
2968 subframe->SetAcceleratorTable (accelTable);
2975 ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
2977 m_pFrame = CreateChildFrame(doc, this);
2981 m_pFrame->GetClientSize (&width, &height);
2982 m_pFrame->SetTitle ("ProjectionFileView");
2983 m_pCanvas = CreateCanvas (m_pFrame);
2986 int x, y; // X requires a forced resize
2987 m_pFrame->GetSize(&x, &y);
2988 m_pFrame->SetSize(-1, -1, x, y);
2991 m_pFrame->Show(true);
2998 ProjectionFileView::OnDraw (wxDC* dc)
3000 wxSize clientSize = m_pFrame->GetClientSize();
3001 wxSize bestSize = m_pCanvas->GetBestSize();
3003 if (clientSize.x > bestSize.x || clientSize.y > bestSize.y)
3004 m_pFrame->SetClientSize (bestSize);
3007 dc->DrawBitmap (m_bitmap, 0, 0, false);
3012 ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
3014 const Projections& rProj = GetDocument()->getProjections();
3015 const int nDet = rProj.nDet();
3016 const int nView = rProj.nView();
3017 if (nDet != 0 && nView != 0) {
3018 const DetectorArray& detarray = rProj.getDetectorArray(0);
3019 const DetectorValue* detval = detarray.detValues();
3020 double min = detval[0];
3021 double max = detval[0];
3022 for (int iy = 0; iy < nView; iy++) {
3023 const DetectorArray& detarray = rProj.getDetectorArray(iy);
3024 const DetectorValue* detval = detarray.detValues();
3025 for (int ix = 0; ix < nDet; ix++) {
3026 if (min > detval[ix])
3028 else if (max < detval[ix])
3033 unsigned char* imageData = new unsigned char [nDet * nView * 3];
3035 sys_error (ERR_SEVERE, "Unable to allocate memory for image display");
3038 double scale = (max - min) / 255;
3039 for (int iy2 = 0; iy2 < nView; iy2++) {
3040 const DetectorArray& detarray = rProj.getDetectorArray (iy2);
3041 const DetectorValue* detval = detarray.detValues();
3042 for (int ix = 0; ix < nDet; ix++) {
3043 int intensity = static_cast<int>(((detval[ix] - min) / scale) + 0.5);
3044 intensity = clamp(intensity, 0, 255);
3045 int baseAddr = (iy2 * nDet + ix) * 3;
3046 imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
3049 wxImage image (nDet, nView, imageData, true);
3050 m_bitmap = image.ConvertToBitmap();
3054 xSize = clamp (xSize, 0, 800);
3055 ySize = clamp (ySize, 0, 800);
3056 m_pFrame->SetClientSize (xSize, ySize);
3057 m_pCanvas->SetScrollbars (20, 20, nDet/20, nView/20);
3061 m_pCanvas->Refresh();
3065 ProjectionFileView::OnClose (bool deleteWindow)
3067 //GetDocumentManager()->ActivateView (this, false, true);
3068 if (! GetDocument() || ! GetDocument()->Close())
3073 m_pCanvas->setView(NULL);
3076 wxString s(wxTheApp->GetAppName());
3078 m_pFrame->SetTitle(s);
3085 if (GetDocument() && GetDocument()->getBadFileOpen())
3086 ::wxYield(); // wxWindows bug workaround
3095 PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
3096 : wxScrolledWindow(frame, -1, pos, size, style)
3101 PlotFileCanvas::~PlotFileCanvas ()
3107 PlotFileCanvas::OnDraw(wxDC& dc)
3110 m_pView->OnDraw(& dc);
3116 IMPLEMENT_DYNAMIC_CLASS(PlotFileView, wxView)
3118 BEGIN_EVENT_TABLE(PlotFileView, wxView)
3119 EVT_MENU(PLOTMENU_FILE_PROPERTIES, PlotFileView::OnProperties)
3120 EVT_MENU(PLOTMENU_VIEW_SCALE_MINMAX, PlotFileView::OnScaleMinMax)
3121 EVT_MENU(PLOTMENU_VIEW_SCALE_AUTO, PlotFileView::OnScaleAuto)
3122 EVT_MENU(PLOTMENU_VIEW_SCALE_FULL, PlotFileView::OnScaleFull)
3125 PlotFileView::PlotFileView()
3126 : wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pEZPlot(NULL), m_pFileMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
3130 PlotFileView::~PlotFileView()
3135 GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
3139 PlotFileView::OnProperties (wxCommandEvent& event)
3141 const PlotFile& rPlot = GetDocument()->getPlotFile();
3142 std::ostringstream os;
3143 os << "Columns: " << rPlot.getNumColumns() << ", Records: " << rPlot.getNumRecords() << "\n";
3144 rPlot.printHeadersBrief (os);
3145 *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<<\n";
3146 wxMessageDialog dialogMsg (getFrameForChild(), os.str().c_str(), "Plot File Properties", wxOK | wxICON_INFORMATION);
3147 dialogMsg.ShowModal();
3148 GetDocument()->Activate();
3153 PlotFileView::OnScaleAuto (wxCommandEvent& event)
3155 const PlotFile& rPlotFile = GetDocument()->getPlotFile();
3156 double min, max, mean, mode, median, stddev;
3157 rPlotFile.statistics (1, min, max, mean, mode, median, stddev);
3158 DialogAutoScaleParameters dialogAutoScale (getFrameForChild(), mean, mode, median, stddev, m_dAutoScaleFactor);
3159 int iRetVal = dialogAutoScale.ShowModal();
3160 if (iRetVal == wxID_OK) {
3161 m_bMinSpecified = true;
3162 m_bMaxSpecified = true;
3164 if (dialogAutoScale.getMinMax (&dMin, &dMax)) {
3167 m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
3168 OnUpdate (this, NULL);
3171 GetDocument()->Activate();
3175 PlotFileView::OnScaleMinMax (wxCommandEvent& event)
3177 const PlotFile& rPlotFile = GetDocument()->getPlotFile();
3181 if (! m_bMinSpecified || ! m_bMaxSpecified) {
3182 if (! rPlotFile.getMinMax (1, min, max)) {
3183 *theApp->getLog() << "Error: unable to find Min/Max\n";
3188 if (m_bMinSpecified)
3190 if (m_bMaxSpecified)
3193 DialogGetMinMax dialogMinMax (getFrameForChild(), "Set Y-axis Minimum & Maximum", min, max);
3194 int retVal = dialogMinMax.ShowModal();
3195 if (retVal == wxID_OK) {
3196 m_bMinSpecified = true;
3197 m_bMaxSpecified = true;
3198 m_dMinPixel = dialogMinMax.getMinimum();
3199 m_dMaxPixel = dialogMinMax.getMaximum();
3200 OnUpdate (this, NULL);
3202 GetDocument()->Activate();
3206 PlotFileView::OnScaleFull (wxCommandEvent& event)
3208 if (m_bMinSpecified || m_bMaxSpecified) {
3209 m_bMinSpecified = false;
3210 m_bMaxSpecified = false;
3211 OnUpdate (this, NULL);
3213 GetDocument()->Activate();
3218 PlotFileView::CreateCanvas (wxFrame* parent)
3220 PlotFileCanvas* pCanvas;
3222 parent->GetClientSize(&width, &height);
3224 pCanvas = new PlotFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
3226 pCanvas->SetBackgroundColour(*wxWHITE);
3237 PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
3240 wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
3242 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
3244 theApp->setIconForFrame (subframe);
3246 m_pFileMenu = new wxMenu;
3248 m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
3249 m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
3250 m_pFileMenu->Append(wxID_OPEN, "&Open...\tCtrl-O");
3251 m_pFileMenu->Append(wxID_SAVE, "&Save\tCtrl-S");
3252 m_pFileMenu->Append(wxID_SAVEAS, "Save &As...");
3253 m_pFileMenu->Append(wxID_CLOSE, "&Close\tCtrl-W");
3255 m_pFileMenu->AppendSeparator();
3256 m_pFileMenu->Append(PLOTMENU_FILE_PROPERTIES, "P&roperties\tCtrl-I");
3258 m_pFileMenu->AppendSeparator();
3259 m_pFileMenu->Append(wxID_PRINT, "&Print...");
3260 m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
3261 m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
3262 m_pFileMenu->AppendSeparator();
3263 m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
3265 m_pFileMenu->AppendSeparator();
3266 m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
3267 m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
3269 GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
3270 GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
3272 wxMenu *view_menu = new wxMenu;
3273 view_menu->Append(PLOTMENU_VIEW_SCALE_MINMAX, "Display Scale &Set...\tCtrl-E");
3274 view_menu->Append(PLOTMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...\tCtrl-A");
3275 view_menu->Append(PLOTMENU_VIEW_SCALE_FULL, "Display &Full Scale\tCtrl-U");
3277 wxMenu *help_menu = new wxMenu;
3278 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
3279 help_menu->Append (MAINMENU_HELP_TIPS, "&Tips");
3280 help_menu->Append (IDH_QUICKSTART, "&Quick Start");
3281 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
3283 wxMenuBar *menu_bar = new wxMenuBar;
3285 menu_bar->Append(m_pFileMenu, "&File");
3286 menu_bar->Append(view_menu, "&View");
3287 menu_bar->Append(help_menu, "&Help");
3289 subframe->SetMenuBar(menu_bar);
3290 subframe->Centre(wxBOTH);
3292 wxAcceleratorEntry accelEntries[4];
3293 accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('E'), PLOTMENU_VIEW_SCALE_MINMAX);
3294 accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('A'), PLOTMENU_VIEW_SCALE_AUTO);
3295 accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('U'), PLOTMENU_VIEW_SCALE_FULL);
3296 accelEntries[3].Set (wxACCEL_CTRL, static_cast<int>('I'), PLOTMENU_FILE_PROPERTIES);
3297 wxAcceleratorTable accelTable (4, accelEntries);
3298 subframe->SetAcceleratorTable (accelTable);
3305 PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
3307 m_pFrame = CreateChildFrame(doc, this);
3310 m_bMinSpecified = false;
3311 m_bMaxSpecified = false;
3312 m_dAutoScaleFactor = 1.;
3315 m_pFrame->GetClientSize(&width, &height);
3316 m_pFrame->SetTitle ("Plot File");
3317 m_pCanvas = CreateCanvas (m_pFrame);
3320 int x, y; // X requires a forced resize
3321 m_pFrame->GetSize(&x, &y);
3322 m_pFrame->SetSize(-1, -1, x, y);
3325 m_pFrame->Show(true);
3332 PlotFileView::OnDraw (wxDC* dc)
3334 const PlotFile& rPlotFile = GetDocument()->getPlotFile();
3335 const int iNColumns = rPlotFile.getNumColumns();
3336 const int iNRecords = rPlotFile.getNumRecords();
3338 if (iNColumns > 0 && iNRecords > 0) {
3340 m_pCanvas->GetClientSize (&xsize, &ysize);
3341 SGPDriver driver (dc, xsize, ysize);
3344 m_pEZPlot->plot (&sgp);
3350 PlotFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
3352 const PlotFile& rPlotFile = GetDocument()->getPlotFile();
3353 const int iNColumns = rPlotFile.getNumColumns();
3354 const int iNRecords = rPlotFile.getNumRecords();
3355 const bool bScatterPlot = rPlotFile.getIsScatterPlot();
3357 if (iNColumns > 0 && iNRecords > 0) {
3360 m_pEZPlot = new EZPlot;
3362 for (unsigned int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++)
3363 m_pEZPlot->ezset (rPlotFile.getEzsetCommand (iEzset));
3365 if (m_bMinSpecified) {
3366 std::ostringstream os;
3367 os << "ymin " << m_dMinPixel;
3368 m_pEZPlot->ezset (os.str());
3371 if (m_bMaxSpecified) {
3372 std::ostringstream os;
3373 os << "ymax " << m_dMaxPixel;
3374 m_pEZPlot->ezset (os.str());
3377 m_pEZPlot->ezset("box");
3378 m_pEZPlot->ezset("grid");
3380 double* pdX = new double [iNRecords];
3381 double* pdY = new double [iNRecords];
3382 if (! bScatterPlot) {
3383 rPlotFile.getColumn (0, pdX);
3385 for (int iCol = 1; iCol < iNColumns; iCol++) {
3386 rPlotFile.getColumn (iCol, pdY);
3387 m_pEZPlot->addCurve (pdX, pdY, iNRecords);
3390 rPlotFile.getColumn (0, pdX);
3391 rPlotFile.getColumn (1, pdY);
3392 m_pEZPlot->addCurve (pdX, pdY, iNRecords);
3399 m_pCanvas->Refresh();
3403 PlotFileView::OnClose (bool deleteWindow)
3405 //GetDocumentManager()->ActivateView (this, false, true);
3406 if (! GetDocument() || ! GetDocument()->Close())
3411 m_pCanvas->setView (NULL);
3414 wxString s(wxTheApp->GetAppName());
3416 m_pFrame->SetTitle(s);
3422 if (GetDocument() && GetDocument()->getBadFileOpen())
3423 ::wxYield(); // wxWindows bug workaround
3430 ////////////////////////////////////////////////////////////////
3433 IMPLEMENT_DYNAMIC_CLASS(TextFileView, wxView)
3435 TextFileView::~TextFileView()
3437 GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
3438 GetDocumentManager()->ActivateView(this, FALSE, TRUE);;
3441 bool TextFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
3443 m_pFrame = CreateChildFrame(doc, this);
3444 SetFrame (m_pFrame);
3447 m_pFrame->GetClientSize(&width, &height);
3448 m_pFrame->SetTitle("TextFile");
3449 m_pCanvas = new TextFileCanvas (this, m_pFrame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE | wxTE_READONLY);
3450 m_pFrame->SetTitle("Log");
3453 // X seems to require a forced resize
3455 frame->GetSize(&x, &y);
3456 frame->SetSize(-1, -1, x, y);
3459 m_pFrame->Show (true);
3465 // Handled by wxTextWindow
3466 void TextFileView::OnDraw(wxDC *WXUNUSED(dc) )
3470 void TextFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
3475 TextFileView::OnClose (bool deleteWindow)
3477 if (! theApp->getMainFrame()->getShuttingDown())
3481 //GetDocumentManager()->ActivateView (this, false, true);
3482 if (! GetDocument() || ! GetDocument()->Close())
3489 if (GetDocument() && GetDocument()->getBadFileOpen())
3490 ::wxYield(); // wxWindows bug workaround
3501 TextFileView::CreateChildFrame (wxDocument *doc, wxView *view)
3504 wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(0,0), wxDEFAULT_FRAME_STYLE, "Log");
3506 wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(300, 150), wxDEFAULT_FRAME_STYLE, "Log");
3508 theApp->setIconForFrame (subframe);
3510 m_pFileMenu = new wxMenu;
3512 m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
3513 m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
3514 m_pFileMenu->Append(wxID_OPEN, "&Open...\tCtrl-O");
3515 m_pFileMenu->Append(wxID_SAVE, "&Save\tCtrl-S");
3516 m_pFileMenu->Append(wxID_SAVEAS, "Save &As...");
3517 // m_pFileMenu->Append(wxID_CLOSE, "&Close\tCtrl-W");
3519 m_pFileMenu->AppendSeparator();
3520 m_pFileMenu->Append(wxID_PRINT, "&Print...");
3521 m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
3522 m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
3523 m_pFileMenu->AppendSeparator();
3524 m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
3526 m_pFileMenu->AppendSeparator();
3527 m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
3528 m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
3530 GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
3531 GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
3533 wxMenu *help_menu = new wxMenu;
3534 help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
3535 help_menu->Append (MAINMENU_HELP_TIPS, "&Tips");
3536 help_menu->Append (IDH_QUICKSTART, "&Quick Start");
3537 help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
3539 wxMenuBar *menu_bar = new wxMenuBar;
3541 menu_bar->Append(m_pFileMenu, "&File");
3542 menu_bar->Append(help_menu, "&Help");
3544 subframe->SetMenuBar(menu_bar);
3545 subframe->Centre(wxBOTH);
3551 // Define a constructor for my text subwindow
3552 TextFileCanvas::TextFileCanvas (TextFileView* v, wxFrame* frame, const wxPoint& pos, const wxSize& size, long style)
3553 : wxTextCtrl (frame, -1, "", pos, size, style), m_pView(v)
3557 TextFileCanvas::~TextFileCanvas ()