]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView.cxx
v1.0.3 BUG 1404
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkInteractorStyleBaseView.cxx
index 2e059d0576fca389ec4215f4a5ab0bb827a4aaea..012e2d9a46f4e1b65101660a93a4c3636756b6c2 100644 (file)
@@ -17,6 +17,9 @@ vtkInteractorStyleBaseView::vtkInteractorStyleBaseView()
        _refresh_waiting                = false;
        _parent_refresh_waiting = false;
        _blockRefresh                   = false;
+       
+       //EED27Juillet2011
+       SetMouseWheelMotionFactor(0.5);
 }
 //---------------------------------------------------------------------------
 vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView()
@@ -75,11 +78,21 @@ void vtkInteractorStyleBaseView::OnRightDClick()  // virtual
 {
        CallLstInteractorStyleMaracas( 12 );
 }
-//---------------------------------------------------------------------------
-void vtkInteractorStyleBaseView::OnMouseWheel()  // virtual
+
+
+void  vtkInteractorStyleBaseView::OnMouseWheelForward()  // virtual
+{
+       CallLstInteractorStyleMaracas( 15 );
+}
+
+void vtkInteractorStyleBaseView::OnMouseWheelBackward() // virtual
 {
-       CallLstInteractorStyleMaracas( 14 );
+       CallLstInteractorStyleMaracas( 16 );
 }
+
+
+
+
 //---------------------------------------------------------------------------
 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
 {
@@ -99,8 +112,9 @@ void  vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMa
                {
                        _lstInteractorStyleMaracas.erase(iter);
                        removed = true;
+               } else {
+                 iter++;
                }
-               iter++;
        }               
 }
 //---------------------------------------------------------------------------
@@ -130,8 +144,13 @@ void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
 
        for (i=0;i<size;i++)
        {
-               intStyMar = _lstInteractorStyleMaracas[i];
-               if (intStyMar->GetActive()==true){
+               if (i < (int)_lstInteractorStyleMaracas.size() )
+               {
+                       intStyMar = _lstInteractorStyleMaracas[i];
+               } else {
+                       intStyMar=NULL;
+               }
+               if (intStyMar!=NULL && intStyMar->GetActive()==true){
                        if (type ==1)
                        {  // OnRightButtonDown
                                if (intStyMar->OnRightButtonDown()==false)
@@ -209,13 +228,23 @@ void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
                                        i=size;
                                }
                        }
-                       if (type==14)
-                       {  // OnMouseWheel
-                               if (intStyMar->OnMouseWheel()==false)
+                       // 14 ... old OnMouseWheelFordward
+                       if (type==15)
+                       {  // OnMouseWheelForward
+                               if (intStyMar->OnMouseWheelForward()==false)
                                {
                                        i=size;
                                }
                        }
+                       if (type==16)
+                       {  // OnMouseWheelBackward
+                               if (intStyMar->OnMouseWheelBackward()==false)
+                               {
+                                       i=size;
+                               }
+                       }
+                       
+                       
                } // if active
        } // for
 
@@ -230,25 +259,27 @@ void  vtkInteractorStyleBaseView::OnChar()  // virtual
 //---------------------------------------------------------------------------
 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
 {
-    vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
+       if(((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ){
+               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 );
+               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];
-       }
+               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]);
+       // EEDx5
+               ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
 
-       X=fP[0];
-       Y=fP[1];
-       Z=fP[2];
+               X=fP[0];
+               Y=fP[1];
+               Z=fP[2];
+       }
 }
 //---------------------------------------------------------------------------
 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
@@ -322,9 +353,16 @@ void vtkInteractorStyleBaseView::EvaluateToRefresh()
                {
                        _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; i<size; i++)
+                       {       
+                               _lstParentToReport[i]->ProcessEvent(newevent1);
+                       }//for
+               }//if
+       }//if _blockRefresh
 }
 //---------------------------------------------------------------------------
 void vtkInteractorStyleBaseView::BlockRefresh()
@@ -337,3 +375,18 @@ 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);
+}