X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxVtk3DBaseView.cxx;h=7a158603a8551078b2d98d63d71fbe8936833711;hb=b90d2dce776b27c95bd59251ee83d10a42b0cae5;hp=94fe0f7e575d330549851e1d5e73d4d7bf56c42f;hpb=9e16e29818047ef5e7f4cd8031a61cc09e8efc3b;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx index 94fe0f7..7a15860 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx @@ -1,11 +1,39 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + #include "wxVtk3DBaseView.h" #include "vtkInteractorStyleBaseView3D.h" - -wxVtk3DBaseView::wxVtk3DBaseView(wxWindow *parent) +#ifdef _DEBUG +#define new DEBUG_NEW +#endif +wxVtk3DBaseView::wxVtk3DBaseView(wxWindow *parent, vtkBaseData* vtkbasedata) :wxVtkBaseView( parent ) { + SetVtkBaseData( vtkbasedata ); _configure = false; _aRenderer = NULL; _renWin = NULL; @@ -14,11 +42,15 @@ wxVtk3DBaseView::wxVtk3DBaseView(wxWindow *parent) //------------------------------------------------------------------- wxVtk3DBaseView::~wxVtk3DBaseView() { - if (_aCamera!=NULL) { _aCamera -> Delete(); _aCamera=NULL;} + + if (_aCamera!=NULL) { _aCamera -> Delete(); _aCamera=NULL;} if (_aRenderer!=NULL) { _aRenderer -> Delete(); _aRenderer=NULL;} - if (_renWin!=NULL) { - if(_renWin->GetReferenceCount()==0){ - _renWin -> Delete(); _renWin=NULL; + if (_renWin!=NULL) + { + if(_renWin->GetReferenceCount()==0) + { + _renWin->Delete(); + _renWin=NULL; } } } @@ -44,6 +76,75 @@ void wxVtk3DBaseView::Refresh() vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor(); vri->vtkRenderWindowInteractor::Render(); } + +//------------------------------------------------------------------- +// EED 27/05/2013 +void wxVtk3DBaseView::ResetCamera(int* ext, double* spc) +{ + + GetRenderer()->ResetCameraClippingRange(); + + if(ext == NULL) + { + + GetRenderer()->ResetCamera (); + GetCamera()->Dolly(1.2); + }else{ + + /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0)); + double y = (spc[1])*(origin[1]+(double)ext[3]); + double z = (spc[2])*(origin[2]+(((double)ext[5]-(double)ext[4])/2.0));*/ + /*double x0=(spc[0])*((double)ext[0]+origin[0]); + double x1=(spc[0])*((double)ext[1]+origin[0]); + double y0=(spc[1])*((double)ext[2]+origin[1]); + double y1=(spc[1])*((double)ext[3]+origin[1]); + double z0=(spc[2])*((double)ext[4]+origin[2]); + double z1=(spc[2])*((double)ext[5]+origin[2]);*/ + + double x0=(spc[0])*((double)ext[0]); + double x1=(spc[0])*((double)ext[1]); + double y0=(spc[1])*((double)ext[2]); + double y1=(spc[1])*((double)ext[3]); + double z0=(spc[2])*((double)ext[4]); + double z1=(spc[2])*((double)ext[5]); + + GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1); + //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z); + GetCamera()->Dolly(1.5); + } +} + +//------------------------------------------------------------------- +void wxVtk3DBaseView::SetStereo(int type) +{ + //EED 02/06/2012 + + if (_renWin!=NULL) + { + if (type==0) + { + _renWin->SetStereoRender(0); // OFF + } else { + _renWin->SetStereoRender(1); // ON + _renWin->SetStereoCapableWindow(1); + _renWin->SetAnaglyphColorMask(4,3); + _renWin->SetAnaglyphColorSaturation(0.65); + + // VTK_STEREO_CRYSTAL_EYES 1 + // VTK_STEREO_RED_BLUE 2 + // VTK_STEREO_INTERLACED 3 + // VTK_STEREO_LEFT 4 + // VTK_STEREO_RIGHT 5 + // VTK_STEREO_DRESDEN 6 + // VTK_STEREO_ANAGLYPH 7 + // VTK_STEREO_CHECKERBOARD 8 + _renWin->SetStereoType(type); + + } // if type + } // _renWin +} + + //------------------------------------------------------------------- void wxVtk3DBaseView::Configure() { @@ -58,18 +159,17 @@ void wxVtk3DBaseView::Configure() _aRenderer->GradientBackgroundOn(); _aRenderer->SetBackground( 0.33 , 0.33 , 0.33 ); _aRenderer->SetBackground2( 0.66 , 0.66 , 0.66 ); + + + +// _aRenderer->GradientBackgroundOff(); +// _aRenderer->SetBackground(0,0,0 ); + + SetStereo(0); -// _renWin->SetStereoCapableWindow(1); -// // //renderwindow->SetStereoTypeToCrystalEyes(); -// _renWin->SetStereoTypeToRedBlue(); -// _renWin->SetStereoRender(1); - GetWxVTKRenderWindowInteractor()->SetRenderWindow(_renWin); - -// EED Borrame -// vtkInteractorStyle3DMaracas *interactorStyle3DMaracas = vtkInteractorStyle3DMaracas::New(); vtkInteractorStyleBaseView3D *interactorStyleBaseView3D = vtkInteractorStyleBaseView3D::New(); SetInteractorStyleBaseView( interactorStyleBaseView3D ); @@ -77,12 +177,6 @@ void wxVtk3DBaseView::Configure() GetWxVTKRenderWindowInteractor()->SetInteractorStyle( interactorStyleBaseView3D ); interactorStyleBaseView3D->SetwxVtkBaseView(this); - -/* EED Borrame - vtkInteractorStyleSwitch *iss = dynamic_cast(_iren->GetInteractorStyle()); - iss->SetCurrentStyleToTrackballCamera(); -*/ - // It is convenient to create an initial view of the data. The // FocalPoint and Position form a vector direction. Later on // (ResetCamera() method) this vector is used to position the camera @@ -100,8 +194,17 @@ void wxVtk3DBaseView::Configure() _aCamera->SetFocalPoint (0, 0, 0); _aCamera->ComputeViewPlaneNormal(); +//EED 27/05/2013 + GetRenderer()->SetActiveCamera(GetCamera()); + +//EED 21 mars 2012 FLIP probleme ..PLOP.. +//EED 13 may 2013 FLIP probleme ..PLOP.. + GetCamera()->Roll(180); + GetCamera()->Yaw(180+30); + GetCamera()->Pitch(-22); } } + //------------------------------------------------------------------- //EED 27 sep 2006 void wxVtk3DBaseView::GetSpacing(double spc[3])