#include "vtkInteractorStyleBaseView.h" #include "wxVtk3DBaseView.h" #include "wxVtk2DBaseView.h" #include "vtkObjectFactory.h" #include "InteractorStyleMaracas.h" vtkStandardNewMacro(vtkInteractorStyleBaseView); //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- vtkInteractorStyleBaseView::vtkInteractorStyleBaseView() { _refresh_waiting = false; _parent_refresh_waiting = false; _blockRefresh = false; } //--------------------------------------------------------------------------- vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView() { } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnMouseMove() // virtual { CallLstInteractorStyleMaracas(3); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnLeftButtonDown() // virtual { CallLstInteractorStyleMaracas(4); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnLeftButtonUp() // virtual { CallLstInteractorStyleMaracas(5); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnLeftDClick() // virtual { CallLstInteractorStyleMaracas( 11 ); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnMiddleButtonDown() // virtual { CallLstInteractorStyleMaracas(6); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnMiddleButtonUp() // virtual { CallLstInteractorStyleMaracas(7); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnMiddleDClick() // virtual { CallLstInteractorStyleMaracas( 13 ); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnRightButtonDown() // virtual { CallLstInteractorStyleMaracas(1); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnRightButtonUp() // virtual { CallLstInteractorStyleMaracas(2); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnRightDClick() // virtual { CallLstInteractorStyleMaracas( 12 ); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnMouseWheel() // virtual { CallLstInteractorStyleMaracas( 14 ); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas) { interactorStyleMaracas->SetVtkInteractorStyleBaseView(this); _lstInteractorStyleMaracas.push_back(interactorStyleMaracas); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas) { interactorStyleMaracas->RemoveVtkInteractorStyleBaseView(); int i, size = _lstInteractorStyleMaracas.size(); std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin(); bool removed = false; for (i=0; !removed && iSetVtkInteractorStyleBaseView(this); _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type) { InteractorStyleMaracas *intStyMar; int i,size=_lstInteractorStyleMaracas.size(); //EED Borrame //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+"); //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" ); //for (i=0;iGetActive()==true){ if (type ==1) { // OnRightButtonDown if (intStyMar->OnRightButtonDown()==false) { i=size; } } if (type ==2) { // OnRightButtonUp if (intStyMar->OnRightButtonUp()==false) { i=size; } } if (type==3) { // OnMouseMouve if (intStyMar->OnMouseMove()==false) { i=size; } } if (type==4) { // OnLeftButtonDown if (intStyMar->OnLeftButtonDown()==false) { i=size; } } if (type==5) { // OnLeftButtonUp if (intStyMar->OnLeftButtonUp()==false) { i=size; } } if (type==6) { // OnMiddleButtonDown if (intStyMar->OnMiddleButtonDown()==false) { i=size; } } if (type==7) { // OnMiddleButtonUp if (intStyMar->OnMiddleButtonUp()==false) { i=size; } } if (type==10) { // OnMiddleButtonUp if (intStyMar->OnChar()==false) { i=size; } } if (type==11) { // OnLeftDClick if (intStyMar->OnLeftDClick()==false) { i=size; } } if (type==12) { // OnRightDClick if (intStyMar->OnRightDClick()==false) { i=size; } } if (type==13) { // OnMiddleDClick if (intStyMar-> OnMiddleDClick()==false) { i=size; } } if (type==14) { // OnMouseWheel if (intStyMar->OnMouseWheel()==false) { i=size; } } } // if active } // for EvaluateToRefresh(); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::OnChar() // virtual { // char a=GetInteractor()->GetKeyCode(); CallLstInteractorStyleMaracas(10); } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z) { vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2(); imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z); imageViewer->GetRenderer()->DisplayToWorld(); double fP[4]; imageViewer->GetRenderer()->GetWorldPoint( fP ); if ( fP[3] ){ fP[0] /= fP[3]; fP[1] /= fP[3]; fP[2] /= fP[3]; } // EEDx5 ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]); X=fP[0]; Y=fP[1]; Z=fP[2]; } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview) { _wxvtkbaseview = wxvtkbaseview; } //--------------------------------------------------------------------------- /*JCP 13/05/2009 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView() { return (wxVtk2DBaseView*)_wxvtkbaseview; } //--------------------------------------------------------------------------- wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView() { return (wxVtk3DBaseView*)_wxvtkbaseview; }JCP 13/05/2009*/ wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView() { return _wxvtkbaseview; } //--------------------------------------------------------------------------- wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView() { return _wxvtkbaseview; } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok) { InteractorStyleMaracas *intStyMar; int i,size=_lstInteractorStyleMaracas.size(); for (i=0;iSetActive(ok); } } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::SetRefresh_waiting() { _refresh_waiting=true; } //--------------------------------------------------------------------------- bool vtkInteractorStyleBaseView::GetRefresh_waiting() { return _refresh_waiting; } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::SetParent_refresh_waiting() { _parent_refresh_waiting=true; } //--------------------------------------------------------------------------- bool vtkInteractorStyleBaseView::GetParent_refresh_waiting() { return _parent_refresh_waiting; } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::EvaluateToRefresh() { if ( _blockRefresh==false ) { if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false)) { _refresh_waiting = false; this->_wxvtkbaseview->Refresh(); } if (_parent_refresh_waiting==true) { _parent_refresh_waiting = false; wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh //CPR 13/01/2010 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1); int i; int size = _lstParentToReport.size(); for(i = 0; iProcessEvent(newevent1); }//for }//if }//if _blockRefresh } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::BlockRefresh() { _blockRefresh=true; } //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::UnBlockRefresh() { _blockRefresh=false; } wxEvtHandler* vtkInteractorStyleBaseView::GetParentToReport(int i) { wxEvtHandler* parentToReport = NULL; if(i>=0 && i<_lstParentToReport.size()) { parentToReport = _lstParentToReport[i]; } return parentToReport; } void vtkInteractorStyleBaseView::AddParentToReport(wxEvtHandler* parentToReport) { _lstParentToReport.push_back(parentToReport); }