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 );
83 void vtkInteractorStyleBaseView::OnMouseWheelForward() // virtual
85 CallLstInteractorStyleMaracas( 15 );
88 void vtkInteractorStyleBaseView::OnMouseWheelBackward() // virtual
90 CallLstInteractorStyleMaracas( 16 );
96 //---------------------------------------------------------------------------
97 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
99 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
100 _lstInteractorStyleMaracas.push_back(interactorStyleMaracas);
102 //---------------------------------------------------------------------------
103 void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
105 interactorStyleMaracas->RemoveVtkInteractorStyleBaseView();
106 int i, size = _lstInteractorStyleMaracas.size();
107 std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin();
108 bool removed = false;
109 for (i=0; !removed && i<size; i++)
111 if ( _lstInteractorStyleMaracas[i] == interactorStyleMaracas )
113 _lstInteractorStyleMaracas.erase(iter);
120 //---------------------------------------------------------------------------
121 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
123 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
124 _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
126 //---------------------------------------------------------------------------
127 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
130 InteractorStyleMaracas *intStyMar;
132 int i,size=_lstInteractorStyleMaracas.size();
135 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
136 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
137 //for (i=0;i<size;i++)
139 //fprintf(ff," %p\n" , _lstInteractorStyleMaracas[i] );
147 if (i < (int)_lstInteractorStyleMaracas.size() )
149 intStyMar = _lstInteractorStyleMaracas[i];
153 if (intStyMar!=NULL && intStyMar->GetActive()==true){
155 { // OnRightButtonDown
156 if (intStyMar->OnRightButtonDown()==false)
163 if (intStyMar->OnRightButtonUp()==false)
170 if (intStyMar->OnMouseMove()==false)
176 { // OnLeftButtonDown
177 if (intStyMar->OnLeftButtonDown()==false)
184 if (intStyMar->OnLeftButtonUp()==false)
190 { // OnMiddleButtonDown
191 if (intStyMar->OnMiddleButtonDown()==false)
197 { // OnMiddleButtonUp
198 if (intStyMar->OnMiddleButtonUp()==false)
204 { // OnMiddleButtonUp
205 if (intStyMar->OnChar()==false)
212 if (intStyMar->OnLeftDClick()==false)
219 if (intStyMar->OnRightDClick()==false)
226 if (intStyMar-> OnMiddleDClick()==false)
231 // 14 ... old OnMouseWheelFordward
233 { // OnMouseWheelForward
234 if (intStyMar->OnMouseWheelForward()==false)
240 { // OnMouseWheelBackward
241 if (intStyMar->OnMouseWheelBackward()==false)
253 //---------------------------------------------------------------------------
254 void vtkInteractorStyleBaseView::OnChar() // virtual
256 // char a=GetInteractor()->GetKeyCode();
257 CallLstInteractorStyleMaracas(10);
259 //---------------------------------------------------------------------------
260 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
262 if(((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ){
263 vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
265 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
266 imageViewer->GetRenderer()->DisplayToWorld();
268 imageViewer->GetRenderer()->GetWorldPoint( fP );
277 ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
284 //---------------------------------------------------------------------------
285 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
287 _wxvtkbaseview = wxvtkbaseview;
289 //---------------------------------------------------------------------------
291 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
293 return (wxVtk2DBaseView*)_wxvtkbaseview;
295 //---------------------------------------------------------------------------
296 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
298 return (wxVtk3DBaseView*)_wxvtkbaseview;
300 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
302 return _wxvtkbaseview;
304 //---------------------------------------------------------------------------
305 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
307 return _wxvtkbaseview;
309 //---------------------------------------------------------------------------
310 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
312 InteractorStyleMaracas *intStyMar;
313 int i,size=_lstInteractorStyleMaracas.size();
316 intStyMar = _lstInteractorStyleMaracas[i];
317 intStyMar->SetActive(ok);
321 //---------------------------------------------------------------------------
322 void vtkInteractorStyleBaseView::SetRefresh_waiting()
324 _refresh_waiting=true;
326 //---------------------------------------------------------------------------
327 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
329 return _refresh_waiting;
331 //---------------------------------------------------------------------------
332 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
334 _parent_refresh_waiting=true;
336 //---------------------------------------------------------------------------
337 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
339 return _parent_refresh_waiting;
341 //---------------------------------------------------------------------------
342 void vtkInteractorStyleBaseView::EvaluateToRefresh()
345 if ( _blockRefresh==false )
347 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
349 _refresh_waiting = false;
350 this->_wxvtkbaseview->Refresh();
352 if (_parent_refresh_waiting==true)
354 _parent_refresh_waiting = false;
355 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
357 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
359 int size = _lstParentToReport.size();
360 for(i = 0; i<size; i++)
362 _lstParentToReport[i]->ProcessEvent(newevent1);
367 //---------------------------------------------------------------------------
368 void vtkInteractorStyleBaseView::BlockRefresh()
372 //---------------------------------------------------------------------------
373 void vtkInteractorStyleBaseView::UnBlockRefresh()
378 wxEvtHandler* vtkInteractorStyleBaseView::GetParentToReport(int i)
380 wxEvtHandler* parentToReport = NULL;
381 if(i>=0 && i<_lstParentToReport.size())
383 parentToReport = _lstParentToReport[i];
385 return parentToReport;
389 void vtkInteractorStyleBaseView::AddParentToReport(wxEvtHandler* parentToReport)
391 _lstParentToReport.push_back(parentToReport);