** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: ctsim.cpp,v 1.90 2001/03/01 20:02:18 kevin Exp $
+** $Id: ctsim.cpp,v 1.91 2001/03/02 02:08:14 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
#endif
#endif
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.90 2001/03/01 20:02:18 kevin Exp $";
+static const char* rcsindent = "$Id: ctsim.cpp,v 1.91 2001/03/02 02:08:14 kevin Exp $";
struct option CTSimApp::ctsimOptions[] =
{
wxString strWildcard;
if (m_iDefaultImportFormat == ImageFile::IMPORT_FORMAT_PPM) {
strExt = ".ppm";
- strWildcard = "PPM Files (*.ppm)|*.pgm|PGM Files (*.pgm)|*.pgm";
+ strWildcard = "PPM Files (*.ppm)|*.ppm|PGM Files (*.pgm)|*.pgm";
}
#ifdef HAVE_PNG
else if (m_iDefaultImportFormat == ImageFile::IMPORT_FORMAT_PNG) {
strExt = ".png";
strWildcard = "PNG Files (*.png)|*.png";
}
+#endif
+#ifdef HAVE_CTN_DICOM
+ else if (m_iDefaultImportFormat == ImageFile::IMPORT_FORMAT_DICOM) {
+ strExt = "*.*";
+ strWildcard = "Dicom Files (*.*)|*.*";
+ }
#endif
else {
return;
wxString strFilename = wxFileSelector (wxString("Import Filename"), wxString(""),
wxString(""), strExt, strWildcard, wxHIDE_READONLY | wxOPEN);
if (! strFilename.IsEmpty()) {
- ImageFile* pIF = new ImageFile;
- if (pIF->importImage (strFormatName.c_str(), strFilename.c_str())) {
- ImageFileDocument* pIFDoc = theApp->newImageDoc();
- pIFDoc->setImageFile(pIF);
- pIFDoc->getView()->getFrame()->Show(true);
- std::ostringstream os;
- os << "Import file " << strFilename.c_str() << " (type " << strFormatName.c_str() << ")";
- pIF->labelAdd (os.str().c_str());
- if (theApp->getAskDeleteNewDocs())
- pIFDoc->Modify (true);
- pIFDoc->UpdateAllViews();
- pIFDoc->GetFirstView()->OnUpdate (NULL, NULL);
- pIFDoc->getView()->getFrame()->Show(true);
- } else
- delete pIF;
+ if (m_iDefaultImportFormat == ImageFile::IMPORT_FORMAT_PPM || m_iDefaultImportFormat == ImageFile::IMPORT_FORMAT_PNG) {
+ ImageFile* pIF = new ImageFile;
+ if (pIF->importImage (strFormatName.c_str(), strFilename.c_str())) {
+ ImageFileDocument* pIFDoc = theApp->newImageDoc();
+ pIFDoc->setImageFile(pIF);
+ pIFDoc->getView()->getFrame()->Show(true);
+ std::ostringstream os;
+ os << "Import file " << strFilename.c_str() << " (type " << strFormatName.c_str() << ")";
+ pIF->labelAdd (os.str().c_str());
+ if (theApp->getAskDeleteNewDocs())
+ pIFDoc->Modify (true);
+ pIFDoc->UpdateAllViews();
+ pIFDoc->GetFirstView()->OnUpdate (NULL, NULL);
+ pIFDoc->getView()->getFrame()->Show(true);
+ } else
+ delete pIF;
+ }
+#ifdef HAVE_CTN_DICOM
+ else if (m_iDefaultImportFormat == ImageFile::IMPORT_FORMAT_DICOM) {
+ DicomImporter dicomImport (strFilename.c_str());
+ if (dicomImport.fail()) {
+ ::wxMessageBox (dicomImport.failMessage().c_str(), "Import Error");
+ } else if (dicomImport.testImage()) {
+ ImageFileDocument* pIFDoc = theApp->newImageDoc();
+ ImageFile* pIF = dicomImport.getImageFile();
+ pIFDoc->setImageFile (pIF);
+ pIFDoc->getView()->getFrame()->Show(true);
+ std::ostringstream os;
+ os << "Import file " << strFilename.c_str() << " (type " << strFormatName.c_str() << ")";
+ pIF->labelAdd (os.str().c_str());
+ if (theApp->getAskDeleteNewDocs())
+ pIFDoc->Modify (true);
+ pIFDoc->UpdateAllViews();
+ pIFDoc->GetFirstView()->OnUpdate (NULL, NULL);
+ pIFDoc->getView()->getFrame()->Show(true);
+ } else if (dicomImport.testProjections()) {
+ ProjectionFileDocument* pProjDoc = theApp->newProjectionDoc();
+ Projections* pProj = dicomImport.getProjections();
+ pProjDoc->setProjections (pProj);
+ pProjDoc->getView()->getFrame()->Show(true);
+ std::ostringstream os;
+ os << "Import projection file " << strFilename.c_str() << " (type " << strFormatName.c_str() << ")";
+ pProj->setRemark (os.str().c_str());
+ if (theApp->getAskDeleteNewDocs())
+ pProjDoc->Modify (true);
+ pProjDoc->UpdateAllViews();
+ pProjDoc->GetFirstView()->OnUpdate (NULL, NULL);
+ pProjDoc->getView()->getFrame()->Show(true);
+ } else
+ ::wxMessageBox ("Unrecognized DICOM file contents", "Import Error");
+ }
+#endif
+ else
+ sys_error (ERR_WARNING, "Unknown import format type");
}
}