1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
27 #include "manualInteractorWindowLevel.h"
28 #include "wxVtk2DBaseView.h"
29 //-------------------------------------------------------------------
30 //-------------------------------------------------------------------
31 //-------------------------------------------------------------------
33 manualInteractorWindowLevel::manualInteractorWindowLevel()
35 _stateWindowLevel = false;
42 //-------------------------------------------------------------------
44 manualInteractorWindowLevel::~manualInteractorWindowLevel()
48 //-------------------------------------------------------------------
50 bool manualInteractorWindowLevel::OnMouseMove() // virtual
52 if (_stateWindowLevel==true)
55 crea::wxVTKRenderWindowInteractor *wxVTKiren;
56 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
57 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
60 vtkImageData* imgrange = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->GetVtkBaseData()->GetImageData();
63 double* scalarrange = imgrange->GetScalarRange();
65 if (scalarrange[1] == scalarrange[0])
67 scalarr=scalarrange[1];
68 if (scalarrange[1]==0) {scalarr=100;}
70 scalarr = scalarrange[1] - scalarrange[0];
72 //std::cout<<"scalar r="<<scalarr<<std::endl;
74 ((wxWindow*)wxVTKiren)->GetSize(&w, &h);
76 double dx = (scalarr*( _backPx - tmpPx ))/dw;
77 double dy = (scalarr*( _backPy - tmpPy ))/dh;
78 //colorWin=_backWindow - (scalarr)*( _backPx - tmpPx );
79 colorWin=_backWindow - dx;
80 colorLev=_backLevel + dy;
82 colorWin=_backWindow - 2*( _backPx - tmpPx );
83 colorLev=_backLevel + 2*( _backPy - tmpPy );
93 //EED 2 Nov 2012 This lets see negative values with the interaction of Window-Level Color
102 wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
103 vtkBaseData *vtkbasedata = wxvtk2Dbaseview->GetVtkBaseData();
105 // vtkImageViewer2 *vtkimageviewer2 = wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
106 // vtkimageviewer2->SetColorWindow(colorWin);
107 // vtkimageviewer2->SetColorLevel(colorLev);
108 vtkbasedata->SetColorWindow(colorWin);
109 vtkbasedata->SetColorLevel(colorLev);
110 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
111 // vtkimageviewer2->Render();
116 //-------------------------------------------------------------------
118 bool manualInteractorWindowLevel::OnMiddleButtonDown() // virtual
120 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&
121 (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ){
122 _stateWindowLevel = true;
123 crea::wxVTKRenderWindowInteractor *wxVTKiren;
124 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
125 wxVTKiren->GetEventPosition( _backPx , _backPy );
126 _backWindow = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorWindow();
127 _backLevel = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorLevel();
132 //-------------------------------------------------------------------
134 bool manualInteractorWindowLevel::OnMiddleButtonUp() // virtual
136 if (_stateWindowLevel==true)
138 _stateWindowLevel=false;