X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxMPRBaseData.cxx;h=feb2f74282b21457dac7a573bb21e26fc7679fac;hb=255f774ce4100c0b84e6b5efa5c64d0db77f8a61;hp=f3217a2e5b2f801419ea11328f6f542898987425;hpb=256ab1f0e32a5ecfa53192370162a8e54b9506c2;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..feb2f74 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx @@ -1,3 +1,28 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + #include @@ -13,109 +38,13 @@ #include "pPlotter/HistogramDialog.h" - -//------------------------------------------------------------------- -//------------------------------------------------------------------- +#ifdef _DEBUG +#define new DEBUG_NEW +#endif //------------------------------------------------------------------- - -vtkBaseData::vtkBaseData() -{ - - _z = 0; - _t = 0; - _marImageData = NULL; -} - -//------------------------------------------------------------------- -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,28 +54,44 @@ vtkMPRBaseData::vtkMPRBaseData() _x=0; _y=0; _z=0; + _x1 = 0; + _x2 = 0; + _y1 = 0; + _y2 = 0; + _z1 = 0; + _z2 = 0; _transformOrientation = NULL; _marImageData = NULL; } + //------------------------------------------------------------------- vtkMPRBaseData::~vtkMPRBaseData() { if (_marImageData) delete _marImageData; if (_transformOrientation) _transformOrientation ->Delete(); } + //------------------------------------------------------------------- void vtkMPRBaseData::Configure() { + //EED 03nov2012 + vtkBaseData::Configure(); + vtkImageData* img = _marImageData->GetImageData(); - if(img !=NULL){ + 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(); + //std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<Identity(); } + //------------------------------------------------------------------- void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2) { @@ -193,7 +138,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,15 +152,18 @@ 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; + _observable->InvokeEvent(1); } } //------------------------------------------------------------------- @@ -226,6 +174,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,15 +188,17 @@ 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; + _observable->InvokeEvent(2); } } //------------------------------------------------------------------- @@ -276,959 +227,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() ); -}