]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx
#3219 creaMaracasVisu Feature New Normal - vtk8itk4wx3-mingw64
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkPlane2DView.cxx
index f0cbc97744c4d841c05e21f5150e7aaf0ce4d67c..3c715ae038aa09f20939c2d2a435b0050d3a7a76 100644 (file)
@@ -62,24 +62,22 @@ vtkPlane2DView::vtkPlane2DView( wxWindow *parent)
        _imageResult                    =       NULL;
 
        // line horizontal
-    _pts                       = NULL;
-    _lineActor         = NULL;
-       _lineMapper             = NULL;
-       _pd                             = NULL;
+    _pts                                       =       NULL;
+    _lineActor                         =       NULL;
+       _lineMapper                             =       NULL;
+       _pd                                             =       NULL;
 
-       _interactorstyleplane2D =       false;
+       _interactorstyleplane2D =       NULL;
 }
 //-------------------------------------------------------------------
 vtkPlane2DView::~vtkPlane2DView()
 {
        ResetPlane();
-
        // Horizontal Line
     if (_pts           != NULL)        {       _pts                    -> Delete(); }
     if (_lineActor     != NULL)        {       _lineActor              -> Delete(); }
     if (_lineMapper    != NULL)        {       _lineMapper             -> Delete(); }
     if (_pd                    != NULL)        {       _pd                             -> Delete(); }
-
        _transform1             -> Delete();
        _transform2             -> Delete();
 }
@@ -97,12 +95,14 @@ void vtkPlane2DView::ResetBack()
 }
 
 //-------------------------------------------------------------------
-void vtkPlane2DView::ResetPlane(){
+void vtkPlane2DView::ResetPlane()
+{
        if (_pSource    !=NULL) { _pSource      -> Delete();    }
        if (_3Dslices   !=NULL) { _3Dslices     -> Delete();    }
        if (_stPoints   !=NULL) { _stPoints     -> Delete();    }
        if (_change             !=NULL) { _change       -> Delete();    }
 }
+
 //-------------------------------------------------------------------
 vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata()
 {
@@ -158,7 +158,6 @@ void vtkPlane2DView::SetPSource(int sizeIma){
 //-------------------------------------------------------------------
 void vtkPlane2DView::ExtractPlane() 
 {
-
        double x = GetVtkmprbasedata()->GetX();
        double y = GetVtkmprbasedata()->GetY();
        double z = GetVtkmprbasedata()->GetZ();
@@ -223,48 +222,66 @@ void vtkPlane2DView::ExtractPlane()
 }
 
 //-------------------------------------------------------------------
-
 void vtkPlane2DView::Extract_One_PlaneVTK()
 {
        vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
        SetPSource(_sizeIma);
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        _3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
        _3Dslices -> SetSource( imagedata );
+#else
+       _3Dslices -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) );
+       _3Dslices -> SetSourceData( imagedata );
+#endif
+
        _3Dslices -> Update( );
        _stPoints -> GetPointData( )->SetScalars(  _3Dslices->GetOutput()->GetPointData()->GetScalars()  );
        _stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        _stPoints -> SetScalarType( imagedata->GetScalarType() );
        _stPoints -> SetScalarTypeToShort();
        _stPoints -> Update();
 //     _change   -> SetInput( _stPoints );  
 //     _change   -> Update();    //important
        _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints );
+#else
+printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
+printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
+printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
+printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
+printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
+       vtkInformation* info=_stPoints->GetInformation();
+       vtkDataObject::SetPointDataActiveScalarInfo(info, VTK_SHORT, 1);
+       _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _stPoints );
+
+#endif
+
+
 //     _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() );
        //      vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
 }
 
 //-------------------------------------------------------------------
-
 void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
 {
-
        int mipWidth;
        double sp;
        int sizeWidth = (_mip_width*2)+1 ;
        int deltaPixel;
        int iWidth,itmp,tmpSizeWith;
-
        double spc[3];
        vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
        SetPSource(_sizeIma);
        imagedata->GetSpacing(spc);
-
        bool heightDefinition=false;
        if (_mip_width<3)
        {
                heightDefinition=true;
        }
-
        if (heightDefinition==true)
        {
                mipWidth        =       _mip_width;
@@ -277,49 +294,50 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
                sizeWidth       =       tmpSizeWith;
                deltaPixel      =       4;
        }
-
-
-
        std::vector< vtkProbeFilter* > slicesLST;
-
        _pSource->Push( -mipWidth * sp );
        _pSource->Update();
-
        for ( iWidth=0 ; iWidth<sizeWidth ; iWidth++ )
        {       
                vtkProbeFilter *slice = vtkProbeFilter::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                slice -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
                slice -> SetSource( imagedata );
+#else
+               slice -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) );
+               slice -> SetSourceData( imagedata );
+#endif
                slice -> Update( );
                slicesLST.push_back( slice );
                _pSource->Push( sp );
        }
