#include "vtkProperty.h"
#include "vtkCellPicker.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
{
_wxvtk3Dbaseview = wxvtk3Dbaseview;
_vtkmpr3Ddataviewer = NULL;
- _wxvtkmpr3DviewCntrlPanel = NULL;
+ _wxvtkmpr3DviewCntrlPanel = NULL;
//_myCallback = NULL;
_pointWidget = NULL;
_planeWidget = NULL;
_vtkplane = NULL;
_probe = NULL;
_contourMapper = NULL;
-
-
+
+ _planeWidgetX = 0;
+ _planeWidgetY = 0;
+ _planeWidgetZ = 0;
//EED Fev 3 2010
- //Free Planes
+ //Free Planes
}
{
VisiblePointWidget( false );
VisiblePlaneWidget( false );
-
+
if(_pointWidget!=NULL){
_pointWidget->Delete();
}
if(_planeWidget!=NULL){
_planeWidget->Delete();
}
-
+
if(_vtkplane!=NULL){
- _vtkplane->Delete();
+ _vtkplane->Delete();
_probe->Delete();
- _contourMapper->Delete();
- _contourPlaneActor->Delete();
+ _contourMapper->Delete();
+ _contourPlaneActor->Delete();
}
-
+
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::RemoveActor(vtkActor* actor)
-{
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
+{
+ _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc)
{
if(ext == NULL){
- _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
- _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
+ _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
+ _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
}else{
- /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0));
+ /*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 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);
+ _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
}
}
//-------------------------------------------------------------------
-void wxVtkMPR3DView::Configure(){
-
-
+void wxVtkMPR3DView::Configure()
+{
vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
_wxvtk3Dbaseview->Configure();
_wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
-
-//EED 27 Mai 2009
-// _wxvtk3Dbaseview->GetRenderer()->Clear();
-
- // Actors are added to the renderer.
+
+//EED 27 Mai 2009
+// _wxvtk3Dbaseview->GetRenderer()->Clear();
+
+ // Actors are added to the renderer.
vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
// _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.
+ // 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 );
- _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
+//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
+ // 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.
//}
vtkmyPWCallback_3DPointWidget *_myCallback = vtkmyPWCallback_3DPointWidget::New();
_myCallback->SetWxVtkMPR3DView(this);
-
- if(_pointWidget!=NULL){
- _pointWidget->Delete();
- }
- _pointWidget = vtkPointWidget::New();
- _myCallback->SetVtkPointWidget(_pointWidget);
- _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
-
+
+
if(imageData){
+ if(_pointWidget==NULL){
+ _pointWidget = vtkPointWidget::New();
+ }
_pointWidget->SetInput( imageData );
- }
-
- _pointWidget->AllOff();
-
- _pointWidget->PlaceWidget();
-// _pointWidget->SetPosition( x,y,z );
-
-//EED01 29Mars2009
-// MACOS probleme vtk-window out of wx-window
-// _pointWidget->On();
-
- _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+ _myCallback->SetVtkPointWidget(_pointWidget);
+ _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _pointWidget->AllOff();
+ _pointWidget->PlaceWidget();
+ _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
-// PlaneWidget
- if(_planeWidget!=NULL)
- {
- _planeWidget->Delete();
- }
- _planeWidget = vtkPlaneWidget::New();
- _myCallback->SetVtkPlaneWidget(_planeWidget);
- if(imageData){
+ if(_planeWidget==NULL)
+ {
+ _planeWidget = vtkPlaneWidget::New();
+ }
_planeWidget->SetInput( imageData );
- }
- _planeWidget->NormalToXAxisOn();
- _planeWidget->SetResolution(50);
- _planeWidget->SetRepresentationToOutline();
- int dim[3];
- if(imageData){
+
+ _myCallback->SetVtkPlaneWidget(_planeWidget);
+
+ _planeWidget->NormalToXAxisOn();
+ _planeWidget->SetResolution(50);
+ _planeWidget->SetRepresentationToOutline();
+
+ int dim[3];
+
imageData->GetDimensions(dim);
- }else{
- dim[0] = 0;
- dim[1] = 0;
- dim[2] = 0;
- }
- int px=(dim[0]/2);
- int py=(dim[1]/2);
- int pz=(dim[2]/2);
- int dd=20;
- _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
+ int px=(dim[0]/2);
+ int py=(dim[1]/2);
+ int pz=(dim[2]/2);
+ int dd=20;
+ _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
+ if(_vtkplane==NULL){
+ _vtkplane = vtkPolyData::New();
- if(_vtkplane==NULL){
- _vtkplane = vtkPolyData::New();
-
- _probe = vtkProbeFilter::New();
- _probe->SetInput(_vtkplane);
+ _probe = vtkProbeFilter::New();
+ _probe->SetInput(_vtkplane);
- _contourMapper = vtkPolyDataMapper::New();
-
- _contourMapper->SetInput( _probe->GetPolyDataOutput() );
+ _contourMapper = vtkPolyDataMapper::New();
- _contourPlaneActor = vtkActor::New();
- _contourPlaneActor->SetMapper(_contourMapper);
+ _contourMapper->SetInput( _probe->GetPolyDataOutput() );
- _contourPlaneActor->VisibilityOff();
+ _contourPlaneActor = vtkActor::New();
+ _contourPlaneActor->SetMapper(_contourMapper);
- _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+ _contourPlaneActor->VisibilityOff();
- _planeWidget->Off();
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
+ _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
- }
+ _planeWidget->Off();
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
- _planeWidget->GetPolyData(_vtkplane);
- if(imageData){
+ }
+
+ _planeWidget->GetPolyData(_vtkplane);
_probe->SetSource( imageData );
_contourMapper->SetScalarRange( imageData->GetScalarRange() );
+
+
+ ConfigureFreePlanes();
}
-
- ConfigureFreePlanes();
+
+// _pointWidget->SetPosition( x,y,z );
+
+//EED01 29Mars2009
+// MACOS probleme vtk-window out of wx-window
+// _pointWidget->On();
+
+// PlaneWidget
+
}
//-------------------------------------------------------------------
vtkCellPicker* picker = vtkCellPicker::New();
picker->SetTolerance(0.005);
- // The 3 image plane widgets
+ // 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);
-
+ _planeWidgetZ = GetPlaneWidget('z', 0, 0, 1, picker);
+
_planeWidgetY->SetLookupTable(_planeWidgetX->GetLookupTable());
_planeWidgetZ->SetLookupTable(_planeWidgetX->GetLookupTable());
-
+
picker->UnRegister(NULL);
-
+
}
//-------------------------------------------------------------------
vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker)
{
- vtkProperty* prop1 = 0;
+ vtkProperty* prop1 = 0;
vtkImagePlaneWidget* planeWidget = 0;
planeWidget = vtkImagePlaneWidget::New();
- planeWidget->EnabledOff();
planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ planeWidget->EnabledOff();
vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
int xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0;
double xSpacing = 0, ySpacing = 0, zSpacing = 0;
if(image){
planeWidget->SetInput( image );
- image->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+ image->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
image->GetSpacing(xSpacing, ySpacing, zSpacing);
}
-
-
-
-
-
if (activationkey=='x')
{
- planeWidget->SetPlaneOrientationToXAxes();
+ planeWidget->SetPlaneOrientationToXAxes();
planeWidget->SetSlicePosition((xMax+xMin)/2.*xSpacing);
}
-
+
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);
//-------------------------------------------------------------------
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();
+ if(_planeWidgetX){
+ 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();
+ if(_planeWidgetX){
+ if (ok==true)
+ {
+ _planeWidgetX->InteractionOn();
+ _planeWidgetY->InteractionOn();
+ _planeWidgetZ->InteractionOn();
+ } else {
+ _planeWidgetX->InteractionOff();
+ _planeWidgetY->InteractionOff();
+ _planeWidgetZ->InteractionOff();
+ }
}
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortable)
{
- GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable);
+ GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable);
}
//-------------------------------------------------------------------
{
double spc[3];
vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
-
+
if(image){
image->GetSpacing(spc);
}else{
y=y*spc[1];
z=z*spc[2];
- _pointWidget->SetPosition( x,y,z );
+ if(_pointWidget){
+ _pointWidget->SetPosition( x,y,z );
- double in[3];
- double normal[3];
- vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
- in[0]=1; in[1]=0; in[2]=0;
- transform->TransformPoint(in,normal);
- _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
+ double in[3];
+ double normal[3];
+ vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
+ in[0]=1; in[1]=0; in[2]=0;
+ transform->TransformPoint(in,normal);
+ _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
- _planeWidget->SetCenter( x,y,z );
- _planeWidget->UpdatePlacement();
- _planeWidget->GetPolyData(_vtkplane);
+ _planeWidget->SetCenter( x,y,z );
+ _planeWidget->UpdatePlacement();
+ _planeWidget->GetPolyData(_vtkplane);
+ }
}
//-------------------------------------------------------------------
wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent, bool align)
return _wxvtkmpr3DviewCntrlPanel;
}
//-------------------------------------------------------------------
-vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
+vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
{
- return _vtkmpr3Ddataviewer;
+ return _vtkmpr3Ddataviewer;
}
//-------------------------------------------------------------------
wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
*/
if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
if (visible==false){
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
+ _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
} else {
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
}
_vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::VisiblePointWidget( bool visible )
{
- if (visible==true)
- {
- _pointWidget->On();
- } else {
- _pointWidget->Off();
+ if(_pointWidget){
+ if (visible==true)
+ {
+ _pointWidget->On();
+ } else {
+ _pointWidget->Off();
+ }
}
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
{
- if (visible==true)
- {
- _planeWidget->On();
- _contourPlaneActor->VisibilityOn();
+ if(_planeWidget){
+ if (visible==true)
+ {
+ _planeWidget->On();
+ _contourPlaneActor->VisibilityOn();
- } else {
- _planeWidget->Off();
- _contourPlaneActor->VisibilityOff();
+ } else {
+ _planeWidget->Off();
+ _contourPlaneActor->VisibilityOff();
+ }
}
}
vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
if(value == true)
{
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
}
else
{
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _outlineActor );
+ _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _outlineActor );
}
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::InitOrientationPointWidget()
{
- this->_planeWidget->SetNormal(1,0,0);
+ this->_planeWidget->SetNormal(1,0,0);
}
stPoints -> Update();
vtkImageChangeInformation *change = vtkImageChangeInformation ::New();
- change -> SetInput( stPoints );
+ change -> SetInput( stPoints );
change -> Update(); //important
double _range[2];
_bwlookup->SetValueRange( 0 , 1 );
_bwlookup->SetAlphaRange( 1 , 1 );
_bwlookup->Build( );
-
+
vtkLookupTable * _collookup = vtkLookupTable::New( );
_collookup->SetNumberOfColors( 256 );
_collookup->SetTableRange( 0 , 255 );
renderer->SetActiveCamera(camera);
renderer->ResetCamera();
renderer->SetBackground(1,1,1);
-
+
renWin->SetSize(300,300);
// interact with data
vtkPlane *slicePlane = vtkPlane::New();
this->_planeWidget->GetPlane( slicePlane );
-
+
vtkCutter* sliceCutter = vtkCutter::New();
vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
sliceCutter->SetInput( vtkimagedata );
contourMapper->SetScalarRange( range );
// contourMapper->SetLookupTable( lut );
-
+
vtkActor *contourActor = vtkActor::New();
contourActor->SetMapper( contourMapper );
renderer->SetActiveCamera(camera);
renderer->ResetCamera();
renderer->SetBackground(1,1,1);
-
+
renWin->SetSize(300,300);
// interact with data