3 * \brief Class bbtk::ThresholdImageView .
6 #include "LayerImageBase.h"
9 //---------------------------------------------------------------------------------------------
10 //---------------------------------------------------------------------------------------------
11 //---------------------------------------------------------------------------------------------
13 ColorLayerImageBasevtkInteractor::ColorLayerImageBasevtkInteractor(LayerImageBase* layerImageBase)
15 _layerImageBase=layerImageBase;
18 //---------------------------------------------------------------------------------------------
19 ColorLayerImageBasevtkInteractor::~ColorLayerImageBasevtkInteractor()
24 //---------------------------------------------------------------------------------------------
25 bool ColorLayerImageBasevtkInteractor::OnMouseMove()
27 printf("EED ColorLayerImageBasevtkInteractor::OnMouseMove \n");
28 if (_vtkInteractorStyleBaseView->GetRefresh_waiting()==true)
30 _layerImageBase->GetvtkImageReslice()->Modified();
37 //---------------------------------------------------------------------------------------------
38 //---------------------------------------------------------------------------------------------
39 //---------------------------------------------------------------------------------------------
43 LayerImageBase::LayerImageBase()
45 _actorPresent = false;
47 _thresholdTable = NULL;
48 _thresholdMapper = NULL;
49 _thresholdActor = NULL;
52 _imageReslicer = vtkImageReslice::New();
56 //----------------------------------------------------------------------------
57 LayerImageBase::~LayerImageBase()
61 //----------------------------------------------------------------------------
62 void LayerImageBase::SetZ(int z)
67 //----------------------------------------------------------------------------
68 int LayerImageBase::GetZ() // virtual
73 //----------------------------------------------------------------------------
74 vtkImageData* LayerImageBase::GetImage()
79 //----------------------------------------------------------------------------
80 bool LayerImageBase::GetActorPresent()
87 //----------------------------------------------------------------------------
88 void LayerImageBase::SetImage(vtkImageData* image)
93 //----------------------------------------------------------------------------
94 void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview)
96 printf("EED LayerImageBase::SetwxVtkBaseView start baseview:%p \n", baseview);
100 vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView());
101 isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) );
103 printf("EED LayerImageBase::SetwxVtkBaseView end \n");
106 //----------------------------------------------------------------------------
107 wxVtkBaseView *LayerImageBase::GetwxVtkBaseView()
112 //----------------------------------------------------------------------------
113 void LayerImageBase::Refresh()
115 printf("EED LayerImageBase::Refresh\n");
118 _baseView->Refresh();
123 //----------------------------------------------------------------------------
124 vtkLookupTable* LayerImageBase::GetThresholdTable()
126 return _thresholdTable;
129 //----------------------------------------------------------------------------
130 int LayerImageBase::CleanZ(int z)
133 _image->GetWholeExtent(ext);
140 if ( z > (ext[5]-ext[4]) )
148 //----------------------------------------------------------------------------
149 void LayerImageBase::onThreshold()
152 printf("EED LayerImageBase::onThreshold start \n");
154 if ((_image!=NULL) && (_baseView!=NULL))
156 int z=CleanZ( GetZ() );
158 if (!GetActorPresent())
160 if (_thresholdTable==NULL)
163 _thresholdTable = vtkLookupTable::New();
166 if (_thresholdMapper==NULL)
168 _thresholdMapper = vtkImageMapToColors::New( );
171 if (_thresholdActor==NULL)
173 _thresholdActor = vtkImageActor::New( );
174 _thresholdActor->SetOpacity( 0.6 );
175 _thresholdActor->InterpolateOn( );
176 _thresholdActor->SetPosition( 0,0, -900-1 );
178 _baseView->GetRenderer()->AddActor( _thresholdActor );
179 _actorPresent = true;
180 } // !GetActorPresent()
182 ConfigLookupTable(); // virtual method
183 _imageReslicer->SetInput( GetImage() );
184 _imageReslicer->SetInformationInput( GetImage() );
185 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
186 _imageReslicer->SetOutputDimensionality(2);
187 // _imageReslicer->SetInterpolationModeToLinear();
188 _imageReslicer->SetInterpolationModeToNearestNeighbor();
189 _imageReslicer->SetResliceAxesOrigin(0,0,z);
191 vtkImageData *img = _imageReslicer->GetOutput();
193 // img->UpdateInformation();
195 _thresholdMapper->SetInput( img );
196 _thresholdMapper->SetLookupTable( _thresholdTable );
197 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
199 printf("EED LayerImageBase::onThreshold working \n");
203 printf("EED LayerImageBase::onThreshold end");
208 //----------------------------------------------------------------------------
209 void LayerImageBase::onThresholdChange()
217 //----------------------------------------------------------------------------
218 void LayerImageBase::onThresholdInterpolation(bool interpolate)
220 if (_thresholdActor!=NULL)
224 _thresholdActor->InterpolateOn( );
228 _thresholdActor->InterpolateOff( );
233 //----------------------------------------------------------------------------
234 void LayerImageBase::onThresholdChangeOpacity (int opacity)
238 _thresholdActor->SetOpacity(opacity*0.1);
242 //----------------------------------------------------------------------------
243 void LayerImageBase::onThresholdRemove()
247 wxVtkBaseView * baseView = _baseView;
248 baseView->GetRenderer()->RemoveActor( _thresholdActor );
249 _actorPresent = false;
253 //----------------------------------------------------------------------------
254 vtkLookupTable *LayerImageBase::GetvtkLookupTable()
256 return _thresholdTable;
259 vtkImageReslice *LayerImageBase::GetvtkImageReslice()
261 return _imageReslicer;