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 std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n";
102 text += "F5 = horizontal flip; F6 = vertical flip\n\n";
103 text += "0,1,2,3,4,5 : preset windowing\n";
104 text += "6,7,8,9 : preset colormap\n";
105 text += "z : local windowing\n";
106 text += "r : reset view\n";
107 text += "l : reload image\n";
108 text += "f : fly to mouse position\n";
109 text += "g : go to cross hair position\n\n";
110 text += "Up,down : change slice\n";
111 text += "Left,right : change tenporal slice\n\n";
112 text += "Scrollbar (or w/x) : zoom in/out\n";
113 text += "left button : synchronize all views\n";
114 text += "middle button : grab image\n";
115 text += "right button : change windowing\n";
117 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
118 crossCursor->AllOff();
119 crossCursor->AxesOn();
120 crossCursor->SetTranslationMode(1);
121 crossCursor->SetRadius(2);
123 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
124 pdm->SetInput(crossCursor->GetOutput());
126 pdmA = vtkSmartPointer<vtkActor2D>::New();
127 pdmA->SetMapper(pdm);
128 pdmA->GetProperty()->SetColor(255,10,212);
129 pdmA->SetVisibility(0);
130 pdmA->SetPickable(0);
132 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
133 ca->GetTextProperty()->SetColor(255,10,212);
134 ca->SetVisibility(1);
142 legend = vtkSmartPointer<vtkScalarBarActor>::New();
143 //legend->SetTitle("test!");
144 legend->SetPosition(0.82,0.18);
145 legend->SetWidth(0.1);
146 legend->SetVisibility(0);
147 legend->SetLabelFormat("%.1f");
148 this->GetRenderer()->AddActor(legend);
150 this->WindowLevel->Delete();
151 this->WindowLevel = vvImageMapToWLColors::New();
153 this->InstallPipeline();
155 //------------------------------------------------------------------------------
158 //------------------------------------------------------------------------------
159 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
161 return mOverlayMapper.GetPointer();
163 //------------------------------------------------------------------------------
166 //------------------------------------------------------------------------------
167 vvBlendImageActor* vvSlicer::GetOverlayActor()
169 return mOverlayActor.GetPointer();
171 //------------------------------------------------------------------------------
174 //------------------------------------------------------------------------------
175 vtkImageMapToColors* vvSlicer::GetFusionMapper()
177 return mFusionMapper.GetPointer();
179 //------------------------------------------------------------------------------
182 //------------------------------------------------------------------------------
183 vtkImageActor* vvSlicer::GetFusionActor()
185 return mFusionActor.GetPointer();
187 //------------------------------------------------------------------------------
190 //------------------------------------------------------------------------------
191 vtkActor* vvSlicer::GetVFActor()
193 return mVFActor.GetPointer();
195 //------------------------------------------------------------------------------
198 //------------------------------------------------------------------------------
199 vtkCornerAnnotation* vvSlicer::GetAnnotation()
201 return ca.GetPointer();
203 //------------------------------------------------------------------------------
206 //------------------------------------------------------------------------------
207 void vvSlicer::EnableReducedExtent(bool b)
209 mUseReducedExtent = b;
211 //------------------------------------------------------------------------------
214 //------------------------------------------------------------------------------
215 void vvSlicer::SetReducedExtent(int * ext)
217 copyExtent(ext, mReducedExtent);
219 //------------------------------------------------------------------------------
222 //------------------------------------------------------------------------------
223 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
226 mSurfaceCutActors.push_back(new vvMeshActor());
228 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
230 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
231 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
232 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
236 //------------------------------------------------------------------------------
239 //------------------------------------------------------------------------------
240 void vvSlicer::ToggleContourSuperposition()
242 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
243 i!=mSurfaceCutActors.end(); i++)
244 (*i)->ToggleSuperposition();
246 //------------------------------------------------------------------------------
249 //------------------------------------------------------------------------------
250 void vvSlicer::SetCursorColor(int r,int g, int b)
252 pdmA->GetProperty()->SetColor(r,g,b);
254 //------------------------------------------------------------------------------
257 //------------------------------------------------------------------------------
258 void vvSlicer::SetCursorVisibility(bool s)
260 pdmA->SetVisibility(s);
262 //------------------------------------------------------------------------------
265 //------------------------------------------------------------------------------
266 bool vvSlicer::GetCursorVisibility()
268 return pdmA->GetVisibility();
270 //------------------------------------------------------------------------------
273 //------------------------------------------------------------------------------
274 void vvSlicer::SetCornerAnnotationVisibility(bool s)
276 ca->SetVisibility(s);
278 //------------------------------------------------------------------------------
281 //------------------------------------------------------------------------------
282 bool vvSlicer::GetCornerAnnotationVisibility()
284 return ca->GetVisibility();
286 //------------------------------------------------------------------------------
289 //------------------------------------------------------------------------------
290 vvSlicer::~vvSlicer()
292 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
293 i!=mSurfaceCutActors.end(); i++)
295 delete [] mReducedExtent;
297 //------------------------------------------------------------------------------
300 //------------------------------------------------------------------------------
301 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
308 //------------------------------------------------------------------------------
311 //------------------------------------------------------------------------------
312 void vvSlicer::SetImage(vvImage::Pointer image)
314 if (image->GetVTKImages().size()) {
317 if (!mImageReslice) {
318 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
319 mImageReslice->SetInterpolationModeToLinear();
320 mImageReslice->AutoCropOutputOn();
321 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
323 mImageReslice->SetResliceTransform(mImage->GetTransform());
324 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
325 mImageReslice->UpdateInformation();
327 this->Superclass::SetInput(mImageReslice->GetOutput());
330 this->GetInput()->GetWholeExtent(extent);
332 // Prevent crash when reload -> change slice if outside extent
333 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
334 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
337 // Make sure that the required part image has been computed
338 extent[SliceOrientation*2] = Slice;
339 extent[SliceOrientation*2+1] = Slice;
340 mImageReslice->GetOutput()->SetUpdateExtent(extent);
341 mImageReslice->GetOutput()->Update();
343 this->UpdateDisplayExtent();
346 ca->SetText(0,mFileName.c_str());
349 //------------------------------------------------------------------------------
352 //------------------------------------------------------------------------------
353 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
355 if (overlay->GetVTKImages().size()) {
358 if (!mOverlayReslice) {
359 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
360 mOverlayReslice->SetInterpolationModeToLinear();
361 mOverlayReslice->AutoCropOutputOn();
362 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
364 mOverlayReslice->SetResliceTransform(mOverlay->GetTransform());
365 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
368 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
369 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
371 if (!mOverlayActor) {
372 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
373 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
374 mOverlayActor->SetPickable(0);
375 mOverlayActor->SetVisibility(true);
376 mOverlayActor->SetOpacity(0.5);
379 //stupid but necessary : the Overlay need to be rendered before fusion
381 this->GetRenderer()->RemoveActor(mFusionActor);
382 this->GetRenderer()->AddActor(mOverlayActor);
383 this->GetRenderer()->AddActor(mFusionActor);
385 this->GetRenderer()->AddActor(mOverlayActor);
387 //Synchronize orientation and slice
388 this->SetSliceOrientation(this->SliceOrientation);
389 this->SetTSlice(mCurrentTSlice);
392 //------------------------------------------------------------------------------
395 //------------------------------------------------------------------------------
396 void vvSlicer::SetFusion(vvImage::Pointer fusion)
398 if (fusion->GetVTKImages().size()) {
401 if (!mFusionReslice) {
402 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
403 mFusionReslice->SetInterpolationModeToLinear();
404 mFusionReslice->AutoCropOutputOn();
405 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
407 mFusionReslice->SetResliceTransform(mFusion->GetTransform());
408 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
411 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
413 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
415 lut->SetValueRange(0, 1);
416 lut->SetSaturationRange(0, 0);
418 mFusionMapper->SetLookupTable(lut);
419 mFusionMapper->SetInput(mFusionReslice->GetOutput());
422 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
423 mFusionActor->SetInput(mFusionMapper->GetOutput());
424 mFusionActor->SetPickable(0);
425 mFusionActor->SetVisibility(true);
426 mFusionActor->SetOpacity(0.7);
427 this->GetRenderer()->AddActor(mFusionActor);
430 //Synchronize orientation and slice
431 this->SetSliceOrientation(this->SliceOrientation);
432 this->SetTSlice(mCurrentTSlice);
435 //------------------------------------------------------------------------------
438 //------------------------------------------------------------------------------
439 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
442 if (actor_type == "image") {
443 vis = this->ImageActor->GetVisibility();
445 else if (actor_type == "vector") {
446 vis = this->mVFActor->GetVisibility();
448 else if (actor_type == "overlay") {
449 vis = this->mOverlayActor->GetVisibility();
451 else if (actor_type == "fusion") {
452 vis = this->mFusionActor->GetVisibility();
454 else if (actor_type == "contour")
455 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
459 //------------------------------------------------------------------------------
461 //------------------------------------------------------------------------------
462 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
464 if (actor_type == "image") {
465 this->ImageActor->SetVisibility(vis);
467 else if (actor_type == "vector") {
468 this->mVFActor->SetVisibility(vis);
470 else if (actor_type == "overlay") {
471 this->mOverlayActor->SetVisibility(vis);
473 else if (actor_type == "fusion") {
474 this->mFusionActor->SetVisibility(vis);
476 else if (actor_type == "contour")
477 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
478 UpdateDisplayExtent();
480 //------------------------------------------------------------------------------
482 //------------------------------------------------------------------------------
483 void vvSlicer::SetVF(vvImage::Pointer vf)
485 if (vf->GetVTKImages().size()) {
489 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
490 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
491 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
493 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
494 mAAFilter->SetInput(mVOIFilter->GetOutput());
495 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
496 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
499 mArrow = vtkSmartPointer<vvGlyphSource>::New();
500 mArrow->SetGlyphTypeToSpecificArrow();
501 mArrow->SetScale(mScale);
504 // Glyph the gradient vector (with arrows)
506 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
507 mGlyphFilter->SetInput(mAAFilter->GetOutput());
508 mGlyphFilter->SetSource(mArrow->GetOutput());
509 mGlyphFilter->ScalingOn();
510 mGlyphFilter->SetScaleModeToScaleByVector();
511 mGlyphFilter->OrientOn();
512 mGlyphFilter->SetVectorModeToUseVector();
513 mGlyphFilter->SetColorModeToColorByVector();
516 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
518 double mVFColorHSV[3];
519 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
520 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
521 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
522 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
525 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
526 mVFMapper->SetInput(mGlyphFilter->GetOutput());
527 mVFMapper->ImmediateModeRenderingOn();
528 mVFMapper->SetLookupTable(mVFColorLUT);
531 mVFActor = vtkSmartPointer<vtkActor>::New();
532 mVFActor->SetMapper(mVFMapper);
533 mVFActor->SetPickable(0);
534 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
535 this->UpdateDisplayExtent();
536 this->GetRenderer()->AddActor(mVFActor);
539 SetTSlice(mCurrentTSlice);
542 //------------------------------------------------------------------------------
545 //------------------------------------------------------------------------------
546 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
548 mLandmarks = landmarks;
552 mCross = vtkSmartPointer<vtkCursor3D>::New();
553 mCross->SetFocalPoint(0.0,0.0,0.0);
554 mCross->SetModelBounds(-10,10,-10,10,-10,10);
559 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
560 mLandGlyph->SetSource(mCross->GetOutput());
561 mLandGlyph->SetInput(landmarks->GetOutput());
562 //mLandGlyph->SetIndexModeToScalar();
563 mLandGlyph->SetRange(0,1);
564 mLandGlyph->ScalingOff();
566 mLandGlyph->SetColorModeToColorByScalar();
569 mClipBox = vtkSmartPointer<vtkBox>::New();
571 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
572 mLandClipper->InsideOutOn();
573 mLandClipper->SetInput(mLandGlyph->GetOutput());
574 mLandClipper->SetClipFunction(mClipBox);
577 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
578 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
579 //mLandMapper->ScalarVisibilityOff();
582 mLandActor = vtkSmartPointer<vtkActor>::New();
583 mLandActor->SetMapper(mLandMapper);
584 mLandActor->GetProperty()->SetColor(255,10,212);
585 mLandActor->SetPickable(0);
586 mLandActor->SetVisibility(true);
587 this->UpdateDisplayExtent();
588 this->GetRenderer()->AddActor(mLandActor);
591 //------------------------------------------------------------------------------
593 //------------------------------------------------------------------------------
594 //FIXME: this function leaks memory, we should fix it someday :)
595 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
597 if (actor_type == "vector") {
598 Renderer->RemoveActor(mVFActor);
607 if (actor_type == "overlay") {
608 Renderer->RemoveActor(mOverlayActor);
610 mOverlayActor = NULL;
611 mOverlayMapper = NULL;
613 if (actor_type == "fusion") {
614 Renderer->RemoveActor(mFusionActor);
617 mFusionMapper = NULL;
619 if (actor_type == "contour") {
620 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
621 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
624 //------------------------------------------------------------------------------
627 //------------------------------------------------------------------------------
628 void vvSlicer::SetVFSubSampling(int sub)
631 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
634 UpdateDisplayExtent();
637 //------------------------------------------------------------------------------
640 //------------------------------------------------------------------------------
641 void vvSlicer::SetVFScale(int scale)
645 mArrow->SetScale(mScale);
646 UpdateDisplayExtent();
649 //------------------------------------------------------------------------------
651 //------------------------------------------------------------------------------
652 void vvSlicer::SetVFWidth(int width)
656 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
657 UpdateDisplayExtent();
660 //------------------------------------------------------------------------------
663 //------------------------------------------------------------------------------
664 void vvSlicer::SetVFLog(int log)
668 mGlyphFilter->SetUseLog(mVFLog);
669 mGlyphFilter->Modified();
671 UpdateDisplayExtent();
674 //------------------------------------------------------------------------------
677 //------------------------------------------------------------------------------
678 void vvSlicer::SetTSlice(int t)
682 else if ((unsigned int)t >= mImage->GetVTKImages().size())
683 t = mImage->GetVTKImages().size() -1;
685 if (mCurrentTSlice == t) return;
688 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
689 if (mVF && mVFActor->GetVisibility()) {
690 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
691 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
693 if (mOverlay && mOverlayActor->GetVisibility()) {
694 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
695 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
697 if (mFusion && mFusionActor->GetVisibility()) {
698 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
699 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
701 if (mSurfaceCutActors.size() > 0)
702 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
703 i!=mSurfaceCutActors.end(); i++)
704 (*i)->SetTimeSlice(mCurrentTSlice);
705 UpdateDisplayExtent();
707 //------------------------------------------------------------------------------
710 //------------------------------------------------------------------------------
711 int vvSlicer::GetTSlice()
713 return mCurrentTSlice;
715 //------------------------------------------------------------------------------
717 //------------------------------------------------------------------------------
718 void vvSlicer::SetSliceOrientation(int orientation)
720 //if 2D image, force to watch in Axial View
722 this->GetInput()->GetWholeExtent(extent);
723 if (extent[5]-extent[4] <= 2)
724 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
726 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
727 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
728 vtkErrorMacro("Error - invalid slice orientation " << orientation);
732 this->SliceOrientation = orientation;
735 AdjustResliceToSliceOrientation(mFusionReslice);
738 AdjustResliceToSliceOrientation(mOverlayReslice);
741 int *range = this->GetSliceRange();
743 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
745 // Go to current cursor position
746 // double* cursorPos = GetCursorPosition();
747 // DDV(cursorPos, 3);
748 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
750 this->UpdateOrientation();
751 this->UpdateDisplayExtent();
753 if (this->Renderer && this->GetInput()) {
754 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
755 this->Renderer->ResetCamera();
756 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
761 //----------------------------------------------------------------------------
763 //------------------------------------------------------------------------------
764 // This function ensures that we sample the slices of a vtkImageReslice filter
765 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
766 // In other words, we change the grid of the reslice in the same way as the grid
767 // of the displayed image in the slicing direction.
768 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
771 double origin[3] = {VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX};
772 double spacing[3] = {VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX};
773 reslice->SetOutputOrigin(origin);
774 reslice->SetOutputSpacing(spacing);
775 reslice->GetOutput()->UpdateInformation();
776 reslice->GetOutput()->GetOrigin(origin);
777 reslice->GetOutput()->GetSpacing(spacing);
779 // Use similar spacing as the image in the direction SliceOrientation
780 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
782 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
783 // Step 1: from world coordinates to image coordinates
784 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
785 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
786 // Step 2: round to superior grid positionInc
787 origin[this->SliceOrientation] = itk::Math::Ceil<double>(origin[this->SliceOrientation]);
788 // Step 3: back to world coordinates
789 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
790 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
792 // Set new spacing and origin
793 reslice->SetOutputOrigin(origin);
794 reslice->SetOutputSpacing(spacing);
795 reslice->UpdateInformation();
797 //------------------------------------------------------------------------------
799 //----------------------------------------------------------------------------
800 int * vvSlicer::GetExtent(){
802 if (mUseReducedExtent) {
803 w_ext = mReducedExtent;
804 } else w_ext = GetInput()->GetWholeExtent();
807 //----------------------------------------------------------------------------
810 //----------------------------------------------------------------------------
811 int vvSlicer::GetOrientation()
813 return this->SliceOrientation;
815 //----------------------------------------------------------------------------
818 //----------------------------------------------------------------------------
819 void vvSlicer::UpdateDisplayExtent()
821 vtkImageData *input = this->GetInput();
822 if (!input || !this->ImageActor) {
825 input->UpdateInformation();
827 // Local copy of extent
829 copyExtent(GetExtent(), w_ext);
831 w_ext[ this->SliceOrientation*2 ] = this->Slice;
832 w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
835 this->ImageActor->SetDisplayExtent(w_ext);
837 // Overlay image actor
838 if (mOverlay && mOverlayActor->GetVisibility()) {
840 mOverlayReslice->GetOutput()->UpdateInformation();
841 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
842 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
843 mOverlayActor->SetDisplayExtent( overExtent );
846 // Fusion image actor
847 if (mFusion && mFusionActor->GetVisibility()) {
849 mFusionReslice->GetOutput()->UpdateInformation();
850 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
851 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
852 mFusionActor->SetDisplayExtent(fusExtent);
855 // Vector field actor
856 double* camera = Renderer->GetActiveCamera()->GetPosition();
857 double* image_bounds = ImageActor->GetBounds();
858 double position[3] = {0, 0, 0};
859 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
861 //print_vector<double, 6>("camera", camera);
862 //print_vector<double, 6>("image_bounds", image_bounds);
863 //print_vector<double, 3>("position", position);
865 // find where to place the VF actor. to deal with
866 // z-buffer issues, the VF is placed right in front of the image,
867 // subject to a small offset. the position actually depends on the
868 // the location of the camera relative to the image.
870 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
873 if (mVF && mVFActor->GetVisibility()) {
875 mVF->GetVTKImages()[0]->UpdateInformation();
876 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
877 ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
878 mVOIFilter->SetVOI(vfExtent);
879 int orientation[3] = {1,1,1};
880 orientation[this->SliceOrientation] = 0;
881 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
884 position[this->SliceOrientation] += offset;
885 mVFActor->SetPosition(position);
892 for(unsigned int i=0; i<6; i++)
893 bounds[i] = ImageActor->GetBounds()[i];
894 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
895 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
896 mClipBox->SetBounds(bounds);
900 position[this->SliceOrientation] = offset;
901 mLandActor->SetPosition(position);
904 // Figure out the correct clipping range
905 if (this->Renderer) {
906 if (this->InteractorStyle &&
907 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
908 this->Renderer->ResetCameraClippingRange();
910 vtkCamera *cam = this->Renderer->GetActiveCamera();
913 this->ImageActor->GetBounds(bounds);
914 double spos = (double)bounds[this->SliceOrientation * 2];
915 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
916 double range = fabs(spos - cpos);
917 double *spacing = input->GetSpacing();
919 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
920 cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
926 //----------------------------------------------------------------------------
928 //----------------------------------------------------------------------------
929 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
930 vtkImageData *targetImage, int targetExtent[6])
933 for(unsigned int i=0; i<6; i++) {
934 // From source voxel coordinates to world coordinates
935 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
937 // From world coordinates to floating point target voxel coordinates
938 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
941 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
944 //----------------------------------------------------------------------------
946 //----------------------------------------------------------------------------
947 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
952 //2D overlay on 3D image specific case
953 if (refExtent[4] == refExtent[5]) {
955 extent[4] = refExtent[4];
956 extent[5] = refExtent[5];
959 for (int i = 0; i < maxBound; i = i+2) {
960 //if we are totally outside the image
961 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
965 //crop to the limit of the image
966 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
967 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
968 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
969 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
972 for (int i = 0; i < maxBound; i = i+2) {
973 extent[i] = refExtent[i];
974 extent[i+1] = refExtent[i];
977 //----------------------------------------------------------------------------
980 //----------------------------------------------------------------------------
981 void vvSlicer::UpdateOrientation()
983 // Set the camera position
984 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
986 switch (this->SliceOrientation) {
987 case vtkImageViewer2::SLICE_ORIENTATION_XY:
988 cam->SetFocalPoint(0,0,0);
989 cam->SetPosition(0,0,-1); // -1 if medical ?
990 cam->SetViewUp(0,-1,0);
993 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
994 cam->SetFocalPoint(0,0,0);
995 cam->SetPosition(0,-1,0); // 1 if medical ?
996 cam->SetViewUp(0,0,1);
999 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1000 cam->SetFocalPoint(0,0,0);
1001 cam->SetPosition(-1,0,0); // -1 if medical ?
1002 cam->SetViewUp(0,0,1);
1007 //----------------------------------------------------------------------------
1010 //----------------------------------------------------------------------------
1011 void vvSlicer::SetOpacity(double s)
1013 this->GetImageActor()->SetOpacity(s);
1015 //----------------------------------------------------------------------------
1018 //----------------------------------------------------------------------------
1019 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1021 this->Superclass::SetRenderWindow(rw);
1022 this->SetupInteractor(rw->GetInteractor());
1023 ca->SetImageActor(this->GetImageActor());
1024 ca->SetWindowLevel(this->GetWindowLevel());
1025 ca->SetText(2, "<slice>");
1026 ca->SetText(3, "<window>\n<level>");
1038 crossCursor->SetModelBounds(bounds);
1039 this->GetRenderer()->AddActor(pdmA);
1040 this->GetRenderer()->AddActor(ca);
1041 this->GetRenderer()->ResetCamera();
1043 //this is just a mapping between the labeling of the orientations presented to the user and
1044 //the one used by vtk
1045 SetSliceOrientation(2-(orientation%3));
1048 //----------------------------------------------------------------------------
1051 //----------------------------------------------------------------------------
1052 void vvSlicer::ResetCamera()
1054 this->GetRenderer()->ResetCamera();
1056 //----------------------------------------------------------------------------
1059 //----------------------------------------------------------------------------
1060 void vvSlicer::SetDisplayMode(bool i)
1062 this->GetRenderer()->SetDraw(i);
1064 UpdateDisplayExtent();
1066 //----------------------------------------------------------------------------
1069 //----------------------------------------------------------------------------
1070 void vvSlicer::FlipHorizontalView()
1072 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1074 double *position = cam->GetPosition();
1075 double factor[3] = {1, 1, 1};
1076 factor[this->SliceOrientation] = -1;
1077 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1079 /* switch (this->SliceOrientation) {
1080 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1081 cam->SetPosition(position[0],position[1],-position[2]);
1084 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1085 cam->SetPosition(position[0],-position[1],position[2]);
1088 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1089 cam->SetPosition(-position[0],position[1],position[2]);
1093 this->Renderer->ResetCameraClippingRange();
1094 this->UpdateDisplayExtent();
1097 //----------------------------------------------------------------------------
1100 //----------------------------------------------------------------------------
1101 void vvSlicer::FlipVerticalView()
1103 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1105 FlipHorizontalView();
1106 double *viewup = cam->GetViewUp();
1107 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1108 this->UpdateDisplayExtent();
1111 //----------------------------------------------------------------------------
1114 //----------------------------------------------------------------------------
1115 void vvSlicer::SetColorWindow(double window)
1117 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1119 double level = this->GetWindowLevel()->GetLevel();
1120 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1123 this->vtkImageViewer2::SetColorWindow(window);
1125 //----------------------------------------------------------------------------
1128 //----------------------------------------------------------------------------
1129 void vvSlicer::SetColorLevel(double level)
1131 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1133 double window = this->GetWindowLevel()->GetWindow();
1134 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1137 this->vtkImageViewer2::SetColorLevel(level);
1139 //----------------------------------------------------------------------------
1141 //----------------------------------------------------------------------------
1142 // Returns the min an the max value in a 41x41 region around the mouse pointer
1143 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
1145 //Get mouse pointer position in view coordinates
1146 double fLocalExtents[6];
1147 for(int i=0; i<3; i++) {
1148 fLocalExtents[i*2 ] = mCurrent[i];
1149 fLocalExtents[i*2+1] = mCurrent[i];
1151 this->Renderer->WorldToView(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1152 this->Renderer->WorldToView(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1153 for(int i=0; i<3; i++) {
1154 if (i!=SliceOrientation) { //SR: assumes that SliceOrientation is valid in ViewCoordinates (???)
1155 fLocalExtents[i*2 ] -= 0.2;
1156 fLocalExtents[i*2+1] += 0.2;
1159 this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1160 this->Renderer->ViewToWorld(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1162 //Convert to image pixel coordinates (rounded)
1163 int iLocalExtents[6];
1164 for(int i=0; i<3; i++) {
1165 fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1166 fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1168 iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
1169 iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
1171 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1172 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1175 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1176 voiFilter->SetInput(this->GetInput());
1177 voiFilter->SetVOI(iLocalExtents);
1178 voiFilter->Update();
1179 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1185 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1186 accFilter->SetInput(voiFilter->GetOutput());
1187 accFilter->Update();
1189 min = *(accFilter->GetMin());
1190 max = *(accFilter->GetMax());
1192 //----------------------------------------------------------------------------
1194 //----------------------------------------------------------------------------
1195 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1200 if (ix < image->GetWholeExtent()[0] ||
1201 ix > image->GetWholeExtent()[1] ||
1202 iy < image->GetWholeExtent()[2] ||
1203 iy > image->GetWholeExtent()[3] ||
1204 iz < image->GetWholeExtent()[4] ||
1205 iz > image->GetWholeExtent()[5] )
1206 return std::numeric_limits<double>::quiet_NaN();
1208 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1210 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1212 //----------------------------------------------------------------------------
1214 //----------------------------------------------------------------------------
1215 void vvSlicer::Render()
1217 if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion) {
1218 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1219 legend->SetVisibility(1);
1220 } else legend->SetVisibility(0);
1222 if (ca->GetVisibility()) {
1223 std::stringstream worldPos;
1224 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1225 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1226 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1228 // if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
1229 // else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1];
1230 // if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
1231 // else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3];
1232 // if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
1233 // else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5];
1235 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1236 X <= this->GetInput()->GetWholeExtent()[1] &&
1237 Y >= this->GetInput()->GetWholeExtent()[2] &&
1238 Y <= this->GetInput()->GetWholeExtent()[3] &&
1239 Z >= this->GetInput()->GetWholeExtent()[4] &&
1240 Z <= this->GetInput()->GetWholeExtent()[5]) {
1244 double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
1246 if(ImageActor->GetVisibility())
1247 worldPos << "data value : " << value << std::endl;
1249 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1250 << lrint(mCurrent[1]) << ' '
1251 << lrint(mCurrent[2]) << ' '
1254 worldPos << "pixel : " << ix << ' '
1260 ca->SetText(1,worldPos.str().c_str());
1263 if (pdmA->GetVisibility()) {
1264 double x = mCursor[0];
1265 double y = mCursor[1];
1266 double z = mCursor[2];
1267 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1268 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1269 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1271 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1272 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1273 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1274 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1275 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1276 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1277 vtkRenderer * renderer = this->Renderer;
1279 renderer->WorldToView(x,y,z);
1280 renderer->ViewToNormalizedViewport(x,y,z);
1281 renderer->NormalizedViewportToViewport(x,y);
1282 renderer->ViewportToNormalizedDisplay(x,y);
1283 renderer->NormalizedDisplayToDisplay(x,y);
1284 crossCursor->SetFocalPoint(x,y,z);
1286 crossCursor->SetFocalPoint(-1,-1,z);
1290 if (mOverlay && mOverlayActor->GetVisibility()) {
1291 mOverlayMapper->SetWindow(this->GetColorWindow());
1292 mOverlayMapper->SetLevel(this->GetColorLevel());
1293 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1294 mOverlayMapper->GetOutput()->Update();
1295 mOverlayMapper->Update();
1300 this->GetRenderWindow()->Render();
1302 //----------------------------------------------------------------------------
1305 //----------------------------------------------------------------------------
1306 void vvSlicer::UpdateCursorPosition()
1308 pdmA->SetVisibility(true);
1309 mCursor[0] = mCurrent[0];
1310 mCursor[1] = mCurrent[1];
1311 mCursor[2] = mCurrent[2];
1312 mCursor[3] = mCurrentTSlice;
1314 //----------------------------------------------------------------------------
1317 //----------------------------------------------------------------------------
1318 void vvSlicer::UpdateLandmarks()
1320 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1321 if (pd->GetPoints()) {
1322 mLandGlyph->SetRange(0,1);
1323 mLandGlyph->Modified();
1324 mLandGlyph->Update();
1326 mClipBox->Modified();
1327 mLandClipper->Update();
1328 mLandMapper->Update();
1332 //----------------------------------------------------------------------------
1335 //----------------------------------------------------------------------------
1336 void vvSlicer::SetSlice(int slice)
1338 int *range = this->GetSliceRange();
1340 if (slice < range[0]) {
1342 } else if (slice > range[1]) {
1347 if (this->Slice == slice) {
1351 this->Slice = slice;
1354 this->UpdateDisplayExtent();
1356 // Seems to work without this line
1359 //----------------------------------------------------------------------------
1362 //----------------------------------------------------------------------------
1363 void vvSlicer::SetContourSlice()
1365 if (mSurfaceCutActors.size() > 0)
1366 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1367 i!=mSurfaceCutActors.end(); i++) {
1369 (*i)->SetSlicingOrientation(this->SliceOrientation);
1370 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1371 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1374 //----------------------------------------------------------------------------
1377 //----------------------------------------------------------------------------
1378 void vvSlicer::ForceUpdateDisplayExtent()
1380 this->UpdateDisplayExtent();
1382 //----------------------------------------------------------------------------
1385 //----------------------------------------------------------------------------
1386 int* vvSlicer::GetDisplayExtent()
1388 return this->GetImageActor()->GetDisplayExtent();
1390 //----------------------------------------------------------------------------
1393 //----------------------------------------------------------------------------
1394 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1396 this->Superclass::PrintSelf(os, indent);
1398 //----------------------------------------------------------------------------
1400 //----------------------------------------------------------------------------
1401 void vvSlicer::SetVFColor(double r, double g, double b)
1403 double mVFColorHSV[3];
1408 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1409 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1410 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1411 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);