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 # ------------------------------------------------------------------------ */
27 #include <wx/tooltip.h>
28 #include <wx/config.h>
30 #include <iostream> // for std::cout
32 #include "wxVTKRenderWindowInteractorEditContour.h"
34 //---------------------------------------------------------------------------
35 vtkInteractorStyle3DMaracas::vtkInteractorStyle3DMaracas(){
37 //---------------------------------------------------------------------------
38 vtkInteractorStyle3DMaracas::~vtkInteractorStyle3DMaracas(){
40 //---------------------------------------------------------------------------
41 void vtkInteractorStyle3DMaracas::OnRightButtonDown (){
43 if (GetInteractor()->GetControlKey()==1 ){
44 this->vtkInteractorStyleTrackballCamera::OnRightButtonDown();
47 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
48 this->Interactor->GetEventPosition()[1]);
50 if (this->CurrentRenderer == NULL)
55 if (this->Interactor->GetControlKey()) {
60 //---------------------------------------------------------------------------
61 void vtkInteractorStyle3DMaracas::OnRightButtonUp () {
63 if (GetInteractor()->GetControlKey()==1 ){
64 this->vtkInteractorStyleTrackballCamera::OnRightButtonUp();
76 //---------------------------------------------------------------------------
77 void vtkInteractorStyle3DMaracas::OnMouseMove () {
79 // this->vtkInteractorStyleTrackballCamera::OnMouseMove();
81 /* int x = */ this->Interactor->GetEventPosition()[0]; // JPRx (unused)
82 /* int y = */ this->Interactor->GetEventPosition()[1]; // JPRx (unused)
85 vtkRenderWindowInteractor *rwi = this->Interactor;
87 /* int lx = */ rwi->GetLastEventPosition()[0]; // JPRx (unused)
88 /* int ly = */ rwi->GetLastEventPosition()[1]; // JPRx (unused)
89 /* int dx = */ rwi->GetEventPosition()[0] ; // JPRx (unused)
90 /* int dy = */ rwi->GetEventPosition()[1] ; // JPRx (unused)
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);
114 // this->FindPokedRenderer(x, y);
116 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
123 //---------------------------------------------------------------------------
124 void vtkInteractorStyle3DMaracas::OnLeftButtonDown (){
126 if (GetInteractor()->GetControlKey()==1 ){
127 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
129 this->vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
134 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
135 this->Interactor->GetEventPosition()[1]);
136 if (this->CurrentRenderer == NULL)
141 if (this->Interactor->GetControlKey()) {
148 if (this->Interactor->GetShiftKey())
150 if (this->Interactor->GetControlKey())
161 if (this->Interactor->GetControlKey())
174 //---------------------------------------------------------------------------
175 void vtkInteractorStyle3DMaracas::OnLeftButtonUp () {
177 if (GetInteractor()->GetControlKey()==1 ){
178 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
180 this->vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
195 //---------------------------------------------------------------------------
196 void vtkInteractorStyle3DMaracas::OnMiddleButtonDown () {
197 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
199 //---------------------------------------------------------------------------
200 void vtkInteractorStyle3DMaracas::OnMiddleButtonUp () {
201 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
205 //---------------------------------------------------------------------------
206 //---------------------------------------------------------------------------
207 //---------------------------------------------------------------------------
210 //---------------------------------------------------------------------------
211 vtkInteractorStyle2DMaracas::vtkInteractorStyle2DMaracas(){
214 //---------------------------------------------------------------------------
215 vtkInteractorStyle2DMaracas::~vtkInteractorStyle2DMaracas(){
217 //---------------------------------------------------------------------------
218 void vtkInteractorStyle2DMaracas::OnRightButtonDown (){
219 if (GetInteractor()->GetControlKey()==1 ){
220 this->vtkInteractorStyleImage::OnRightButtonDown();
223 //---------------------------------------------------------------------------
224 void vtkInteractorStyle2DMaracas::OnRightButtonUp () {
225 if (GetInteractor()->GetControlKey()==1 ){
226 this->vtkInteractorStyleImage::OnRightButtonUp();
229 //---------------------------------------------------------------------------
230 void vtkInteractorStyle2DMaracas::OnMouseMove () {
231 this->vtkInteractorStyleImage::OnMouseMove();
233 //---------------------------------------------------------------------------
234 void vtkInteractorStyle2DMaracas::OnLeftButtonDown (){
235 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
236 this->vtkInteractorStyleImage::OnMiddleButtonDown();
237 } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
239 _obs->Execute( NULL , vtkCommand::LeftButtonPressEvent , NULL ) ;
242 this->vtkInteractorStyleImage::OnLeftButtonDown();
246 //---------------------------------------------------------------------------
247 void vtkInteractorStyle2DMaracas::OnLeftButtonUp () {
248 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
249 this->vtkInteractorStyleImage::OnMiddleButtonUp();
250 } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
252 _obs->Execute( NULL , vtkCommand::LeftButtonReleaseEvent , NULL );
255 this->vtkInteractorStyleImage::OnLeftButtonUp();
258 //---------------------------------------------------------------------------
259 void vtkInteractorStyle2DMaracas::OnMiddleButtonDown () {
261 //---------------------------------------------------------------------------
262 void vtkInteractorStyle2DMaracas::OnMiddleButtonUp () {
265 //---------------------------------------------------------------------------
266 void vtkInteractorStyle2DMaracas::SetObserver(vtkCommand* obs){
270 //---------------------------------------------------------------------------
271 //---------------------------------------------------------------------------
272 //---------------------------------------------------------------------------
274 wxVTKRenderWindowInteractorEditContour::wxVTKRenderWindowInteractorEditContour(wxWindow *parent,wxWindowID id)
275 :wxVTKRenderWindowInteractor(parent,id){
278 //---------------------------------------------------------------------------
279 wxVTKRenderWindowInteractorEditContour::~wxVTKRenderWindowInteractorEditContour(){
281 //---------------------------------------------------------------------------
282 void wxVTKRenderWindowInteractorEditContour::OnButtonDown(wxMouseEvent &event){
283 if (this->_state==1){
284 wxVTKRenderWindowInteractor::OnButtonDown(event);
286 if (this->_state==2){
287 if(event.LeftDown()==true){
288 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
289 _obs->Execute( NULL , wxEVT_LEFT_DOWN , NULL ) ;
291 if(event.RightDown()==true){
292 wxVTKRenderWindowInteractor::OnButtonDown(event);
293 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
294 _obs->Execute( NULL , wxEVT_RIGHT_DOWN , NULL ) ;
298 //---------------------------------------------------------------------------
299 void wxVTKRenderWindowInteractorEditContour::OnButtonUp(wxMouseEvent &event){
300 if (this->_state==1){
301 wxVTKRenderWindowInteractor::OnButtonUp(event);
303 if (this->_state==2){
304 if(event.LeftUp()==true){
305 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
306 _obs->Execute( NULL , wxEVT_LEFT_UP , NULL ) ;
308 if(event.RightUp()==true){
309 wxVTKRenderWindowInteractor::OnButtonUp(event);
313 //---------------------------------------------------------------------------
314 void wxVTKRenderWindowInteractorEditContour::OnButtonDouble(wxMouseEvent &event){
315 if (this->_state==1){
316 // EED 22 dec 2007 : SIL que tengo que hacer aqui ..?? Esto creo que lo quito silvia y como se
318 // wxVTKRenderWindowInteractor::OnButtonDouble(event);
320 if (this->_state==2){
321 if(event.LeftDClick()==true){
322 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
323 _obs->Execute( NULL , wxEVT_LEFT_DCLICK , NULL ) ;
327 //---------------------------------------------------------------------------
328 void wxVTKRenderWindowInteractorEditContour::OnMotion(wxMouseEvent &event){
329 if (this->_state==1){
330 wxVTKRenderWindowInteractor::OnMotion(event);
332 if (this->_state==2){
333 wxVTKRenderWindowInteractor::OnMotion(event);
334 if(event.Moving()==true){
335 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
336 _obs->Execute( NULL , wxEVT_MOTION , NULL ) ;
340 //---------------------------------------------------------------------------
341 void wxVTKRenderWindowInteractorEditContour::OnKeyDown(wxKeyEvent &event){
342 wxVTKRenderWindowInteractor::OnKeyDown(event);
343 if (( event.GetKeyCode()==WXK_BACK ) || ( event.GetKeyCode()==WXK_DELETE) ){
344 _obs->Execute( NULL , WXK_CLEAR , NULL ) ;
347 //---------------------------------------------------------------------------
348 void wxVTKRenderWindowInteractorEditContour::SetState(int state){
351 //---------------------------------------------------------------------------
352 int wxVTKRenderWindowInteractorEditContour::GetState(){
355 //---------------------------------------------------------------------------
356 void wxVTKRenderWindowInteractorEditContour::SetObserver(vtkCommand* obs){