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://oncora1.lyon.fnclcc.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);
73 //------------------------------------------------------------------------------
76 this->UnInstallPipeline();
79 mUseReducedExtent = false;
81 mCurrent[0] = -VTK_DOUBLE_MAX;
82 mCurrent[1] = -VTK_DOUBLE_MAX;
83 mCurrent[2] = -VTK_DOUBLE_MAX;
85 mCursor[0] = -VTK_DOUBLE_MAX;
86 mCursor[1] = -VTK_DOUBLE_MAX;
87 mCursor[2] = -VTK_DOUBLE_MAX;
88 mCursor[3] = -VTK_DOUBLE_MAX;
95 std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n";
96 text += "F5 = horizontal flip; F6 = vertical flip\n\n";
97 text += "0,1,2,3,4,5 : preset windowing\n";
98 text += "6,7,8,9 : preset colormap\n";
99 text += "z : local windowing\n";
100 text += "r : reset view\n";
101 text += "l : reload image\n";
102 text += "f : fly to mouse position\n";
103 text += "g : go to cross hair position\n\n";
104 text += "Up,down : change slice\n";
105 text += "Left,right : change tenporal slice\n\n";
106 text += "Scrollbar (or w/x) : zoom in/out\n";
107 text += "left button : synchronize all views\n";
108 text += "middle button : grab image\n";
109 text += "right button : change windowing\n";
111 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
112 crossCursor->AllOff();
113 crossCursor->AxesOn();
114 crossCursor->SetTranslationMode(1);
115 crossCursor->SetRadius(2);
117 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
118 pdm->SetInput(crossCursor->GetOutput());
120 pdmA = vtkSmartPointer<vtkActor2D>::New();
121 pdmA->SetMapper(pdm);
122 pdmA->GetProperty()->SetColor(255,10,212);
123 pdmA->SetVisibility(0);
124 pdmA->SetPickable(0);
126 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
127 ca->GetTextProperty()->SetColor(255,10,212);
128 ca->SetVisibility(1);
136 legend = vtkSmartPointer<vtkScalarBarActor>::New();
137 //legend->SetTitle("test!");
138 legend->SetPosition(0.82,0.18);
139 legend->SetWidth(0.1);
140 legend->SetVisibility(0);
141 legend->SetLabelFormat("%.1f");
142 this->GetRenderer()->AddActor(legend);
144 this->WindowLevel->Delete();
145 this->WindowLevel = vvImageMapToWLColors::New();
147 this->InstallPipeline();
149 //------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------
153 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
155 return mOverlayMapper.GetPointer();
157 //------------------------------------------------------------------------------
160 //------------------------------------------------------------------------------
161 vvBlendImageActor* vvSlicer::GetOverlayActor()
163 return mOverlayActor.GetPointer();
165 //------------------------------------------------------------------------------
168 //------------------------------------------------------------------------------
169 vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper()
171 return mFusionMapper.GetPointer();
173 //------------------------------------------------------------------------------
176 //------------------------------------------------------------------------------
177 vtkImageActor* vvSlicer::GetFusionActor()
179 return mFusionActor.GetPointer();
181 //------------------------------------------------------------------------------
184 //------------------------------------------------------------------------------
185 vtkActor* vvSlicer::GetVFActor()
187 return mVFActor.GetPointer();
189 //------------------------------------------------------------------------------
192 //------------------------------------------------------------------------------
193 vtkCornerAnnotation* vvSlicer::GetAnnotation()
195 return ca.GetPointer();
197 //------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------
201 void vvSlicer::EnableReducedExtent(bool b)
203 mUseReducedExtent = b;
205 //------------------------------------------------------------------------------
208 //------------------------------------------------------------------------------
209 void vvSlicer::SetReducedExtent(int * ext)
211 mReducedExtent = ext;
213 //------------------------------------------------------------------------------
216 //------------------------------------------------------------------------------
217 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
220 mSurfaceCutActors.push_back(new vvMeshActor());
222 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
224 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
225 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
226 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
230 //------------------------------------------------------------------------------
233 //------------------------------------------------------------------------------
234 void vvSlicer::ToggleContourSuperposition()
236 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
237 i!=mSurfaceCutActors.end(); i++)
238 (*i)->ToggleSuperposition();
240 //------------------------------------------------------------------------------
243 //------------------------------------------------------------------------------
244 void vvSlicer::SetCursorColor(int r,int g, int b)
246 pdmA->GetProperty()->SetColor(r,g,b);
248 //------------------------------------------------------------------------------
251 //------------------------------------------------------------------------------
252 void vvSlicer::SetCursorVisibility(bool s)
254 pdmA->SetVisibility(s);
256 //------------------------------------------------------------------------------
259 //------------------------------------------------------------------------------
260 bool vvSlicer::GetCursorVisibility()
262 return pdmA->GetVisibility();
264 //------------------------------------------------------------------------------
267 //------------------------------------------------------------------------------
268 vvSlicer::~vvSlicer()
270 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
271 i!=mSurfaceCutActors.end(); i++)
274 //------------------------------------------------------------------------------
277 //------------------------------------------------------------------------------
278 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
285 //------------------------------------------------------------------------------
288 //------------------------------------------------------------------------------
289 void vvSlicer::SetImage(vvImage::Pointer image)
291 if (image->GetVTKImages().size()) {
293 this->Superclass::SetInput(image->GetTransformedVTKImages()[0]);
296 this->GetInput()->GetWholeExtent(extent);
298 // Prevent crash when reload -> change slice if outside extent
299 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
300 Slice = (extent[SliceOrientation*2+1]-extent[SliceOrientation*2])/2.0;
303 // Make sure that the required part image has been computed
304 extent[SliceOrientation*2] = Slice;
305 extent[SliceOrientation*2+1] = Slice;
306 image->GetTransformedVTKImages()[0]->SetUpdateExtent(extent);
307 image->GetTransformedVTKImages()[0]->Update();
309 this->UpdateDisplayExtent();
312 ca->SetText(0,mFileName.c_str());
315 //------------------------------------------------------------------------------
318 //------------------------------------------------------------------------------
319 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
321 if (overlay->GetVTKImages().size()) {
325 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
326 mOverlayMapper->SetInput(overlay->GetTransformedVTKImages()[0]);
328 if (!mOverlayActor) {
329 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
330 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
331 mOverlayActor->SetPickable(0);
332 mOverlayActor->SetVisibility(false);
333 mOverlayActor->SetOpacity(0.5);
334 this->UpdateDisplayExtent();
337 //stupid but necessary : the Overlay need to be rendered before fusion
339 this->GetRenderer()->RemoveActor(mFusionActor);
340 this->GetRenderer()->AddActor(mOverlayActor);
341 this->GetRenderer()->AddActor(mFusionActor);
343 this->GetRenderer()->AddActor(mOverlayActor);
346 SetTSlice(mCurrentTSlice);
349 //------------------------------------------------------------------------------
352 //------------------------------------------------------------------------------
353 void vvSlicer::SetFusion(vvImage::Pointer fusion)
355 if (fusion->GetVTKImages().size()) {
359 mFusionMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
360 mFusionMapper->SetInput(fusion->GetTransformedVTKImages()[0]);
363 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
364 mFusionActor->SetInput(mFusionMapper->GetOutput());
365 mFusionActor->SetPickable(0);
366 mFusionActor->SetVisibility(false);
367 mFusionActor->SetOpacity(0.7);
368 this->UpdateDisplayExtent();
369 this->GetRenderer()->AddActor(mFusionActor);
373 SetTSlice(mCurrentTSlice);
376 //------------------------------------------------------------------------------
379 //------------------------------------------------------------------------------
380 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
382 if (actor_type == "vector") {
383 this->mVFActor->SetVisibility(vis);
385 if (actor_type == "overlay") {
386 this->mOverlayActor->SetVisibility(vis);
388 if (actor_type == "fusion") {
389 this->mFusionActor->SetVisibility(vis);
391 if (actor_type == "contour")
392 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
393 UpdateDisplayExtent();
395 //------------------------------------------------------------------------------
398 //------------------------------------------------------------------------------
399 void vvSlicer::SetVF(vvImage::Pointer vf)
401 if (vf->GetVTKImages().size()) {
405 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
406 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
407 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
409 mVOIFilter->SetInput(vf->GetTransformedVTKImages()[0]);
410 mAAFilter->SetInput(mVOIFilter->GetOutput());
411 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
412 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
415 mArrow = vtkSmartPointer<vvGlyphSource>::New();
416 mArrow->SetGlyphTypeToSpecificArrow();
417 mArrow->SetScale(mScale);
420 // Glyph the gradient vector (with arrows)
422 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
423 mGlyphFilter->SetInput(mAAFilter->GetOutput());
424 mGlyphFilter->SetSource(mArrow->GetOutput());
425 mGlyphFilter->ScalingOn();
426 mGlyphFilter->SetScaleModeToScaleByVector();
427 mGlyphFilter->OrientOn();
428 mGlyphFilter->SetVectorModeToUseVector();
429 mGlyphFilter->SetColorModeToColorByVector();
432 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
433 //mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
434 mVFMapper->SetInput(mGlyphFilter->GetOutput());
435 mVFMapper->ImmediateModeRenderingOn();
438 mVFActor = vtkSmartPointer<vtkActor>::New();
439 mVFActor->SetMapper(mVFMapper);
440 mVFActor->SetPickable(0);
441 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
442 this->UpdateDisplayExtent();
443 this->GetRenderer()->AddActor(mVFActor);
446 SetTSlice(mCurrentTSlice);
449 //------------------------------------------------------------------------------
452 //------------------------------------------------------------------------------
453 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
455 mLandmarks = landmarks;
459 mCross = vtkSmartPointer<vtkCursor3D>::New();
460 mCross->SetFocalPoint(0.0,0.0,0.0);
461 mCross->SetModelBounds(-10,10,-10,10,-10,10);
466 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
467 mLandGlyph->SetSource(mCross->GetOutput());
468 mLandGlyph->SetInput(landmarks->GetOutput());
469 //mLandGlyph->SetIndexModeToScalar();
470 mLandGlyph->SetRange(0,1);
471 mLandGlyph->ScalingOff();
473 mLandGlyph->SetColorModeToColorByScalar();
476 mClipBox = vtkSmartPointer<vtkBox>::New();
478 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
479 mLandClipper->InsideOutOn();
480 mLandClipper->SetInput(mLandGlyph->GetOutput());
481 mLandClipper->SetClipFunction(mClipBox);
484 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
485 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
486 //mLandMapper->ScalarVisibilityOff();
489 mLandActor = vtkSmartPointer<vtkActor>::New();
490 mLandActor->SetMapper(mLandMapper);
491 mLandActor->GetProperty()->SetColor(255,10,212);
492 mLandActor->SetPickable(0);
493 mLandActor->SetVisibility(true);
494 this->UpdateDisplayExtent();
495 this->GetRenderer()->AddActor(mLandActor);
498 //------------------------------------------------------------------------------
500 //------------------------------------------------------------------------------
501 //FIXME: this function leaks memory, we should fix it someday :)
502 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
504 if (actor_type == "vector") {
505 Renderer->RemoveActor(mVFActor);
514 if (actor_type == "overlay") {
515 Renderer->RemoveActor(mOverlayActor);
517 mOverlayActor = NULL;
518 mOverlayMapper = NULL;
520 if (actor_type == "fusion") {
521 Renderer->RemoveActor(mFusionActor);
524 mFusionMapper = NULL;
526 if (actor_type == "contour") {
527 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
528 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
531 //------------------------------------------------------------------------------
534 //------------------------------------------------------------------------------
535 void vvSlicer::SetVFSubSampling(int sub)
538 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
541 UpdateDisplayExtent();
544 //------------------------------------------------------------------------------
547 //------------------------------------------------------------------------------
548 void vvSlicer::SetVFScale(int scale)
552 mArrow->SetScale(mScale);
553 UpdateDisplayExtent();
556 //------------------------------------------------------------------------------
558 //------------------------------------------------------------------------------
559 void vvSlicer::SetVFWidth(int width)
563 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
564 UpdateDisplayExtent();
567 //------------------------------------------------------------------------------
570 //------------------------------------------------------------------------------
571 void vvSlicer::SetVFLog(int log)
575 mGlyphFilter->SetUseLog(mVFLog);
576 mGlyphFilter->Modified();
578 UpdateDisplayExtent();
581 //------------------------------------------------------------------------------
584 //------------------------------------------------------------------------------
585 void vvSlicer::SetTSlice(int t)
589 else if ((unsigned int)t >= mImage->GetVTKImages().size())
590 t = mImage->GetVTKImages().size() -1;
592 if (mCurrentTSlice == t) return;
595 this->SetInput(mImage->GetTransformedVTKImages()[t]);
596 if (mVF && mVFActor->GetVisibility()) {
597 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
598 mVOIFilter->SetInput(mVF->GetTransformedVTKImages()[mCurrentTSlice]);
600 if (mOverlay && mOverlayActor->GetVisibility()) {
601 if (mOverlay->GetTransformedVTKImages().size() > (unsigned int)mCurrentTSlice)
602 mOverlayMapper->SetInput(mOverlay->GetTransformedVTKImages()[mCurrentTSlice]);
604 if (mFusion && mFusionActor->GetVisibility()) {
605 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
606 mFusionMapper->SetInput(mFusion->GetTransformedVTKImages()[mCurrentTSlice]);
608 if (mSurfaceCutActors.size() > 0)
609 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
610 i!=mSurfaceCutActors.end(); i++)
611 (*i)->SetTimeSlice(mCurrentTSlice);
612 UpdateDisplayExtent();
614 //------------------------------------------------------------------------------
617 //------------------------------------------------------------------------------
618 int vvSlicer::GetTSlice()
620 return mCurrentTSlice;
622 //------------------------------------------------------------------------------
625 //------------------------------------------------------------------------------
626 void vvSlicer::SetSliceOrientation(int orientation)
628 //if 2D image, force to watch in Axial View
630 this->GetInput()->GetWholeExtent(extent);
631 if (extent[5]-extent[4] <= 2)
634 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
635 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
636 vtkErrorMacro("Error - invalid slice orientation " << orientation);
640 this->SliceOrientation = orientation;
643 int *range = this->GetSliceRange();
645 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
647 // Go to current cursor position
648 // double* cursorPos = GetCursorPosition();
649 // DDV(cursorPos, 3);
650 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
652 this->UpdateOrientation();
653 this->UpdateDisplayExtent();
655 if (this->Renderer && this->GetInput()) {
656 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
657 this->Renderer->ResetCamera();
658 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
663 //----------------------------------------------------------------------------
666 //----------------------------------------------------------------------------
667 int * vvSlicer::GetExtent()
670 if (mUseReducedExtent) {
671 w_ext = mReducedExtent;
672 } else w_ext = GetInput()->GetWholeExtent();
675 //----------------------------------------------------------------------------
678 //----------------------------------------------------------------------------
679 int vvSlicer::GetOrientation()
681 return this->SliceOrientation;
683 //----------------------------------------------------------------------------
686 //----------------------------------------------------------------------------
687 void vvSlicer::UpdateDisplayExtent()
689 vtkImageData *input = this->GetInput();
690 if (!input || !this->ImageActor) {
693 input->UpdateInformation();
694 int *w_ext;// = input->GetWholeExtent();
696 if (mUseReducedExtent) {
697 w_ext = mReducedExtent;
698 } else w_ext = input->GetWholeExtent();
700 switch (this->SliceOrientation) {
701 case vtkImageViewer2::SLICE_ORIENTATION_XY:
702 this->ImageActor->SetDisplayExtent(
703 w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice);
704 if (mVF && mVFActor->GetVisibility()) {
706 ComputeVFDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,vfExtent);
707 mVOIFilter->SetVOI(vfExtent);
708 mGlyphFilter->SetOrientation(1,1,0);
710 // put the vector field between the image and the camera
711 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
712 mVFActor->SetPosition(0,0,ImageActor->GetBounds()[5]+2);
714 mVFActor->SetPosition(0,0,ImageActor->GetBounds()[4]-2);
716 if (mOverlay && mOverlayActor->GetVisibility()) {
718 ComputeOverlayDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,overExtent);
719 mOverlayActor->SetDisplayExtent(overExtent);
720 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
721 mOverlayActor->SetPosition(0,0,1);
723 mOverlayActor->SetPosition(0,0,-1);
725 if (mFusion && mFusionActor->GetVisibility()) {
727 ComputeFusionDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,fusExtent);
728 mFusionActor->SetDisplayExtent(fusExtent);
729 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
730 mFusionActor->SetPosition(0,0,1.5);
732 mFusionActor->SetPosition(0,0,-1.5);
737 bounds[0] = ImageActor->GetBounds()[0];
738 bounds[1] = ImageActor->GetBounds()[1];
739 bounds[2] = ImageActor->GetBounds()[2];
740 bounds[3] = ImageActor->GetBounds()[3];
741 bounds[4] = ImageActor->GetBounds()[4]-fabs(0.5/this->GetInput()->GetSpacing()[2]);
742 bounds[5] = ImageActor->GetBounds()[5]+fabs(0.5/this->GetInput()->GetSpacing()[2]);
743 mClipBox->SetBounds(bounds);
746 // DD(mLandActor->GetPosition()[2]);
747 // DD(Renderer->GetActiveCamera()->GetPosition()[2]);
748 mLandActor->SetPosition(0,0,-1.5);
750 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
751 mLandActor->SetPosition(0,0,1.5);
753 mLandActor->SetPosition(0,0,-1.5);
758 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
759 this->ImageActor->SetDisplayExtent(
760 w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5]);
761 if (mVF && mVFActor->GetVisibility()) {
763 ComputeVFDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],vfExtent);
764 mVOIFilter->SetVOI(vfExtent);
765 mGlyphFilter->SetOrientation(1,0,1);
767 // put the vector field between the image aSpacingnd the camera
768 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
769 mVFActor->SetPosition(0,ImageActor->GetBounds()[3]+2,0);
771 mVFActor->SetPosition(0,ImageActor->GetBounds()[2]-2,0);
773 if (mOverlay && mOverlayActor->GetVisibility()) {
775 ComputeOverlayDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],overExtent);
776 mOverlayActor->SetDisplayExtent(overExtent);
777 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
778 mOverlayActor->SetPosition(0,1,0);
780 mOverlayActor->SetPosition(0,-1,0);
782 if (mFusion && mFusionActor->GetVisibility()) {
784 ComputeFusionDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],fusExtent);
785 mFusionActor->SetDisplayExtent(fusExtent);
786 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
787 mFusionActor->SetPosition(0,1.5,0);
789 mFusionActor->SetPosition(0,-1.5,0);
794 bounds[0] = ImageActor->GetBounds()[0];
795 bounds[1] = ImageActor->GetBounds()[1];
796 bounds[2] = ImageActor->GetBounds()[2]-fabs(0.5/this->GetInput()->GetSpacing()[1]);
797 bounds[3] = ImageActor->GetBounds()[3]+fabs(0.5/this->GetInput()->GetSpacing()[1]);
798 bounds[4] = ImageActor->GetBounds()[4];
799 bounds[5] = ImageActor->GetBounds()[5];
800 mClipBox->SetBounds(bounds);
803 // DD(mLandActor->GetPosition()[1]);
804 //DD(Renderer->GetActiveCamera()->GetPosition()[1]);
805 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
806 mLandActor->SetPosition(0,1.5,0);
808 mLandActor->SetPosition(0,-1.5,0);
812 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
813 this->ImageActor->SetDisplayExtent(
814 this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
815 if (mVF && mVFActor->GetVisibility()) {
817 ComputeVFDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],vfExtent);
818 mVOIFilter->SetVOI(vfExtent);
819 mGlyphFilter->SetOrientation(0,1,1);
821 // put the vector field between the image and the camera
822 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
823 mVFActor->SetPosition(ImageActor->GetBounds()[1]+2,0,0);
825 mVFActor->SetPosition(ImageActor->GetBounds()[0]-2,0,0);
827 if (mOverlay && mOverlayActor->GetVisibility()) {
829 ComputeOverlayDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],overExtent);
830 mOverlayActor->SetDisplayExtent(overExtent);
831 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
832 mOverlayActor->SetPosition(1,0,0);
834 mOverlayActor->SetPosition(-1,0,0);
836 if (mFusion && mFusionActor->GetVisibility()) {
838 ComputeFusionDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],fusExtent);
839 mFusionActor->SetDisplayExtent(fusExtent);
840 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
841 mFusionActor->SetPosition(1.5,0,0);
843 mFusionActor->SetPosition(-1.5,0,0);
848 bounds[0] = ImageActor->GetBounds()[0]-fabs(0.5/this->GetInput()->GetSpacing()[0]);
849 bounds[1] = ImageActor->GetBounds()[1]+fabs(0.5/this->GetInput()->GetSpacing()[0]);
850 bounds[2] = ImageActor->GetBounds()[2];
851 bounds[3] = ImageActor->GetBounds()[3];
852 bounds[4] = ImageActor->GetBounds()[4];
853 bounds[5] = ImageActor->GetBounds()[5];
854 mClipBox->SetBounds(bounds);
857 // DD(mLandActor->GetPosition()[1]);
858 // DD(Renderer->GetActiveCamera()->GetPosition()[1]);
859 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
860 mLandActor->SetPosition(1.5,0,0);
862 mLandActor->SetPosition(-1.5,0,0);
867 // Figure out the correct clipping range
869 if (this->Renderer) {
870 if (this->InteractorStyle &&
871 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
872 this->Renderer->ResetCameraClippingRange();
874 vtkCamera *cam = this->Renderer->GetActiveCamera();
877 this->ImageActor->GetBounds(bounds);
878 double spos = (double)bounds[this->SliceOrientation * 2];
879 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
880 double range = fabs(spos - cpos);
881 double *spacing = input->GetSpacing();
883 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
884 cam->SetClippingRange(
885 range - avg_spacing * 3.0, range + avg_spacing * 3.0);
890 //----------------------------------------------------------------------------
893 //----------------------------------------------------------------------------
894 void vvSlicer::ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int vfExtent[6])
896 vtkImageData* image=this->GetInput();
897 vfExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mVF->GetOrigin()[0]) /
898 mVF->GetSpacing()[0];
899 vfExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mVF->GetOrigin()[0]) /
900 mVF->GetSpacing()[0];
901 vfExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mVF->GetOrigin()[1]) /
902 mVF->GetSpacing()[1];
903 vfExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mVF->GetOrigin()[1]) /
904 mVF->GetSpacing()[1];
905 vfExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mVF->GetOrigin()[2]) /
906 mVF->GetSpacing()[2];
907 vfExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mVF->GetOrigin()[2]) /
908 mVF->GetSpacing()[2];
910 ClipDisplayedExtent(vfExtent,mVOIFilter->GetInput()->GetWholeExtent());
912 //----------------------------------------------------------------------------
915 //----------------------------------------------------------------------------
916 void vvSlicer::ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6])
918 vtkImageData* image=this->GetInput();
919 overExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mOverlay->GetOrigin()[0]) /
920 mOverlay->GetSpacing()[0];
921 overExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mOverlay->GetOrigin()[0]) /
922 mOverlay->GetSpacing()[0];
923 overExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mOverlay->GetOrigin()[1]) /
924 mOverlay->GetSpacing()[1];
925 overExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mOverlay->GetOrigin()[1]) /
926 mOverlay->GetSpacing()[1];
927 overExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mOverlay->GetOrigin()[2]) /
928 mOverlay->GetSpacing()[2];
929 overExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mOverlay->GetOrigin()[2]) /
930 mOverlay->GetSpacing()[2];
931 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
933 //----------------------------------------------------------------------------
936 //----------------------------------------------------------------------------
937 void vvSlicer::ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int fusExtent[6])
939 vtkImageData* image=this->GetInput();
940 fusExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mFusion->GetOrigin()[0]) /
941 mFusion->GetSpacing()[0];
942 fusExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mFusion->GetOrigin()[0]) /
943 mFusion->GetSpacing()[0];
944 fusExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mFusion->GetOrigin()[1]) /
945 mFusion->GetSpacing()[1];
946 fusExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mFusion->GetOrigin()[1]) /
947 mFusion->GetSpacing()[1];
948 fusExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mFusion->GetOrigin()[2]) /
949 mFusion->GetSpacing()[2];
950 fusExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mFusion->GetOrigin()[2]) /
951 mFusion->GetSpacing()[2];
952 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
954 //----------------------------------------------------------------------------
957 //----------------------------------------------------------------------------
958 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
963 //2D overlay on 3D image specific case
964 if (refExtent[4] == refExtent[5]) {
966 extent[4] = refExtent[4];
967 extent[5] = refExtent[5];
970 for (int i = 0; i < maxBound; i = i+2) {
971 //if we are totally outside the image
972 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
976 //crop to the limit of the image
977 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
978 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
979 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
980 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
983 for (int i = 0; i < maxBound; i = i+2) {
984 extent[i] = refExtent[i];
985 extent[i+1] = refExtent[i];
988 //----------------------------------------------------------------------------
991 //----------------------------------------------------------------------------
992 void vvSlicer::UpdateOrientation()
994 // Set the camera position
995 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
997 switch (this->SliceOrientation) {
998 case vtkImageViewer2::SLICE_ORIENTATION_XY:
999 cam->SetFocalPoint(0,0,0);
1000 cam->SetPosition(0,0,-1); // -1 if medical ?
1001 cam->SetViewUp(0,-1,0);
1004 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1005 cam->SetFocalPoint(0,0,0);
1006 cam->SetPosition(0,-1,0); // 1 if medical ?
1007 cam->SetViewUp(0,0,1);
1010 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1011 cam->SetFocalPoint(0,0,0);
1012 cam->SetPosition(-1,0,0); // -1 if medical ?
1013 cam->SetViewUp(0,0,1);
1018 //----------------------------------------------------------------------------
1021 //----------------------------------------------------------------------------
1022 void vvSlicer::SetOpacity(double s)
1024 this->GetImageActor()->SetOpacity(s);
1026 //----------------------------------------------------------------------------
1029 //----------------------------------------------------------------------------
1030 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1032 this->Superclass::SetRenderWindow(rw);
1033 this->SetupInteractor(rw->GetInteractor());
1034 ca->SetImageActor(this->GetImageActor());
1035 ca->SetWindowLevel(this->GetWindowLevel());
1036 ca->SetText(2, "<slice>");
1037 ca->SetText(3, "<window>\n<level>");
1049 crossCursor->SetModelBounds(bounds);
1050 this->GetRenderer()->AddActor(pdmA);
1051 this->GetRenderer()->AddActor(ca);
1052 this->GetRenderer()->ResetCamera();
1054 //this is just a mapping between the labeling of the orientations presented to the user and
1055 //the one used by vtk
1056 SetSliceOrientation(2-(orientation%3));
1059 //----------------------------------------------------------------------------
1062 //----------------------------------------------------------------------------
1063 void vvSlicer::ResetCamera()
1065 if (this->GetInput()) {
1066 double* input_bounds=this->GetInput()->GetBounds();
1067 double bmax=input_bounds[1]-input_bounds[0];
1068 if (bmax < input_bounds[3]-input_bounds[2]) bmax=input_bounds[3]-input_bounds[2];
1069 if (bmax < input_bounds[5]-input_bounds[4]) bmax=input_bounds[5]-input_bounds[4];
1070 this->GetRenderer()->ResetCamera();
1071 this->GetRenderer()->GetActiveCamera()->SetParallelScale(bmax/2);
1074 //----------------------------------------------------------------------------
1077 //----------------------------------------------------------------------------
1078 void vvSlicer::SetDisplayMode(bool i)
1080 this->GetImageActor()->SetVisibility(i);
1081 this->GetAnnotation()->SetVisibility(i);
1082 this->GetRenderer()->SetDraw(i);
1084 mLandActor->SetVisibility(i);
1085 pdmA->SetVisibility(i);
1087 UpdateDisplayExtent();
1089 //----------------------------------------------------------------------------
1092 //----------------------------------------------------------------------------
1093 void vvSlicer::FlipHorizontalView()
1095 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1097 double *position = cam->GetPosition();
1098 switch (this->SliceOrientation) {
1099 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1100 cam->SetPosition(position[0],position[1],-position[2]);
1103 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1104 cam->SetPosition(position[0],-position[1],position[2]);
1107 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1108 cam->SetPosition(-position[0],position[1],position[2]);
1111 this->Renderer->ResetCameraClippingRange();
1112 this->UpdateDisplayExtent();
1115 //----------------------------------------------------------------------------
1118 //----------------------------------------------------------------------------
1119 void vvSlicer::FlipVerticalView()
1121 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1123 FlipHorizontalView();
1124 double *viewup = cam->GetViewUp();
1125 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1126 this->UpdateDisplayExtent();
1129 //----------------------------------------------------------------------------
1132 //----------------------------------------------------------------------------
1133 void vvSlicer::SetColorWindow(double window)
1135 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1137 double level = this->GetWindowLevel()->GetLevel();
1138 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1141 this->vtkImageViewer2::SetColorWindow(window);
1143 //----------------------------------------------------------------------------
1146 //----------------------------------------------------------------------------
1147 void vvSlicer::SetColorLevel(double level)
1149 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1151 double window = this->GetWindowLevel()->GetWindow();
1152 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1155 this->vtkImageViewer2::SetColorLevel(level);
1157 //----------------------------------------------------------------------------
1159 //----------------------------------------------------------------------------
1160 // Returns the min an the max value in a 41x41 region around the mouse pointer
1161 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
1163 //Get mouse pointer position in view coordinates
1164 double fLocalExtents[6];
1165 for(int i=0; i<3; i++) {
1166 fLocalExtents[i*2 ] = mCurrent[i];
1167 fLocalExtents[i*2+1] = mCurrent[i];
1169 this->Renderer->WorldToView(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1170 this->Renderer->WorldToView(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1171 for(int i=0; i<3; i++) {
1172 if (i!=SliceOrientation) { //SR: assumes that SliceOrientation is valid in ViewCoordinates (???)
1173 fLocalExtents[i*2 ] -= 0.2;
1174 fLocalExtents[i*2+1] += 0.2;
1177 this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1178 this->Renderer->ViewToWorld(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1180 //Convert to image pixel coordinates (rounded)
1181 int iLocalExtents[6];
1182 for(int i=0; i<3; i++) {
1183 fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1184 fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1186 iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
1187 iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
1189 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1190 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1193 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1194 voiFilter->SetInput(this->GetInput());
1195 voiFilter->SetVOI(iLocalExtents);
1196 voiFilter->Update();
1197 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1203 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1204 accFilter->SetInput(voiFilter->GetOutput());
1205 accFilter->Update();
1207 min = *(accFilter->GetMin());
1208 max = *(accFilter->GetMax());
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::string worldPos = "";
1222 std::stringstream world1;
1223 std::stringstream world2;
1224 std::stringstream world3;
1225 world1 << (int)mCurrent[0];
1226 world2 << (int)mCurrent[1];
1227 world3 << (int)mCurrent[2];
1228 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1229 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1230 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1232 if (pdmA->GetVisibility()) {
1233 double x = mCursor[0];
1234 double y = mCursor[1];
1235 double z = mCursor[2];
1236 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1237 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1238 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1240 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1241 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1242 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1243 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1244 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1245 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1246 vtkRenderer * renderer = this->Renderer;
1248 renderer->WorldToView(x,y,z);
1249 renderer->ViewToNormalizedViewport(x,y,z);
1250 renderer->NormalizedViewportToViewport(x,y);
1251 renderer->ViewportToNormalizedDisplay(x,y);
1252 renderer->NormalizedDisplayToDisplay(x,y);
1253 crossCursor->SetFocalPoint(x,y,z);
1255 crossCursor->SetFocalPoint(-1,-1,z);
1258 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1259 X <= this->GetInput()->GetWholeExtent()[1] &&
1260 Y >= this->GetInput()->GetWholeExtent()[2] &&
1261 Y <= this->GetInput()->GetWholeExtent()[3] &&
1262 Z >= this->GetInput()->GetWholeExtent()[4] &&
1263 Z <= this->GetInput()->GetWholeExtent()[5]) {
1267 std::stringstream pixel1;
1268 std::stringstream pixel2;
1269 std::stringstream pixel3;
1270 std::stringstream temps;
1274 temps << mCurrentTSlice;
1275 this->GetInput()->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1276 this->GetInput()->Update();
1277 double value = this->GetInput()->GetScalarComponentAsDouble(ix, iy, iz, 0);
1279 std::stringstream val;
1281 worldPos += "data value : " + val.str();
1282 worldPos += "\n mm : " + world1.str() + " " + world2.str() + " " +
1283 world3.str() + " " + temps.str();
1284 worldPos += "\n pixel : " + pixel1.str() + " " + pixel2.str() + " " +
1285 pixel3.str() + " " + temps.str();
1287 ca->SetText(1,worldPos.c_str());
1289 if (mOverlay && mOverlayActor->GetVisibility()) {
1290 mOverlayMapper->SetWindow(this->GetColorWindow());
1291 mOverlayMapper->SetLevel(this->GetColorLevel());
1292 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1293 mOverlayMapper->GetOutput()->Update();
1294 mOverlayMapper->Update();
1298 //this->Superclass::Render();
1299 this->GetRenderWindow()->Render();
1301 //----------------------------------------------------------------------------
1304 //----------------------------------------------------------------------------
1305 void vvSlicer::UpdateCursorPosition()
1307 if (this->GetImageActor()->GetVisibility()) {
1308 pdmA->SetVisibility(true);
1309 mCursor[0] = mCurrent[0];
1310 mCursor[1] = mCurrent[1];
1311 mCursor[2] = mCurrent[2];
1312 mCursor[3] = mCurrentTSlice;
1315 //----------------------------------------------------------------------------
1318 //----------------------------------------------------------------------------
1319 void vvSlicer::UpdateLandmarks()
1321 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1322 if (pd->GetPoints()) {
1323 mLandGlyph->SetRange(0,1);
1324 mLandGlyph->Modified();
1325 mLandGlyph->Update();
1327 mClipBox->Modified();
1328 mLandClipper->Update();
1329 mLandMapper->Update();
1333 //----------------------------------------------------------------------------
1336 //----------------------------------------------------------------------------
1337 void vvSlicer::SetSlice(int slice)
1339 int *range = this->GetSliceRange();
1341 if (slice < range[0]) {
1343 } else if (slice > range[1]) {
1348 if (this->Slice == slice) {
1352 this->Slice = slice;
1355 this->UpdateDisplayExtent();
1357 // Seems to work without this line
1360 //----------------------------------------------------------------------------
1363 //----------------------------------------------------------------------------
1364 void vvSlicer::SetContourSlice()
1366 if (mSurfaceCutActors.size() > 0)
1367 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1368 i!=mSurfaceCutActors.end(); i++)
1369 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1370 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 //----------------------------------------------------------------------------