X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=8107d7f5757d9db6f95df18f7df1cbd9c5b1c001;hb=c99626f17e07dbde440eb40a25683ce441a49a6e;hp=30f7da57693088207b345d4420971b291daf6858;hpb=6edda2a8b31b7345623e363dc27efd202aa59c9f;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 30f7da5..8107d7f 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -25,6 +25,7 @@ It is distributed under dual licence #include #include #include +#include // VV include #include "vvMainWindow.h" @@ -386,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); @@ -832,8 +836,8 @@ void vvMainWindow::dropEvent(QDropEvent *event) if (!mimeData->hasUrls()) return; std::vector images; - for (auto const & url : mimeData->urls()) { - images.push_back(url.toLocalFile().toStdString()); + for (int i=0; iurls().size(); ++i) { + images.push_back(mimeData->urls()[i].toLocalFile().toStdString()); } LoadImages(images, vvImageReader::IMAGE); } @@ -979,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)), @@ -1438,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) @@ -3300,7 +3333,7 @@ void vvMainWindow::SaveSEScreenshot() //------------------------------------------------------------------------------ void vvMainWindow::SaveScreenshotAllSlices() { -#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9 +#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9 QVTKOpenGLNativeWidget *widget = NOViewWidget; #else QVTKWidget *widget = NOViewWidget; @@ -3330,7 +3363,7 @@ void vvMainWindow::SaveScreenshotAllSlices() // Screenshot vtkSmartPointer windowToImageFilter = vtkSmartPointer::New(); windowToImageFilter->SetInput(renderWindow); -#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9 +#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9 windowToImageFilter->SetScale(1); #else windowToImageFilter->SetMagnification(1); @@ -3360,7 +3393,7 @@ void vvMainWindow::SaveScreenshotAllSlices() //------------------------------------------------------------------------------ -#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9 +#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9 void vvMainWindow::SaveScreenshot(QVTKOpenGLNativeWidget *widget) #else void vvMainWindow::SaveScreenshot(QVTKWidget *widget) @@ -3388,7 +3421,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) if (!fileName.isEmpty()) { vtkSmartPointer w2i = vtkSmartPointer::New(); w2i->SetInput(widget->GetRenderWindow()); -#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9 +#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9 w2i->SetScale(1); #else w2i->SetMagnification(1);