]> Creatis software - clitk.git/commitdiff
Romulo:
authordsarrut <dsarrut>
Fri, 1 Apr 2011 09:59:55 +0000 (09:59 +0000)
committerdsarrut <dsarrut>
Fri, 1 Apr 2011 09:59:55 +0000 (09:59 +0000)
- 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
vv/vvMainWindow.h
vv/vvSlicer.cxx
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvSlicerManagerCommand.cxx

index 885201ba6572ea8c15c39840c1937cf1892b76ff..4671d65622413a1e74aad15cdd442165f71d3d7c 100644 (file)
@@ -886,8 +886,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(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()));
index fa61855e1fc99b331b9a39444c51421fd562419a..5cd52f711f40b504a3f3e7dad953fb5d83d4c1d1 100644 (file)
@@ -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);
index 77f75356314da830272042bfd5754b23d4a8a6e4..1c486bc786213e22bc1e7d82342dbf2a04ed8644 100644 (file)
@@ -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();
 }
 //----------------------------------------------------------------------------
 
index 1daee2c666332458ffba9e6f722d31c5b8f7c1f9..0278de0e6d0d8443f99d2261a7e72dcb62af0f6b 100644 (file)
@@ -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<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++)
-      emit UpdateLinkedNavigation(*i, this);
+      emit UpdateLinkedNavigation(*i, this, refSlicer);
 }
 //----------------------------------------------------------------------------
 
index ea079c426bb359dd6ebf1d41282d1d8f31e7ce6c..eda2d227a2ead7e85b76b7f7be4a82e22ae430d5 100644 (file)
@@ -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);
index 6f59659364a712f02f07abaf08479bf0122a477c..7415116f071e52eab1fc8a76dab06f76ca1f95bb 100644 (file)
@@ -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;