X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=153b461380e4566fb22418e90bd388141d84e887;hb=0e51b8dde15bfe59437d6f351c516f4137faf631;hp=001162797244beaf6cf5ce964bd2133424c070b5;hpb=067cf5847bb412d0067bcd52d7844377a0a43635;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 0011627..153b461 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -18,11 +18,13 @@ It is distributed under dual licence #include #include +#include #include #include #include "QTreePushButton.h" #include #include +#include // VV include #include "vvMainWindow.h" @@ -47,8 +49,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 @@ -75,9 +83,7 @@ It is distributed under dual licence #include #include #include -#ifdef CLITK_EXPERIMENTAL -# include -#endif +#include #ifdef VTK_USE_VIDEO_FOR_WINDOWS # include #endif @@ -124,9 +130,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 +156,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 +209,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 +236,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 +281,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 +299,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 +371,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 recent_files = GetRecentlyOpenedImages(); recentlyOpenedFilesMenu=NULL; @@ -375,35 +390,43 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() 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 +438,7 @@ void vvMainWindow::createRecentlyOpenedFilesMenu() //------------------------------------------------------------------------------ void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list &recent_files) -{ //out << __func__ << endl; +{ if(recentlyOpenedFilesMenu==NULL) { createRecentlyOpenedFilesMenu(); } else { @@ -432,7 +455,7 @@ void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list &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 +480,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 +488,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 +527,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 +550,7 @@ void vvMainWindow::OpenVTKContour() //------------------------------------------------------------------------------ void vvMainWindow::AddDCStructContour(int index, QString file) -{ //out << __func__ << endl; +{ vvMeshReader reader; reader.SetFilename(file.toStdString()); vvStructSelector selector; @@ -551,7 +574,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 +590,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 +607,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 +624,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 +647,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 +668,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 +727,7 @@ void vvMainWindow::MergeImages() //------------------------------------------------------------------------------ void vvMainWindow::SliceImages() -{ //out << __func__ << endl; +{ QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; @@ -718,7 +744,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 +766,7 @@ void vvMainWindow::MergeImagesWithTime() //------------------------------------------------------------------------------ void vvMainWindow::OpenDicom() -{ //out << __func__ << endl; +{ std::vector files; //std::cout << "dicomSeriesSelector " << std::endl; @@ -748,12 +774,29 @@ void vvMainWindow::OpenDicom() files = *(dicomSeriesSelector->GetFilenames()); LoadImages(files, vvImageReader::DICOM); } -} +} +#if CLITK_USE_PACS_CONNECTION +void vvMainWindow::ConnectPacs() +{ + std::vector 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 +811,7 @@ void vvMainWindow::OpenImages() } //------------------------------------------------------------------------------ void vvMainWindow::OpenRecentImage() -{ //out << __func__ << endl; +{ QAction * caller = qobject_cast(sender()); std::vector images; images.push_back(caller->text().toStdString()); @@ -776,11 +819,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 images; + for (auto const & url : mimeData->urls()) { + images.push_back(url.toLocalFile().toStdString()); + } + LoadImages(images, vvImageReader::IMAGE); +} +//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvMainWindow::OpenImageWithTime() -{ //out << __func__ << endl; +{ QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; @@ -799,7 +861,7 @@ void vvMainWindow::OpenImageWithTime() //------------------------------------------------------------------------------ void vvMainWindow::LoadImages(std::vector 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 +924,14 @@ void vvMainWindow::LoadImages(std::vector 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(); @@ -944,6 +1008,7 @@ void vvMainWindow::LoadImages(std::vector 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 +1039,7 @@ void vvMainWindow::LoadImages(std::vector 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 +1053,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 +1080,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 +1101,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 +1197,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 +1279,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 +1301,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 size1, size2; @@ -1327,21 +1392,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 +1414,7 @@ QString vvMainWindow::GetSizeInBytes(unsigned long size) //------------------------------------------------------------------------------ QString vvMainWindow::GetVectorDoubleAsString(std::vector vectorDouble) -{ //out << __func__ << endl; +{ QString result; for (unsigned int i= 0; i < vectorDouble.size(); i++) { if (i != 0) @@ -1362,7 +1427,7 @@ QString vvMainWindow::GetVectorDoubleAsString(std::vector vectorDouble) //------------------------------------------------------------------------------ QString vvMainWindow::GetVectorIntAsString(std::vector vectorInt) -{ //out << __func__ << endl; +{ QString result; for (unsigned int i= 0; i < vectorInt.size(); i++) { if (i != 0) @@ -1376,7 +1441,7 @@ QString vvMainWindow::GetVectorIntAsString(std::vector vectorInt) //------------------------------------------------------------------------------ //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 +1453,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 +1465,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 +1533,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 +1583,7 @@ void vvMainWindow::InitDisplay() //------------------------------------------------------------------------------ void vvMainWindow::DisplaySliders(int slicer, int window) -{ //out << __func__ << endl; +{ if(!mSlicerManagers[slicer]->GetSlicer(window)->GetRenderer()->GetDraw()) return; @@ -1545,7 +1612,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 +1730,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 +1770,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 +1801,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 +1856,7 @@ void vvMainWindow::WindowLevelChanged() //------------------------------------------------------------------------------ void vvMainWindow::WindowLevelEdited() -{ //out << __func__ << endl; +{ presetComboBox->setCurrentIndex(WL_USER); UpdateWindowLevel(); } @@ -1797,7 +1864,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 +1875,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 +1891,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 +1901,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 +1910,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 +1921,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 +1950,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 +1964,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 +1978,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 +1991,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 +2002,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 +2031,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 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 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 fileNames, vvImageReader::LoadedImageType type) -{ //out << __func__ << endl; +{ QString file(fileNames[0].c_str()); if (QFile::exists(file)) { @@ -2031,6 +2109,10 @@ void vvMainWindow::AddOverlayImage(int index, std::vector 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 +2168,7 @@ void vvMainWindow::AddOverlayImage(int index, std::vector fileNames //------------------------------------------------------------------------------ void vvMainWindow::AddROI(int index, QString file) -{ //out << __func__ << endl; +{ /* // Get slice manager @@ -2113,37 +2195,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 vecFileNames; - for (int i = 0; i < files.size(); i++) { - vecFileNames.push_back(files[i].toStdString()); - } - AddFusionImage(index,vecFileNames,vvImageReader::IMAGE); + std::vector 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 +2227,7 @@ void vvMainWindow::ResetTransformationToIdentity() //------------------------------------------------------------------------------ void vvMainWindow::AddFusionImage(int index, std::vector fileNames, vvImageReader::LoadedImageType type) -{ //out << __func__ << endl; +{ QString file(fileNames[0].c_str()); if (QFile::exists(file)) { @@ -2178,7 +2252,10 @@ void vvMainWindow::AddFusionImage(int index, std::vector 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 +2308,7 @@ void vvMainWindow::AddFusionImage(int index, std::vector fileNames, //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvMainWindow::AddLandmarks(int index, std::vector files) -{ //out << __func__ << endl; +{ if (!landmarksPanel->LoadFromFile(files)) QMessageBox::information(this,tr("Problem reading Landmarks !"),"File doesn't exist!"); @@ -2241,35 +2318,29 @@ void vvMainWindow::AddLandmarks(int index, std::vector 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 +2391,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 +2412,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 +2444,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 +2464,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 +2479,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 +2497,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 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; - //associate the secondary sequence (US) to the main one - AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME); + std::vector 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); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ 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 +2587,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 fileNames, vvImageReader::LoadedImageType type) -{ //out << __func__ << endl; +{ QString file(fileNames[0].c_str()); if (QFile::exists(file)) { @@ -2547,6 +2615,10 @@ void vvMainWindow::AddFusionSequence(int index, std::vector 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 +2712,7 @@ void vvMainWindow::AddFusionSequence(int index, std::vector 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 +2792,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 +2896,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 +2909,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 +2929,7 @@ void vvMainWindow::ReadSavedState() //------------------------------------------------------------------------------ void vvMainWindow::ReadSavedStateFile(const std::string& stateFile) -{ //out << __func__ << endl; +{ vvReadState read_state; read_state.Run(this, stateFile); } @@ -2865,13 +2937,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 +2977,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 +2991,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 +3007,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 +3044,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 +3054,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 +3064,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 +3074,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 +3083,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 +3109,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 +3131,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 +3154,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 +3176,7 @@ void vvMainWindow::SEVerticalSliderChanged() //------------------------------------------------------------------------------ void vvMainWindow::UpdateSlice(int slicer, int slice) -{ //out << __func__ << endl; +{ // DD("vvMainWindow::UpdateSlice"); // DD(slicer); // DD(slice); @@ -3130,7 +3202,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 +3241,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 +3267,7 @@ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int //------------------------------------------------------------------------------ void vvMainWindow::SaveNOScreenshot() -{ //out << __func__ << endl; +{ SaveScreenshot(NOViewWidget); } //------------------------------------------------------------------------------ @@ -3203,7 +3275,7 @@ void vvMainWindow::SaveNOScreenshot() //------------------------------------------------------------------------------ void vvMainWindow::SaveNEScreenshot() -{ //out << __func__ << endl; +{ SaveScreenshot(NEViewWidget); } //------------------------------------------------------------------------------ @@ -3211,7 +3283,7 @@ void vvMainWindow::SaveNEScreenshot() //------------------------------------------------------------------------------ void vvMainWindow::SaveSOScreenshot() -{ //out << __func__ << endl; +{ SaveScreenshot(SOViewWidget); } //------------------------------------------------------------------------------ @@ -3219,7 +3291,7 @@ void vvMainWindow::SaveSOScreenshot() //------------------------------------------------------------------------------ void vvMainWindow::SaveSEScreenshot() -{ //out << __func__ << endl; +{ SaveScreenshot(SEViewWidget); } //------------------------------------------------------------------------------ @@ -3227,7 +3299,7 @@ void vvMainWindow::SaveSEScreenshot() //------------------------------------------------------------------------------ void vvMainWindow::SaveScreenshotAllSlices() -{ //out << __func__ << endl; +{ QVTKWidget *widget = NOViewWidget; int index = 0;// GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -3254,7 +3326,11 @@ void vvMainWindow::SaveScreenshotAllSlices() // Screenshot vtkSmartPointer windowToImageFilter = vtkSmartPointer::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(); @@ -3271,7 +3347,7 @@ void vvMainWindow::SaveScreenshotAllSlices() #if VTK_MAJOR_VERSION <= 5 writer->SetInput(windowToImageFilter->GetOutput()); #else - writer->SetInputData(windowToImageFilter->GetOutput()); + writer->SetInputConnection(windowToImageFilter->GetOutputPort()); #endif writer->Write(); } @@ -3281,7 +3357,7 @@ void vvMainWindow::SaveScreenshotAllSlices() //------------------------------------------------------------------------------ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) -{ //out << __func__ << endl; +{ QString Extensions = "Images( *.png);;"; Extensions += "Images( *.jpg);;"; Extensions += "Images( *.bmp);;"; @@ -3293,9 +3369,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) #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, @@ -3306,6 +3380,12 @@ 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 + w2i->SetScale(1); +#else + w2i->SetMagnification(1); +#endif + w2i->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel w2i->Update(); vtkImageData *image = w2i->GetOutput(); @@ -3329,7 +3409,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) #if VTK_MAJOR_VERSION <= 5 imgwriter->SetInput(image); #else - imgwriter->SetInputData(image); + imgwriter->SetInputConnection(w2i->GetOutputPort()); #endif imgwriter->SetFileName(fileName.toStdString().c_str()); imgwriter->Write(); @@ -3338,7 +3418,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 +3442,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 +3461,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; @@ -3403,7 +3481,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) #if VTK_MAJOR_VERSION <= 5 vidwriter->SetInput(image); #else - vidwriter->SetInputData(image); + vidwriter->SetInputConnection(w2i->GetOutputPort()); #endif vidwriter->SetFileName(fileName.toStdString().c_str()); vidwriter->Start(); @@ -3416,7 +3494,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) #if VTK_MAJOR_VERSION <= 5 vidwriter->SetInput(w2i->GetOutput()); #else - vidwriter->SetInputData(w2i->GetOutput()); + vidwriter->SetInputConnection(w2i->GetOutputPort()); #endif vidwriter->Write(); } @@ -3433,7 +3511,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 +3528,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 +3545,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 +3570,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 +3587,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 +3599,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 +3615,7 @@ void vvMainWindow::UpdateRenderWindows() //------------------------------------------------------------------------------ void vvMainWindow::SegmentationOnCurrentImage() -{ //out << __func__ << endl; +{ int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); vvSegmentationDialog segmentation; @@ -3547,7 +3625,7 @@ void vvMainWindow::SegmentationOnCurrentImage() //------------------------------------------------------------------------------ void vvMainWindow::SurfaceViewerLaunch() -{ //out << __func__ << endl; +{ vvSurfaceViewerDialog surfaceViewer; surfaceViewer.exec(); } @@ -3556,7 +3634,7 @@ void vvMainWindow::SurfaceViewerLaunch() //------------------------------------------------------------------------------ int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename) -{ //out << __func__ << endl; +{ int number=0; for(unsigned int l=0; lselectedItems().size() > 0) { index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);