]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx
BUG view MPR
[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
31 //-------------------------------------------------------------------
32 wxVtkBaseView::~wxVtkBaseView()
33 {
34         _iren -> Delete();
35         //_iren=NULL;
36 }
37 //-------------------------------------------------------------------
38 wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
39 {
40
41         if(_iren==NULL){
42                 throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren wxVTKRenderWindowInteractorPlus =NULL";
43         }
44    return _iren;
45 }
46 //-------------------------------------------------------------------
47 void wxVtkBaseView::Configure()  // virtual 
48 {
49 }
50 //-------------------------------------------------------------------
51 void wxVtkBaseView::Refresh()  // virtual 
52 {
53 // EED 10 Oct 2007
54
55         #if defined(WIN32)
56                 _iren->Refresh(false);
57         #else
58         
59 //EED 01Avril2009
60 //              _iren->Render();        
61         vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
62         vri->vtkRenderWindowInteractor::Render();
63         
64         
65                 //_iren->Refresh();
66         #endif
67
68 }
69 //-------------------------------------------------------------------
70 void wxVtkBaseView::RefreshView()  // virtual 
71 {
72 // EED 10 Oct 2007
73
74         #if defined(WIN32)
75                 GetRenWin()->Render();
76         #else
77                 //GetRenWin()->Render();
78         #endif
79
80 }
81 //---------------------------------------------------------------------------
82 vtkRenderer* wxVtkBaseView::GetRenderer()       // virtual 
83 {
84         return NULL;
85 }
86 //---------------------------------------------------------------------------
87 vtkRenderWindow* wxVtkBaseView::GetRenWin()             // virtual
88 {
89         return _iren->GetRenderWindow();
90 }
91
92 //----------------------------------------------------------------------------
93                                         
94 void wxVtkBaseView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type) //virtual //keepNormalDirection=false, type=2
95 {  
96         GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
97         GetRenderer()->DisplayToWorld();
98         double fP[4];
99         GetRenderer()->GetWorldPoint( fP );
100         if ( fP[3] ){
101                 fP[0] /= fP[3];
102                 fP[1] /= fP[3];
103                 fP[2] /= fP[3];
104         }
105
106 // EEDx5
107         //JCP 13/05/2009
108         vtkInteractorStyleBaseView* interactorstyle = (vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView();
109         wxVtk2DBaseView* baseview = (wxVtk2DBaseView*)interactorstyle->GetWxVtk2DBaseView();
110         baseview->TransformCoordinate_spacing_ViewToModel( fP[0] , fP[1] , fP[2] );
111         //JCP 13/05/2009
112
113         if (type!=0)
114         {
115                 X=fP[0];
116         }
117         if (type!=1)
118         {
119                 Y=fP[1];
120         }
121         if (type!=2)
122         {
123                 Z=fP[2];
124         } 
125 }
126
127 //---------------------------------------------------------------------------
128 /* JCP 14/05/09
129 vtkInteractorStyleBaseView*     wxVtkBaseView::GetInteractorStyleBaseView()
130 {
131         return _interactorStyle;
132 }
133 */
134 vtkInteractorStyleImage*        wxVtkBaseView::GetInteractorStyleBaseView()
135 {
136         return _interactorStyle;
137 }
138
139
140 //---------------------------------------------------------------------------
141
142 void wxVtkBaseView::SetInteractorStyleBaseView( vtkInteractorStyleImage*        interactorStyle)
143 {
144         _interactorStyle = interactorStyle;
145 }
146
147 //---------------------------------------------------------------------------
148
149 void wxVtkBaseView::GetSpacing(double spc[3])  // virtual
150 {
151         spc[0]=1;
152         spc[1]=1;
153         spc[2]=1;
154 }
155
156
157
158 //-------------------------------------------------------------------
159 //-------------------------------------------------------------------
160 //-------------------------------------------------------------------
161
162
163