From a0b0efabb1aadd2422cb32f4173f3ffecc041ab0 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Fri, 1 Apr 2011 09:59:55 +0000 Subject: [PATCH] Romulo: - Finally solved bug 243 (moving linked images) + when propagating, vvMainWindow::UpdateLinkedNavigation was always using slicer[0] as the reference. Now, the reference vvSlicer is passed as an argument from vvSlicerManager::UpdateLinkedNavigation. - More corrections wrt bug 283 - cursor rendering... (accidentally removed from the bug tracker) + better treatment of cursor rendering when images are linked + there are still corrections to be made wrt to the corner annotations. --- vv/vvMainWindow.cxx | 18 ++++++------ vv/vvMainWindow.h | 3 +- vv/vvSlicer.cxx | 12 +++++++- vv/vvSlicerManager.cxx | 52 +++++++++++++++-------------------- vv/vvSlicerManager.h | 6 +++- vv/vvSlicerManagerCommand.cxx | 17 ++++++------ 6 files changed, 58 insertions(+), 50 deletions(-) diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 885201b..4671d65 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -886,8 +886,8 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi this,SLOT(UpdateSliceRange(int,int,int,int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)), this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); - connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*)), - this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*))); + connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*)), + this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*))); connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)), this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); @@ -1699,11 +1699,11 @@ void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, doubl //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm) +void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm, vvSlicer* refSlicer) { for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { if (id == mSlicerManagers[i]->GetId()) { - mSlicerManagers[i]->UpdateLinkedNavigation(sm->GetSlicer(0)); + mSlicerManagers[i]->UpdateLinkedNavigation(refSlicer); } } } @@ -2236,11 +2236,11 @@ void vvMainWindow::AddLink(QString image1,QString image2) } if (linkPanel->isLinkAll()) { - emit UpdateLinkedNavigation(mSlicerManagers[sm1]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]); - emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]); + emit UpdateLinkedNavigation(mSlicerManagers[sm1]->GetId(), mSlicerManagers[mCurrentPickedImageIndex], mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(0)); + emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[mCurrentPickedImageIndex], mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(0)); } else { - emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[sm1]); + emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[sm1], mSlicerManagers[sm1]->GetSlicer(0)); } } @@ -2793,8 +2793,8 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen this,SLOT(UpdateSliceRange(int,int,int,int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)), this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int))); - connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*)), - this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*))); + connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*)), + this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*,vvSlicer*))); connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)), this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index fa61855..5cd52f7 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -39,6 +39,7 @@ class vtkImageData; class vtkRenderer; class vtkMatrix4x4; class vvDicomSeriesSelector; +class vvSlicer; //------------------------------------------------------------------------------ class vvMainWindow: public vvMainWindowBase, @@ -110,7 +111,7 @@ public slots: void SwitchWindowLevel(); void ApplyWindowLevelToAllImages(); void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps); - void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm); + void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer); void AddLink(QString image1,QString image2); void RemoveLink(QString image1,QString image2); void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 77f7535..1c486bc 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -1265,12 +1265,22 @@ void vvSlicer::Render() double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0]; double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1]; double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2]; + +// if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0]; +// else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1]; +// if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2]; +// else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3]; +// if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4]; +// else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5]; + if (X >= this->GetInput()->GetWholeExtent()[0] && X <= this->GetInput()->GetWholeExtent()[1] && Y >= this->GetInput()->GetWholeExtent()[2] && Y <= this->GetInput()->GetWholeExtent()[3] && Z >= this->GetInput()->GetWholeExtent()[4] && Z <= this->GetInput()->GetWholeExtent()[5]) { + + int ix, iy, iz; double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz); @@ -1390,7 +1400,7 @@ void vvSlicer::SetSlice(int slice) this->UpdateDisplayExtent(); // Seems to work without this line - // this->Render(); + //this->Render(); } //---------------------------------------------------------------------------- diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 1daee2c..0278de0 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -518,26 +518,21 @@ void vvSlicerManager::UpdateViews(int current,int slicer) switch (mSlicers[slicer]->GetSliceOrientation()) { case vtkImageViewer2::SLICE_ORIENTATION_XY: - if (mSlicers[slicer]->GetSlice() == (int)floor(z)) - mSlicers[slicer]->Render(); - else + if (mSlicers[slicer]->GetSlice() != (int)floor(z)) mSlicers[slicer]->SetSlice((int)floor(z)); break; case vtkImageViewer2::SLICE_ORIENTATION_XZ: - if (mSlicers[slicer]->GetSlice() == (int)floor(y)) - mSlicers[slicer]->Render(); - else + if (mSlicers[slicer]->GetSlice() != (int)floor(y)) mSlicers[slicer]->SetSlice((int)floor(y)); break; case vtkImageViewer2::SLICE_ORIENTATION_YZ: - if (mSlicers[slicer]->GetSlice() == (int)floor(x)) - mSlicers[slicer]->Render(); - else + if (mSlicers[slicer]->GetSlice() != (int)floor(x)) mSlicers[slicer]->SetSlice((int)floor(x)); break; } + mSlicers[slicer]->Render(); for ( unsigned int i = 0; i < mSlicers.size(); i++) { if (i != (unsigned int)slicer && mSlicers[i]->GetImageActor()->GetVisibility() @@ -557,26 +552,23 @@ void vvSlicerManager::UpdateViews(int current,int slicer) } switch (mSlicers[i]->GetSliceOrientation()) { case vtkImageViewer2::SLICE_ORIENTATION_XY: - if (mSlicers[i]->GetSlice() == (int)floor(z)) - mSlicers[i]->Render(); - else + if (mSlicers[i]->GetSlice() != (int)floor(z)) mSlicers[i]->SetSlice((int)floor(z)); break; case vtkImageViewer2::SLICE_ORIENTATION_XZ: - if (mSlicers[i]->GetSlice() == (int)floor(y)) - mSlicers[i]->Render(); - else + if (mSlicers[i]->GetSlice() != (int)floor(y)) mSlicers[i]->SetSlice((int)floor(y)); break; case vtkImageViewer2::SLICE_ORIENTATION_YZ: - if (mSlicers[i]->GetSlice() == (int)floor(x)) - mSlicers[i]->Render(); - else + if (mSlicers[i]->GetSlice() != (int)floor(x)) mSlicers[i]->SetSlice((int)floor(x)); break; } + + mSlicers[i]->Render(); + UpdateSlice(i); UpdateTSlice(i); } @@ -612,29 +604,29 @@ void vvSlicerManager::UpdateLinked(int slicer) //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- -void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate) +void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagate) { + vtkCamera *refCam = refSlicer->GetRenderer()->GetActiveCamera(); + double refPosition[3], refFocal[3]; + refCam->GetPosition(refPosition); + refCam->GetFocalPoint(refFocal); + for ( unsigned int i = 0; i < mSlicers.size(); i++) { - vtkCamera *camera = mSlicers[i] ->GetRenderer()->GetActiveCamera(); - vtkCamera *refCam = slicer->GetRenderer()->GetActiveCamera(); + vtkCamera *camera = mSlicers[i]->GetRenderer()->GetActiveCamera(); camera->SetParallelScale(refCam->GetParallelScale()); double position[3], focal[3]; camera->GetPosition(position); camera->GetFocalPoint(focal); - double refPosition[3], refFocal[3]; - refCam->GetPosition(refPosition); - refCam->GetFocalPoint(refFocal); - - if(slicer->GetSliceOrientation()==mSlicers[i]->GetSliceOrientation()) { + if(refSlicer->GetSliceOrientation()==mSlicers[i]->GetSliceOrientation()) { for(int i=0; i<3; i++) { position[i] = refPosition[i]; focal[i] = refFocal[i]; } } - if(slicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XY) { + if(refSlicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XY) { if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XZ) { position[0] = refPosition[0]; focal[0] = refFocal[0]; @@ -645,7 +637,7 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate) } } - if(slicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XZ) { + if(refSlicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XZ) { if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_YZ) { position[2] = refPosition[2]; focal[2] = refFocal[2]; @@ -656,7 +648,7 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate) } } - if(slicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_YZ) { + if(refSlicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_YZ) { if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XY) { position[1] = refPosition[1]; focal[1] = refFocal[1]; @@ -677,7 +669,7 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate) Render(); if(bPropagate) for (std::list::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) - emit UpdateLinkedNavigation(*i, this); + emit UpdateLinkedNavigation(*i, this, refSlicer); } //---------------------------------------------------------------------------- diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index ea079c4..eda2d22 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -168,6 +168,10 @@ class vvSlicerManager : public QObject { void RemoveLink(std::string oldId) { mLinkedId.remove(oldId); } + + bool IsLinked() { + return mLinkedId.size() > 0; + } ///Remove the actor defined by its type and index (example: 3rd contour) void RemoveActor(const std::string& actor_type, int overlay_index); @@ -207,7 +211,7 @@ signals : void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax); void WindowLevelChanged(double window, double level, int preset, int colormap); void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps); - void UpdateLinkedNavigation(std::string, vvSlicerManager*); + void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*); void LandmarkAdded(); void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset); void LeftButtonReleaseSignal(int slicer); diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 6f59659..7415116 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -86,7 +86,8 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1) { for (int i = 0; i < this->SM->GetNumberOfSlicers(); i++) { - if (this->SM->GetSlicer(i)->GetCursorVisibility()) { + if (this->SM->GetSlicer(i)->GetCursorVisibility() && !this->SM->IsLinked()) { + this->SM->GetSlicer(i)->SetCursorVisibility(0); this->SM->GetSlicer(i)->SetCornerAnnotationVisibility(0); this->SM->GetSlicer(i)->Render(); } @@ -184,6 +185,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, return; } if (KeyPress == "h") { + std::cout << "KeyPress == \"h\"\n"; this->SM->SetCursorAndCornerAnnotationVisibility(0); this->SM->Render(); return; @@ -292,18 +294,17 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, } if (event == vtkCommand::EndInteractionEvent) { - this->SM->Picked(); + this->SM->Picked(); this->SM->UpdateLinkedNavigation(this->SM->GetSlicer(VisibleInWindow),true); return; } } if (VisibleInWindow > -1) { this->SM->Activated(); - //if(!this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->GetVisibility()) - this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetVisibility(1); + this->SM->GetSlicer(VisibleInWindow)->SetCornerAnnotationVisibility(1); if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey()) { - this->SM->Picked(); + this->SM->Picked(); this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1); this->SM->UpdateSlice(VisibleInWindow); } else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey()) { @@ -311,7 +312,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, this->Dolly(pow((double)1.1, factor),isi->GetInteractor()); Execute(caller, vtkCommand::EndInteractionEvent, NULL); } else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey()) { - this->SM->Picked(); + this->SM->Picked(); this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1); this->SM->UpdateSlice(VisibleInWindow); } else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey()) { @@ -363,7 +364,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, this->SM->Render(); } if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) { - this->SM->Picked(); + this->SM->Picked(); this->SM->UpdateViews(1,VisibleInWindow); this->SM->UpdateLinked(VisibleInWindow); this->SM->UpdateInfoOnCursorPosition(VisibleInWindow); @@ -376,7 +377,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, } if (event == vtkCommand::WindowLevelEvent && mStartSlicer > -1) { - this->SM->GetSlicer(mStartSlicer)->GetAnnotation()->SetVisibility(1); + this->SM->GetSlicer(mStartSlicer)->SetCornerAnnotationVisibility(1); // Adjust the window level here int *size = isi->GetInteractor()->GetRenderWindow()->GetSize(); double window = this->InitialWindow; -- 2.45.1