]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleMPRView.cxx
#3128 creaMaracasVisu Feature New Normal - branch changeWx28to30 compilation with...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkInteractorStyleMPRView.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 #include "vtkInteractorStyleMPRView.h"
27
28 #include "wxVtkMPR2DView.h"
29
30 vtkInteractorStyleMPRView::vtkInteractorStyleMPRView()
31 {
32         _stateMoveAxisX = false;
33         _stateMoveAxisY = false;
34         _stateMoveAxisZ = false;
35 }
36 //---------------------------------------------------------------------------
37 vtkInteractorStyleMPRView::~vtkInteractorStyleMPRView()
38 {
39 }
40
41
42 //---------------------------------------------------------------------------
43 bool  vtkInteractorStyleMPRView::OnLeftDClick () // virtual
44 {
45         wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
46         double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
47         double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
48         double z = 1;
49         _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);            
50         wxvtkmpr2Dview->MoveX(x,y,z);
51         wxvtkmpr2Dview->MoveY(x,y,z);
52         wxvtkmpr2Dview->MoveZ(x,y,z);
53         wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
54         wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122);  // Doble click
55
56 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
57 #if wxMAJOR_VERSION <= 2
58         wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
59         wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
60 #else
61         wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
62         wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent2);
63 #endif
64
65
66
67         return true;
68 }
69 //---------------------------------------------------------------------------
70 bool  vtkInteractorStyleMPRView::OnLeftButtonDown () 
71 {
72         wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
73         double x        = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
74         double y        = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
75         double z        = 1;
76         //double xx     = x;  // JPRx
77         //double yy     = y;  // JPRx
78         _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);            
79
80 /*EED Borrame
81         if ((_xBack==xx) && (_yBack==yy))
82         {
83                 wxvtkmpr2Dview->MoveX(x,y,z);
84                 wxvtkmpr2Dview->MoveY(x,y,z);
85                 wxvtkmpr2Dview->MoveZ(x,y,z);
86                 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
87                 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
88                 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122);  // Doble click
89                 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
90         }
91
92         _xBack=xx;      
93         _yBack=yy;
94 */
95
96         _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
97         _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
98         _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
99
100         return true;
101 }
102 //---------------------------------------------------------------------------
103 bool  vtkInteractorStyleMPRView::OnLeftButtonUp () 
104 {
105         if (_stateMoveAxisX==true) 
106         {
107                 _stateMoveAxisX=false;
108         }
109         if (_stateMoveAxisY==true) 
110         {
111                 _stateMoveAxisY=false;
112         }
113         if (_stateMoveAxisZ==true) 
114         {
115                 _stateMoveAxisZ=false;
116         }
117         return true;
118 }
119 //---------------------------------------------------------------------------
120 bool  vtkInteractorStyleMPRView::OnMouseMove () 
121 {
122         double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
123         double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
124
125         double z=1;
126         _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);            
127         wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
128 //      wxvtkmpr2Dview->TransfromCoordViewWorld(x,y,z);     
129
130         wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
131
132         if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true)  || (_stateMoveAxisZ==true) )
133         {
134                 if (_stateMoveAxisX==true) 
135                 {
136                         wxvtkmpr2Dview-> MoveX(x,y,z);
137                 }
138                 if (_stateMoveAxisY==true) 
139                 {
140                         wxvtkmpr2Dview->MoveY(x,y,z);
141                 }
142                 if (_stateMoveAxisZ==true) 
143                 {
144                         wxvtkmpr2Dview->MoveZ(x,y,z);
145                 }
146
147                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
148         }
149         return true;
150 }
151