69 #include "vtkInformation.h"
71 #include "vtkSmartPointer.h"
73 #include "vtkCamera.h"
74 #include "vtkCommand.h"
75 #include "vtkImageActor.h"
76 #include "vtkImageData.h"
77 #include "vtkImageMapToWindowLevelColors.h"
78 #include "vtkInteractorStyleImage.h"
79 #include "vtkObjectFactory.h"
80 #include "vtkRenderWindow.h"
81 #include "vtkRenderWindowInteractor.h"
82 #include "vtkRenderer.h"
83 #include "vtkMatrix4x4.h"
84 #include "vtkScalarBarActor.h"
86 #include "vtkCornerAnnotation.h"
87 #include "vtkTextProperty.h"
88 #include "vtkLookupTable.h"
91 #include "vtkCutter.h"
92 #include "vtkProperty.h"
94 #include "vtkPolyDataMapper.h"
95 #include "vtkPoints.h"
96 #include "vtkIdList.h"
97 #include "vtkOutlineSource.h"
98 #include "vtkMatrixToLinearTransform.h"
99 #include "vtkPointData.h"
100 #include "vtkUnsignedCharArray.h"
101 #include "vtkIntArray.h"
102 #include "vtkImageAccumulate.h"
103 #include "vtkInteractorStyleImage.h"
169 Superclass::SetInput(in);
171 this->
IsColor = ( in->GetNumberOfScalarComponents() > 1 );
176 this->ImageActor->SetInput(this->WindowLevel->GetOutput());
177 this->WindowLevel->SetLookupTable(NULL);
179 int type = in->GetScalarSize();
180 double threshold = pow((
double)2, (
int)8*type) - 1;
182 this->WindowLevel->SetWindow(threshold);
183 this->WindowLevel->SetLevel(threshold/2);
190 this->ImageActor->SetInput(this->WindowLevel->GetOutput());
191 this->WindowLevel->SetLookupTable(this->
LookupTable);
224 this->UpdateOrientation();
233 this->WindowLevel->SetLookupTable(this->
LookupTable);
260 Superclass::SetColorWindow(t);
264 double level = this->GetColorLevel();
266 double v_min = level - t;
267 double v_max = level + t;
280 Superclass::SetColorLevel(s);
284 double t = 0.5 * this->GetColorWindow();
285 double v_min = s - t;
286 double v_max = s + t;
298 const double & y,
const double & z)
300 double pos[3] = { x, y, z };
312 if ( !this->GetInput() )
319 vtkImageData *input = this->GetInput();
321 int *extent = input->GetWholeExtent();
323 if ( !( ( indices[0] < extent[0] ) || ( indices[0] > extent[1] )
324 || ( indices[1] < extent[2] ) || ( indices[1] > extent[3] )
325 || ( indices[2] < extent[4] ) || ( indices[2] > extent[5] ) ) )
327 value = input->GetScalarComponentAsDouble(indices[0], indices[1],
328 indices[2], component);
341 vtkImageData *input = this->GetInput();
345 double *nullpos =
new double[3];
353 double *spacing = input->GetSpacing();
354 double *origin = input->GetOrigin();
356 double unorientedposition[4];
357 for (
unsigned int i = 0; i < 3; i++ )
359 unorientedposition[i] = origin[i] + spacing[i] * indices[i];
361 unorientedposition[3] = 1;
364 double *position =
new double[4];
365 this->GetOrientationMatrix()->MultiplyPoint(unorientedposition, position);
376 vtkImageData *input = this->GetInput();
380 int *nullpos =
new int[3];
388 double unorientedposition[4] = { position[0], position[1], position[2], 1 };
389 double spacing[4] = { input->GetSpacing()[0],
390 input->GetSpacing()[1],
391 input->GetSpacing()[2],
393 double origin[4] = { input->GetOrigin()[0],
394 input->GetOrigin()[1],
395 input->GetOrigin()[2],
399 vtkSmartPointer< vtkMatrix4x4 > inverse = vtkSmartPointer< vtkMatrix4x4 >::New();
400 vtkMatrix4x4::Invert (this->GetOrientationMatrix(), inverse);
401 inverse->MultiplyPoint (unorientedposition, unorientedposition);
403 int *indices =
new int[3];
404 for (
unsigned int i = 0; i < 3; i++ )
406 if ( fabs (spacing[i]) > 1e-5 )
408 indices[i] = vtkMath::Round( ( unorientedposition[i] - origin[i] ) / spacing[i] );
421 if ( this->Renderer )
423 this->Renderer->SetBackground(rgb);
430 if ( this->Renderer )
432 this->Renderer->SetBackground(r, g, b);
439 if ( this->Renderer )
441 return this->Renderer->GetBackground();
452 vtkImageData *input = this->GetInput();
461 double *range = input->GetScalarRange();
462 double window = range[1] - range[0];
463 double level = 0.5 * ( range[1] + range[0] );
479 double window = range[1] - range[0];
480 double level = 0.5 * ( range[1] + range[0] );
495 if ( this->Renderer )
497 this->Renderer->ResetCamera();
512 this->Interactor->Enable();
518 this->Interactor->Disable();
524 return ( this->Interactor->GetEnabled() == 1 );
547 if ( this->RenderWindow && !this->RenderWindow->GetNeverRendered() )
549 if ( this->FirstRender )
552 this->FirstRender = 0;
556 if ( this->GetInput() )
558 this->RenderWindow->Render();
565 return this->Interactor;
571 if ( this->GetRenderWindow() )
573 return this->GetRenderWindow()->GetInteractor();
577 return static_cast< vtkRenderWindowInteractor *
>( 0x0 );
584 if ( this->Renderer )
586 vtkCamera *cam = this->Renderer->GetActiveCamera();
589 cam->SetPosition (arg);
596 if ( this->Renderer )
598 vtkCamera *cam = this->Renderer->GetActiveCamera();
601 return cam->GetPosition ();
605 return static_cast< double *
>( 0x0 );
611 if ( this->Renderer )
613 vtkCamera *cam = this->Renderer->GetActiveCamera();
616 cam->SetFocalPoint (arg);
624 if ( this->Renderer )
626 vtkCamera *cam = this->Renderer->GetActiveCamera();
629 return cam->GetFocalPoint ();
632 return static_cast< double *
>( 0x0 );
638 if ( this->Renderer )
640 vtkCamera *cam = this->Renderer->GetActiveCamera();
643 cam->SetViewUp (arg);
651 if ( this->Renderer )
653 vtkCamera *cam = this->Renderer->GetActiveCamera();
657 return cam->GetViewUp();
660 return static_cast< double *
>( 0x0 );
666 if ( this->Renderer )
668 vtkCamera *cam = this->Renderer->GetActiveCamera();
672 cam->SetParallelScale (arg);
680 if ( this->Renderer )
682 vtkCamera *cam = this->Renderer->GetActiveCamera();
686 return cam->GetParallelScale();
717 this->
Level = iLevel;
float IntersectionLineWidth
virtual void SetColorLevel(double s)
virtual void SetShowAnnotations(const int &iShowAnnotations)
Change the visibility of the annotations.
virtual bool GetEnabled(void)
Enable or Disable interaction on the view.
virtual double * GetWorldCoordinatesFromImageCoordinates(int indices[3])
Convert an indices coordinate point (image coordinates) into a world coordinate point.
vtkTextProperty * TextProperty
void SetLevel(double iLevel)
void SetWindow(double iWindow)
virtual double GetValueAtPosition(double worldcoordinates[3], int component=0)
Get the pixel value at a given world coordinate point in space, return zero if out of bounds...
void SetWorldCoordinates(const double &x, const double &y, const double &z)
Set the world coordinates.
virtual void Disable(void)
Enable or Disable interaction on the view.
virtual void ResetWindowLevel(void)
Reset the window level.
double * GetCameraPosition(void)
Get the camera position.
virtual int * GetImageCoordinatesFromWorldCoordinates(double position[3])
Convert a world coordinate point into an image indices coordinate point.
virtual void Enable(void)
Enable or Disable interaction on the view.
double GetCameraParallelScale(void)
Get the camera parallel scale.
std::string DirectionAnnotationMatrix[3][2]
vtkScalarBarActor * ScalarBarActor
void SetCameraPosition(double *arg)
Set the camera position.
virtual void SetLookupTable(vtkLookupTable *lookuptable)
virtual void SetBackground(double rgb[3])
Set the background color. Format is RGB, 0 <= R,G,B <=1 Example: SetBackground(0.9,0.9,0.9) for grey-white.
void SetCameraViewUp(double *arg)
Set the camera view up.
double * GetCameraFocalPoint(void)
Get the camera focal point.
virtual void SetOrientationMatrix(vtkMatrix4x4 *matrix)
virtual void SetInput(vtkImageData *input)
virtual vtkRenderWindowInteractor * GetRenderWindowInteractor()
This class is a top-level convenience class for displaying a scalar - or RGB image in a 2D or 3D scen...
virtual double * GetBackground(void)
virtual void Reset(void)
Reset position - zoom - window/level to default.
virtual void Update(void)
vtkMatrix4x4 * OrientationMatrix
virtual void Render(void)
virtual void SetTextProperty(vtkTextProperty *textproperty)
virtual void SetShowScalarBar(const bool &)
Show/Hide scalar bar.
vtkMatrixToLinearTransform * OrientationTransform
vtkCornerAnnotation * CornerAnnotation
virtual vtkRenderWindowInteractor * GetInteractor()
double * GetCameraViewUp(void)
Get the camera view up.
vtkLookupTable * LookupTable
void SetCameraFocalPoint(double *arg)
Set the camera focal point.
#define vtkSetObjectMacro2Body(object, type, _arg)
virtual void SetColorWindow(double s)
Set window and level for mapping pixels to colors.
vtkCxxRevisionMacro(vtkViewImage,"$Revision: 546 $")
void SetCameraParallelScale(double arg)
Set the camera parallel scale.
virtual void ResetCamera(void)
Reset the camera.