wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition( tmpPx , tmpPy );
- int colorWin=_backWindow - 2*( _backPx - tmpPx );
- int colorLev=_backLevel + 2*( _backPy - tmpPy );
+
+
+ int colorWin;
+ int colorLev;
+
+
+ vtkImageData* imgrange = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->GetVtkBaseData()->GetImageData();
+
+ if(imgrange != NULL){
+ double* scalarrange = imgrange->GetScalarRange();
+ double scalarr = scalarrange[1] - scalarrange[0];
+ //std::cout<<"scalar r="<<scalarr<<std::endl;
+ int w, h;
+ ((wxWindow*)wxVTKiren)->GetSize(&w, &h);
+ int dx = (scalarr*( _backPx - tmpPx ))/w;
+ int dy = (scalarr*( _backPy - tmpPy ))/h;
+ //colorWin=_backWindow - (scalarr)*( _backPx - tmpPx );
+ colorWin=_backWindow - dx;
+ colorLev=_backLevel + dy;
+ }else{
+ colorWin=_backWindow - 2*( _backPx - tmpPx );
+ colorLev=_backLevel + 2*( _backPy - tmpPy );
+ }
if (colorWin<0)
{
_vtkimageviewer2->GetRenderer()->GradientBackgroundOn();
_vtkimageviewer2->GetRenderer()->SetBackground( 0.33 , 0.33 , 0.33 );
_vtkimageviewer2->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );
+ _colortable = NULL;
}
//-------------------------------------------------------------------
vtkImageViewer2_XYZ::~vtkImageViewer2_XYZ()
vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _vtkimageviewer2->GetWindowLevel();
- if(colortable!=NULL&&colortable->GetSize()>0){
+ if(colortable!=NULL&&colortable->GetSize()>0 && _colortable != colortable){
+ _colortable = colortable;
imagemaptowindowlevel->SetLookupTable(colortable);
}