2 #include "manualInteractorWindowLevel.h"
3 #include "wxVtk2DBaseView.h"
4 //-------------------------------------------------------------------
5 //-------------------------------------------------------------------
6 //-------------------------------------------------------------------
8 manualInteractorWindowLevel::manualInteractorWindowLevel()
10 _stateWindowLevel = false;
17 //-------------------------------------------------------------------
19 manualInteractorWindowLevel::~manualInteractorWindowLevel()
23 //-------------------------------------------------------------------
25 bool manualInteractorWindowLevel::OnMouseMove() // virtual
28 if (_stateWindowLevel==true)
31 wxVTKRenderWindowInteractor *wxVTKiren;
32 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
33 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
38 vtkImageData* imgrange = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->GetVtkBaseData()->GetImageData();
41 double* scalarrange = imgrange->GetScalarRange();
42 double scalarr = scalarrange[1] - scalarrange[0];
43 //std::cout<<"scalar r="<<scalarr<<std::endl;
45 ((wxWindow*)wxVTKiren)->GetSize(&w, &h);
48 double dx = (scalarr*( _backPx - tmpPx ))/dw;
49 double dy = (scalarr*( _backPy - tmpPy ))/dh;
51 //colorWin=_backWindow - (scalarr)*( _backPx - tmpPx );
52 colorWin=_backWindow - dx;
53 colorLev=_backLevel + dy;
55 colorWin=_backWindow - 2*( _backPx - tmpPx );
56 colorLev=_backLevel + 2*( _backPy - tmpPy );
76 vtkImageViewer2 *vtkimageviewer2;
77 vtkimageviewer2=((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
78 vtkimageviewer2->SetColorWindow(colorWin);
79 vtkimageviewer2->SetColorLevel(colorLev);
80 // vtkimageviewer2->Render();
85 //-------------------------------------------------------------------
87 bool manualInteractorWindowLevel::OnMiddleButtonDown() // virtual
89 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&
90 (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ){
91 _stateWindowLevel = true;
92 wxVTKRenderWindowInteractor *wxVTKiren;
93 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
94 wxVTKiren->GetEventPosition( _backPx , _backPy );
95 _backWindow = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorWindow();
96 _backLevel = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorLevel();
101 //-------------------------------------------------------------------
103 bool manualInteractorWindowLevel::OnMiddleButtonUp() // virtual
105 if (_stateWindowLevel==true)
107 _stateWindowLevel=false;