#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"
#include "vvMeshReader.h"
#include "vvSaveState.h"
#include "vvReadState.h"
-#ifdef CLITK_USE_PACS_CONNECTION
+#if CLITK_USE_PACS_CONNECTION
#include "vvQPacsConnection.h"
#endif
#include "clitkConfiguration.h"
#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
{
setupUi(this); // this sets up the GUI
+ setAcceptDrops(true); // enable to drop into the window
+
setDicomClient();
//Qt::WindowFlags flags = windowFlags();
documentation = new vvDocumentation();
help_dialog = new vvHelpDialog();
dicomSeriesSelector = new vvDicomSeriesSelector();
-#ifdef CLITK_USE_PACS_CONNECTION
+#if CLITK_USE_PACS_CONNECTION
PacsConnection = new vvQPacsConnection();
#endif
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()));
- #ifdef CLITK_USE_PACS_CONNECTION
-connect(actionConnect_Pacs,SIGNAL(triggered()),this,SLOT(ConnectPacs()));
+#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()));
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);
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()));
{
// 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");
}
//------------------------------------------------------------------------------
LoadImages(files, vvImageReader::DICOM);
}
}
-#ifdef CLITK_USE_PACS_CONNECTION
+#if CLITK_USE_PACS_CONNECTION
void vvMainWindow::ConnectPacs()
{
std::vector<std::string> files;
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);
+}
+//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// 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) {
QApplication::restoreOverrideCursor();
QString error = "Cannot open file \n";
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)),
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++;
}
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 + ")";
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;
}
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+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 vvMainWindow::SaveScreenshotAllSlices()
{
+#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9
+ QVTKOpenGLNativeWidget *widget = NOViewWidget;
+#else
QVTKWidget *widget = NOViewWidget;
+#endif
int index = 0;// GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
vvSlicerManager * SM = mSlicerManagers[index];
// Screenshot
vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
windowToImageFilter->SetInput(renderWindow);
+#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9
+ windowToImageFilter->SetScale(1);
+#else
windowToImageFilter->SetMagnification(1);
+#endif
windowToImageFilter->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel
windowToImageFilter->Update();
//------------------------------------------------------------------------------
+#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9
+void vvMainWindow::SaveScreenshot(QVTKOpenGLNativeWidget *widget)
+#else
void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
+#endif
{
QString Extensions = "Images( *.png);;";
Extensions += "Images( *.jpg);;";
#ifdef VTK_USE_MPEG2_ENCODER
Extensions += ";;Video( *.mpg)";
#endif
-#ifdef CLITK_EXPERIMENTAL
Extensions += ";;Video( *.gif)";
-#endif
int smIndex=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
QString fileName = QFileDialog::getSaveFileName(this,
if (!fileName.isEmpty()) {
vtkSmartPointer<vtkWindowToImageFilter> w2i = vtkSmartPointer<vtkWindowToImageFilter>::New();
w2i->SetInput(widget->GetRenderWindow());
+#if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 1) || 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();
// Video
vtkGenericMovieWriter *vidwriter = NULL;
-#if CLITK_EXPERIMENTAL == 1
if (ext==".gif") {
vvAnimatedGIFWriter *gif = vvAnimatedGIFWriter::New();
vidwriter = gif;
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();
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()));