]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleSphere.cxx
de3d2b0241baa4a50463855059f940da6df1a673
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkInteractorStyleSphere.cxx
1
2 #include "vtkInteractorStyleSphere.h"
3
4 #include "wxSphereView.h"
5
6 vtkInteractorStyleSphere::vtkInteractorStyleSphere()
7 {
8         _stateRadio  = false;
9         _stateRotate = false;
10 }
11
12 //---------------------------------------------------------------------------
13
14 vtkInteractorStyleSphere::~vtkInteractorStyleSphere()
15 {
16 }
17
18
19 //---------------------------------------------------------------------------
20
21 bool  vtkInteractorStyleSphere::OnRightButtonDown()
22 {
23         if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
24         {
25                 _stateRadio     = true;
26                 //_fordwareX    = this->Interactor->GetEventPosition()[0];
27                 _fordwareY      = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
28
29                 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
30
31                 _radio = wxsphereview->GetRadio();
32         }
33
34         return true;
35 }
36
37 //---------------------------------------------------------------------------
38
39 bool  vtkInteractorStyleSphere::OnRightButtonUp() 
40 {
41         if (_stateRadio==true)
42         {
43                 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
44                 wxsphereview->SetDeltaVoxel(1);
45                 double radio=wxsphereview->GetRadio();
46                 wxsphereview->GetIdOfImage(radio+0.1);
47                 wxsphereview->GetIdOfImage(radio+0.2);
48                 wxsphereview->GetIdOfImage(radio-0.1);
49                 wxsphereview->GetIdOfImage(radio-0.2);
50
51                 wxsphereview->RefreshView();
52                 _stateRadio = false;
53         }
54
55         return true;
56 }
57 //---------------------------------------------------------------------------
58
59 bool vtkInteractorStyleSphere::OnLeftButtonDown()
60 {
61         _stateRotate    = true;
62         _fordwareX              = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
63         _fordwareY              = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
64         return true;
65 }
66
67
68 //---------------------------------------------------------------------------
69
70 bool  vtkInteractorStyleSphere::OnLeftButtonUp() 
71 {
72         wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
73         if (_stateRotate==true){
74                 int fx  = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
75                 int fy  = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
76
77                 if ((_fordwareX==fx)&&(_fordwareY==fy)){
78                         double x=fx,y=fy,z=1;
79                         _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);            
80                         wxsphereview->SetXYZtoParent(x,y);
81                         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
82                         wxsphereview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
83                 } else {
84                         wxsphereview->RotationEnd();
85                 }
86                 wxsphereview->RefreshView();
87                 _stateRotate = false;
88         }
89
90         return true;
91 }
92
93
94 //---------------------------------------------------------------------------
95
96 bool  vtkInteractorStyleSphere::OnMouseMove () 
97 {
98         wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
99         if (_stateRotate==true)
100         {
101                 bool ok_v, ok_ang;
102                 ok_v=false;
103                 ok_ang=false;
104                 if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
105                 {
106                         ok_v = true;
107                 }
108                 if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
109                 {
110                         ok_ang = true;
111                 }
112             int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
113         int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
114                 wxsphereview->RotationStart( fx - _fordwareX , -(fy - _fordwareY) , ok_v, ok_ang);
115                 wxsphereview->RefreshView();
116         } 
117         if (_stateRadio==true)
118         {           
119                 //int fx = this->Interactor->GetEventPosition()[0];
120         int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
121                 double dif=(fy-_fordwareY) / 10.0;
122                 wxsphereview->SetRadio( _radio + dif );
123                 wxsphereview->SetDeltaVoxel(3);
124                 wxsphereview->RefreshView();
125         }
126
127         return true;
128 }