]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx
changes in viewers
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkMPR3DView.cxx
index e406380814b179a5794fffd504f142716790fcd9..67ecb3fe665ddf113d04ce5dda2cd3023a08ae94 100644 (file)
@@ -28,7 +28,9 @@ wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
        _probe                                          =       NULL;
        _contourMapper                          =       NULL;
        
-       
+       _planeWidgetX = 0;
+       _planeWidgetY = 0;
+       _planeWidgetZ = 0;
        //EED Fev 3 2010
        //Free Planes 
 }
@@ -138,88 +140,92 @@ void wxVtkMPR3DView::Configure(){
        //}
        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){
-               _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);
-
-
-// PlaneWidget
-       if(_planeWidget!=NULL)
-       {
-               _planeWidget->Delete();
-       }
-       _planeWidget = vtkPlaneWidget::New();
-       _myCallback->SetVtkPlaneWidget(_planeWidget);
        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 );
-       }
-       _planeWidget->NormalToXAxisOn();
-       _planeWidget->SetResolution(50);
-       _planeWidget->SetRepresentationToOutline();
-       int dim[3];
-       if(imageData){
-               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 );
-
-
-       if(_vtkplane==NULL){
-               _vtkplane = vtkPolyData::New();
                
-               _probe = vtkProbeFilter::New();
-               _probe->SetInput(_vtkplane);
+               _myCallback->SetVtkPlaneWidget(_planeWidget);
 
-               _contourMapper = vtkPolyDataMapper::New();
+               _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 );
                
-               _contourMapper->SetInput( _probe->GetPolyDataOutput() );
+               if(_vtkplane==NULL){
+                       _vtkplane = vtkPolyData::New();
+                       
+                       _probe = vtkProbeFilter::New();
+                       _probe->SetInput(_vtkplane);
 
-               _contourPlaneActor = vtkActor::New();
-               _contourPlaneActor->SetMapper(_contourMapper);
+                       _contourMapper = vtkPolyDataMapper::New();
+                       
+                       _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
+       
+       
+       
+       
+       
+       
+
+
+       
 }
 
 //-------------------------------------------------------------------
@@ -294,27 +300,30 @@ vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char 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();
+               }
        }
 }
 
@@ -361,20 +370,22 @@ void wxVtkMPR3DView::RefreshView()   // virtual
        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)
@@ -421,25 +432,29 @@ void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool 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();
+               }
        }
 }