X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxMPRBaseData.cxx;h=5e63470d34661172610a17e09625d5c9f20f4dd7;hb=ed43f37723fd50cd4b0db043399050a20f9edd3b;hp=f3217a2e5b2f801419ea11328f6f542898987425;hpb=a4ee3758aa0477f677fb981e2c4d6e29995e8db8;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx index f3217a2..5e63470 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx @@ -13,109 +13,13 @@ #include "pPlotter/HistogramDialog.h" - -//------------------------------------------------------------------- -//------------------------------------------------------------------- -//------------------------------------------------------------------- - -vtkBaseData::vtkBaseData() -{ - - _z = 0; - _t = 0; - _marImageData = NULL; -} - +#ifdef _DEBUG +#define new DEBUG_NEW +#endif //------------------------------------------------------------------- -vtkBaseData::~vtkBaseData() -{ -} - -//------------------------------------------------------------------- -void vtkBaseData::SetMarImageData(marImageData *marimagedata) -{ - _marImageData = marimagedata; - //Configure(); -} - -//------------------------------------------------------------------- -vtkImageData* vtkBaseData::GetImageData() -{ - return _marImageData->GetImageDataT(_t); -} -//------------------------------------------------------------------- -marImageData* vtkBaseData::GetMarImageData() -{ - return _marImageData; -} - //------------------------------------------------------------------- - -void vtkBaseData::Configure() // virtual -{ -} - //------------------------------------------------------------------- -void vtkBaseData::SetZ(double z){ - //int maxZ; - -// int dim[3]; -// _marImageData->GetDimensions(dim); -// maxZ=dim[2]; - - int ext[6]; - vtkImageData* img = _marImageData->GetImageData(); - if(img!=NULL){ - /*img->GetWholeExtent(ext); - maxZ=ext[5]-ext[4]+1; - if (z>=maxZ) - { - //z=maxZ-1; - } - if (z<=0) - { - z=0; - } - - _z=z;*/ - img->GetExtent(ext); - if (z > ext[5]) - { - z = ext[5]; - } - if (z < ext[4]) - { - z = ext[4]; - } - - _z=z; - } -} -//------------------------------------------------------------------- -double vtkBaseData::GetZ() -{ - return _z; -} -//------------------------------------------------------------------- -int vtkBaseData::GetT() -{ - return _t; -} -//------------------------------------------------------------------- -void vtkBaseData::SetT(double t) -{ - int maxT = _marImageData->GetMaxT(); - if (t>=maxT) - { - t=maxT-1; - } - if (t<=0) - { - t=0; - } - _t=(int)t; -} //------------------------------------------------------------------- //------------------------------------------------------------------- @@ -125,6 +29,12 @@ vtkMPRBaseData::vtkMPRBaseData() _x=0; _y=0; _z=0; + _x1 = 0; + _x2 = 0; + _y1 = 0; + _y2 = 0; + _z1 = 0; + _z2 = 0; _transformOrientation = NULL; _marImageData = NULL; } @@ -141,11 +51,12 @@ void vtkMPRBaseData::Configure() if(img !=NULL){ img->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2); //std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<Identity(); + } + if(_transformOrientation==NULL){ + _transformOrientation=vtkTransform::New(); + } + _transformOrientation->Identity(); } //------------------------------------------------------------------- void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2) @@ -193,7 +104,7 @@ void vtkMPRBaseData::SetX(double x) { //int dim[3]; int ext[6]; - + double* origin; vtkImageData* img = _marImageData->GetImageData(); if(img!=NULL){ /*img->GetDimensions(dim); @@ -207,14 +118,16 @@ void vtkMPRBaseData::SetX(double x) } _x=x;*/ img->GetExtent(ext); + origin = img->GetOrigin(); if (x < ext[0]) { - x=ext[0]; + x=ext[0] + origin[0]; } if (x > ext[1]) { - x=ext[1]; + x=ext[1] + origin[0]; } + _x=x; } } @@ -226,6 +139,7 @@ void vtkMPRBaseData::SetY(double y) { //int dim[3]; int ext[6]; + double* origin; vtkImageData* img = _marImageData->GetImageData(); if(img!=NULL){ /*img->GetDimensions(dim); @@ -239,13 +153,14 @@ void vtkMPRBaseData::SetY(double y) } _y=y;*/ img->GetExtent(ext); + origin = img->GetOrigin(); if (y ext[3]) { - y=ext[3]; + y=ext[3] + origin[1]; } _y=y; } @@ -276,959 +191,3 @@ void vtkMPRBaseData::InitTransformOrientation(vtkTransform *trans) //------------------------------------------------------------------- //------------------------------------------------------------------- - -vtkMPR3DDataViewer::vtkMPR3DDataViewer() -{ - _visiblePosition[0]=false; - _visiblePosition[1]=false; - _visiblePosition[2]=false; - _ctfun = NULL; - _vtkmprbasedata=NULL; - - _ctfun=NULL; - _saggitalColors=NULL; - _saggital=NULL; - _axialColors=NULL; - _axial=NULL; - _coronalColors=NULL; - _coronal=NULL; - _mapOutline=NULL; - _outline=NULL; - _outlineData=NULL; -} -//------------------------------------------------------------------- -vtkMPR3DDataViewer::~vtkMPR3DDataViewer() -{ - _outlineData -> Delete(); - _mapOutline -> Delete(); - _outline -> Delete(); - -// if (_bwLut) _bwLut -> Delete(); -// if (_hueLut) _hueLut -> Delete(); -// if (_satLut) _satLut -> Delete(); - if (_ctfun) _ctfun -> Delete(); - if (_saggitalColors) _saggitalColors -> Delete(); - if (_saggital) _saggital -> Delete(); - if (_axialColors) _axialColors -> Delete(); - if (_axial) _axial -> Delete(); - if (_coronalColors) _coronalColors -> Delete(); - if (_coronal) _coronal -> Delete(); - -} -//------------------------------------------------------------------- -vtkActor* vtkMPR3DDataViewer::GetOutlineActor() -{ - return _outline; -} -//------------------------------------------------------------------- -vtkImageActor* vtkMPR3DDataViewer::GetImageActor(int id) -{ - vtkImageActor *tmpVtkActor=NULL; - if (id==0){ - tmpVtkActor = GetvtkActor_saggital(); - } - if (id==1){ - tmpVtkActor = GetvtkActor_coronal(); - } - if (id==2){ - tmpVtkActor = GetvtkActor_axial(); - } - return tmpVtkActor; -} -//------------------------------------------------------------------- -void vtkMPR3DDataViewer::Refresh() -{ - int x = (int)(_vtkmprbasedata->GetX()); - int y = (int)(_vtkmprbasedata->GetY()); - int z = (int)(_vtkmprbasedata->GetZ()); - std::cout<<" vtkMPR3DDataViewer::Refresh() x="<greyValuesTransferenceFVector.size(); - if(tfSize>0) - { - int i=0,y; - hDlg->erasePointsTransferenceFunction(); - while(iaddPointToTransferenceFunction(g,in*100); - i++; - } - - } - - int ctfSize=this->redColorsOfColorTransferenceFVector.size(); - if(ctfSize>0) - { - int i=0,y; - while(iaddColorPoint(gr,r*255,g*255,b*255); - i++; - } - } - //If it is smooth activate next line - //hDlg->updatePlotter(); - //setting variables if the user wants to do refresh - hDlg->setCTF(_ctfun); - hDlg->setTF(_tfun); - - // - // when the user had changed the transference Function - // - if(hDlg->ShowModal()== wxID_OK ) - { - // -- vtkPiecewiseFunction -- - this->_tfun->RemoveAllPoints(); - greyValuesTransferenceFVector.clear(); - intensityValuesTransferenceFVector.clear(); - - int nTFPoints=hDlg->getSizeTransferenceFunction(); - i=0; - while(igetTransferenceFunctionPoint(i,xi,yi); - this->_tfun->AddPoint( xi , yi/100.0 ); - greyValuesTransferenceFVector.push_back(xi); - intensityValuesTransferenceFVector.push_back(yi/100.0); - i++; - } - // -- vtkColorTransferFunction -- - this->_ctfun->RemoveAllPoints (); - //clean colors - redColorsOfColorTransferenceFVector.clear(); - greenColorsOfColorTransferenceFVector.clear(); - blueColorsOfColorTransferenceFVector.clear(); - greyValueColorsOfColorTransferenceFVector.clear(); - - int nCTFpoints=hDlg->getSizeBarColor(); - i=0; - while(igetDataBarColorPoint(i,xi,r,g,b); - this->_ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 ); - redColorsOfColorTransferenceFVector.push_back(r/255.0); - greenColorsOfColorTransferenceFVector.push_back(g/255.0); - blueColorsOfColorTransferenceFVector.push_back(b/255.0); - greyValueColorsOfColorTransferenceFVector.push_back(xi); - i++; - } - - this->_volumeMapper->Update(); - this->_newvol->Update(); - } - - else - { - - if(hDlg->getRefreshed()) - { - int i=0,size; - //--Transference Function---- - this->_tfun->RemoveAllPoints(); - i=0; - size=greyValuesTransferenceFVector.size(); - for(i=0;i_tfun->AddPoint( grey1 , in2 ); - } - - // -- vtkColorTransferFunction -- - _ctfun->RemoveAllPoints (); - - i=0; - size=greyValueColorsOfColorTransferenceFVector.size(); - for(i=0;iAddRGBPoint(grey2,red,green,blue); - } - this->_volumeMapper->Update(); - this->_newvol->Update(); - } - - } - hDlg->Destroy(); -*/ -} -/* -void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile) -{ - char tmp[256]; - short int max; - double range[2]; - double x,val,r,g,b; - - FILE *ff = fopen ( namefile ,"r"); - - // -- MAX -- - fscanf(ff,"%s",tmp); - if (strcmp(tmp,"MAX")==0) - { - vtkImageData *vtkimagedata = this->_vtkmprbasedata->GetImageData(); - vtkimagedata->GetScalarRange(range); - max = (int) (range[1]); - } else { - max = atoi(tmp); - } - - fscanf(ff,"%s",tmp); // -- - - // -- vtkPiecewiseFunction -- - this->_tfun->RemoveAllPoints(); - fscanf(ff,"%s",tmp); - while ( strcmp(tmp,"--")!=0 ) - { - x=atof(tmp); - fscanf(ff,"%s",tmp); - val=atof(tmp); - this->_tfun->AddPoint( x*max , val ); - fscanf(ff,"%s",tmp); - } - - this->_ctfun->RemoveAllPoints (); - // -- vtkColorTransferFunction -- - while ( !feof(ff)) - { - fscanf(ff,"%s",tmp); - x=atof(tmp); - fscanf(ff,"%s",tmp); - r=atof(tmp); - fscanf(ff,"%s",tmp); - g=atof(tmp); - fscanf(ff,"%s",tmp); - b=atof(tmp); - this->_ctfun->AddRGBPoint( x*max , r,g,b ); - } - - - this->_volumeMapper->Update(); - this->_newvol->Update(); - - - fclose(ff); -} -*/ - -//------------------------------------------------------------------- -// EED 23 Mai 2007 -void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile) -{ - vtkDataSetReader *reader = vtkDataSetReader::New(); - reader->SetFileName(namefile); - reader->Update(); - _tissueStripper[3]->SetInput( reader->GetPolyDataOutput() ); -}