From 08c1ec110dc7936c2bbd1c619bd2cf3618c6b4cc Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 11 Mar 2001 17:55:29 +0000 Subject: [PATCH] r632: Added Clipboard functions to image files --- ChangeLog | 17 +++--- NEWS | 9 ++- libctsim/projections.cpp | 16 +++--- msvc/ctsim/ctsim.plg | 63 +++------------------ src/backgroundmgr.cpp | 4 +- src/ctsim.h | 8 ++- src/dialogs.cpp | 10 ++-- src/docs.cpp | 9 ++- src/docs.h | 3 +- src/views.cpp | 115 +++++++++++++++++++++++++++++++++++---- src/views.h | 6 +- 11 files changed, 166 insertions(+), 94 deletions(-) diff --git a/ChangeLog b/ChangeLog index 566e6a1..7d4a93f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -3.5.0 - Released 2//01 +3.5.0 - Released 3//01 * ctsim: Added tips to be displayed at startup and via the help menu. @@ -7,6 +7,9 @@ projection files are not incompatible with previous version of CTSim. + * ctsim: Added background and SMP processing for reconstructions, + scanning, and rasterization. + * ctsim: Added generic threaded tasks and background manager for background processing as well as taking advantage of multiple-CPU's on SMP systems. @@ -17,15 +20,11 @@ * ctsim: Added imagefile export to DICOM files. - * ctsim: Added plot t-theta sampling to projection file menu. + * ctsim: Added clipboard cut/copy/paste for image files. - * ctsim: Added background and SMP processing for reconstructions. - - * ctsim: Added background and SMP processing for scanning. - - * ctsim: Added background and SMP processing for rasterization. + * ctsim: Added plot t-theta sampling to projection file menu. - * ctsim: Added region of interest to reconstruction dialog. + * ctsim: Added region of interest to reconstructions. * ctsim: Added "Verbose Logging", "Startup Tips", and "Background processes" options to Preferences dialog. @@ -34,6 +33,8 @@ * ctsim: Added accelerator key for File-Properties + * sgp.cpp/ezplot.cpp: Improved plotting with markers. + * views.cpp: Added out of memory checks to display for huge image and projection files. diff --git a/NEWS b/NEWS index b2837f0..a4a4c47 100644 --- a/NEWS +++ b/NEWS @@ -4,13 +4,20 @@ Version 3.5 New Features takes advantage of multiple-CPU's in SMP systems for speed improvements with parallel processing. +* Interpolate divergent beams to parallel beams for faster reconstructions. + +* Region of interest can be specified for reconstruction zooming. + * Import PNG, PPM, and PGM images * DICOM file import/export +* Clipboard for cutting and pasting images + * Can read and reconstruct SIEMENS AR.STAR DICOM raw data files -* Scattergram of T-Theta sampling. +* Scattergram of T-Theta sampling. Useful for understand divergent beam + scanning. * Added startup-tips to help new users learn features. diff --git a/libctsim/projections.cpp b/libctsim/projections.cpp index dc7248e..27d5b69 100644 --- a/libctsim/projections.cpp +++ b/libctsim/projections.cpp @@ -8,7 +8,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: projections.cpp,v 1.59 2001/03/11 15:27:30 kevin Exp $ +** $Id: projections.cpp,v 1.60 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -688,17 +688,16 @@ Projections::convertPolar (ImageFile& rIF, int iInterpolationID) if (! v || nx == 0 || ny == 0) return false; - if (m_geometry != Scanner::GEOMETRY_PARALLEL) { - sys_error (ERR_WARNING, "convertPolar supports Parallel only"); - return false; - } + Projections* pProj = this; + if (m_geometry == Scanner::GEOMETRY_EQUIANGULAR || m_geometry == Scanner::GEOMETRY_EQUILINEAR) + pProj = interpolateToParallel(); Array2d adView (nx, ny); Array2d adDet (nx, ny); double** ppdView = adView.getArray(); double** ppdDet = adDet.getArray(); - if (! calcArrayPolarCoordinates (nx, ny, ppdView, ppdDet)) + if (! pProj->calcArrayPolarCoordinates (nx, ny, ppdView, ppdDet)) return false; std::complex** ppcDetValue = new std::complex* [m_nView]; @@ -709,12 +708,15 @@ Projections::convertPolar (ImageFile& rIF, int iInterpolationID) ppcDetValue[iView][iDet] = std::complex(getDetectorArray (iView).detValues()[iDet], 0); } - interpolatePolar (v, vImag, nx, ny, ppcDetValue, ppdView, ppdDet, m_nView, m_nDet, iInterpolationID); + pProj->interpolatePolar (v, vImag, nx, ny, ppcDetValue, ppdView, ppdDet, m_nView, m_nDet, iInterpolationID); for (iView = 0; iView < m_nView; iView++) delete [] ppcDetValue[iView]; delete [] ppcDetValue; + if (m_geometry == Scanner::GEOMETRY_EQUIANGULAR || m_geometry == Scanner::GEOMETRY_EQUILINEAR) + delete pProj; + return true; } diff --git a/msvc/ctsim/ctsim.plg b/msvc/ctsim/ctsim.plg index 21230c3..34c4d9d 100644 --- a/msvc/ctsim/ctsim.plg +++ b/msvc/ctsim/ctsim.plg @@ -3,63 +3,16 @@
 

