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 "vtkInteractorStyleSphere.h"
29 #include "wxSphereView.h"
31 vtkInteractorStyleSphere::vtkInteractorStyleSphere()
37 //---------------------------------------------------------------------------
39 vtkInteractorStyleSphere::~vtkInteractorStyleSphere()
44 //---------------------------------------------------------------------------
46 bool vtkInteractorStyleSphere::OnRightButtonDown()
48 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
51 //_fordwareX = this->Interactor->GetEventPosition()[0];
52 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
54 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
56 _radio = wxsphereview->GetRadio();
62 //---------------------------------------------------------------------------
64 bool vtkInteractorStyleSphere::OnRightButtonUp()
66 if (_stateRadio==true)
68 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
69 wxsphereview->SetDeltaVoxel(1);
70 double radio=wxsphereview->GetRadio();
71 wxsphereview->GetIdOfImage(radio+0.1);
72 wxsphereview->GetIdOfImage(radio+0.2);
73 wxsphereview->GetIdOfImage(radio-0.1);
74 wxsphereview->GetIdOfImage(radio-0.2);
76 wxsphereview->RefreshView();
82 //---------------------------------------------------------------------------
84 bool vtkInteractorStyleSphere::OnLeftButtonDown()
87 _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
88 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
93 //---------------------------------------------------------------------------
95 bool vtkInteractorStyleSphere::OnLeftButtonUp()
97 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
98 if (_stateRotate==true){
99 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
100 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
102 if ((_fordwareX==fx)&&(_fordwareY==fy)){
103 double x=fx,y=fy,z=1;
104 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
105 wxsphereview->SetXYZtoParent(x,y);
106 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
107 wxsphereview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
109 wxsphereview->RotationEnd();
111 wxsphereview->RefreshView();
112 _stateRotate = false;
119 //---------------------------------------------------------------------------
121 bool vtkInteractorStyleSphere::OnMouseMove ()
123 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
124 if (_stateRotate==true)
129 if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
133 if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
137 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
138 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
139 wxsphereview->RotationStart( fx - _fordwareX , -(fy - _fordwareY) , ok_v, ok_ang);
140 wxsphereview->RefreshView();
142 if (_stateRadio==true)
144 //int fx = this->Interactor->GetEventPosition()[0];
145 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
146 double dif=(fy-_fordwareY) / 10.0;
147 wxsphereview->SetRadio( _radio + dif );
148 wxsphereview->SetDeltaVoxel(3);
149 wxsphereview->RefreshView();