X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxVtkMPR3DView.cxx;h=e67cc22c0b5b7b4898c38685eaf9de4657c8f699;hb=60238e95450685ecb14f7e6d77247fa9e15b7441;hp=72acc37357cecda89316bb71e61249e69fda0da9;hpb=543dfcbe8f5ff78bbed90ef1e20c722bfa0ef248;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx index 72acc37..e67cc22 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx @@ -1,3 +1,28 @@ +/*# --------------------------------------------------------------------- +# +# 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 "wxVtkMPR3DView.h" #include "vtkDataSetMapper.h" @@ -17,10 +42,6 @@ #include "vtkInteractorStyleBaseView.h" #include -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - //---------------------------------------------------------------------------- @@ -31,7 +52,7 @@ class vtkWindowLevelImagePlaneWidgetCallback : public vtkCommand public: static vtkWindowLevelImagePlaneWidgetCallback *New() { - return new vtkWindowLevelImagePlaneWidgetCallback; + return new vtkWindowLevelImagePlaneWidgetCallback; } void Execute( vtkObject *caller, unsigned long ev, void *callData ) @@ -159,44 +180,7 @@ void wxVtkMPR3DView::RemoveActor(vtkActor* actor) _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor); } -//------------------------------------------------------------------- -void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc) -{ - if(ext == NULL){ - _wxvtk3Dbaseview->GetRenderer()->ResetCamera (); - _wxvtk3Dbaseview->GetCamera()->Dolly(2.0); - -//EED 21 mars 2012 FLIP probleme ..PLOP.. - _wxvtk3Dbaseview->GetCamera()->Roll(180); - _wxvtk3Dbaseview->GetCamera()->Yaw(180+30); - _wxvtk3Dbaseview->GetCamera()->Pitch(-22); - - }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]); - - _wxvtk3Dbaseview->GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1); - //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z); - _wxvtk3Dbaseview->GetCamera()->Dolly(1.5); - - } - -} + //------------------------------------------------------------------- void wxVtkMPR3DView::Configure() @@ -217,26 +201,7 @@ void wxVtkMPR3DView::Configure() // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal - // An initial camera view is created. The Dolly() method moves - // the camera towards the FocalPoint, thereby enlarging the image. - _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera()); - this->ResetCamera(); - - - // Set a background color for the renderer and set the size of the - // render window (expressed in pixels). - _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 ); -//EED 23oct2010 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400); - - // Note that when camera movement occurs (as it does in the Dolly() - // method), the clipping planes often need adjusting. Clipping planes - // consist of two planes: near and far along the view direction. The - // near plane clips out objects in front of the plane; the far plane - // clips out objects behind the plane. This way only what is drawn - // between the planes is actually rendered. - _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange(); - - + // vtkPointWidget //if(_myCallback!=NULL){ //_myCallback->Delete(); @@ -317,6 +282,30 @@ void wxVtkMPR3DView::Configure() // PlaneWidget + +// An initial camera view is created. The Dolly() method moves + // the camera towards the FocalPoint, thereby enlarging the image. +// _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera()); + + // Note that when camera movement occurs (as it does in the Dolly() + // method), the clipping planes often need adjusting. Clipping planes + // consist of two planes: near and far along the view direction. The + // near plane clips out objects in front of the plane; the far plane + // clips out objects behind the plane. This way only what is drawn + // between the planes is actually rendered. + +//EED 27/05/2013 +// _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange(); + +//EED 27/05/2013 +// this->ResetCamera(); + _wxvtk3Dbaseview->ResetCamera(); + + // Set a background color for the renderer and set the size of the + // render window (expressed in pixels). + _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 ); +//EED 23oct2010 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400); + } //------------------------------------------------------------------- @@ -398,6 +387,9 @@ vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, //------------------------------------------------------------------- void wxVtkMPR3DView::SetFreePlanesOrtho() { + + + _planeWidgetX->SetPlaneOrientationToXAxes(); _planeWidgetY->SetPlaneOrientationToYAxes(); _planeWidgetZ->SetPlaneOrientationToZAxes(); @@ -411,13 +403,44 @@ void wxVtkMPR3DView::FreePlaneVisible(int plane, bool ok) { if(_planeWidgetX) { - if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn(); - if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn(); - if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn(); + if (ok==true) + { +//EED 21/07/2013 +// 1. Make backup of actors +// 2. Putting out all the actors +// 3. Add vtkImagageActor in first place +// 4. Putting again the originals actors +// 5. Refresh + + // step 1, step 2 + vtkActorCollection *tmpCollection = vtkActorCollection::New(); + vtkActorCollection *collectionActors = _wxvtk3Dbaseview->GetRenderer()->GetActors(); + int i,size=collectionActors->GetNumberOfItems(); + for (i=0; iAddItem ( (vtkActor*)collectionActors->GetItemAsObject(0) ); + _wxvtk3Dbaseview->GetRenderer()->RemoveActor( (vtkProp*)tmpCollection->GetItemAsObject(i) ); + } // for + + // step 3 + if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn(); + if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn(); + if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn(); + + // step 4 + for (i=0; iGetRenderer()->AddActor( (vtkProp*)tmpCollection->GetItemAsObject(i) ); + } // for + tmpCollection->Delete(); + + // step 5 Refresh + _wxvtk3Dbaseview->GetRenderer()->GetRenderWindow()->Render(); + } // if ok if ((plane==1) && (ok==false)) _planeWidgetX->EnabledOff(); if ((plane==2) && (ok==false)) _planeWidgetY->EnabledOff(); if ((plane==3) && (ok==false)) _planeWidgetZ->EnabledOff(); - } + } // if _planeWidgetX } //------------------------------------------------------------------- @@ -555,7 +578,36 @@ void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){ if (visible==false){ _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) ); } else { +//EED 21/07/2013 +// 1. Make backup of actors +// 2. Putting out all the actors +// 3. Add vtkImagageActor in first place +// 4. Putting again the originals actors +// 5. Refresh + + // step 1, step 2 + vtkActorCollection *tmpCollection = vtkActorCollection::New(); + vtkActorCollection *collectionActors = _wxvtk3Dbaseview->GetRenderer()->GetActors(); + int i,size=collectionActors->GetNumberOfItems(); + for (i=0; iAddItem ( (vtkActor*)collectionActors->GetItemAsObject(0) ); + _wxvtk3Dbaseview->GetRenderer()->RemoveActor( (vtkProp*)tmpCollection->GetItemAsObject(i) ); + } // for + + // step 3 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) ); + + // step 4 + for (i=0; iGetRenderer()->AddActor( (vtkProp*)tmpCollection->GetItemAsObject(i) ); + } // for + tmpCollection->Delete(); + + // step 5 Refresh + _wxvtk3Dbaseview->GetRenderer()->GetRenderWindow()->Render(); + } _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible); }