4 * \brief Class bbtk::ThresholdImageView .
7 #include "LayerImageBase.h"
9 LayerImageBase::LayerImageBase()
11 _actorPresent = false;
13 _thresholdTable = NULL;
14 _thresholdMapper = NULL;
15 _thresholdActor = NULL;
18 _imageReslicer = vtkImageReslice::New();
22 //----------------------------------------------------------------------------
23 LayerImageBase::~LayerImageBase()
27 //----------------------------------------------------------------------------
28 void LayerImageBase::SetZ(int z)
33 //----------------------------------------------------------------------------
34 int LayerImageBase::GetZ() // virtual
39 //----------------------------------------------------------------------------
40 vtkImageData* LayerImageBase::GetImage()
45 //----------------------------------------------------------------------------
46 bool LayerImageBase::GetActorPresent()
53 //----------------------------------------------------------------------------
54 void LayerImageBase::SetImage(vtkImageData* image)
59 //----------------------------------------------------------------------------
60 void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview)
65 //----------------------------------------------------------------------------
66 wxVtkBaseView *LayerImageBase::GetwxVtkBaseView()
71 //----------------------------------------------------------------------------
72 void LayerImageBase::Refresh()
81 //----------------------------------------------------------------------------
82 vtkLookupTable* LayerImageBase::GetThresholdTable()
84 return _thresholdTable;
87 //----------------------------------------------------------------------------
88 int LayerImageBase::CleanZ(int z)
91 _image->GetWholeExtent(ext);
98 if ( z > (ext[5]-ext[4]) )
106 //----------------------------------------------------------------------------
107 void LayerImageBase::onThreshold()
110 if ((_image!=NULL) && (_baseView!=NULL))
112 int z=CleanZ( GetZ() );
114 if (!GetActorPresent())
116 if (_thresholdTable==NULL)
119 _thresholdTable = vtkLookupTable::New();
122 if (_thresholdMapper==NULL)
124 _thresholdMapper = vtkImageMapToColors::New( );
127 if (_thresholdActor==NULL)
129 _thresholdActor = vtkImageActor::New( );
130 _thresholdActor->SetOpacity( 0.6 );
131 _thresholdActor->InterpolateOn( );
132 _thresholdActor->SetPosition( 0,0, 900-1 );
134 _baseView->GetRenderer()->AddActor( _thresholdActor );
135 _actorPresent = true;
136 } // !GetActorPresent()
138 ConfigLookupTable(); // virtual method
139 _imageReslicer->SetInput( GetImage() );
140 _imageReslicer->SetInformationInput( GetImage() );
141 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
142 _imageReslicer->SetOutputDimensionality(2);
143 _imageReslicer->SetInterpolationModeToLinear();
144 _imageReslicer->SetResliceAxesOrigin(0,0,z);
146 vtkImageData *img = _imageReslicer->GetOutput();
148 img->UpdateInformation();
150 _thresholdMapper->SetInput( img );
151 _thresholdMapper->SetLookupTable( _thresholdTable );
152 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
158 //----------------------------------------------------------------------------
159 void LayerImageBase::onThresholdChange()
167 //----------------------------------------------------------------------------
168 void LayerImageBase::onThresholdInterpolation(bool interpolate)
170 if (_thresholdActor!=NULL)
174 _thresholdActor->InterpolateOn( );
178 _thresholdActor->InterpolateOff( );
183 //----------------------------------------------------------------------------
184 void LayerImageBase::onThresholdChangeOpacity (int opacity)
188 _thresholdActor->SetOpacity(opacity*0.1);
192 //----------------------------------------------------------------------------
193 void LayerImageBase::onThresholdRemove()
197 wxVtkBaseView * baseView = _baseView;
198 baseView->GetRenderer()->RemoveActor( _thresholdActor );
199 _actorPresent = false;