window.show();
std::vector<std::string> sequence_filenames;
- enum {P_NORMAL,P_SEQUENCE,P_WINDOW,P_LEVEL};
- int parse_mode=P_NORMAL;
+ enum {P_NORMAL,P_SEQUENCE,P_WINDOW,P_LEVEL} parse_mode;
+ parse_mode=P_NORMAL;
+ enum {O_BASE,O_OVERLAY,O_FUSION,O_VF,O_CONTOUR} open_mode;
+ std::string open_mode_names[] = {"base", "overlay", "fusion", "vf", "contour"};
+ open_mode=O_BASE;
int n_image_loaded=0;
std::string win(""), lev("");
std::string current = argv[i];
if (!current.compare(0,2,"--")) { //We are parsing an option
if (parse_mode == P_SEQUENCE) {//First finish the current sequence
- window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
+ if(open_mode==O_BASE)
+ window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
+ else if (open_mode==O_OVERLAY)
+ window.AddOverlayImage(n_image_loaded-1,sequence_filenames);
+ else{
+ std::cerr << "Sequences are not managed for opening " << open_mode_names[open_mode] << std::endl;
+ exit(1);
+ }
sequence_filenames.clear();
parse_mode=P_NORMAL;
}
}
if (current=="--vf") {
if (!n_image_loaded) load_image_first_error();
- window.AddField(argv[i+1],n_image_loaded-1);
- i++; //skip vf name
+ open_mode = O_VF;
} else if (current=="--overlay") {
if (!n_image_loaded) load_image_first_error();
- window.AddOverlayImage(n_image_loaded-1,argv[i+1]);
- i++; //skip overlay name
- } /*else if (current=="--roi") {
- if (!n_image_loaded) load_image_first_error();
- window.AddROI(n_image_loaded-1,argv[i+1]);
- i++; //skip roi name
- }*/ else if (current=="--contour") {
+ open_mode = O_OVERLAY;
+ } else if (current=="--contour") {
if (!n_image_loaded) load_image_first_error();
- window.AddDCStructContour(n_image_loaded-1,argv[i+1]);
- i++; //skip roi name
+ open_mode = O_CONTOUR;
} else if (current=="--fusion") {
if (!n_image_loaded) load_image_first_error();
- window.AddFusionImage(n_image_loaded-1,argv[i+1]);
- i++; //skip fusion name
+ open_mode = O_FUSION;
} else if (current == "--sequence") {
- n_image_loaded++; //count only one for the sequence
+ if(open_mode==O_BASE) n_image_loaded++; //count only one for the whole sequence
parse_mode=P_SEQUENCE;
} else if (current == "--window") {
parse_mode=P_WINDOW;
} else {
std::vector<std::string> image;
image.push_back(current);
- window.LoadImages(image, vvImageReader::IMAGE);
- n_image_loaded++;
+ if(open_mode==O_BASE) {
+ window.LoadImages(image, vvImageReader::IMAGE);
+ n_image_loaded++;
+ }
+ else if (open_mode==O_VF)
+ window.AddField(current.c_str(), n_image_loaded-1);
+ else if (open_mode==O_OVERLAY)
+ window.AddOverlayImage(n_image_loaded-1,image);
+ else if (open_mode==O_CONTOUR)
+ window.AddDCStructContour(n_image_loaded-1,current.c_str());
+ else if (open_mode==O_FUSION)
+ window.AddFusionImage(n_image_loaded-1,current.c_str());
+ open_mode = O_BASE;
}
}
if (parse_mode == P_SEQUENCE) { //Finish any current sequence
- window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
+ if(open_mode==O_BASE)
+ window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
+ else if (open_mode==O_OVERLAY)
+ window.AddOverlayImage(n_image_loaded-1,sequence_filenames);
+ else{
+ std::cerr << "Sequences are not managed for opening " << open_mode_names[open_mode] << std::endl;
+ exit(1);
+ }
sequence_filenames.clear();
parse_mode=P_NORMAL;
}
QString Extensions = EXTENSIONS;
Extensions += ";;All Files (*)";
- QString file = QFileDialog::getOpenFileName(this,tr("Load Overlay image"),mInputPathName,Extensions);
- if (!file.isEmpty())
- AddOverlayImage(index,file);
+ QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image"),mInputPathName,Extensions);
+ if (files.isEmpty())
+ return;
+
+ std::vector<std::string> vecFileNames;
+ for (int i = 0; i < files.size(); i++) {
+ vecFileNames.push_back(files[i].toStdString());
+ }
+ AddOverlayImage(index,vecFileNames);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvMainWindow::AddOverlayImage(int index, QString file)
+void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames)
{
+ QString file(fileNames[0].c_str());
if (QFile::exists(file))
{
mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
- reader->SetFileName(file.toStdString().c_str());
+ reader->SetFileName(fileNames[0].c_str());
reader->ReadImageInformation();
std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
int dimension = reader->GetNumberOfDimensions();
qApp->processEvents();
std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
- if (mSlicerManagers[index]->SetOverlay(file.toStdString(),dimension, component)) {
+ if (mSlicerManagers[index]->SetOverlay(fileNames,dimension, component)) {
//create an item in the tree with good settings
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setData(0,Qt::UserRole,file.toStdString().c_str());
void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
void AddField(QString file,int index);
- void AddOverlayImage(int index, QString filename);
+ void AddOverlayImage(int index, std::vector<std::string> fileNames);
void AddFusionImage(int index, QString filename);
void AddROI(int index, QString filename);
///Adds a mesh to a SlicerManager, with optional warping by vector field
if (m_XmlReader->isStartElement()) {
if (value == "FileName") {
file = m_XmlReader->readElementText().toStdString();
- if (!m_XmlReader->hasError())
- m_Window->AddOverlayImage(index, file.c_str());
+ if (!m_XmlReader->hasError()) {
+ // TODO: manage sequence of images
+ std::vector<std::string> vec;
+ vec.push_back(file.c_str());
+ m_Window->AddOverlayImage(index, vec);
+ }
}
if (value == "OverlayColorWindow") {
vald = m_XmlReader->readElementText().toDouble();
//----------------------------------------------------------------------------
-bool vvSlicerManager::SetOverlay(std::string filename,int dim, std::string component)
+bool vvSlicerManager::SetOverlay(std::vector<std::string> filenames,int dim, std::string component)
{
- mOverlayName = filename;
+ mOverlayName = filenames[0];
mOverlayComponent = component;
if (dim > mImage->GetNumberOfDimensions()) {
mLastError = " Overlay dimension cannot be greater then reference image!";
}
if (mOverlayReader.IsNull())
mOverlayReader = vvImageReader::New();
- std::vector<std::string> filenames;
- filenames.push_back(filename);
mOverlayReader->SetInputFilenames(filenames);
mOverlayReader->Update(mImage->GetNumberOfDimensions(),component.c_str(),mType);
if (mOverlayReader->GetLastError().size() == 0) {
void SetImage(vvImage::Pointer image);
bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0);
- bool SetOverlay(std::string filename, int dim, std::string component);
+ bool SetOverlay(std::vector<std::string> filenames, int dim, std::string component);
bool SetFusion(std::string filename, int dim, std::string component);
///Set a VF by loading it from the disk
bool SetVF(std::string filename);