From: srit Date: Tue, 22 Jun 2010 13:35:42 +0000 (+0000) Subject: Added linked navigation (zoom and pan) X-Git-Tag: v1.2.0~608 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0b04af7278ad344a167c4e8d99e6e67c535f0d95;p=clitk.git Added linked navigation (zoom and pan) --- diff --git a/vv/vvInteractorStyleNavigator.cxx b/vv/vvInteractorStyleNavigator.cxx index e161cc0..4363adf 100644 --- a/vv/vvInteractorStyleNavigator.cxx +++ b/vv/vvInteractorStyleNavigator.cxx @@ -472,7 +472,9 @@ void vvInteractorStyleNavigator::Pan() this->CurrentRenderer->UpdateLightsGeometryToFollowCamera(); } - rwi->Render(); + this->InvokeEvent(vtkCommand::EndInteractionEvent, this); + +// rwi->Render(); } //---------------------------------------------------------------------------- @@ -557,6 +559,8 @@ void vvInteractorStyleNavigator::Dolly(double factor) } this->CurrentRenderer->ResetCameraClippingRange(); //this->Interactor->Render(); + + this->InvokeEvent(vtkCommand::EndInteractionEvent, this); } diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index c0abea3..abdbd1a 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -849,6 +849,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(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)), this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int))); connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); @@ -1606,6 +1608,8 @@ void vvMainWindow::SplitImage() 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(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); UpdateTree(); qApp->processEvents(); @@ -1725,6 +1729,17 @@ void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, doubl } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm) +{ + for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { + if (id == mSlicerManagers[i]->GetId()) { + mSlicerManagers[i]->UpdateLinkedNavigation(sm->GetSlicer(0)); + } + } +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::ShowContextMenu(QPoint point) { @@ -2301,23 +2316,21 @@ void vvMainWindow::NOVerticalSliderChanged() 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) - { - if (mSlicerManagers[i]->GetSlicer(0)->GetSlice() != value) { - mSlicerManagers[i]->GetSlicer(0)->SetSlice(value); - mSlicerManagers[i]->VerticalSliderHasChanged(0, value); - - // If nor Update/Render -> slider not work - // only render = ok navigation, but for contour Update needed but slower ? - - 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; - } + for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { + if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1) { + if (mSlicerManagers[i]->GetSlicer(0)->GetSlice() != value) { + mSlicerManagers[i]->GetSlicer(0)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(0, value); + + // If nor Update/Render -> slider not work + // only render = ok navigation, but for contour Update needed but slower ? + + 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; } + } } //------------------------------------------------------------------------------ @@ -2734,6 +2747,8 @@ void vvMainWindow::AddImage(vvImage::Pointer image,std::string filename) 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(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 be50cb7..ffae061 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -102,6 +102,7 @@ public slots: void UpdateWindowLevel(); void SwitchWindowLevel(); void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps); + void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm); void AddLink(QString image1,QString image2); void RemoveLink(QString image1,QString image2); void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset); diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 55efda3..c896420 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -40,6 +40,7 @@ It is distributed under dual licence #include #include #include +#include //---------------------------------------------------------------------------- vvSlicerManager::vvSlicerManager(int numberOfSlicers) @@ -418,6 +419,8 @@ void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* sty // GetInteractorStyle()->AddObserver(vtkCommand::LeftButtonReleaseEvent, smc); mSlicers[i]->GetRenderWindow()->GetInteractor()-> GetInteractorStyle()->AddObserver(vtkCommand::EndPickEvent, smc); + mSlicers[i]->GetRenderWindow()->GetInteractor()-> + GetInteractorStyle()->AddObserver(vtkCommand::EndInteractionEvent, smc); smc->Delete(); } //---------------------------------------------------------------------------- @@ -665,6 +668,72 @@ void vvSlicerManager::UpdateLinked(int slicer) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate) +{ + for ( unsigned int i = 0; i < mSlicers.size(); i++) { + vtkCamera *camera = mSlicers[i] ->GetRenderer()->GetActiveCamera(); + vtkCamera *refCam = slicer->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()) { + for(int i=0; i<3; i++) { + position[i] = refPosition[i]; + focal[i] = refFocal[i]; + } + } + + if(slicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XY) { + if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XZ) { + position[0] = refPosition[0]; + focal[0] = refFocal[0]; + } + if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_YZ) { + position[1] = refPosition[1]; + focal[1] = refFocal[1]; + } + } + + if(slicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XZ) { + if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_YZ) { + position[2] = refPosition[2]; + focal[2] = refFocal[2]; + } + if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XY) { + position[0] = refPosition[0]; + focal[0] = refFocal[0]; + } + } + + if(slicer->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_YZ) { + if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XY) { + position[1] = refPosition[1]; + focal[1] = refFocal[1]; + } + if(mSlicers[i]->GetSliceOrientation()==vtkImageViewer2::SLICE_ORIENTATION_XZ) { + position[2] = refPosition[2]; + focal[2] = refFocal[2]; + } + } + + camera->SetFocalPoint(focal); + camera->SetPosition(position); + + if(bPropagate) + for (std::list::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) + emit UpdateLinkedNavigation(*i, this); + } + Render(); +} +//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- double vvSlicerManager::GetColorWindow() diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 5eaaa57..afefa80 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -158,6 +158,7 @@ class vvSlicerManager : public QObject { void SetCursorVisibility(int s); void UpdateViews(int current, int slicer); void UpdateLinked(int slicer); + void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false); void Render(); void AddLink(std::string newId) { @@ -202,6 +203,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 LandmarkAdded(); void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset); void LeftButtonReleaseSignal(int slicer); diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 5b1ad27..068de40 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -189,15 +189,14 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, return; } if (KeyPress == "x") { - for(int i=0;iNumberOfSlicers();i++) - { - SM->RemoveActor("overlay",0); - SM->SetColorMap(0); - SM->Render(); - } - return; - } - if (KeyPress == "u") { + for(int i=0; iNumberOfSlicers(); i++) { + SM->RemoveActor("overlay",0); + SM->SetColorMap(0); + SM->Render(); + } + return; + } + if (KeyPress == "u") { this->SM->Reload(); this->SM->Render(); return; @@ -300,6 +299,10 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, mStartSlicer = -1; } + if (event == vtkCommand::EndInteractionEvent) { + this->SM->UpdateLinkedNavigation(this->SM->GetSlicer(VisibleInWindow),true); + return; + } } if (VisibleInWindow > -1) { this->SM->Activated();