]> Creatis software - clitk.git/commitdiff
Added linked navigation (zoom and pan)
authorsrit <srit>
Tue, 22 Jun 2010 13:35:42 +0000 (13:35 +0000)
committersrit <srit>
Tue, 22 Jun 2010 13:35:42 +0000 (13:35 +0000)
vv/vvInteractorStyleNavigator.cxx
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvSlicerManagerCommand.cxx

index e161cc08c24758f0e73dec236e42960e8808101e..4363adf32d991c09cb9f9c07a1243c4072edad5c 100644 (file)
@@ -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);
 }
 
 
index c0abea3568925f6f8d698f48b143de4f20ee854f..abdbd1ae45393729c662180780208c0373505500 100644 (file)
@@ -849,6 +849,8 @@ void vvMainWindow::LoadImages(std::vector<std::string> 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()));
index be50cb74dee6a2b61c897b28c71711befba74f42..ffae061112b828f7bd3fc5db982183eb0394a32b 100644 (file)
@@ -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);
index 55efda3965169896acfe11ffa5bdbeea91efeb37..c8964201ddf5923aace50401f822dcfe1941dac2 100644 (file)
@@ -40,6 +40,7 @@ It is distributed under dual licence
 #include <vtkLODActor.h>
 #include <vtkPointData.h>
 #include <vtksys/SystemTools.hxx>
+#include <vtkCamera.h>
 
 //----------------------------------------------------------------------------
 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<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++)
+        emit UpdateLinkedNavigation(*i, this);
+  }
+  Render();
+}
+//----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
 double vvSlicerManager::GetColorWindow()
index 5eaaa57ce389bfd2fa9d3b7fe2bc8a6c87af2517..afefa807c26873532bbb93f403168b64cdc220b7 100644 (file)
@@ -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);
index 5b1ad270442ecce2dc4267400b5c4991b1775b03..068de40927ed7a5611d013ec21e945ed1a16ce06 100644 (file)
@@ -189,15 +189,14 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
           return;
         }
         if (KeyPress == "x") {
-         for(int i=0;i<SM->NumberOfSlicers();i++)
-         {
-          SM->RemoveActor("overlay",0);
-          SM->SetColorMap(0);
-          SM->Render();
-         }
-          return;
-       }
-       if (KeyPress == "u") {
+          for(int i=0; i<SM->NumberOfSlicers(); 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();