Build Log

---------------------Configuration: libctsim - Win32 Debug-------------------- +--------------------Configuration: ctsim - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP461.tmp" with contents -[ -/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "..\..\..\wx2.2.5\src\png" /I "..\..\..\wx2.2.5\src\zlib" /I "..\..\INCLUDE" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\fftw" /I "..\..\..\fftw-2.1.3\rfftw" /I "..\..\..\wx2.2.5\include" /I "\dicom\ctn\include" /D "_DEBUG" /D "HAVE_WXWIN" /D "HAVE_STRING_H" /D "HAVE_GETOPT_H" /D "WIN32" /D "_MBCS" /D "_LIB" /D "MSVC" /D "HAVE_FFTW" /D "HAVE_PNG" /D "HAVE_SGP" /D "HAVE_WXWINDOWS" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "HAVE_CTN_DICOM" /D VERSION=\"3.1.0\" /FR"Debug/" /Fp"Debug/libctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c -"C:\ctsim\libctgraphics\ezplot.cpp" -"C:\ctsim\libctsim\projections.cpp" -] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP461.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP462.tmp" with contents +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP4EA.tmp" with contents [ -/nologo /out:"Debug\libctsim.lib" -.\Debug\array2dfile.obj -.\Debug\backprojectors.obj -.\Debug\clip.obj -.\Debug\consoleio.obj -.\Debug\ctndicom.obj -.\Debug\dlgezplot.obj -.\Debug\ezplot.obj -.\Debug\ezset.obj -.\Debug\ezsupport.obj -.\Debug\filter.obj -.\Debug\fnetorderstream.obj -.\Debug\fourier.obj -.\Debug\getopt.obj -.\Debug\getopt1.obj -.\Debug\globalvars.obj -.\Debug\hashtable.obj -.\Debug\imagefile.obj -.\Debug\interpolator.obj -.\Debug\mathfuncs.obj -.\Debug\phantom.obj -.\Debug\plotfile.obj -.\Debug\pol.obj -.\Debug\procsignal.obj -.\Debug\projections.obj -.\Debug\reconstruct.obj -.\Debug\scanner.obj -.\Debug\sgp.obj -.\Debug\strfuncs.obj -.\Debug\syserror.obj -.\Debug\trace.obj -.\Debug\transformmatrix.obj -.\Debug\xform.obj +/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /I "\dicom\ctn\include" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.1.0\" /D "HAVE_CTN_DICOM" /D CTSIMVERSION=\"3.0.0alpha5\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\ctsim\src\views.cpp" ] -Creating command line "link.exe -lib @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP462.tmp" -

Output Window

-Compiling... -ezplot.cpp -projections.cpp -Creating library... -

---------------------Configuration: ctsim - Win32 Debug-------------------- -

