#include <QUrl>
#include <QSettings>
#include <QShortcut>
+#include <QFileSystemWatcher>
// VV include
#include "vvMainWindow.h"
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)),
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+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)
void UpdateRenderWindows();
void UpdateMemoryUsage();
void show();
+ void SlotFileChanged(const QString& pathname);
protected:
QString GetSizeInBytes(unsigned long size);
QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
QString GetVectorIntAsString(std::vector<int> vectorInt);
+ std::vector<QTreeWidgetItem*> GetItemFromPathname(const QString& pathname);
int GetSlicerIndexFromItem(QTreeWidgetItem* item); //this actually returns the SlicerManager index TODO: rename it to GetSlicerManagerIndexFromItem
QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9