]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx
#3230 vtk8itk4wx3-mingw64 MACOS
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkBaseView.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
27
28 //#include "vtkInteractorStyleBaseView.h"
29
30 #include "wxVtkBaseView.h"
31 #include "wxVtk2DBaseView.h"
32 #include "wxVTKRenderWindowInteractorPlus.h"
33
34
35
36 wxVtkBaseView::wxVtkBaseView()
37 {
38         _parent                         = NULL;
39         _iren                           = NULL;
40         _interactorStyle        = NULL;
41 }
42
43 //-------------------------------------------------------------------
44
45 wxVtkBaseView::wxVtkBaseView(wxWindow *parent)
46 {
47         _parent                         = parent;
48         _iren                           = (crea::wxVTKRenderWindowInteractor*)new wxVTKRenderWindowInteractorPlus(_parent,this);
49 //      _iren->UseCaptureMouseOn();
50 //      _iren                           = new wxVTKRenderWindowInteractor(_parent,-1);
51         _interactorStyle        = NULL;
52 }
53
54 //-------------------------------------------------------------------
55 wxVtkBaseView::~wxVtkBaseView()
56 {
57         _iren -> Delete();
58         //_iren=NULL;
59 }
60 //-------------------------------------------------------------------
61 crea::wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
62 {
63
64         if(_iren==NULL)
65         {
66                 throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren cwxVTKRenderWindowInteractorPlus =NULL";
67         }
68    return _iren;
69 }
70 //-------------------------------------------------------------------
71 void wxVtkBaseView::Configure()  // virtual 
72 {
73 }
74 //-------------------------------------------------------------------
75 void wxVtkBaseView::Refresh()  // virtual 
76 {
77 // EED 10 Oct 2007
78         #if defined(WIN32)
79                 _iren->Refresh(true);
80 // EED 27 sept 2016
81            vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
82            vri->vtkRenderWindowInteractor::Render();
83         #else
84 //EED 01Avril2009
85 //              _iren->Render();        
86         vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
87         vri->vtkRenderWindowInteractor::Render();
88                 //_iren->Refresh();
89         #endif
90 }
91 //-------------------------------------------------------------------
92 void wxVtkBaseView::RefreshView()  // virtual 
93 {
94 // EED 10 Oct 2007
95         #if defined(WIN32)
96                 GetRenWin()->Render();
97         #else
98                 //GetRenWin()->Render();
99         #endif
100 }
101 //---------------------------------------------------------------------------
102 vtkRenderer* wxVtkBaseView::GetRenderer()       // virtual 
103 {
104         return NULL;
105 }
106 //---------------------------------------------------------------------------
107 vtkRenderWindow* wxVtkBaseView::GetRenWin()             // virtual
108 {
109         return _iren->GetRenderWindow();
110 }
111
112 //----------------------------------------------------------------------------
113
114 void wxVtkBaseView::TransCoordScreenToWorld(double &X, double &Y, double &Z, int type)
115 {
116         GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
117         GetRenderer()->DisplayToWorld();
118         double fP[4];
119         GetRenderer()->GetWorldPoint( fP );
120     if ( fP[3] ){
121                 fP[0] /= fP[3];
122                 fP[1] /= fP[3];
123                 fP[2] /= fP[3];
124         }
125
126         if (type!=0)
127         {
128                 X=fP[0];
129         }
130         if (type!=1)
131         {
132                 Y=fP[1];
133         }
134         if (type!=2)
135         {
136                 Z=fP[2];
137         } 
138 }
139 //----------------------------------------------------------------------------
140                                         
141 void wxVtkBaseView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type) //virtual //keepNormalDirection=false, type=2
142 {
143         double xx = X;
144         double yy = Y;
145         double zz = Z;
146
147         //RaC 03-2010
148         TransCoordScreenToWorld(xx,yy,zz,type);
149
150         X = xx;
151         Y = yy;
152         Z = zz;
153
154 // EEDx5
155         //JCP 13/05/2009
156         vtkInteractorStyleBaseView* interactorstyle = (vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView();
157     wxVtk2DBaseView* baseview = (wxVtk2DBaseView*)interactorstyle->GetWxVtk2DBaseView();
158
159         double fP[3];
160         fP[0] = X;
161         fP[1] = Y;
162         fP[2] = Z;
163
164         baseview->TransformCoordinate_spacing_ViewToModel( fP[0] , fP[1] , fP[2] );
165         //JCP 13/05/2009
166
167         if (type!=0)
168         {
169                 X=fP[0];
170         }
171         if (type!=1)
172         {
173                 Y=fP[1];
174         }
175         if (type!=2)
176         {
177                 Z=fP[2];
178         }
179
180 }
181
182 //---------------------------------------------------------------------------
183 /* JCP 14/05/09
184 vtkInteractorStyleBaseView*     wxVtkBaseView::GetInteractorStyleBaseView()
185 {
186         return _interactorStyle;
187 }
188 */
189 vtkInteractorStyleImage*        wxVtkBaseView::GetInteractorStyleBaseView()
190 {
191         return _interactorStyle;
192 }
193
194 //---------------------------------------------------------------------------
195
196 void wxVtkBaseView::SetInteractorStyleBaseView( vtkInteractorStyleImage*        interactorStyle)
197 {
198         _interactorStyle = interactorStyle;
199 }
200
201 //---------------------------------------------------------------------------
202
203 void wxVtkBaseView::GetSpacing(double spc[3])  // virtual
204 {
205         spc[0]=1;
206         spc[1]=1;
207         spc[2]=1;
208 }
209
210
211 //---------------------------------------------------------------------------
212 int  wxVtkBaseView::GetDirection()   // virtual 
213 {
214         return -1;
215 }
216
217 //-------------------------------------------------------------------
218 vtkBaseData *wxVtkBaseView::GetVtkBaseData()
219 {
220    return _vtkbasedata;
221 }
222
223 //-------------------------------------------------------------------
224 void wxVtkBaseView::SetVtkBaseData(vtkBaseData *vtkbasedata)
225 {
226    _vtkbasedata=vtkbasedata;
227 }
228
229
230
231 //-------------------------------------------------------------------
232 //-------------------------------------------------------------------
233 //-------------------------------------------------------------------
234
235
236