From 407e3715e0917fcbb1556342f6ac9ac2ead0e476 Mon Sep 17 00:00:00 2001 From: rblanc Date: Tue, 8 Jan 2013 18:57:23 +0100 Subject: [PATCH] fixed the TSliders issues for FusionSequence, and prepared ground for temporal synchronization, which still needs to be implemented... --- vv/qt_ui/vvOverlayPanel.ui | 4 +- vv/vvMainWindow.cxx | 1184 ++++++++++++++++++------------------ vv/vvMainWindow.h | 2 +- vv/vvOverlayPanel.cxx | 26 +- vv/vvOverlayPanel.h | 90 +-- vv/vvSlicer.h | 2 + vv/vvSlicerManager.cxx | 16 +- vv/vvSlicerManager.h | 2 +- 8 files changed, 682 insertions(+), 644 deletions(-) diff --git a/vv/qt_ui/vvOverlayPanel.ui b/vv/qt_ui/vvOverlayPanel.ui index 8143521..0e5a01f 100644 --- a/vv/qt_ui/vvOverlayPanel.ui +++ b/vv/qt_ui/vvOverlayPanel.ui @@ -7,7 +7,7 @@ 0 0 444 - 815 + 612 @@ -91,7 +91,7 @@ p, li { white-space: pre-wrap; } true - true + false diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index cde6d50..56aa5b1 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -1,19 +1,19 @@ /*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv +Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr +Authors belong to: +- University of LYON http://www.universite-lyon.fr/ +- Léon Bérard cancer center http://www.centreleonberard.fr +- CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the copyright notices for more information. - It is distributed under dual licence +It is distributed under dual licence - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +- BSD See included LICENSE.txt file +- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ===========================================================================**/ #include @@ -108,14 +108,14 @@ /*Data Tree values - 0,Qt::UserRole full filename - 1,Qt::CheckStateRole checkbutton UL View - 1,Qt::UserRole overlay, fusion or vector - 2,Qt::CheckStateRole checkbutton UR View - 3,Qt::CheckStateRole checkbutton DL View - 4,Qt::CheckStateRole checkbutton DR View - 5,0 short filename - 5,Qt::UserRole mSlicerManager id*/ +0,Qt::UserRole full filename +1,Qt::CheckStateRole checkbutton UL View +1,Qt::UserRole overlay, fusion or vector +2,Qt::CheckStateRole checkbutton UR View +3,Qt::CheckStateRole checkbutton DL View +4,Qt::CheckStateRole checkbutton DR View +5,0 short filename +5,Qt::UserRole mSlicerManager id*/ //------------------------------------------------------------------------------ vvMainWindow::vvMainWindow():vvMainWindowBase() @@ -137,34 +137,34 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() this->setContextMenuPolicy(Qt::CustomContextMenu); contextActions.resize(0); QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/fileopen.png")), - tr("O&pen new Image")); + 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(); QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/exit.png")), - tr("Close Current Image")); + tr("Close Current Image")); connect(actionClose_Image,SIGNAL(triggered()),this,SLOT(CloseImage())); contextActions.push_back(actionClose_Image); QAction* actionReload_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")), - tr("Reload Current Image")); + tr("Reload Current Image")); connect(actionReload_image,SIGNAL(triggered()),this,SLOT(ReloadImage())); contextActions.push_back(actionReload_image); QAction* actionSave_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")), - tr("Save Current Image")); + tr("Save Current Image")); connect(actionSave_image,SIGNAL(triggered()),this,SLOT(SaveAs())); contextActions.push_back(actionSave_image); QAction* actionSave_state = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")), - tr("Save Current State")); + tr("Save Current State")); connect(actionSave_state,SIGNAL(triggered()),this,SLOT(SaveCurrentState())); contextActions.push_back(actionSave_state); QAction* actionRead_state = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")), - tr("Read Saved State")); + tr("Read Saved State")); connect(actionRead_state,SIGNAL(triggered()),this,SLOT(ReadSavedState())); contextActions.push_back(actionRead_state); @@ -187,7 +187,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() contextMenu.addSeparator(); QAction* actionResetMatrix = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/identity.png")), - tr("Reset transformation to identity")); + tr("Reset transformation to identity")); connect(actionResetMatrix, SIGNAL(triggered()), this,SLOT(ResetTransformationToIdentity())); // TRIAL DS @@ -197,9 +197,9 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() // m->setObjectName(QString::fromUtf8("TOTOTO")); contextMenu.addMenu(m); QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")), - tr("BIDON")); + tr("BIDON")); QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")), - tr("BIDON2")); + tr("BIDON2")); m->addAction(a); m->addAction(b); connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage())); @@ -313,7 +313,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(DataTree,SIGNAL(itemSelectionChanged()),this,SLOT(ImageInfoChanged())); connect(DataTree,SIGNAL(itemClicked(QTreeWidgetItem*, int)),this, - SLOT(DisplayChanged(QTreeWidgetItem*, int))); + SLOT(DisplayChanged(QTreeWidgetItem*, int))); connect(viewButton,SIGNAL(clicked()),this, SLOT(ChangeViewMode()) ); connect(windowSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited())); @@ -330,13 +330,13 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString))); connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double))); connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int,int,double,double)), - this,SLOT(SetOverlayProperty(int,int,double,double))); + this,SLOT(SetOverlayProperty(int,int,double,double))); connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,int,double,double, bool)), - this,SLOT(SetFusionProperty(int,int,int,double,double, bool))); + this,SLOT(SetFusionProperty(int,int,int,double,double, bool))); connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows())); connect(overlayPanel,SIGNAL(FusionSequencePropertyUpdated(int, bool, unsigned int, bool)), - this,SLOT(SetFusionSequenceProperty(int, bool,unsigned int, bool))); + this,SLOT(SetFusionSequenceProperty(int, bool,unsigned int, bool))); playMode = 0;//pause @@ -428,7 +428,7 @@ void vvMainWindow::ComputeMidPosition() bool ok; int index=GetSlicerIndexFromItem(DataTree->selectedItems()[0]); int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\ - mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok); + mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok); if (ok) { vvMidPosition midp; midp.slicer_manager = mSlicerManagers[index]; @@ -468,7 +468,7 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro cButton->setToolTip(tr("close image")); cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(CloseImage(QTreeWidgetItem*, int))); + this,SLOT(CloseImage(QTreeWidgetItem*, int))); QTreePushButton* rButton = new QTreePushButton; rButton->setItem(item); @@ -520,25 +520,25 @@ void vvMainWindow::OpenVTKContour() //------------------------------------------------------------------------------ void vvMainWindow::AddDCStructContour(int index, QString file) { - vvMeshReader reader; - reader.SetFilename(file.toStdString()); - vvStructSelector selector; - selector.SetStructures(reader.GetROINames()); - if (!mSlicerManagers[index]->GetVF().IsNull()) - selector.EnablePropagationCheckBox(); - if (selector.exec()) { - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - reader.SetSelectedItems(selector.getSelectedItems()); - reader.SetImage(mSlicerManagers[index]->GetImage()); - if (selector.PropagationEnabled()) - reader.SetPropagationVF(mSlicerManagers[index]->GetVF()); - reader.Update(); - std::vector contours=reader.GetOutput(); - for (std::vector::iterator i=contours.begin(); - i!=contours.end(); i++) - AddContour(index,*i,selector.PropagationEnabled()); - QApplication::restoreOverrideCursor(); - } + vvMeshReader reader; + reader.SetFilename(file.toStdString()); + vvStructSelector selector; + selector.SetStructures(reader.GetROINames()); + if (!mSlicerManagers[index]->GetVF().IsNull()) + selector.EnablePropagationCheckBox(); + if (selector.exec()) { + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + reader.SetSelectedItems(selector.getSelectedItems()); + reader.SetImage(mSlicerManagers[index]->GetImage()); + if (selector.PropagationEnabled()) + reader.SetPropagationVF(mSlicerManagers[index]->GetVF()); + reader.Update(); + std::vector contours=reader.GetOutput(); + for (std::vector::iterator i=contours.begin(); + i!=contours.end(); i++) + AddContour(index,*i,selector.PropagationEnabled()); + QApplication::restoreOverrideCursor(); + } } //------------------------------------------------------------------------------ @@ -581,7 +581,7 @@ void vvMainWindow::WarpImage() if (!mSlicerManagers[index]->GetVF().IsNull()) { bool ok; int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\ - mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok); + mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok); if (ok) { WarpImage(mSlicerManagers[index],ref); } @@ -598,7 +598,7 @@ void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phas QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QFileInfo info(selected_slicer->GetFileName().c_str()); vvImageWarp warp(selected_slicer->GetImage(),selected_slicer->GetVF(), - reference_phase,this); + reference_phase,this); if (warp.ComputeWarpedImage()) { AddImage(warp.GetWarpedImage(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_warped.mhd"); AddImage(warp.GetDiffImage() ,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_diff.mhd"); @@ -650,7 +650,7 @@ void vvMainWindow::MergeImages() for (int i = 0; i < files.size(); i++) { itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO( - files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode); + files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode); reader->SetFileName(files[i].toStdString().c_str()); reader->ReadImageInformation(); if (reader) { @@ -672,14 +672,14 @@ void vvMainWindow::MergeImages() currentSpacing[j] = reader->GetSpacing(j); currentSize[j] = reader->GetDimensions(j); } else if (currentDim != reader->GetNumberOfDimensions() - || currentSpacing[j] != reader->GetSpacing(j) - || currentSize[j] != (int)reader->GetDimensions(j) - || currentOrigin[j] != reader->GetOrigin(j)) { - QString error = "Cannot read file (too different from others "; - error += files[i].toStdString().c_str(); - QMessageBox::information(this,tr("Reading problem"),error); - IsOk = false; - break; + || currentSpacing[j] != reader->GetSpacing(j) + || currentSize[j] != (int)reader->GetDimensions(j) + || currentOrigin[j] != reader->GetOrigin(j)) { + QString error = "Cannot read file (too different from others "; + error += files[i].toStdString().c_str(); + QMessageBox::information(this,tr("Reading problem"),error); + IsOk = false; + break; } } if (IsOk) @@ -844,7 +844,7 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa progress.SetProgress(i,fileSize); qApp->processEvents(); - for (unsigned int j = 0; j < nSlices[i]; j++) { + for (unsigned int j = 0; j < nSlices[i]; j++) { //read the image and put it in mSlicerManagers vvSlicerManager* imageManager = new vvSlicerManager(4); qApp->processEvents(); @@ -860,7 +860,7 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa SetImageSucceed = imageManager->SetImages(files,filetype, number); } - if (!SetImageSucceed) { + if (!SetImageSucceed) { QApplication::restoreOverrideCursor(); QString error = "Cannot open file \n"; error += imageManager->GetLastError().c_str(); @@ -878,7 +878,7 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa item->setToolTip(COLUMN_IMAGE_NAME, imageManager->GetListOfAbsoluteFilePathInOneString("image").c_str()); qApp->processEvents(); - //Create the buttons for reload and close + //Create the buttons for reload and close qApp->processEvents(); QTreePushButton* cButton = new QTreePushButton; cButton->setItem(item); @@ -886,7 +886,7 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa cButton->setToolTip(tr("close image")); cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(CloseImage(QTreeWidgetItem*, int))); + this,SLOT(CloseImage(QTreeWidgetItem*, int))); QTreePushButton* rButton = new QTreePushButton; rButton->setItem(item); @@ -894,7 +894,7 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa rButton->setToolTip(tr("reload image")); rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(ReloadImage(QTreeWidgetItem*, int))); + this,SLOT(ReloadImage(QTreeWidgetItem*, int))); DataTree->addTopLevelItem(item); DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton); @@ -907,37 +907,37 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa linkPanel->addImage(imageManager->GetFileName(), id.toStdString()); - connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)), - this,SLOT(CurrentImageChanged(std::string))); + connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)), + this,SLOT(CurrentImageChanged(std::string))); connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)), - this, SLOT(CurrentPickedImageChanged(std::string))); + this, SLOT(CurrentPickedImageChanged(std::string))); connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)), - this,SLOT(MousePositionChanged(int,double, double, double, double, double, double, double))); + this,SLOT(MousePositionChanged(int,double, double, double, double, double, double, double))); connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)), - this, SLOT(VectorChanged(int,double,double,double, double))); + this, SLOT(VectorChanged(int,double,double,double, double))); connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)), - this, SLOT(OverlayChanged(int,double,double))); + this, SLOT(OverlayChanged(int,double,double))); connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)), - this, SLOT(FusionChanged(int,double))); + this, SLOT(FusionChanged(int,double))); connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()), - this,SLOT(WindowLevelChanged())); + this,SLOT(WindowLevelChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)), - this,SLOT(UpdateSlice(int,int))); - connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), - this,SLOT(UpdateTSlice(int, int))); - connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), - this,SLOT(ImageInfoChanged())); + this,SLOT(UpdateSlice(int,int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int, int)), + this,SLOT(UpdateTSlice(int, int, int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int, int)), + this,SLOT(ImageInfoChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)), - this,SLOT(UpdateSliceRange(int,int,int,int,int))); + this,SLOT(UpdateSliceRange(int,int,int,int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)), - this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); + this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*)), - this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*))); + this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*))); connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)), - this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); + this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); - InitSlicers(); + InitSlicers(); numberofsuccesulreads++; } } @@ -1045,14 +1045,14 @@ void vvMainWindow::ImageInfoChanged() colorMapComboBox->setEnabled(1); for (int i = 0; i < DataTree->topLevelItem(index)->childCount(); i++) { if (DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "overlay" || - DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusion" || - DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusionSequence") { - colorMapComboBox->setEnabled(0); - break; + DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusion" || + DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusionSequence") { + colorMapComboBox->setEnabled(0); + break; } } - std::vector origin; + std::vector origin; std::vector inputSpacing; std::vector inputSize; std::vector sizeMM; @@ -1062,9 +1062,9 @@ void vvMainWindow::ImageInfoChanged() QString inputSizeInBytes; QString image = DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString(); - int nframes = mSlicerManagers[index]->GetSlicer(0)->GetTMax(); + int nframes = mSlicerManagers[index]->GetSlicer(0)->GetTMax(); - if (nframes > 1 || playMode == 1) { + if (nframes > 1 || playMode == 1) { playButton->setEnabled(1); frameRateLabel->setEnabled(1); frameRateSpinBox->setEnabled(1); @@ -1077,7 +1077,7 @@ void vvMainWindow::ImageInfoChanged() //read image header int NPixel = 1; - int tSlice = 0; + int tSlice = 0; vvImage::Pointer imageSelected; if (DataTree->topLevelItem(index) == DataTree->selectedItems()[0]) { imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage(); @@ -1089,23 +1089,23 @@ void vvMainWindow::ImageInfoChanged() imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetOverlay(); tSlice = mSlicerManagers[index]->GetSlicer(0)->GetOverlayTSlice(); } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusion") { - imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion(); - tSlice = mSlicerManagers[index]->GetSlicer(0)->GetFusionTSlice(); + imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion(); + tSlice = mSlicerManagers[index]->GetSlicer(0)->GetFusionTSlice(); } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusionSequence") { - imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion(); - tSlice = mSlicerManagers[index]->GetSlicer(0)->GetFusionTSlice(); - } + imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion(); + tSlice = mSlicerManagers[index]->GetSlicer(0)->GetFusionTSlice(); + } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "contour") { - imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage(); - tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice(); + imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage(); + tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice(); } else { - imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage(); - tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice(); + imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage(); + tSlice = mSlicerManagers[index]->GetSlicer(0)->GetTSlice(); } - dimension = imageSelected->GetNumberOfDimensions(); + dimension = imageSelected->GetNumberOfDimensions(); origin.resize(dimension); inputSpacing.resize(dimension); inputSize.resize(dimension); @@ -1131,11 +1131,11 @@ void vvMainWindow::ImageInfoChanged() infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing)); infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); - transformation = imageSelected->GetTransform()[tSlice]->GetMatrix(); + transformation = imageSelected->GetTransform()[tSlice]->GetMatrix(); infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation)); - landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), - mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size()); + landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), + mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size()); landmarksPanel->SetCurrentPath(mInputPathName.toStdString()); landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str()); @@ -1147,7 +1147,7 @@ void vvMainWindow::ImageInfoChanged() } } - infoPanel->setFileName(image); + infoPanel->setFileName(image); infoPanel->setDimension(dim); infoPanel->setSizePixel(GetVectorIntAsString(inputSize)); infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM)); @@ -1156,7 +1156,7 @@ void vvMainWindow::ImageInfoChanged() infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), - mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size()); + mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size()); landmarksPanel->SetCurrentPath(mInputPathName.toStdString()); landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str()); @@ -1167,15 +1167,15 @@ void vvMainWindow::ImageInfoChanged() break; } } - WindowLevelChanged(); + WindowLevelChanged(); - slicingPresetComboBox->setCurrentIndex(mSlicerManagers[index]->GetSlicingPreset()); + slicingPresetComboBox->setCurrentIndex(mSlicerManagers[index]->GetSlicingPreset()); - if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { + if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str()); overlayPanel->getVFProperty(mSlicerManagers[index]->GetSlicer(0)->GetVFSubSampling(), - mSlicerManagers[index]->GetSlicer(0)->GetVFScale(), - mSlicerManagers[index]->GetSlicer(0)->GetVFLog()); + mSlicerManagers[index]->GetSlicer(0)->GetVFScale(), + mSlicerManagers[index]->GetSlicer(0)->GetVFLog()); } else { overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str()); overlayPanel->getVFProperty(-1,-1,-1); @@ -1185,8 +1185,8 @@ void vvMainWindow::ImageInfoChanged() } else { overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str()); } - - if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { + + if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); } else { overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); @@ -1268,7 +1268,7 @@ void vvMainWindow::ChangeViewMode() sizes[3].cols[0] = 1; sizes[3].cols[1] = 2; sizes[3].cols[2] = 3; - + int slicer = mSlicerManagers[mCurrentPickedImageIndex]->GetSelectedSlicer(); if (viewMode == 1) { if (slicer >= 0) { @@ -1298,12 +1298,12 @@ void vvMainWindow::ChangeViewMode() ** the associated Slicer to redraw crosses. */ for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { -// if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1) - mSlicerManagers[i]->GetSlicer(0)->Render(); - mSlicerManagers[i]->GetSlicer(1)->Render(); -// if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1) - mSlicerManagers[i]->GetSlicer(2)->Render(); - mSlicerManagers[i]->GetSlicer(3)->Render(); + // if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1) + mSlicerManagers[i]->GetSlicer(0)->Render(); + mSlicerManagers[i]->GetSlicer(1)->Render(); + // if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1) + mSlicerManagers[i]->GetSlicer(2)->Render(); + mSlicerManagers[i]->GetSlicer(3)->Render(); } } //------------------------------------------------------------------------------ @@ -1508,13 +1508,13 @@ void vvMainWindow::InitDisplay() for (int i = 0; i < DataTree->topLevelItemCount(); i++) { mSlicerManagers[i]->SetInteractorStyleNavigator(j,style); - //select the image only if previous are not selected + //select the image only if previous are not selected if (DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->UpdateSlicer(j,1); - AlreadySelected = true; + AlreadySelected = true; } else if (i == DataTree->topLevelItemCount()-1 && !AlreadySelected) { if (DataTree->selectedItems().size() == 0) - DataTree->topLevelItem(i)->setSelected(1); //RB: crash here when loading an image... + DataTree->topLevelItem(i)->setSelected(1); DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,2); mSlicerManagers[i]->UpdateSlicer(j,1); DisplaySliders(i,j); @@ -1567,7 +1567,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) QString warning = "Do you really want to close the overlay : "; warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString(); QMessageBox msgBox(QMessageBox::Warning, tr("Close Overlay"), - warning, 0, this); + warning, 0, this); msgBox.addButton(tr("Close"), QMessageBox::AcceptRole); msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); if (msgBox.exec() == QMessageBox::AcceptRole) { @@ -1575,20 +1575,20 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) int overlay_index=0; for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++) { if (DataTree->topLevelItem(index)->\ - child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type) + child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type) overlay_index++; if (DataTree->topLevelItem(index)->child(child) == item) break; } - if (overlay_type=="fusionSequence") { - //removing the overlay sequence in a fusion sequence visualization mode - //TODO: remove the synchronization (transform matrices, etc...) + if (overlay_type=="fusionSequence") { + //removing the overlay sequence in a fusion sequence visualization mode + //TODO: remove the synchronization (transform matrices, etc...) - //=> unlink and untie the slicer managers - mSlicerManagers[index]->SetFusionSequenceInvolvmentCode(-1); - mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->SetFusionSequenceInvolvmentCode(-1); - RemoveLink(mSlicerManagers[index]->GetId().c_str(), mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->GetId().c_str()); + //=> unlink and untie the slicer managers + RemoveLink(mSlicerManagers[index]->GetId().c_str(), mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->GetId().c_str()); + mSlicerManagers[index]->SetFusionSequenceInvolvmentCode(-1); + mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->SetFusionSequenceInvolvmentCode(-1); - } + } mSlicerManagers[index]->RemoveActor(overlay_type, overlay_index-1); mSlicerManagers[index]->SetColorMap(0); DataTree->topLevelItem(index)->takeChild(DataTree->topLevelItem(index)->indexOfChild(item)); @@ -1599,7 +1599,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString(); warning += "\nThis is the last image, you're about to close vv !!!"; QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"), - warning, 0, this); + warning, 0, this); msgBox.addButton(tr("Close vv"), QMessageBox::AcceptRole); msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); if (msgBox.exec() == QMessageBox::AcceptRole) { @@ -1609,7 +1609,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) QString warning = "Do you really want to close the image : "; warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString(); QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"), - warning, 0, this); + warning, 0, this); msgBox.addButton(tr("Close"), QMessageBox::AcceptRole); msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); if (msgBox.exec() == QMessageBox::AcceptRole) { @@ -1625,16 +1625,16 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) linkPanel->removeImage(index); mSlicerManagers[index]->RemoveActors(); - //if the slicer manager was involved in a fusion sequence visualization... - if ( item->data(1,Qt::UserRole).toString().toStdString() == "fusionSequence" ) { - //TODO - //make sure both SlicerManager exit the FusionSequence visualization mode - //disable the temporal and spatial sync? make sure we reset the spatial transforms to their initial states... - mSlicerManagers[index]->SetFusionSequenceInvolvmentCode(-1); - mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->SetFusionSequenceInvolvmentCode(-1); - } + //if the slicer manager was involved in a fusion sequence visualization... + if ( item->data(1,Qt::UserRole).toString().toStdString() == "fusionSequence" ) { + //TODO + //make sure both SlicerManager exit the FusionSequence visualization mode + //disable the temporal and spatial sync? make sure we reset the spatial transforms to their initial states... + mSlicerManagers[index]->SetFusionSequenceInvolvmentCode(-1); + mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->SetFusionSequenceInvolvmentCode(-1); + } - //remove the slicer manager + //remove the slicer manager delete mSlicerManagers[index]; mSlicerManagers.erase(Manageriter); @@ -1715,6 +1715,9 @@ void vvMainWindow::FusionChanged(int visibility, double value) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ +//called when AddOverlayImage, AddFusionSequence +//or when UpdateWindowLevel() is called ; when slicerManager emits WindowLevelChanged +//when ImageInfoChanged() is called void vvMainWindow::WindowLevelChanged() { // Base image @@ -1728,43 +1731,43 @@ void vvMainWindow::WindowLevelChanged() // Overlay image if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor(), - mSlicerManagers[index]->GetLinkOverlayWindowLevel(), - mSlicerManagers[index]->GetOverlayColorWindow(), - mSlicerManagers[index]->GetOverlayColorLevel()); + mSlicerManagers[index]->GetLinkOverlayWindowLevel(), + mSlicerManagers[index]->GetOverlayColorWindow(), + mSlicerManagers[index]->GetOverlayColorLevel()); else overlayPanel->getOverlayProperty(-1,0,0.,0.); // Fusion & SequenceFusion image if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { - overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(), - mSlicerManagers[index]->GetFusionThresholdOpacity(), - mSlicerManagers[index]->GetFusionColorMap(), - mSlicerManagers[index]->GetFusionWindow(), - mSlicerManagers[index]->GetFusionLevel()); - if (mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) { - overlayPanel->getFusionSequenceProperty(mSlicerManagers[index]->GetFusionSequenceFrameIndex(), - mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(), - mSlicerManagers[index]->GetFusionSequenceNbFrames(), - mSlicerManagers[index]->GetFusionSequenceTemporalSyncFlag()); - } + overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(), + mSlicerManagers[index]->GetFusionThresholdOpacity(), + mSlicerManagers[index]->GetFusionColorMap(), + mSlicerManagers[index]->GetFusionWindow(), + mSlicerManagers[index]->GetFusionLevel()); + if (mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) { + overlayPanel->getFusionSequenceProperty(mSlicerManagers[index]->GetFusionSequenceFrameIndex(), + mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(), + mSlicerManagers[index]->GetFusionSequenceNbFrames(), + mSlicerManagers[index]->GetFusionSequenceTemporalSyncFlag()); + } } else if ( mSlicerManagers[index]->IsSecondarySequenceOfFusionSequence() ) { - //if the image is involved in a fusion sequence, preserve the overlay panel! - int ind = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager(); - overlayPanel->getFusionProperty(mSlicerManagers[ind]->GetFusionOpacity(), - mSlicerManagers[ind]->GetFusionThresholdOpacity(), - mSlicerManagers[ind]->GetFusionColorMap(), - mSlicerManagers[ind]->GetFusionWindow(), - mSlicerManagers[ind]->GetFusionLevel()); - overlayPanel->getFusionSequenceProperty(mSlicerManagers[ind]->GetFusionSequenceFrameIndex(), - mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(), - mSlicerManagers[ind]->GetFusionSequenceNbFrames(), - mSlicerManagers[ind]->GetFusionSequenceTemporalSyncFlag()); + //if the image is involved in a fusion sequence, preserve the overlay panel! + int ind = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager(); + overlayPanel->getFusionProperty(mSlicerManagers[ind]->GetFusionOpacity(), + mSlicerManagers[ind]->GetFusionThresholdOpacity(), + mSlicerManagers[ind]->GetFusionColorMap(), + mSlicerManagers[ind]->GetFusionWindow(), + mSlicerManagers[ind]->GetFusionLevel()); + overlayPanel->getFusionSequenceProperty(mSlicerManagers[ind]->GetFusionSequenceFrameIndex(), + mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(), + mSlicerManagers[ind]->GetFusionSequenceNbFrames(), + mSlicerManagers[ind]->GetFusionSequenceTemporalSyncFlag()); } else { - overlayPanel->getFusionProperty(-1, -1, -1, -1, -1); - overlayPanel->getFusionSequenceProperty(-1, false, 0, false); + overlayPanel->getFusionProperty(-1, -1, -1, -1, -1); + overlayPanel->getFusionSequenceProperty(-1, false, 0, false); } } //------------------------------------------------------------------------------ @@ -1882,13 +1885,13 @@ void vvMainWindow::ApplyLevelToSetOfImages(double level, unsigned int indexMin, //------------------------------------------------------------------------------ void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps) { - for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { - if (mSlicerManagers[i]->GetId() == id) { - mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps); - mSlicerManagers[i]->UpdateViews(0,slicer); - break; - } - } + for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { + if (mSlicerManagers[i]->GetId() == id) { + mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps); + mSlicerManagers[i]->UpdateViews(0,slicer); + break; + } + } } //------------------------------------------------------------------------------ @@ -1918,7 +1921,7 @@ void vvMainWindow::ShowContextMenu(QPoint point) contextActions[1]->setEnabled(1); contextActions[2]->setEnabled( DataTree->itemWidget(DataTree->selectedItems()[0], - COLUMN_RELOAD_IMAGE)->isEnabled()); + COLUMN_RELOAD_IMAGE)->isEnabled()); contextActions[3]->setEnabled(1); contextActions[5]->setEnabled(1); contextActions[6]->setEnabled(1); @@ -1961,17 +1964,17 @@ void vvMainWindow::SelectOverlayImage() return; } - QString Extensions = EXTENSIONS; - Extensions += ";;All Files (*)"; - QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image"),mInputPathName,Extensions); - if (files.isEmpty()) - 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); + std::vector vecFileNames; + for (int i = 0; i < files.size(); i++) { + vecFileNames.push_back(files[i].toStdString()); + } + AddOverlayImage(index,vecFileNames,vvImageReader::IMAGE); } //------------------------------------------------------------------------------ @@ -1983,7 +1986,7 @@ void vvMainWindow::AddOverlayImage(int index, std::vector fileNames { mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str(); itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO( - file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); + file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); reader->SetFileName(fileNames[0].c_str()); reader->ReadImageInformation(); std::string component = reader->GetComponentTypeAsString(reader->GetComponentType()); @@ -2015,7 +2018,7 @@ void vvMainWindow::AddOverlayImage(int index, std::vector fileNames cButton->setToolTip(tr("close image")); cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(CloseImage(QTreeWidgetItem*, int))); + this,SLOT(CloseImage(QTreeWidgetItem*, int))); QTreePushButton* rButton = new QTreePushButton; rButton->setItem(item); @@ -2023,7 +2026,7 @@ void vvMainWindow::AddOverlayImage(int index, std::vector fileNames rButton->setToolTip(tr("reload image")); rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(ReloadImage(QTreeWidgetItem*, int))); + this,SLOT(ReloadImage(QTreeWidgetItem*, int))); DataTree->topLevelItem(index)->setExpanded(1); DataTree->topLevelItem(index)->addChild(item); @@ -2067,12 +2070,12 @@ void vvMainWindow::AddROI(int index, QString file) mReader->SetInputFilename(filename.toStdString()); mReader->Update(IMAGE); if (mReader->GetLastError().size() != 0) { - std::cerr << "Error while reading " << filename.toStdString() << std::endl; - QString error = "Cannot open file \n"; - error += mReader->GetLastError().c_str(); - QMessageBox::information(this,tr("Reading problem"),error); - delete mReader; - return; + std::cerr << "Error while reading " << filename.toStdString() << std::endl; + QString error = "Cannot open file \n"; + error += mReader->GetLastError().c_str(); + QMessageBox::information(this,tr("Reading problem"),error); + delete mReader; + return; } vvImage::Pointer roi = mReader->GetOutput(); @@ -2090,19 +2093,19 @@ void vvMainWindow::SelectFusionImage() //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; + (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; } - QString Extensions = EXTENSIONS; - Extensions += ";;All Files (*)"; - QString file = QFileDialog::getOpenFileName(this,tr("Load Fusion image"),mInputPathName,Extensions); - if (!file.isEmpty()) - AddFusionImage(index,file); + QString Extensions = EXTENSIONS; + Extensions += ";;All Files (*)"; + QString file = QFileDialog::getOpenFileName(this,tr("Load Fusion image"),mInputPathName,Extensions); + if (!file.isEmpty()) + AddFusionImage(index,file); } //------------------------------------------------------------------------------ @@ -2123,7 +2126,7 @@ void vvMainWindow::AddFusionImage(int index, QString file) { mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str(); itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO( - file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); + file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); reader->SetFileName(file.toStdString().c_str()); reader->ReadImageInformation(); std::string component = reader->GetComponentTypeAsString(reader->GetComponentType()); @@ -2134,50 +2137,50 @@ void vvMainWindow::AddFusionImage(int index, QString file) std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str(); if (mSlicerManagers[index]->SetFusion(file.toStdString(), - reader->GetNumberOfDimensions(), component)) { - //create an item in the tree with good settings - QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setData(0,Qt::UserRole,file.toStdString().c_str()); - item->setData(1,Qt::UserRole,tr("fusion")); - QFileInfo fileinfo(filename.c_str()); //Do not show the path - item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); - item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusion").c_str()); - qApp->processEvents(); - - for (int j = 1; j <= 4; j++) { - item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole)); - } + reader->GetNumberOfDimensions(), component)) { + //create an item in the tree with good settings + QTreeWidgetItem *item = new QTreeWidgetItem(); + item->setData(0,Qt::UserRole,file.toStdString().c_str()); + item->setData(1,Qt::UserRole,tr("fusion")); + QFileInfo fileinfo(filename.c_str()); //Do not show the path + item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); + item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusion").c_str()); + qApp->processEvents(); + + for (int j = 1; j <= 4; j++) { + item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole)); + } - //Create the buttons for reload and close - qApp->processEvents(); - QTreePushButton* cButton = new QTreePushButton; - cButton->setItem(item); - cButton->setColumn(COLUMN_CLOSE_IMAGE); - cButton->setToolTip(tr("close image")); - cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); - connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), + //Create the buttons for reload and close + qApp->processEvents(); + QTreePushButton* cButton = new QTreePushButton; + cButton->setItem(item); + cButton->setColumn(COLUMN_CLOSE_IMAGE); + cButton->setToolTip(tr("close image")); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); + connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(CloseImage(QTreeWidgetItem*, int))); - QTreePushButton* rButton = new QTreePushButton; - rButton->setItem(item); - rButton->setColumn(COLUMN_RELOAD_IMAGE); - rButton->setToolTip(tr("reload image")); - rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); - connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), + QTreePushButton* rButton = new QTreePushButton; + rButton->setItem(item); + rButton->setColumn(COLUMN_RELOAD_IMAGE); + rButton->setToolTip(tr("reload image")); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); + connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(ReloadImage(QTreeWidgetItem*, int))); - DataTree->topLevelItem(index)->setExpanded(1); - DataTree->topLevelItem(index)->addChild(item); - DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton); - DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton); - - //set the id of the image - QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString(); - item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str()); - UpdateTree(); - qApp->processEvents(); - ImageInfoChanged(); - QApplication::restoreOverrideCursor(); + DataTree->topLevelItem(index)->setExpanded(1); + DataTree->topLevelItem(index)->addChild(item); + DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton); + DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton); + + //set the id of the image + QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString(); + item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str()); + UpdateTree(); + qApp->processEvents(); + ImageInfoChanged(); + QApplication::restoreOverrideCursor(); } else { QApplication::restoreOverrideCursor(); QString error = "Cannot import the new image.\n"; @@ -2209,16 +2212,16 @@ void vvMainWindow::OpenField() return; } - QString Extensions = "Images ( *.mhd)"; - 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)"; + 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); } //------------------------------------------------------------------------------ @@ -2247,7 +2250,7 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) cButton->setToolTip(tr("close vector field")); cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(CloseImage(QTreeWidgetItem*, int))); + this,SLOT(CloseImage(QTreeWidgetItem*, int))); QTreePushButton* rButton = new QTreePushButton; rButton->setItem(item); @@ -2256,7 +2259,7 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) rButton->setEnabled(from_disk); rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(ReloadImage(QTreeWidgetItem*, int))); + this,SLOT(ReloadImage(QTreeWidgetItem*, int))); DataTree->topLevelItem(index)->setExpanded(1); DataTree->topLevelItem(index)->addChild(item); @@ -2370,7 +2373,7 @@ void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap mSlicerManagers[index]->SetFusionLevel(level); mSlicerManagers[index]->SetFusionShowLegend(showLegend); mSlicerManagers[index]->SetColorMap(0); - mSlicerManagers[index]->Render(); + mSlicerManagers[index]->Render(); } } //------------------------------------------------------------------------------ @@ -2379,32 +2382,32 @@ void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap //------------------------------------------------------------------------------ void vvMainWindow::SelectFusionSequence() { - //get the index of the slicer manager of the main sequence (CT) + //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; + (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; + QString Extensions = EXTENSIONS; + Extensions += ";;All Files (*)"; + QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),mInputPathName,Extensions); + if (files.isEmpty()) + return; - 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); + 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); } //------------------------------------------------------------------------------ @@ -2412,44 +2415,44 @@ void vvMainWindow::SelectFusionSequence() //------------------------------------------------------------------------------ void vvMainWindow::SelectFusionSequenceTemporalSignal() { - //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]); - //in case the other sequence got selected, make sure we select the primary sequence - if ( (!mSlicerManagers[index]->GetSlicer(0)->GetFusion()) && mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()>=0 ) { - index = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager(); - } - - //open a dialog box to find a file - QString Extensions = EXTENSIONS; - Extensions += ";;All Files (*)"; - QString fileName = QFileDialog::getOpenFileName(this,tr("Load respiratory signal for fused sequence"),mInputPathName,Extensions); - if (fileName.isNull()) - return; - - //read it as a vector of values - std::vector signal; - //...TODO, look for itk functions that can do that... vnl in the worst case. - signal.push_back(1);signal.push_back(2); + //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]); + //in case the other sequence got selected, make sure we select the primary sequence + if ( (!mSlicerManagers[index]->GetSlicer(0)->GetFusion()) && mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()>=0 ) { + index = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager(); + } - //TODO: instead: if the loaded signal is longer, just crop it... - //this allows loading only the first few frames when testing. - //->maybe raise a message that this behavior may be unsafe... + //open a dialog box to find a file + QString Extensions = EXTENSIONS; + Extensions += ";;All Files (*)"; + QString fileName = QFileDialog::getOpenFileName(this,tr("Load respiratory signal for fused sequence"),mInputPathName,Extensions); + if (fileName.isNull()) + return; - //if compatible with the fused image sequence (number of images = number of entries), enable the temporalSync - if ( signal.size() >= mSlicerManagers[index]->GetFusionSequenceNbFrames()) { - //for convenience, associate this sequence to both the current slicer manager, and to the linked one - mSlicerManagers[index]->SetFusionSequenceTemporalSignal(signal); - mSlicerManagers[ mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager() ]->SetFusionSequenceTemporalSignal(signal); - overlayPanel->enableFusionSequenceTemporalSync(); - QMessageBox::information(this,tr("Adding signal"),"would add the signal from file: "+ fileName); - } - else {//else, send a message to signal the failure... - QString error = "The provided signal doesn't have the same duration as the sequence\n"; - error += "Ignoring file: " + fileName; - QMessageBox::information(this,tr("Problem adding signal!"),error); - return; - } + //read it as a vector of values + std::vector signal; + //...TODO, look for itk functions that can do that... vnl in the worst case. + signal.push_back(1);signal.push_back(2); + + //TODO: instead: if the loaded signal is longer, just crop it... + //this allows loading only the first few frames when testing. + //->maybe raise a message that this behavior may be unsafe... + + //if compatible with the fused image sequence (number of images = number of entries), enable the temporalSync + if ( signal.size() >= mSlicerManagers[index]->GetFusionSequenceNbFrames()) { + //for convenience, associate this sequence to both the current slicer manager, and to the linked one + mSlicerManagers[index]->SetFusionSequenceTemporalSignal(signal); + mSlicerManagers[ mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager() ]->SetFusionSequenceTemporalSignal(signal); + overlayPanel->enableFusionSequenceTemporalSync(); + QMessageBox::information(this,tr("Adding signal"),"would add the signal from file: "+ fileName); + } + else {//else, send a message to signal the failure... + QString error = "The provided signal doesn't have the same duration as the sequence\n"; + error += "Ignoring file: " + fileName; + QMessageBox::information(this,tr("Problem adding signal!"),error); + return; + } } //------------------------------------------------------------------------------ @@ -2460,106 +2463,110 @@ void vvMainWindow::SelectFusionSequenceTemporalSignal() { //the files behind fileNames points to the data for the secondary sequence void vvMainWindow::AddFusionSequence(int index, std::vector fileNames, vvImageReader::LoadedImageType type) { - QString file(fileNames[0].c_str()); - if (QFile::exists(file)) - { - mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str(); - itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO( - file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); - reader->SetFileName(fileNames[0].c_str()); - reader->ReadImageInformation(); - std::string component = reader->GetComponentTypeAsString(reader->GetComponentType()); - int dimension = reader->GetNumberOfDimensions(); - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - vvProgressDialog progress("Opening " + file.toStdString()); - qApp->processEvents(); - - std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str(); - - if (mSlicerManagers[index]->SetFusionSequence(fileNames,dimension, component,type)) { - //create an item in the tree with good settings - QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setData(0,Qt::UserRole,file.toStdString().c_str()); - item->setData(1,Qt::UserRole,tr("fusionSequence")); - - QFileInfo fileinfo(file); //Do not show the path - item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); - item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusionSequence").c_str()); - qApp->processEvents(); - for (int j = 1; j <= 4; j++) { - item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole)); - } - - //Create the buttons for reload and close - qApp->processEvents(); - QTreePushButton* cButton = new QTreePushButton; - cButton->setItem(item); - cButton->setColumn(COLUMN_CLOSE_IMAGE); - cButton->setToolTip(tr("close image")); - cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); - connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(CloseImage(QTreeWidgetItem*, int))); - - QTreePushButton* rButton = new QTreePushButton; - rButton->setItem(item); - rButton->setColumn(COLUMN_RELOAD_IMAGE); - rButton->setToolTip(tr("reload image")); - rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); - connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(ReloadImage(QTreeWidgetItem*, int))); - - DataTree->topLevelItem(index)->setExpanded(1); - DataTree->topLevelItem(index)->addChild(item); - DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton); - DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton); - - //store the original transform matrix - int indexParent = GetSlicerIndexFromItem( DataTree->topLevelItem(index) ); - mSlicerManagers[indexParent]->SetFusionSequenceMainTransformMatrix( mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform()[0]->GetMatrix() ); - - //set the id of the image - QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString(); - item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str()); - UpdateTree(); - qApp->processEvents(); - - ImageInfoChanged(); - - QApplication::restoreOverrideCursor(); - // Update the display to update, e.g., the sliders - for(int i=0; i<4; i++) - DisplaySliders(index, i); - - - //This loads the secondary sequence (US) as an independent sequence - LoadImages(fileNames, type); - //reset the transforms to identiy - for (unsigned i=0 ; iGetImage()->GetTransform().size() ; i++) { - mSlicerManagers.back()->GetImage()->GetTransform()[i]->Identity(); - mSlicerManagers.back()->GetImage()->GetTransform()[i]->Update(); - } - - //automatically link both images... - AddLink(mSlicerManagers[indexParent]->GetId().c_str(), mSlicerManagers.back()->GetId().c_str(), false); - - //tie the main and secondary sequences by raising flags and informing each another of their respective SlicerManager indices - mSlicerManagers[indexParent]->SetFusionSequenceIndexOfLinkedManager(mSlicerManagers.size()-1); - mSlicerManagers[indexParent]->SetFusionSequenceInvolvmentCode(0); //main sequence - mSlicerManagers.back()->SetFusionSequenceIndexOfLinkedManager(indexParent); - mSlicerManagers.back()->SetFusionSequenceInvolvmentCode(1); //secondary sequence - - } else { - QApplication::restoreOverrideCursor(); - QString error = "Cannot import the new image.\n"; - error += mSlicerManagers[index]->GetLastError().c_str(); - QMessageBox::information(this,tr("Problem reading image !"),error); - } - WindowLevelChanged(); - } - else { - QMessageBox::information(this,tr("Problem reading fusion sequence !"),"File doesn't exist!"); - return; - } + QString file(fileNames[0].c_str()); + if (QFile::exists(file)) + { + mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str(); + itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO( + file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); + reader->SetFileName(fileNames[0].c_str()); + reader->ReadImageInformation(); + std::string component = reader->GetComponentTypeAsString(reader->GetComponentType()); + int dimension = reader->GetNumberOfDimensions(); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + vvProgressDialog progress("Opening " + file.toStdString()); + qApp->processEvents(); + + std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str(); + + if (mSlicerManagers[index]->SetFusionSequence(fileNames,dimension, component,type)) { + //create an item in the tree with good settings + QTreeWidgetItem *item = new QTreeWidgetItem(); + item->setData(0,Qt::UserRole,file.toStdString().c_str()); + item->setData(1,Qt::UserRole,tr("fusionSequence")); + + QFileInfo fileinfo(file); //Do not show the path + item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); + item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusionSequence").c_str()); + qApp->processEvents(); + for (int j = 1; j <= 4; j++) { + item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole)); + } + + //Create the buttons for reload and close + qApp->processEvents(); + QTreePushButton* cButton = new QTreePushButton; + cButton->setItem(item); + cButton->setColumn(COLUMN_CLOSE_IMAGE); + cButton->setToolTip(tr("close image")); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); + connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), + this,SLOT(CloseImage(QTreeWidgetItem*, int))); + + QTreePushButton* rButton = new QTreePushButton; + rButton->setItem(item); + rButton->setColumn(COLUMN_RELOAD_IMAGE); + rButton->setToolTip(tr("reload image")); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); + connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), + this,SLOT(ReloadImage(QTreeWidgetItem*, int))); + + DataTree->topLevelItem(index)->setExpanded(1); + DataTree->topLevelItem(index)->addChild(item); + DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton); + DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton); + + //store the original transform matrix + int indexParent = GetSlicerIndexFromItem( DataTree->topLevelItem(index) ); + mSlicerManagers[indexParent]->SetFusionSequenceMainTransformMatrix( mSlicerManagers[indexParent]->GetSlicer(0)->GetImage()->GetTransform()[0]->GetMatrix() ); + + //set the id of the image + QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString(); + item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str()); + UpdateTree(); + qApp->processEvents(); + + //ImageInfoChanged(); + + QApplication::restoreOverrideCursor(); + // Update the display to update, e.g., the sliders + for(int i=0; i<4; i++) + DisplaySliders(index, i); + + + //This loads the secondary sequence (US) as an independent sequence + LoadImages(fileNames, type); + //reset the transforms to identiy + for (unsigned i=0 ; iGetImage()->GetTransform().size() ; i++) { + mSlicerManagers.back()->GetImage()->GetTransform()[i]->Identity(); + mSlicerManagers.back()->GetImage()->GetTransform()[i]->Update(); + } + + //automatically link both images... + AddLink(mSlicerManagers[indexParent]->GetId().c_str(), mSlicerManagers.back()->GetId().c_str(), false); + + //tie the main and secondary sequences by raising flags and informing each another of their respective SlicerManager indices + mSlicerManagers[indexParent]->SetFusionSequenceIndexOfLinkedManager(mSlicerManagers.size()-1); + mSlicerManagers[indexParent]->SetFusionSequenceInvolvmentCode(0); //main sequence + mSlicerManagers.back()->SetFusionSequenceIndexOfLinkedManager(indexParent); + mSlicerManagers.back()->SetFusionSequenceInvolvmentCode(1); //secondary sequence + for (unsigned i=0 ; i<4 ; i++) { + mSlicerManagers.back()->GetSlicer(i)->SetFusionSequenceCode(1); //flag the slicers of the secondary sequence + } + + } else { + QApplication::restoreOverrideCursor(); + QString error = "Cannot import the new image.\n"; + error += mSlicerManagers[index]->GetLastError().c_str(); + QMessageBox::information(this,tr("Problem reading image !"),error); + } + //WindowLevelChanged(); + ImageInfoChanged(); //this internally calls WindowLevelChanged... + } + else { + QMessageBox::information(this,tr("Problem reading fusion sequence !"),"File doesn't exist!"); + return; + } } //------------------------------------------------------------------------------ @@ -2569,47 +2576,44 @@ 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) { - int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - //check if the focus moved to the linked sequence, and in this case, select the master sequence instead - if (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) { - index = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager(); - } + if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return; + //check if the focus moved to the linked sequence, and in this case, select the master sequence instead + if (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) { + index = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager(); + } int secondaryIndex = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager(); + if (secondaryIndex==-1) return; //this should never happen if ( (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) || (!mSlicerManagers[secondaryIndex]->IsSecondarySequenceOfFusionSequence()) ) {return;} //this should never happen, raise an exception? if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { - int indexParent = GetSlicerIndexFromItem( DataTree->topLevelItem(index) ); -//check whether this really makes sense to look at 'parentIndex'... -std::cout<<"index = "<GetFileName().c_str(), - Extensions); + tr("Save As"), + mSlicerManagers[index]->GetFileName().c_str(), + Extensions); if (!fileName.isEmpty()) { std::string fileformat = itksys::SystemTools::GetFilenameLastExtension(fileName.toStdString()); if (OutputListeFormat.contains( - fileformat.c_str())) { - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - std::string action = "Saving"; - vvProgressDialog progress("Saving "+fileName.toStdString()); - qApp->processEvents(); - vvImageWriter::Pointer writer = vvImageWriter::New(); - writer->SetOutputFileName(fileName.toStdString()); - writer->SetInput(mSlicerManagers[index]->GetImage()); - - // Check on transform and prompt user - writer->SetSaveTransform(false); - bool bId = true; - for(int i=0; i<4; i++) - for(int j=0; j<4; j++) { - // TODO SR and BP: check on the list of transforms and not the first only - double elt = mSlicerManagers[index]->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j); - if(i==j && elt!=1.) - bId = false; - if(i!=j && elt!=0.) - bId = false; - } - if( !bId ) { - QString warning = "The image has an associated linear transform. Do you want to save it along?"; - QMessageBox msgBox(QMessageBox::Warning, tr("Save transform"), warning, 0, this); - msgBox.addButton(tr("Yes"), QMessageBox::AcceptRole); - msgBox.addButton(tr("No"), QMessageBox::RejectRole); - if (msgBox.exec() == QMessageBox::AcceptRole) - writer->SetSaveTransform(true); - } + fileformat.c_str())) { + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + std::string action = "Saving"; + vvProgressDialog progress("Saving "+fileName.toStdString()); + qApp->processEvents(); + vvImageWriter::Pointer writer = vvImageWriter::New(); + writer->SetOutputFileName(fileName.toStdString()); + writer->SetInput(mSlicerManagers[index]->GetImage()); + + // Check on transform and prompt user + writer->SetSaveTransform(false); + bool bId = true; + for(int i=0; i<4; i++) + for(int j=0; j<4; j++) { + // TODO SR and BP: check on the list of transforms and not the first only + double elt = mSlicerManagers[index]->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j); + if(i==j && elt!=1.) + bId = false; + if(i!=j && elt!=0.) + bId = false; + } + if( !bId ) { + QString warning = "The image has an associated linear transform. Do you want to save it along?"; + QMessageBox msgBox(QMessageBox::Warning, tr("Save transform"), warning, 0, this); + msgBox.addButton(tr("Yes"), QMessageBox::AcceptRole); + msgBox.addButton(tr("No"), QMessageBox::RejectRole); + if (msgBox.exec() == QMessageBox::AcceptRole) + writer->SetSaveTransform(true); + } - writer->Update(); - QApplication::restoreOverrideCursor(); - if (writer->GetLastError().size()) { - QString error = "Saving did not succeed\n"; - error += writer->GetLastError().c_str(); - QMessageBox::information(this,tr("Saving Problem"),error); - SaveAs(); - } + writer->Update(); + QApplication::restoreOverrideCursor(); + if (writer->GetLastError().size()) { + QString error = "Saving did not succeed\n"; + error += writer->GetLastError().c_str(); + QMessageBox::information(this,tr("Saving Problem"),error); + SaveAs(); + } } else { QString error = fileformat.c_str(); if (error.isEmpty()) @@ -2766,10 +2770,10 @@ void vvMainWindow::SaveCurrentState() { QString Extensions = "XML Files(*.xml)"; QString fileName = QFileDialog::getSaveFileName(this, - tr("Save Current Window State"), - "", - Extensions); - + tr("Save Current Window State"), + "", + Extensions); + SaveCurrentStateAs(fileName.toStdString()); } //------------------------------------------------------------------------------ @@ -2786,10 +2790,10 @@ void vvMainWindow::ReadSavedState() { QString Extensions = "XML Files(*.xml)"; QString fileName = QFileDialog::getOpenFileName(this, - tr("Load Window State"), - "", - Extensions); - + tr("Load Window State"), + "", + Extensions); + ReadSavedStateFile(fileName.toStdString()); } //------------------------------------------------------------------------------ @@ -2805,7 +2809,7 @@ void vvMainWindow::ReadSavedStateFile(const std::string& stateFile) //------------------------------------------------------------------------------ void vvMainWindow::LinkAllImages() { - linkPanel->linkAll(); + linkPanel->linkAll(); } //------------------------------------------------------------------------------ @@ -2816,7 +2820,7 @@ void vvMainWindow::AddLink(QString image1,QString image2,bool fromPanel) linkPanel->addLinkFromIds(image1, image2); return; } - + unsigned int sm1 = 0; unsigned int sm2 = 0; @@ -2875,29 +2879,35 @@ void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, i //------------------------------------------------------------------------------ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index) { - for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { - if (DataTree->topLevelItem(i)->data(column,Qt::CheckStateRole).toInt() > 1) { - - if (mSlicerManagers[i]->IsInvolvedInFusionSequence()) { - //if the slicerManager is involved in a fusionSequence as the secondary sequence, then update the slider position in the overlay panel and everything accordingly - if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) { overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true); } - else { //if this is the primary sequence that has been modified - if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) { - //TODO: if temporal sync is active - //estimate a corresponding time index for the secondary (US) sequence, and update it accordingly. - int estimatedValue=0; - overlayPanel->updateFusionSequenceSliderValueFromWindow(estimatedValue, true); - } - } - } + 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. + if (mSlicerManagers[i]->IsInvolvedInFusionSequence()) { + //if the slicerManager is involved in a fusionSequence as the secondary sequence, then update the slider position in the overlay panel and everything accordingly + if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) { + overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true); + } + else { //if this is the primary sequence that has been modified + if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) { + //WARNING: for some obscure reason, there are problems when accessing mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex(); + + //int estimatedValue=mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex(); + int estimatedValue=0; + //TODO: if temporal sync is active + //estimate a corresponding time index for the secondary (US) sequence, and update it accordingly. + //estimatedValue = ... + overlayPanel->updateFusionSequenceSliderValueFromWindow(estimatedValue, true); + } + } + } - for (int j = 0; j < 4; j++) { - mSlicerManagers[i]->SetTSliceInSlicer(value,j); - } - mSlicerManagers[i]->GetSlicer(slicer_index)->Render(); - break; - } - } + for (int j = 0; j < 4; j++) { + mSlicerManagers[i]->SetTSliceInSlicer(value,j); + } + mSlicerManagers[i]->GetSlicer(slicer_index)->Render(); + break; + } + } } //------------------------------------------------------------------------------ @@ -2907,7 +2917,7 @@ void vvMainWindow::NOHorizontalSliderMoved() { // if (mCurrentTime == NOHorizontalSlider->value()) return; HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0); -// mCurrentTime = NOHorizontalSlider->value(); + // mCurrentTime = NOHorizontalSlider->value(); } //------------------------------------------------------------------------------ @@ -2917,7 +2927,7 @@ void vvMainWindow::NEHorizontalSliderMoved() { // if (mCurrentTime == NEHorizontalSlider->value()) return; HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1); -// mCurrentTime = NEHorizontalSlider->value(); + // mCurrentTime = NEHorizontalSlider->value(); } //------------------------------------------------------------------------------ @@ -3038,8 +3048,8 @@ void vvMainWindow::SEVerticalSliderChanged() void vvMainWindow::UpdateSlice(int slicer, int slice) { // DD("vvMainWindow::UpdateSlice"); -// DD(slicer); -// DD(slice); + // DD(slicer); + // DD(slice); if (slicer == 0) { // if (slice != NOVerticalSlider->value()) NOVerticalSlider->setValue(slice); @@ -3061,19 +3071,37 @@ void vvMainWindow::UpdateSlice(int slicer, int slice) //------------------------------------------------------------------------------ -void vvMainWindow::UpdateTSlice(int slicer, int slice) +void vvMainWindow::UpdateTSlice(int slicer, int slice, int code) { + //FusionSequence: the slider value should be updated for slicers which show the same sequence as requested + bool doUpdate=false; + if (code==-1) doUpdate=true; + else { + for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { + if (DataTree->topLevelItem(i)->data(slicer+1,Qt::CheckStateRole).toInt() > 1) { + //i is the active SlicerManager + if (mSlicerManagers[i]->GetFusionSequenceInvolvmentCode()==code) doUpdate=true; + break; + } + } + } + if (!doUpdate) return; + switch (slicer) { case 0: + if (NOHorizontalSlider->value()==slice) return; NOHorizontalSlider->setValue(slice); break; case 1: + if (NEHorizontalSlider->value()==slice) return; NEHorizontalSlider->setValue(slice); break; case 2: + if (SOHorizontalSlider->value()==slice) return; SOHorizontalSlider->setValue(slice); break; case 3: + if (SEHorizontalSlider->value()==slice) return; SEHorizontalSlider->setValue(slice); break; } @@ -3154,9 +3182,9 @@ void vvMainWindow::SaveScreenshotAllSlices() // Select filename base QString filename = QFileDialog::getSaveFileName(this, - tr("Save As (filename will be completed by slice number)"), - itksys::SystemTools::GetFilenamePath(mSlicerManagers[index]->GetFileName()).c_str(), - "Images( *.png);;Images( *.jpg)"); + tr("Save As (filename will be completed by slice number)"), + itksys::SystemTools::GetFilenamePath(mSlicerManagers[index]->GetFileName()).c_str(), + "Images( *.png);;Images( *.jpg)"); // Loop on slices for(int i=0; iSetMagnification(1); windowToImageFilter->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel windowToImageFilter->Update(); - + vtkSmartPointer writer = vtkSmartPointer::New(); std::string fn = itksys::SystemTools::GetFilenameWithoutLastExtension(filename.toStdString()); std::string num = clitk::toString(i); @@ -3209,9 +3237,9 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) int smIndex=GetSlicerIndexFromItem(DataTree->selectedItems()[0]); QString fileName = QFileDialog::getSaveFileName(this, - tr("Save As"), - itksys::SystemTools::GetFilenamePath(mSlicerManagers[smIndex]->GetFileName()).c_str(), - Extensions); + tr("Save As"), + itksys::SystemTools::GetFilenamePath(mSlicerManagers[smIndex]->GetFileName()).c_str(), + Extensions); if (!fileName.isEmpty()) { vtkSmartPointer w2i = vtkSmartPointer::New(); @@ -3252,13 +3280,13 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) // FPS bool ok; int fps = QInputDialog::getInteger(this, tr("Number of frames per second"), - tr("FPS:"), 5, 0, 1000, 1, &ok); + tr("FPS:"), 5, 0, 1000, 1, &ok); if(ok) gif->SetRate(fps); // Loops int loops = QInputDialog::getInteger(this, tr("Loops"), - tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok); + tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok); if(ok) gif->SetLoops(loops); @@ -3277,7 +3305,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) mpg->SetQuality(2); bool ok; int fps = QInputDialog::getInteger(this, tr("Number of frames per second"), - tr("FPS:"), 5, 0, 1024, 1, &ok); + tr("FPS:"), 5, 0, 1024, 1, &ok); if(!ok) fps = 5; mpg->SetRate(fps); @@ -3290,7 +3318,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) mpg->SetQuality(2); bool ok; int fps = QInputDialog::getInteger(this, tr("Number of frames per second"), - tr("FPS:"), 5, 0, 1024, 1, &ok); + tr("FPS:"), 5, 0, 1024, 1, &ok); if(!ok) fps = 5; mpg->SetRate(fps); @@ -3362,11 +3390,11 @@ void vvMainWindow::PlayPause() has_temporal=true; break; } - if (has_temporal) { - playMode = 1; - playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_pause.png"))); - QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext())); - } + if (has_temporal) { + playMode = 1; + playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_pause.png"))); + QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext())); + } } } //------------------------------------------------------------------------------ @@ -3380,11 +3408,11 @@ void vvMainWindow::PlayNext() for (int i=0; iGetSlicer(0)->GetTMax() > 0 && - DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 0) { - mSlicerManagers[i]->SetNextTSlice(j); - break; + DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 0) { + mSlicerManagers[i]->SetNextTSlice(j); + break; } - QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext())); + QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext())); } } //------------------------------------------------------------------------------ @@ -3441,8 +3469,8 @@ int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename) for(unsigned int l=0; lGetBaseFileName() == - vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename))) { - number = std::max(number, v->GetBaseFileNameNumber()+1); + vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename))) { + number = std::max(number, v->GetBaseFileNameNumber()+1); } } return number; @@ -3479,7 +3507,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen cButton->setColumn(COLUMN_CLOSE_IMAGE); cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(CloseImage(QTreeWidgetItem*, int))); + this,SLOT(CloseImage(QTreeWidgetItem*, int))); QTreePushButton* rButton = new QTreePushButton; rButton->setItem(item); @@ -3487,7 +3515,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); rButton->setEnabled(0); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), - this,SLOT(ReloadImage(QTreeWidgetItem*, int))); + this,SLOT(ReloadImage(QTreeWidgetItem*, int))); DataTree->addTopLevelItem(item); DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton); @@ -3499,40 +3527,40 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen mSlicerManagers.back()->SetId(id.toStdString()); linkPanel->addImage(slicer_manager->GetFileName().c_str()// filename - , id.toStdString()); + , id.toStdString()); connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)), - this, SLOT(CurrentImageChanged(std::string))); + this, SLOT(CurrentImageChanged(std::string))); connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)), - this, SLOT(CurrentPickedImageChanged(std::string))); + this, SLOT(CurrentPickedImageChanged(std::string))); connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)), - this, SLOT(MousePositionChanged(int,double, double, double, double, double, double, double))); + this, SLOT(MousePositionChanged(int,double, double, double, double, double, double, double))); connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)), - this, SLOT(VectorChanged(int,double,double,double, double))); + this, SLOT(VectorChanged(int,double,double,double, double))); connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)), - this, SLOT(OverlayChanged(int,double,double))); + this, SLOT(OverlayChanged(int,double,double))); connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)), - this, SLOT(FusionChanged(int,double))); + this, SLOT(FusionChanged(int,double))); //connect(mSlicerManagers.back(), SIGNAL(UpdateFusionSequence(int, bool, unsigned int)), - // this, SLOT(FusionSequenceChanged(int, bool, unsigned int))); + // this, SLOT(FusionSequenceChanged(int, bool, unsigned int))); connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()), - this,SLOT(WindowLevelChanged())); + this,SLOT(WindowLevelChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)), - this,SLOT(UpdateSlice(int,int))); - connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), - this,SLOT(UpdateTSlice(int, int))); - connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), - this,SLOT(ImageInfoChanged())); + this,SLOT(UpdateSlice(int,int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int, int)), + this,SLOT(UpdateTSlice(int, int, int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int, int)), + this,SLOT(ImageInfoChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)), - this,SLOT(UpdateSliceRange(int,int,int,int,int))); + this,SLOT(UpdateSliceRange(int,int,int,int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)), - this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); + this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*)), - this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*))); + this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*))); connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)), - this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); + this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); - + UpdateTree(); qApp->processEvents(); diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index 7933b16..7911a75 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -116,7 +116,7 @@ public slots: void WindowLevelChanged(); void UpdateSlice(int slicer, int slice); - void UpdateTSlice(int slicer, int slice); + void UpdateTSlice(int slicer, int slice, int code=-1); void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax); void WindowLevelEdited(); void SetWindowLevel(double w, double l); diff --git a/vv/vvOverlayPanel.cxx b/vv/vvOverlayPanel.cxx index f32357b..649f1fd 100644 --- a/vv/vvOverlayPanel.cxx +++ b/vv/vvOverlayPanel.cxx @@ -29,6 +29,9 @@ //==================================================================== vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent) { + disableFusionSignals = true; + disableFusionSequenceSignals = true; + setupUi(this); vFFrame->hide(); @@ -40,7 +43,6 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent) lutCheckBox->hide(); lutCheckBox->setEnabled(0); fusionShowLegendCheckBox->setChecked(false); - fCTUSActivateSpaceSyncCheckBox->setChecked(true); connect(subSamplingSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty())); connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty())); @@ -64,9 +66,6 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent) connect(fCTUSActivateSpaceSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty())); connect(fCTUSActivateTimeSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty())); connect(fCTUSLoadSignalPushButton,SIGNAL(clicked()),this,SIGNAL(FusionSequenceSignalButtonPressed())); - - disableFusionSignals = false; - disableFusionSequenceSignals = false; } void vvOverlayPanel::getCurrentImageName(QString name) @@ -275,6 +274,7 @@ void vvOverlayPanel::getFusionSequenceProperty(int sequenceFrameIndex, bool spat disableFusionSequenceSignals = false; setFusionSequenceProperty(); } else { + disableFusionSequenceSignals = true; fCTUSFrame->hide(); fCTUSFrame->setEnabled(0); fCTUSSlider->setEnabled(0); @@ -282,28 +282,38 @@ void vvOverlayPanel::getFusionSequenceProperty(int sequenceFrameIndex, bool spat fCTUSSlider->setMaximum(0); fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked); fCTUSActivateTimeSyncCheckBox->setCheckState(Qt::Unchecked); + disableFusionSequenceSignals = false; + setFusionSequenceProperty(); } } void vvOverlayPanel::setFusionSequenceProperty() { - if (disableFusionSequenceSignals) - return; - - emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked()); + if (disableFusionSequenceSignals) + return; + emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked()); } void vvOverlayPanel::enableFusionSequenceTemporalSync() { + bool backup = disableFusionSequenceSignals; + disableFusionSequenceSignals=true; //not sure this is necessary, but just in case... fCTUSActivateTimeSyncCheckBox->setEnabled(1); fCTUSActivateTimeSyncCheckBox->setChecked(true); + disableFusionSequenceSignals = backup; // if (disableFusionSequenceSignals) return; emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked()); } void vvOverlayPanel::updateFusionSequenceSliderValueFromWindow(int val, bool updateVisualization) { + if (fCTUSSlider->value()==val) return; + + disableFusionSequenceSignals = true; //not sure this is necessary, but just in case... fCTUSSlider->setValue(val); + disableFusionSequenceSignals = false; + + if (disableFusionSequenceSignals) return; if (updateVisualization) emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked()); } diff --git a/vv/vvOverlayPanel.h b/vv/vvOverlayPanel.h index 1b3f914..b0e69db 100644 --- a/vv/vvOverlayPanel.h +++ b/vv/vvOverlayPanel.h @@ -1,19 +1,19 @@ /*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv +Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr +Authors belong to: +- University of LYON http://www.universite-lyon.fr/ +- Léon Bérard cancer center http://www.centreleonberard.fr +- CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the copyright notices for more information. - It is distributed under dual licence +It is distributed under dual licence - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +- BSD See included LICENSE.txt file +- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ===========================================================================**/ #ifndef _vvOverlayPanel_H #define _vvOverlayPanel_H @@ -26,54 +26,54 @@ class vvOverlayPanel : public QWidget, private Ui::vvOverlayPanel { - Q_OBJECT + Q_OBJECT public: - // constructor - destructor - vvOverlayPanel(QWidget * parent=0); - ~vvOverlayPanel() {} + // constructor - destructor + vvOverlayPanel(QWidget * parent=0); + ~vvOverlayPanel() {} - void getCurrentImageName(QString name); + void getCurrentImageName(QString name); - void getVFProperty(int subsampling, int scale, int log); - void getVFName(QString name); + void getVFProperty(int subsampling, int scale, int log); + void getVFName(QString name); - void getOverlayProperty(int color, int linked, double window, double level); - void getOverlayName(QString name); + void getOverlayProperty(int color, int linked, double window, double level); + void getOverlayName(QString name); - void getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level); - void getFusionName(QString name); + void getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level); + void getFusionName(QString name); - void getFusionSequenceProperty(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLength, bool temporalSync); + void getFusionSequenceProperty(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLength, bool temporalSync); - void getCurrentVectorInfo(int visibility, double x, double y, double z, double value); - void getCurrentOverlayInfo(int visibility,double valueOver, double valueRef); - void getCurrentFusionInfo(int visibility,double value); - - bool getShowLegend(); + void getCurrentVectorInfo(int visibility, double x, double y, double z, double value); + void getCurrentOverlayInfo(int visibility,double valueOver, double valueRef); + void getCurrentFusionInfo(int visibility,double value); - void updateFusionSequenceSliderValueFromWindow(int val, bool updateVisualization); + bool getShowLegend(); + + void updateFusionSequenceSliderValueFromWindow(int val, bool updateVisualization); public slots: - void setVFProperty(); - void setOverlayProperty(); - void setFusionProperty(); - void setFusionSpinProperty(); - void VFColorChangeRequest(); - void setFusionSequenceProperty(); - void enableFusionSequenceTemporalSync(); + void setVFProperty(); + void setOverlayProperty(); + void setFusionProperty(); + void setFusionSpinProperty(); + void VFColorChangeRequest(); + void setFusionSequenceProperty(); + void enableFusionSequenceTemporalSync(); signals: - void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b); - void OverlayPropertyUpdated(int color, int linked, double window, double level); - void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level, bool showLegend); - void FusionSequencePropertyUpdated(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLength, bool temporalSync); - void FusionSequenceSignalButtonPressed(); - + void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b); + void OverlayPropertyUpdated(int color, int linked, double window, double level); + void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level, bool showLegend); + void FusionSequencePropertyUpdated(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLength, bool temporalSync); + void FusionSequenceSignalButtonPressed(); + private: - bool disableFusionSignals; - bool disableFusionSequenceSignals; - + bool disableFusionSignals; + bool disableFusionSequenceSignals; + }; // end class vvOverlayPanel //==================================================================== diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 7cb4036..7746331 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -206,6 +206,8 @@ public: } void SetVFColor(double r, double g, double b); + //necessary to flag the secondary sequence + void SetFusionSequenceCode(int code) {mFusionSequenceCode=code;} protected: vvSlicer(); ~vvSlicer(); diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 01821d9..94a834f 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -77,8 +77,8 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers) mSlicers.push_back(vtkSmartPointer::New()); mSelectedSlicer = -1; - mPreviousSlice.resize(numberOfSlicers); - mPreviousTSlice.resize(numberOfSlicers); + mPreviousSlice.resize(numberOfSlicers, 0); + mPreviousTSlice.resize(numberOfSlicers, 0); mSlicingPreset = WORLD_SLICING; @@ -513,7 +513,7 @@ int vvSlicerManager::GetTSlice() //---------------------------------------------------------------------------- void vvSlicerManager::SetTSlice(int slice, bool updateLinkedImages) { - if (!updateLinkedImages) { + if (!updateLinkedImages) { //for fusionSequence, TMax / MaxCurrentTSlice are irrelevant. for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetTSlice(slice, updateLinkedImages); UpdateTSlice(i); @@ -521,7 +521,6 @@ void vvSlicerManager::SetTSlice(int slice, bool updateLinkedImages) return; } - if (slice < 0) slice = 0; else if (slice > mSlicers[0]->GetTMax()) @@ -557,7 +556,7 @@ void vvSlicerManager::SetNextTSlice(int originating_slicer) if (t > mSlicers[0]->GetTMax()) t = 0; //std::cout << "vvSlicerManager::SetNextTSlice" << std::endl; - emit UpdateTSlice(originating_slicer,t); + emit UpdateTSlice(originating_slicer,t, mFusionSequenceInvolvementCode); } //---------------------------------------------------------------------------- @@ -570,7 +569,7 @@ void vvSlicerManager::SetPreviousTSlice(int originating_slicer) if (t < 0) t = mSlicers[0]->GetTMax(); //std::cout << "vvSlicerManager::SetPreviousTSlice" << std::endl; - emit UpdateTSlice(originating_slicer,t); + emit UpdateTSlice(originating_slicer,t, mFusionSequenceInvolvementCode); } //---------------------------------------------------------------------------- @@ -1057,7 +1056,6 @@ void vvSlicerManager::RemoveActors() //---------------------------------------------------------------------------- void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) { -//TODO: this is probably here that I shall prevent the overlayPanel to disappear when the mouse goes over the linked sequence! // int view = mSlicers[slicer]->GetSliceOrientation(); // int slice = mSlicers[slicer]->GetSlice(); double x = mSlicers[slicer]->GetCursorPosition()[0]; @@ -1183,7 +1181,7 @@ void vvSlicerManager::UpdateTSlice(int slicer) int slice = mSlicers[slicer]->GetSlice(); int tslice = mSlicers[slicer]->GetMaxCurrentTSlice(); - if (this->IsInvolvedInFusionSequence()) tslice = mSlicers[slicer]->GetTSlice(); + //if (this->IsInvolvedInFusionSequence()) tslice = mSlicers[slicer]->GetTSlice(); //actually, this is handled by the Slicer if (mPreviousSlice[slicer] == slice) { if (mPreviousTSlice[slicer] == tslice) { @@ -1194,7 +1192,7 @@ void vvSlicerManager::UpdateTSlice(int slicer) mPreviousSlice[slicer] = slice; mPreviousTSlice[slicer] = tslice; - emit UpdateTSlice(slicer, tslice); + emit UpdateTSlice(slicer, tslice, mFusionSequenceInvolvementCode); } //---------------------------------------------------------------------------- diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 527078a..d634fbd 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -282,7 +282,7 @@ signals : void KeyPressedSignal(std::string KeyPressed); void UpdateOrientation(int slicer, int orientation); void UpdateSlice(int slicer, int slice); - void UpdateTSlice(int slicer, int slice); + void UpdateTSlice(int slicer, int slice, int code); void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax); void WindowLevelChanged(); void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps); -- 2.47.1