X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=2b414926abb673fd0bfa10f8eae36f1f5b750646;hb=706d7e2dc69e12b3823cfae2f3be3f903e4d3c80;hp=6a81732949e5857d50b2acb260925c5a0a2f7b7f;hpb=75719c377dd8aa759f32dd277cfd7b2f914ebfa8;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 6a81732..2b41492 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -18,12 +18,14 @@ It is distributed under dual licence #include #include +#include #include #include #include "QTreePushButton.h" #include #include #include +#include // VV include #include "vvMainWindow.h" @@ -132,6 +134,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { setupUi(this); // this sets up the GUI + setAcceptDrops(true); // enable to drop into the window + setDicomClient(); //Qt::WindowFlags flags = windowFlags(); @@ -383,6 +387,9 @@ 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); @@ -816,6 +823,25 @@ 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 images; + for (int i=0; iurls().size(); ++i) { + images.push_back(mimeData->urls()[i].toLocalFile().toStdString()); + } + LoadImages(images, vvImageReader::IMAGE); +} +//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ @@ -957,6 +983,12 @@ void vvMainWindow::LoadImages(std::vector 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)), @@ -1416,6 +1448,29 @@ QString vvMainWindow::GetVectorIntAsString(std::vector vectorInt) } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::SlotFileChanged(const QString& pathname) +{ + std::vector items = GetItemFromPathname(pathname); + for (unsigned int i=0; i< items.size(); ++i) + ReloadImage(items[i], 0); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +std::vector vvMainWindow::GetItemFromPathname(const QString& pathname) +{ + std::vector 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)