]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleMPRView.cxx
Support #1768 CREATIS Licence insertion
[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         wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
55         wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122);  // Doble click
56         wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
57
58         return true;
59 }
60 //---------------------------------------------------------------------------
61 bool  vtkInteractorStyleMPRView::OnLeftButtonDown () 
62 {
63         wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
64         double x        = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
65         double y        = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
66         double z        = 1;
67         //double xx     = x;  // JPRx
68         //double yy     = y;  // JPRx
69         _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);            
70
71 /*EED Borrame
72         if ((_xBack==xx) && (_yBack==yy))
73         {
74                 wxvtkmpr2Dview->MoveX(x,y,z);
75                 wxvtkmpr2Dview->MoveY(x,y,z);
76                 wxvtkmpr2Dview->MoveZ(x,y,z);
77                 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
78                 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
79                 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122);  // Doble click
80                 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
81         }
82
83         _xBack=xx;      
84         _yBack=yy;
85 */
86
87         _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
88         _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
89         _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
90
91         return true;
92 }
93 //---------------------------------------------------------------------------
94 bool  vtkInteractorStyleMPRView::OnLeftButtonUp () 
95 {
96         if (_stateMoveAxisX==true) 
97         {
98                 _stateMoveAxisX=false;
99         }
100         if (_stateMoveAxisY==true) 
101         {
102                 _stateMoveAxisY=false;
103         }
104         if (_stateMoveAxisZ==true) 
105         {
106                 _stateMoveAxisZ=false;
107         }
108         return true;
109 }
110 //---------------------------------------------------------------------------
111 bool  vtkInteractorStyleMPRView::OnMouseMove () 
112 {
113         double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
114         double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
115
116         double z=1;
117         _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);            
118         wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
119 //      wxvtkmpr2Dview->TransfromCoordViewWorld(x,y,z);     
120
121         wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
122
123         if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true)  || (_stateMoveAxisZ==true) )
124         {
125                 if (_stateMoveAxisX==true) 
126                 {
127                         wxvtkmpr2Dview-> MoveX(x,y,z);
128                 }
129                 if (_stateMoveAxisY==true) 
130                 {
131                         wxvtkmpr2Dview->MoveY(x,y,z);
132                 }
133                 if (_stateMoveAxisZ==true) 
134                 {
135                         wxvtkmpr2Dview->MoveZ(x,y,z);
136                 }
137
138                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
139         }
140         return true;
141 }
142