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);
106 //---------------------------------------------------------------------------
107 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
109 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
110 _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
112 //---------------------------------------------------------------------------
113 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
116 InteractorStyleMaracas *intStyMar;
118 int i,size=_lstInteractorStyleMaracas.size();
121 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
122 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
123 //for (i=0;i<size;i++)
125 //fprintf(ff," %p\n" , _lstInteractorStyleMaracas[i] );
133 intStyMar = _lstInteractorStyleMaracas[i];
134 if (intStyMar->GetActive()==true){
136 { // OnRightButtonDown
137 if (intStyMar->OnRightButtonDown()==false)
144 if (intStyMar->OnRightButtonUp()==false)
151 if (intStyMar->OnMouseMove()==false)
157 { // OnLeftButtonDown
158 if (intStyMar->OnLeftButtonDown()==false)
165 if (intStyMar->OnLeftButtonUp()==false)
171 { // OnMiddleButtonDown
172 if (intStyMar->OnMiddleButtonDown()==false)
178 { // OnMiddleButtonUp
179 if (intStyMar->OnMiddleButtonUp()==false)
185 { // OnMiddleButtonUp
186 if (intStyMar->OnChar()==false)
193 if (intStyMar->OnLeftDClick()==false)
200 if (intStyMar->OnRightDClick()==false)
207 if (intStyMar-> OnMiddleDClick()==false)
214 if (intStyMar->OnMouseWheel()==false)
224 //---------------------------------------------------------------------------
225 void vtkInteractorStyleBaseView::OnChar() // virtual
227 // char a=GetInteractor()->GetKeyCode();
228 CallLstInteractorStyleMaracas(10);
230 //---------------------------------------------------------------------------
231 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
233 vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
235 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
236 imageViewer->GetRenderer()->DisplayToWorld();
238 imageViewer->GetRenderer()->GetWorldPoint( fP );
247 ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
253 //---------------------------------------------------------------------------
254 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
256 _wxvtkbaseview = wxvtkbaseview;
258 //---------------------------------------------------------------------------
260 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
262 return (wxVtk2DBaseView*)_wxvtkbaseview;
264 //---------------------------------------------------------------------------
265 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
267 return (wxVtk3DBaseView*)_wxvtkbaseview;
269 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
271 return _wxvtkbaseview;
273 //---------------------------------------------------------------------------
274 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
276 return _wxvtkbaseview;
278 //---------------------------------------------------------------------------
279 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
281 InteractorStyleMaracas *intStyMar;
282 int i,size=_lstInteractorStyleMaracas.size();
285 intStyMar = _lstInteractorStyleMaracas[i];
286 intStyMar->SetActive(ok);
290 //---------------------------------------------------------------------------
291 void vtkInteractorStyleBaseView::SetRefresh_waiting()
293 _refresh_waiting=true;
295 //---------------------------------------------------------------------------
296 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
298 return _refresh_waiting;
300 //---------------------------------------------------------------------------
301 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
303 _parent_refresh_waiting=true;
305 //---------------------------------------------------------------------------
306 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
308 return _parent_refresh_waiting;
310 //---------------------------------------------------------------------------
311 void vtkInteractorStyleBaseView::EvaluateToRefresh()
314 if ( _blockRefresh==false )
316 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
318 _refresh_waiting = false;
319 this->_wxvtkbaseview->Refresh();
321 if (_parent_refresh_waiting==true)
323 _parent_refresh_waiting = false;
324 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
325 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
329 //---------------------------------------------------------------------------
330 void vtkInteractorStyleBaseView::BlockRefresh()
334 //---------------------------------------------------------------------------
335 void vtkInteractorStyleBaseView::UnBlockRefresh()