]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkMPR3DView.cxx
index 67ecb3fe665ddf113d04ce5dda2cd3023a08ae94..319e00c1c693fb292a22b196a0f14b3254932423 100644 (file)
@@ -20,19 +20,19 @@ 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
 }
 
 
@@ -41,37 +41,37 @@ wxVtkMPR3DView::~wxVtkMPR3DView()
 {
        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]);
@@ -86,47 +86,46 @@ void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc)
                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.
@@ -140,50 +139,49 @@ void wxVtkMPR3DView::Configure(){
        //}
        vtkmyPWCallback_3DPointWidget *_myCallback = vtkmyPWCallback_3DPointWidget::New();
        _myCallback->SetWxVtkMPR3DView(this);
-       
-       
+
+
        if(imageData){
                if(_pointWidget==NULL){
                        _pointWidget = vtkPointWidget::New();
                }
                _pointWidget->SetInput( imageData );
                _myCallback->SetVtkPointWidget(_pointWidget);
-               _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() ); 
+               _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();
@@ -195,37 +193,26 @@ void wxVtkMPR3DView::Configure(){
                        _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
 
                        _planeWidget->Off();
-                       _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );        
+                       _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
 
                }
 
                _planeWidget->GetPolyData(_vtkplane);
                _probe->SetSource( imageData );
                _contourMapper->SetScalarRange( imageData->GetScalarRange() );
-               
-               
+
+
                ConfigureFreePlanes();
        }
-       
-//     _pointWidget->SetPosition( x,y,z ); 
-       
+
+//     _pointWidget->SetPosition( x,y,z );
+
 //EED01 29Mars2009
-// MACOS probleme vtk-window out of wx-window  
+// MACOS probleme vtk-window out of wx-window
 //     _pointWidget->On();
-       
-       
-
 
 // PlaneWidget
-       
-       
-       
-       
-       
-       
 
-
-       
 }
 
 //-------------------------------------------------------------------
@@ -237,58 +224,53 @@ void wxVtkMPR3DView::ConfigureFreePlanes()
        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);
@@ -331,7 +313,7 @@ void wxVtkMPR3DView::FreePlaneInteraction(bool ok)
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortable)
 {
-       GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable); 
+       GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable);
 }
 
 //-------------------------------------------------------------------
@@ -350,7 +332,7 @@ void wxVtkMPR3DView::RefreshView()   // virtual
 {
        double spc[3];
        vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
-       
+
        if(image){
                image->GetSpacing(spc);
        }else{
@@ -371,10 +353,10 @@ void wxVtkMPR3DView::RefreshView()   // virtual
        z=z*spc[2];
 
        if(_pointWidget){
-               _pointWidget->SetPosition( x,y,z ); 
+               _pointWidget->SetPosition( x,y,z );
 
 
-               double in[3]; 
+               double in[3];
                double normal[3];
                vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
                in[0]=1;                in[1]=0;                        in[2]=0;
@@ -394,9 +376,9 @@ wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent, bool align)
        return _wxvtkmpr3DviewCntrlPanel;
 }
 //-------------------------------------------------------------------
-vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer() 
+vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
 {
-       return _vtkmpr3Ddataviewer; 
+       return _vtkmpr3Ddataviewer;
 }
 //-------------------------------------------------------------------
 wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
@@ -420,9 +402,9 @@ void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
        */
        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);
        }
@@ -464,11 +446,11 @@ void wxVtkMPR3DView::showOutlineActor(bool value)
        vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
        if(value == true)
        {
-               _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );     
+               _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
        }
        else
        {
-               _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _outlineActor );  
+               _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _outlineActor );
        }
 }
 
@@ -481,7 +463,7 @@ void wxVtkMPR3DView::SetVtkMPR3DDataViewer(vtkMPR3DDataViewer *vtkmpr3Ddataviewe
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::InitOrientationPointWidget()
 {
-       this->_planeWidget->SetNormal(1,0,0);           
+       this->_planeWidget->SetNormal(1,0,0);
 }
 
 
@@ -533,7 +515,7 @@ void wxVtkMPR3DView::TestLoic1()
        stPoints -> Update();
 
        vtkImageChangeInformation  *change = vtkImageChangeInformation ::New();
-       change    -> SetInput( stPoints );  
+       change    -> SetInput( stPoints );
        change    -> Update();    //important
 
        double _range[2];
@@ -546,7 +528,7 @@ void wxVtkMPR3DView::TestLoic1()
    _bwlookup->SetValueRange( 0 , 1 );
    _bwlookup->SetAlphaRange( 1 , 1 );
    _bwlookup->Build( );
+
    vtkLookupTable * _collookup = vtkLookupTable::New( );
    _collookup->SetNumberOfColors( 256 );
    _collookup->SetTableRange( 0 , 255 );
@@ -589,7 +571,7 @@ void wxVtkMPR3DView::TestLoic1()
       renderer->SetActiveCamera(camera);
       renderer->ResetCamera();
       renderer->SetBackground(1,1,1);
-  
+
   renWin->SetSize(300,300);
 
   // interact with data
@@ -616,7 +598,7 @@ void wxVtkMPR3DView::TestLoic2()
         vtkPlane *slicePlane = vtkPlane::New();
                                this->_planeWidget->GetPlane( slicePlane );
 
-                
+
         vtkCutter* sliceCutter = vtkCutter::New();
                vtkImageData *vtkimagedata =  this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
                 sliceCutter->SetInput( vtkimagedata );
@@ -645,7 +627,7 @@ void wxVtkMPR3DView::TestLoic2()
                 contourMapper->SetScalarRange( range );
   //              contourMapper->SetLookupTable( lut );
 
-                
+
         vtkActor *contourActor = vtkActor::New();
                 contourActor->SetMapper( contourMapper );
 
@@ -668,7 +650,7 @@ void wxVtkMPR3DView::TestLoic2()
       renderer->SetActiveCamera(camera);
       renderer->ResetCamera();
       renderer->SetBackground(1,1,1);
-  
+
   renWin->SetSize(300,300);
 
   // interact with data