X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=abf38e98fe2d55f4533cef82e3c58a7922948ad9;hb=e7f88877b4e3d136e9cfa08613490df94e2728d7;hp=1dbd8e4575fadbeeccfd645091ec3b147139c442;hpb=10ec7dc09aeea303fdc6a30449ec69de2f2ccd88;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 1dbd8e4..abf38e9 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/03/10 15:36:26 $ - Version: $Revision: 1.16 $ - 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 @@ -43,7 +33,6 @@ #include "vvSlicer.h" #include "vvInteractorStyleNavigator.h" #include "vvImageWriter.h" -#include "vvResamplerDialog.h" #include "vvSegmentationDialog.h" #include "vvSurfaceViewerDialog.h" #include "vvDeformationDialog.h" @@ -112,41 +101,44 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { mInputPathName = ""; 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")), + // 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); @@ -156,7 +148,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { 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); @@ -167,6 +159,21 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { 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); @@ -248,8 +255,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { 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())); /////////////////////////////////////////////// @@ -307,11 +312,11 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { 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())); @@ -320,6 +325,9 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { // Adding all new tools (insertion in the menu) vvToolManager::GetInstance()->InsertToolsInMenu(this); + + if (!CLITK_EXPERIMENTAL) + menuExperimental->menuAction()->setVisible(false); } //------------------------------------------------------------------------------ @@ -331,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"); } //------------------------------------------------------------------------------ @@ -382,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))); @@ -390,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)), @@ -439,7 +448,7 @@ 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()) @@ -745,6 +754,8 @@ void vvMainWindow::OpenRecentImage() mInputPathName = itksys::SystemTools::GetFilenamePath(images[0]).c_str(); LoadImages(images,IMAGE); } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::OpenImageWithTime() { @@ -764,6 +775,7 @@ void vvMainWindow::OpenImageWithTime() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::LoadImages(std::vector files, LoadedImageType filetype) { //Separate the way to open images and dicoms @@ -799,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) { @@ -830,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))); @@ -838,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))); @@ -853,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++; @@ -893,6 +920,17 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi } QApplication::restoreOverrideCursor(); + // 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 + } } //------------------------------------------------------------------------------ @@ -1278,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); @@ -1285,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) { @@ -1622,7 +1675,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))); @@ -1630,7 +1683,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))); @@ -1885,7 +1938,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))); @@ -1893,7 +1946,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))); @@ -1975,7 +2028,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))); @@ -1983,7 +2036,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))); @@ -2015,8 +2068,10 @@ void vvMainWindow::AddFusionImage() } } } +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void vvMainWindow::OpenField() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2037,7 +2092,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 @@ -2060,7 +2118,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))); @@ -2069,7 +2127,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))); @@ -2086,7 +2144,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)); @@ -2103,7 +2164,10 @@ void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index) } QApplication::restoreOverrideCursor(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddField(QString file,int index) { if (QFile::exists(file)) @@ -2139,6 +2203,7 @@ void vvMainWindow::AddField(QString file,int index) } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2157,6 +2222,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SetOverlayProperty(int color) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2300,6 +2366,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++) @@ -2317,28 +2398,41 @@ 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(); } //------------------------------------------------------------------------------ @@ -2350,13 +2444,16 @@ void vvMainWindow::NOVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(0)->SetSlice(value); - mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? + mSlicerManagers[i]->VerticalSliderHasChanged(0, value); + // mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES. + mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::NEVerticalSliderChanged() { int value = NEVerticalSlider->value(); @@ -2365,12 +2462,15 @@ void vvMainWindow::NEVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(1)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(1, value); + mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SOVerticalSliderChanged() { int value = SOVerticalSlider->value(); @@ -2379,12 +2479,15 @@ void vvMainWindow::SOVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(2)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(2, value); + mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SEVerticalSliderChanged() { int value = SEVerticalSlider->value(); @@ -2393,12 +2496,15 @@ void vvMainWindow::SEVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(3)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(3, value); + 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) { @@ -2414,6 +2520,7 @@ void vvMainWindow::UpdateSlice(int slicer, int slice) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateTSlice(int slicer, int slice) { switch (slicer) @@ -2434,6 +2541,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); @@ -2469,6 +2577,7 @@ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveNOScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2479,6 +2588,7 @@ void vvMainWindow::SaveNOScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveNEScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2489,6 +2599,7 @@ void vvMainWindow::SaveNEScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveSOScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2499,6 +2610,7 @@ void vvMainWindow::SaveSOScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveSEScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2509,6 +2621,7 @@ void vvMainWindow::SaveSEScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveScreenshot(vtkImageData* image) { QString Extensions = "Images( *.png);;"; @@ -2573,6 +2686,7 @@ void vvMainWindow::SaveScreenshot(vtkImageData* image) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::GoToCursor() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2596,7 +2710,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; } @@ -2613,7 +2727,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())); } } @@ -2659,16 +2773,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]); @@ -2688,18 +2792,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()); @@ -2713,14 +2810,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))); @@ -2736,30 +2833,31 @@ 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();