X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=9914710cdaddf8067d6a834ad15a5057604cfcdd;hb=2dad4a649b5e61f450b47047f379fcc351b50215;hp=422f3ef977cc3c3ed2db42e7718e288f390d14ee;hpb=95b2888f075a2873e583c6e818716ac8381bee0f;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 422f3ef..9914710 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -33,7 +33,6 @@ #include "vvSlicer.h" #include "vvInteractorStyleNavigator.h" #include "vvImageWriter.h" -#include "vvResamplerDialog.h" #include "vvSegmentationDialog.h" #include "vvSurfaceViewerDialog.h" #include "vvDeformationDialog.h" @@ -255,8 +254,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())); /////////////////////////////////////////////// @@ -881,29 +878,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++; @@ -1306,6 +1304,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); @@ -1313,6 +1323,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) { @@ -2328,6 +2341,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++) @@ -2378,7 +2406,8 @@ 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]->UpdateSlice(0); + // <-- DS add this. Not too much update ? YES. break; } } @@ -2687,16 +2716,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]); @@ -2716,18 +2735,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()); @@ -2764,30 +2776,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();