00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "TImageDump.h"
00035 #include "TImage.h"
00036 #include "TMath.h"
00037 #include "TPoint.h"
00038 #include "TColor.h"
00039 #include "TVirtualPad.h"
00040 #include "TEnv.h"
00041 #include "TROOT.h"
00042 #include "TSystem.h"
00043 #include "TText.h"
00044 #include "RStipples.h"
00045 #include "TList.h"
00046 #include "TStyle.h"
00047 #include "TObjString.h"
00048 #include "TObjArray.h"
00049
00050
00051 ClassImp(TImageDump)
00052
00053
00054
00055 TImageDump::TImageDump() : TVirtualPS()
00056 {
00057
00058
00059 fStream = 0;
00060 fImage = 0;
00061 gVirtualPS = this;
00062 fType = 0;
00063 }
00064
00065
00066 TImageDump::TImageDump(const char *fname, Int_t wtype) : TVirtualPS(fname, wtype)
00067 {
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 Open(fname, wtype);
00078 gVirtualPS = this;
00079 }
00080
00081
00082 void TImageDump::Open(const char *fname, Int_t type)
00083 {
00084
00085
00086 fStream = 0;
00087 fImage = TImage::Create();
00088 fType = type;
00089 SetName(fname);
00090 }
00091
00092
00093 TImageDump::~TImageDump()
00094 {
00095
00096
00097 Close();
00098
00099 delete fImage;
00100 fImage = 0;
00101
00102 gVirtualPS = 0;
00103 }
00104
00105
00106 void TImageDump::Close(Option_t *)
00107 {
00108
00109
00110
00111 if (!fImage || (fType == 114)) {
00112 return;
00113 }
00114
00115
00116 fImage->WriteImage(GetName());
00117 }
00118
00119
00120 void TImageDump::DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
00121 {
00122
00123
00124 if (!gPad || !fImage) {
00125 return;
00126 }
00127
00128 fImage->BeginPaint();
00129
00130 static Double_t x[4], y[4];
00131 Int_t ix1 = x1 < x2 ? XtoPixel(x1) : XtoPixel(x2);
00132 Int_t ix2 = x1 < x2 ? XtoPixel(x2) : XtoPixel(x1);
00133 Int_t iy1 = y1 < y2 ? YtoPixel(y1) : YtoPixel(y2);
00134 Int_t iy2 = y1 < y2 ? YtoPixel(y2) : YtoPixel(y1);
00135 if (TMath::Abs(ix2-ix1) < 1) ix2 = ix1+1;
00136 if (TMath::Abs(iy1-iy2) < 1) iy1 = iy2+1;
00137
00138 Int_t fillis = fFillStyle/1000;
00139 Int_t fillsi = fFillStyle%1000;
00140
00141 TColor *col = gROOT->GetColor(fFillColor);
00142 if (!col) {
00143 fFillColor = 10;
00144 col = gROOT->GetColor(fFillColor);
00145 }
00146
00147 TColor *linecol = gROOT->GetColor(fLineColor);
00148 if (!linecol) {
00149 fLineColor = 1;
00150 linecol = gROOT->GetColor(fLineColor);
00151 }
00152
00153 if ((fillis == 3) || (fillis == 2)) {
00154 if (fillsi > 99) {
00155 x[0] = x1; y[0] = y1;
00156 x[1] = x2; y[1] = y1;
00157 x[2] = x2; y[2] = y2;
00158 x[3] = x1; y[3] = y2;
00159 return;
00160 }
00161 if ((fillsi > 0) && (fillsi < 26)) {
00162 x[0] = x1; y[0] = y1;
00163 x[1] = x2; y[1] = y1;
00164 x[2] = x2; y[2] = y2;
00165 x[3] = x1; y[3] = y2;
00166 DrawPS(-4, &x[0], &y[0]);
00167 }
00168 if (fillsi == -3) {
00169
00170 }
00171 }
00172
00173 if (fillis == 1) {
00174 fImage->DrawBox(ix1, iy1, ix2, iy2, col->AsHexString(), 1, TVirtualX::kFilled);
00175 }
00176
00177 if (fillis == 0) {
00178 fImage->DrawBox(ix1, iy1, ix2, iy2, linecol->AsHexString(), fLineWidth, TVirtualX::kHollow);
00179 }
00180 }
00181
00182
00183 void TImageDump::DrawFrame(Double_t x1, Double_t y1, Double_t x2, Double_t y2,
00184 Int_t mode, Int_t bordersize, Int_t dark, Int_t light)
00185 {
00186
00187
00188
00189
00190
00191
00192
00193
00194 if (!gPad || !fImage) {
00195 return;
00196 }
00197
00198 fImage->BeginPaint();
00199
00200 bordersize = bordersize < 1 ? 1 : bordersize;
00201
00202 TColor *col;
00203 TColor *lo = gROOT->GetColor(dark);
00204 if (!lo) {
00205 lo = gROOT->GetColor(10);
00206 }
00207 TColor *hi = gROOT->GetColor(light);
00208 if (!hi) {
00209 hi = gROOT->GetColor(10);
00210 }
00211
00212 Short_t pxl,pyl,pxt,pyt,px1,py1,px2,py2;
00213 Double_t xl, xt, yl, yt;
00214
00215 px1 = XtoPixel(x1); py1 = YtoPixel(y1);
00216 px2 = XtoPixel(x2); py2 = YtoPixel(y2);
00217 if (px1 < px2) {pxl = px1; pxt = px2; xl = x1; xt = x2; }
00218 else {pxl = px2; pxt = px1; xl = x2; xt = x1;}
00219 if (py1 > py2) {pyl = py1; pyt = py2; yl = y1; yt = y2;}
00220 else {pyl = py2; pyt = py1; yl = y2; yt = y1;}
00221
00222 if (bordersize == 1) {
00223 col = gROOT->GetColor(fLineColor);
00224 if (!col) {
00225 fLineColor = 1;
00226 col = gROOT->GetColor(fLineColor);
00227 }
00228 fImage->DrawBox(pxl, pyl, pxt, pyt-1, col->AsHexString(), TVirtualX::kFilled);
00229 return;
00230 }
00231
00232 if (!fImage->IsValid()) {
00233 col = gROOT->GetColor(light);
00234 if (!col) {
00235 col = gROOT->GetColor(10);
00236 if (!col) return;
00237 }
00238 fImage->DrawBox(pxl, pyl, pxt, pyt,
00239 "#ffffffff", 1, TVirtualX::kFilled);
00240 }
00241
00242 TPoint frame[6];
00243
00244 frame[0].fX = pxl; frame[0].fY = pyl;
00245 frame[1].fX = pxl + bordersize; frame[1].fY = pyl - bordersize;
00246 frame[2].fX = pxl + bordersize; frame[2].fY = pyt + bordersize;
00247 frame[3].fX = pxt - bordersize; frame[3].fY = pyt + bordersize;;
00248 frame[4].fX = pxt; frame[4].fY = pyt;
00249 frame[5].fX = pxl; frame[5].fY = pyt;
00250
00251 if (mode == -1) col = lo;
00252 else col = hi;
00253
00254 fImage->DrawFillArea(6, frame, col->AsHexString());
00255
00256 frame[0].fX = pxl; frame[0].fY = pyl;
00257 frame[1].fX = pxl + bordersize; frame[1].fY = pyl - bordersize;
00258 frame[2].fX = pxt - bordersize; frame[2].fY = frame[1].fY;
00259 frame[3].fX = frame[2].fX; frame[3].fY = pyt + bordersize;
00260 frame[4].fX = pxt; frame[4].fY = pyt;
00261 frame[5].fX = pxt; frame[5].fY = pyl;
00262
00263 if (mode == -1) col = hi;
00264 else col = lo;
00265
00266 fImage->DrawFillArea(6, frame, col->AsHexString());
00267 }
00268
00269
00270 void TImageDump::DrawPolyMarker(Int_t, Float_t *, Float_t *)
00271 {
00272
00273
00274 if (!gPad || !fImage) {
00275 return;
00276 }
00277 }
00278
00279
00280 void TImageDump::DrawPolyMarker(Int_t n, Double_t *xw, Double_t *yw)
00281 {
00282
00283
00284 if (!gPad || !fImage) {
00285 return;
00286 }
00287
00288 fImage->BeginPaint();
00289
00290 Int_t ms = TMath::Abs(fMarkerStyle);
00291 static TPoint pt[20];
00292
00293 if (ms > 7 && ms <= 19) ms = 20;
00294 if (ms == 4) ms = 24;
00295
00296
00297 const Int_t kBASEMARKER = 8;
00298 Double_t msize = fMarkerSize * kBASEMARKER;
00299 if (ms == 6) msize *= 0.2;
00300 if (ms == 7) msize *= 0.3;
00301 Double_t m = msize;
00302 Double_t m2 = m/2;
00303 Double_t m3 = m/3;
00304 Double_t m6 = m/6;
00305
00306 TColor *col = gROOT->GetColor(fMarkerColor);
00307 if (!col) {
00308 fMarkerColor = 1;
00309 col = gROOT->GetColor(fMarkerColor);
00310 }
00311
00312
00313 Short_t ix,iy;
00314 for (Int_t i=0;i<n;i++) {
00315 ix = XtoPixel(xw[i]);
00316 iy = YtoPixel(yw[i]);
00317
00318 switch (ms) {
00319
00320 case 7:
00321 fImage->PutPixel((UInt_t)ix-1, (UInt_t)iy-1, col->AsHexString());
00322 fImage->PutPixel((UInt_t)ix-1, (UInt_t)iy+1, col->AsHexString());
00323 fImage->PutPixel((UInt_t)ix+1, (UInt_t)iy+1, col->AsHexString());
00324 fImage->PutPixel((UInt_t)ix+1, (UInt_t)iy-1, col->AsHexString());
00325 case 6:
00326 fImage->PutPixel((UInt_t)ix, (UInt_t)iy-1, col->AsHexString());
00327 fImage->PutPixel((UInt_t)ix, (UInt_t)iy+1, col->AsHexString());
00328 fImage->PutPixel((UInt_t)ix-1, (UInt_t)iy, col->AsHexString());
00329 fImage->PutPixel((UInt_t)ix+1, (UInt_t)iy, col->AsHexString());
00330 case 1:
00331 fImage->PutPixel((UInt_t)ix, (UInt_t)iy, col->AsHexString());
00332 break;
00333
00334 case 2:
00335 fImage->DrawLine(UInt_t(ix-m2), UInt_t(iy), UInt_t(ix+m2), UInt_t(iy), col->AsHexString());
00336 fImage->DrawLine(UInt_t(ix), UInt_t(iy-m2), UInt_t(ix), UInt_t(iy+m2), col->AsHexString());
00337 break;
00338
00339 case 5:
00340 fImage->DrawLine(UInt_t(ix-m2), UInt_t(iy-m2), UInt_t(ix+m2), UInt_t(iy+m2), col->AsHexString());
00341 fImage->DrawLine(UInt_t(ix-m2), UInt_t(iy+m2), UInt_t(ix+m2), UInt_t(iy-m2), col->AsHexString());
00342 break;
00343
00344 case 3:
00345 case 31:
00346 fImage->DrawLine(UInt_t(ix-m2), UInt_t(iy), UInt_t(ix+m2), UInt_t(iy), col->AsHexString());
00347 fImage->DrawLine(UInt_t(ix), UInt_t(iy-m2), UInt_t(ix), UInt_t(iy+m2), col->AsHexString());
00348 fImage->DrawLine(UInt_t(ix-m2), UInt_t(iy-m2), UInt_t(ix+m2), UInt_t(iy+m2), col->AsHexString());
00349 fImage->DrawLine(UInt_t(ix-m2), UInt_t(iy+m2), UInt_t(ix+m2), UInt_t(iy-m2), col->AsHexString());
00350 break;
00351
00352 case 4:
00353 case 24:
00354 fImage->DrawCircle(ix, iy, Int_t(msize/2), col->AsHexString(), 1);
00355 break;
00356
00357 case 8:
00358 case 20:
00359 fImage->DrawCircle(ix, iy, Int_t(msize/2), col->AsHexString(), -1);
00360 break;
00361
00362 case 21:
00363 fImage->FillRectangle(col->AsHexString(), UInt_t(ix-m2), UInt_t(iy-m2), UInt_t(m), UInt_t(m));
00364 break;
00365 case 25:
00366 fImage->DrawRectangle(UInt_t(ix-m2), UInt_t(iy-m2), UInt_t(m), UInt_t(m), col->AsHexString());
00367 break;
00368
00369 case 23:
00370 case 32:
00371 pt[0].fX = Short_t(ix-m2); pt[0].fY = Short_t(iy-m2);
00372 pt[1].fX = Short_t(ix+m2); pt[1].fY = Short_t(iy-m2);
00373 pt[2].fX = Short_t(ix); pt[2].fY = Short_t(iy+m2);
00374 pt[3].fX = Short_t(ix-m2); pt[3].fY = Short_t(iy-m2);
00375 ms == 32 ? fImage->DrawPolyLine(4, pt, col->AsHexString()) :
00376 fImage->FillPolygon(3, pt, col->AsHexString());
00377 break;
00378
00379 case 22:
00380 case 26:
00381 pt[0].fX = Short_t(ix); pt[0].fY = Short_t(iy-m2);
00382 pt[1].fX = Short_t(ix+m2); pt[1].fY = Short_t(iy+m2);
00383 pt[2].fX = Short_t(ix-m2); pt[2].fY = Short_t(iy+m2);
00384 pt[3].fX = Short_t(ix); pt[3].fY = Short_t(iy-m2);
00385 ms == 26 ? fImage->DrawPolyLine(4, pt, col->AsHexString()) :
00386 fImage->FillPolygon(3, pt, col->AsHexString());
00387 break;
00388 case 27:
00389 case 33:
00390 pt[0].fX = Short_t(ix); pt[0].fY = Short_t(iy-m2);
00391 pt[1].fX = Short_t(ix+m3); pt[1].fY = Short_t(iy);
00392 pt[2].fX = Short_t(ix); pt[2].fY = Short_t(iy+m2);
00393 pt[3].fX = Short_t(ix-m3); pt[3].fY = Short_t(iy);
00394 pt[4].fX = Short_t(ix); pt[4].fY = Short_t(iy-m2);
00395 ms == 27 ? fImage->DrawPolyLine(5, pt, col->AsHexString()) :
00396 fImage->FillPolygon(4, pt, col->AsHexString());
00397 break;
00398 case 28:
00399 case 34:
00400 pt[0].fX = Short_t(ix-m6); pt[0].fY = Short_t(iy-m6);
00401 pt[1].fX = Short_t(ix-m6); pt[1].fY = Short_t(iy-m2);
00402 pt[2].fX = Short_t(ix+m6); pt[2].fY = Short_t(iy-m2);
00403 pt[3].fX = Short_t(ix+m6); pt[3].fY = Short_t(iy-m6);
00404 pt[4].fX = Short_t(ix+m2); pt[4].fY = Short_t(iy-m6);
00405 pt[5].fX = Short_t(ix+m2); pt[5].fY = Short_t(iy+m6);
00406 pt[6].fX = Short_t(ix+m6); pt[6].fY = Short_t(iy+m6);
00407 pt[7].fX = Short_t(ix+m6); pt[7].fY = Short_t(iy+m2);
00408 pt[8].fX = Short_t(ix-m6); pt[8].fY = Short_t(iy+m2);
00409 pt[9].fX = Short_t(ix-m6); pt[9].fY = Short_t(iy+m6);
00410 pt[10].fX = Short_t(ix-m2); pt[10].fY = Short_t(iy+m6);
00411 pt[11].fX = Short_t(ix-m2); pt[11].fY = Short_t(iy-m6);
00412 pt[12].fX = Short_t(ix-m6); pt[12].fY = Short_t(iy-m6);
00413 ms == 28 ? fImage->DrawPolyLine(13, pt, col->AsHexString()) :
00414 fImage->FillPolygon(12, pt, col->AsHexString());
00415 break;
00416 case 29:
00417 case 30:
00418 pt[0].fX = Short_t(ix); pt[0].fY = Short_t(iy+m2);
00419 pt[1].fX = Short_t(ix+0.112255*m); pt[1].fY = Short_t(iy+0.15451*m);
00420 pt[2].fX = Short_t(ix+0.47552*m); pt[2].fY = Short_t(iy+0.15451*m);
00421 pt[3].fX = Short_t(ix+0.181635*m); pt[3].fY = Short_t(iy-0.05902*m);
00422 pt[4].fX = Short_t(ix+0.29389*m); pt[4].fY = Short_t(iy-0.40451*m);
00423 pt[5].fX = Short_t(ix); pt[5].fY = Short_t(iy-0.19098*m);
00424 pt[6].fX = Short_t(ix-0.29389*m); pt[6].fY = Short_t(iy-0.40451*m);
00425 pt[7].fX = Short_t(ix-0.181635*m); pt[7].fY = Short_t(iy-0.05902*m);
00426 pt[8].fX = Short_t(ix-0.47552*m); pt[8].fY = Short_t(iy+0.15451*m);
00427 pt[9].fX = Short_t(ix-0.112255*m); pt[9].fY = Short_t(iy+0.15451*m);
00428 pt[10].fX = Short_t(ix); pt[10].fY = Short_t(iy+m2);
00429 ms == 30 ? fImage->DrawPolyLine(11, pt, col->AsHexString()) :
00430 fImage->DrawFillArea(10, pt, col->AsHexString());
00431 break;
00432 default:
00433 fImage->PutPixel(UInt_t(ix), UInt_t(iy), col->AsHexString());
00434 break;
00435 }
00436 }
00437 }
00438
00439
00440 void TImageDump::DrawPS(Int_t nn, Double_t *x, Double_t *y)
00441 {
00442
00443
00444
00445
00446
00447
00448 if (!gPad || !fImage || !nn) {
00449 return;
00450 }
00451
00452 fImage->BeginPaint();
00453
00454 TColor *col = 0;
00455 Int_t fais = 0 , fasi = 0;
00456 Bool_t line = nn > 1;
00457 UInt_t n = TMath::Abs(nn);
00458
00459 fais = fFillStyle/1000;
00460 fasi = fFillStyle%1000;
00461
00462 Short_t px1, py1, px2, py2;
00463 static const UInt_t gCachePtSize = 200;
00464 static TPoint gPointCache[gCachePtSize];
00465 Bool_t del = kTRUE;
00466
00467
00468
00469 Int_t ndashes = 0;
00470 char *dash = 0;
00471 static char dashList[10];
00472 Int_t dashLength = 0;
00473 Int_t dashSize = 0;
00474
00475 if (line) {
00476
00477 if (fLineStyle > 1) {
00478 TString st = gStyle->GetLineStyleString(fLineStyle);
00479 TObjArray *tokens = st.Tokenize(" ");
00480 ndashes = tokens->GetEntries();
00481 dash = new char[ndashes];
00482
00483 for (int j = 0; j < ndashes; j++) {
00484 Int_t it;
00485 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
00486 dash[j] = (char)(it/4);
00487 }
00488
00489 dashSize = TMath::Min((int)sizeof(dashList), ndashes);
00490 dashLength = 0;
00491 for (int i = 0; i < dashSize; i++ ) {
00492 dashList[i] = dash[i];
00493 dashLength += dashList[i];
00494 }
00495 delete tokens;
00496 delete [] dash;
00497 }
00498
00499
00500 col = gROOT->GetColor(fLineColor);
00501 if (!col) {
00502 fLineColor = 1;
00503 col = gROOT->GetColor(fLineColor);
00504 if (!col) return;
00505 }
00506 }
00507
00508 if (n == 1) {
00509 col = gROOT->GetColor(fFillColor);
00510 if (!col) {
00511 fFillColor = 1;
00512 col = gROOT->GetColor(fFillColor);
00513 }
00514 px1 = XtoPixel(x[0]); py1 = YtoPixel(y[0]);
00515 fImage->PutPixel(px1, py1, col->AsHexString());
00516 return;
00517 }
00518
00519 if (n == 2) {
00520 px1 = XtoPixel(x[0]); py1 = YtoPixel(y[0]);
00521 px2 = XtoPixel(x[1]); py2 = YtoPixel(y[1]);
00522
00523
00524 col = gROOT->GetColor(fLineColor);
00525 if (!col) {
00526 fLineColor = 1;
00527 col = gROOT->GetColor(fLineColor);
00528 }
00529 if (fLineStyle < 2) {
00530 fImage->DrawLine(px1, py1, px2, py2, col->AsHexString(), fLineWidth);
00531 } else {
00532 fImage->DrawDashLine(px1, py1, px2, py2, dashSize, (const char*)dashList,
00533 col->AsHexString(), fLineWidth);
00534 }
00535 return;
00536 }
00537
00538 if (!line && ((fais == 3) || (fais == 2)) && (fasi > 100) ) {
00539 return;
00540 }
00541
00542 TPoint *pt = 0;
00543 if (n+1 < gCachePtSize) {
00544 pt = (TPoint*)&gPointCache;
00545 del = kFALSE;
00546 } else {
00547 pt = new TPoint[n+1];
00548 del = kTRUE;
00549 }
00550
00551 TColor *fcol = gROOT->GetColor(fFillColor);
00552 if (!fcol) {
00553 fFillColor = 10;
00554 fcol = gROOT->GetColor(fFillColor);
00555 }
00556
00557 TColor *lcol = gROOT->GetColor(fLineColor);
00558 if (!lcol) {
00559 fLineColor = 1;
00560 lcol = gROOT->GetColor(fLineColor);
00561 }
00562
00563 for (UInt_t i = 0; i < n; i++) {
00564 pt[i].fX = XtoPixel(x[i]);
00565 pt[i].fY = YtoPixel(y[i]);
00566 }
00567 pt[n].fX = pt[0].fX;
00568 pt[n].fY = pt[0].fY;
00569
00570 const char *stipple = (fais == 3) && (fasi > 0) && (fasi < 26) ? (const char*)gStipples[fasi] : 0;
00571
00572
00573 if (!line && fFillStyle && (fFillStyle != 4000)) {
00574 if (!fcol) return;
00575
00576 if (n < 5) {
00577 fImage->FillPolygon(n, pt, fcol->AsHexString(), stipple);
00578 } else {
00579 fImage->DrawFillArea(n, pt, fcol->AsHexString(), stipple);
00580 }
00581 }
00582
00583
00584 if (line || !fFillStyle || (fFillStyle == 4000)) {
00585 if (!lcol) return;
00586 if (!line) {
00587 fImage->DrawPolyLine(n+1, pt, fcol->AsHexString(), 1);
00588 } else {
00589 if (fLineStyle < 2) {
00590 fImage->DrawPolyLine(n, pt, lcol->AsHexString(), fLineWidth);
00591 } else {
00592 DrawDashPolyLine(n, pt, dashSize, (const char*)dashList,
00593 lcol->AsHexString(), fLineWidth);
00594 }
00595 }
00596 }
00597 if (del) delete [] pt;
00598 }
00599
00600
00601 void TImageDump::DrawPS(Int_t, Float_t *, Float_t *)
00602 {
00603
00604
00605 if (!gPad || !fImage) {
00606 return;
00607 }
00608 }
00609
00610 void TImageDump::DrawDashPolyLine(Int_t nn, TPoint *xy, UInt_t nDash,
00611 const char* pDash, const char* col, UInt_t thick)
00612 {
00613
00614
00615 Int_t x0 = xy[0].GetX();
00616 Int_t y0 = xy[0].GetY();
00617 Int_t x = 0;
00618 Int_t y = 0;
00619
00620 for (Int_t i = 1; i < nn; i++) {
00621 x = xy[i].GetX();
00622 y = xy[i].GetY();
00623
00624 fImage->DrawDashLine(x0, y0, x, y, nDash, pDash, col, thick);
00625
00626 x0 = x;
00627 y0 = y;
00628 }
00629 }
00630
00631
00632 void TImageDump::NewPage()
00633 {
00634
00635
00636 if (gPad && fImage) {
00637 UInt_t w = UInt_t(gPad->GetWw()*gPad->GetWNDC());
00638 UInt_t h = UInt_t(gPad->GetWh()*gPad->GetHNDC());
00639 fImage->DrawRectangle(0, 0, w, h, "#ffffffff");
00640 }
00641 return;
00642 }
00643
00644
00645 void TImageDump::Text(Double_t x, Double_t y, const char *chars)
00646 {
00647
00648
00649
00650
00651
00652 if (!gPad || !fImage) {
00653 return;
00654 }
00655
00656 fImage->BeginPaint();
00657
00658 TText t(x, y, chars);
00659 t.SetTextSize(fTextSize);
00660 t.SetTextFont(fTextFont);
00661 t.SetTextAlign(fTextAlign);
00662 t.SetTextAngle(fTextAngle);
00663 t.SetTextColor(fTextColor);
00664 fImage->DrawText(&t, XtoPixel(x), YtoPixel(y));
00665 }
00666
00667
00668
00669 static UInt_t *gCellArrayColors = 0;
00670 static Int_t gCellArrayN = 0;
00671 static Int_t gCellArrayW = 0;
00672 static Int_t gCellArrayH = 0;
00673 static Int_t gCellArrayX1 = 0;
00674 static Int_t gCellArrayX2 = 0;
00675 static Int_t gCellArrayY1 = 0;
00676 static Int_t gCellArrayY2 = 0;
00677 static Int_t gCellArrayIdx = 0;
00678
00679
00680 void TImageDump::CellArrayBegin(Int_t w, Int_t h, Double_t x1, Double_t x2,
00681 Double_t y1, Double_t y2)
00682 {
00683
00684
00685 if (!gPad || !fImage || (w <= 0) || (h <= 0)) {
00686 return;
00687 }
00688
00689 if (gCellArrayColors) {
00690 delete [] gCellArrayColors;
00691 }
00692
00693 fImage->BeginPaint();
00694
00695 gCellArrayN = w * h;
00696 gCellArrayW = w;
00697 gCellArrayH = h;
00698 gCellArrayColors = new UInt_t[gCellArrayN];
00699
00700 gCellArrayX1 = x1 < x2 ? XtoPixel(x1) : XtoPixel(x2);
00701 gCellArrayX2 = x1 > x2 ? XtoPixel(x2) : XtoPixel(x1);
00702 gCellArrayY1 = y1 < y2 ? YtoPixel(y1) : YtoPixel(y2);
00703 gCellArrayY2 = y1 < y2 ? YtoPixel(y2) : YtoPixel(y1);
00704
00705 gCellArrayIdx = 0;
00706 }
00707
00708
00709 void TImageDump::CellArrayFill(Int_t r, Int_t g, Int_t b)
00710 {
00711
00712
00713 if (gCellArrayIdx >= gCellArrayN) return;
00714
00715 fImage->BeginPaint();
00716
00717 gCellArrayColors[gCellArrayIdx] = ((r & 0xFF) << 16) + ((g & 0xFF) << 8) + (b & 0xFF);
00718 gCellArrayIdx++;
00719 }
00720
00721
00722 void TImageDump::CellArrayEnd()
00723 {
00724
00725
00726 if (!fImage || !gCellArrayColors || !gCellArrayW || !gCellArrayH) {
00727 return;
00728 }
00729
00730 fImage->BeginPaint();
00731
00732 fImage->DrawCellArray(gCellArrayX1, gCellArrayX2, gCellArrayY1, gCellArrayY2,
00733 gCellArrayW, gCellArrayH, gCellArrayColors);
00734
00735 delete [] gCellArrayColors;
00736 gCellArrayColors = 0;
00737 gCellArrayN = 0;
00738 gCellArrayW = 0;
00739 gCellArrayH = 0;
00740 gCellArrayX1 = 0;
00741 gCellArrayX2 = 0;
00742 gCellArrayY1 = 0;
00743 gCellArrayY2 = 0;
00744 gCellArrayIdx = 0;
00745 }
00746
00747
00748 void TImageDump::SetColor(Float_t , Float_t , Float_t )
00749 {
00750
00751
00752
00753
00754
00755
00756 }
00757
00758
00759 Int_t TImageDump::XtoPixel(Double_t x)
00760 {
00761
00762
00763 return gPad->XtoAbsPixel(x);
00764 }
00765
00766
00767 Int_t TImageDump::YtoPixel(Double_t y)
00768 {
00769
00770
00771 return gPad->YtoAbsPixel(y);
00772 }