]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkmyPWCallback_3DPointWidget.cxx
#3219 creaMaracasVisu Feature New Normal - vtk8itk4wx3-mingw64
[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 //EED 2017-01-01 Migration VTK7
50 #if VTK_MAJOR_VERSION <= 5
51                 //..
52 #else
53                 _planeWidget->GetPolyData(_vtkplane);
54                 _probe->Update();
55 #endif
56
57         }
58
59         double spc[3];
60         _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
61         p[0]=p[0]/spc[0];
62         p[1]=p[1]/spc[1];
63         p[2]=p[2]/spc[2];
64
65         // Orientation change
66         if ( (fabs(n[0]-_backNormal[0])>delta) || (fabs(n[1]-_backNormal[1])>delta) || (fabs(n[2]-_backNormal[2])>delta) )
67         {
68                 _backNormal[0] = n[0];
69                 _backNormal[1] = n[1];
70                 _backNormal[2] = n[2];
71                 isbv->SetParent_refresh_waiting();
72         }
73
74         // ----------
75
76         double tx = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
77         double ty = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
78         double tz = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
79
80         // Position Change
81         if ( (fabs(tx-p[0])>delta) || (fabs(ty-p[1])>delta) || (fabs(tz-p[2])>delta) )
82         {
83                 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( p[0] );
84                 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( p[1] );
85                 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( p[2] );
86                 vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
87                 isbv->BlockRefresh();
88                 isbv->vtkInteractorStyleBaseView::OnLeftButtonDown();
89                 isbv->SetParent_refresh_waiting();
90                 isbv->vtkInteractorStyleBaseView::OnMouseMove();
91                 isbv->UnBlockRefresh();
92         } 
93         isbv->EvaluateToRefresh();
94 }
95 //-------------------------------------------------------------------
96 void vtkmyPWCallback_3DPointWidget::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
97 {
98         _wxvtkmpr3Dview=wxvtkmpr3Dview;
99 }
100 //-------------------------------------------------------------------
101 void vtkmyPWCallback_3DPointWidget::SetVtkPointWidget( vtkPointWidget *pointWidget )
102 {
103         _pointWidget=pointWidget;
104 }
105 //-------------------------------------------------------------------
106 void vtkmyPWCallback_3DPointWidget::SetVtkPlaneWidget( vtkPlaneWidget *planeWidget )
107 {
108         _planeWidget=planeWidget;
109 }
110
111 //-------------------------------------------------------------------
112  void vtkmyPWCallback_3DPointWidget::SetVtkPolyData( vtkPolyData *vtkplane)
113 {
114         _vtkplane=vtkplane;
115 }
116
117 //-------------------------------------------------------------------
118 void vtkmyPWCallback_3DPointWidget::SetVtkProbeFilter( vtkProbeFilter *probe)
119 {
120         _probe=probe;
121 }
122
123
124