** 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
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<double> adView (nx, ny);
Array2d<double> 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<double>** ppcDetValue = new std::complex<double>* [m_nView];
ppcDetValue[iView][iDet] = std::complex<double>(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;
}
** 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
#include "wx/image.h"
#include "wx/progdlg.h"
+#include "wx/clipbrd.h"
#include "ct.h"
#include "ctsim.h"
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)
wxMessageDialog dialogMsg (getFrameForChild(), os.str().c_str(), "Imagefile Properties", wxOK | wxICON_INFORMATION);
dialogMsg.ShowModal();
}
+ GetDocument()->Activate();
}
void
m_dMinPixel = dMin;
m_dMaxPixel = dMax;
m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
- OnUpdate (this, NULL);
+ GetDocument()->UpdateAllViews (this);
}
}
+ GetDocument()->Activate();
}
void
m_bMaxSpecified = true;
m_dMinPixel = dialogMinMax.getMinimum();
m_dMaxPixel = dialogMinMax.getMaximum();
- OnUpdate (this, NULL);
+ GetDocument()->UpdateAllViews (this);
}
+ GetDocument()->Activate();
}
void
if (m_bMinSpecified || m_bMaxSpecified) {
m_bMinSpecified = false;
m_bMaxSpecified = false;
- OnUpdate (this, NULL);
+ GetDocument()->UpdateAllViews (this);
}
+ GetDocument()->Activate();
}
void
pDifferenceDoc->UpdateAllViews (this);
pDifferenceDoc->getView()->OnUpdate (this, NULL);
pDifferenceDoc->getView()->getFrame()->Show(true);
+ pDifferenceDoc->Activate();
}
wxMessageBox(os.str().c_str(), "Image Comparison");
}
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
GetDocument()->UpdateAllViews (this);
+ GetDocument()->Activate();
}
void
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
GetDocument()->UpdateAllViews (this);
+ GetDocument()->Activate();
}
void
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
GetDocument()->UpdateAllViews (this);
+ GetDocument()->Activate();
}
void
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
GetDocument()->UpdateAllViews (this);
+ GetDocument()->Activate();
}
void
if (theApp->getAskDeleteNewDocs())
GetDocument()->Modify (true);
GetDocument()->UpdateAllViews (this);
+ GetDocument()->Activate();
}
void
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->OnUpdate (this, NULL);
pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->Activate();
}
}
}
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->OnUpdate (this, NULL);
pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->Activate();
}
}
}
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->OnUpdate (this, NULL);
pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->Activate();
}
}
}
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->OnUpdate (this, NULL);
pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->Activate();
}
}
}
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");
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");
subframe->Centre(wxBOTH);
- wxAcceleratorEntry accelEntries[5];
+ wxAcceleratorEntry accelEntries[8];
accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('A'), IFMENU_VIEW_SCALE_AUTO);
accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('U'), IFMENU_VIEW_SCALE_FULL);
accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('E'), IFMENU_VIEW_SCALE_MINMAX);
accelEntries[3].Set (wxACCEL_CTRL, static_cast<int>('I'), IFMENU_FILE_PROPERTIES);
+ accelEntries[4].Set (wxACCEL_CTRL, static_cast<int>('C'), IFMENU_EDIT_COPY);
+ accelEntries[5].Set (wxACCEL_CTRL, static_cast<int>('X'), IFMENU_EDIT_CUT);
+ accelEntries[6].Set (wxACCEL_CTRL, static_cast<int>('V'), IFMENU_EDIT_PASTE);
#if wxUSE_GLCANVAS
- accelEntries[4].Set (wxACCEL_CTRL, static_cast<int>('3'), IFMENU_IMAGE_CONVERT3D);
- wxAcceleratorTable accelTable (5, accelEntries);
+ accelEntries[7].Set (wxACCEL_CTRL, static_cast<int>('3'), IFMENU_IMAGE_CONVERT3D);
+ wxAcceleratorTable accelTable (8, accelEntries);
#else
- wxAcceleratorTable accelTable (4, accelEntries);
+ wxAcceleratorTable accelTable (7, accelEntries);
#endif
subframe->SetAcceleratorTable (accelTable);
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)
{
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();
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();