#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{
_wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
}
}
-void wxVtkMPR3DView::Configure(){
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::Configure(){
_wxvtk3Dbaseview->Configure();
_wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
// PlaneWidget
- if(_planeWidget!=NULL){
+ if(_planeWidget!=NULL)
+ {
_planeWidget->Delete();
}
_planeWidget = vtkPlaneWidget::New();
}
_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)
{
- printf("EED wxVtkMPR3DView::~wxVtkMPR3DView\n");
- VisiblePointWidget( false );
- VisiblePlaneWidget( false );
+ vtkProperty* prop1 = 0;
+ vtkImagePlaneWidget* planeWidget = 0;
+ planeWidget = vtkImagePlaneWidget::New();
+ planeWidget->EnabledOff();
+ planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+ planeWidget->SetInput( image );
+
- if(_pointWidget!=NULL){
- _pointWidget->Delete();
+ 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(_vtkplane!=NULL){
- _vtkplane->Delete();
- _probe->Delete();
- _contourMapper->Delete();
- _contourPlaneActor->Delete();
+
+ 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;
+}
+//-------------------------------------------------------------------
+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::setColorTransferFunction(vtkColorTransferFunction* colortable){
+
+//-------------------------------------------------------------------
+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);
}
+
//-------------------------------------------------------------------
void wxVtkMPR3DView::Refresh() // virtual
{
}
}
+
//-------------------------------------------------------------------
void wxVtkMPR3DView::RefreshView() // virtual
{