vtkInfoTextImage.cxx

Go to the documentation of this file.
00001 #include "vtkInfoTextImage.h"
00002 
00003 #include "vtkTextProperty.h"
00004 #include <vtkImageMapToWindowLevelColors.h>
00005 //-------------------------------------------------------------------
00006 //-------------------------------------------------------------------
00007 //-------------------------------------------------------------------
00008 
00009 vtkInfoTextImage::vtkInfoTextImage()
00010 {
00011         _vtkText_WindowLevel    = NULL;
00012         _vtkText_ColorLevel             = NULL;
00013         _vtkText_position               = NULL;
00014         _vtkText_pixelIntensity = NULL;
00015         _marimagedata                   = NULL;
00016 }
00017 
00018 //-------------------------------------------------------------------
00019 
00020 vtkInfoTextImage::~vtkInfoTextImage()
00021 {
00022 }
00023 
00024 //-------------------------------------------------------------------
00025 
00026 void vtkInfoTextImage::Configure()
00027 {
00028         if(_vtkText_WindowLevel == NULL){
00029                 _vtkText_WindowLevel    = Create_Text_Label( 10 , 55 );
00030                 _vtkText_ColorLevel             = Create_Text_Label( 10 , 40 );
00031                 _vtkText_position               = Create_Text_Label( 10 , 25 );
00032                 _vtkText_pixelIntensity = Create_Text_Label( 10 , 10 );
00033         }
00034 }
00035 
00036 
00037 //-------------------------------------------------------------------
00038 
00039 void vtkInfoTextImage::SetMarImageData(marImageData *marimagedata)
00040 {
00041         _marimagedata=marimagedata;
00042 }
00043 
00044 //-------------------------------------------------------------------
00045 
00046 void vtkInfoTextImage::SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview)
00047 {
00048         _wxvtk2Dbaseview=wxvtk2Dbaseview;
00049 }
00050 
00051 //-------------------------------------------------------------------
00052 
00053 vtkTextActor *vtkInfoTextImage::Create_Text_Label(int px, int py )
00054 {
00055         // Text Window Level
00056         vtkTextActor *textActor = vtkTextActor::New();
00057         textActor->SetDisplayPosition(px, py);
00058         textActor->SetInput("0");
00059 
00060         // Set coordinates to match the old vtkScaledTextActor default value
00061         textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
00062         textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
00063 
00064         vtkTextProperty *tprop = textActor->GetTextProperty();
00065         tprop->SetFontSize(14);
00066         tprop->SetFontFamilyToArial();
00067         tprop->SetColor(1, 1, 0);
00068         _wxvtk2Dbaseview->GetRenderer()->AddActor2D(textActor);
00069 
00070         return textActor;
00071 }
00072 
00073 //-------------------------------------------------------------------
00074 
00075 void vtkInfoTextImage::PutWindowLevel()
00076 {
00077         int value = (int)( _wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetWindow() );
00078         char zTzxt[20];
00079         char resultText[50];
00080 
00081         strcpy(resultText,"w:");
00082 
00083 
00084         //ltoa ( (long)value , zTzxt , 10 );
00085         sprintf(zTzxt,"%d",value);
00086 
00087         strcat(resultText,zTzxt);
00088         _vtkText_WindowLevel            -> SetInput(resultText);
00089 }
00090 
00091 //-------------------------------------------------------------------
00092 
00093 void vtkInfoTextImage::PutColorLevel()
00094 {
00095         int value = (int)(_wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetLevel());
00096         char zTzxt[20];
00097         char resultText[50];
00098 
00099         strcpy(resultText,"c:");
00100 
00101 //      itoa (value,zTzxt,10);
00102         sprintf(zTzxt,"%d",value);
00103 
00104         strcat(resultText,zTzxt);
00105         _vtkText_ColorLevel             -> SetInput(resultText);
00106 }
00107 
00108 //-------------------------------------------------------------------
00109 
00110 void vtkInfoTextImage::PutPosition(int xx,int yy, int zz)
00111 {
00112 
00113 //EEDx7
00114 //      double spa[3];
00115 //      _imagedata->GetSpacing(spa);
00116 //      xx=xx*(1/spa[0]);
00117 //      yy=yy*(1/spa[1]);
00118 
00119 
00120         char zTzxt[50];
00121         char resultText[50];
00122         strcpy(resultText,"p: ");
00123 //      itoa ((int)xx,zTzxt,10);
00124         sprintf(zTzxt,"%d",xx);
00125 
00126         strcat(resultText,zTzxt);
00127         strcat(resultText," , ");
00128 
00129 //      itoa ((int)yy,zTzxt,10);
00130         sprintf(zTzxt,"%d",yy);
00131 
00132         strcat(resultText,zTzxt);
00133         strcat(resultText," , ");
00134 
00135 //      itoa ((int)zz,zTzxt,10);
00136         sprintf(zTzxt,"%d",zz);
00137 
00138         strcat(resultText,zTzxt);
00139 
00140 
00141         
00142         int nX = _marimagedata->GetXOriginal(xx);
00143         int nY = _marimagedata->GetYOriginal(yy);
00144         int nZ = _marimagedata->GetZOriginal(zz);
00145 
00146         strcat(resultText,"   (");
00147 //      ltoa ((int)nX,zTzxt,10);
00148         sprintf(zTzxt,"%d",nX);
00149 
00150         strcat(resultText,zTzxt);
00151         strcat(resultText,",");
00152 
00153 //      ltoa ((int)nY,zTzxt,10);
00154         sprintf(zTzxt,"%d",nY);
00155 
00156         strcat(resultText,zTzxt);
00157         strcat(resultText,",");
00158 
00159 //      ltoa ((int)nZ,zTzxt,10);
00160         sprintf(zTzxt,"%d",nZ);
00161 
00162         strcat(resultText,zTzxt);
00163         strcat(resultText,")");
00164 
00165 
00166 
00167 
00168         _vtkText_position               -> SetInput(resultText);
00169 }
00170 
00171 //-------------------------------------------------------------------
00172 
00173 void vtkInfoTextImage::PutPixelIntensity(int xx, int yy, int zz)
00174 {
00175 
00176 //EEDx2
00177         bool ok=true;
00178 
00179         int dim[3];
00180         double spa[3];
00181         vtkImageData *imagedata = _marimagedata->GetImageData();
00182         imagedata->GetDimensions(dim);
00183         imagedata->GetSpacing(spa);
00184 
00185 // EEDx7
00186 //      xx=xx*(1/spa[0]);
00187 //      yy=yy*(1/spa[1]);
00188 //      zz=xx*spa[2];
00189 
00190         if ( (xx<0) || (xx>=dim[0]) || (yy<0) || (yy>=dim[1]) || (zz<0) || (zz>=dim[2]) )
00191         {
00192                 ok=false;
00193         }
00194 
00195         
00196         char zTzxt[20];
00197         char resultText[50];
00198         strcpy(resultText,"GL: ");
00199         if (ok==true) 
00200         {
00201                 if (imagedata->GetScalarType()==VTK_BIT)
00202                 {
00203                         char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00204         //              itoa (*pOrg,zTzxt,10);
00205                         if(*pOrg==0)
00206                         {
00207                                 sprintf(zTzxt,"%d",0);
00208                         }
00209                         else
00210                         {
00211                                 sprintf(zTzxt,"%d",1);
00212                         }
00213                 }
00214         
00215                 else if (imagedata->GetScalarType()==VTK_CHAR)
00216                 {
00217                         char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00218         //              itoa (*pOrg,zTzxt,10);
00219                         int tmp=*pOrg;
00220                         sprintf(zTzxt,"%d",tmp);
00221                 }
00222 
00223                 else if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
00224                 {
00225                         signed char *pOrg=(signed char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00226         //              itoa (*pOrg,zTzxt,10);
00227                         int tmp=*pOrg;
00228                         sprintf(zTzxt,"%d",tmp);
00229                 }
00230 
00231                 else if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
00232                 {
00233                         unsigned char *pOrg=(unsigned char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00234         //              itoa (*pOrg,zTzxt,10);
00235                         int tmp=*pOrg;
00236                         sprintf(zTzxt,"%d",tmp);
00237                 }
00238 
00239                 else if (imagedata->GetScalarType()==VTK_SHORT)
00240                 {
00241                         short *pOrg=(short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00242         //              itoa (*pOrg,zTzxt,10);
00243                         int tmp=*pOrg;
00244                         sprintf(zTzxt,"%d",tmp);
00245                 }
00246 
00247                 else if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
00248                 {
00249                         unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00250         //              itoa (*pOrg,zTzxt,10);
00251                         int tmp=*pOrg;
00252                         sprintf(zTzxt,"%d",tmp);
00253                 }
00254         
00255                 else if (imagedata->GetScalarType()==VTK_INT)
00256                 {
00257                         int *pOrg=(int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00258         //              itoa (*pOrg,zTzxt,10);
00259                         sprintf(zTzxt,"%d",*pOrg);
00260                 }
00261 
00262                 else if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
00263                 {
00264                         unsigned int *pOrg=(unsigned int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00265         //              itoa (*pOrg,zTzxt,10);
00266                         int tmp=*pOrg;
00267                         sprintf(zTzxt,"%d",tmp);
00268                 }
00269 
00270                 else if (imagedata->GetScalarType()==VTK_LONG)
00271                 {
00272                         long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00273         //              itoa (*pOrg,zTzxt,10);
00274                         double tmp=*pOrg;
00275                         sprintf(zTzxt,"%3.2f",tmp);
00276                 }
00277 
00278                 else if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
00279                 {
00280                         unsigned long *pOrg=(unsigned long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00281         //              itoa (*pOrg,zTzxt,10);
00282                         double tmp=*pOrg;
00283                         sprintf(zTzxt,"%3.2f",tmp);
00284                 }
00285 
00286                 else if (imagedata->GetScalarType()==VTK_FLOAT)
00287                 {
00288                         float *pOrg=(float*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00289         //              itoa (*pOrg,zTzxt,10);
00290                         double tmp=(double)*pOrg;
00291                         sprintf(zTzxt,"%3.2f",tmp);
00292                 }
00293 
00294                 else if (imagedata->GetScalarType()==VTK_DOUBLE)
00295                 {
00296                         double *pOrg=(double*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
00297         //              itoa (*pOrg,zTzxt,10);
00298                         double tmp=*pOrg;
00299                         sprintf(zTzxt,"%3.2f",tmp);
00300                 }
00301         } 
00302         else 
00303         {
00304                 strcpy(zTzxt,"---");
00305         }
00306         strcat(resultText,zTzxt);
00307         _vtkText_pixelIntensity -> SetInput(resultText);
00308 }

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1