4 * \brief Class bbtk::ThresholdImageView .
7 #include "LayerImageBase.h"
9 LayerImageBase::LayerImageBase()
11 _actorPresent = false;
13 _thresholdTable = NULL;
14 _thresholdMapper = NULL;
15 _thresholdActor = NULL;
17 _imageReslicer = vtkImageReslice::New();
21 //----------------------------------------------------------------------------
22 LayerImageBase::~LayerImageBase()
26 //----------------------------------------------------------------------------
27 void LayerImageBase::SetZ(int z)
32 //----------------------------------------------------------------------------
33 int LayerImageBase::GetZ()
38 //----------------------------------------------------------------------------
39 vtkImageData* LayerImageBase::GetImage()
44 //----------------------------------------------------------------------------
45 bool LayerImageBase::GetActorPresent()
52 //----------------------------------------------------------------------------
53 void LayerImageBase::SetImage(vtkImageData* image)
58 //----------------------------------------------------------------------------
59 void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview)
64 //----------------------------------------------------------------------------
65 wxVtkBaseView *LayerImageBase::GetwxVtkBaseView()
72 //----------------------------------------------------------------------------
73 vtkLookupTable* LayerImageBase::GetThresholdTable()
75 return _thresholdTable;
80 //----------------------------------------------------------------------------
81 void LayerImageBase::onThreshold()
85 if (!GetActorPresent())
87 if (_thresholdTable==NULL)
90 _thresholdTable = vtkLookupTable::New();
93 if (_thresholdMapper==NULL)
95 _thresholdMapper = vtkImageMapToColors::New( );
98 if (_thresholdActor==NULL)
100 _thresholdActor = vtkImageActor::New( );
101 _thresholdActor->SetOpacity( 0.6 );
102 _thresholdActor->InterpolateOn( );
103 _thresholdActor->SetPosition( 0,0, 900-1 );
107 _baseView->GetRenderer()->AddActor( _thresholdActor );
108 _actorPresent = true;
109 } // !GetActorPresent()
111 ConfigLookupTable(); // virtual method
112 _imageReslicer->SetInput( GetImage() );
113 _imageReslicer->SetInformationInput( GetImage() );
114 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
115 _imageReslicer->SetOutputDimensionality(2);
116 _imageReslicer->SetInterpolationModeToLinear();
117 _imageReslicer->SetResliceAxesOrigin(0,0,z);
119 vtkImageData *img = _imageReslicer->GetOutput();
121 img->UpdateInformation();
123 _thresholdMapper->SetInput( img );
124 _thresholdMapper->SetLookupTable( _thresholdTable );
125 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
130 //----------------------------------------------------------------------------
131 void LayerImageBase::onThresholdChange()
139 //----------------------------------------------------------------------------
140 void LayerImageBase::onThresholdInterpolation(bool interpolate)
142 if (_thresholdActor!=NULL)
146 _thresholdActor->InterpolateOn( );
150 _thresholdActor->InterpolateOff( );
155 //----------------------------------------------------------------------------
156 void LayerImageBase::onThresholdChangeOpacity (int opacity)
160 _thresholdActor->SetOpacity(opacity*0.1);
164 //----------------------------------------------------------------------------
165 void LayerImageBase::onThresholdRemove()
169 wxVtkBaseView * baseView = _baseView;
170 baseView->GetRenderer()->RemoveActor( _thresholdActor );
171 _actorPresent = false;