vtkInteractorStyleSphere.cxx
Go to the documentation of this file.00001
00002 #include "vtkInteractorStyleSphere.h"
00003
00004 #include "wxSphereView.h"
00005
00006 vtkInteractorStyleSphere::vtkInteractorStyleSphere()
00007 {
00008 _stateRadio = false;
00009 _stateRotate = false;
00010 }
00011
00012
00013
00014 vtkInteractorStyleSphere::~vtkInteractorStyleSphere()
00015 {
00016 }
00017
00018
00019
00020
00021 bool vtkInteractorStyleSphere::OnRightButtonDown()
00022 {
00023 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
00024 {
00025 _stateRadio = true;
00026
00027 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
00028
00029 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
00030
00031 _radio = wxsphereview->GetRadio();
00032 }
00033
00034 return true;
00035 }
00036
00037
00038
00039 bool vtkInteractorStyleSphere::OnRightButtonUp()
00040 {
00041 if (_stateRadio==true)
00042 {
00043 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
00044 wxsphereview->SetDeltaVoxel(1);
00045 double radio=wxsphereview->GetRadio();
00046 wxsphereview->GetIdOfImage(radio+0.1);
00047 wxsphereview->GetIdOfImage(radio+0.2);
00048 wxsphereview->GetIdOfImage(radio-0.1);
00049 wxsphereview->GetIdOfImage(radio-0.2);
00050
00051 wxsphereview->RefreshView();
00052 _stateRadio = false;
00053 }
00054
00055 return true;
00056 }
00057
00058
00059 bool vtkInteractorStyleSphere::OnLeftButtonDown()
00060 {
00061 _stateRotate = true;
00062 _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
00063 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
00064 return true;
00065 }
00066
00067
00068
00069
00070 bool vtkInteractorStyleSphere::OnLeftButtonUp()
00071 {
00072 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
00073 if (_stateRotate==true){
00074 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
00075 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
00076
00077 if ((_fordwareX==fx)&&(_fordwareY==fy)){
00078 double x=fx,y=fy,z=1;
00079 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
00080 wxsphereview->SetXYZtoParent(x,y);
00081 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
00082 wxsphereview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
00083 } else {
00084 wxsphereview->RotationEnd();
00085 }
00086 wxsphereview->RefreshView();
00087 _stateRotate = false;
00088 }
00089
00090 return true;
00091 }
00092
00093
00094
00095
00096 bool vtkInteractorStyleSphere::OnMouseMove ()
00097 {
00098 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
00099 if (_stateRotate==true)
00100 {
00101 bool ok_v, ok_ang;
00102 ok_v=false;
00103 ok_ang=false;
00104 if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
00105 {
00106 ok_v = true;
00107 }
00108 if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
00109 {
00110 ok_ang = true;
00111 }
00112 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
00113 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
00114 wxsphereview->RotationStart( fx - _fordwareX , -(fy - _fordwareY) , ok_v, ok_ang);
00115 wxsphereview->RefreshView();
00116 }
00117 if (_stateRadio==true)
00118 {
00119
00120 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
00121 double dif=(fy-_fordwareY) / 10.0;
00122 wxsphereview->SetRadio( _radio + dif );
00123 wxsphereview->SetDeltaVoxel(3);
00124 wxsphereview->RefreshView();
00125 }
00126
00127 return true;
00128 }