X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxSphereView.cxx;h=961918187031c5118bb9d2c959e8aa8d29bc9b43;hb=b80b4dcc301c1c2c63c0f76cd06b0a434350f7a7;hp=bfe896e01a10c156588bda0fd047b4d2fa566d4b;hpb=97dee12beaba08089198ed7bab9544b8b4c4f240;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx index bfe896e..9619181 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx @@ -25,24 +25,31 @@ #include "wxSphereView.h" - -wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vtkImageData *imageData ) +wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata/*, vtkImageData *imageData */) : wxVtk2DBaseView(parent) { _delta = 1; _vtkmprbasedata = vtkmprbasedata; - _imageDataOriginal = imageData; +//EED 2016-08-31 +// _imageDataOriginal = imageData; + + SetImage(); _imageSphere = vtkImageData::New(); _imageSphere->SetDimensions (150,150,500); - _imageSphere->SetScalarTypeToUnsignedShort(); + +//EED +// _imageSphere->SetScalarTypeToUnsignedShort(); + _imageSphere->SetScalarType( _imageDataOriginal->GetScalarType() ); + _imageSphere->AllocateScalars(); _imageSphere->Update(); - - vtkBaseData *vtkbasedata = new vtkBaseData(); - vtkbasedata->SetMarImageData( new marImageData(_imageSphere) ); - this->SetVtkBaseData(vtkbasedata); +//EED ???? vtkBaseData no esta compartido con los otros objetos .. PLOP +// vtkBaseData *vtkbasedata = new vtkBaseData(); +// vtkbasedata->SetMarImageData( new marImageData(_imageSphere) ); +// this->SetVtkBaseData(vtkbasedata); + this->SetVtkBaseData(_vtkmprbasedata); _transform = vtkTransform::New(); _transform1 = vtkTransform::New(); @@ -50,12 +57,10 @@ wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vt _transform ->Identity(); _transform1->Identity(); _transform2->Identity(); - _radio=25; } //------------------------------------------------------------------- - wxSphereView::~wxSphereView() { _transform -> Delete(); @@ -65,33 +70,46 @@ wxSphereView::~wxSphereView() } //---------------------------------------------------------------------------- +void wxSphereView::SetImage() +{ + ResetlstId(); + _imageDataOriginal=_vtkmprbasedata->GetImageData(); +} +//---------------------------------------------------------------------------- double wxSphereView::GetRadio() { return _radio; } //---------------------------------------------------------------------------- - void wxSphereView::SetRadio(double radio) { if (radio<0) { radio=0; - } + } // if _radio=radio; } //---------------------------------------------------------------------------- - void wxSphereView::Configure() { wxVtk2DBaseView::Configure(); + + vtkInteractorStyleBaseView2D *style2D = vtkInteractorStyleBaseView2D::New(); + manualInteractorWindowLevel *_manualinteractorwindowlevel= new manualInteractorWindowLevel(); + style2D->SetInteractorWindowLevel( _manualinteractorwindowlevel ); +// vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ(); +// style2D->SetInteractorScrollZ(_vtkInteractorScrollZ); + SetInteractorStyleImage( style2D ); + + + _vtkinteractorstylesphere = new vtkInteractorStyleSphere(); ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _vtkinteractorstylesphere ); double points[4][3]; - // EED purify 12/sep/2006 int i,j; for (i=0;i<4;i++) @@ -99,15 +117,15 @@ void wxSphereView::Configure() for (j=0;j<3;j++) { points[i][j]=0; - } - } - + } // for + } // for InitSphere(points); + + DefineImageSphere(); } //---------------------------------------------------------------------------- - void wxSphereView::RefreshPoint() { double x = _vtkmprbasedata->GetX() - _centerX; @@ -115,29 +133,39 @@ void wxSphereView::RefreshPoint() double z = _vtkmprbasedata->GetZ() - _centerZ; double alpha= atan2(x,z); double beta = atan2( y , sqrt(z*z+x*x) ); - alpha = alpha*180/3.1416; beta = beta*180/3.1416; - _transform1->Identity(); _transform1->RotateY(alpha); _transform1->RotateX(-beta); - _radio= sqrt(x*x + y*y +z*z); - RefreshView(); } -//---------------------------------------------------------------------------- + +//------------------------------------------------------------------- +void wxSphereView::Refresh( ) +{ +// ExtractPlane(); + UpdateColorWindowLevel(); + wxVtkBaseView::Refresh(); +} + + + +//---------------------------------------------------------------------------- void wxSphereView::RefreshView() { +//EED + _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageSphere ); DefineImageSphere(); - wxVtk2DBaseView::Refresh(); +// UpdateColorWindowLevel(); +// wxVtk2DBaseView::Refresh(); + Refresh(); } //---------------------------------------------------------------------------- - void wxSphereView::RotationEnd() { _transform1->RotateWXYZ(_ang,_vxb,_vyb,0); @@ -147,19 +175,16 @@ void wxSphereView::RotationEnd() } //---------------------------------------------------------------------------- - void wxSphereView::RotationStart(double vx, double vy, bool ok_v, bool ok_ang) { if (ok_ang==false) { _ang = -sqrt( vx*vx + vy*vy ) / 1.0; - } - + } // if ok_ang if (ok_v==false){ _vxb=-vy; _vyb=vx; - } - + } // if ok_v _transform2->Identity(); _transform2->RotateWXYZ(_ang,_vxb,_vyb,0); SetDeltaVoxel(3); @@ -167,7 +192,6 @@ void wxSphereView::RotationStart(double vx, double vy, bool ok_v, bool ok_ang) } //---------------------------------------------------------------------------- - void wxSphereView::GetPointSphere(double p[3],double r1,double angA,double angB) { double in[3],out[3]; @@ -186,61 +210,16 @@ void wxSphereView::GetPointSphere(double p[3],double r1,double angA,double angB) } //---------------------------------------------------------------------------- - void wxSphereView::RotatePointOverTheSphere( double pp[3], double p[3],double cc[3]) { - double out[3]; _transform->TransformPoint(p,out); pp[0] = out[0] + cc[0]; pp[1] = out[1] + cc[1]; pp[2] = out[2] + cc[2]; - } //---------------------------------------------------------------------------- - -void wxSphereView::TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image) -{ - double t; - double difX = pp2[0]-pp1[0]; - double difY = pp2[1]-pp1[1]; - double difZ = pp2[2]-pp1[2]; - - double max = 200; - - int dimOrg[3]; - int dimRes[3]; - int z; - _imageDataOriginal->GetDimensions(dimOrg); - image->GetDimensions(dimRes); - - int i; - double x1=pp1[0]; - double y1=pp1[1]; - double z1=pp1[2]; - int xx=-1,yy=-1,zz=-1; - - for (i=0;i=0) && (xx=0) && (yy=0) && (zz=0) && (AngX=0) && (AngY=0) && (zGetScalarPointer (xx,yy,zz); - unsigned short *pRes=(unsigned short*)image->GetScalarPointer( (int)AngX , (int)AngY , z ); - *pRes=*pOrg; - } - } -} - -//---------------------------------------------------------------------------- - void wxSphereView::ResetlstId() { int i,size=_lstId.size(); @@ -252,7 +231,6 @@ void wxSphereView::ResetlstId() } //---------------------------------------------------------------------------- - int wxSphereView::GetIdOfImage(double radio) { int id=0; @@ -280,22 +258,21 @@ int wxSphereView::GetIdOfImage(double radio) } else { id = 0; } - FiltreImage(id,radio); _lstId.insert(_lstId.begin(),1,new idAlBeRa(id,radio,_delta) ); - return id; } //---------------------------------------------------------------------------- - void wxSphereView::DefineImageSphere() { int id; id=GetIdOfImage( _radio ); - GetVtkBaseData()->SetZ( id ); -} +//EED +// GetVtkBaseData()->SetZ( id ); + _imageViewer2XYZ->GetVtkImageViewer2()->SetSlice ( id ); +} //---------------------------------------------------------------------------- void wxSphereView::SetDeltaVoxel(int delta) @@ -304,7 +281,7 @@ void wxSphereView::SetDeltaVoxel(int delta) } //---------------------------------------------------------------------------- -void wxSphereView::SetVoxel(double i, double j, int delta,double id, unsigned short gris) +void wxSphereView::SetVoxel(double i, double j, int delta,double id, double gris) { int ii,jj,delta2; unsigned short *pRes; @@ -319,16 +296,16 @@ void wxSphereView::SetVoxel(double i, double j, int delta,double id, unsigned s if ( (ii>=0)&&(ii=0)&&(jjGetScalarPointer( ii , jj , (int)id ); - *pRes=gris; +//EED +// pRes = (unsigned short*)_imageSphere->GetScalarPointer( ii , jj , (int)id ); +// *pRes=gris; + _imageSphere->SetScalarComponentFromDouble( ii , jj , (int)id , 0, gris ); } - } - } - + } // for jj + } // for ii } //---------------------------------------------------------------------------- - void wxSphereView::SetXYZtoParent(double i, double j) { @@ -345,7 +322,6 @@ void wxSphereView::SetXYZtoParent(double i, double j) d2x=dimRes[0]/2; d2y=dimRes[1]/2; _imageDataOriginal->GetDimensions(dimOrig); - p[0] = (i - d2x)*factor; pxx=p[0]*p[0]; p[1] = (j - d2y)*factor; @@ -364,15 +340,14 @@ void wxSphereView::SetXYZtoParent(double i, double j) _vtkmprbasedata->SetY(pp[1]); _vtkmprbasedata->SetZ(pp[2]); } - } - } + } // if pp + } // if radio } - //---------------------------------------------------------------------------- - void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) { + double value; double factor = 0.75; double radioB = radio/3; double radio2 = radio*radio; @@ -394,9 +369,7 @@ void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) //JCP 24 - 04 -09 d2x=dimRes[0]/2; d2y=dimRes[1]/2; -// double deltaTMP=_delta; _imageDataOriginal->GetDimensions(dimOrig); - int start,end; int limitA,limitB; limitA = (int) ( (-radioB/factor)+d2x ); @@ -431,8 +404,11 @@ void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) (pp[1]>=0) && (pp[1]=0) && (pp[2]GetScalarPointer( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]) ); - SetVoxel(i,j,deltaTMP,id,*pOrig); +//EED +// pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]) ); +// SetVoxel(i,j,deltaTMP,id,*pOrig); + value=_imageDataOriginal->GetScalarComponentAsDouble( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]), 0); + SetVoxel(i,j,deltaTMP,id,value); } else { SetVoxel(i,j,deltaTMP,id,2000); } @@ -442,28 +418,20 @@ void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) } } } - _imageSphere->Modified(); _imageSphere->Update(); } - - - //---------------------------------------------------------------------------- - void wxSphereView::FiltreImage(int id, double radio) { - _transform -> Identity(); _transform -> Concatenate(_transform1); _transform -> Concatenate(_transform2); - FiltreImageB(id,radio,false, _delta); FiltreImageB(id,radio,true, 1); } - //---------------------------------------------------------------------------- /* @@ -600,6 +568,48 @@ void wxSphereView::FiltreImage(vtkImageData *imageSphere) } } } + + +//---------------------------------------------------------------------------- + +void wxSphereView::TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image) +{ + double t; + double difX = pp2[0]-pp1[0]; + double difY = pp2[1]-pp1[1]; + double difZ = pp2[2]-pp1[2]; + double max = 200; + int dimOrg[3]; + int dimRes[3]; + int z; + _imageDataOriginal->GetDimensions(dimOrg); + image->GetDimensions(dimRes); + int i; + double x1=pp1[0]; + double y1=pp1[1]; + double z1=pp1[2]; + int xx=-1,yy=-1,zz=-1; + for (i=0;i=0) && (xx=0) && (yy=0) && (zz=0) && (AngX=0) && (AngY=0) && (zGetScalarPointer (xx,yy,zz); + unsigned short *pRes=(unsigned short*)image->GetScalarPointer( (int)AngX , (int)AngY , z ); + *pRes=*pOrg; + } + } +} + + + + */