]> Creatis software - clitk.git/blobdiff - vv/vvSlicerManager.cxx
Managed opening sequence of overlay images. Parser is ready for
[clitk.git] / vv / vvSlicerManager.cxx
index ee1c084568714d56387f3612374a9c302e4885e4..9a51c4b0a427cc5bb950cae079c77853f0662287 100644 (file)
@@ -242,9 +242,9 @@ bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReade
 
 
 //----------------------------------------------------------------------------
-bool vvSlicerManager::SetOverlay(std::string filename,int dim, std::string component)
+bool vvSlicerManager::SetOverlay(std::vector<std::string> filenames,int dim, std::string component)
 {
-  mOverlayName = filename;
+  mOverlayName = filenames[0];
   mOverlayComponent = component;
   if (dim > mImage->GetNumberOfDimensions()) {
     mLastError = " Overlay dimension cannot be greater then reference image!";
@@ -252,8 +252,6 @@ bool vvSlicerManager::SetOverlay(std::string filename,int dim, std::string compo
   }
   if (mOverlayReader.IsNull())
     mOverlayReader = vvImageReader::New();
-  std::vector<std::string> filenames;
-  filenames.push_back(filename);
   mOverlayReader->SetInputFilenames(filenames);
   mOverlayReader->Update(mImage->GetNumberOfDimensions(),component.c_str(),mType);
   if (mOverlayReader->GetLastError().size() == 0) {
@@ -686,9 +684,7 @@ void vvSlicerManager::UpdateLinked(int slicer)
       z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 &&
       z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) {
     for (std::list<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) {
-      emit UpdateLinkManager(*i, slicer,mSlicers[slicer]->GetCurrentPosition()[0],
-                             mSlicers[slicer]->GetCurrentPosition()[1],
-                             mSlicers[slicer]->GetCurrentPosition()[2],mSlicers[slicer]->GetTSlice());
+      emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], mSlicers[slicer]->GetTSlice());
     }
   }
 }
@@ -698,14 +694,15 @@ void vvSlicerManager::UpdateLinked(int slicer)
 void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagate)
 {
   vtkCamera *refCam = refSlicer->GetRenderer()->GetActiveCamera();
-  double refPosition[3], refFocal[3];
+
+  double refPosition[3];
   refCam->GetPosition(refPosition);
-  refCam->GetFocalPoint(refFocal);
-  
-  refSlicer->GetSlicingTransform()->TransformPoint(refPosition);
-  refSlicer->GetSlicingTransform()->TransformPoint(refFocal);
-  mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refPosition);
-  mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refFocal);
+  refPosition[refSlicer->GetSliceOrientation()] = refSlicer->GetSlice() *
+      refSlicer->GetInput()->GetSpacing()[refSlicer->GetSliceOrientation()] +
+      refSlicer->GetInput()->GetOrigin()[refSlicer->GetSliceOrientation()];
+
+  refSlicer->GetSlicingTransform()->TransformPoint(refPosition, refPosition);
+  mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refPosition, refPosition);
 
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {
     vtkCamera *camera = mSlicers[i]->GetRenderer()->GetActiveCamera();
@@ -715,51 +712,15 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat
     camera->GetPosition(position);
     camera->GetFocalPoint(focal);
 
-    if(refSlicer->GetSliceOrientation()==mSlicers[i]->GetSliceOrientation()) {
-      for(int i=0; i<3; i++) {
-        position[i] = refPosition[i];
-        focal[i]    = refFocal[i];
-      }
-    }
-
-    if(refSlicer->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(refSlicer->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];
+    for(int j=0; j<3; j++) {
+      if(j!=mSlicers[i]->GetSliceOrientation()) {
+        position[j] = refPosition[j];
+        focal[j]    = refPosition[j];
       }
     }
 
-    if(refSlicer->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];
-      }
-    }
-DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2])
     camera->SetFocalPoint(focal);
-DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2])
-DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2])
     camera->SetPosition(position);
-DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2])
 
     //Fix for bug #243
     mSlicers[i]->ForceUpdateDisplayExtent();
@@ -1183,19 +1144,20 @@ void vvSlicerManager::SetPreset(int preset)
 void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey)
 {
   double min, max;
-  int t = this->GetTSlice();
   if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) {
+    int t = mSlicers[slicer]->GetFusionTSlice();
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t],
-                                                          this->mSlicers[slicer]->GetFusion()->GetTransform()[t]);
+                                                          this->mSlicers[slicer]->GetConcatenatedFusionTransform());
     this->SetFusionWindow(max-min);
     this->SetFusionLevel(0.5*(min+max));
     this->SetColorMap(mColorMap);
   }
   else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) {
+    int t = mSlicers[slicer]->GetOverlayTSlice();
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t],
-                                                          this->mSlicers[slicer]->GetOverlay()->GetTransform()[t]);
+                                                          this->mSlicers[slicer]->GetConcatenatedOverlayTransform());
     if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){
       this->SetColorWindow(max-min);
       this->SetColorLevel(0.5*(min+max));
@@ -1205,6 +1167,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK
     }
   }
   else {
+    int t = this->GetTSlice();
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetImage()->GetVTKImages()[t],
                                                           this->mSlicers[slicer]->GetConcatenatedTransform());