1 #include "vtkInteractorStyleBaseView.h"
3 #include "wxVtk3DBaseView.h"
4 #include "wxVtk2DBaseView.h"
6 #include "vtkObjectFactory.h"
8 #include "InteractorStyleMaracas.h"
10 vtkStandardNewMacro(vtkInteractorStyleBaseView);
11 //---------------------------------------------------------------------------
12 //---------------------------------------------------------------------------
13 //---------------------------------------------------------------------------
15 vtkInteractorStyleBaseView::vtkInteractorStyleBaseView()
17 _refresh_waiting = false;
18 _parent_refresh_waiting = false;
19 _blockRefresh = false;
22 SetMouseWheelMotionFactor(0.5);
24 //---------------------------------------------------------------------------
25 vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView()
28 //---------------------------------------------------------------------------
29 void vtkInteractorStyleBaseView::OnMouseMove() // virtual
31 CallLstInteractorStyleMaracas(3);
33 //---------------------------------------------------------------------------
34 void vtkInteractorStyleBaseView::OnLeftButtonDown() // virtual
36 CallLstInteractorStyleMaracas(4);
38 //---------------------------------------------------------------------------
39 void vtkInteractorStyleBaseView::OnLeftButtonUp() // virtual
41 CallLstInteractorStyleMaracas(5);
44 //---------------------------------------------------------------------------
45 void vtkInteractorStyleBaseView::OnLeftDClick() // virtual
47 CallLstInteractorStyleMaracas( 11 );
50 //---------------------------------------------------------------------------
51 void vtkInteractorStyleBaseView::OnMiddleButtonDown() // virtual
53 CallLstInteractorStyleMaracas(6);
55 //---------------------------------------------------------------------------
56 void vtkInteractorStyleBaseView::OnMiddleButtonUp() // virtual
58 CallLstInteractorStyleMaracas(7);
60 //---------------------------------------------------------------------------
61 void vtkInteractorStyleBaseView::OnMiddleDClick() // virtual
63 CallLstInteractorStyleMaracas( 13 );
66 //---------------------------------------------------------------------------
67 void vtkInteractorStyleBaseView::OnRightButtonDown() // virtual
69 CallLstInteractorStyleMaracas(1);
71 //---------------------------------------------------------------------------
72 void vtkInteractorStyleBaseView::OnRightButtonUp() // virtual
74 CallLstInteractorStyleMaracas(2);
76 //---------------------------------------------------------------------------
77 void vtkInteractorStyleBaseView::OnRightDClick() // virtual
79 CallLstInteractorStyleMaracas( 12 );
81 //---------------------------------------------------------------------------
83 void vtkInteractorStyleBaseView::OnMouseWheel() // virtual
85 printf("EED vtkInteractorStyleBaseView::OnMouseWheel\n");
86 CallLstInteractorStyleMaracas( 14 );
89 void vtkInteractorStyleBaseView::OnMouseWheelForward() // virtual
91 printf("EED.. vtkInteractorStyleBaseView::OnMouseWheelForward\n");
92 CallLstInteractorStyleMaracas( 15 );
95 void vtkInteractorStyleBaseView::OnMouseWheelBackward() // virtual
97 printf("EED.. vtkInteractorStyleBaseView::OnMouseWheelBackward\n");
98 CallLstInteractorStyleMaracas( 16 );
104 //---------------------------------------------------------------------------
105 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
107 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
108 _lstInteractorStyleMaracas.push_back(interactorStyleMaracas);
110 //---------------------------------------------------------------------------
111 void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
113 interactorStyleMaracas->RemoveVtkInteractorStyleBaseView();
114 int i, size = _lstInteractorStyleMaracas.size();
115 std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin();
116 bool removed = false;
117 for (i=0; !removed && i<size; i++)
119 if ( _lstInteractorStyleMaracas[i] == interactorStyleMaracas )
121 _lstInteractorStyleMaracas.erase(iter);
128 //---------------------------------------------------------------------------
129 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
131 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
132 _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
134 //---------------------------------------------------------------------------
135 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
138 InteractorStyleMaracas *intStyMar;
140 int i,size=_lstInteractorStyleMaracas.size();
143 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
144 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
145 //for (i=0;i<size;i++)
147 //fprintf(ff," %p\n" , _lstInteractorStyleMaracas[i] );
155 if (i < (int)_lstInteractorStyleMaracas.size() )
157 intStyMar = _lstInteractorStyleMaracas[i];
161 if (intStyMar!=NULL && intStyMar->GetActive()==true){
163 { // OnRightButtonDown
164 if (intStyMar->OnRightButtonDown()==false)
171 if (intStyMar->OnRightButtonUp()==false)
178 if (intStyMar->OnMouseMove()==false)
184 { // OnLeftButtonDown
185 if (intStyMar->OnLeftButtonDown()==false)
192 if (intStyMar->OnLeftButtonUp()==false)
198 { // OnMiddleButtonDown
199 if (intStyMar->OnMiddleButtonDown()==false)
205 { // OnMiddleButtonUp
206 if (intStyMar->OnMiddleButtonUp()==false)
212 { // OnMiddleButtonUp
213 if (intStyMar->OnChar()==false)
220 if (intStyMar->OnLeftDClick()==false)
227 if (intStyMar->OnRightDClick()==false)
234 if (intStyMar-> OnMiddleDClick()==false)
240 //EED ????? 27Juillet2011
243 if (intStyMar->OnMouseWheel()==false)
249 { // OnMouseWheelForward
250 if (intStyMar->OnMouseWheelForward()==false)
256 { // OnMouseWheelBackward
257 if (intStyMar->OnMouseWheelBackward()==false)
269 //---------------------------------------------------------------------------
270 void vtkInteractorStyleBaseView::OnChar() // virtual
272 // char a=GetInteractor()->GetKeyCode();
273 CallLstInteractorStyleMaracas(10);
275 //---------------------------------------------------------------------------
276 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
278 if(((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ){
279 vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
281 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
282 imageViewer->GetRenderer()->DisplayToWorld();
284 imageViewer->GetRenderer()->GetWorldPoint( fP );
293 ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
300 //---------------------------------------------------------------------------
301 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
303 _wxvtkbaseview = wxvtkbaseview;
305 //---------------------------------------------------------------------------
307 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
309 return (wxVtk2DBaseView*)_wxvtkbaseview;
311 //---------------------------------------------------------------------------
312 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
314 return (wxVtk3DBaseView*)_wxvtkbaseview;
316 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
318 return _wxvtkbaseview;
320 //---------------------------------------------------------------------------
321 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
323 return _wxvtkbaseview;
325 //---------------------------------------------------------------------------
326 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
328 InteractorStyleMaracas *intStyMar;
329 int i,size=_lstInteractorStyleMaracas.size();
332 intStyMar = _lstInteractorStyleMaracas[i];
333 intStyMar->SetActive(ok);
337 //---------------------------------------------------------------------------
338 void vtkInteractorStyleBaseView::SetRefresh_waiting()
340 _refresh_waiting=true;
342 //---------------------------------------------------------------------------
343 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
345 return _refresh_waiting;
347 //---------------------------------------------------------------------------
348 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
350 _parent_refresh_waiting=true;
352 //---------------------------------------------------------------------------
353 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
355 return _parent_refresh_waiting;
357 //---------------------------------------------------------------------------
358 void vtkInteractorStyleBaseView::EvaluateToRefresh()
361 if ( _blockRefresh==false )
363 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
365 _refresh_waiting = false;
366 this->_wxvtkbaseview->Refresh();
368 if (_parent_refresh_waiting==true)
370 _parent_refresh_waiting = false;
371 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
373 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
375 int size = _lstParentToReport.size();
376 for(i = 0; i<size; i++)
378 _lstParentToReport[i]->ProcessEvent(newevent1);
383 //---------------------------------------------------------------------------
384 void vtkInteractorStyleBaseView::BlockRefresh()
388 //---------------------------------------------------------------------------
389 void vtkInteractorStyleBaseView::UnBlockRefresh()
394 wxEvtHandler* vtkInteractorStyleBaseView::GetParentToReport(int i)
396 wxEvtHandler* parentToReport = NULL;
397 if(i>=0 && i<_lstParentToReport.size())
399 parentToReport = _lstParentToReport[i];
401 return parentToReport;
405 void vtkInteractorStyleBaseView::AddParentToReport(wxEvtHandler* parentToReport)
407 _lstParentToReport.push_back(parentToReport);