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;
21 //---------------------------------------------------------------------------
22 vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView()
25 //---------------------------------------------------------------------------
26 void vtkInteractorStyleBaseView::OnMouseMove() // virtual
28 CallLstInteractorStyleMaracas(3);
30 //---------------------------------------------------------------------------
31 void vtkInteractorStyleBaseView::OnLeftButtonDown() // virtual
33 CallLstInteractorStyleMaracas(4);
35 //---------------------------------------------------------------------------
36 void vtkInteractorStyleBaseView::OnLeftButtonUp() // virtual
38 CallLstInteractorStyleMaracas(5);
41 //---------------------------------------------------------------------------
42 void vtkInteractorStyleBaseView::OnLeftDClick() // virtual
44 CallLstInteractorStyleMaracas( 11 );
47 //---------------------------------------------------------------------------
48 void vtkInteractorStyleBaseView::OnMiddleButtonDown() // virtual
50 CallLstInteractorStyleMaracas(6);
52 //---------------------------------------------------------------------------
53 void vtkInteractorStyleBaseView::OnMiddleButtonUp() // virtual
55 CallLstInteractorStyleMaracas(7);
57 //---------------------------------------------------------------------------
58 void vtkInteractorStyleBaseView::OnMiddleDClick() // virtual
60 CallLstInteractorStyleMaracas( 13 );
63 //---------------------------------------------------------------------------
64 void vtkInteractorStyleBaseView::OnRightButtonDown() // virtual
66 CallLstInteractorStyleMaracas(1);
68 //---------------------------------------------------------------------------
69 void vtkInteractorStyleBaseView::OnRightButtonUp() // virtual
71 CallLstInteractorStyleMaracas(2);
73 //---------------------------------------------------------------------------
74 void vtkInteractorStyleBaseView::OnRightDClick() // virtual
76 CallLstInteractorStyleMaracas( 12 );
78 //---------------------------------------------------------------------------
79 void vtkInteractorStyleBaseView::OnMouseWheel() // virtual
81 CallLstInteractorStyleMaracas( 14 );
83 //---------------------------------------------------------------------------
84 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
86 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
87 _lstInteractorStyleMaracas.push_back(interactorStyleMaracas);
89 //---------------------------------------------------------------------------
90 void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
92 interactorStyleMaracas->RemoveVtkInteractorStyleBaseView();
93 int i, size = _lstInteractorStyleMaracas.size();
94 std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin();
96 for (i=0; !removed && i<size; i++)
98 if ( _lstInteractorStyleMaracas[i] == interactorStyleMaracas )
100 _lstInteractorStyleMaracas.erase(iter);
107 //---------------------------------------------------------------------------
108 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
110 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
111 _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
113 //---------------------------------------------------------------------------
114 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
117 InteractorStyleMaracas *intStyMar;
119 int i,size=_lstInteractorStyleMaracas.size();
122 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
123 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
124 //for (i=0;i<size;i++)
126 //fprintf(ff," %p\n" , _lstInteractorStyleMaracas[i] );
134 if (i < (int)_lstInteractorStyleMaracas.size() )
136 intStyMar = _lstInteractorStyleMaracas[i];
140 if (intStyMar!=NULL && intStyMar->GetActive()==true){
142 { // OnRightButtonDown
143 if (intStyMar->OnRightButtonDown()==false)
150 if (intStyMar->OnRightButtonUp()==false)
157 if (intStyMar->OnMouseMove()==false)
163 { // OnLeftButtonDown
164 if (intStyMar->OnLeftButtonDown()==false)
171 if (intStyMar->OnLeftButtonUp()==false)
177 { // OnMiddleButtonDown
178 if (intStyMar->OnMiddleButtonDown()==false)
184 { // OnMiddleButtonUp
185 if (intStyMar->OnMiddleButtonUp()==false)
191 { // OnMiddleButtonUp
192 if (intStyMar->OnChar()==false)
199 if (intStyMar->OnLeftDClick()==false)
206 if (intStyMar->OnRightDClick()==false)
213 if (intStyMar-> OnMiddleDClick()==false)
220 if (intStyMar->OnMouseWheel()==false)
230 //---------------------------------------------------------------------------
231 void vtkInteractorStyleBaseView::OnChar() // virtual
233 // char a=GetInteractor()->GetKeyCode();
234 CallLstInteractorStyleMaracas(10);
236 //---------------------------------------------------------------------------
237 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
239 if(((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ){
240 vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
242 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
243 imageViewer->GetRenderer()->DisplayToWorld();
245 imageViewer->GetRenderer()->GetWorldPoint( fP );
254 ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
261 //---------------------------------------------------------------------------
262 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
264 _wxvtkbaseview = wxvtkbaseview;
266 //---------------------------------------------------------------------------
268 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
270 return (wxVtk2DBaseView*)_wxvtkbaseview;
272 //---------------------------------------------------------------------------
273 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
275 return (wxVtk3DBaseView*)_wxvtkbaseview;
277 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
279 return _wxvtkbaseview;
281 //---------------------------------------------------------------------------
282 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
284 return _wxvtkbaseview;
286 //---------------------------------------------------------------------------
287 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
289 InteractorStyleMaracas *intStyMar;
290 int i,size=_lstInteractorStyleMaracas.size();
293 intStyMar = _lstInteractorStyleMaracas[i];
294 intStyMar->SetActive(ok);
298 //---------------------------------------------------------------------------
299 void vtkInteractorStyleBaseView::SetRefresh_waiting()
301 _refresh_waiting=true;
303 //---------------------------------------------------------------------------
304 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
306 return _refresh_waiting;
308 //---------------------------------------------------------------------------
309 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
311 _parent_refresh_waiting=true;
313 //---------------------------------------------------------------------------
314 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
316 return _parent_refresh_waiting;
318 //---------------------------------------------------------------------------
319 void vtkInteractorStyleBaseView::EvaluateToRefresh()
322 if ( _blockRefresh==false )
324 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
326 _refresh_waiting = false;
327 this->_wxvtkbaseview->Refresh();
329 if (_parent_refresh_waiting==true)
331 _parent_refresh_waiting = false;
332 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
334 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
336 int size = _lstParentToReport.size();
337 for(i = 0; i<size; i++)
339 _lstParentToReport[i]->ProcessEvent(newevent1);
344 //---------------------------------------------------------------------------
345 void vtkInteractorStyleBaseView::BlockRefresh()
349 //---------------------------------------------------------------------------
350 void vtkInteractorStyleBaseView::UnBlockRefresh()
355 wxEvtHandler* vtkInteractorStyleBaseView::GetParentToReport(int i)
357 wxEvtHandler* parentToReport = NULL;
358 if(i>=0 && i<_lstParentToReport.size())
360 parentToReport = _lstParentToReport[i];
362 return parentToReport;
366 void vtkInteractorStyleBaseView::AddParentToReport(wxEvtHandler* parentToReport)
368 _lstParentToReport.push_back(parentToReport);