]> Creatis software - clitk.git/blobdiff - vv/vvMainWindow.cxx
Debug RTStruct conversion with empty struc
[clitk.git] / vv / vvMainWindow.cxx
index 9ee7f8c2eb26e9d5133ade0a36704610fc47adb3..d148c3f14cc8ecf9ed748483372cbe5751ebaa6c 100644 (file)
@@ -18,11 +18,14 @@ It is distributed under dual licence
 
 #include <algorithm>
 #include <QMessageBox>
+#include <QMimeData>
 #include <QInputDialog>
 #include <QTimer>
 #include "QTreePushButton.h"
 #include <QUrl>
 #include <QSettings>
+#include <QShortcut>
+#include <QFileSystemWatcher>
 
 // VV include
 #include "vvMainWindow.h"
@@ -47,8 +50,14 @@ It is distributed under dual licence
 #include "vvMeshReader.h"
 #include "vvSaveState.h"
 #include "vvReadState.h"
+#if CLITK_USE_PACS_CONNECTION
+#include "vvQPacsConnection.h"
+#endif
 #include "clitkConfiguration.h"
 #include "clitkMatrix.h"
+#ifdef Q_OS_OSX
+# include "vvOSXHelper.h"
+#endif
 
 // ITK include
 #include <itkImage.h>
@@ -75,9 +84,7 @@ It is distributed under dual licence
 #include <vtkPNGWriter.h>
 #include <vtkJPEGWriter.h>
 #include <vtkGenericMovieWriter.h>
-#ifdef CLITK_EXPERIMENTAL
-#  include <vvAnimatedGIFWriter.h>
-#endif
+#include <vvAnimatedGIFWriter.h>
 #ifdef VTK_USE_VIDEO_FOR_WINDOWS
 #  include <vtkAVIWriter.h>
 #endif
@@ -124,9 +131,16 @@ It is distributed under dual licence
 
 //------------------------------------------------------------------------------
 vvMainWindow::vvMainWindow():vvMainWindowBase()
-{ //out << __func__ << endl;
+{ 
   setupUi(this); // this sets up the GUI
 
+  setAcceptDrops(true); // enable to drop into the window
+
+  setDicomClient();
+
+  //Qt::WindowFlags flags = windowFlags();
+  //setWindowFlags(flags | Qt::WindowStaysOnTopHint);
+
   mInputPathName = "";
   mMenuTools = menuTools;
   //  mMenuSegmentation = menuSegmentation;
@@ -143,7 +157,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   contextActions.resize(0);
   QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/fileopen.png")),
     tr("O&pen new Image"));
-  actionOpen_new_image->setShortcut(QKeySequence(tr("Ctrl+O")));
   connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages()));
   contextActions.push_back(actionOpen_new_image);
   contextMenu.addSeparator();
@@ -197,21 +210,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
     tr("Reset transformation to identity"));
   connect(actionResetMatrix, SIGNAL(triggered()), this,SLOT(ResetTransformationToIdentity()));
 
-  // TRIAL DS
-  /*
-  QMenu * m = new QMenu(menubar);
-  m->setTitle("TOTO");
-  //  m->setObjectName(QString::fromUtf8("TOTOTO"));
-  contextMenu.addMenu(m);
-  QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
-  tr("BIDON"));
-  QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
-  tr("BIDON2"));
-  m->addAction(a);
-  m->addAction(b);
-  connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
-  */
-
   //init the DataTree
   mSlicerManagers.resize(0);
 
@@ -239,6 +237,9 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   documentation = new vvDocumentation();
   help_dialog = new vvHelpDialog();
   dicomSeriesSelector = new vvDicomSeriesSelector();
+#if CLITK_USE_PACS_CONNECTION
+     PacsConnection = new vvQPacsConnection();
+#endif
 
   inverseButton->setEnabled(0);
   actionAdd_overlay_image_to_current_image->setEnabled(0);
@@ -281,6 +282,9 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   connect(actionWarp_image_with_vector_field,SIGNAL(triggered()),this,SLOT(WarpImage()));
   connect(actionLoad_images,SIGNAL(triggered()),this,SLOT(OpenImages()));
   connect(actionOpen_Dicom,SIGNAL(triggered()),this,SLOT(OpenDicom()));
+#if CLITK_USE_PACS_CONNECTION
+  connect(actionConnect_Pacs,SIGNAL(triggered()),this,SLOT(ConnectPacs()));
+#endif
   //  connect(actionOpen_Dicom_Struct,SIGNAL(triggered()),this,SLOT(OpenDCStructContour()));
   connect(actionOpen_VTK_contour,SIGNAL(triggered()),this,SLOT(OpenVTKContour()));
   connect(actionOpen_Multiple_Images_As_One,SIGNAL(triggered()),this,SLOT(MergeImages()));
@@ -296,6 +300,11 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   connect(actionAdd_overlay_image_to_current_image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
   connect(actionAdd_USSequence_toCT,SIGNAL(triggered()), this,SLOT(SelectFusionSequence()));
   connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
+
+  QShortcut *shortcutHelp = new QShortcut(QKeySequence(QKeySequence::HelpContents),this);
+  shortcutHelp->setContext(Qt::ApplicationShortcut);
+  QObject::connect(shortcutHelp, SIGNAL(activated()), this, SLOT(ShowHelpDialog()));
+
   connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
   connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
 
@@ -363,6 +372,13 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   SOViewWidget->hide();
   SEViewWidget->hide();
 
+#ifdef Q_OS_OSX
+  disableGLHiDPI(NOViewWidget->winId());
+  disableGLHiDPI(NEViewWidget->winId());
+  disableGLHiDPI(SOViewWidget->winId());
+  disableGLHiDPI(SEViewWidget->winId());
+#endif
+
   //Recently opened files
   std::list<std::string> recent_files = GetRecentlyOpenedImages();
   recentlyOpenedFilesMenu=NULL;
@@ -371,39 +387,50 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
     updateRecentlyOpenedFilesMenu(recent_files);
   }
 
+  //Update and get vv parameters
+  setVVSettings();
+
   // Adding all new tools (insertion in the menu)
   vvToolManager::GetInstance()->InsertToolsInMenu(this);
   vvToolManager::GetInstance()->EnableToolsInMenu(this, false);
 
