]> Creatis software - clitk.git/blobdiff - vv/vvSlicer.cxx
added window/level preset for head/brain
[clitk.git] / vv / vvSlicer.cxx
index eafc3fac1670d194e46f11121f83bd772b258809..efaf80fde672006a3926428eb8b271163bd30eb5 100644 (file)
@@ -81,7 +81,7 @@ static void copyExtent(int* in, int* to){
 //------------------------------------------------------------------------------
 vvSlicer::vvSlicer()
 {
-       mFusionSequenceFlag = false;
+       mFusionSequenceCode = -1;
   this->UnInstallPipeline();
   mImage = NULL;
   mReducedExtent = new int[6];
@@ -312,7 +312,7 @@ void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
   mCurrentBeforeSlicingTransform[1]=y;
   mCurrentBeforeSlicingTransform[2]=z;
   mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
-  SetTSlice(t);
+  if (t>=0) SetTSlice(t);
 }
 //------------------------------------------------------------------------------
 
@@ -415,9 +415,9 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay)
 
 
 //------------------------------------------------------------------------------
-void vvSlicer::SetFusion(vvImage::Pointer fusion, bool fusionSequenceFlag)
+void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
 {
-       mFusionSequenceFlag = fusionSequenceFlag;
+       mFusionSequenceCode = fusionSequenceCode;
   if (fusion->GetVTKImages().size()) {
     mFusion = fusion;
 
@@ -755,7 +755,7 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
     }
   }
   //update the fusion ; except in case this is a fusionSequence, in which case both 'times' should be independent.
-  if (mFusion && mFusionActor->GetVisibility() && !mFusionSequenceFlag) {
+  if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode<0)) {
     if (mFusion->GetVTKImages().size() > (unsigned int)t) {
       mCurrentFusionTSlice = t;
       mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
@@ -778,7 +778,7 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
 //------------------------------------------------------------------------------
 void vvSlicer::SetFusionSequenceTSlice(int t)
 {
-  if (mFusion && mFusionActor->GetVisibility() && mFusionSequenceFlag) {
+  if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode>=0)) {
     if (mFusion->GetVTKImages().size() > (unsigned int)t) {
       mCurrentFusionTSlice = t;
       mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
@@ -807,7 +807,7 @@ int vvSlicer::GetMaxCurrentTSlice()
   int t = mCurrentTSlice;
   if(mOverlay)
     t = std::max(t, mCurrentOverlayTSlice);
-  if(mFusion&& (!mFusionSequenceFlag)) //ignore fusionSequence data: for these, the times are not to be related (this way)
+  if(mFusion&& (mFusionSequenceCode<0)) //ignore fusionSequence data: for these, the times are not to be related (this way)
     t = std::max(t, mCurrentFusionTSlice);
   return t;
 }
@@ -1183,9 +1183,8 @@ void vvSlicer::ResetCamera()
 //----------------------------------------------------------------------------
 void vvSlicer::SetDisplayMode(bool i)
 {
-  this->GetRenderer()->SetDraw(i);
-  if (i)
-    UpdateDisplayExtent();
+       this->GetRenderer()->SetDraw(i);
+       if (i) UpdateDisplayExtent();
 }
 //----------------------------------------------------------------------------
 
@@ -1361,8 +1360,6 @@ double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, doubl
   iy = lrint(Y);
   iz = lrint(Z);
 
-  image->UpdateInformation();
-
   if (ix < image->GetWholeExtent()[0] ||
       ix > image->GetWholeExtent()[1] ||
       iy < image->GetWholeExtent()[2] ||
@@ -1435,12 +1432,12 @@ void vvSlicer::Render()
     double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
     double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
 
-    if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
-        xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
-        yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
-        yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
-        zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
-        zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
+    if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0]-0.5 &&
+        xCursor < this->GetImageActor()->GetDisplayExtent()[1]+0.5 &&
+        yCursor >= this->GetImageActor()->GetDisplayExtent()[2]-0.5 &&
+        yCursor < this->GetImageActor()->GetDisplayExtent()[3]+0.5 &&
+        zCursor >= this->GetImageActor()->GetDisplayExtent()[4]-0.5 &&
+        zCursor < this->GetImageActor()->GetDisplayExtent()[5]+0.5 ) {
       vtkRenderer * renderer = this->Renderer;
 
       renderer->WorldToView(x,y,z);