_probe = NULL;
_contourMapper = NULL;
-
+ _planeWidgetX = 0;
+ _planeWidgetY = 0;
+ _planeWidgetZ = 0;
//EED Fev 3 2010
//Free Planes
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::Configure(){
+
+
+ vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
_wxvtk3Dbaseview->Configure();
_wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
//}
vtkmyPWCallback_3DPointWidget *_myCallback = vtkmyPWCallback_3DPointWidget::New();
_myCallback->SetWxVtkMPR3DView(this);
-
- if(_pointWidget!=NULL){
- _pointWidget->Delete();
- }
- _pointWidget = vtkPointWidget::New();
- _myCallback->SetVtkPointWidget(_pointWidget);
- _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
- _pointWidget->AllOff();
- _pointWidget->PlaceWidget();
+ if(imageData){
+ if(_pointWidget==NULL){
+ _pointWidget = vtkPointWidget::New();
+ }
+ _pointWidget->SetInput( imageData );
+ _myCallback->SetVtkPointWidget(_pointWidget);
+ _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _pointWidget->AllOff();
+ _pointWidget->PlaceWidget();
+
+ _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+
+
+ if(_planeWidget==NULL)
+ {
+ _planeWidget = vtkPlaneWidget::New();
+ }
+ _planeWidget->SetInput( imageData );
+
+ _myCallback->SetVtkPlaneWidget(_planeWidget);
+
+ _planeWidget->NormalToXAxisOn();
+ _planeWidget->SetResolution(50);
+ _planeWidget->SetRepresentationToOutline();
+
+ int dim[3];
+
+ imageData->GetDimensions(dim);
+ 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();
+
+ _probe = vtkProbeFilter::New();
+ _probe->SetInput(_vtkplane);
+
+ _contourMapper = vtkPolyDataMapper::New();
+
+ _contourMapper->SetInput( _probe->GetPolyDataOutput() );
+
+ _contourPlaneActor = vtkActor::New();
+ _contourPlaneActor->SetMapper(_contourMapper);
+
+ _contourPlaneActor->VisibilityOff();
+
+ _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+
+ _planeWidget->Off();
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
+
+ }
+
+ _planeWidget->GetPolyData(_vtkplane);
+ _probe->SetSource( imageData );
+ _contourMapper->SetScalarRange( imageData->GetScalarRange() );
+
+
+ ConfigureFreePlanes();
+ }
+
// _pointWidget->SetPosition( x,y,z );
//EED01 29Mars2009
// MACOS probleme vtk-window out of wx-window
// _pointWidget->On();
- _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+
// PlaneWidget
- if(_planeWidget!=NULL)
- {
- _planeWidget->Delete();
- }
- _planeWidget = vtkPlaneWidget::New();
- _myCallback->SetVtkPlaneWidget(_planeWidget);
- _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
- _planeWidget->NormalToXAxisOn();
- _planeWidget->SetResolution(50);
- _planeWidget->SetRepresentationToOutline();
- int dim[3];
- GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
- 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();
-
- _probe = vtkProbeFilter::New();
- _probe->SetInput(_vtkplane);
-
- _contourMapper = vtkPolyDataMapper::New();
-
- _contourMapper->SetInput( _probe->GetPolyDataOutput() );
-
- _contourPlaneActor = vtkActor::New();
- _contourPlaneActor->SetMapper(_contourMapper);
-
- _contourPlaneActor->VisibilityOff();
-
- _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+
+
+
+
+
+
- _planeWidget->Off();
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
- }else{
-
- }
- _planeWidget->GetPolyData(_vtkplane);
- vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- _probe->SetSource( imageData );
- _contourMapper->SetScalarRange( imageData->GetScalarRange() );
- ConfigureFreePlanes();
}
//-------------------------------------------------------------------
planeWidget->EnabledOff();
planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- planeWidget->SetInput( image );
+ 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->GetSpacing(xSpacing, ySpacing, zSpacing);
+ }
- 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')
{
//-------------------------------------------------------------------
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::RefreshView() // virtual
{
double spc[3];
- this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
+ vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+
+ if(image){
+ image->GetSpacing(spc);
+ }else{
+ spc[0] = 0;
+ spc[1] = 0;
+ spc[2] = 0;
+ }
+ //this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
//double nx=1,ny=0,nz=0; // JPRx
Refresh();
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)
//-------------------------------------------------------------------
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();
+ }
}
}