4 * \brief Class bbtk::ThresholdImageView .
7 #include "LayerImageBase.h"
10 //---------------------------------------------------------------------------------------------
11 //---------------------------------------------------------------------------------------------
12 //---------------------------------------------------------------------------------------------
14 ColorLayerImageBasevtkInteractor::ColorLayerImageBasevtkInteractor(LayerImageBase* layerImageBase)
16 _layerImageBase=layerImageBase;
19 //---------------------------------------------------------------------------------------------
20 ColorLayerImageBasevtkInteractor::~ColorLayerImageBasevtkInteractor()
25 //---------------------------------------------------------------------------------------------
26 bool ColorLayerImageBasevtkInteractor::OnMouseMove()
29 if (_vtkInteractorStyleBaseView->GetRefresh_waiting()==true)
31 _layerImageBase->GetvtkImageReslice()->Modified();
38 //---------------------------------------------------------------------------------------------
39 //---------------------------------------------------------------------------------------------
40 //---------------------------------------------------------------------------------------------
44 LayerImageBase::LayerImageBase()
46 _actorPresent = false;
48 _thresholdTable = NULL;
49 _thresholdMapper = NULL;
50 _thresholdActor = NULL;
53 _imageReslicer = vtkImageReslice::New();
57 //----------------------------------------------------------------------------
58 LayerImageBase::~LayerImageBase()
62 //----------------------------------------------------------------------------
63 void LayerImageBase::SetZ(int z)
68 //----------------------------------------------------------------------------
69 int LayerImageBase::GetZ() // virtual
74 //----------------------------------------------------------------------------
75 vtkImageData* LayerImageBase::GetImage()
80 //----------------------------------------------------------------------------
81 bool LayerImageBase::GetActorPresent()
88 //----------------------------------------------------------------------------
89 void LayerImageBase::SetImage(vtkImageData* image)
94 //----------------------------------------------------------------------------
95 void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview)
99 vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView());
100 isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) );
103 //----------------------------------------------------------------------------
104 wxVtkBaseView *LayerImageBase::GetwxVtkBaseView()
109 //----------------------------------------------------------------------------
110 void LayerImageBase::Refresh()
112 printf("EED LayerImageBase::Refresh\n");
115 _baseView->Refresh();
120 //----------------------------------------------------------------------------
121 vtkLookupTable* LayerImageBase::GetThresholdTable()
123 return _thresholdTable;
126 //----------------------------------------------------------------------------
127 int LayerImageBase::CleanZ(int z)
130 _image->GetWholeExtent(ext);
137 if ( z > (ext[5]-ext[4]) )
145 //----------------------------------------------------------------------------
146 void LayerImageBase::onThreshold()
149 if ((_image!=NULL) && (_baseView!=NULL))
151 int z=CleanZ( GetZ() );
153 if (!GetActorPresent())
155 if (_thresholdTable==NULL)
158 _thresholdTable = vtkLookupTable::New();
161 if (_thresholdMapper==NULL)
163 _thresholdMapper = vtkImageMapToColors::New( );
166 if (_thresholdActor==NULL)
168 _thresholdActor = vtkImageActor::New( );
169 _thresholdActor->SetOpacity( 0.6 );
170 _thresholdActor->InterpolateOn( );
171 _thresholdActor->SetPosition( 0,0, 900-1 );
173 _baseView->GetRenderer()->AddActor( _thresholdActor );
174 _actorPresent = true;
175 } // !GetActorPresent()
177 ConfigLookupTable(); // virtual method
178 _imageReslicer->SetInput( GetImage() );
179 _imageReslicer->SetInformationInput( GetImage() );
180 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
181 _imageReslicer->SetOutputDimensionality(2);
182 _imageReslicer->SetInterpolationModeToLinear();
183 _imageReslicer->SetResliceAxesOrigin(0,0,z);
185 vtkImageData *img = _imageReslicer->GetOutput();
187 // img->UpdateInformation();
189 _thresholdMapper->SetInput( img );
190 _thresholdMapper->SetLookupTable( _thresholdTable );
191 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
197 //----------------------------------------------------------------------------
198 void LayerImageBase::onThresholdChange()
206 //----------------------------------------------------------------------------
207 void LayerImageBase::onThresholdInterpolation(bool interpolate)
209 if (_thresholdActor!=NULL)
213 _thresholdActor->InterpolateOn( );
217 _thresholdActor->InterpolateOff( );
222 //----------------------------------------------------------------------------
223 void LayerImageBase::onThresholdChangeOpacity (int opacity)
227 _thresholdActor->SetOpacity(opacity*0.1);
231 //----------------------------------------------------------------------------
232 void LayerImageBase::onThresholdRemove()
236 wxVtkBaseView * baseView = _baseView;
237 baseView->GetRenderer()->RemoveActor( _thresholdActor );
238 _actorPresent = false;
242 //----------------------------------------------------------------------------
243 vtkLookupTable *LayerImageBase::GetvtkLookupTable()
245 return _thresholdTable;
248 vtkImageReslice *LayerImageBase::GetvtkImageReslice()
250 return _imageReslicer;