1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
21 #include "vvSlicerManagerCommand.h"
22 #include "vvGlyphSource.h"
23 #include "vvGlyph2D.h"
24 #include "vvImageMapToWLColors.h"
26 #include <vtkTextProperty.h>
27 #include <vtkTextActor.h>
28 #include <vtkTextSource.h>
29 #include <vtkActor2D.h>
30 #include <vtkCursor2D.h>
31 #include <vtkPolyDataMapper2D.h>
32 #include <vtkProperty2D.h>
33 #include <vtkCornerAnnotation.h>
34 #include <vtkImageMapToWindowLevelColors.h>
35 #include <vtkImageData.h>
36 #include <vtkImageActor.h>
37 #include <vvBlendImageActor.h>
38 #include <vtkToolkits.h>
39 #include <vtkObjectFactory.h>
40 #include <vtkPointData.h>
41 #include <vtkDataArray.h>
42 #include <vtkFloatArray.h>
43 #include <vtkClipPolyData.h>
44 #include <vtkGlyph3D.h>
46 #include <vtkCursor3D.h>
47 #include <vtkProperty.h>
49 #include <vtkLightCollection.h>
50 #include <vtkScalarBarActor.h>
51 #include <vtkLookupTable.h>
53 #include <vtkRenderer.h>
54 #include <vtkRendererCollection.h>
55 #include <vtkRenderWindow.h>
56 #include <vtkRenderWindowInteractor.h>
57 #include <vtkCamera.h>
58 #include <vtkCallbackCommand.h>
59 #include <vtkCommand.h>
60 #include <vtkPolyDataMapper.h>
63 #include <vtkExtractVOI.h>
64 #include <vtkSphereSource.h>
65 #include <vtkCutter.h>
66 #include <vtkAssignAttribute.h>
67 #include <vtkImageAccumulate.h>
68 #include <vtkImageReslice.h>
70 vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
71 vtkStandardNewMacro(vvSlicer);
72 static void copyExtent(int* in, int* to){
73 for(int i=0; i<6; ++i) to[i]=in[i];
75 //------------------------------------------------------------------------------
78 this->UnInstallPipeline();
80 mReducedExtent = new int[6];
82 mUseReducedExtent = false;
84 mCurrent[0] = -VTK_DOUBLE_MAX;
85 mCurrent[1] = -VTK_DOUBLE_MAX;
86 mCurrent[2] = -VTK_DOUBLE_MAX;
88 mCursor[0] = -VTK_DOUBLE_MAX;
89 mCursor[1] = -VTK_DOUBLE_MAX;
90 mCursor[2] = -VTK_DOUBLE_MAX;
91 mCursor[3] = -VTK_DOUBLE_MAX;
101 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
102 crossCursor->AllOff();
103 crossCursor->AxesOn();
104 crossCursor->SetTranslationMode(1);
105 crossCursor->SetRadius(2);
107 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
108 pdm->SetInput(crossCursor->GetOutput());
110 pdmA = vtkSmartPointer<vtkActor2D>::New();
111 pdmA->SetMapper(pdm);
112 pdmA->GetProperty()->SetColor(255,10,212);
113 pdmA->SetVisibility(0);
114 pdmA->SetPickable(0);
116 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
117 ca->GetTextProperty()->SetColor(255,10,212);
118 ca->SetVisibility(1);
126 legend = vtkSmartPointer<vtkScalarBarActor>::New();
127 //legend->SetTitle("test!");
128 legend->SetPosition(0.82,0.18);
129 legend->SetWidth(0.1);
130 legend->SetVisibility(0);
131 legend->SetLabelFormat("%.1f");
132 this->GetRenderer()->AddActor(legend);
134 this->WindowLevel->Delete();
135 this->WindowLevel = vvImageMapToWLColors::New();
137 this->InstallPipeline();
139 mLinkOverlayWindowLevel = true;
141 //------------------------------------------------------------------------------
144 //------------------------------------------------------------------------------
145 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
147 return mOverlayMapper.GetPointer();
149 //------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------
153 vvBlendImageActor* vvSlicer::GetOverlayActor()
155 return mOverlayActor.GetPointer();
157 //------------------------------------------------------------------------------
160 //------------------------------------------------------------------------------
161 vtkImageMapToColors* vvSlicer::GetFusionMapper()
163 return mFusionMapper.GetPointer();
165 //------------------------------------------------------------------------------
168 //------------------------------------------------------------------------------
169 vtkImageActor* vvSlicer::GetFusionActor()
171 return mFusionActor.GetPointer();
173 //------------------------------------------------------------------------------
176 //------------------------------------------------------------------------------
177 vtkActor* vvSlicer::GetVFActor()
179 return mVFActor.GetPointer();
181 //------------------------------------------------------------------------------
184 //------------------------------------------------------------------------------
185 vtkCornerAnnotation* vvSlicer::GetAnnotation()
187 return ca.GetPointer();
189 //------------------------------------------------------------------------------
192 //------------------------------------------------------------------------------
193 void vvSlicer::EnableReducedExtent(bool b)
195 mUseReducedExtent = b;
197 //------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------
201 void vvSlicer::SetReducedExtent(int * ext)
203 copyExtent(ext, mReducedExtent);
205 //------------------------------------------------------------------------------
208 //------------------------------------------------------------------------------
209 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
212 mSurfaceCutActors.push_back(new vvMeshActor());
214 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
216 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
217 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
218 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
222 //------------------------------------------------------------------------------
225 //------------------------------------------------------------------------------
226 void vvSlicer::ToggleContourSuperposition()
228 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
229 i!=mSurfaceCutActors.end(); i++)
230 (*i)->ToggleSuperposition();
232 //------------------------------------------------------------------------------
235 //------------------------------------------------------------------------------
236 void vvSlicer::SetCursorColor(int r,int g, int b)
238 pdmA->GetProperty()->SetColor(r,g,b);
240 //------------------------------------------------------------------------------
243 //------------------------------------------------------------------------------
244 void vvSlicer::SetCursorVisibility(bool s)
246 pdmA->SetVisibility(s);
248 //------------------------------------------------------------------------------
251 //------------------------------------------------------------------------------
252 bool vvSlicer::GetCursorVisibility()
254 return pdmA->GetVisibility();
256 //------------------------------------------------------------------------------
259 //------------------------------------------------------------------------------
260 void vvSlicer::SetCornerAnnotationVisibility(bool s)
262 ca->SetVisibility(s);
264 //------------------------------------------------------------------------------
267 //------------------------------------------------------------------------------
268 bool vvSlicer::GetCornerAnnotationVisibility()
270 return ca->GetVisibility();
272 //------------------------------------------------------------------------------
275 //------------------------------------------------------------------------------
276 vvSlicer::~vvSlicer()
278 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
279 i!=mSurfaceCutActors.end(); i++)
281 delete [] mReducedExtent;
283 //------------------------------------------------------------------------------
286 //------------------------------------------------------------------------------
287 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
294 //------------------------------------------------------------------------------
297 //------------------------------------------------------------------------------
298 void vvSlicer::SetImage(vvImage::Pointer image)
300 if (image->GetVTKImages().size()) {
303 if (!mImageReslice) {
304 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
305 mImageReslice->SetInterpolationModeToLinear();
306 mImageReslice->AutoCropOutputOn();
307 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
309 mImageReslice->SetResliceTransform(mImage->GetTransform());
310 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
311 mImageReslice->UpdateInformation();
313 this->Superclass::SetInput(mImageReslice->GetOutput());
316 this->GetInput()->GetWholeExtent(extent);
318 // Prevent crash when reload -> change slice if outside extent
319 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
320 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
323 // Make sure that the required part image has been computed
324 extent[SliceOrientation*2] = Slice;
325 extent[SliceOrientation*2+1] = Slice;
326 mImageReslice->GetOutput()->SetUpdateExtent(extent);
327 mImageReslice->GetOutput()->Update();
329 this->UpdateDisplayExtent();
332 ca->SetText(0,mFileName.c_str());
335 //------------------------------------------------------------------------------
338 //------------------------------------------------------------------------------
339 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
341 if (overlay->GetVTKImages().size()) {
344 if (!mOverlayReslice) {
345 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
346 mOverlayReslice->SetInterpolationModeToLinear();
347 mOverlayReslice->AutoCropOutputOn();
348 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
350 mOverlayReslice->SetResliceTransform(mOverlay->GetTransform());
351 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
354 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
355 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
357 if (!mOverlayActor) {
358 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
359 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
360 mOverlayActor->SetPickable(0);
361 mOverlayActor->SetVisibility(true);
362 mOverlayActor->SetOpacity(0.5);
365 //stupid but necessary : the Overlay need to be rendered before fusion
367 this->GetRenderer()->RemoveActor(mFusionActor);
368 this->GetRenderer()->AddActor(mOverlayActor);
369 this->GetRenderer()->AddActor(mFusionActor);
371 this->GetRenderer()->AddActor(mOverlayActor);
373 //Synchronize orientation and slice
374 AdjustResliceToSliceOrientation(mOverlayReslice);
375 this->UpdateDisplayExtent();
376 this->SetTSlice(mCurrentTSlice);
379 //------------------------------------------------------------------------------
382 //------------------------------------------------------------------------------
383 void vvSlicer::SetFusion(vvImage::Pointer fusion)
385 if (fusion->GetVTKImages().size()) {
388 if (!mFusionReslice) {
389 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
390 mFusionReslice->SetInterpolationModeToLinear();
391 mFusionReslice->AutoCropOutputOn();
392 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
394 mFusionReslice->SetResliceTransform(mFusion->GetTransform());
395 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
398 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
400 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
402 lut->SetValueRange(0, 1);
403 lut->SetSaturationRange(0, 0);
405 mFusionMapper->SetLookupTable(lut);
406 mFusionMapper->SetInput(mFusionReslice->GetOutput());
409 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
410 mFusionActor->SetInput(mFusionMapper->GetOutput());
411 mFusionActor->SetPickable(0);
412 mFusionActor->SetVisibility(true);
413 mFusionActor->SetOpacity(0.7);
414 this->GetRenderer()->AddActor(mFusionActor);
417 //Synchronize orientation and slice
418 AdjustResliceToSliceOrientation(mFusionReslice);
419 this->UpdateDisplayExtent();
420 this->SetTSlice(mCurrentTSlice);
423 //------------------------------------------------------------------------------
426 //------------------------------------------------------------------------------
427 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
430 if (actor_type == "image") {
431 vis = this->ImageActor->GetVisibility();
433 else if (actor_type == "vector") {
434 vis = this->mVFActor->GetVisibility();
436 else if (actor_type == "overlay") {
437 vis = this->mOverlayActor->GetVisibility();
439 else if (actor_type == "fusion") {
440 vis = this->mFusionActor->GetVisibility();
442 else if (actor_type == "contour")
443 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
447 //------------------------------------------------------------------------------
449 //------------------------------------------------------------------------------
450 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
452 if (actor_type == "image") {
453 this->ImageActor->SetVisibility(vis);
455 else if (actor_type == "vector") {
456 this->mVFActor->SetVisibility(vis);
458 else if (actor_type == "overlay") {
459 this->mOverlayActor->SetVisibility(vis);
461 else if (actor_type == "fusion") {
462 this->mFusionActor->SetVisibility(vis);
464 else if (actor_type == "contour")
465 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
466 UpdateDisplayExtent();
468 //------------------------------------------------------------------------------
470 //------------------------------------------------------------------------------
471 void vvSlicer::SetVF(vvImage::Pointer vf)
473 if (vf->GetVTKImages().size()) {
477 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
478 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
479 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
481 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
482 mAAFilter->SetInput(mVOIFilter->GetOutput());
483 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
484 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
487 mArrow = vtkSmartPointer<vvGlyphSource>::New();
488 mArrow->SetGlyphTypeToSpecificArrow();
489 mArrow->SetScale(mScale);
492 // Glyph the gradient vector (with arrows)
494 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
495 mGlyphFilter->SetInput(mAAFilter->GetOutput());
496 mGlyphFilter->SetSource(mArrow->GetOutput());
497 mGlyphFilter->ScalingOn();
498 mGlyphFilter->SetScaleModeToScaleByVector();
499 mGlyphFilter->OrientOn();
500 mGlyphFilter->SetVectorModeToUseVector();
501 mGlyphFilter->SetColorModeToColorByVector();
504 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
506 double mVFColorHSV[3];
507 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
508 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
509 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
510 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
513 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
514 mVFMapper->SetInput(mGlyphFilter->GetOutput());
515 mVFMapper->ImmediateModeRenderingOn();
516 mVFMapper->SetLookupTable(mVFColorLUT);
519 mVFActor = vtkSmartPointer<vtkActor>::New();
520 mVFActor->SetMapper(mVFMapper);
521 mVFActor->SetPickable(0);
522 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
523 this->UpdateDisplayExtent();
524 this->GetRenderer()->AddActor(mVFActor);
527 SetTSlice(mCurrentTSlice);
530 //------------------------------------------------------------------------------
533 //------------------------------------------------------------------------------
534 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
536 mLandmarks = landmarks;
540 mCross = vtkSmartPointer<vtkCursor3D>::New();
541 mCross->SetFocalPoint(0.0,0.0,0.0);
542 mCross->SetModelBounds(-10,10,-10,10,-10,10);
547 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
548 mLandGlyph->SetSource(mCross->GetOutput());
549 mLandGlyph->SetInput(landmarks->GetOutput());
550 //mLandGlyph->SetIndexModeToScalar();
551 mLandGlyph->SetRange(0,1);
552 mLandGlyph->ScalingOff();
554 mLandGlyph->SetColorModeToColorByScalar();
557 mClipBox = vtkSmartPointer<vtkBox>::New();
559 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
560 mLandClipper->InsideOutOn();
561 mLandClipper->SetInput(mLandGlyph->GetOutput());
562 mLandClipper->SetClipFunction(mClipBox);
565 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
566 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
567 //mLandMapper->ScalarVisibilityOff();
570 mLandActor = vtkSmartPointer<vtkActor>::New();
571 mLandActor->SetMapper(mLandMapper);
572 mLandActor->GetProperty()->SetColor(255,10,212);
573 mLandActor->SetPickable(0);
574 mLandActor->SetVisibility(true);
575 this->UpdateDisplayExtent();
576 this->GetRenderer()->AddActor(mLandActor);
579 //------------------------------------------------------------------------------
581 //------------------------------------------------------------------------------
582 //FIXME: this function leaks memory, we should fix it someday :)
583 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
585 if (actor_type == "vector") {
586 Renderer->RemoveActor(mVFActor);
595 if (actor_type == "overlay") {
596 Renderer->RemoveActor(mOverlayActor);
598 mOverlayActor = NULL;
599 mOverlayMapper = NULL;
601 if (actor_type == "fusion") {
602 Renderer->RemoveActor(mFusionActor);
605 mFusionMapper = NULL;
607 if (actor_type == "contour") {
608 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
609 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
612 //------------------------------------------------------------------------------
615 //------------------------------------------------------------------------------
616 void vvSlicer::SetVFSubSampling(int sub)
619 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
622 UpdateDisplayExtent();
625 //------------------------------------------------------------------------------
628 //------------------------------------------------------------------------------
629 void vvSlicer::SetVFScale(int scale)
633 mArrow->SetScale(mScale);
634 UpdateDisplayExtent();
637 //------------------------------------------------------------------------------
639 //------------------------------------------------------------------------------
640 void vvSlicer::SetVFWidth(int width)
644 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
645 UpdateDisplayExtent();
648 //------------------------------------------------------------------------------
651 //------------------------------------------------------------------------------
652 void vvSlicer::SetVFLog(int log)
656 mGlyphFilter->SetUseLog(mVFLog);
657 mGlyphFilter->Modified();
659 UpdateDisplayExtent();
662 //------------------------------------------------------------------------------
665 //------------------------------------------------------------------------------
666 void vvSlicer::SetTSlice(int t)
670 else if ((unsigned int)t >= mImage->GetVTKImages().size())
671 t = mImage->GetVTKImages().size() -1;
673 if (mCurrentTSlice == t) return;
676 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
677 if (mVF && mVFActor->GetVisibility()) {
678 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
679 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
681 if (mOverlay && mOverlayActor->GetVisibility()) {
682 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
683 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
685 if (mFusion && mFusionActor->GetVisibility()) {
686 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
687 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
689 if (mSurfaceCutActors.size() > 0)
690 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
691 i!=mSurfaceCutActors.end(); i++)
692 (*i)->SetTimeSlice(mCurrentTSlice);
693 UpdateDisplayExtent();
695 //------------------------------------------------------------------------------
698 //------------------------------------------------------------------------------
699 int vvSlicer::GetTSlice()
701 return mCurrentTSlice;
703 //------------------------------------------------------------------------------
705 //------------------------------------------------------------------------------
706 void vvSlicer::SetSliceOrientation(int orientation)
708 //if 2D image, force to watch in Axial View
710 this->GetInput()->GetWholeExtent(extent);
711 if (extent[5]-extent[4] <= 2)
712 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
714 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
715 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
716 vtkErrorMacro("Error - invalid slice orientation " << orientation);
720 this->SliceOrientation = orientation;
723 AdjustResliceToSliceOrientation(mFusionReslice);
726 AdjustResliceToSliceOrientation(mOverlayReslice);
729 int *range = this->GetSliceRange();
731 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
733 // Go to current cursor position
734 // double* cursorPos = GetCursorPosition();
735 // DDV(cursorPos, 3);
736 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
738 this->UpdateOrientation();
739 this->UpdateDisplayExtent();
741 if (this->Renderer && this->GetInput()) {
742 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
743 this->Renderer->ResetCamera();
744 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
749 //----------------------------------------------------------------------------
751 //------------------------------------------------------------------------------
752 // This function ensures that we sample the slices of a vtkImageReslice filter
753 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
754 // In other words, we change the grid of the reslice in the same way as the grid
755 // of the displayed image in the slicing direction.
756 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
758 // Reset autocrop and update output information
759 reslice->SetOutputOriginToDefault();
760 reslice->SetOutputSpacingToDefault();
761 reslice->GetOutput()->UpdateInformation();
763 // Ge new origin / spacing
766 reslice->GetOutput()->GetOrigin(origin);
767 reslice->GetOutput()->GetSpacing(spacing);
769 // Use similar spacing as the image in the direction SliceOrientation
770 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
772 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
773 // Step 1: from world coordinates to image coordinates
774 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
775 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
776 // Step 2: round to superior grid positionInc
777 origin[this->SliceOrientation] = itk::Math::Ceil<double>(origin[this->SliceOrientation]);
778 // Step 3: back to world coordinates
779 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
780 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
782 // Set new spacing and origin
783 reslice->SetOutputOrigin(origin);
784 reslice->SetOutputSpacing(spacing);
785 reslice->UpdateInformation();
786 reslice->GetOutput()->UpdateInformation();
788 //------------------------------------------------------------------------------
790 //----------------------------------------------------------------------------
791 int * vvSlicer::GetExtent(){
793 if (mUseReducedExtent) {
794 w_ext = mReducedExtent;
795 } else w_ext = GetInput()->GetWholeExtent();
798 //----------------------------------------------------------------------------
801 //----------------------------------------------------------------------------
802 int vvSlicer::GetOrientation()
804 return this->SliceOrientation;
806 //----------------------------------------------------------------------------
809 //----------------------------------------------------------------------------
810 void vvSlicer::UpdateDisplayExtent()
812 vtkImageData *input = this->GetInput();
813 if (!input || !this->ImageActor) {
816 input->UpdateInformation();
818 // Local copy of extent
820 copyExtent(GetExtent(), w_ext);
822 w_ext[ this->SliceOrientation*2 ] = this->Slice;
823 w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
826 this->ImageActor->SetDisplayExtent(w_ext);
828 // Overlay image actor
829 if (mOverlay && mOverlayActor->GetVisibility()) {
830 AdjustResliceToSliceOrientation(mOverlayReslice);
832 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
833 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
834 mOverlayActor->SetDisplayExtent( overExtent );
837 // Fusion image actor
838 if (mFusion && mFusionActor->GetVisibility()) {
839 AdjustResliceToSliceOrientation(mFusionReslice);
841 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
842 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
843 mFusionActor->SetDisplayExtent(fusExtent);
846 // Vector field actor
847 double* camera = Renderer->GetActiveCamera()->GetPosition();
848 double* image_bounds = ImageActor->GetBounds();
849 double position[3] = {0, 0, 0};
850 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
852 //print_vector<double, 6>("camera", camera);
853 //print_vector<double, 6>("image_bounds", image_bounds);
854 //print_vector<double, 3>("position", position);
856 // find where to place the VF actor. to deal with
857 // z-buffer issues, the VF is placed right in front of the image,
858 // subject to a small offset. the position actually depends on the
859 // the location of the camera relative to the image.
861 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
864 if (mVF && mVFActor->GetVisibility()) {
866 mVF->GetVTKImages()[0]->UpdateInformation();
867 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
868 ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
869 mVOIFilter->SetVOI(vfExtent);
870 int orientation[3] = {1,1,1};
871 orientation[this->SliceOrientation] = 0;
872 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
875 position[this->SliceOrientation] += offset;
876 mVFActor->SetPosition(position);
883 for(unsigned int i=0; i<6; i++)
884 bounds[i] = ImageActor->GetBounds()[i];
885 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
886 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
887 mClipBox->SetBounds(bounds);
891 position[this->SliceOrientation] = offset;
892 mLandActor->SetPosition(position);
895 // Figure out the correct clipping range
896 if (this->Renderer) {
897 if (this->InteractorStyle &&
898 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
899 this->Renderer->ResetCameraClippingRange();
901 vtkCamera *cam = this->Renderer->GetActiveCamera();
904 this->ImageActor->GetBounds(bounds);
905 double spos = (double)bounds[this->SliceOrientation * 2];
906 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
907 double range = fabs(spos - cpos);
908 double *spacing = input->GetSpacing();
910 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
911 cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
917 //----------------------------------------------------------------------------
919 //----------------------------------------------------------------------------
920 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
921 vtkImageData *targetImage, int targetExtent[6])
924 for(unsigned int i=0; i<6; i++) {
925 // From source voxel coordinates to world coordinates
926 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
928 // From world coordinates to floating point target voxel coordinates
929 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
932 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
935 //----------------------------------------------------------------------------
937 //----------------------------------------------------------------------------
938 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
943 //2D overlay on 3D image specific case
944 if (refExtent[4] == refExtent[5]) {
946 extent[4] = refExtent[4];
947 extent[5] = refExtent[5];
950 for (int i = 0; i < maxBound; i = i+2) {
951 //if we are totally outside the image
952 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
956 //crop to the limit of the image
957 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
958 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
959 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
960 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
963 for (int i = 0; i < maxBound; i = i+2) {
964 extent[i] = refExtent[i];
965 extent[i+1] = refExtent[i];
968 //----------------------------------------------------------------------------
971 //----------------------------------------------------------------------------
972 void vvSlicer::UpdateOrientation()
974 // Set the camera position
975 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
977 switch (this->SliceOrientation) {
978 case vtkImageViewer2::SLICE_ORIENTATION_XY:
979 cam->SetFocalPoint(0,0,0);
980 cam->SetPosition(0,0,-1); // -1 if medical ?
981 cam->SetViewUp(0,-1,0);
984 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
985 cam->SetFocalPoint(0,0,0);
986 cam->SetPosition(0,-1,0); // 1 if medical ?
987 cam->SetViewUp(0,0,1);
990 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
991 cam->SetFocalPoint(0,0,0);
992 cam->SetPosition(-1,0,0); // -1 if medical ?
993 cam->SetViewUp(0,0,1);
998 //----------------------------------------------------------------------------
1001 //----------------------------------------------------------------------------
1002 void vvSlicer::SetOpacity(double s)
1004 this->GetImageActor()->SetOpacity(s);
1006 //----------------------------------------------------------------------------
1009 //----------------------------------------------------------------------------
1010 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1012 this->Superclass::SetRenderWindow(rw);
1013 this->SetupInteractor(rw->GetInteractor());
1014 ca->SetImageActor(this->GetImageActor());
1015 ca->SetWindowLevel(this->GetWindowLevel());
1016 ca->SetText(2, "<slice>");
1017 ca->SetText(3, "<window>\n<level>");
1029 crossCursor->SetModelBounds(bounds);
1030 this->GetRenderer()->AddActor(pdmA);
1031 this->GetRenderer()->AddActor(ca);
1032 this->GetRenderer()->ResetCamera();
1034 //this is just a mapping between the labeling of the orientations presented to the user and
1035 //the one used by vtk
1036 SetSliceOrientation(2-(orientation%3));
1039 //----------------------------------------------------------------------------
1042 //----------------------------------------------------------------------------
1043 void vvSlicer::ResetCamera()
1045 this->GetRenderer()->ResetCamera();
1047 //----------------------------------------------------------------------------
1050 //----------------------------------------------------------------------------
1051 void vvSlicer::SetDisplayMode(bool i)
1053 this->GetRenderer()->SetDraw(i);
1055 UpdateDisplayExtent();
1057 //----------------------------------------------------------------------------
1060 //----------------------------------------------------------------------------
1061 void vvSlicer::FlipHorizontalView()
1063 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1065 double *position = cam->GetPosition();
1066 double factor[3] = {1, 1, 1};
1067 factor[this->SliceOrientation] = -1;
1068 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1070 /* switch (this->SliceOrientation) {
1071 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1072 cam->SetPosition(position[0],position[1],-position[2]);
1075 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1076 cam->SetPosition(position[0],-position[1],position[2]);
1079 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1080 cam->SetPosition(-position[0],position[1],position[2]);
1084 this->Renderer->ResetCameraClippingRange();
1085 this->UpdateDisplayExtent();
1088 //----------------------------------------------------------------------------
1091 //----------------------------------------------------------------------------
1092 void vvSlicer::FlipVerticalView()
1094 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1096 FlipHorizontalView();
1097 double *viewup = cam->GetViewUp();
1098 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1099 this->UpdateDisplayExtent();
1102 //----------------------------------------------------------------------------
1105 //----------------------------------------------------------------------------
1106 void vvSlicer::SetColorWindow(double window)
1108 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1110 double level = this->GetWindowLevel()->GetLevel();
1111 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1114 this->vtkImageViewer2::SetColorWindow(window);
1116 //----------------------------------------------------------------------------
1118 //----------------------------------------------------------------------------
1119 void vvSlicer::SetColorLevel(double level)
1121 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1123 double window = this->GetWindowLevel()->GetWindow();
1124 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1127 this->vtkImageViewer2::SetColorLevel(level);
1129 //----------------------------------------------------------------------------
1131 //----------------------------------------------------------------------------
1132 double vvSlicer::GetOverlayColorWindow()
1135 return mOverlayMapper->GetWindow();
1139 //----------------------------------------------------------------------------
1141 //----------------------------------------------------------------------------
1142 double vvSlicer::GetOverlayColorLevel()
1145 return mOverlayMapper->GetLevel();
1149 //----------------------------------------------------------------------------
1151 //----------------------------------------------------------------------------
1152 void vvSlicer::SetOverlayColorWindow(double window)
1154 mOverlayMapper->SetWindow(window);
1156 //----------------------------------------------------------------------------
1158 //----------------------------------------------------------------------------
1159 void vvSlicer::SetOverlayColorLevel(double level)
1161 mOverlayMapper->SetLevel(level);
1163 //----------------------------------------------------------------------------
1165 //----------------------------------------------------------------------------
1166 // Returns the min an the max value in a 41x41 region around the mouse pointer
1167 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image)
1169 //Get mouse pointer position in view coordinates
1170 double fLocalExtents[6];
1171 for(int i=0; i<3; i++) {
1172 fLocalExtents[i*2 ] = mCurrent[i];
1173 fLocalExtents[i*2+1] = mCurrent[i];
1175 this->Renderer->WorldToView(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1176 this->Renderer->WorldToView(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1177 for(int i=0; i<3; i++) {
1178 if (i!=SliceOrientation) { //SR: assumes that SliceOrientation is valid in ViewCoordinates (???)
1179 fLocalExtents[i*2 ] -= 0.2;
1180 fLocalExtents[i*2+1] += 0.2;
1183 this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1184 this->Renderer->ViewToWorld(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1186 //Convert to image pixel coordinates (rounded)
1187 int iLocalExtents[6];
1188 for(int i=0; i<3; i++) {
1189 fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - image->GetOrigin()[i])/image->GetSpacing()[i];
1190 fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - image->GetOrigin()[i])/image->GetSpacing()[i];
1192 iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
1193 iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
1195 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1196 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1199 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1200 voiFilter->SetInput(image);
1201 voiFilter->SetVOI(iLocalExtents);
1202 voiFilter->Update();
1203 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1209 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1210 accFilter->SetInput(voiFilter->GetOutput());
1211 accFilter->Update();
1213 min = *(accFilter->GetMin());
1214 max = *(accFilter->GetMax());
1216 //----------------------------------------------------------------------------
1218 //----------------------------------------------------------------------------
1219 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1224 if (ix < image->GetWholeExtent()[0] ||
1225 ix > image->GetWholeExtent()[1] ||
1226 iy < image->GetWholeExtent()[2] ||
1227 iy > image->GetWholeExtent()[3] ||
1228 iz < image->GetWholeExtent()[4] ||
1229 iz > image->GetWholeExtent()[5] )
1230 return std::numeric_limits<double>::quiet_NaN();
1232 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1234 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1236 //----------------------------------------------------------------------------
1238 //----------------------------------------------------------------------------
1239 void vvSlicer::Render()
1241 if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion) {
1242 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1243 legend->SetVisibility(1);
1244 } else legend->SetVisibility(0);
1246 if (ca->GetVisibility()) {
1247 std::stringstream worldPos;
1248 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1249 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1250 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1252 // if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
1253 // else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1];
1254 // if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
1255 // else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3];
1256 // if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
1257 // else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5];
1259 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1260 X <= this->GetInput()->GetWholeExtent()[1] &&
1261 Y >= this->GetInput()->GetWholeExtent()[2] &&
1262 Y <= this->GetInput()->GetWholeExtent()[3] &&
1263 Z >= this->GetInput()->GetWholeExtent()[4] &&
1264 Z <= this->GetInput()->GetWholeExtent()[5]) {
1268 double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
1270 if(ImageActor->GetVisibility())
1271 worldPos << "data value : " << value << std::endl;
1273 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1274 << lrint(mCurrent[1]) << ' '
1275 << lrint(mCurrent[2]) << ' '
1278 worldPos << "pixel : " << ix << ' '
1284 ca->SetText(1,worldPos.str().c_str());
1287 if (pdmA->GetVisibility()) {
1288 double x = mCursor[0];
1289 double y = mCursor[1];
1290 double z = mCursor[2];
1291 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1292 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1293 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1295 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1296 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1297 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1298 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1299 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1300 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1301 vtkRenderer * renderer = this->Renderer;
1303 renderer->WorldToView(x,y,z);
1304 renderer->ViewToNormalizedViewport(x,y,z);
1305 renderer->NormalizedViewportToViewport(x,y);
1306 renderer->ViewportToNormalizedDisplay(x,y);
1307 renderer->NormalizedDisplayToDisplay(x,y);
1308 crossCursor->SetFocalPoint(x,y,z);
1310 crossCursor->SetFocalPoint(-1,-1,z);
1314 if (mOverlay && mOverlayActor->GetVisibility()) {
1315 if(mLinkOverlayWindowLevel) {
1316 mOverlayMapper->SetWindow(this->GetColorWindow());
1317 mOverlayMapper->SetLevel(this->GetColorLevel());
1319 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1320 mOverlayMapper->GetOutput()->Update();
1321 mOverlayMapper->Update();
1326 this->GetRenderWindow()->Render();
1328 //----------------------------------------------------------------------------
1331 //----------------------------------------------------------------------------
1332 void vvSlicer::UpdateCursorPosition()
1334 pdmA->SetVisibility(true);
1335 mCursor[0] = mCurrent[0];
1336 mCursor[1] = mCurrent[1];
1337 mCursor[2] = mCurrent[2];
1338 mCursor[3] = mCurrentTSlice;
1340 //----------------------------------------------------------------------------
1343 //----------------------------------------------------------------------------
1344 void vvSlicer::UpdateLandmarks()
1346 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1347 if (pd->GetPoints()) {
1348 mLandGlyph->SetRange(0,1);
1349 mLandGlyph->Modified();
1350 mLandGlyph->Update();
1352 mClipBox->Modified();
1353 mLandClipper->Update();
1354 mLandMapper->Update();
1358 //----------------------------------------------------------------------------
1361 //----------------------------------------------------------------------------
1362 void vvSlicer::SetSlice(int slice)
1364 int *range = this->GetSliceRange();
1366 if (slice < range[0]) {
1368 } else if (slice > range[1]) {
1373 if (this->Slice == slice) {
1377 this->Slice = slice;
1380 this->UpdateDisplayExtent();
1382 // Seems to work without this line
1385 //----------------------------------------------------------------------------
1388 //----------------------------------------------------------------------------
1389 void vvSlicer::SetContourSlice()
1391 if (mSurfaceCutActors.size() > 0)
1392 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1393 i!=mSurfaceCutActors.end(); i++) {
1395 (*i)->SetSlicingOrientation(this->SliceOrientation);
1396 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1397 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1400 //----------------------------------------------------------------------------
1403 //----------------------------------------------------------------------------
1404 void vvSlicer::ForceUpdateDisplayExtent()
1406 this->UpdateDisplayExtent();
1408 //----------------------------------------------------------------------------
1411 //----------------------------------------------------------------------------
1412 int* vvSlicer::GetDisplayExtent()
1414 return this->GetImageActor()->GetDisplayExtent();
1416 //----------------------------------------------------------------------------
1419 //----------------------------------------------------------------------------
1420 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1422 this->Superclass::PrintSelf(os, indent);
1424 //----------------------------------------------------------------------------
1426 //----------------------------------------------------------------------------
1427 void vvSlicer::SetVFColor(double r, double g, double b)
1429 double mVFColorHSV[3];
1434 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1435 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1436 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1437 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);