]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx
remove home-made 'uint', 'uchar', 'ushort', etc replace by uint32_t, uint8_t, uint16_t
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkBaseView.cxx
1
2
3 //#include "vtkInteractorStyleBaseView.h"
4
5 #include "wxVtkBaseView.h"
6 #include "wxVtk2DBaseView.h"
7 #include "wxVTKRenderWindowInteractorPlus.h"
8
9
10
11 wxVtkBaseView::wxVtkBaseView()
12 {
13         _parent                         = NULL;
14         _iren                           = NULL;
15         _interactorStyle        = NULL;
16 }
17
18 //-------------------------------------------------------------------
19
20 wxVtkBaseView::wxVtkBaseView(wxWindow *parent)
21 {
22         _parent                         = parent;
23         _iren                           = (wxVTKRenderWindowInteractor*)new wxVTKRenderWindowInteractorPlus(_parent,this);
24 //      _iren->UseCaptureMouseOn();
25 //      _iren                           = new wxVTKRenderWindowInteractor(_parent,-1);
26         _interactorStyle        = NULL;
27 }
28
29 //-------------------------------------------------------------------
30 wxVtkBaseView::~wxVtkBaseView()
31 {
32         _iren -> Delete();
33         //_iren=NULL;
34 }
35 //-------------------------------------------------------------------
36 wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
37 {
38
39         if(_iren==NULL){
40                 throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren wxVTKRenderWindowInteractorPlus =NULL";
41         }
42    return _iren;
43 }
44 //-------------------------------------------------------------------
45 void wxVtkBaseView::Configure()  // virtual 
46 {
47 }
48 //-------------------------------------------------------------------
49 void wxVtkBaseView::Refresh()  // virtual 
50 {
51 // EED 10 Oct 2007
52
53         #if defined(WIN32)
54                 _iren->Refresh(false);
55         #else
56         
57 //EED 01Avril2009
58 //              _iren->Render();        
59         vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
60         vri->vtkRenderWindowInteractor::Render();
61         
62         
63                 //_iren->Refresh();
64         #endif
65
66 }
67 //-------------------------------------------------------------------
68 void wxVtkBaseView::RefreshView()  // virtual 
69 {
70 // EED 10 Oct 2007
71
72         #if defined(WIN32)
73                 GetRenWin()->Render();
74         #else
75                 //GetRenWin()->Render();
76         #endif
77
78 }
79 //---------------------------------------------------------------------------
80 vtkRenderer* wxVtkBaseView::GetRenderer()       // virtual 
81 {
82         return NULL;
83 }
84 //---------------------------------------------------------------------------
85 vtkRenderWindow* wxVtkBaseView::GetRenWin()             // virtual
86 {
87         return _iren->GetRenderWindow();
88 }
89
90 //----------------------------------------------------------------------------
91
92 void wxVtkBaseView::TransCoordScreenToWorld(double &X, double &Y, double &Z, int type)
93 {
94         GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
95         GetRenderer()->DisplayToWorld();
96         double fP[4];
97         GetRenderer()->GetWorldPoint( fP );
98         if ( fP[3] ){
99                 fP[0] /= fP[3];
100                 fP[1] /= fP[3];
101                 fP[2] /= fP[3];
102         }
103
104         if (type!=0)
105         {
106                 X=fP[0];
107         }
108         if (type!=1)
109         {
110                 Y=fP[1];
111         }
112         if (type!=2)
113         {
114                 Z=fP[2];
115         } 
116 }
117 //----------------------------------------------------------------------------
118                                         
119 void wxVtkBaseView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type) //virtual //keepNormalDirection=false, type=2
120 {
121         double xx = X;
122         double yy = Y;
123         double zz = Z;
124
125         //RaC 03-2010
126         TransCoordScreenToWorld(xx,yy,zz,type);
127
128         X = xx;
129         Y = yy;
130         Z=zz;
131
132 // EEDx5
133         //JCP 13/05/2009
134         vtkInteractorStyleBaseView* interactorstyle = (vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView();
135     wxVtk2DBaseView* baseview = (wxVtk2DBaseView*)interactorstyle->GetWxVtk2DBaseView();
136
137         double fP[3];
138         fP[0] = X;
139         fP[1] = Y;
140         fP[2] = Z;
141
142         baseview->TransformCoordinate_spacing_ViewToModel( fP[0] , fP[1] , fP[2] );
143         //JCP 13/05/2009
144
145         if (type!=0)
146         {
147                 X=fP[0];
148         }
149         if (type!=1)
150         {
151                 Y=fP[1];
152         }
153         if (type!=2)
154         {
155                 Z=fP[2];
156         } 
157 }
158
159 //---------------------------------------------------------------------------
160 /* JCP 14/05/09
161 vtkInteractorStyleBaseView*     wxVtkBaseView::GetInteractorStyleBaseView()
162 {
163         return _interactorStyle;
164 }
165 */
166 vtkInteractorStyleImage*        wxVtkBaseView::GetInteractorStyleBaseView()
167 {
168         return _interactorStyle;
169 }
170
171 //---------------------------------------------------------------------------
172
173 void wxVtkBaseView::SetInteractorStyleBaseView( vtkInteractorStyleImage*        interactorStyle)
174 {
175         _interactorStyle = interactorStyle;
176 }
177
178 //---------------------------------------------------------------------------
179
180 void wxVtkBaseView::GetSpacing(double spc[3])  // virtual
181 {
182         spc[0]=1;
183         spc[1]=1;
184         spc[2]=1;
185 }
186
187 //-------------------------------------------------------------------
188 //-------------------------------------------------------------------
189 //-------------------------------------------------------------------
190
191
192