X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxVtkMPR3DView.cxx;h=e740c60db0b54851abceeaad79c2adbed82edaec;hb=0e9c6cea471e235717da5cac8b924254ed3f4f75;hp=a094c266bcc871a8457c4f41b461ef5e0ef9c049;hpb=84b5725a8c5c34c86a82f132c6dc3a2756bfc999;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx index a094c26..e740c60 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx @@ -13,28 +13,59 @@ #include "vtkCutter.h" #include "vtkTransform.h" #include "vtkmyPWCallback_3DPointWidget.h" +#include "vtkProperty.h" +#include "vtkCellPicker.h" wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview ) { _wxvtk3Dbaseview = wxvtk3Dbaseview; _vtkmpr3Ddataviewer = NULL; _wxvtkmpr3DviewCntrlPanel = NULL; - //_myCallback=NULL; - _pointWidget=NULL; - _planeWidget=NULL; - _vtkplane=NULL; - _probe=NULL; - _contourMapper=NULL; + //_myCallback = NULL; + _pointWidget = NULL; + _planeWidget = NULL; + _vtkplane = NULL; + _probe = NULL; + _contourMapper = NULL; + + + //EED Fev 3 2010 + //Free Planes } -void wxVtkMPR3DView::RemoveActor(vtkActor* actor){ - _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor); +//------------------------------------------------------------------- +wxVtkMPR3DView::~wxVtkMPR3DView() +{ + VisiblePointWidget( false ); + VisiblePlaneWidget( false ); + + if(_pointWidget!=NULL){ + _pointWidget->Delete(); + } + if(_planeWidget!=NULL){ + _planeWidget->Delete(); + } + + if(_vtkplane!=NULL){ + _vtkplane->Delete(); + _probe->Delete(); + _contourMapper->Delete(); + _contourPlaneActor->Delete(); + } + +} +//------------------------------------------------------------------- +void wxVtkMPR3DView::RemoveActor(vtkActor* actor) +{ + _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor); } -void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){ - if(ext == NULL){ +//------------------------------------------------------------------- +void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc) +{ + if(ext == NULL){ _wxvtk3Dbaseview->GetRenderer()->ResetCamera (); _wxvtk3Dbaseview->GetCamera()->Dolly(1.5); }else{ @@ -59,8 +90,9 @@ void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){ _wxvtk3Dbaseview->GetCamera()->Dolly(1.5); } } -void wxVtkMPR3DView::Configure(){ +//------------------------------------------------------------------- +void wxVtkMPR3DView::Configure(){ _wxvtk3Dbaseview->Configure(); _wxvtkmpr3DviewCntrlPanel->UpdateControlPanel(); @@ -125,7 +157,8 @@ void wxVtkMPR3DView::Configure(){ // PlaneWidget - if(_planeWidget!=NULL){ + if(_planeWidget!=NULL) + { _planeWidget->Delete(); } _planeWidget = vtkPlaneWidget::New(); @@ -168,35 +201,109 @@ void wxVtkMPR3DView::Configure(){ } _planeWidget->GetPolyData(_vtkplane); - - vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); _probe->SetSource( imageData ); - - _contourMapper->SetScalarRange( imageData->GetScalarRange() ); - + ConfigureFreePlanes(); +} + +//------------------------------------------------------------------- +void wxVtkMPR3DView::ConfigureFreePlanes() +{ + + // The shared picker enables us to use 3 planes at one time + // and gets the picking order right + vtkCellPicker* picker = vtkCellPicker::New(); + picker->SetTolerance(0.005); - + // The 3 image plane widgets + _planeWidgetX = GetPlaneWidget('x', 1, 0, 0, picker); + _planeWidgetY = GetPlaneWidget('y', 1, 1, 0, picker); + _planeWidgetZ = GetPlaneWidget('z', 0, 0, 1, picker); + + _planeWidgetY->SetLookupTable(_planeWidgetX->GetLookupTable()); + _planeWidgetZ->SetLookupTable(_planeWidgetX->GetLookupTable()); + + picker->UnRegister(NULL); + } + //------------------------------------------------------------------- -wxVtkMPR3DView::~wxVtkMPR3DView() +vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker) { - if(_pointWidget!=NULL){ - _pointWidget->Delete(); + vtkProperty* prop1 = 0; + vtkImagePlaneWidget* planeWidget = 0; + planeWidget = vtkImagePlaneWidget::New(); + planeWidget->EnabledOff(); + planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() ); + vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); + planeWidget->SetInput( image ); + + + int xMin, xMax, yMin, yMax, zMin, zMax; + image->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax); + double xSpacing, ySpacing, zSpacing; + image->GetSpacing(xSpacing, ySpacing, zSpacing); + + if (activationkey=='x') + { + planeWidget->SetPlaneOrientationToXAxes(); + planeWidget->SetSlicePosition((xMax+xMin)/2.*xSpacing); } - if(_planeWidget!=NULL){ - _planeWidget->Delete(); + + if (activationkey=='y') + { + planeWidget->SetPlaneOrientationToYAxes(); + planeWidget->SetSlicePosition((yMax+yMin)/2.*ySpacing); } + + if (activationkey=='z') + { + planeWidget->SetPlaneOrientationToZAxes(); + planeWidget->SetSlicePosition((zMax+zMin)/2.*zSpacing); + } + + planeWidget->DisplayTextOn(); + planeWidget->SetPicker(picker); + planeWidget->SetKeyPressActivationValue(activationkey); + prop1 = planeWidget->GetPlaneProperty(); + prop1->SetColor(r, g, b); + return planeWidget; +} - if(_vtkplane!=NULL){ - _vtkplane->Delete(); - _probe->Delete(); - _contourMapper->Delete(); - _contourPlaneActor->Delete(); +//------------------------------------------------------------------- +void wxVtkMPR3DView::FreePlaneVisible(int plane, bool ok) +{ + + if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn(); + if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn(); + if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn(); + if ((plane==1) && (ok==false)) _planeWidgetX->EnabledOff(); + if ((plane==2) && (ok==false)) _planeWidgetY->EnabledOff(); + if ((plane==3) && (ok==false)) _planeWidgetZ->EnabledOff(); +} + +//------------------------------------------------------------------- +void wxVtkMPR3DView::FreePlaneInteraction(bool ok) +{ + if (ok==true) + { + _planeWidgetX->InteractionOn(); + _planeWidgetY->InteractionOn(); + _planeWidgetZ->InteractionOn(); + } else { + _planeWidgetX->InteractionOff(); + _planeWidgetY->InteractionOff(); + _planeWidgetZ->InteractionOff(); } +} + +//------------------------------------------------------------------- +void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortable) +{ + GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable); } //------------------------------------------------------------------- @@ -209,6 +316,7 @@ void wxVtkMPR3DView::Refresh() // virtual } } + //------------------------------------------------------------------- void wxVtkMPR3DView::RefreshView() // virtual { @@ -241,9 +349,9 @@ void wxVtkMPR3DView::RefreshView() // virtual _planeWidget->GetPolyData(_vtkplane); } //------------------------------------------------------------------- -wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent) +wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent, bool align) { - _wxvtkmpr3DviewCntrlPanel = new wxVtkMPR3DViewCntrlPanel(parent,this); + _wxvtkmpr3DviewCntrlPanel = new wxVtkMPR3DViewCntrlPanel(parent,this, align); return _wxvtkmpr3DviewCntrlPanel; } //------------------------------------------------------------------- @@ -263,6 +371,14 @@ wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*) //------------------------------------------------------------------- void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){ + /*if(visible == false) + printf("CPR: wxVtkMPR3DView::VisibleImageActor-> visibleActor == false \n"); + else + { + printf("CPR: wxVtkMPR3DView::VisibleImageActor-> visibleActor == true\n"); + printf("CPR: wxVtkMPR3DView::VisibleImageActor-> idPosition == %d\n", idPosition); + } + */ if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){ if (visible==false){ _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) ); @@ -299,6 +415,20 @@ void wxVtkMPR3DView::VisiblePlaneWidget( bool visible ) } } +//CPR: Method added 30 Nov 2009 +void wxVtkMPR3DView::showOutlineActor(bool value) +{ + vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor(); + if(value == true) + { + _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor ); + } + else + { + _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _outlineActor ); + } +} + //------------------------------------------------------------------- void wxVtkMPR3DView::SetVtkMPR3DDataViewer(vtkMPR3DDataViewer *vtkmpr3Ddataviewer) { @@ -503,4 +633,5 @@ void wxVtkMPR3DView::TestLoic2() iren->Start(); -} \ No newline at end of file +} +