+//#ifndef CLITK_EXPERIMENTAL
+//#define CLITK_EXPERIMENTAL 0
+//#endif
+#ifdef CLITK_EXPERIMENTAL
   if (!CLITK_EXPERIMENTAL)
     menuExperimental->menuAction()->setVisible(false);
+#endif
 
+#if !CLITK_USE_PACS_CONNECTION
+    actionConnect_Pacs->setVisible(false);
+#endif
 
   QTimer * timerMemory = new QTimer(this);
   //timerMemory->setInterval(5);
   connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
   timerMemory->start(2000);
-
 }
+
 //------------------------------------------------------------------------------
 void vvMainWindow::show()
-{ //out << __func__ << endl;
+{ 
   vvMainWindowBase::show();
   PopupRegisterForm(true);
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateMemoryUsage()
-{ //out << __func__ << endl;
+{ 
   //  clitk::PrintMemory(true);
   if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA");
-  else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB");
+  else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MB");
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvMainWindow::createRecentlyOpenedFilesMenu()
-{ //out << __func__ << endl;
+{ 
   recentlyOpenedFilesMenu = new QMenu("Recently opened files...");
   recentlyOpenedFilesMenu->setIcon(QIcon(QString::fromUtf8(":/common/icons/open.png")));
   menuFile->insertMenu(actionOpen_Image_With_Time,recentlyOpenedFilesMenu);
@@ -415,7 +442,7 @@ void vvMainWindow::createRecentlyOpenedFilesMenu()
 //------------------------------------------------------------------------------
 
 void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list<std::string> &recent_files)
-{ //out << __func__ << endl;
+{ 
   if(recentlyOpenedFilesMenu==NULL) {
     createRecentlyOpenedFilesMenu();
   } else {
@@ -432,7 +459,7 @@ void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list<std::string> &r
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ComputeMidPosition()
-{ //out << __func__ << endl;
+{ 
   bool ok;
   int index=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   int ref = QInputDialog::getInt(this,"Chose reference phase","Reference phase",0,0,\
@@ -457,7 +484,7 @@ mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation)
-{ //out << __func__ << endl;
+{ 
   QTreeWidgetItem *item = new QTreeWidgetItem();
   item->setData(0,Qt::UserRole,"filename.vtk");
   item->setData(1,Qt::UserRole,tr("contour"));
@@ -465,7 +492,7 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro
   brush.setColor(QColor(contour->r*255,contour->g*255,contour->b*255));
   brush.setStyle(Qt::SolidPattern);
   item->setData(COLUMN_IMAGE_NAME,Qt::BackgroundRole,brush);
-  //  item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
+  item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
 
   for (int j = 1; j <= 4; j++)
     item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(image_index)->data(j,Qt::CheckStateRole));
@@ -504,7 +531,7 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenVTKContour()
-{ //out << __func__ << endl;
+{ 
   if (mSlicerManagers.size() > 0) {
     QString Extensions = "Images ( *.vtk *.obj)";
     Extensions += ";;All Files (*)";
@@ -527,7 +554,7 @@ void vvMainWindow::OpenVTKContour()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddDCStructContour(int index, QString file)
-{ //out << __func__ << endl;
+{ 
   vvMeshReader reader;
   reader.SetFilename(file.toStdString());
   vvStructSelector selector;
@@ -551,7 +578,7 @@ void vvMainWindow::AddDCStructContour(int index, QString file)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenDCStructContour()
-{ //out << __func__ << endl;
+{ 
   if (mSlicerManagers.size() > 0) {
     QString Extensions = "Dicom Files ( *.dcm RS*)";
     Extensions += ";;All Files (*)";
@@ -567,7 +594,7 @@ void vvMainWindow::OpenDCStructContour()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ComputeDeformableRegistration()
-{ //out << __func__ << endl;
+{ 
   if (mSlicerManagers.size() > 0) {
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
     vvDeformationDialog dialog(index,mSlicerManagers);
@@ -584,7 +611,7 @@ void vvMainWindow::ComputeDeformableRegistration()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WarpImage()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (!mSlicerManagers[index]->GetVF().IsNull()) {
     bool ok;
@@ -601,7 +628,7 @@ void vvMainWindow::WarpImage()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phase)
-{ //out << __func__ << endl;
+{ 
   if (!selected_slicer->GetVF().IsNull()) {
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     QFileInfo info(selected_slicer->GetFileName().c_str());
@@ -624,17 +651,20 @@ void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phas
 
 //------------------------------------------------------------------------------
 vvMainWindow::~vvMainWindow()
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i] != NULL)
       delete mSlicerManagers[i];
   }
+  delete documentation;
+  delete help_dialog;
+  delete dicomSeriesSelector;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 QTabWidget * vvMainWindow::GetTab()
-{ //out << __func__ << endl;
+{ 
   return tabWidget;
 }
 //------------------------------------------------------------------------------
@@ -642,7 +672,7 @@ QTabWidget * vvMainWindow::GetTab()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::MergeImages()
-{ //out << __func__ << endl;
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
   QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images"),mInputPathName,Extensions);
@@ -701,7 +731,7 @@ void vvMainWindow::MergeImages()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SliceImages()
-{ //out << __func__ << endl;
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
 
@@ -718,7 +748,7 @@ void vvMainWindow::SliceImages()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::MergeImagesWithTime()
-{ //out << __func__ << endl;
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
   QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images With Time"),mInputPathName,Extensions);
@@ -740,7 +770,7 @@ void vvMainWindow::MergeImagesWithTime()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenDicom()
-{ //out << __func__ << endl;
+{ 
   std::vector<std::string> files;
 
   //std::cout << "dicomSeriesSelector " << std::endl;
@@ -748,12 +778,29 @@ void vvMainWindow::OpenDicom()
     files = *(dicomSeriesSelector->GetFilenames());
     LoadImages(files, vvImageReader::DICOM);
   }
-}
+}  
+#if CLITK_USE_PACS_CONNECTION
+void vvMainWindow::ConnectPacs()
+{
+  std::vector<std::string> files;
+
+  //std::cout << "dicomSeriesSelector " << std::endl;
+if (PacsConnection->exec() == QDialog::Accepted) {
+       for (int i = 0; i < PacsConnection->getSeriesCount(); i++)
+       {
+               files = PacsConnection->getFileNames(i);
+               LoadImages(files, vvImageReader::DICOM);
+       }
+       PacsConnection->clearMove();
+  }
+  }
+
+#endif
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenImages()
-{ //out << __func__ << endl;
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
 
@@ -768,7 +815,7 @@ void vvMainWindow::OpenImages()
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenRecentImage()
-{ //out << __func__ << endl;
+{ 
   QAction * caller = qobject_cast<QAction*>(sender());
   std::vector<std::string> images;
   images.push_back(caller->text().toStdString());
@@ -776,11 +823,30 @@ void vvMainWindow::OpenRecentImage()
   LoadImages(images, vvImageReader::IMAGE);
 }
 //------------------------------------------------------------------------------
+void vvMainWindow::dragEnterEvent(QDragEnterEvent *event)
+{
+  if (event->mimeData()->hasUrls()) {
+    event->acceptProposedAction();
+  }
+}
+//------------------------------------------------------------------------------
+void vvMainWindow::dropEvent(QDropEvent *event)
+{
+  const QMimeData * mimeData = event->mimeData();
+  if (!mimeData->hasUrls())
+    return;
+  std::vector<std::string> images;
+  for (int i=0; i<mimeData->urls().size(); ++i) {
+    images.push_back(mimeData->urls()[i].toLocalFile().toStdString());
+  }
+  LoadImages(images, vvImageReader::IMAGE);
+}
+//------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenImageWithTime()
-{ //out << __func__ << endl;
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
 
@@ -799,7 +865,7 @@ void vvMainWindow::OpenImageWithTime()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::LoadedImageType filetype)
-{ //out << __func__ << endl;
+{ 
   //Separate the way to open images and dicoms
   int fileSize;
   if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME)
@@ -862,12 +928,14 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
       // Change filename if an image with the same already exist
       int number = GetImageDuplicateFilenameNumber(files[i] + std::string("_slice"));
 
-      if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED) {
+      if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED)
         SetImageSucceed = imageManager->SetImage(files[i],filetype, number, j);
-      } else {
+      else if (filetype == vvImageReader::DICOM)
+        SetImageSucceed = imageManager->SetImages(files,filetype, number, dicomSeriesSelector->IsPatientCoordianteSystemChecked());
+      else
         SetImageSucceed = imageManager->SetImages(files,filetype, number);
-      }
-      if (!SetImageSucceed) {;
+
+      if (!SetImageSucceed) {
         QApplication::restoreOverrideCursor();
         QString error = "Cannot open file \n";
         error += imageManager->GetLastError().c_str();
@@ -915,6 +983,12 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
 
         linkPanel->addImage(imageManager->GetFileName(), id.toStdString());
 
+        //Create a watcher to see if the image file is modified. In such a case, reload it automatically
+        QFileSystemWatcher* watcher = new QFileSystemWatcher;
+        watcher->addPath(files[i].c_str());
+        connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(SlotFileChanged(const QString&)));
+
+
         connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
           this,SLOT(CurrentImageChanged(std::string)));
         connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)),
@@ -944,6 +1018,7 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
         connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
           this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
         connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+        connect(landmarksPanel,SIGNAL(UpdateLandmarkTransform()), mSlicerManagers.back(), SLOT(UpdateLandmark()));
         InitSlicers();
         numberofsuccesulreads++;
       }
@@ -974,7 +1049,7 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateTree()
-{ //out << __func__ << endl;
+{ 
   DataTree->resizeColumnToContents(COLUMN_TREE);
   DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
   DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
@@ -988,7 +1063,7 @@ void vvMainWindow::UpdateTree()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CurrentImageChanged(std::string id)
-{ //out << __func__ << endl;
+{ 
   if (id == mCurrentSelectedImageId) return; // Do nothing
   int selected = 0;
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
@@ -1015,7 +1090,7 @@ void vvMainWindow::CurrentImageChanged(std::string id)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CurrentPickedImageChanged(std::string id)
-{ //out << __func__ << endl;
+{ 
   if (id == mCurrentPickedImageId) return; // Do nothing
   int selected = 0;
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
@@ -1036,7 +1111,7 @@ void vvMainWindow::CurrentPickedImageChanged(std::string id)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ImageInfoChanged()
-{ //out << __func__ << endl;
+{ 
   contextActions[6]->setEnabled(1);
   contextActions[5]->setEnabled(1);
   actionSave_As->setEnabled(1);
@@ -1132,7 +1207,7 @@ void vvMainWindow::ImageInfoChanged()
       sizeMM[i] = inputSize[i]*inputSpacing[i];
       NPixel *= inputSize[i];
     }
-    inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
+    inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize());
 
     QString dim = QString::number(dimension) + " (";
     dim += pixelType + ")";
@@ -1214,14 +1289,14 @@ void vvMainWindow::ImageInfoChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ShowDocumentation()
-{ //out << __func__ << endl;
+{ 
   documentation->show();
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::PopupRegisterForm(bool checkCanPush)
-{ //out << __func__ << endl;
+{ 
   vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://www.creatis.insa-lyon.fr/~dsarrut/vvregister/write.php"), getVVSettingsPath(), getSettingsOptionFormat());
   if(!checkCanPush) {
     registerForm->show();
@@ -1236,14 +1311,14 @@ void vvMainWindow::PopupRegisterForm(bool checkCanPush)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ShowHelpDialog()
-{ //out << __func__ << endl;
+{ 
   help_dialog->show();
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ChangeViewMode()
-{ //out << __func__ << endl;
+{ 
   typedef struct _SIZE{
     QSplitter* splitter;
     QList<int> size1, size2;
@@ -1327,21 +1402,21 @@ void vvMainWindow::ChangeViewMode()
 
 //------------------------------------------------------------------------------
 QString vvMainWindow::GetSizeInBytes(unsigned long size)
-{ //out << __func__ << endl;
+{ 
   QString result = "";// QString::number(size);
   //result += " bytes (";
   if (size > 1000000000) {
     size /= 1000000000;
     result += QString::number(size);
-    result += "Gb";//)";
+    result += "GB";//)";
   } else if (size > 1000000) {
     size /= 1000000;
     result += QString::number(size);
-    result += "Mb";//)";
+    result += "MB";//)";
   } else if (size > 1000) {
     size /= 1000;
     result += QString::number(size);
-    result += "kb";//)";
+    result += "kB";//)";
   }
   return result;
 }
@@ -1349,7 +1424,7 @@ QString vvMainWindow::GetSizeInBytes(unsigned long size)
 
 //------------------------------------------------------------------------------
 QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
-{ //out << __func__ << endl;
+{ 
   QString result;
   for (unsigned int i= 0; i < vectorDouble.size(); i++) {
     if (i != 0)
@@ -1362,7 +1437,7 @@ QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
 
 //------------------------------------------------------------------------------
 QString vvMainWindow::GetVectorIntAsString(std::vector<int> vectorInt)
-{ //out << __func__ << endl;
+{ 
   QString result;
   for (unsigned int i= 0; i < vectorInt.size(); i++) {
     if (i != 0)
@@ -1373,10 +1448,33 @@ QString vvMainWindow::GetVectorIntAsString(std::vector<int> vectorInt)
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvMainWindow::SlotFileChanged(const QString& pathname)
+{
+  std::vector<QTreeWidgetItem*> items = GetItemFromPathname(pathname);
+  for (unsigned int i=0; i< items.size(); ++i)
+    ReloadImage(items[i], 0);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+std::vector<QTreeWidgetItem*> vvMainWindow::GetItemFromPathname(const QString& pathname)
+{
+  std::vector<QTreeWidgetItem*> items;
+  for (int i = 0; i < DataTree->topLevelItemCount(); ++i) {
+    QString tempItemPathname(DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString());
+    tempItemPathname = tempItemPathname.left(tempItemPathname.length() - 1);
+    if (tempItemPathname == pathname)
+      items.push_back(DataTree->topLevelItem(i));
+  }
+  return items;
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 //this actually returns the SlicerManager index!
 int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item)
-{ //out << __func__ << endl;
+{ 
   QString id = item->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
     if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
@@ -1388,7 +1486,7 @@ int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item)
 
 //------------------------------------------------------------------------------
 QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm)
-{ //out << __func__ << endl;
+{ 
   QString id = sm->GetId().c_str();
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
     if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
@@ -1400,7 +1498,7 @@ QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
-{ //out << __func__ << endl;
+{ 
   if ( column >= COLUMN_CLOSE_IMAGE || column <= 0)
     return;
 
@@ -1468,20 +1566,22 @@ void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
 //------------------------------------------------------------------------------
 
 void vvMainWindow::InitSlicers()
-{ //out << __func__ << endl;
+{ 
   if (mSlicerManagers.size()) {
     mSlicerManagers.back()->GenerateDefaultLookupTable();
     mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->GetRenderWindow());
     mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->GetRenderWindow());
     mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->GetRenderWindow());
     mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->GetRenderWindow());
-    mSlicerManagers.back()->Render(); // SR: displayed #slice is wrong without this
+#if VTK_MAJOR_VERSION <= 5
+    mSlicerManagers.back()->Render(); // SR: displayed #slice is wrong without this / TB: With VTK6 and multiple images, all slicers are updated, not only the first
+#endif
   }
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::InitDisplay()
-{ //out << __func__ << endl;
+{ 
   if (mSlicerManagers.size()) {
     //BE CAREFUL : this is absolutely necessary to set the interactor style
     //in order to have the same style instanciation for all SlicerManagers in
@@ -1516,7 +1616,7 @@ void vvMainWindow::InitDisplay()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::DisplaySliders(int slicer, int window)
-{ //out << __func__ << endl;
+{ 
   if(!mSlicerManagers[slicer]->GetSlicer(window)->GetRenderer()->GetDraw())
     return;
 
@@ -1545,7 +1645,7 @@ void vvMainWindow::DisplaySliders(int slicer, int window)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(item);
 
   if (DataTree->topLevelItem(index) != item) {
@@ -1663,7 +1763,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
-{ //out << __func__ << endl;
+{ 
   // int index = GetSlicerIndexFromItem(item);
   //   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
   //   if (item->data(1,Qt::UserRole).toString() == "vector")
@@ -1703,28 +1803,28 @@ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::MousePositionChanged(int visibility,double x, double y, double z, double X, double Y, double Z , double value)
-{ //out << __func__ << endl;
+{ 
   infoPanel->setCurrentInfo(visibility,x,y,z,X,Y,Z,value);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::VectorChanged(int visibility,double x, double y, double z, double value)
-{ //out << __func__ << endl;
+{ 
   overlayPanel->getCurrentVectorInfo(visibility,x,y,z,value);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OverlayChanged(int visibility, double valueOver, double valueRef)
-{ //out << __func__ << endl;
+{ 
   overlayPanel->getCurrentOverlayInfo(visibility,valueOver, valueRef);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::FusionChanged(int visibility, double value)
-{ //out << __func__ << endl;
+{ 
   overlayPanel->getCurrentFusionInfo(visibility,value);
 }
 //------------------------------------------------------------------------------
@@ -1734,7 +1834,7 @@ void vvMainWindow::FusionChanged(int visibility, double value)
 //or when UpdateWindowLevel() is called ; when slicerManager emits WindowLevelChanged
 //when ImageInfoChanged() is called
 void vvMainWindow::WindowLevelChanged()
-{ //out << __func__ << endl;
+{ 
   // Base image
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if(index==-1) return;
@@ -1789,7 +1889,7 @@ void vvMainWindow::WindowLevelChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WindowLevelEdited()
-{ //out << __func__ << endl;
+{ 
   presetComboBox->setCurrentIndex(WL_USER);
   UpdateWindowLevel();
 }
@@ -1797,7 +1897,7 @@ void vvMainWindow::WindowLevelEdited()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetWindowLevel(double w, double l)
-{ //out << __func__ << endl;
+{ 
   windowSpinBox->setValue(w);
   levelSpinBox->setValue(l);
   presetComboBox->setCurrentIndex(WL_USER);
@@ -1808,7 +1908,7 @@ void vvMainWindow::SetWindowLevel(double w, double l)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateWindowLevel()
-{ //out << __func__ << endl;
+{ 
   if (DataTree->selectedItems().size()) {
     if (presetComboBox->currentIndex() == WL_VENTILATION) //For ventilation
       colorMapComboBox->setCurrentIndex(5);
@@ -1824,7 +1924,7 @@ void vvMainWindow::UpdateWindowLevel()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSlicingPreset()
-{ //out << __func__ << endl;
+{ 
   if (DataTree->selectedItems().size()) {
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
     mSlicerManagers[index]->SetSlicingPreset(vvSlicerManager::SlicingPresetType(slicingPresetComboBox->currentIndex()));
@@ -1834,7 +1934,7 @@ void vvMainWindow::UpdateSlicingPreset()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateColorMap()
-{ //out << __func__ << endl;
+{ 
   if (DataTree->selectedItems().size()) {
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
     mSlicerManagers[index]->SetColorMap(colorMapComboBox->currentIndex());
@@ -1843,7 +1943,7 @@ void vvMainWindow::UpdateColorMap()
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::SwitchWindowLevel()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   int window = mSlicerManagers[index]->GetColorWindow();
   presetComboBox->setCurrentIndex(WL_USER);
@@ -1854,7 +1954,7 @@ void vvMainWindow::SwitchWindowLevel()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ApplyWindowLevelToAllImages()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if(index==-1) return;
   double window = mSlicerManagers[index]->GetColorWindow();
@@ -1883,10 +1983,11 @@ void vvMainWindow::ApplyWindowLevelToAllImages()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax)
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = indexMin; i <= indexMax && i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i] == NULL)
       continue;
+    SetWindowLevel(window, mSlicerManagers[i]->GetColorLevel());
     mSlicerManagers[i]->SetColorWindow(window);
     mSlicerManagers[i]->SetPreset(WL_USER);
     mSlicerManagers[i]->Render();
@@ -1896,10 +1997,11 @@ void vvMainWindow::ApplyWindowToSetOfImages(double window, unsigned int indexMin
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax)
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = indexMin; i <= indexMax && i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i] == NULL)
       continue;
+    SetWindowLevel(mSlicerManagers[i]->GetColorWindow(), level);
     mSlicerManagers[i]->SetColorLevel(level);
     mSlicerManagers[i]->SetPreset(WL_USER);
     mSlicerManagers[i]->Render();
@@ -1909,7 +2011,7 @@ void vvMainWindow::ApplyLevelToSetOfImages(double level, unsigned int indexMin,
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps)
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i]->GetId() == id) {
       mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps);
@@ -1922,7 +2024,7 @@ void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, doubl
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm, vvSlicer* refSlicer)
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (id == mSlicerManagers[i]->GetId()) {
       mSlicerManagers[i]->UpdateLinkedNavigation(refSlicer);
@@ -1933,7 +2035,7 @@ void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm,
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ShowContextMenu(QPoint point)
-{ //out << __func__ << endl;
+{ 
   if (!DataTree->selectedItems().size()) {
     contextActions[1]->setEnabled(0);
     contextActions[2]->setEnabled(0);
@@ -1962,51 +2064,60 @@ void vvMainWindow::ShowContextMenu(QPoint point)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CloseImage()
-{ //out << __func__ << endl;
+{ 
   CloseImage(DataTree->selectedItems()[0],0);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReloadImage()
-{ //out << __func__ << endl;
+{ 
   ReloadImage(DataTree->selectedItems()[0],0);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectOverlayImage()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
+  if (!(CheckAddedImage(index, "overlay")))
+    return;
+
+  QString Extensions = EXTENSIONS;
+  Extensions += ";;All Files (*)";
+  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,vvImageReader::IMAGE);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+bool vvMainWindow::CheckAddedImage(int index, QString imageType)
+{ 
   //check if one overlay image is added
   for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "overlay") {
+    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString().compare(imageType) == 0) {
       QString error = "Cannot add more than one compared image\n";
       error += "Please remove first ";
       error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
       QMessageBox::information(this,tr("Problem adding compared image !"),error);
-      return;
+      return false;
     }
-
-    QString Extensions = EXTENSIONS;
-    Extensions += ";;All Files (*)";
-    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,vvImageReader::IMAGE);
+    return true;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{ //out << __func__ << endl;
+{ 
   QString file(fileNames[0].c_str());
   if (QFile::exists(file))
   {
@@ -2031,6 +2142,10 @@ void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames
       item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
       item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("overlay").c_str());
       qApp->processEvents();
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
 
       for (int j = 1; j <= 4; j++) {
         item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
@@ -2086,7 +2201,7 @@ void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddROI(int index, QString file)
-{ //out << __func__ << endl;
+{ 
   /*
   // Get slice manager
 
@@ -2113,37 +2228,29 @@ void vvMainWindow::AddROI(int index, QString file)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectFusionImage()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
-  //check if one fusion image is added
-  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
-      (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
-        QString error = "Cannot add more than one fusion image\n";
-        error += "Please remove first ";
-        error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-        QMessageBox::information(this,tr("Problem adding fusion image !"),error);
-        return;
-    }
+  if (!(CheckAddedImage(index, "fusion")) || !(CheckAddedImage(index, "fusionSequence")))
+    return;
 
-    QString Extensions = EXTENSIONS;
-    Extensions += ";;All Files (*)";
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Fusion image"),mInputPathName,Extensions);
-    if (files.isEmpty())
-      return;
+  QString Extensions = EXTENSIONS;
+  Extensions += ";;All Files (*)";
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Fusion 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());
-    }
-    AddFusionImage(index,vecFileNames,vvImageReader::IMAGE);
+  std::vector<std::string> vecFileNames;
+  for (int i = 0; i < files.size(); i++) {
+    vecFileNames.push_back(files[i].toStdString());
+  }
+  AddFusionImage(index,vecFileNames,vvImageReader::IMAGE);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ResetTransformationToIdentity()
-{ //out << __func__ << endl;
+{ 
   std::string actorType = DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString().toStdString();
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   mSlicerManagers[index]->ResetTransformationToIdentity(actorType);
@@ -2153,7 +2260,7 @@ void vvMainWindow::ResetTransformationToIdentity()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddFusionImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{ //out << __func__ << endl;
+{ 
   QString file(fileNames[0].c_str());
   if (QFile::exists(file))
   {
@@ -2178,7 +2285,10 @@ void vvMainWindow::AddFusionImage(int index, std::vector<std::string> fileNames,
           item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
           item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusion").c_str());
           qApp->processEvents();
-
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
       for (int j = 1; j <= 4; j++) {
         item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
       }
@@ -2231,7 +2341,7 @@ void vvMainWindow::AddFusionImage(int index, std::vector<std::string> fileNames,
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 void vvMainWindow::AddLandmarks(int index, std::vector<std::string> files)
-{ //out << __func__ << endl;
+{ 
     if (!landmarksPanel->LoadFromFile(files))
       QMessageBox::information(this,tr("Problem reading Landmarks !"),"File doesn't exist!");
 
@@ -2241,35 +2351,29 @@ void vvMainWindow::AddLandmarks(int index, std::vector<std::string> files)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenField()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-  //check if a vector field has already been added
-  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "vector") {
-      QString error = "Cannot add more than one vector field\n";
-      error += "Please remove first ";
-      error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-      QMessageBox::information(this,tr("Problem adding vector field!"),error);
-      return;
-    }
+  
+  if (!(CheckAddedImage(index, "vector")))
+    return;
 
-    QString Extensions = "Images ( *.mhd *.mha *.vf *.nii *.nrrd *.nhdr)";
-    // Extensions += ";;Images ( *.mha)";
-    // Extensions += ";;VF Images ( *.vf)";
-    // Extensions += ";;nii Images ( *.nii)";
-    // Extensions += ";;nrrd Images ( *.nrrd)";
-    // Extensions += ";;nhdr Images ( *.nhdr)";
-    Extensions += ";;All Files (*)";
-    QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
-    if (!file.isEmpty())
-      AddField(file,index);
+  QString Extensions = "Images ( *.mhd *.mha *.vf *.nii *.nrrd *.nhdr)";
+  // Extensions += ";;Images ( *.mha)";
+  // Extensions += ";;VF Images ( *.vf)";
+  // Extensions += ";;nii Images ( *.nii)";
+  // Extensions += ";;nrrd Images ( *.nrrd)";
+  // Extensions += ";;nhdr Images ( *.nhdr)";
+  Extensions += ";;All Files (*)";
+  QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
+  if (!file.isEmpty())
+    AddField(file,index);
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk)
-{ //out << __func__ << endl;
+{ 
   //create an item in the tree with good settings
   QTreeWidgetItem *item = new QTreeWidgetItem();
   item->setData(0,Qt::UserRole,filename.toStdString().c_str());
@@ -2320,11 +2424,15 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
-{ //out << __func__ << endl;
+{ 
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
   vvSlicerManager* imageManager = mSlicerManagers[index];
   if (imageManager->SetVF(vf,file.toStdString())) {
     AddFieldEntry(file,index,false);
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
   } else {
     QString error = "Cannot import the vector field for this image.\n";
     error += imageManager->GetLastError().c_str();
@@ -2337,7 +2445,7 @@ void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddField(QString file,int index)
-{ //out << __func__ << endl;
+{ 
   if (QFile::exists(file)) {
     mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
 
@@ -2369,7 +2477,7 @@ void vvMainWindow::AddField(QString file,int index)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width, double r, double g, double b)
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
     for (int i = 0; i < 4; i++) {
@@ -2389,7 +2497,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width,
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetOverlayProperty(int color, int linked, double window, double level)
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) {
     mSlicerManagers[index]->SetOverlayColor(color);
@@ -2404,7 +2512,7 @@ void vvMainWindow::SetOverlayProperty(int color, int linked, double window, doub
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap,double window, double level, bool showLegend)
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
     mSlicerManagers[index]->SetFusionColorMap(colormap);
@@ -2422,40 +2530,33 @@ void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectFusionSequence()
-{ //out << __func__ << endl;
+{ 
   //get the index of the slicer manager of the main sequence (CT)
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-  //check if one overlay image is already associated
-  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
-      (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
-        QString error = "Cannot add more than one compared image\n";
-        error += "Please remove first ";
-        error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-        QMessageBox::information(this,tr("Problem adding compared image !"),error);
-        return;
-    }
 
-    QString Extensions = EXTENSIONS;
-    Extensions += ";;All Files (*)";
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),mInputPathName,Extensions);
-    if (files.isEmpty())
-      return;
+  if (!(CheckAddedImage(index, "fusion")) || !(CheckAddedImage(index, "fusionSequence")))
+    return;
 
-    std::vector<std::string> vecFileNames;
-    for (int i = 0; i < files.size(); i++) {
-      vecFileNames.push_back(files[i].toStdString());
-    }
+  QString Extensions = EXTENSIONS;
+  Extensions += ";;All Files (*)";
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),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());
+  }
 
-    //associate the secondary sequence (US) to the main one
-    AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME);
+  //associate the secondary sequence (US) to the main one
+  AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME);
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectFusionSequenceCorrespondances() 
-{ //out << __func__ << endl;
+{ 
   //make sure the index is right?
   //in the end, I should attach the temporal data to the right sequence!
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
@@ -2519,7 +2620,7 @@ void vvMainWindow::SelectFusionSequenceCorrespondances()
 //when this function is called index is the slicer manager index corresponding to the main sequence (CT)
 //the files behind fileNames points to the data for the secondary sequence
 void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{ //out << __func__ << endl;
+{ 
   QString file(fileNames[0].c_str());
   if (QFile::exists(file))
   {
@@ -2547,6 +2648,10 @@ void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNam
       item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
       item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusionSequence").c_str());
       qApp->processEvents();
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
       for (int j = 1; j <= 4; j++) {
         item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
       }
@@ -2640,7 +2745,7 @@ void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNam
 //------------------------------------------------------------------------------
 //fusionSequenceFrameIndex and fusionSequenceNbFrames are relative to the secondary sequence (US)
 void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag)
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
   if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return;
@@ -2720,7 +2825,7 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveAs()
-{ //out << __func__ << endl;
+{ 
   if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") {
     QMessageBox::warning(this,tr("Unsupported type"),tr("Sorry, saving a vector field is unsupported for the moment"));
     return;
@@ -2824,7 +2929,7 @@ void vvMainWindow::SaveAs()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveCurrentState()
-{ //out << __func__ << endl;
+{ 
   QString Extensions = "XML Files(*.xml)";
   QString fileName = QFileDialog::getSaveFileName(this,
     tr("Save Current Window State"),
@@ -2837,14 +2942,14 @@ void vvMainWindow::SaveCurrentState()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveCurrentStateAs(const std::string& stateFile)
-{ //out << __func__ << endl;
+{ 
   vvSaveState save_state;
   save_state.Run(this, stateFile);
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReadSavedState()
-{ //out << __func__ << endl;
+{ 
   QString Extensions = "XML Files(*.xml)";
   QString fileName = QFileDialog::getOpenFileName(this,
     tr("Load Window State"),
@@ -2857,7 +2962,7 @@ void vvMainWindow::ReadSavedState()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReadSavedStateFile(const std::string& stateFile)
-{ //out << __func__ << endl;
+{ 
   vvReadState read_state;
   read_state.Run(this, stateFile);
 }
@@ -2865,13 +2970,13 @@ void vvMainWindow::ReadSavedStateFile(const std::string& stateFile)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::LinkAllImages()
-{ //out << __func__ << endl;
+{ 
   linkPanel->linkAll();
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddLink(QString image1,QString image2,bool fromPanel)
-{ //out << __func__ << endl;
+{ 
   if (!fromPanel) {
     // delegate to linkPanel if call came from elsewhere...
     linkPanel->addLinkFromIds(image1, image2);
@@ -2905,7 +3010,7 @@ void vvMainWindow::AddLink(QString image1,QString image2,bool fromPanel)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::RemoveLink(QString image1,QString image2)
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (image1.toStdString() == mSlicerManagers[i]->GetId()) {
       mSlicerManagers[i]->RemoveLink(image2.toStdString());
@@ -2919,7 +3024,7 @@ void vvMainWindow::RemoveLink(QString image1,QString image2)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset)
-{ //out << __func__ << endl;
+{ 
   if(mSlicerManagers.size()==1)
     return;
 
@@ -2935,7 +3040,7 @@ void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, i
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (DataTree->topLevelItem(i)->data(column,Qt::CheckStateRole).toInt() > 1) {
       //i is the SlicerManager that is in charge of this slicer.
@@ -2972,7 +3077,7 @@ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NOHorizontalSliderMoved()
-{ //out << __func__ << endl;
+{ 
   // if (mCurrentTime == NOHorizontalSlider->value()) return;
   HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0);
   //  mCurrentTime = NOHorizontalSlider->value();
@@ -2982,7 +3087,7 @@ void vvMainWindow::NOHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NEHorizontalSliderMoved()
-{ //out << __func__ << endl;
+{ 
   // if (mCurrentTime == NEHorizontalSlider->value()) return;
   HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1);
   //  mCurrentTime = NEHorizontalSlider->value();
@@ -2992,7 +3097,7 @@ void vvMainWindow::NEHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SOHorizontalSliderMoved()
-{ //out << __func__ << endl;
+{ 
   // if (mCurrentTime == SOHorizontalSlider->value()) return;
   HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2);
   // mCurrentTime = SOHorizontalSlider->value();
@@ -3002,7 +3107,7 @@ void vvMainWindow::SOHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SEHorizontalSliderMoved()
-{ //out << __func__ << endl;
+{ 
   // if (mCurrentTime == SEHorizontalSlider->value()) return;
   HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3);
   // mCurrentTime = SEHorizontalSlider->value();
@@ -3011,7 +3116,7 @@ void vvMainWindow::SEHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NOVerticalSliderChanged()
-{ //out << __func__ << endl;
+{ 
   static int value=-1;
   if (value == NOVerticalSlider->value()) return;
   else value = NOVerticalSlider->value();
@@ -3037,7 +3142,7 @@ void vvMainWindow::NOVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NEVerticalSliderChanged()
-{ //out << __func__ << endl;
+{ 
   static int value=-1;
   if (value == NEVerticalSlider->value()) return;
   else value = NEVerticalSlider->value();
@@ -3059,7 +3164,7 @@ void vvMainWindow::NEVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SOVerticalSliderChanged()
-{ //out << __func__ << endl;
+{ 
   static int value=-1;
   if (value == SOVerticalSlider->value()) return;
   else value = SOVerticalSlider->value();
@@ -3082,7 +3187,7 @@ void vvMainWindow::SOVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SEVerticalSliderChanged()
-{ //out << __func__ << endl;
+{ 
   static int value=-1;
   if (value == SEVerticalSlider->value()) return;
   else value = SEVerticalSlider->value();
@@ -3104,7 +3209,7 @@ void vvMainWindow::SEVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSlice(int slicer, int slice)
-{ //out << __func__ << endl;
+{ 
   // DD("vvMainWindow::UpdateSlice");
   //   DD(slicer);
   //   DD(slice);
@@ -3130,7 +3235,7 @@ void vvMainWindow::UpdateSlice(int slicer, int slice)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateTSlice(int slicer, int slice, int code)
-{ //out << __func__ << endl;
+{ 
   //FusionSequence: the slider value should be updated for slicers which show the same sequence as requested
   bool doUpdate=false;
   if (code==-1) doUpdate=true;
@@ -3169,7 +3274,7 @@ void vvMainWindow::UpdateTSlice(int slicer, int slice, int code)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax)
-{ //out << __func__ << endl;
+{ 
   //int position = int((min+max)/2);
   int position = mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(slicer)->GetSlice();
   if (slicer == 0) {
@@ -3195,7 +3300,7 @@ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveNOScreenshot()
-{ //out << __func__ << endl;
+{ 
   SaveScreenshot(NOViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3203,7 +3308,7 @@ void vvMainWindow::SaveNOScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveNEScreenshot()
-{ //out << __func__ << endl;
+{ 
   SaveScreenshot(NEViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3211,7 +3316,7 @@ void vvMainWindow::SaveNEScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveSOScreenshot()
-{ //out << __func__ << endl;
+{ 
   SaveScreenshot(SOViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3219,7 +3324,7 @@ void vvMainWindow::SaveSOScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveSEScreenshot()
-{ //out << __func__ << endl;
+{ 
   SaveScreenshot(SEViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3227,8 +3332,12 @@ void vvMainWindow::SaveSEScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveScreenshotAllSlices()
-{ //out << __func__ << endl;
+{ 
+#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9
+  QVTKOpenGLNativeWidget *widget = NOViewWidget;
+#else
   QVTKWidget *widget = NOViewWidget;
+#endif
 
   int index = 0;// GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   vvSlicerManager * SM = mSlicerManagers[index];
@@ -3254,7 +3363,11 @@ void vvMainWindow::SaveScreenshotAllSlices()
     // Screenshot
     vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
     windowToImageFilter->SetInput(renderWindow);
+#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9
+    windowToImageFilter->SetScale(1);
+#else
     windowToImageFilter->SetMagnification(1);
+#endif
     windowToImageFilter->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel
     windowToImageFilter->Update();
 
@@ -3280,22 +3393,24 @@ void vvMainWindow::SaveScreenshotAllSlices()
 
 
 //------------------------------------------------------------------------------
+#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9
+void vvMainWindow::SaveScreenshot(QVTKOpenGLNativeWidget *widget)
+#else
 void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
-{ //out << __func__ << endl;
-  QString Extensions = "Images( *.png);;";
-  Extensions += "Images( *.jpg);;";
-  Extensions += "Images( *.bmp);;";
-  Extensions += "Images( *.tif);;";
-  Extensions += "Images( *.ppm)";
+#endif
+{ 
+  QString Extensions = "*.png;;";
+  Extensions += "*.jpg;;";
+  Extensions += "*.bmp;;";
+  Extensions += "*.tif;;";
+  Extensions += "*.ppm";
 #if defined(VTK_USE_FFMPEG_ENCODER) || defined(VTK_USE_VIDEO_FOR_WINDOWS)
-  Extensions += ";;Video( *.avi)";
+  Extensions += ";;*.avi Video";
 #endif
 #ifdef VTK_USE_MPEG2_ENCODER
-  Extensions += ";;Video( *.mpg)";
-#endif
-#ifdef CLITK_EXPERIMENTAL
-  Extensions += ";;Video( *.gif)";
+  Extensions += ";;*.mpg Video";
 #endif
+  Extensions += ";;*.gif Video";
 
   int smIndex=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   QString fileName = QFileDialog::getSaveFileName(this,
@@ -3306,6 +3421,12 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
   if (!fileName.isEmpty()) {
     vtkSmartPointer<vtkWindowToImageFilter> w2i = vtkSmartPointer<vtkWindowToImageFilter>::New();
     w2i->SetInput(widget->GetRenderWindow());
+#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9
+    w2i->SetScale(1);
+#else
+    w2i->SetMagnification(1);
+#endif
+    //w2i->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel
     w2i->Update();
     vtkImageData *image = w2i->GetOutput();
 
@@ -3338,7 +3459,6 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
 
     // Video
     vtkGenericMovieWriter *vidwriter = NULL;
-#if CLITK_EXPERIMENTAL == 1
     if (ext==".gif") {
       vvAnimatedGIFWriter *gif = vvAnimatedGIFWriter::New();
       vidwriter = gif;
@@ -3363,14 +3483,13 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
       msgBox.addButton(tr("No"), QMessageBox::RejectRole);
       gif->SetDither(msgBox.exec() == QMessageBox::AcceptRole);
     }
-#endif
 #ifdef VTK_USE_VIDEO_FOR_WINDOWS
     if (ext==".avi") {
       vtkAVIWriter *mpg = vtkAVIWriter::New();
       vidwriter = mpg;
       mpg->SetQuality(2);
       bool ok;
-      int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+      int fps = QInputDialog::getInt(this, tr("Number of frames per second"),
         tr("FPS:"), 5, 0, 1024, 1, &ok);
       if(!ok)
         fps = 5;
@@ -3383,7 +3502,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
       vidwriter = mpg;
       mpg->SetQuality(2);
       bool ok;
-      int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+      int fps = QInputDialog::getInt(this, tr("Number of frames per second"),
         tr("FPS:"), 5, 0, 1024, 1, &ok);
       if(!ok)
         fps = 5;
@@ -3433,7 +3552,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::GoToCursor()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   for (int column = 1; column < 5; column++) {
     if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) {
@@ -3450,7 +3569,7 @@ void vvMainWindow::GoToCursor()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::GoToLandmark()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   for (int column = 1; column < 5; column++) {
     if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) {
@@ -3467,7 +3586,7 @@ void vvMainWindow::GoToLandmark()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::PlayPause()
-{ //out << __func__ << endl;
+{ 
   if (playMode) {
     playMode = 0;
     playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_play.png")));
@@ -3492,7 +3611,7 @@ void vvMainWindow::PlayPause()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::PlayNext()
-{ //out << __func__ << endl;
+{ 
   if (playMode && !this->isHidden()) {
     int image_number=DataTree->topLevelItemCount();
     ///Only play one slicer per SM, and only if the SM is being displayed
@@ -3509,7 +3628,7 @@ void vvMainWindow::PlayNext()
 //------------------------------------------------------------------------------
 
 void vvMainWindow::ShowLastImage()
-{ //out << __func__ << endl;
+{ 
   if (mSlicerManagers.size() > 1) {
     QTreeWidgetItem * item=DataTree->topLevelItem(DataTree->topLevelItemCount()-1);
     CurrentImageChanged(mSlicerManagers.back()->GetId()); //select new image
@@ -3521,12 +3640,12 @@ void vvMainWindow::ShowLastImage()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateRenderWindows()
-{ //out << __func__ << endl;
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
-    mSlicerManagers[i]->GetSlicer(0)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(1)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(2)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(3)->UpdateLandmarks();
+      for (unsigned int j = 0; j < 4; ++j) {
+        mSlicerManagers[i]->GetSlicer(j)->RemoveLandmarks();
+        mSlicerManagers[i]->GetSlicer(j)->DisplayLandmarks();
+      }
   }
   if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render();
   if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render();
@@ -3537,7 +3656,7 @@ void vvMainWindow::UpdateRenderWindows()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SegmentationOnCurrentImage()
-{ //out << __func__ << endl;
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
   vvSegmentationDialog segmentation;
@@ -3547,7 +3666,7 @@ void vvMainWindow::SegmentationOnCurrentImage()
 //------------------------------------------------------------------------------
 
 void vvMainWindow::SurfaceViewerLaunch()
-{ //out << __func__ << endl;
+{ 
   vvSurfaceViewerDialog surfaceViewer;
   surfaceViewer.exec();
 }
@@ -3556,7 +3675,7 @@ void vvMainWindow::SurfaceViewerLaunch()
 
 //------------------------------------------------------------------------------
 int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename)
-{ //out << __func__ << endl;
+{ 
   int number=0;
   for(unsigned int l=0; l<mSlicerManagers.size(); l++) {
     vvSlicerManager * v = mSlicerManagers[l];
@@ -3572,7 +3691,7 @@ int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename)
 
 //------------------------------------------------------------------------------
 vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filename)
-{ //out << __func__ << endl;
+{ 
   // Change filename if another image exist with the same name
   int number = GetImageDuplicateFilenameNumber(filename);
 
@@ -3652,6 +3771,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
   connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
     this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
   connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+  connect(landmarksPanel,SIGNAL(UpdateLandmarkTransform()), mSlicerManagers.back(), SLOT(UpdateLandmark()));
 
 
 
@@ -3670,7 +3790,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateCurrentSlicer()
-{ //out << __func__ << endl;
+{ 
   int index = -1;
   if (DataTree->selectedItems().size() > 0) {
     index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);