X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=af4b65e4fe17e330f77c6cdb436ad02944fa56d0;hb=30659c9eea7c95c04002cb3de18d6e584f8d1296;hp=5473980f452abe3ecf85a490b898d859313a081c;hpb=26bbfd8756d07eb73acbfe2fcfd77b3a4f3b52a9;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 5473980..af4b65e 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -1,31 +1,21 @@ /*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Program: vv - Module: $RCSfile: vvMainWindow.cxx,v $ - Language: C++ - Date: $Date: 2010/02/07 12:00:59 $ - Version: $Revision: 1.9 $ - Author : Pierre Seroul (pierre.seroul@gmail.com) + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - Copyright (C) 200COLUMN_IMAGE_NAME - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS-LRMN 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 program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, version 3 of the License. + It is distributed under dual licence - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - =========================================================================*/ - -// QT include #include #include #include @@ -39,11 +29,10 @@ #include "vvProgressDialog.h" #include "vvQDicomSeriesSelector.h" #include "vvSlicerManager.h" -#include "clitkIOCommon.h" +#include "clitkImageCommon.h" #include "vvSlicer.h" #include "vvInteractorStyleNavigator.h" #include "vvImageWriter.h" -#include "vvResamplerDialog.h" #include "vvSegmentationDialog.h" #include "vvSurfaceViewerDialog.h" #include "vvDeformationDialog.h" @@ -54,8 +43,8 @@ #include "vvMesh.h" #include "vvStructSelector.h" #include "vvMeshReader.h" -#include "vvCropDialog.h" #include "vvConstants.h" + #ifdef CLITK_VV_USE_BDCM #include #endif @@ -94,6 +83,8 @@ #define COLUMN_RELOAD_IMAGE 6 #define COLUMN_IMAGE_NAME 7 +#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox *.his *.xdr)" + /*Data Tree values 0,Qt::UserRole full filename 1,Qt::CheckStateRole checkbutton UL View @@ -105,45 +96,49 @@ 5,Qt::UserRole mSlicerManager id*/ //------------------------------------------------------------------------------ -vvMainWindow::vvMainWindow() { +vvMainWindow::vvMainWindow():vvMainWindowBase() { setupUi(this); // this sets up the GUI mInputPathName = ""; - mCurrentToolInfo = 0; + mMenuTools = menuTools; + mContextMenu = &contextMenu; + mMenuExperimentalTools = menuExperimental; + mMainWidget = this; + mCurrentTime = -1; //Init the contextMenu this->setContextMenuPolicy(Qt::CustomContextMenu); contextActions.resize(0); - QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/fileopen.png")), + QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/fileopen.png")), tr("O&pen new Image")); actionOpen_new_image->setShortcut(QKeySequence(tr("Ctrl+O"))); connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages())); contextActions.push_back(actionOpen_new_image); contextMenu.addSeparator(); - QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")), + QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/exit.png")), 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(":/new/prefix1/icons/rotateright.png")), + QAction* actionReload_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")), 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(":/new/prefix1/icons/filesave.png")), + QAction* actionSave_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")), tr("Save Current Image")); connect(actionSave_image,SIGNAL(triggered()),this,SLOT(SaveAs())); contextActions.push_back(actionSave_image); contextMenu.addSeparator(); - QAction* actionCrop_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/crop.png")), - tr("Crop Current Image")); - connect(actionCrop_image,SIGNAL(triggered()),this,SLOT(CropImage())); - contextActions.push_back(actionCrop_image); + // QAction* actionCrop_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/crop.png")), + // tr("Crop Current Image")); + // connect(actionCrop_image,SIGNAL(triggered()),this,SLOT(CropImage())); + // contextActions.push_back(actionCrop_image); - QAction* actionSplit_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/cut.png")), + QAction* actionSplit_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/cut.png")), tr("Split Current Image")); connect(actionSplit_image,SIGNAL(triggered()),this,SLOT(SplitImage())); contextActions.push_back(actionSplit_image); @@ -153,7 +148,7 @@ vvMainWindow::vvMainWindow() { contextMenu.addAction(actionAdd_VF_to_current_Image); contextActions.push_back(actionAdd_VF_to_current_Image); - QAction* actionAdd_Overlay_to_current_Image = menuOverlay->addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/GPSup.png")), + QAction* actionAdd_Overlay_to_current_Image = menuOverlay->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")), tr("Add overlay image to current image")); contextMenu.addAction(actionAdd_Overlay_to_current_Image); contextActions.push_back(actionAdd_Overlay_to_current_Image); @@ -164,6 +159,20 @@ vvMainWindow::vvMainWindow() { connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(AddFusionImage())); contextActions.push_back(actionAdd_fusion_image); + // TRIAL DS + /* + QMenu * m = new QMenu(menubar); + m->setTitle("TOTO"); + // m->setObjectName(QString::fromUtf8("TOTOTO")); + contextMenu.addMenu(m); + QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")), + tr("BIDON")); + QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")), + tr("BIDON2")); + m->addAction(a); + m->addAction(b); + connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage())); + */ //init the DataTree mSlicerManagers.resize(0); @@ -246,8 +255,6 @@ vvMainWindow::vvMainWindow() { connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation())); /////////////////////////////////////////////// - contextMenu.addAction(actionResampler); - connect(actionResampler,SIGNAL(triggered()),this,SLOT(ResampleCurrentImage())); connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage())); connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch())); /////////////////////////////////////////////// @@ -278,7 +285,7 @@ vvMainWindow::vvMainWindow() { connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString))); connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString))); - connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int)),this,SLOT(SetVFProperty(int,int,int))); + connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int)),this,SLOT(SetVFProperty(int,int,int,int))); connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int))); connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)), this,SLOT(SetFusionProperty(int,int,double,double))); @@ -305,11 +312,11 @@ vvMainWindow::vvMainWindow() { if ( !recent_files.empty() ) { QMenu * rmenu = new QMenu("Recently opened files..."); - rmenu->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/open.png"))); + rmenu->setIcon(QIcon(QString::fromUtf8(":/common/icons/open.png"))); menuFile->insertMenu(actionOpen_Image_With_Time,rmenu); for (std::list::iterator i = recent_files.begin();i!=recent_files.end();i++) { - QAction* current=new QAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/open.png")), + QAction* current=new QAction(QIcon(QString::fromUtf8(":/common/icons/open.png")), (*i).c_str(),this); rmenu->addAction(current); connect(current,SIGNAL(triggered()),this,SLOT(OpenRecentImage())); @@ -317,7 +324,10 @@ vvMainWindow::vvMainWindow() { } // Adding all new tools (insertion in the menu) - vvToolManager::GetInstance()->Initialize(this); + vvToolManager::GetInstance()->InsertToolsInMenu(this); + + if (!CLITK_EXPERIMENTAL) + menuExperimental->menuAction()->setVisible(false); } //------------------------------------------------------------------------------ @@ -329,7 +339,8 @@ void vvMainWindow::ComputeMIP() vvSlicerManager* selected_slicer = mSlicerManagers[GetSlicerIndexFromItem(DataTree->selectedItems()[0])]; QFileInfo info(selected_slicer->GetFileName().c_str()); mip.Compute(selected_slicer); - AddImage(mip.GetOutput(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_mip.mhd"); + if (!mip.error) + AddImage(mip.GetOutput(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_mip.mhd"); } //------------------------------------------------------------------------------ @@ -358,7 +369,10 @@ void vvMainWindow::ComputeMidPosition() QApplication::restoreOverrideCursor(); } } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation) { QTreeWidgetItem *item = new QTreeWidgetItem(); @@ -377,7 +391,7 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro cButton->setItem(item); cButton->setColumn(COLUMN_CLOSE_IMAGE); cButton->setToolTip(tr("close image")); - cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png"))); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(CloseImage(QTreeWidgetItem*, int))); @@ -385,7 +399,7 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro rButton->setItem(item); rButton->setColumn(COLUMN_RELOAD_IMAGE); rButton->setToolTip(tr("reload image")); - rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png"))); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); rButton->setEnabled(false); //Not implemented //connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), @@ -402,13 +416,15 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro mSlicerManagers[image_index]->AddContour(contour,propagation); mSlicerManagers[image_index]->Render(); } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::OpenVTKContour() { if (mSlicerManagers.size() > 0) { - QString Extensions = "Images ( *.vtk)"; + QString Extensions = "Images ( *.vtk; *.obj)"; Extensions += ";;All Files (*)"; QString file = QFileDialog::getOpenFileName(this,tr("Open vtkPolyData"),mInputPathName,Extensions); if (file.isNull()) @@ -416,6 +432,7 @@ void vvMainWindow::OpenVTKContour() QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); vvMeshReader reader; + reader.SetImage(mSlicerManagers[index]->GetImage()); reader.SetModeToVTK(); reader.SetFilename(file.toStdString()); reader.Update(); @@ -423,12 +440,15 @@ void vvMainWindow::OpenVTKContour() QApplication::restoreOverrideCursor(); } } +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvMainWindow::OpenDCStructContour() { if (mSlicerManagers.size() > 0) { - QString Extensions = "Dicom Files ( *.dcm)"; + QString Extensions = "Dicom Files ( *.dcm; RS*)"; Extensions += ";;All Files (*)"; QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"),mInputPathName,Extensions); if (file.isNull()) @@ -456,6 +476,8 @@ void vvMainWindow::OpenDCStructContour() } } } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::ComputeDeformableRegistration() @@ -475,6 +497,8 @@ void vvMainWindow::ComputeDeformableRegistration() } else QMessageBox::information(this, "Need to open image","You must open an image first."); } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::WarpImage() @@ -493,6 +517,8 @@ void vvMainWindow::WarpImage() else QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field")); } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phase) @@ -519,6 +545,8 @@ void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phas else QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field.")); } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ vvMainWindow::~vvMainWindow() { @@ -530,9 +558,10 @@ vvMainWindow::~vvMainWindow() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::MergeImages() { - QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)"; + QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images"),mInputPathName,Extensions); if (files.isEmpty()) @@ -548,45 +577,45 @@ 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) NOViewWidget->hide(); - NEViewWidget->hide(); - SOViewWidget->hide(); - SEViewWidget->hide(); - { - if (i == 0) - currentDim = reader->GetNumberOfDimensions(); - bool IsOk = true; - for (unsigned int j = 0;j < currentDim; j++) + if (reader) { + //NOViewWidget->hide(); + //NEViewWidget->hide(); + //SOViewWidget->hide(); + //SEViewWidget->hide(); + if (i == 0) + currentDim = reader->GetNumberOfDimensions(); + bool IsOk = true; + for (unsigned int j = 0;j < currentDim; j++) { - if (i == 0) + if (i == 0) { - if (j == 0) + if (j == 0) { - currentSpacing.resize(currentDim); - currentSize.resize(currentDim); - currentOrigin.resize(currentDim); + currentSpacing.resize(currentDim); + currentSize.resize(currentDim); + currentOrigin.resize(currentDim); } - currentOrigin[j] = reader->GetOrigin(j); - currentSpacing[j] = reader->GetSpacing(j); - currentSize[j] = reader->GetDimensions(j); + currentOrigin[j] = reader->GetOrigin(j); + 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)) + 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; + 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) - vector.push_back(files[i].toStdString()); + if (IsOk) + vector.push_back(files[i].toStdString()); } } if (vector.size() > 0) @@ -594,9 +623,10 @@ void vvMainWindow::MergeImages() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::MergeImagesWithTime() { - QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)"; + QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images With Time"),mInputPathName,Extensions); if (files.isEmpty()) @@ -666,6 +696,7 @@ void vvMainWindow::MergeImagesWithTime() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::OpenDicom() { std::vector files; @@ -702,7 +733,7 @@ void vvMainWindow::OpenDicom() { //------------------------------------------------------------------------------ void vvMainWindow::OpenImages() { - QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)"; + QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images"),mInputPathName,Extensions); @@ -723,10 +754,12 @@ void vvMainWindow::OpenRecentImage() mInputPathName = itksys::SystemTools::GetFilenamePath(images[0]).c_str(); LoadImages(images,IMAGE); } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::OpenImageWithTime() { - QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)"; + QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images With Time"),mInputPathName,Extensions); @@ -742,6 +775,7 @@ void vvMainWindow::OpenImageWithTime() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::LoadImages(std::vector files, LoadedImageType filetype) { //Separate the way to open images and dicoms @@ -777,11 +811,25 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi bool SetImageSucceed=false; + // Change filename if an image with the same already exist + // DD(files[i]); + int number=0; + for(unsigned int l=0; lGetBaseFileName()); + // DD(v->GetFileName()); + if (v->GetBaseFileName() == + vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(files[i]))) { + number = std::max(number, v->GetBaseFileNameNumber()+1); + } + } + + if (filetype == IMAGE || filetype == IMAGEWITHTIME) - SetImageSucceed = imageManager->SetImage(files[i],filetype); + SetImageSucceed = imageManager->SetImage(files[i],filetype, number); else { - SetImageSucceed = imageManager->SetImages(files,filetype); + SetImageSucceed = imageManager->SetImages(files,filetype, number); } if (SetImageSucceed == false) { @@ -808,7 +856,7 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi cButton->setItem(item); cButton->setColumn(COLUMN_CLOSE_IMAGE); cButton->setToolTip(tr("close image")); - cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png"))); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(CloseImage(QTreeWidgetItem*, int))); @@ -816,7 +864,7 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi rButton->setItem(item); rButton->setColumn(COLUMN_RELOAD_IMAGE); rButton->setToolTip(tr("reload image")); - rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png"))); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(ReloadImage(QTreeWidgetItem*, int))); @@ -831,29 +879,30 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi linkPanel->addImage(imageManager->GetFileName(), id.toStdString()); - connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)), + connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)), this,SLOT(CurrentImageChanged(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))); - connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)), + connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(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))); - connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)), + connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)), this, SLOT(OverlayChanged(int,double,double))); - connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)), + connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)), this, SLOT(FusionChanged(int,double))); - connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)), + connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)), this,SLOT(WindowsChanged(int, int, int))); - connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)), + connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)), this,SLOT(WindowLevelChanged(double, double, int, int))); - connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)), + connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)), this,SLOT(UpdateSlice(int,int))); - connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)), + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), this,SLOT(UpdateTSlice(int, int))); - connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)), + connect(mSlicerManagers.back(), SIGNAL(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)), + connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)), this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); + connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)), + this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); InitSlicers(); numberofsuccesulreads++; @@ -871,9 +920,17 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi } QApplication::restoreOverrideCursor(); - - // vvToolManager::GetInstance()->UpdateEnabledTool(); - // emit SlicerManagersHasChanged(); + // Try to guess default WindowLevel + double range[2]; + mSlicerManagers.back()->GetImage()->GetFirstVTKImageData()->GetScalarRange(range); + // DD(range[0]); + // DD(range[1]); + if ((range[0] == 0) && (range[1] == 1)) { + presetComboBox->setCurrentIndex(5);// binary + } + else { + // TODO + } } //------------------------------------------------------------------------------ @@ -1069,74 +1126,74 @@ void vvMainWindow::ImageInfoChanged() { } windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); - DD(mSlicerManagers[index]->GetColorMap()); - DD(mSlicerManagers[index]->GetPreset()); + // DD(mSlicerManagers[index]->GetColorMap()); + // DD(mSlicerManagers[index]->GetPreset()); presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); - infoPanel->setFileName(image); - infoPanel->setDimension(dim); - infoPanel->setSizePixel(GetVectorIntAsString(inputSize)); - infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM)); - infoPanel->setOrigin(GetVectorDoubleAsString(origin)); - infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing)); - infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); - - landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), - mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size()); - landmarksPanel->SetCurrentPath(mInputPathName.toStdString()); - landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str()); - - overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str()); - for (int i = 0; i < 4;i++) - { - if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3) - { - mSlicerManagers[index]->UpdateInfoOnCursorPosition(i); - break; - } - } - windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); - levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); - presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); - colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); + infoPanel->setFileName(image); + infoPanel->setDimension(dim); + infoPanel->setSizePixel(GetVectorIntAsString(inputSize)); + infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM)); + infoPanel->setOrigin(GetVectorDoubleAsString(origin)); + infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing)); + infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); - 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()); - } - else - { - overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str()); - overlayPanel->getVFProperty(-1,-1,-1); - } - if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) - { - overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str()); - overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor()); - } - else - { - overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str()); - overlayPanel->getOverlayProperty(-1); - } - if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) - { - overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); - overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(), - mSlicerManagers[index]->GetFusionColorMap(), - mSlicerManagers[index]->GetFusionWindow(), - mSlicerManagers[index]->GetFusionLevel()); - } - else - { - overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); - overlayPanel->getFusionProperty(-1, -1,-1,-1); - } - } + landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), + mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size()); + landmarksPanel->SetCurrentPath(mInputPathName.toStdString()); + landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str()); + + overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str()); + for (int i = 0; i < 4;i++) + { + if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3) + { + mSlicerManagers[index]->UpdateInfoOnCursorPosition(i); + break; + } + } + windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); + levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); + presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); + colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); + + 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()); + } + else + { + overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str()); + overlayPanel->getVFProperty(-1,-1,-1); + } + if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) + { + overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str()); + overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor()); + } + else + { + overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str()); + overlayPanel->getOverlayProperty(-1); + } + if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) + { + overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); + overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(), + mSlicerManagers[index]->GetFusionColorMap(), + mSlicerManagers[index]->GetFusionWindow(), + mSlicerManagers[index]->GetFusionLevel()); + } + else + { + overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); + overlayPanel->getFusionProperty(-1, -1,-1,-1); + } + } } //------------------------------------------------------------------------------ @@ -1259,6 +1316,18 @@ int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item) { } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm) { + QString id = sm->GetId().c_str(); + for (int i = 0; i < DataTree->topLevelItemCount(); i++) + { + if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id) + return DataTree->topLevelItem(i); + } + return NULL; +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column) { int index = GetSlicerIndexFromItem(clicked_item); @@ -1266,6 +1335,9 @@ void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column) { return; for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { + //Trick to avoid redoing twice the job for a key (sr) + mSlicerManagers[i]->GetSlicer(column-1)->GetRenderWindow()-> GetInteractor()->SetKeySym("Crap"); + QTreeWidgetItem* current_row=DataTree->topLevelItem(i); if (DataTree->topLevelItem(index) == current_row) { @@ -1473,7 +1545,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) { msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); if (msgBox.exec() == QMessageBox::AcceptRole) { - this->close(); + this->close(); } } else @@ -1486,6 +1558,10 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) { msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); if (msgBox.exec() == QMessageBox::AcceptRole) { + + // Tell tools that we close an image + emit AnImageIsBeingClosed(mSlicerManagers[index]); + std::vector::iterator Manageriter = mSlicerManagers.begin(); DataTree->takeTopLevelItem(index); for (int i = 0; i < index; i++) @@ -1496,25 +1572,24 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) { mSlicerManagers[index]->RemoveActors(); delete mSlicerManagers[index]; mSlicerManagers.erase(Manageriter); + + // InitDisplay(); } } - - // vvToolManager::GetInstance()->UpdateEnabledTool(); - // emit SlicerManagersHasChanged(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column) { // int index = GetSlicerIndexFromItem(item); -// QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); -// if (item->data(1,Qt::UserRole).toString() == "vector") -// mSlicerManagers[index]->ReloadVF(); -// else -// mSlicerManagers[index]->Reload(); + // QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + // if (item->data(1,Qt::UserRole).toString() == "vector") + // mSlicerManagers[index]->ReloadVF(); + // else + // mSlicerManagers[index]->Reload(); -// QApplication::restoreOverrideCursor(); + // QApplication::restoreOverrideCursor(); int index = GetSlicerIndexFromItem(item); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QString role=item->data(1,Qt::UserRole).toString(); @@ -1526,17 +1601,21 @@ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column) { mSlicerManagers[index]->ReloadFusion(); else mSlicerManagers[index]->Reload(); + + // Update view and info + ImageInfoChanged(); + mSlicerManagers[index]->Render(); QApplication::restoreOverrideCursor(); } //------------------------------------------------------------------------------ -void vvMainWindow::CropImage() -{ - int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - vvCropDialog crop(mSlicerManagers,index); - if(crop.exec()) - AddImage(crop.GetOutput(),"cropped.mhd"); -} +// void vvMainWindow::CropImage() +// { +// int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); +// vvCropDialog crop(mSlicerManagers,index); +// if(crop.exec()) +// AddImage(crop.GetOutput(),"cropped.mhd"); +// } //------------------------------------------------------------------------------ void vvMainWindow::SplitImage() { @@ -1600,7 +1679,7 @@ void vvMainWindow::SplitImage() { cButton->setItem(item); cButton->setColumn(COLUMN_CLOSE_IMAGE); cButton->setToolTip(tr("close image")); - cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png"))); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(CloseImage(QTreeWidgetItem*, int))); @@ -1608,7 +1687,7 @@ void vvMainWindow::SplitImage() { rButton->setItem(item); rButton->setColumn(COLUMN_RELOAD_IMAGE); rButton->setToolTip(tr("reload image")); - rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png"))); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); rButton->setEnabled(false); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(ReloadImage(QTreeWidgetItem*, int))); @@ -1819,7 +1898,7 @@ void vvMainWindow::SelectOverlayImage() { return; } - QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)"; + QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; QString file = QFileDialog::getOpenFileName(this,tr("Load Overlay image"),mInputPathName,Extensions); if (!file.isEmpty()) @@ -1829,6 +1908,7 @@ void vvMainWindow::SelectOverlayImage() { //------------------------------------------------------------------------------ void vvMainWindow::AddOverlayImage(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); @@ -1839,7 +1919,7 @@ void vvMainWindow::AddOverlayImage(int index, QString file) { 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]->SetOverlay(file.toStdString(),dimension, component)) { @@ -1854,7 +1934,7 @@ void vvMainWindow::AddOverlayImage(int index, QString file) { { item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole)); mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("overlay",0, - DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt()); + DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt()); } //Create the buttons for reload and close @@ -1863,7 +1943,7 @@ void vvMainWindow::AddOverlayImage(int index, QString file) { cButton->setItem(item); cButton->setColumn(COLUMN_CLOSE_IMAGE); cButton->setToolTip(tr("close image")); - cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png"))); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(CloseImage(QTreeWidgetItem*, int))); @@ -1871,7 +1951,7 @@ void vvMainWindow::AddOverlayImage(int index, QString file) { rButton->setItem(item); rButton->setColumn(COLUMN_RELOAD_IMAGE); rButton->setToolTip(tr("reload image")); - rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png"))); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(ReloadImage(QTreeWidgetItem*, int))); @@ -1912,7 +1992,7 @@ void vvMainWindow::AddFusionImage() return; } - QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)"; + QString Extensions = EXTENSIONS; Extensions += ";;All Files (*)"; QString file = QFileDialog::getOpenFileName(this,tr("Load Fusion image"),mInputPathName,Extensions); if (!file.isEmpty()) @@ -1953,7 +2033,7 @@ void vvMainWindow::AddFusionImage() cButton->setItem(item); cButton->setColumn(COLUMN_CLOSE_IMAGE); cButton->setToolTip(tr("close image")); - cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png"))); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(CloseImage(QTreeWidgetItem*, int))); @@ -1961,7 +2041,7 @@ void vvMainWindow::AddFusionImage() rButton->setItem(item); rButton->setColumn(COLUMN_RELOAD_IMAGE); rButton->setToolTip(tr("reload image")); - rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png"))); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(ReloadImage(QTreeWidgetItem*, int))); @@ -1993,8 +2073,10 @@ void vvMainWindow::AddFusionImage() } } } +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void vvMainWindow::OpenField() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2015,7 +2097,10 @@ void vvMainWindow::OpenField() if (!file.isEmpty()) AddField(file,index); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) { //create an item in the tree with good settings @@ -2038,7 +2123,7 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) cButton->setItem(item); cButton->setColumn(COLUMN_CLOSE_IMAGE); cButton->setToolTip(tr("close vector field")); - cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png"))); + cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png"))); connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(CloseImage(QTreeWidgetItem*, int))); @@ -2047,7 +2132,7 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) rButton->setColumn(COLUMN_RELOAD_IMAGE); rButton->setToolTip(tr("reload vector field")); rButton->setEnabled(from_disk); - rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png"))); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(ReloadImage(QTreeWidgetItem*, int))); @@ -2064,7 +2149,10 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) ImageInfoChanged(); QApplication::restoreOverrideCursor(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index) { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -2081,7 +2169,10 @@ void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index) } QApplication::restoreOverrideCursor(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddField(QString file,int index) { if (QFile::exists(file)) @@ -2117,8 +2208,9 @@ void vvMainWindow::AddField(QString file,int index) } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ -void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { +void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { @@ -2126,6 +2218,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { { mSlicerManagers[index]->GetSlicer(i)->SetVFSubSampling(subsampling); mSlicerManagers[index]->GetSlicer(i)->SetVFScale(scale); + mSlicerManagers[index]->GetSlicer(i)->SetVFWidth(width); if (log > 0) mSlicerManagers[index]->GetSlicer(i)->SetVFLog(1); else @@ -2135,6 +2228,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SetOverlayProperty(int color) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2246,6 +2340,7 @@ void vvMainWindow::SaveAs() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::AddLink(QString image1,QString image2) { for (unsigned int i = 0; i < mSlicerManagers.size();i++) @@ -2262,8 +2357,10 @@ void vvMainWindow::AddLink(QString image1,QString image2) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::RemoveLink(QString image1,QString image2) { + // DD("vvMainWindow:RemoveLink"); for (unsigned int i = 0; i < mSlicerManagers.size();i++) { if (image1.toStdString() == mSlicerManagers[i]->GetId()) @@ -2278,6 +2375,21 @@ void vvMainWindow::RemoveLink(QString image1,QString image2) { } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset) +{ + int index = 0; + while(sm != mSlicerManagers[index]) + index++; + index = (index+offset) % mSlicerManagers.size(); + + QTreeWidgetItem* item = GetItemFromSlicerManager(mSlicerManagers[index]); + //CurrentImageChanged(mSlicerManagers[index]->GetId()); //select new image + item->setData(slicer+1,Qt::CheckStateRole,2); //change checkbox + DisplayChanged(item,slicer+1); +} +//------------------------------------------------------------------------------ + void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index) { for (unsigned int i = 0; i < mSlicerManagers.size(); i++) @@ -2295,101 +2407,166 @@ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index) } } } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::NOHorizontalSliderMoved() { + // if (mCurrentTime == NOHorizontalSlider->value()) return; HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0); + // mCurrentTime = NOHorizontalSlider->value(); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::NEHorizontalSliderMoved() { + // if (mCurrentTime == NEHorizontalSlider->value()) return; HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1); + // mCurrentTime = NEHorizontalSlider->value(); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SOHorizontalSliderMoved() { + // if (mCurrentTime == SOHorizontalSlider->value()) return; HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2); + // mCurrentTime = SOHorizontalSlider->value(); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SEHorizontalSliderMoved() { + // if (mCurrentTime == SEHorizontalSlider->value()) return; HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3); + // mCurrentTime = SEHorizontalSlider->value(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvMainWindow::NOVerticalSliderChanged() { - int value = NOVerticalSlider->value(); + static int value=-1; + if (value == NOVerticalSlider->value()) return; + else value = NOVerticalSlider->value(); + // int value = NOVerticalSlider->value(); 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)->SetSlice(value); - // mSlicerManagers[i]->UpdateSlice(0); // <-- too much update... + if (mSlicerManagers[i]->GetSlicer(0)->GetSlice() != value) { + mSlicerManagers[i]->GetSlicer(0)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(0, value); + mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES. but needed for ImageContour ... + //mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? + } break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::NEVerticalSliderChanged() { - int value = NEVerticalSlider->value(); + static int value=-1; + if (value == NEVerticalSlider->value()) return; + else value = NEVerticalSlider->value(); + // int value = NEVerticalSlider->value(); for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1) { - mSlicerManagers[i]->GetSlicer(1)->SetSlice(value); + if (mSlicerManagers[i]->GetSlicer(1)->GetSlice() != value) { + mSlicerManagers[i]->GetSlicer(1)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(1, value); + mSlicerManagers[i]->UpdateSlice(1); + //mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? + } break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SOVerticalSliderChanged() { - int value = SOVerticalSlider->value(); + // DD("SOVerticalSliderChanged"); + static int value=-1; + // DD(value); +// DD(SOVerticalSlider->value()); + if (value == SOVerticalSlider->value()) return; + else value = SOVerticalSlider->value(); + //int value = SOVerticalSlider->value(); for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1) { - mSlicerManagers[i]->GetSlicer(2)->SetSlice(value); + if (mSlicerManagers[i]->GetSlicer(2)->GetSlice() != value) { + mSlicerManagers[i]->GetSlicer(2)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(2, value); + mSlicerManagers[i]->UpdateSlice(2); + //mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? + } + // else { DD("avoid SOVerticalSlider slicer update"); } break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SEVerticalSliderChanged() { - int value = SEVerticalSlider->value(); + static int value=-1; + if (value == SEVerticalSlider->value()) return; + else value = SEVerticalSlider->value(); + // int value = SEVerticalSlider->value(); for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1) { - mSlicerManagers[i]->GetSlicer(3)->SetSlice(value); + if (mSlicerManagers[i]->GetSlicer(3)->GetSlice() != value) { + mSlicerManagers[i]->GetSlicer(3)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(3, value); + mSlicerManagers[i]->UpdateSlice(3); + //mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? + } break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateSlice(int slicer, int slice) { - if (slicer == 0) + // DD("vvMainWindow::UpdateSlice"); +// DD(slicer); +// DD(slice); + if (slicer == 0) { + // if (slice != NOVerticalSlider->value()) NOVerticalSlider->setValue(slice); - else if (slicer == 1) + } + else { + if (slicer == 1) NEVerticalSlider->setValue(slice); - else if (slicer == 2) - SOVerticalSlider->setValue(slice); - else if (slicer == 3) - SEVerticalSlider->setValue(slice); + else { + if (slicer == 2) + SOVerticalSlider->setValue(slice); + else { + if (slicer == 3) + SEVerticalSlider->setValue(slice); + } + } + } + // DD("vvMainWindow:UpdateSlice END"); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateTSlice(int slicer, int slice) { switch (slicer) @@ -2410,6 +2587,7 @@ void vvMainWindow::UpdateTSlice(int slicer, int slice) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax) { int position = int((min+max)/2); @@ -2445,6 +2623,7 @@ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveNOScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2455,6 +2634,7 @@ void vvMainWindow::SaveNOScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveNEScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2465,6 +2645,7 @@ void vvMainWindow::SaveNEScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveSOScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2475,6 +2656,7 @@ void vvMainWindow::SaveSOScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveSEScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2485,6 +2667,7 @@ void vvMainWindow::SaveSEScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveScreenshot(vtkImageData* image) { QString Extensions = "Images( *.png);;"; @@ -2549,6 +2732,7 @@ void vvMainWindow::SaveScreenshot(vtkImageData* image) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::GoToCursor() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2572,7 +2756,7 @@ void vvMainWindow::PlayPause() { if (playMode) { playMode = 0; - playButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/player_play.png"))); + playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_play.png"))); ImageInfoChanged(); return; } @@ -2589,7 +2773,7 @@ void vvMainWindow::PlayPause() { if (has_temporal) { playMode = 1; - playButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/player_pause.png"))); + playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_pause.png"))); QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext())); } } @@ -2635,16 +2819,6 @@ void vvMainWindow::UpdateRenderWindows() { } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvMainWindow::ResampleCurrentImage() { - vvResamplerDialog resampler; - int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - resampler.SetSlicerManagers(mSlicerManagers,index); - if (resampler.exec()) - AddImage(resampler.GetOutput(),resampler.GetOutputFileName()); -} -//------------------------------------------------------------------------------ - //------------------------------------------------------------------------------ void vvMainWindow::SegmentationOnCurrentImage() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2664,18 +2838,11 @@ void vvMainWindow::SurfaceViewerLaunch() //------------------------------------------------------------------------------ void vvMainWindow::AddImage(vvImage::Pointer image,std::string filename) { - vvSlicerManager* m = new vvSlicerManager(4); - m->SetImage(image); - m->SetFilename(filename); - AddImage(m); -} - -//------------------------------------------------------------------------------ -void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) { + vvSlicerManager* slicer_manager = new vvSlicerManager(4); + slicer_manager->SetImage(image); + slicer_manager->SetFilename(filename); mSlicerManagers.push_back(slicer_manager); - std::string filename = slicer_manager->GetFileName(); - //create an item in the tree with good settings QTreeWidgetItem *item = new QTreeWidgetItem(); item->setData(0,Qt::UserRole,slicer_manager->GetFileName().c_str());//files[i].c_str()); @@ -2689,14 +2856,14 @@ void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) { QTreePushButton* cButton = new QTreePushButton; cButton->setItem(item); cButton->setColumn(COLUMN_CLOSE_IMAGE); - cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png"))); + 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->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png"))); + rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png"))); rButton->setEnabled(0); connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)), this,SLOT(ReloadImage(QTreeWidgetItem*, int))); @@ -2712,61 +2879,48 @@ void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) { linkPanel->addImage(filename, id.toStdString()); - connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)), - this,SLOT(CurrentImageChanged(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))); - connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)), + connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)), + this, SLOT(CurrentImageChanged(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))); + connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)), this, SLOT(VectorChanged(int,double,double,double, double))); - connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)), + connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)), this, SLOT(OverlayChanged(int,double,double))); - connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)), + connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)), this, SLOT(FusionChanged(int,double))); - connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)), + connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)), this,SLOT(WindowsChanged(int, int, int))); - connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)), + connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)), this,SLOT(WindowLevelChanged(double, double, int, int))); - connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)), + connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)), this,SLOT(UpdateSlice(int,int))); - connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)), + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), this,SLOT(UpdateTSlice(int, int))); - connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)), + connect(mSlicerManagers.back(), SIGNAL(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)), + connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)), this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); - connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); + connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)), + this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); + connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); UpdateTree(); qApp->processEvents(); InitSlicers(); ShowLastImage(); InitDisplay(); qApp->processEvents(); - - // vvToolManager::GetInstance()->UpdateEnabledTool(); - // emit SlicerManagersHasChanged(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -vvMainWindowToolInfo * vvMainWindow::GetInfoForTool() { - DD("GetInfoForTool"); - if (mCurrentToolInfo ==0) mCurrentToolInfo = new vvMainWindowToolInfo; - - mCurrentToolInfo->mMenuTools = menuTools; - mCurrentToolInfo->mSlicerManagers = &mSlicerManagers; +void vvMainWindow::UpdateCurrentSlicer() { int index = -1; - DD(DataTree->selectedItems().size()); if (DataTree->selectedItems().size() > 0) { index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - DD(DataTree->selectedItems()[0]); - DD(index); } - mCurrentToolInfo->mSlicerManagerCurrentIndex = index; - - return mCurrentToolInfo; + mSlicerManagerCurrentIndex = index; } //------------------------------------------------------------------------------ -