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 "wxVTKRenderWindowInteractorEditContour.h"
28 //---------------------------------------------------------------------------
29 vtkInteractorStyle3DMaracas::vtkInteractorStyle3DMaracas(){
31 //---------------------------------------------------------------------------
32 vtkInteractorStyle3DMaracas::~vtkInteractorStyle3DMaracas(){
34 //---------------------------------------------------------------------------
35 void vtkInteractorStyle3DMaracas::OnRightButtonDown (){
37 if (GetInteractor()->GetControlKey()==1 ){
38 this->vtkInteractorStyleTrackballCamera::OnRightButtonDown();
41 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
42 this->Interactor->GetEventPosition()[1]);
44 if (this->CurrentRenderer == NULL)
49 if (this->Interactor->GetControlKey()) {
54 //---------------------------------------------------------------------------
55 void vtkInteractorStyle3DMaracas::OnRightButtonUp () {
57 if (GetInteractor()->GetControlKey()==1 ){
58 this->vtkInteractorStyleTrackballCamera::OnRightButtonUp();
70 //---------------------------------------------------------------------------
71 void vtkInteractorStyle3DMaracas::OnMouseMove () {
73 // this->vtkInteractorStyleTrackballCamera::OnMouseMove();
75 /* int x = */ this->Interactor->GetEventPosition()[0]; // JPRx (unused)
76 /* int y = */ this->Interactor->GetEventPosition()[1]; // JPRx (unused)
79 vtkRenderWindowInteractor *rwi = this->Interactor;
81 /* int lx = */ rwi->GetLastEventPosition()[0]; // JPRx (unused)
82 /* int ly = */ rwi->GetLastEventPosition()[1]; // JPRx (unused)
83 /* int dx = */ rwi->GetEventPosition()[0] ; // JPRx (unused)
84 /* int dy = */ rwi->GetEventPosition()[1] ; // JPRx (unused)
90 // this->FindPokedRenderer(x, y);
92 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
96 // this->FindPokedRenderer(x, y);
98 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
102 // this->FindPokedRenderer(x, y);
104 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
108 // this->FindPokedRenderer(x, y);
110 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
117 //---------------------------------------------------------------------------
118 void vtkInteractorStyle3DMaracas::OnLeftButtonDown (){
120 if (GetInteractor()->GetControlKey()==1 ){
121 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
123 this->vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
128 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
129 this->Interactor->GetEventPosition()[1]);
130 if (this->CurrentRenderer == NULL)
135 if (this->Interactor->GetControlKey()) {
142 if (this->Interactor->GetShiftKey())
144 if (this->Interactor->GetControlKey())
155 if (this->Interactor->GetControlKey())
168 //---------------------------------------------------------------------------
169 void vtkInteractorStyle3DMaracas::OnLeftButtonUp () {
171 if (GetInteractor()->GetControlKey()==1 ){
172 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
174 this->vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
189 //---------------------------------------------------------------------------
190 void vtkInteractorStyle3DMaracas::OnMiddleButtonDown () {
191 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
193 //---------------------------------------------------------------------------
194 void vtkInteractorStyle3DMaracas::OnMiddleButtonUp () {
195 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
199 //---------------------------------------------------------------------------
200 //---------------------------------------------------------------------------
201 //---------------------------------------------------------------------------
204 //---------------------------------------------------------------------------
205 vtkInteractorStyle2DMaracas::vtkInteractorStyle2DMaracas(){
208 //---------------------------------------------------------------------------
209 vtkInteractorStyle2DMaracas::~vtkInteractorStyle2DMaracas(){
211 //---------------------------------------------------------------------------
212 void vtkInteractorStyle2DMaracas::OnRightButtonDown (){
213 if (GetInteractor()->GetControlKey()==1 ){
214 this->vtkInteractorStyleImage::OnRightButtonDown();
217 //---------------------------------------------------------------------------
218 void vtkInteractorStyle2DMaracas::OnRightButtonUp () {
219 if (GetInteractor()->GetControlKey()==1 ){
220 this->vtkInteractorStyleImage::OnRightButtonUp();
223 //---------------------------------------------------------------------------
224 void vtkInteractorStyle2DMaracas::OnMouseMove () {
225 this->vtkInteractorStyleImage::OnMouseMove();
227 //---------------------------------------------------------------------------
228 void vtkInteractorStyle2DMaracas::OnLeftButtonDown (){
229 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
230 this->vtkInteractorStyleImage::OnMiddleButtonDown();
231 } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
233 _obs->Execute( NULL , vtkCommand::LeftButtonPressEvent , NULL ) ;
236 this->vtkInteractorStyleImage::OnLeftButtonDown();
240 //---------------------------------------------------------------------------
241 void vtkInteractorStyle2DMaracas::OnLeftButtonUp () {
242 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
243 this->vtkInteractorStyleImage::OnMiddleButtonUp();
244 } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
246 _obs->Execute( NULL , vtkCommand::LeftButtonReleaseEvent , NULL );
249 this->vtkInteractorStyleImage::OnLeftButtonUp();
252 //---------------------------------------------------------------------------
253 void vtkInteractorStyle2DMaracas::OnMiddleButtonDown () {
255 //---------------------------------------------------------------------------
256 void vtkInteractorStyle2DMaracas::OnMiddleButtonUp () {
259 //---------------------------------------------------------------------------
260 void vtkInteractorStyle2DMaracas::SetObserver(vtkCommand* obs){
264 //---------------------------------------------------------------------------
265 //---------------------------------------------------------------------------
266 //---------------------------------------------------------------------------
268 wxVTKRenderWindowInteractorEditContour::wxVTKRenderWindowInteractorEditContour(wxWindow *parent,wxWindowID id)
269 :wxVTKRenderWindowInteractor(parent,id){
272 //---------------------------------------------------------------------------
273 wxVTKRenderWindowInteractorEditContour::~wxVTKRenderWindowInteractorEditContour(){
275 //---------------------------------------------------------------------------
276 void wxVTKRenderWindowInteractorEditContour::OnButtonDown(wxMouseEvent &event){
277 if (this->_state==1){
278 wxVTKRenderWindowInteractor::OnButtonDown(event);
280 if (this->_state==2){
281 if(event.LeftDown()==true){
282 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
283 _obs->Execute( NULL , wxEVT_LEFT_DOWN , NULL ) ;
285 if(event.RightDown()==true){
286 wxVTKRenderWindowInteractor::OnButtonDown(event);
287 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
288 _obs->Execute( NULL , wxEVT_RIGHT_DOWN , NULL ) ;
292 //---------------------------------------------------------------------------
293 void wxVTKRenderWindowInteractorEditContour::OnButtonUp(wxMouseEvent &event){
294 if (this->_state==1){
295 wxVTKRenderWindowInteractor::OnButtonUp(event);
297 if (this->_state==2){
298 if(event.LeftUp()==true){
299 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
300 _obs->Execute( NULL , wxEVT_LEFT_UP , NULL ) ;
302 if(event.RightUp()==true){
303 wxVTKRenderWindowInteractor::OnButtonUp(event);
307 //---------------------------------------------------------------------------
308 void wxVTKRenderWindowInteractorEditContour::OnButtonDouble(wxMouseEvent &event){
309 if (this->_state==1){
310 // EED 22 dec 2007 : SIL que tengo que hacer aqui ..?? Esto creo que lo quito silvia y como se
312 // wxVTKRenderWindowInteractor::OnButtonDouble(event);
314 if (this->_state==2){
315 if(event.LeftDClick()==true){
316 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
317 _obs->Execute( NULL , wxEVT_LEFT_DCLICK , NULL ) ;
321 //---------------------------------------------------------------------------
322 void wxVTKRenderWindowInteractorEditContour::OnMotion(wxMouseEvent &event){
323 if (this->_state==1){
324 wxVTKRenderWindowInteractor::OnMotion(event);
326 if (this->_state==2){
327 wxVTKRenderWindowInteractor::OnMotion(event);
328 if(event.Moving()==true){
329 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
330 _obs->Execute( NULL , wxEVT_MOTION , NULL ) ;
334 //---------------------------------------------------------------------------
335 void wxVTKRenderWindowInteractorEditContour::OnKeyDown(wxKeyEvent &event){
336 wxVTKRenderWindowInteractor::OnKeyDown(event);
337 if (( event.GetKeyCode()==WXK_BACK ) || ( event.GetKeyCode()==WXK_DELETE) ){
338 _obs->Execute( NULL , WXK_CLEAR , NULL ) ;
341 //---------------------------------------------------------------------------
342 void wxVTKRenderWindowInteractorEditContour::SetState(int state){
345 //---------------------------------------------------------------------------
346 int wxVTKRenderWindowInteractorEditContour::GetState(){
349 //---------------------------------------------------------------------------
350 void wxVTKRenderWindowInteractorEditContour::SetObserver(vtkCommand* obs){