00001 #include "wxVTKRenderWindowInteractorEditContour.h"
00002
00003
00004 vtkInteractorStyle3DMaracas::vtkInteractorStyle3DMaracas(){
00005 }
00006
00007 vtkInteractorStyle3DMaracas::~vtkInteractorStyle3DMaracas(){
00008 }
00009
00010 void vtkInteractorStyle3DMaracas::OnRightButtonDown (){
00011
00012
00013
00014
00015
00016 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
00017 this->Interactor->GetEventPosition()[1]);
00018
00019 if (this->CurrentRenderer == NULL)
00020 {
00021 return;
00022 }
00023
00024 if (this->Interactor->GetControlKey()) {
00025 this->StartDolly();
00026 }
00027
00028 }
00029
00030 void vtkInteractorStyle3DMaracas::OnRightButtonUp () {
00031
00032
00033
00034
00035
00036
00037
00038 switch (this->State)
00039 {
00040 case VTKIS_DOLLY:
00041 this->EndDolly();
00042 break;
00043 }
00044 }
00045
00046 void vtkInteractorStyle3DMaracas::OnMouseMove () {
00047
00048
00049
00050 this->Interactor->GetEventPosition()[0];
00051 this->Interactor->GetEventPosition()[1];
00052
00053
00054 vtkRenderWindowInteractor *rwi = this->Interactor;
00055
00056 rwi->GetLastEventPosition()[0];
00057 rwi->GetLastEventPosition()[1];
00058 rwi->GetEventPosition()[0] ;
00059 rwi->GetEventPosition()[1] ;
00060
00061
00062 switch (this->State)
00063 {
00064 case VTKIS_ROTATE:
00065
00066 this->Rotate();
00067
00068 break;
00069
00070 case VTKIS_PAN:
00071
00072 this->Pan();
00073
00074 break;
00075
00076 case VTKIS_DOLLY:
00077
00078 this->Dolly();
00079
00080 break;
00081
00082 case VTKIS_SPIN:
00083
00084 this->Spin();
00085
00086 break;
00087 }
00088
00089
00090
00091 }
00092
00093 void vtkInteractorStyle3DMaracas::OnLeftButtonDown (){
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
00104 this->Interactor->GetEventPosition()[1]);
00105 if (this->CurrentRenderer == NULL)
00106 {
00107 return;
00108 }
00109
00110 if (this->Interactor->GetControlKey()) {
00111 this->StartPan();
00112 } else {
00113 this->StartRotate();
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 }
00143
00144 void vtkInteractorStyle3DMaracas::OnLeftButtonUp () {
00145
00146
00147
00148
00149
00150
00151
00152 switch (this->State)
00153 {
00154
00155 case VTKIS_PAN:
00156 this->EndPan();
00157 break;
00158
00159 case VTKIS_ROTATE:
00160 this->EndRotate();
00161 break;
00162 }
00163 }
00164
00165 void vtkInteractorStyle3DMaracas::OnMiddleButtonDown () {
00166
00167 }
00168
00169 void vtkInteractorStyle3DMaracas::OnMiddleButtonUp () {
00170
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180 vtkInteractorStyle2DMaracas::vtkInteractorStyle2DMaracas(){
00181 _obs=NULL;
00182 }
00183
00184 vtkInteractorStyle2DMaracas::~vtkInteractorStyle2DMaracas(){
00185 }
00186
00187 void vtkInteractorStyle2DMaracas::OnRightButtonDown (){
00188 if (GetInteractor()->GetControlKey()==1 ){
00189 this->vtkInteractorStyleImage::OnRightButtonDown();
00190 }
00191 }
00192
00193 void vtkInteractorStyle2DMaracas::OnRightButtonUp () {
00194 if (GetInteractor()->GetControlKey()==1 ){
00195 this->vtkInteractorStyleImage::OnRightButtonUp();
00196 }
00197 }
00198
00199 void vtkInteractorStyle2DMaracas::OnMouseMove () {
00200 this->vtkInteractorStyleImage::OnMouseMove();
00201 }
00202
00203 void vtkInteractorStyle2DMaracas::OnLeftButtonDown (){
00204 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
00205 this->vtkInteractorStyleImage::OnMiddleButtonDown();
00206 } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
00207 if (_obs){
00208 _obs->Execute( NULL , vtkCommand::LeftButtonPressEvent , NULL ) ;
00209 }
00210 } else {
00211 this->vtkInteractorStyleImage::OnLeftButtonDown();
00212 }
00213 }
00214
00215
00216 void vtkInteractorStyle2DMaracas::OnLeftButtonUp () {
00217 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
00218 this->vtkInteractorStyleImage::OnMiddleButtonUp();
00219 } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
00220 if (_obs) {
00221 _obs->Execute( NULL , vtkCommand::LeftButtonReleaseEvent , NULL );
00222 }
00223 } else {
00224 this->vtkInteractorStyleImage::OnLeftButtonUp();
00225 }
00226 }
00227
00228 void vtkInteractorStyle2DMaracas::OnMiddleButtonDown () {
00229 }
00230
00231 void vtkInteractorStyle2DMaracas::OnMiddleButtonUp () {
00232 }
00233
00234
00235 void vtkInteractorStyle2DMaracas::SetObserver(vtkCommand* obs){
00236 this->_obs=obs;
00237 }
00238
00239
00240
00241
00242
00243 wxVTKRenderWindowInteractorEditContour::wxVTKRenderWindowInteractorEditContour(wxWindow *parent,wxWindowID id)
00244 :wxVTKRenderWindowInteractor(parent,id){
00245 this->_state=0;
00246 }
00247
00248 wxVTKRenderWindowInteractorEditContour::~wxVTKRenderWindowInteractorEditContour(){
00249 }
00250
00251 void wxVTKRenderWindowInteractorEditContour::OnButtonDown(wxMouseEvent &event){
00252 if (this->_state==1){
00253 wxVTKRenderWindowInteractor::OnButtonDown(event);
00254 }
00255 if (this->_state==2){
00256 if(event.LeftDown()==true){
00257 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
00258 _obs->Execute( NULL , wxEVT_LEFT_DOWN , NULL ) ;
00259 }
00260 if(event.RightDown()==true){
00261 wxVTKRenderWindowInteractor::OnButtonDown(event);
00262 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
00263 _obs->Execute( NULL , wxEVT_RIGHT_DOWN , NULL ) ;
00264 }
00265 }
00266 }
00267
00268 void wxVTKRenderWindowInteractorEditContour::OnButtonUp(wxMouseEvent &event){
00269 if (this->_state==1){
00270 wxVTKRenderWindowInteractor::OnButtonUp(event);
00271 }
00272 if (this->_state==2){
00273 if(event.LeftUp()==true){
00274 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
00275 _obs->Execute( NULL , wxEVT_LEFT_UP , NULL ) ;
00276 }
00277 if(event.RightUp()==true){
00278 wxVTKRenderWindowInteractor::OnButtonUp(event);
00279 }
00280 }
00281 }
00282
00283 void wxVTKRenderWindowInteractorEditContour::OnButtonDouble(wxMouseEvent &event){
00284 if (this->_state==1){
00285
00286
00287
00288 }
00289 if (this->_state==2){
00290 if(event.LeftDClick()==true){
00291 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
00292 _obs->Execute( NULL , wxEVT_LEFT_DCLICK , NULL ) ;
00293 }
00294 }
00295 }
00296
00297 void wxVTKRenderWindowInteractorEditContour::OnMotion(wxMouseEvent &event){
00298 if (this->_state==1){
00299 wxVTKRenderWindowInteractor::OnMotion(event);
00300 }
00301 if (this->_state==2){
00302 wxVTKRenderWindowInteractor::OnMotion(event);
00303 if(event.Moving()==true){
00304 SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
00305 _obs->Execute( NULL , wxEVT_MOTION , NULL ) ;
00306 }
00307 }
00308 }
00309
00310 void wxVTKRenderWindowInteractorEditContour::OnKeyDown(wxKeyEvent &event){
00311 wxVTKRenderWindowInteractor::OnKeyDown(event);
00312 if (( event.GetKeyCode()==WXK_BACK ) || ( event.GetKeyCode()==WXK_DELETE) ){
00313 _obs->Execute( NULL , WXK_CLEAR , NULL ) ;
00314 }
00315 }
00316
00317 void wxVTKRenderWindowInteractorEditContour::SetState(int state){
00318 this->_state=state;
00319 }
00320
00321 int wxVTKRenderWindowInteractorEditContour::GetState(){
00322 return this->_state;
00323 }
00324
00325 void wxVTKRenderWindowInteractorEditContour::SetObserver(vtkCommand* obs){
00326 this->_obs=obs;
00327 }
00328