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 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
55 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
56 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
60 //---------------------------------------------------------------------------
61 bool vtkInteractorStyleMPRView::OnLeftButtonDown ()
63 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
64 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
65 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
67 //double xx = x; // JPRx
68 //double yy = y; // JPRx
69 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
72 if ((_xBack==xx) && (_yBack==yy))
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);
87 _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
88 _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
89 _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
93 //---------------------------------------------------------------------------
94 bool vtkInteractorStyleMPRView::OnLeftButtonUp ()
96 if (_stateMoveAxisX==true)
98 _stateMoveAxisX=false;
100 if (_stateMoveAxisY==true)
102 _stateMoveAxisY=false;
104 if (_stateMoveAxisZ==true)
106 _stateMoveAxisZ=false;
110 //---------------------------------------------------------------------------
111 bool vtkInteractorStyleMPRView::OnMouseMove ()
113 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
114 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
117 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
118 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
119 // wxvtkmpr2Dview->TransfromCoordViewWorld(x,y,z);
121 wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
123 if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true) || (_stateMoveAxisZ==true) )
125 if (_stateMoveAxisX==true)
127 wxvtkmpr2Dview-> MoveX(x,y,z);
129 if (_stateMoveAxisY==true)
131 wxvtkmpr2Dview->MoveY(x,y,z);
133 if (_stateMoveAxisZ==true)
135 wxvtkmpr2Dview->MoveZ(x,y,z);
138 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();