]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx
BUG histogram
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkBaseView.cxx
index 86358111a08130bd8bb53698a71106f7820de076..7bbda0afddaf0f87117dbe6ac11cff696a48df19 100644 (file)
@@ -30,7 +30,7 @@ vtkImageViewer2_XYZ::vtkImageViewer2_XYZ()
 //-------------------------------------------------------------------
 vtkImageViewer2_XYZ::~vtkImageViewer2_XYZ()
 {
-       _vtkimageviewer2->Delete();
+       //_vtkimageviewer2->Delete();
 }
 //-------------------------------------------------------------------
 void vtkImageViewer2_XYZ::SetExtentDimension(int x1,int x2,
@@ -191,10 +191,15 @@ wxVtkBaseView::wxVtkBaseView(wxWindow *parent)
 wxVtkBaseView::~wxVtkBaseView()
 {
  //    _iren -> Delete();
+       _iren=NULL;
 }
 //-------------------------------------------------------------------
-wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor()
+wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
 {
+
+       if(_iren==NULL){
+               throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren wxVTKRenderWindowInteractorPlus =NULL";
+       }
    return _iren;
 }
 //-------------------------------------------------------------------
@@ -209,7 +214,13 @@ void wxVtkBaseView::Refresh()  // virtual
        #if defined(WIN32)
                _iren->Refresh(false);
        #else
-               _iren->Render();
+       
+//EED 01Avril2009
+//             _iren->Render();        
+       vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
+       vri->vtkRenderWindowInteractor::Render();
+       
+       
                //_iren->Refresh();
        #endif
 
@@ -1341,14 +1352,112 @@ void vtkInfoTextImage::PutPixelIntensity(int xx, int yy, int zz)
        
        char zTzxt[20];
        char resultText[50];
-       strcpy(resultText,"NG: ");
-       if (ok==true) {
-               unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
-//             itoa (*pOrg,zTzxt,10);
-               int tmp=*pOrg;
-               sprintf(zTzxt,"%d",tmp);
-
-       } else {
+       strcpy(resultText,"GL: ");
+       if (ok==true) 
+       {
+               if (imagedata->GetScalarType()==VTK_BIT)
+               {
+                       char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       if(*pOrg==0)
+                       {
+                               sprintf(zTzxt,"%d",0);
+                       }
+                       else
+                       {
+                               sprintf(zTzxt,"%d",1);
+                       }
+               }
+       
+               if (imagedata->GetScalarType()==VTK_CHAR)
+               {
+                       char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       int tmp=*pOrg;
+                       sprintf(zTzxt,"%d",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
+               {
+                       signed char *pOrg=(signed char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       int tmp=*pOrg;
+                       sprintf(zTzxt,"%d",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
+               {
+                       unsigned char *pOrg=(unsigned char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       int tmp=*pOrg;
+                       sprintf(zTzxt,"%d",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_SHORT)
+               {
+                       short *pOrg=(short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       int tmp=*pOrg;
+                       sprintf(zTzxt,"%d",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
+               {
+                       unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       int tmp=*pOrg;
+                       sprintf(zTzxt,"%d",tmp);
+               }
+       
+               if (imagedata->GetScalarType()==VTK_INT)
+               {
+                       int *pOrg=(int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       sprintf(zTzxt,"%d",*pOrg);
+               }
+
+               if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
+               {
+                       unsigned int *pOrg=(unsigned int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       int tmp=*pOrg;
+                       sprintf(zTzxt,"%d",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_LONG)
+               {
+                       long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       double tmp=*pOrg;
+                       sprintf(zTzxt,"%3.2f",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
+               {
+                       unsigned long *pOrg=(unsigned long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       double tmp=*pOrg;
+                       sprintf(zTzxt,"%3.2f",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_FLOAT)
+               {
+                       long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       double tmp=*pOrg;
+                       sprintf(zTzxt,"%3.2f",tmp);
+               }
+
+               if (imagedata->GetScalarType()==VTK_DOUBLE)
+               {
+                       double *pOrg=(double*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+       //              itoa (*pOrg,zTzxt,10);
+                       double tmp=*pOrg;
+                       sprintf(zTzxt,"%3.2f",tmp);
+               }
+       } 
+       else 
+       {
                strcpy(zTzxt,"---");
        }
        strcat(resultText,zTzxt);
@@ -1389,6 +1498,7 @@ bool vtkInfoTextImageInteractor::OnMouseMove()
        double xx=X,yy=Y,zz=z;
        _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->TransfromeCoordScreenToWorld(xx,yy,zz);
 
+       
        GetVtkInfoTextImage()->PutWindowLevel();
        GetVtkInfoTextImage()->PutColorLevel();
        GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
@@ -1417,17 +1527,19 @@ wxVtk2DBaseView::wxVtk2DBaseView(wxWindow *parent)
        _vtkIinfoTextImage      = NULL;
 }
 
+//EED 5mai2009
 //-------------------------------------------------------------------
 wxVtk2DBaseView::~wxVtk2DBaseView()
-{
-       if (_imageViewer2XYZ!=NULL) {
-               delete _imageViewer2XYZ; 
-       }
-
-       if (_imageViewer2XYZ!=NULL) {
+{      
+       if (_vtkIinfoTextImage!=NULL) 
+       {
                delete _vtkIinfoTextImage; 
        }
 
+       if (_imageViewer2XYZ!=NULL) 
+       {
+               delete _imageViewer2XYZ; 
+       }
 }
 
 //-------------------------------------------------------------------
@@ -1477,10 +1589,7 @@ void wxVtk2DBaseView::ResetView()
        _imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2);
        _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
 
-printf("EED wxVtk2DBaseView::ResetView podemos 01\n ");        
        _imageViewer2XYZ->GetVtkImageViewer2()->Render();
-printf("EED wxVtk2DBaseView::ResetView podemos 02\n ");        
-
        SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
        
 }
@@ -1543,13 +1652,22 @@ void wxVtk2DBaseView::Configure(bool okimage)
 
                        vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2();
                        vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera();
+
+//EED 17Avril2009      
+/*                     
                        camera->SetViewUp               ( spx*0                 , -spy*1                        , spz*0         );
                        camera->SetPosition             ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , -spz*10000    ); 
                        camera->SetFocalPoint   ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0         ); 
+*/ 
+                       camera->SetViewUp               ( spx*0                 , spy*1                 , spz*0         );
+                       camera->SetPosition             ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*10000     ); 
+                       camera->SetFocalPoint   ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0         ); 
+                       
+                       
                        camera->SetClippingRange( 0.01                  , 1000000 );
                        camera->ComputeViewPlaneNormal();
                        camera->SetParallelScale( spx*(x2-x1)/3.0 );
-
+                       
                        // text information over the graphic window
                        _vtkIinfoTextImage                              = new vtkInfoTextImage();
                        _vtkIinfoTextImageInteractor    = new vtkInfoTextImageInteractor();
@@ -1611,7 +1729,7 @@ void wxVtk2DBaseView::SetInteractorStyleImage(vtkInteractorStyleBaseView *intera
        iren->SetInteractorStyle(interactorstylebaseview);
        interactorstylebaseview->SetwxVtkBaseView(this);        
 
-       vtkMaracasImageViewer2Callback *cbk = vtkMaracasImageViewer2Callback::New();
+       vtkMaracasImageViewer2Callback * cbk = vtkMaracasImageViewer2Callback::New();
        cbk->IV = _imageViewer2XYZ->GetVtkImageViewer2();
        interactorstylebaseview->AddObserver( vtkCommand::WindowLevelEvent, cbk );
        interactorstylebaseview->AddObserver( vtkCommand::StartWindowLevelEvent, cbk );
@@ -1688,7 +1806,7 @@ void wxVtk3DBaseView::Configure()
        if (_configure==false)
        {
                _configure=true;
-               wxVtkBaseView::Configure();
+               //wxVtkBaseView::Configure();
                _aRenderer      = vtkRenderer::New();
                _renWin         = vtkRenderWindow::New();
                _renWin->AddRenderer(_aRenderer);
@@ -1722,10 +1840,18 @@ void wxVtk3DBaseView::Configure()
                // (ResetCamera() method) this vector is used to position the camera
                // to look at the data in this direction.
                _aCamera = vtkCamera::New();
+
+//EED 17Avril2009      
+/*
                _aCamera->SetViewUp (0, 0, -1);
                _aCamera->SetPosition (0, 1, 0);
+ */
+               _aCamera->SetViewUp (0, 1, 0);
+               _aCamera->SetPosition (0, 0, 1);
+               
                _aCamera->SetFocalPoint (0, 0, 0);
                _aCamera->ComputeViewPlaneNormal();
+
        }
 }
 //-------------------------------------------------------------------