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() // virtual
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;
78 //----------------------------------------------------------------------------
79 int LayerImageBase::CleanZ(int z)
82 _image->GetWholeExtent(ext);
89 if ( z > (ext[5]-ext[4]) )
97 //----------------------------------------------------------------------------
98 void LayerImageBase::onThreshold()
103 int z=CleanZ( GetZ() );
105 if (!GetActorPresent())
107 if (_thresholdTable==NULL)
110 _thresholdTable = vtkLookupTable::New();
113 if (_thresholdMapper==NULL)
115 _thresholdMapper = vtkImageMapToColors::New( );
118 if (_thresholdActor==NULL)
120 _thresholdActor = vtkImageActor::New( );
121 _thresholdActor->SetOpacity( 0.6 );
122 _thresholdActor->InterpolateOn( );
123 _thresholdActor->SetPosition( 0,0, 900-1 );
125 _baseView->GetRenderer()->AddActor( _thresholdActor );
126 _actorPresent = true;
127 } // !GetActorPresent()
129 ConfigLookupTable(); // virtual method
130 _imageReslicer->SetInput( GetImage() );
131 _imageReslicer->SetInformationInput( GetImage() );
132 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
133 _imageReslicer->SetOutputDimensionality(2);
134 _imageReslicer->SetInterpolationModeToLinear();
135 _imageReslicer->SetResliceAxesOrigin(0,0,z);
137 vtkImageData *img = _imageReslicer->GetOutput();
139 img->UpdateInformation();
141 _thresholdMapper->SetInput( img );
142 _thresholdMapper->SetLookupTable( _thresholdTable );
143 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
149 //----------------------------------------------------------------------------
150 void LayerImageBase::onThresholdChange()
158 //----------------------------------------------------------------------------
159 void LayerImageBase::onThresholdInterpolation(bool interpolate)
161 if (_thresholdActor!=NULL)
165 _thresholdActor->InterpolateOn( );
169 _thresholdActor->InterpolateOff( );
174 //----------------------------------------------------------------------------
175 void LayerImageBase::onThresholdChangeOpacity (int opacity)
179 _thresholdActor->SetOpacity(opacity*0.1);
183 //----------------------------------------------------------------------------
184 void LayerImageBase::onThresholdRemove()
188 wxVtkBaseView * baseView = _baseView;
189 baseView->GetRenderer()->RemoveActor( _thresholdActor );
190 _actorPresent = false;