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 vtkImageMapToWindowLevelColors* 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(false);
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<vtkImageMapToWindowLevelColors>::New();
412 mFusionMapper->SetInput(mFusionReslice->GetOutput());
415 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
416 mFusionActor->SetInput(mFusionMapper->GetOutput());
417 mFusionActor->SetPickable(0);
418 mFusionActor->SetVisibility(false);
419 mFusionActor->SetOpacity(0.7);
420 this->GetRenderer()->AddActor(mFusionActor);
423 //Synchronize orientation and slice
424 this->SetSliceOrientation(this->SliceOrientation);
425 this->SetTSlice(mCurrentTSlice);
428 //------------------------------------------------------------------------------
431 //------------------------------------------------------------------------------
432 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
435 if (actor_type == "image") {
436 vis = this->ImageActor->GetVisibility();
438 else if (actor_type == "vector") {
439 vis = this->mVFActor->GetVisibility();
441 else if (actor_type == "overlay") {
442 vis = this->mOverlayActor->GetVisibility();
444 else if (actor_type == "fusion") {
445 vis = this->mFusionActor->GetVisibility();
447 else if (actor_type == "contour")
448 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
452 //------------------------------------------------------------------------------
454 //------------------------------------------------------------------------------
455 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
457 if (actor_type == "image") {
458 this->ImageActor->SetVisibility(vis);
460 else if (actor_type == "vector") {
461 this->mVFActor->SetVisibility(vis);
463 else if (actor_type == "overlay") {
464 this->mOverlayActor->SetVisibility(vis);
466 else if (actor_type == "fusion") {
467 this->mFusionActor->SetVisibility(vis);
469 else if (actor_type == "contour")
470 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
471 UpdateDisplayExtent();
473 //------------------------------------------------------------------------------
475 //------------------------------------------------------------------------------
476 void vvSlicer::SetVF(vvImage::Pointer vf)
478 if (vf->GetVTKImages().size()) {
482 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
483 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
484 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
486 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
487 mAAFilter->SetInput(mVOIFilter->GetOutput());
488 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
489 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
492 mArrow = vtkSmartPointer<vvGlyphSource>::New();
493 mArrow->SetGlyphTypeToSpecificArrow();
494 mArrow->SetScale(mScale);
497 // Glyph the gradient vector (with arrows)
499 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
500 mGlyphFilter->SetInput(mAAFilter->GetOutput());
501 mGlyphFilter->SetSource(mArrow->GetOutput());
502 mGlyphFilter->ScalingOn();
503 mGlyphFilter->SetScaleModeToScaleByVector();
504 mGlyphFilter->OrientOn();
505 mGlyphFilter->SetVectorModeToUseVector();
506 mGlyphFilter->SetColorModeToColorByVector();
509 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
511 double mVFColorHSV[3];
512 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
513 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
514 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
515 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
518 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
519 mVFMapper->SetInput(mGlyphFilter->GetOutput());
520 mVFMapper->ImmediateModeRenderingOn();
521 mVFMapper->SetLookupTable(mVFColorLUT);
524 mVFActor = vtkSmartPointer<vtkActor>::New();
525 mVFActor->SetMapper(mVFMapper);
526 mVFActor->SetPickable(0);
527 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
528 this->UpdateDisplayExtent();
529 this->GetRenderer()->AddActor(mVFActor);
532 SetTSlice(mCurrentTSlice);
535 //------------------------------------------------------------------------------
538 //------------------------------------------------------------------------------
539 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
541 mLandmarks = landmarks;
545 mCross = vtkSmartPointer<vtkCursor3D>::New();
546 mCross->SetFocalPoint(0.0,0.0,0.0);
547 mCross->SetModelBounds(-10,10,-10,10,-10,10);
552 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
553 mLandGlyph->SetSource(mCross->GetOutput());
554 mLandGlyph->SetInput(landmarks->GetOutput());
555 //mLandGlyph->SetIndexModeToScalar();
556 mLandGlyph->SetRange(0,1);
557 mLandGlyph->ScalingOff();
559 mLandGlyph->SetColorModeToColorByScalar();
562 mClipBox = vtkSmartPointer<vtkBox>::New();
564 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
565 mLandClipper->InsideOutOn();
566 mLandClipper->SetInput(mLandGlyph->GetOutput());
567 mLandClipper->SetClipFunction(mClipBox);
570 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
571 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
572 //mLandMapper->ScalarVisibilityOff();
575 mLandActor = vtkSmartPointer<vtkActor>::New();
576 mLandActor->SetMapper(mLandMapper);
577 mLandActor->GetProperty()->SetColor(255,10,212);
578 mLandActor->SetPickable(0);
579 mLandActor->SetVisibility(true);
580 this->UpdateDisplayExtent();
581 this->GetRenderer()->AddActor(mLandActor);
584 //------------------------------------------------------------------------------
586 //------------------------------------------------------------------------------
587 //FIXME: this function leaks memory, we should fix it someday :)
588 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
590 if (actor_type == "vector") {
591 Renderer->RemoveActor(mVFActor);
600 if (actor_type == "overlay") {
601 Renderer->RemoveActor(mOverlayActor);
603 mOverlayActor = NULL;
604 mOverlayMapper = NULL;
606 if (actor_type == "fusion") {
607 Renderer->RemoveActor(mFusionActor);
610 mFusionMapper = NULL;
612 if (actor_type == "contour") {
613 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
614 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
617 //------------------------------------------------------------------------------
620 //------------------------------------------------------------------------------
621 void vvSlicer::SetVFSubSampling(int sub)
624 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
627 UpdateDisplayExtent();
630 //------------------------------------------------------------------------------
633 //------------------------------------------------------------------------------
634 void vvSlicer::SetVFScale(int scale)
638 mArrow->SetScale(mScale);
639 UpdateDisplayExtent();
642 //------------------------------------------------------------------------------
644 //------------------------------------------------------------------------------
645 void vvSlicer::SetVFWidth(int width)
649 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
650 UpdateDisplayExtent();
653 //------------------------------------------------------------------------------
656 //------------------------------------------------------------------------------
657 void vvSlicer::SetVFLog(int log)
661 mGlyphFilter->SetUseLog(mVFLog);
662 mGlyphFilter->Modified();
664 UpdateDisplayExtent();
667 //------------------------------------------------------------------------------
670 //------------------------------------------------------------------------------
671 void vvSlicer::SetTSlice(int t)
675 else if ((unsigned int)t >= mImage->GetVTKImages().size())
676 t = mImage->GetVTKImages().size() -1;
678 if (mCurrentTSlice == t) return;
681 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
682 if (mVF && mVFActor->GetVisibility()) {
683 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
684 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
686 if (mOverlay && mOverlayActor->GetVisibility()) {
687 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
688 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
690 if (mFusion && mFusionActor->GetVisibility()) {
691 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
692 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
694 if (mSurfaceCutActors.size() > 0)
695 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
696 i!=mSurfaceCutActors.end(); i++)
697 (*i)->SetTimeSlice(mCurrentTSlice);
698 UpdateDisplayExtent();
700 //------------------------------------------------------------------------------
703 //------------------------------------------------------------------------------
704 int vvSlicer::GetTSlice()
706 return mCurrentTSlice;
708 //------------------------------------------------------------------------------
710 //------------------------------------------------------------------------------
711 void vvSlicer::SetSliceOrientation(int orientation)
713 //if 2D image, force to watch in Axial View
715 this->GetInput()->GetWholeExtent(extent);
716 if (extent[5]-extent[4] <= 2)
717 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
719 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
720 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
721 vtkErrorMacro("Error - invalid slice orientation " << orientation);
725 this->SliceOrientation = orientation;
728 AdjustResliceToSliceOrientation(mFusionReslice);
731 AdjustResliceToSliceOrientation(mOverlayReslice);
734 int *range = this->GetSliceRange();
736 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
738 // Go to current cursor position
739 // double* cursorPos = GetCursorPosition();
740 // DDV(cursorPos, 3);
741 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
743 this->UpdateOrientation();
744 this->UpdateDisplayExtent();
746 if (this->Renderer && this->GetInput()) {
747 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
748 this->Renderer->ResetCamera();
749 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
754 //----------------------------------------------------------------------------
756 //------------------------------------------------------------------------------
757 // This function ensures that we sample the slices of a vtkImageReslice filter
758 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
759 // In other words, we change the grid of the reslice in the same way as the grid
760 // of the displayed image in the slicing direction.
761 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
764 double origin[3] = {VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX};
765 double spacing[3] = {VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX};
766 reslice->SetOutputOrigin(origin);
767 reslice->SetOutputSpacing(spacing);
768 reslice->GetOutput()->UpdateInformation();
769 reslice->GetOutput()->GetOrigin(origin);
770 reslice->GetOutput()->GetSpacing(spacing);
772 // Use similar spacing as the image in the direction SliceOrientation
773 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
775 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
776 // Step 1: from world coordinates to image coordinates
777 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
778 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
779 // Step 2: round to superior grid positionInc
780 origin[this->SliceOrientation] = itk::Math::Ceil<double>(origin[this->SliceOrientation]);
781 // Step 3: back to world coordinates
782 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
783 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
785 // Set new spacing and origin
786 reslice->SetOutputOrigin(origin);
787 reslice->SetOutputSpacing(spacing);
788 reslice->UpdateInformation();
790 //------------------------------------------------------------------------------
792 //----------------------------------------------------------------------------
793 int * vvSlicer::GetExtent(){
795 if (mUseReducedExtent) {
796 w_ext = mReducedExtent;
797 } else w_ext = GetInput()->GetWholeExtent();
800 //----------------------------------------------------------------------------
803 //----------------------------------------------------------------------------
804 int vvSlicer::GetOrientation()
806 return this->SliceOrientation;
808 //----------------------------------------------------------------------------
811 //----------------------------------------------------------------------------
812 void vvSlicer::UpdateDisplayExtent()
814 vtkImageData *input = this->GetInput();
815 if (!input || !this->ImageActor) {
818 input->UpdateInformation();
820 // Local copy of extent
822 copyExtent(GetExtent(), w_ext);
824 w_ext[ this->SliceOrientation*2 ] = this->Slice;
825 w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
828 this->ImageActor->SetDisplayExtent(w_ext);
830 // Overlay image actor
831 if (mOverlay && mOverlayActor->GetVisibility()) {
833 mOverlayReslice->GetOutput()->UpdateInformation();
834 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
835 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
836 mOverlayActor->SetDisplayExtent( overExtent );
839 // Fusion image actor
840 if (mFusion && mFusionActor->GetVisibility()) {
842 mFusionReslice->GetOutput()->UpdateInformation();
843 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
844 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
845 mFusionActor->SetDisplayExtent(fusExtent);
848 // Vector field actor
849 double* camera = Renderer->GetActiveCamera()->GetPosition();
850 double* image_bounds = ImageActor->GetBounds();
851 double position[3] = {0, 0, 0};
852 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
854 //print_vector<double, 6>("camera", camera);
855 //print_vector<double, 6>("image_bounds", image_bounds);
856 //print_vector<double, 3>("position", position);
858 // find where to place the VF actor. to deal with
859 // z-buffer issues, the VF is placed right in front of the image,
860 // subject to a small offset. the position actually depends on the
861 // the location of the camera relative to the image.
863 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
866 if (mVF && mVFActor->GetVisibility()) {
868 mVF->GetVTKImages()[0]->UpdateInformation();
869 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
870 ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
871 mVOIFilter->SetVOI(vfExtent);
872 int orientation[3] = {1,1,1};
873 orientation[this->SliceOrientation] = 0;
874 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
877 position[this->SliceOrientation] += offset;
878 mVFActor->SetPosition(position);
885 for(unsigned int i=0; i<6; i++)
886 bounds[i] = ImageActor->GetBounds()[i];
887 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
888 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
889 mClipBox->SetBounds(bounds);
893 position[this->SliceOrientation] = offset;
894 mLandActor->SetPosition(position);
897 // Figure out the correct clipping range
898 if (this->Renderer) {
899 if (this->InteractorStyle &&
900 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
901 this->Renderer->ResetCameraClippingRange();
903 vtkCamera *cam = this->Renderer->GetActiveCamera();
906 this->ImageActor->GetBounds(bounds);
907 double spos = (double)bounds[this->SliceOrientation * 2];
908 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
909 double range = fabs(spos - cpos);
910 double *spacing = input->GetSpacing();
912 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
913 cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
919 //----------------------------------------------------------------------------
921 //----------------------------------------------------------------------------
922 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
923 vtkImageData *targetImage, int targetExtent[6])
926 for(unsigned int i=0; i<6; i++) {
927 // From source voxel coordinates to world coordinates
928 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
930 // From world coordinates to floating point target voxel coordinates
931 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
934 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
937 //----------------------------------------------------------------------------
939 //----------------------------------------------------------------------------
940 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
945 //2D overlay on 3D image specific case
946 if (refExtent[4] == refExtent[5]) {
948 extent[4] = refExtent[4];
949 extent[5] = refExtent[5];
952 for (int i = 0; i < maxBound; i = i+2) {
953 //if we are totally outside the image
954 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
958 //crop to the limit of the image
959 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
960 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
961 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
962 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
965 for (int i = 0; i < maxBound; i = i+2) {
966 extent[i] = refExtent[i];
967 extent[i+1] = refExtent[i];
970 //----------------------------------------------------------------------------
973 //----------------------------------------------------------------------------
974 void vvSlicer::UpdateOrientation()
976 // Set the camera position
977 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
979 switch (this->SliceOrientation) {
980 case vtkImageViewer2::SLICE_ORIENTATION_XY:
981 cam->SetFocalPoint(0,0,0);
982 cam->SetPosition(0,0,-1); // -1 if medical ?
983 cam->SetViewUp(0,-1,0);
986 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
987 cam->SetFocalPoint(0,0,0);
988 cam->SetPosition(0,-1,0); // 1 if medical ?
989 cam->SetViewUp(0,0,1);
992 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
993 cam->SetFocalPoint(0,0,0);
994 cam->SetPosition(-1,0,0); // -1 if medical ?
995 cam->SetViewUp(0,0,1);
1000 //----------------------------------------------------------------------------
1003 //----------------------------------------------------------------------------
1004 void vvSlicer::SetOpacity(double s)
1006 this->GetImageActor()->SetOpacity(s);
1008 //----------------------------------------------------------------------------
1011 //----------------------------------------------------------------------------
1012 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1014 this->Superclass::SetRenderWindow(rw);
1015 this->SetupInteractor(rw->GetInteractor());
1016 ca->SetImageActor(this->GetImageActor());
1017 ca->SetWindowLevel(this->GetWindowLevel());
1018 ca->SetText(2, "<slice>");
1019 ca->SetText(3, "<window>\n<level>");
1031 crossCursor->SetModelBounds(bounds);
1032 this->GetRenderer()->AddActor(pdmA);
1033 this->GetRenderer()->AddActor(ca);
1034 this->GetRenderer()->ResetCamera();
1036 //this is just a mapping between the labeling of the orientations presented to the user and
1037 //the one used by vtk
1038 SetSliceOrientation(2-(orientation%3));
1041 //----------------------------------------------------------------------------
1044 //----------------------------------------------------------------------------
1045 void vvSlicer::ResetCamera()
1047 this->GetRenderer()->ResetCamera();
1049 //----------------------------------------------------------------------------
1052 //----------------------------------------------------------------------------
1053 void vvSlicer::SetDisplayMode(bool i)
1055 this->GetImageActor()->SetVisibility(i);
1056 this->GetAnnotation()->SetVisibility(i);
1057 this->GetRenderer()->SetDraw(i);
1059 mLandActor->SetVisibility(i);
1060 pdmA->SetVisibility(i);
1062 UpdateDisplayExtent();
1064 //----------------------------------------------------------------------------
1067 //----------------------------------------------------------------------------
1068 void vvSlicer::FlipHorizontalView()
1070 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1072 double *position = cam->GetPosition();
1073 double factor[3] = {1, 1, 1};
1074 factor[this->SliceOrientation] = -1;
1075 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1077 /* switch (this->SliceOrientation) {
1078 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1079 cam->SetPosition(position[0],position[1],-position[2]);
1082 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1083 cam->SetPosition(position[0],-position[1],position[2]);
1086 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1087 cam->SetPosition(-position[0],position[1],position[2]);
1091 this->Renderer->ResetCameraClippingRange();
1092 this->UpdateDisplayExtent();
1095 //----------------------------------------------------------------------------
1098 //----------------------------------------------------------------------------
1099 void vvSlicer::FlipVerticalView()
1101 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1103 FlipHorizontalView();
1104 double *viewup = cam->GetViewUp();
1105 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1106 this->UpdateDisplayExtent();
1109 //----------------------------------------------------------------------------
1112 //----------------------------------------------------------------------------
1113 void vvSlicer::SetColorWindow(double window)
1115 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1117 double level = this->GetWindowLevel()->GetLevel();
1118 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1121 this->vtkImageViewer2::SetColorWindow(window);
1123 //----------------------------------------------------------------------------
1126 //----------------------------------------------------------------------------
1127 void vvSlicer::SetColorLevel(double level)
1129 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1131 double window = this->GetWindowLevel()->GetWindow();
1132 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1135 this->vtkImageViewer2::SetColorLevel(level);
1137 //----------------------------------------------------------------------------
1139 //----------------------------------------------------------------------------
1140 // Returns the min an the max value in a 41x41 region around the mouse pointer
1141 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
1143 //Get mouse pointer position in view coordinates
1144 double fLocalExtents[6];
1145 for(int i=0; i<3; i++) {
1146 fLocalExtents[i*2 ] = mCurrent[i];
1147 fLocalExtents[i*2+1] = mCurrent[i];
1149 this->Renderer->WorldToView(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1150 this->Renderer->WorldToView(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1151 for(int i=0; i<3; i++) {
1152 if (i!=SliceOrientation) { //SR: assumes that SliceOrientation is valid in ViewCoordinates (???)
1153 fLocalExtents[i*2 ] -= 0.2;
1154 fLocalExtents[i*2+1] += 0.2;
1157 this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1158 this->Renderer->ViewToWorld(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1160 //Convert to image pixel coordinates (rounded)
1161 int iLocalExtents[6];
1162 for(int i=0; i<3; i++) {
1163 fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1164 fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1166 iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
1167 iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
1169 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1170 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1173 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1174 voiFilter->SetInput(this->GetInput());
1175 voiFilter->SetVOI(iLocalExtents);
1176 voiFilter->Update();
1177 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1183 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1184 accFilter->SetInput(voiFilter->GetOutput());
1185 accFilter->Update();
1187 min = *(accFilter->GetMin());
1188 max = *(accFilter->GetMax());
1190 //----------------------------------------------------------------------------
1192 //----------------------------------------------------------------------------
1193 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1198 if (ix < image->GetWholeExtent()[0] ||
1199 ix > image->GetWholeExtent()[1] ||
1200 iy < image->GetWholeExtent()[2] ||
1201 iy > image->GetWholeExtent()[3] ||
1202 iz < image->GetWholeExtent()[4] ||
1203 iz > image->GetWholeExtent()[5] )
1204 return std::numeric_limits<double>::quiet_NaN();
1206 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1208 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1210 //----------------------------------------------------------------------------
1212 //----------------------------------------------------------------------------
1213 void vvSlicer::Render()
1215 if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion) {
1216 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1217 legend->SetVisibility(1);
1218 } else legend->SetVisibility(0);
1220 if (ca->GetVisibility()) {
1221 std::stringstream worldPos;
1222 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1223 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1224 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1226 // if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
1227 // else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1];
1228 // if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
1229 // else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3];
1230 // if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
1231 // else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5];
1233 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1234 X <= this->GetInput()->GetWholeExtent()[1] &&
1235 Y >= this->GetInput()->GetWholeExtent()[2] &&
1236 Y <= this->GetInput()->GetWholeExtent()[3] &&
1237 Z >= this->GetInput()->GetWholeExtent()[4] &&
1238 Z <= this->GetInput()->GetWholeExtent()[5]) {
1242 double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
1244 worldPos << "data value : " << value << std::endl;
1245 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1246 << lrint(mCurrent[1]) << ' '
1247 << lrint(mCurrent[2]) << ' '
1250 worldPos << "pixel : " << ix << ' '
1256 ca->SetText(1,worldPos.str().c_str());
1259 if (pdmA->GetVisibility()) {
1260 double x = mCursor[0];
1261 double y = mCursor[1];
1262 double z = mCursor[2];
1263 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1264 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1265 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1267 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1268 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1269 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1270 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1271 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1272 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1273 vtkRenderer * renderer = this->Renderer;
1275 renderer->WorldToView(x,y,z);
1276 renderer->ViewToNormalizedViewport(x,y,z);
1277 renderer->NormalizedViewportToViewport(x,y);
1278 renderer->ViewportToNormalizedDisplay(x,y);
1279 renderer->NormalizedDisplayToDisplay(x,y);
1280 crossCursor->SetFocalPoint(x,y,z);
1282 crossCursor->SetFocalPoint(-1,-1,z);
1286 if (mOverlay && mOverlayActor->GetVisibility()) {
1287 mOverlayMapper->SetWindow(this->GetColorWindow());
1288 mOverlayMapper->SetLevel(this->GetColorLevel());
1289 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1290 mOverlayMapper->GetOutput()->Update();
1291 mOverlayMapper->Update();
1296 this->GetRenderWindow()->Render();
1298 //----------------------------------------------------------------------------
1301 //----------------------------------------------------------------------------
1302 void vvSlicer::UpdateCursorPosition()
1304 if (this->GetImageActor()->GetVisibility()) {
1305 pdmA->SetVisibility(true);
1306 mCursor[0] = mCurrent[0];
1307 mCursor[1] = mCurrent[1];
1308 mCursor[2] = mCurrent[2];
1309 mCursor[3] = mCurrentTSlice;
1312 //----------------------------------------------------------------------------
1315 //----------------------------------------------------------------------------
1316 void vvSlicer::UpdateLandmarks()
1318 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1319 if (pd->GetPoints()) {
1320 mLandGlyph->SetRange(0,1);
1321 mLandGlyph->Modified();
1322 mLandGlyph->Update();
1324 mClipBox->Modified();
1325 mLandClipper->Update();
1326 mLandMapper->Update();
1330 //----------------------------------------------------------------------------
1333 //----------------------------------------------------------------------------
1334 void vvSlicer::SetSlice(int slice)
1336 int *range = this->GetSliceRange();
1338 if (slice < range[0]) {
1340 } else if (slice > range[1]) {
1345 if (this->Slice == slice) {
1349 this->Slice = slice;
1352 this->UpdateDisplayExtent();
1354 // Seems to work without this line
1357 //----------------------------------------------------------------------------
1360 //----------------------------------------------------------------------------
1361 void vvSlicer::SetContourSlice()
1363 if (mSurfaceCutActors.size() > 0)
1364 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1365 i!=mSurfaceCutActors.end(); i++) {
1367 (*i)->SetSlicingOrientation(this->SliceOrientation);
1368 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1369 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1372 //----------------------------------------------------------------------------
1375 //----------------------------------------------------------------------------
1376 void vvSlicer::ForceUpdateDisplayExtent()
1378 this->UpdateDisplayExtent();
1380 //----------------------------------------------------------------------------
1383 //----------------------------------------------------------------------------
1384 int* vvSlicer::GetDisplayExtent()
1386 return this->GetImageActor()->GetDisplayExtent();
1388 //----------------------------------------------------------------------------
1391 //----------------------------------------------------------------------------
1392 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1394 this->Superclass::PrintSelf(os, indent);
1396 //----------------------------------------------------------------------------
1398 //----------------------------------------------------------------------------
1399 void vvSlicer::SetVFColor(double r, double g, double b)
1401 double mVFColorHSV[3];
1406 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1407 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1408 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1409 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);