+ DialogExportParameters dialogExport (getFrameForChild(), m_iDefaultExportFormatID);
+ if (dialogExport.ShowModal() == wxID_OK) {
+ wxString strFormatName (dialogExport.getFormatName ());
+ m_iDefaultExportFormatID = ImageFile::convertExportFormatNameToID (strFormatName.c_str());
+
+ wxString strExt;
+ wxString strWildcard;
+ if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PGM || m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PGMASCII) {
+ strExt = ".pgm";
+ strWildcard = "PGM Files (*.pgm)|*.pgm";
+ }
+#ifdef HAVE_PNG
+ else if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PNG || m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PNG16) {
+ strExt = ".png";
+ strWildcard = "PNG Files (*.png)|*.png";
+ }
+#endif
+#ifdef HAVE_CTN_DICOM
+ else if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_DICOM) {
+ strExt = "";
+ strWildcard = "DICOM Files (*.*)|*.*";
+ }
+#endif
+ else if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_TEXT) {
+ strExt = ".txt";
+ strWildcard = "Text (*.txt)|*.txt";
+ }
+ else {
+ strExt = "";
+ strWildcard = "Miscellaneous (*.*)|*.*";
+ }
+
+ const wxString& strFilename = wxFileSelector (wxString("Export Filename"), wxString(""),
+ wxString(""), strExt, strWildcard, wxOVERWRITE_PROMPT | wxHIDE_READONLY | wxSAVE);
+ if (strFilename) {
+ rIF.exportImage (strFormatName.c_str(), strFilename.c_str(), 1, 1, m_dMinPixel, m_dMaxPixel);
+ *theApp->getLog() << "Exported file " << strFilename << "\n";
+ }
+ }
+ }
+}
+
+void
+ImageFileView::OnScaleSize (wxCommandEvent& event)
+{
+ ImageFile& rIF = GetDocument()->getImageFile();
+ unsigned int iOldNX = rIF.nx();
+ unsigned int iOldNY = rIF.ny();
+
+ DialogGetXYSize dialogGetXYSize (getFrameForChild(), "Set New X & Y Dimensions", iOldNX, iOldNY);
+ if (dialogGetXYSize.ShowModal() == wxID_OK) {
+ unsigned int iNewNX = dialogGetXYSize.getXSize();
+ unsigned int iNewNY = dialogGetXYSize.getYSize();
+ std::ostringstream os;
+ os << "Scale Size from (" << iOldNX << "," << iOldNY << ") to (" << iNewNX << "," << iNewNY << ")";
+ ImageFileDocument* pScaledDoc = theApp->newImageDoc();
+ if (! pScaledDoc) {
+ sys_error (ERR_SEVERE, "Unable to create image file");
+ return;
+ }
+ ImageFile& rScaledIF = pScaledDoc->getImageFile();
+ rScaledIF.setArraySize (iNewNX, iNewNY);
+ rScaledIF.labelsCopy (rIF);
+ rScaledIF.labelAdd (os.str().c_str());
+ rIF.scaleImage (rScaledIF);
+ *theApp->getLog() << os.str().c_str() << "\n";
+ if (theApp->getAskDeleteNewDocs())
+ pScaledDoc->Modify (true);
+ pScaledDoc->UpdateAllViews (this);
+ pScaledDoc->getView()->setInitialClientSize();
+ pScaledDoc->Activate();
+ }
+}
+
+#if wxUSE_GLCANVAS
+void
+ImageFileView::OnConvert3d (wxCommandEvent& event)
+{
+ ImageFile& rIF = GetDocument()->getImageFile();
+ Graph3dFileDocument* pGraph3d = theApp->newGraph3dDoc();
+ pGraph3d->getView()->getFrame()->Show (false);
+ pGraph3d->setBadFileOpen();
+ pGraph3d->createFromImageFile (rIF);
+ pGraph3d->UpdateAllViews();
+ pGraph3d->getView()->getFrame()->Show (true);
+ pGraph3d->getView()->Activate(true);
+ ::wxYield();
+ pGraph3d->getView()->getCanvas()->SetFocus();
+}
+#endif
+
+void
+ImageFileView::OnPlotRow (wxCommandEvent& event)
+{
+ int xCursor, yCursor;
+ if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
+ wxMessageBox ("No row selected. Please use left mouse button on image to select column","Error");
+ return;
+ }
+
+ const ImageFile& rIF = GetDocument()->getImageFile();
+ ImageFileArrayConst v = rIF.getArray();
+ ImageFileArrayConst vImag = rIF.getImaginaryArray();
+ int nx = rIF.nx();
+ int ny = rIF.ny();
+
+ if (v != NULL && yCursor < ny) {
+ double* pX = new double [nx];
+ double* pYReal = new double [nx];
+ double *pYImag = NULL;
+ double *pYMag = NULL;
+ if (rIF.isComplex()) {
+ pYImag = new double [nx];
+ pYMag = new double [nx];
+ }
+ for (int i = 0; i < nx; i++) {
+ pX[i] = i;
+ pYReal[i] = v[i][yCursor];
+ if (rIF.isComplex()) {
+ pYImag[i] = vImag[i][yCursor];
+ pYMag[i] = ::sqrt (v[i][yCursor] * v[i][yCursor] + vImag[i][yCursor] * vImag[i][yCursor]);
+ }
+ }
+ PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
+ if (! pPlotDoc) {
+ sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
+ } else {
+ PlotFile& rPlotFile = pPlotDoc->getPlotFile();
+ std::ostringstream os;
+ os << "Row " << yCursor;
+ std::string title("title ");
+ title += os.str();
+ rPlotFile.addEzsetCommand (title.c_str());
+ rPlotFile.addEzsetCommand ("xlabel Column");
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");
+ rPlotFile.addEzsetCommand ("lxfrac 0");
+ rPlotFile.addEzsetCommand ("box");
+ rPlotFile.addEzsetCommand ("grid");
+ rPlotFile.addEzsetCommand ("curve 1");
+ rPlotFile.addEzsetCommand ("color 1");
+ if (rIF.isComplex()) {
+ rPlotFile.addEzsetCommand ("dash 1");
+ rPlotFile.addEzsetCommand ("curve 2");
+ rPlotFile.addEzsetCommand ("color 4");
+ rPlotFile.addEzsetCommand ("dash 3");
+ rPlotFile.addEzsetCommand ("curve 3");
+ rPlotFile.addEzsetCommand ("color 0");
+ rPlotFile.addEzsetCommand ("solid");
+ rPlotFile.setCurveSize (4, nx);
+ } else
+ rPlotFile.setCurveSize (2, nx);
+ rPlotFile.addColumn (0, pX);
+ rPlotFile.addColumn (1, pYReal);
+ if (rIF.isComplex()) {
+ rPlotFile.addColumn (2, pYImag);
+ rPlotFile.addColumn (3, pYMag);
+ }
+ for (unsigned int iL = 0; iL < rIF.nLabels(); iL++)
+ rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str());
+ os << " Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
+ *theApp->getLog() << os.str().c_str() << "\n";
+ rPlotFile.addDescription (os.str().c_str());
+ }
+ delete pX;
+ delete pYReal;
+ if (rIF.isComplex()) {
+ delete pYImag;
+ delete pYMag;
+ }
+ if (theApp->getAskDeleteNewDocs())
+ pPlotDoc->Modify (true);
+ pPlotDoc->getView()->getFrame()->Show(true);
+ pPlotDoc->UpdateAllViews ();
+ pPlotDoc->Activate();
+ }
+}
+
+void
+ImageFileView::OnPlotCol (wxCommandEvent& event)
+{
+ int xCursor, yCursor;
+ if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
+ wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");
+ return;
+ }
+
+ const ImageFile& rIF = GetDocument()->getImageFile();
+ ImageFileArrayConst v = rIF.getArray();
+ ImageFileArrayConst vImag = rIF.getImaginaryArray();
+ int nx = rIF.nx();
+ int ny = rIF.ny();
+
+ if (v != NULL && xCursor < nx) {
+ double* pX = new double [ny];
+ double* pYReal = new double [ny];
+ double* pYImag = NULL;
+ double* pYMag = NULL;
+ if (rIF.isComplex()) {
+ pYImag = new double [ny];
+ pYMag = new double [ny];
+ }
+ for (int i = 0; i < ny; i++) {
+ pX[i] = i;
+ pYReal[i] = v[xCursor][i];
+ if (rIF.isComplex()) {
+ pYImag[i] = vImag[xCursor][i];
+ pYMag[i] = ::sqrt (v[xCursor][i] * v[xCursor][i] + vImag[xCursor][i] * vImag[xCursor][i]);
+ }
+ }
+ PlotFileDocument* pPlotDoc = theApp->newPlotDoc();
+ if (! pPlotDoc) {
+ sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");
+ } else {
+ PlotFile& rPlotFile = pPlotDoc->getPlotFile();
+ std::ostringstream os;
+ os << "Column " << xCursor;
+ std::string title("title ");
+ title += os.str();
+ rPlotFile.addEzsetCommand (title.c_str());
+ rPlotFile.addEzsetCommand ("xlabel Row");
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");
+ rPlotFile.addEzsetCommand ("lxfrac 0");
+ rPlotFile.addEzsetCommand ("box");
+ rPlotFile.addEzsetCommand ("grid");
+ rPlotFile.addEzsetCommand ("curve 1");
+ rPlotFile.addEzsetCommand ("color 1");
+ if (rIF.isComplex()) {
+ rPlotFile.addEzsetCommand ("dash 1");
+ rPlotFile.addEzsetCommand ("curve 2");
+ rPlotFile.addEzsetCommand ("color 4");
+ rPlotFile.addEzsetCommand ("dash 3");
+ rPlotFile.addEzsetCommand ("curve 3");
+ rPlotFile.addEzsetCommand ("color 0");
+ rPlotFile.addEzsetCommand ("solid");
+ rPlotFile.setCurveSize (4, ny);
+ } else
+ rPlotFile.setCurveSize (2, ny);
+ rPlotFile.addColumn (0, pX);
+ rPlotFile.addColumn (1, pYReal);
+ if (rIF.isComplex()) {
+ rPlotFile.addColumn (2, pYImag);
+ rPlotFile.addColumn (3, pYMag);
+ }
+ for (unsigned int iL = 0; iL < rIF.nLabels(); iL++)
+ rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str());
+ os << " Plot of " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str();
+ *theApp->getLog() << os.str().c_str() << "\n";
+ rPlotFile.addDescription (os.str().c_str());
+ }
+ delete pX;
+ delete pYReal;
+ if (rIF.isComplex()) {
+ delete pYImag;
+ delete pYMag;
+ }
+ if (theApp->getAskDeleteNewDocs())
+ pPlotDoc->Modify (true);
+ pPlotDoc->getView()->getFrame()->Show(true);
+ pPlotDoc->UpdateAllViews ();
+ pPlotDoc->Activate();
+ }
+}
+
+#ifdef HAVE_FFT
+void
+ImageFileView::OnPlotFFTRow (wxCommandEvent& event)
+{
+ int xCursor, yCursor;
+ if (! m_pCanvas->GetCurrentCursor (xCursor, yCursor)) {
+ wxMessageBox ("No row selected. Please use left mouse button on image to select column","Error");
+ return;
+ }
+
+ const ImageFile& rIF = GetDocument()->getImageFile();
+ ImageFileArrayConst v = rIF.getArray();
+ ImageFileArrayConst vImag = rIF.getImaginaryArray();
+ int nx = rIF.nx();
+ int ny = rIF.ny();
+
+ if (v != NULL && yCursor < ny) {
+ fftw_complex* pcIn = new fftw_complex [nx];
+
+ int i;
+ for (i = 0; i < nx; i++) {
+ pcIn[i].re = v[i][yCursor];
+ if (rIF.isComplex())
+ pcIn[i].im = vImag[i][yCursor];
+ else
+ pcIn[i].im = 0;
+ }
+
+ fftw_plan plan = fftw_create_plan (nx, FFTW_FORWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM);
+ fftw_one (plan, pcIn, NULL);
+ fftw_destroy_plan (plan);