-

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP463.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP4EA.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP4EB.tmp" with contents [ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib wxd.lib xpmd.lib tiffd.lib zlibd.lib pngd.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib htmlhelp.lib ctn_lib.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"\wx2.2.5\lib" /libpath:"\dicom\ctn\winctn\ctn_lib\Debug" .\Debug\backgroundmgr.obj @@ -86,8 +39,10 @@ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\.. \wx2.2.5\lib\zlibd.lib \wx2.2.5\lib\tiffd.lib ] -Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP463.tmp" +Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP4EB.tmp"

Output Window

+Compiling... +views.cpp Linking... diff --git a/src/backgroundmgr.cpp b/src/backgroundmgr.cpp index 58bd902..55e611b 100644 --- a/src/backgroundmgr.cpp +++ b/src/backgroundmgr.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: backgroundmgr.cpp,v 1.17 2001/03/11 12:37:34 kevin Exp $ +** $Id: backgroundmgr.cpp,v 1.18 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -151,8 +151,8 @@ BackgroundManager::OnAddTask (wxCommandEvent& event) resizeWindow(); if (m_iNumTasks == 1) { + m_pCanvas->SetFocus(); Show(true); - theApp->getLog()->SetFocus(); } } diff --git a/src/ctsim.h b/src/ctsim.h index 9ca514c..ef100ad 100644 --- a/src/ctsim.h +++ b/src/ctsim.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: ctsim.h,v 1.57 2001/03/11 06:34:37 kevin Exp $ +** $Id: ctsim.h,v 1.58 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -315,7 +315,11 @@ enum { IFMENU_FILE_EXPORT, IFMENU_FILE_PROPERTIES, - + + IFMENU_EDIT_COPY, + IFMENU_EDIT_CUT, + IFMENU_EDIT_PASTE, + IFMENU_PLOT_ROW, IFMENU_PLOT_COL, IFMENU_PLOT_FFT_ROW, diff --git a/src/dialogs.cpp b/src/dialogs.cpp index b4811ed..57dc3f7 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: dialogs.cpp,v 1.50 2001/03/11 15:27:30 kevin Exp $ +** $Id: dialogs.cpp,v 1.51 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -392,7 +392,7 @@ DialogAutoScaleParameters::DialogAutoScaleParameters (wxWindow *pParent, double pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - wxString asTitle[] = {"Median", "Mode", "Mean"}; + wxString asTitle[] = {"Mode", "Median", "Mean"}; m_pRadioBoxCenter = new wxRadioBox (this, -1, _T("Center"), wxDefaultPosition, wxDefaultSize, 3, asTitle, 1, wxRA_SPECIFY_COLS); m_pRadioBoxCenter->SetSelection (0); @@ -429,11 +429,11 @@ bool DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax) { int iCenter = m_pRadioBoxCenter->GetSelection(); - double dCenter = m_dMedian; + double dCenter = m_dMode; if (iCenter == 1) - dCenter = m_dMode; + dCenter = m_dMedian; else if (iCenter == 2) - dCenter = m_dMode; + dCenter = m_dMean; wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue(); double dValue; diff --git a/src/docs.cpp b/src/docs.cpp index bd4e404..aa70dbf 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: docs.cpp,v 1.33 2001/03/05 17:26:46 kevin Exp $ +** $Id: docs.cpp,v 1.34 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -104,6 +104,13 @@ ImageFileDocument::getView() const return dynamic_cast(GetFirstView()); } +void +ImageFileDocument::Activate() +{ +#if CTSIM_MDI + getView()->getFrame()->Activate(); +#endif +}; bool ImageFileDocument::Revert () diff --git a/src/docs.h b/src/docs.h index 7c41956..ab29026 100644 --- a/src/docs.h +++ b/src/docs.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: docs.h,v 1.28 2001/03/05 17:26:46 kevin Exp $ +** $Id: docs.h,v 1.29 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -84,6 +84,7 @@ public: ImageFileView* getView() const; bool getBadFileOpen() const { return m_bBadFileOpen; } void setBadFileOpen() { m_bBadFileOpen = true; } + void Activate(); }; class BackgroundProcessingDocument : public wxDocument diff --git a/src/views.cpp b/src/views.cpp index c9689bf..41e4367 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: views.cpp,v 1.133 2001/03/11 15:27:30 kevin Exp $ +** $Id: views.cpp,v 1.134 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -36,6 +36,7 @@ #include "wx/image.h" #include "wx/progdlg.h" +#include "wx/clipbrd.h" #include "ct.h" #include "ctsim.h" @@ -204,6 +205,9 @@ IMPLEMENT_DYNAMIC_CLASS(ImageFileView, wxView) BEGIN_EVENT_TABLE(ImageFileView, wxView) EVT_MENU(IFMENU_FILE_EXPORT, ImageFileView::OnExport) EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties) +EVT_MENU(IFMENU_EDIT_COPY, ImageFileView::OnEditCopy) +EVT_MENU(IFMENU_EDIT_CUT, ImageFileView::OnEditCut) +EVT_MENU(IFMENU_EDIT_PASTE, ImageFileView::OnEditPaste) EVT_MENU(IFMENU_VIEW_SCALE_MINMAX, ImageFileView::OnScaleMinMax) EVT_MENU(IFMENU_VIEW_SCALE_AUTO, ImageFileView::OnScaleAuto) EVT_MENU(IFMENU_VIEW_SCALE_FULL, ImageFileView::OnScaleFull) @@ -289,6 +293,7 @@ ImageFileView::OnProperties (wxCommandEvent& event) wxMessageDialog dialogMsg (getFrameForChild(), os.str().c_str(), "Imagefile Properties", wxOK | wxICON_INFORMATION); dialogMsg.ShowModal(); } + GetDocument()->Activate(); } void @@ -307,9 +312,10 @@ ImageFileView::OnScaleAuto (wxCommandEvent& event) m_dMinPixel = dMin; m_dMaxPixel = dMax; m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor(); - OnUpdate (this, NULL); + GetDocument()->UpdateAllViews (this); } } + GetDocument()->Activate(); } void @@ -332,8 +338,9 @@ ImageFileView::OnScaleMinMax (wxCommandEvent& event) m_bMaxSpecified = true; m_dMinPixel = dialogMinMax.getMinimum(); m_dMaxPixel = dialogMinMax.getMaximum(); - OnUpdate (this, NULL); + GetDocument()->UpdateAllViews (this); } + GetDocument()->Activate(); } void @@ -342,8 +349,9 @@ ImageFileView::OnScaleFull (wxCommandEvent& event) if (m_bMinSpecified || m_bMaxSpecified) { m_bMinSpecified = false; m_bMaxSpecified = false; - OnUpdate (this, NULL); + GetDocument()->UpdateAllViews (this); } + GetDocument()->Activate(); } void @@ -401,6 +409,7 @@ ImageFileView::OnCompare (wxCommandEvent& event) pDifferenceDoc->UpdateAllViews (this); pDifferenceDoc->getView()->OnUpdate (this, NULL); pDifferenceDoc->getView()->getFrame()->Show(true); + pDifferenceDoc->Activate(); } wxMessageBox(os.str().c_str(), "Image Comparison"); } @@ -416,6 +425,7 @@ ImageFileView::OnInvertValues (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); + GetDocument()->Activate(); } void @@ -427,6 +437,7 @@ ImageFileView::OnSquare (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); + GetDocument()->Activate(); } void @@ -438,6 +449,7 @@ ImageFileView::OnSquareRoot (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); + GetDocument()->Activate(); } void @@ -449,6 +461,7 @@ ImageFileView::OnLog (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); + GetDocument()->Activate(); } void @@ -460,6 +473,7 @@ ImageFileView::OnExp (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); + GetDocument()->Activate(); } void @@ -497,8 +511,8 @@ ImageFileView::OnAdd (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); pNewDoc->UpdateAllViews (this); - pNewDoc->getView()->OnUpdate (this, NULL); pNewDoc->getView()->getFrame()->Show(true); + pNewDoc->Activate(); } } } @@ -538,8 +552,8 @@ ImageFileView::OnSubtract (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); pNewDoc->UpdateAllViews (this); - pNewDoc->getView()->OnUpdate (this, NULL); pNewDoc->getView()->getFrame()->Show(true); + pNewDoc->Activate(); } } } @@ -579,8 +593,8 @@ ImageFileView::OnMultiply (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); pNewDoc->UpdateAllViews (this); - pNewDoc->getView()->OnUpdate (this, NULL); pNewDoc->getView()->getFrame()->Show(true); + pNewDoc->Activate(); } } } @@ -620,8 +634,8 @@ ImageFileView::OnDivide (wxCommandEvent& event) if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); pNewDoc->UpdateAllViews (this); - pNewDoc->getView()->OnUpdate (this, NULL); pNewDoc->getView()->getFrame()->Show(true); + pNewDoc->Activate(); } } } @@ -850,6 +864,11 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu); GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu); + wxMenu* edit_menu = new wxMenu; + edit_menu->Append(IFMENU_EDIT_COPY, "Copy\tCtrl-C"); + edit_menu->Append(IFMENU_EDIT_CUT, "Cut\tCtrl-X"); + edit_menu->Append(IFMENU_EDIT_PASTE, "Paste\tCtrl-V"); + wxMenu *view_menu = new wxMenu; view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale S&et...\tCtrl-E"); view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...\tCtrl-A"); @@ -918,6 +937,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(m_pFileMenu, "&File"); + menu_bar->Append(edit_menu, "&Edit"); menu_bar->Append(view_menu, "&View"); menu_bar->Append(image_menu, "&Image"); menu_bar->Append(filter_menu, "Fi<er"); @@ -928,16 +948,19 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) subframe->Centre(wxBOTH); - wxAcceleratorEntry accelEntries[5]; + wxAcceleratorEntry accelEntries[8]; accelEntries[0].Set (wxACCEL_CTRL, static_cast('A'), IFMENU_VIEW_SCALE_AUTO); accelEntries[1].Set (wxACCEL_CTRL, static_cast('U'), IFMENU_VIEW_SCALE_FULL); accelEntries[2].Set (wxACCEL_CTRL, static_cast('E'), IFMENU_VIEW_SCALE_MINMAX); accelEntries[3].Set (wxACCEL_CTRL, static_cast('I'), IFMENU_FILE_PROPERTIES); + accelEntries[4].Set (wxACCEL_CTRL, static_cast('C'), IFMENU_EDIT_COPY); + accelEntries[5].Set (wxACCEL_CTRL, static_cast('X'), IFMENU_EDIT_CUT); + accelEntries[6].Set (wxACCEL_CTRL, static_cast('V'), IFMENU_EDIT_PASTE); #if wxUSE_GLCANVAS - accelEntries[4].Set (wxACCEL_CTRL, static_cast('3'), IFMENU_IMAGE_CONVERT3D); - wxAcceleratorTable accelTable (5, accelEntries); + accelEntries[7].Set (wxACCEL_CTRL, static_cast('3'), IFMENU_IMAGE_CONVERT3D); + wxAcceleratorTable accelTable (8, accelEntries); #else - wxAcceleratorTable accelTable (4, accelEntries); + wxAcceleratorTable accelTable (7, accelEntries); #endif subframe->SetAcceleratorTable (accelTable); @@ -1062,6 +1085,72 @@ ImageFileView::OnClose (bool deleteWindow) return true; } +void +ImageFileView::OnEditCopy (wxCommandEvent& event) +{ + wxBitmapDataObject *pBitmapObject = new wxBitmapDataObject; + + pBitmapObject->SetBitmap (m_bitmap); + + if (wxTheClipboard->Open()) { + wxTheClipboard->SetData (pBitmapObject); + wxTheClipboard->Close(); + } +} + +void +ImageFileView::OnEditCut (wxCommandEvent& event) +{ + OnEditCopy (event); + ImageFile& rIF = GetDocument()->getImageFile(); + int nx = rIF.nx(); + int ny = rIF.ny(); + ImageFile* pIF = new ImageFile (nx, ny); + pIF->arrayDataClear(); + GetDocument()->setImageFile (pIF); // deletes old IF + OnUpdate(this, NULL); + GetDocument()->UpdateAllViews(); + if (theApp->getAskDeleteNewDocs()) + GetDocument()->Modify (true); +} + +void +ImageFileView::OnEditPaste (wxCommandEvent& event) +{ + ImageFile& rIF = GetDocument()->getImageFile(); + + if (wxTheClipboard->Open()) { + wxBitmap bitmap; + if (wxTheClipboard->IsSupported (wxDF_BITMAP)) { + wxBitmapDataObject bitmapObject; + wxTheClipboard->GetData (bitmapObject); + bitmap = bitmapObject.GetBitmap (); + } + wxTheClipboard->Close(); + + int nx = rIF.nx(); + int ny = rIF.ny(); + if (bitmap.Ok() == true && bitmap.GetWidth() == nx && bitmap.GetHeight() == ny) { + wxImage image (bitmap); + unsigned char* pixels = image.GetData(); + ImageFileArray v = rIF.getArray(); + for (int ix = 0; ix < rIF.nx(); ix++) { + for (int iy = 0; iy < rIF.ny(); iy++) { + unsigned int iBase = 3 * (iy * nx + ix); + double dR = pixels[iBase] / 255.; + double dG = pixels[iBase+1] / 255.; + double dB = pixels[iBase+2] / 255.; + v[ix][ny - 1 - iy] = ImageFile::colorToGrayscale (dR, dG, dB); + } + } + OnUpdate(this, NULL); + GetDocument()->UpdateAllViews(); + if (theApp->getAskDeleteNewDocs()) + GetDocument()->Modify(true); + } + } +} + void ImageFileView::OnExport (wxCommandEvent& event) { @@ -2340,6 +2429,7 @@ ProjectionFileView::OnConvertPolar (wxCommandEvent& event) DialogGetConvertPolarParameters dialogPolar (getFrameForChild(), "Convert Polar", m_iDefaultPolarNX, m_iDefaultPolarNY, m_iDefaultPolarInterpolation, -1); if (dialogPolar.ShowModal() == wxID_OK) { + wxProgressDialog dlgProgress (wxString("Convert Polar"), wxString("Conversion Progress"), 1, getFrameForChild(), wxPD_APP_MODAL); wxString strInterpolation (dialogPolar.getInterpolationName()); m_iDefaultPolarNX = dialogPolar.getXSize(); m_iDefaultPolarNY = dialogPolar.getYSize(); @@ -2381,6 +2471,7 @@ ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event) DialogGetConvertPolarParameters dialogPolar (getFrameForChild(), "Convert to FFT Polar", m_iDefaultPolarNX, m_iDefaultPolarNY, m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad); if (dialogPolar.ShowModal() == wxID_OK) { + wxProgressDialog dlgProgress (wxString("Convert FFT Polar"), wxString("Conversion Progress"), 1, getFrameForChild(), wxPD_APP_MODAL); wxString strInterpolation (dialogPolar.getInterpolationName()); m_iDefaultPolarNX = dialogPolar.getXSize(); m_iDefaultPolarNY = dialogPolar.getYSize(); diff --git a/src/views.h b/src/views.h index 1946806..9aca964 100644 --- a/src/views.h +++ b/src/views.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: views.h,v 1.49 2001/03/11 06:34:37 kevin Exp $ +** $Id: views.h,v 1.50 2001/03/11 17:55:29 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -91,6 +91,10 @@ public: void OnUpdate(wxView *sender, wxObject *hint = NULL); bool OnClose (bool deleteWindow = true); + void OnEditCopy (wxCommandEvent& event); + void OnEditCut (wxCommandEvent& event); + void OnEditPaste (wxCommandEvent& event); + void OnRevert (wxCommandEvent& event); void OnExport (wxCommandEvent& event); void OnProperties (wxCommandEvent& event); -- 2.34.1