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 printf("EED %p vtkInteractorStyleBaseView A i=%d size=%d sizeLst%d\n", this, i, size, _lstInteractorStyleMaracas.size() );
135 if (i < _lstInteractorStyleMaracas.size() )
137 intStyMar = _lstInteractorStyleMaracas[i];
141 printf("EED %p vtkInteractorStyleBaseView B i=%d size=%d sizeLst%d\n", this, i, size, _lstInteractorStyleMaracas.size() );
142 if (intStyMar!=NULL && intStyMar->GetActive()==true){
143 printf("EED %p vtkInteractorStyleBaseView C i=%d size=%d sizeLst%d\n", this, i, size, _lstInteractorStyleMaracas.size() );
145 { // OnRightButtonDown
146 if (intStyMar->OnRightButtonDown()==false)
153 if (intStyMar->OnRightButtonUp()==false)
160 if (intStyMar->OnMouseMove()==false)
166 { // OnLeftButtonDown
167 if (intStyMar->OnLeftButtonDown()==false)
174 if (intStyMar->OnLeftButtonUp()==false)
180 { // OnMiddleButtonDown
181 if (intStyMar->OnMiddleButtonDown()==false)
187 { // OnMiddleButtonUp
188 if (intStyMar->OnMiddleButtonUp()==false)
194 { // OnMiddleButtonUp
195 if (intStyMar->OnChar()==false)
202 if (intStyMar->OnLeftDClick()==false)
209 if (intStyMar->OnRightDClick()==false)
216 if (intStyMar-> OnMiddleDClick()==false)
223 if (intStyMar->OnMouseWheel()==false)
233 //---------------------------------------------------------------------------
234 void vtkInteractorStyleBaseView::OnChar() // virtual
236 // char a=GetInteractor()->GetKeyCode();
237 CallLstInteractorStyleMaracas(10);
239 //---------------------------------------------------------------------------
240 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
242 vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
244 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
245 imageViewer->GetRenderer()->DisplayToWorld();
247 imageViewer->GetRenderer()->GetWorldPoint( fP );
256 ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
262 //---------------------------------------------------------------------------
263 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
265 _wxvtkbaseview = wxvtkbaseview;
267 //---------------------------------------------------------------------------
269 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
271 return (wxVtk2DBaseView*)_wxvtkbaseview;
273 //---------------------------------------------------------------------------
274 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
276 return (wxVtk3DBaseView*)_wxvtkbaseview;
278 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
280 return _wxvtkbaseview;
282 //---------------------------------------------------------------------------
283 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
285 return _wxvtkbaseview;
287 //---------------------------------------------------------------------------
288 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
290 InteractorStyleMaracas *intStyMar;
291 int i,size=_lstInteractorStyleMaracas.size();
294 intStyMar = _lstInteractorStyleMaracas[i];
295 intStyMar->SetActive(ok);
299 //---------------------------------------------------------------------------
300 void vtkInteractorStyleBaseView::SetRefresh_waiting()
302 _refresh_waiting=true;
304 //---------------------------------------------------------------------------
305 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
307 return _refresh_waiting;
309 //---------------------------------------------------------------------------
310 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
312 _parent_refresh_waiting=true;
314 //---------------------------------------------------------------------------
315 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
317 return _parent_refresh_waiting;
319 //---------------------------------------------------------------------------
320 void vtkInteractorStyleBaseView::EvaluateToRefresh()
323 if ( _blockRefresh==false )
325 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
327 _refresh_waiting = false;
328 this->_wxvtkbaseview->Refresh();
330 if (_parent_refresh_waiting==true)
332 _parent_refresh_waiting = false;
333 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
334 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
338 //---------------------------------------------------------------------------
339 void vtkInteractorStyleBaseView::BlockRefresh()
343 //---------------------------------------------------------------------------
344 void vtkInteractorStyleBaseView::UnBlockRefresh()