]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkmyPWCallback_3DPointWidget.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkmyPWCallback_3DPointWidget.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 "vtkmyPWCallback_3DPointWidget.h"
27 #include "vtkInteractorStyleBaseView.h"
28
29 //-------------------------------------------------------------------
30 //-------------------------------------------------------------------
31 //-------------------------------------------------------------------
32 void vtkmyPWCallback_3DPointWidget::Execute(vtkObject *caller, unsigned long, void*)
33 {
34         double n[3];
35         double p[3];
36         double delta = 0.000000001;
37
38         vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
39
40         if (caller==_pointWidget)
41         {
42                 _pointWidget->GetPosition(p);
43         }
44         if (caller==_planeWidget)
45         {
46                 _planeWidget->GetCenter(p);
47                 _planeWidget->GetNormal(n);
48                 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetNormal(n[0],n[1],n[2]);
49         }
50
51         double spc[3];
52         _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
53         p[0]=p[0]/spc[0];
54         p[1]=p[1]/spc[1];
55         p[2]=p[2]/spc[2];
56
57         // Orientation change
58         if ( (fabs(n[0]-_backNormal[0])>delta) || (fabs(n[1]-_backNormal[1])>delta) || (fabs(n[2]-_backNormal[2])>delta) )
59         {
60                 _backNormal[0] = n[0];
61                 _backNormal[1] = n[1];
62                 _backNormal[2] = n[2];
63                 isbv->SetParent_refresh_waiting();
64         }
65
66         // ----------
67
68         double tx = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
69         double ty = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
70         double tz = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
71
72         // Position Change
73         if ( (fabs(tx-p[0])>delta) || (fabs(ty-p[1])>delta) || (fabs(tz-p[2])>delta) )
74         {
75                 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( p[0] );
76                 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( p[1] );
77                 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( p[2] );
78                 vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
79                 isbv->BlockRefresh();
80                 isbv->vtkInteractorStyleBaseView::OnLeftButtonDown();
81                 isbv->SetParent_refresh_waiting();
82                 isbv->vtkInteractorStyleBaseView::OnMouseMove();
83                 isbv->UnBlockRefresh();
84         } 
85         isbv->EvaluateToRefresh();
86 }
87 //-------------------------------------------------------------------
88 void vtkmyPWCallback_3DPointWidget::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
89 {
90         _wxvtkmpr3Dview=wxvtkmpr3Dview;
91 }
92 //-------------------------------------------------------------------
93 void vtkmyPWCallback_3DPointWidget::SetVtkPointWidget( vtkPointWidget *pointWidget )
94 {
95         _pointWidget=pointWidget;
96 }
97 //-------------------------------------------------------------------
98 void vtkmyPWCallback_3DPointWidget::SetVtkPlaneWidget( vtkPlaneWidget *planeWidget )
99 {
100         _planeWidget=planeWidget;
101 }
102