-       
        if (_imageResult ==NULL)
        {
                _imageResult = vtkImageData::New();
                _imageResult -> SetDimensions(_sizeIma,_sizeIma,1);
                _imageResult -> SetSpacing(1,1,1);
-               _imageResult -> SetScalarType( imagedata->GetScalarType() );
                _imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               _imageResult -> SetScalarType( imagedata->GetScalarType() );
                _imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
                _imageResult -> AllocateScalars();
                _imageResult -> Update();
-       }
+#else
+               _imageResult -> AllocateScalars(imagedata->GetScalarType(),1);
+#endif
 
+       }
        unsigned short *pTemp;
        unsigned short *pResult;
        pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); 
-
        int iPixels , sizePixels = _sizeIma*_sizeIma;
        for(iPixels=0 ; iPixels<sizePixels ; iPixels=iPixels+deltaPixel)
        {
-
                pTemp = (unsigned short*)slicesLST[0]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
-
                pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); 
                pResult[iPixels] = pTemp[iPixels];
-
                for (iWidth=1;iWidth<sizeWidth;iWidth++)
                {
                        pTemp = (unsigned short*)slicesLST[iWidth]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
@@ -329,7 +347,6 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
                                pResult[iPixels] = pTemp[iPixels];
                        }
                }
-
                if (deltaPixel!=1)
                {
                        for (itmp=1;itmp<deltaPixel;itmp++)
@@ -337,17 +354,18 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
                                pResult[iPixels+itmp] = pResult[iPixels];
                        }
                }
-
        }
-
        for (iWidth=0;iWidth<sizeWidth;iWidth++)
        {       
                slicesLST[iWidth]->Delete();
        }
-
        _imageResult->Modified();
-       _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult );
-
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+       _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( _imageResult );
+#else
+       _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _imageResult );
+#endif
 }
 
 //-------------------------------------------------------------------
@@ -364,7 +382,7 @@ void vtkPlane2DView::Configure( )
        _stPoints        = vtkStructuredPoints::New( );
        _change          = vtkImageChangeInformation::New();
 
-       wxVTKRenderWindowInteractor *iren               = GetWxVTKRenderWindowInteractor();
+       crea::wxVTKRenderWindowInteractor *iren         = GetWxVTKRenderWindowInteractor();
        ExtractPlane();
 //     SetActive(false);
        _imageViewer2XYZ -> GetVtkImageViewer2()        -> SetupInteractor ( iren );
@@ -377,13 +395,10 @@ void vtkPlane2DView::Configure( )
        //
        // Actual version
        vtkInteractorStyleBaseView2D *style2D = vtkInteractorStyleBaseView2D::New();
-
        manualInteractorWindowLevel *_manualinteractorwindowlevel= new manualInteractorWindowLevel();
        style2D->SetInteractorWindowLevel( _manualinteractorwindowlevel );
-
        vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ();
        style2D->SetInteractorScrollZ(_vtkInteractorScrollZ);
-
        SetInteractorStyleImage( style2D );
 
        // RaC
@@ -430,7 +445,12 @@ void vtkPlane2DView::HorizontalLine()
        lines->Delete();  //do not delete lines ??
        _lineActor                                      =       vtkActor::New();
     _lineMapper                                        =       vtkPolyDataMapper::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        _lineMapper->SetInput(_pd);
+#else
+       _lineMapper->SetInputData(_pd);
+#endif
        _lineMapper->ImmediateModeRenderingOn();
        _lineActor->SetMapper(_lineMapper);
        _lineActor->GetProperty()->BackfaceCullingOn();
@@ -447,6 +467,7 @@ void vtkPlane2DView::RotationStart()
        vtkTransform    *transform       = mprbasedata->GetTransformOrientation();
        _transform1->SetMatrix( transform->GetMatrix() );
 }
+
 //-------------------------------------------------------------------
 void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
 { 
@@ -480,6 +501,7 @@ void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
 void vtkPlane2DView::Refresh(  )
 {
        ExtractPlane();
+       UpdateColorWindowLevel();
        wxVtkBaseView::Refresh();
 }
 //-------------------------------------------------------------------
@@ -559,19 +581,16 @@ void vtkPlane2DView::SetVisibleLine(bool ok)
        }
        _lineActor->GetProperty()->SetOpacity(opacity);
 }
+
 // ----------------------------------------------------------------------------
 void vtkPlane2DView::TransfromCoordViewWorld2(double &X, double &Y, double &Z)
 {
        double spc[3];
        GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
-
        double xx = X;
        double yy = Y;
        double zz = 0;
-
        TransFromCoordScreenToWorld(xx,yy,zz);
-
-
        vtkTransform *transf1 = vtkTransform::New();
        transf1->Identity();
        vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation();
@@ -582,10 +601,8 @@ void vtkPlane2DView::TransfromCoordViewWorld2(double &X, double &Y, double &Z)
        in[1] = xx - center;
        in[2] = yy - center;
        in[3] = 0;
-
        transf1->MultiplyPoint(in,out);
        transf1->Delete();
-
        X = out[0] + GetVtkmprbasedata()->GetX() ;
        Y = out[1] + GetVtkmprbasedata()->GetY() ;
        Z = out[2] + GetVtkmprbasedata()->GetZ() ;