vtkInteractorStyleBaseView.cxx

Go to the documentation of this file.
00001 #include "vtkInteractorStyleBaseView.h"
00002 
00003 #include "wxVtk3DBaseView.h"
00004 #include "wxVtk2DBaseView.h"
00005 
00006 #include "vtkObjectFactory.h"
00007 
00008 #include "InteractorStyleMaracas.h"
00009 
00010 vtkStandardNewMacro(vtkInteractorStyleBaseView);
00011 //---------------------------------------------------------------------------
00012 //---------------------------------------------------------------------------
00013 //---------------------------------------------------------------------------
00014 
00015 vtkInteractorStyleBaseView::vtkInteractorStyleBaseView()
00016 {
00017         _refresh_waiting                = false;
00018         _parent_refresh_waiting = false;
00019         _blockRefresh                   = false;
00020 }
00021 //---------------------------------------------------------------------------
00022 vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView()
00023 {
00024 }
00025 //---------------------------------------------------------------------------
00026 void vtkInteractorStyleBaseView::OnMouseMove() // virtual 
00027 {
00028         CallLstInteractorStyleMaracas(3);
00029 }
00030 //---------------------------------------------------------------------------
00031 void vtkInteractorStyleBaseView::OnLeftButtonDown()  // virtual 
00032 {
00033         CallLstInteractorStyleMaracas(4);
00034 }
00035 //---------------------------------------------------------------------------
00036 void vtkInteractorStyleBaseView::OnLeftButtonUp() // virtual 
00037 {
00038         CallLstInteractorStyleMaracas(5);
00039 }
00040 
00041 //---------------------------------------------------------------------------
00042 void vtkInteractorStyleBaseView::OnLeftDClick()  // virtual
00043 {
00044         CallLstInteractorStyleMaracas( 11 );
00045 }
00046 
00047 //---------------------------------------------------------------------------
00048 void vtkInteractorStyleBaseView::OnMiddleButtonDown()  // virtual 
00049 {
00050         CallLstInteractorStyleMaracas(6);
00051 }
00052 //---------------------------------------------------------------------------
00053 void vtkInteractorStyleBaseView::OnMiddleButtonUp() // virtual 
00054 {
00055         CallLstInteractorStyleMaracas(7);
00056 }
00057 //---------------------------------------------------------------------------
00058 void vtkInteractorStyleBaseView::OnMiddleDClick()  // virtual
00059 {
00060         CallLstInteractorStyleMaracas( 13 );
00061 }
00062 
00063 //---------------------------------------------------------------------------
00064 void vtkInteractorStyleBaseView::OnRightButtonDown() // virtual 
00065 {
00066         CallLstInteractorStyleMaracas(1);
00067 }
00068 //---------------------------------------------------------------------------
00069 void vtkInteractorStyleBaseView::OnRightButtonUp() // virtual 
00070 {
00071         CallLstInteractorStyleMaracas(2);
00072 }
00073 //---------------------------------------------------------------------------
00074 void vtkInteractorStyleBaseView::OnRightDClick()  // virtual
00075 {
00076         CallLstInteractorStyleMaracas( 12 );
00077 }
00078 //---------------------------------------------------------------------------
00079 void vtkInteractorStyleBaseView::OnMouseWheel()  // virtual
00080 {
00081         CallLstInteractorStyleMaracas( 14 );
00082 }
00083 //---------------------------------------------------------------------------
00084 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
00085 {
00086         interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
00087         _lstInteractorStyleMaracas.push_back(interactorStyleMaracas);
00088 }
00089 //---------------------------------------------------------------------------
00090 void  vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
00091 {
00092         interactorStyleMaracas->RemoveVtkInteractorStyleBaseView();
00093         int i, size = _lstInteractorStyleMaracas.size();
00094         std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin();
00095         bool removed = false;
00096         for (i=0; !removed && i<size; i++)
00097         {
00098                 if ( _lstInteractorStyleMaracas[i] == interactorStyleMaracas )
00099                 {
00100                         _lstInteractorStyleMaracas.erase(iter);
00101                         removed = true;
00102                 }
00103                 iter++;
00104         }               
00105 }
00106 //---------------------------------------------------------------------------
00107 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
00108 {
00109         interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
00110         _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
00111 }
00112 //---------------------------------------------------------------------------
00113 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
00114 {
00115 
00116         InteractorStyleMaracas *intStyMar;
00117 
00118         int i,size=_lstInteractorStyleMaracas.size();
00119 
00120 //EED Borrame
00121 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
00122 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
00123 //for (i=0;i<size;i++)
00124 //{
00125 //fprintf(ff,"    %p\n" , _lstInteractorStyleMaracas[i] );
00126 //}
00127 //fclose(ff);
00128 
00129 
00130 
00131         for (i=0;i<size;i++)
00132         {
00133                 intStyMar = _lstInteractorStyleMaracas[i];
00134                 if (intStyMar->GetActive()==true){
00135                         if (type ==1)
00136                         {  // OnRightButtonDown
00137                                 if (intStyMar->OnRightButtonDown()==false)
00138                                 {
00139                                         i=size;
00140                                 }
00141                         }
00142                         if (type ==2)
00143                         {  // OnRightButtonUp
00144                                 if (intStyMar->OnRightButtonUp()==false)
00145                                 {
00146                                         i=size;
00147                                 }
00148                         }
00149                         if (type==3)
00150                         {  // OnMouseMouve
00151                                 if (intStyMar->OnMouseMove()==false)
00152                                 {
00153                                         i=size;
00154                                 }
00155                         }
00156                         if (type==4)
00157                         {  // OnLeftButtonDown
00158                                 if (intStyMar->OnLeftButtonDown()==false)
00159                                 {
00160                                         i=size;
00161                                 }
00162                         }
00163                         if (type==5)
00164                         {  // OnLeftButtonUp
00165                                 if (intStyMar->OnLeftButtonUp()==false)
00166                                 {
00167                                         i=size;
00168                                 }
00169                         }
00170                         if (type==6)
00171                         {  // OnMiddleButtonDown
00172                                 if (intStyMar->OnMiddleButtonDown()==false)
00173                                 {
00174                                         i=size;
00175                                 }
00176                         }
00177                         if (type==7)
00178                         {  // OnMiddleButtonUp
00179                                 if (intStyMar->OnMiddleButtonUp()==false)
00180                                 {
00181                                         i=size;
00182                                 }
00183                         }
00184                         if (type==10)
00185                         {  // OnMiddleButtonUp
00186                                 if (intStyMar->OnChar()==false)
00187                                 {
00188                                         i=size;
00189                                 }
00190                         }
00191                         if (type==11)
00192                         {  // OnLeftDClick
00193                                 if (intStyMar->OnLeftDClick()==false)
00194                                 {
00195                                         i=size;
00196                                 }
00197                         }
00198                         if (type==12)
00199                         {  // OnRightDClick
00200                                 if (intStyMar->OnRightDClick()==false)
00201                                 {
00202                                         i=size;
00203                                 }
00204                         }
00205                         if (type==13)
00206                         {  // OnMiddleDClick
00207                                 if (intStyMar-> OnMiddleDClick()==false)
00208                                 {
00209                                         i=size;
00210                                 }
00211                         }
00212                         if (type==14)
00213                         {  // OnMouseWheel
00214                                 if (intStyMar->OnMouseWheel()==false)
00215                                 {
00216                                         i=size;
00217                                 }
00218                         }
00219                 } // if active
00220         } // for
00221 
00222         EvaluateToRefresh();
00223 }
00224 //---------------------------------------------------------------------------
00225 void  vtkInteractorStyleBaseView::OnChar()  // virtual 
00226 {    
00227 //      char a=GetInteractor()->GetKeyCode();
00228         CallLstInteractorStyleMaracas(10);
00229 }
00230 //---------------------------------------------------------------------------
00231 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
00232 {
00233     vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
00234 
00235         imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
00236         imageViewer->GetRenderer()->DisplayToWorld();
00237         double fP[4];
00238         imageViewer->GetRenderer()->GetWorldPoint( fP );
00239 
00240         if ( fP[3] ){
00241                 fP[0] /= fP[3];
00242                 fP[1] /= fP[3];
00243                 fP[2] /= fP[3];
00244         }
00245 
00246 // EEDx5
00247         ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
00248 
00249         X=fP[0];
00250         Y=fP[1];
00251         Z=fP[2];
00252 }
00253 //---------------------------------------------------------------------------
00254 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
00255 {
00256         _wxvtkbaseview = wxvtkbaseview;
00257 }
00258 //---------------------------------------------------------------------------
00259 /*JCP 13/05/2009
00260 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
00261 {
00262         return (wxVtk2DBaseView*)_wxvtkbaseview;
00263 }
00264 //---------------------------------------------------------------------------
00265 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
00266 {
00267         return (wxVtk3DBaseView*)_wxvtkbaseview;
00268 }JCP 13/05/2009*/
00269 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
00270 {
00271         return _wxvtkbaseview;
00272 }
00273 //---------------------------------------------------------------------------
00274 wxVtkBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
00275 {
00276         return _wxvtkbaseview;
00277 }
00278 //---------------------------------------------------------------------------
00279 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
00280 {
00281         InteractorStyleMaracas *intStyMar;
00282         int i,size=_lstInteractorStyleMaracas.size();
00283         for (i=0;i<size;i++)
00284         {
00285                 intStyMar = _lstInteractorStyleMaracas[i];
00286                 intStyMar->SetActive(ok);
00287         }
00288 
00289 }
00290 //---------------------------------------------------------------------------
00291 void vtkInteractorStyleBaseView::SetRefresh_waiting()
00292 {
00293         _refresh_waiting=true;
00294 }
00295 //---------------------------------------------------------------------------
00296 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
00297 {
00298         return _refresh_waiting;
00299 }
00300 //---------------------------------------------------------------------------
00301 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
00302 {
00303         _parent_refresh_waiting=true;
00304 }
00305 //---------------------------------------------------------------------------
00306 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
00307 {
00308         return _parent_refresh_waiting;
00309 }
00310 //---------------------------------------------------------------------------
00311 void vtkInteractorStyleBaseView::EvaluateToRefresh()
00312 {
00313 
00314         if  ( _blockRefresh==false )
00315         {
00316                 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
00317                 {
00318                         _refresh_waiting                = false;
00319                         this->_wxvtkbaseview->Refresh();
00320                 }
00321                 if (_parent_refresh_waiting==true)
00322                 {
00323                         _parent_refresh_waiting = false;
00324                         wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
00325                         this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00326                 }
00327         }
00328 }
00329 //---------------------------------------------------------------------------
00330 void vtkInteractorStyleBaseView::BlockRefresh()
00331 {
00332         _blockRefresh=true;
00333 }
00334 //---------------------------------------------------------------------------
00335 void vtkInteractorStyleBaseView::UnBlockRefresh()
00336 {
00337         _blockRefresh=false;
00338 }
00339 

Generated on Wed Jul 29 16:35:30 2009 for creaMaracasVisu_lib by  doxygen 1.5.3