wxVtkBaseView.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005 #include "wxVtkBaseView.h"
00006 #include "wxVtk2DBaseView.h"
00007 #include "wxVTKRenderWindowInteractorPlus.h"
00008
00009
00010
00011 wxVtkBaseView::wxVtkBaseView()
00012 {
00013 _parent = NULL;
00014 _iren = NULL;
00015 _interactorStyle = NULL;
00016 }
00017
00018
00019
00020 wxVtkBaseView::wxVtkBaseView(wxWindow *parent)
00021 {
00022 _parent = parent;
00023 _iren = (wxVTKRenderWindowInteractor*)new wxVTKRenderWindowInteractorPlus(_parent,this);
00024
00025
00026 _interactorStyle = NULL;
00027 }
00028
00029
00030 wxVtkBaseView::~wxVtkBaseView()
00031 {
00032 _iren -> Delete();
00033
00034 }
00035
00036 wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
00037 {
00038
00039 if(_iren==NULL){
00040 throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren wxVTKRenderWindowInteractorPlus =NULL";
00041 }
00042 return _iren;
00043 }
00044
00045 void wxVtkBaseView::Configure()
00046 {
00047 }
00048
00049 void wxVtkBaseView::Refresh()
00050 {
00051
00052
00053 #if defined(WIN32)
00054 _iren->Refresh(false);
00055 #else
00056
00057
00058
00059 vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
00060 vri->vtkRenderWindowInteractor::Render();
00061
00062
00063
00064 #endif
00065
00066 }
00067
00068 void wxVtkBaseView::RefreshView()
00069 {
00070
00071
00072 #if defined(WIN32)
00073 GetRenWin()->Render();
00074 #else
00075
00076 #endif
00077
00078 }
00079
00080 vtkRenderer* wxVtkBaseView::GetRenderer()
00081 {
00082 return NULL;
00083 }
00084
00085 vtkRenderWindow* wxVtkBaseView::GetRenWin()
00086 {
00087 return _iren->GetRenderWindow();
00088 }
00089
00090
00091
00092 void wxVtkBaseView::TransCoordScreenToWorld(double &X, double &Y, double &Z, int type)
00093 {
00094 GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
00095 GetRenderer()->DisplayToWorld();
00096 double fP[4];
00097 GetRenderer()->GetWorldPoint( fP );
00098 if ( fP[3] ){
00099 fP[0] /= fP[3];
00100 fP[1] /= fP[3];
00101 fP[2] /= fP[3];
00102 }
00103
00104 if (type!=0)
00105 {
00106 X=fP[0];
00107 }
00108 if (type!=1)
00109 {
00110 Y=fP[1];
00111 }
00112 if (type!=2)
00113 {
00114 Z=fP[2];
00115 }
00116 }
00117
00118
00119 void wxVtkBaseView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type)
00120 {
00121 double xx = X;
00122 double yy = Y;
00123 double zz = Z;
00124
00125
00126 TransCoordScreenToWorld(xx,yy,zz,type);
00127
00128 X = xx;
00129 Y = yy;
00130 Z=zz;
00131
00132
00133
00134 vtkInteractorStyleBaseView* interactorstyle = (vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView();
00135 wxVtk2DBaseView* baseview = (wxVtk2DBaseView*)interactorstyle->GetWxVtk2DBaseView();
00136
00137 double fP[3];
00138 fP[0] = X;
00139 fP[1] = Y;
00140 fP[2] = Z;
00141
00142 baseview->TransformCoordinate_spacing_ViewToModel( fP[0] , fP[1] , fP[2] );
00143
00144
00145 if (type!=0)
00146 {
00147 X=fP[0];
00148 }
00149 if (type!=1)
00150 {
00151 Y=fP[1];
00152 }
00153 if (type!=2)
00154 {
00155 Z=fP[2];
00156 }
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166 vtkInteractorStyleImage* wxVtkBaseView::GetInteractorStyleBaseView()
00167 {
00168 return _interactorStyle;
00169 }
00170
00171
00172
00173 void wxVtkBaseView::SetInteractorStyleBaseView( vtkInteractorStyleImage* interactorStyle)
00174 {
00175 _interactorStyle = interactorStyle;
00176 }
00177
00178
00179
00180 void wxVtkBaseView::GetSpacing(double spc[3])
00181 {
00182 spc[0]=1;
00183 spc[1]=1;
00184 spc[2]=1;
00185 }
00186
00187
00188
00189
00190
00191
00192