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 # ------------------------------------------------------------------------ */
26 #include "vtkInteractorStyleMPRView.h"
28 #include "wxVtkMPR2DView.h"
30 vtkInteractorStyleMPRView::vtkInteractorStyleMPRView()
32 _stateMoveAxisX = false;
33 _stateMoveAxisY = false;
34 _stateMoveAxisZ = false;
36 //---------------------------------------------------------------------------
37 vtkInteractorStyleMPRView::~vtkInteractorStyleMPRView()
42 //---------------------------------------------------------------------------
43 bool vtkInteractorStyleMPRView::OnLeftDClick () // virtual
45 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
46 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
47 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[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
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);
61 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
62 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent2);
69 //---------------------------------------------------------------------------
70 bool vtkInteractorStyleMPRView::OnLeftButtonDown ()
72 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
73 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
74 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
76 //double xx = x; // JPRx
77 //double yy = y; // JPRx
78 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
81 if ((_xBack==xx) && (_yBack==yy))
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);
96 _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
97 _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
98 _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
102 //---------------------------------------------------------------------------
103 bool vtkInteractorStyleMPRView::OnLeftButtonUp ()
105 if (_stateMoveAxisX==true)
107 _stateMoveAxisX=false;
109 if (_stateMoveAxisY==true)
111 _stateMoveAxisY=false;
113 if (_stateMoveAxisZ==true)
115 _stateMoveAxisZ=false;
119 //---------------------------------------------------------------------------
120 bool vtkInteractorStyleMPRView::OnMouseMove ()
122 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
123 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
126 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
127 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
128 // wxvtkmpr2Dview->TransfromCoordViewWorld(x,y,z);
130 wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
132 if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true) || (_stateMoveAxisZ==true) )
134 if (_stateMoveAxisX==true)
136 wxvtkmpr2Dview-> MoveX(x,y,z);
138 if (_stateMoveAxisY==true)
140 wxvtkmpr2Dview->MoveY(x,y,z);
142 if (_stateMoveAxisZ==true)
144 wxvtkmpr2Dview->MoveZ(x,y,z);
147 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();