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()
28 printf("EED ColorLayerImageBasevtkInteractor::OnMouseMove \n");
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)
97 printf("EED LayerImageBase::SetwxVtkBaseView start baseview:%p \n", baseview);
101 vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView());
102 isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) );
104 printf("EED LayerImageBase::SetwxVtkBaseView end \n");
107 //----------------------------------------------------------------------------
108 wxVtkBaseView *LayerImageBase::GetwxVtkBaseView()
113 //----------------------------------------------------------------------------
114 void LayerImageBase::Refresh()
116 printf("EED LayerImageBase::Refresh\n");
119 _baseView->Refresh();
124 //----------------------------------------------------------------------------
125 vtkLookupTable* LayerImageBase::GetThresholdTable()
127 return _thresholdTable;
130 //----------------------------------------------------------------------------
131 int LayerImageBase::CleanZ(int z)
134 _image->GetWholeExtent(ext);
141 if ( z > (ext[5]-ext[4]) )
149 //----------------------------------------------------------------------------
150 void LayerImageBase::onThreshold()
153 printf("EED LayerImageBase::onThreshold start \n");
155 if ((_image!=NULL) && (_baseView!=NULL))
157 int z=CleanZ( GetZ() );
159 if (!GetActorPresent())
161 if (_thresholdTable==NULL)
164 _thresholdTable = vtkLookupTable::New();
167 if (_thresholdMapper==NULL)
169 _thresholdMapper = vtkImageMapToColors::New( );
172 if (_thresholdActor==NULL)
174 _thresholdActor = vtkImageActor::New( );
175 _thresholdActor->SetOpacity( 0.6 );
176 _thresholdActor->InterpolateOn( );
177 _thresholdActor->SetPosition( 0,0, -900-1 );
179 _baseView->GetRenderer()->AddActor( _thresholdActor );
180 _actorPresent = true;
181 } // !GetActorPresent()
183 ConfigLookupTable(); // virtual method
184 _imageReslicer->SetInput( GetImage() );
185 _imageReslicer->SetInformationInput( GetImage() );
186 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
187 _imageReslicer->SetOutputDimensionality(2);
188 // _imageReslicer->SetInterpolationModeToLinear();
189 _imageReslicer->SetInterpolationModeToNearestNeighbor();
190 _imageReslicer->SetResliceAxesOrigin(0,0,z);
192 vtkImageData *img = _imageReslicer->GetOutput();
194 // img->UpdateInformation();
196 _thresholdMapper->SetInput( img );
197 _thresholdMapper->SetLookupTable( _thresholdTable );
198 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
200 printf("EED LayerImageBase::onThreshold working \n");
204 printf("EED LayerImageBase::onThreshold end");
209 //----------------------------------------------------------------------------
210 void LayerImageBase::onThresholdChange()
218 //----------------------------------------------------------------------------
219 void LayerImageBase::onThresholdInterpolation(bool interpolate)
221 if (_thresholdActor!=NULL)
225 _thresholdActor->InterpolateOn( );
229 _thresholdActor->InterpolateOff( );
234 //----------------------------------------------------------------------------
235 void LayerImageBase::onThresholdChangeOpacity (int opacity)
239 _thresholdActor->SetOpacity(opacity*0.1);
243 //----------------------------------------------------------------------------
244 void LayerImageBase::onThresholdRemove()
248 wxVtkBaseView * baseView = _baseView;
249 baseView->GetRenderer()->RemoveActor( _thresholdActor );
250 _actorPresent = false;
254 //----------------------------------------------------------------------------
255 vtkLookupTable *LayerImageBase::GetvtkLookupTable()
257 return _thresholdTable;
260 vtkImageReslice *LayerImageBase::GetvtkImageReslice()
262 return _imageReslicer;