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