Changeset 1965 for trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
- Timestamp:
- 04/19/03 18:39:05 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
r1906 r1965 38 38 39 39 #include <TBox.h> 40 #include <TText.h>41 40 #include <TArrow.h> 41 #include <TLatex.h> 42 42 #include <TStyle.h> 43 43 #include <TCanvas.h> 44 //#include <TButton.h>45 44 #include <TClonesArray.h> 46 45 46 #include "MH.h" 47 47 #include "MHexagon.h" 48 48 … … 63 63 // ------------------------------------------------------------------------ 64 64 // 65 // default constructor 65 // Default Constructor. To be used by the root system ONLY. 66 // 67 MCamDisplay::MCamDisplay() 68 : fGeomCam(NULL), fAutoScale(kTRUE), fW(0), fH(0) 69 { 70 fNumPixels = 0; 71 fRange = 0; 72 73 fPixels = NULL; 74 fLegend = NULL; 75 fLegText = NULL; 76 fArrowX = NULL; 77 fArrowY = NULL; 78 fLegRadius = NULL; 79 fLegDegree = NULL; 80 } 81 82 // ------------------------------------------------------------------------ 83 // 84 // Constructor. Makes a clone of MGeomCam. 66 85 // 67 86 MCamDisplay::MCamDisplay(MGeomCam *geom) 68 : f AutoScale(kTRUE), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)69 { 70 fGeomCam = (MGeomCam*)geom ; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone();87 : fGeomCam(NULL), fAutoScale(kTRUE), fW(0), fH(0) 88 { 89 fGeomCam = (MGeomCam*)geom->Clone(); 71 90 72 91 // 73 92 // create the hexagons of the display 74 93 // 75 fNumPixels = geom->GetNumPixels(); 76 fRange = geom->GetMaxRadius(); 77 78 // 79 // Construct all hexagons. Use new-operator with placement 80 // 94 fNumPixels = fGeomCam->GetNumPixels(); 95 fRange = fGeomCam->GetMaxRadius(); 81 96 82 97 // root 3.02 … … 85 100 // not get an automatic context menu when clicked with the right mouse button. 86 101 102 // 103 // Construct all hexagons. Use new-operator with placement 104 // 87 105 fPixels = new TClonesArray("MHexagon", fNumPixels); 88 106 for (UInt_t i=0; i<fNumPixels; i++) 89 new ((*fPixels)[i]) MHexagon((*geom)[i]); 90 91 // 92 // set the color palette for the TBox elements 93 // 107 { 108 MHexagon &pix = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]); 109 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 110 pix.SetBit(/*kNoContextMenu|*/kCannotPick); 111 #endif 112 pix.SetFillColor(16); 113 } 114 115 // 116 // set up the Legend 117 // 118 const Float_t H = 0.9*fRange; 119 const Float_t h = 2./kItemsLegend; 120 121 const Float_t w = fRange/sqrt(fNumPixels); 122 123 fLegend = new TClonesArray("TBox", kItemsLegend); 124 fLegText = new TClonesArray("TText", kItemsLegend); 125 126 for (Int_t i = 0; i<kItemsLegend; i++) 127 { 128 TBox &newbox = *new ((*fLegend)[i]) TBox; 129 TText &newtxt = *new ((*fLegText)[i]) TText; 130 131 newbox.SetX1(fRange); 132 newbox.SetX2(fRange+w); 133 newbox.SetY1(H*( i *h - 1.)); 134 newbox.SetY2(H*((i+1)*h - 1.)); 135 newbox.SetFillColor(16); 136 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 137 newbox.SetBit(/*kNoContextMenu|*/kCannotPick); 138 #endif 139 140 newtxt.SetTextSize(0.025); 141 newtxt.SetTextAlign(12); 142 newtxt.SetX(fRange+1.5*w); 143 newtxt.SetY(H*((i+0.5)*h - 1.)); 144 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 145 newtxt.SetBit(/*kNoContextMenu|*/kCannotPick); 146 #endif 147 } 148 149 fArrowX = new TArrow(-fRange*.9, -fRange*.9, -fRange*.6, -fRange*.9, 0.025); 150 fArrowY = new TArrow(-fRange*.9, -fRange*.9, -fRange*.9, -fRange*.6, 0.025); 151 152 TString text; 153 text += (int)(fRange*.3); 154 text += "mm"; 155 156 fLegRadius = new TText(-fRange*.85, -fRange*.85, text); 157 text = ""; 158 text += (float)((int)(fRange*.3*fGeomCam->GetConvMm2Deg()*10))/10; 159 text += "\\circ"; 160 text = text.Strip(TString::kLeading); 161 fLegDegree = new TLatex(-fRange*.85, -fRange*.75, text); 162 fLegRadius->SetTextSize(0.04); 163 fLegDegree->SetTextSize(0.04); 164 94 165 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06) 95 166 SetPalette(1, 0); … … 98 169 #endif 99 170 100 //101 // set up the Legend102 //103 fLegend = new TClonesArray("TBox", kItemsLegend);104 fLegText = new TClonesArray("TText", kItemsLegend);105 106 for (Int_t i = 0; i<kItemsLegend; i++)107 {108 TBox *newbox = new ((*fLegend)[i]) TBox;109 TText *newtxt = new ((*fLegText)[i]) TText;110 111 newbox->SetFillColor(fColors[i]);112 113 newtxt->SetTextSize(0.025);114 newtxt->SetTextAlign(12);115 }116 117 fArrowX = new TArrow(-fRange*.9, -fRange*.9, -fRange*.6, -fRange*.9, 0.025);118 fArrowY = new TArrow(-fRange*.9, -fRange*.9, -fRange*.9, -fRange*.6, 0.025);119 120 TString text;121 text += (int)(fRange*.3);122 text += "mm";123 124 fLegRadius = new TText(-fRange*.85, -fRange*.85, text);125 text = "";126 text += (float)((int)(fRange*.3*geom->GetConvMm2Deg()*10))/10;127 text += "°";128 text = text.Strip(TString::kLeading);129 fLegDegree = new TText(-fRange*.85, -fRange*.75, text);130 fLegRadius->SetTextSize(0.04);131 fLegDegree->SetTextSize(0.04);132 171 } 133 172 … … 152 191 delete fLegDegree; 153 192 154 // delete fGeomCam; 155 156 // Not allocated by MCamDisplay or already deleted by the user 157 if (!fIsAllocated || !gROOT->GetListOfCanvases()->FindObject(fDrawingPad)) 158 return; 159 160 // If it is not already removed make sure that nothing of this object 161 // maybe be deleted automatically by the canvas destructor 162 if (!fDrawingPad->GetListOfPrimitives()->FindObject(this)) 163 return; 164 165 fDrawingPad->RecursiveRemove(this); 166 delete fDrawingPad; 193 delete fGeomCam; 167 194 } 168 195 … … 237 264 // ------------------------------------------------------------------------ 238 265 // 266 // Call this function to draw the camera layout into your canvas. 267 // Setup a drawing canvas. Add this object and all child objects 268 // (hexagons, etc) to the current pad. If no pad exists a new one is 269 // created. 270 // 271 void MCamDisplay::Draw(Option_t *option) 272 { 273 // root 3.02: 274 // gPad->SetFixedAspectRatio() 275 276 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 750, 600); 277 pad->SetBorderMode(0); 278 pad->SetFillColor(16); 279 280 // 281 // All this is necessary to get the background in the correct color 282 // 283 pad->Divide(1,1); 284 pad->cd(1); 285 286 gPad->SetBorderMode(0); 287 gPad->SetFillColor(16); 288 289 // 290 // set the color palette for the TBox elements 291 // 292 AppendPad(""); 293 294 // 295 // Necessary to visualize the background color (FIXME?) 296 // 297 gPad->Modified(); 298 gPad->Update(); 299 } 300 301 302 void MCamDisplay::SetRange() 303 { 304 // 305 // Maintain aspect ratio 306 // 307 const float ratio = 1.15; 308 309 const float w = gPad->GetWw(); 310 const float h = gPad->GetWh()*ratio; 311 312 if (h<w) 313 gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 0.9999999); 314 else 315 gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2); 316 317 gPad->Range(-fRange, -fRange, (2*ratio-1)*fRange, fRange); 318 } 319 320 // ------------------------------------------------------------------------ 321 // 239 322 // This is called at any time the canvas should get repainted. 240 // Here we maintain an aspect ratio of 5/4=1.15. This makes sure,323 // Here we maintain an aspect ratio of 1.15. This makes sure, 241 324 // that the camera image doesn't get distorted by resizing the canvas. 242 325 // 243 326 void MCamDisplay::Paint(Option_t *opt) 244 327 { 245 const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC()); 246 const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC()); 247 248 // 249 // Check for a change in width or height, and make sure, that the 250 // first call also sets the range 251 // 252 if (w*fH == h*fW && fW && fH) 328 if (!fPixels) 253 329 return; 254 330 255 331 // 256 // Calculate aspect ratio (5/4=1.25 recommended) 257 // 258 const Double_t ratio = (Double_t)w/h; 259 260 Float_t x; 261 Float_t y; 262 263 if (ratio>1.25) 264 { 265 x = (ratio*2-1)*fRange; 266 y = fRange; 267 } 268 else 269 { 270 x = fRange*1.5; 271 y = fRange*1.25/ratio; 272 } 273 274 fH = h; 275 fW = w; 276 277 // 278 // Set new range 279 // 280 gPad->Range(-fRange, -y, x, y); 281 282 // 283 // Make sure, that the correct aspect is always displayed also 284 // if - by chance - there is not update for the pad after the 285 // Paint function was called. 286 // 287 gPad->Update(); 332 // Maintain aspect ratio 333 // 334 SetRange(); 335 336 // 337 // Maintain colors 338 // 339 SetPalette(); 340 341 // 342 // Paint primitives 343 // 344 for (UInt_t i=0; i<fNumPixels; i++) 345 (*this)[i].Paint(); 346 347 for (Int_t i=0; i<kItemsLegend; i++) 348 { 349 GetBox(i)->Paint(); 350 GetText(i)->Paint(); 351 } 352 353 fArrowX->Paint(">"); 354 fArrowY->Paint(">"); 355 356 fLegRadius->Paint(); 357 fLegDegree->Paint(); 288 358 } 289 359 … … 321 391 gStyle->SetPalette(ncolors, colors); 322 392 323 if (fDrawingPad) 393 // 394 // Change the colors of the pixels 395 // 396 for (unsigned int i=0; i<fNumPixels; i++) 324 397 { 325 398 // 326 // Set the colors of the legend 399 // Get the old color index and check whether it is 400 // background or transparent 327 401 // 328 for (int i=0; i<kItemsLegend; i++) 402 Int_t col = (*this)[i].GetFillColor(); 403 if (col==10 || col==16) 404 continue; 405 406 // 407 // Search for the color index (level) in the color table 408 // 409 int idx; 410 for (idx=0; idx<kItemsLegend; idx++) 411 if (col==fColors[idx]) 412 break; 413 414 // 415 // Should not happen 416 // 417 if (idx==kItemsLegend) 329 418 { 330 Int_t col = GetBox(i)->GetFillColor(); 331 332 // 333 // Make sure, that the legend is already colored 334 // 335 if (col==10 || col==22) 336 continue; 337 GetBox(i)->SetFillColor(gStyle->GetColorPalette(i)); 419 cout << "MCamDisplay::SetPalette: Strange... FIXME!" << endl; 420 continue; 338 421 } 339 422 340 423 // 341 // C hange the colors of the pixels424 // Convert the old color index (level) into the new one 342 425 // 343 for (unsigned int i=0; i<fNumPixels; i++) 344 { 345 // 346 // Get the old color index and check whether it is 347 // background or transparent 348 // 349 Int_t col = (*this)[i].GetFillColor(); 350 if (col==10 || col==22) 351 continue; 352 353 // 354 // Search for the color index (level) in the color table 355 // 356 int idx; 357 for (idx=0; idx<kItemsLegend; idx++) 358 if (col==fColors[idx]) 359 break; 360 // 361 // Should not happen 362 // 363 if (idx==kItemsLegend) 364 { 365 cout << "MCamDisplay::SetPalette: Strange... FIXME!" << endl; 366 continue; 367 } 368 369 // 370 // Convert the old color index (level) into the new one 371 // 372 (*this)[i].SetFillColor(gStyle->GetColorPalette(idx)); 373 } 374 375 // 376 // Update the pad on the screen 377 // 378 fDrawingPad->Modified(); 379 fDrawingPad->Update(); 426 (*this)[i].SetFillColor(gStyle->GetColorPalette(idx)); 380 427 } 381 428 … … 384 431 // 385 432 for (int i=0; i<kItemsLegend; i++) 433 { 386 434 fColors[i] = gStyle->GetColorPalette(i); 435 GetBox(i)->SetFillColor(fColors[i]); 436 } 387 437 } 388 438 … … 402 452 } 403 453 404 // ------------------------------------------------------------------------ 405 // 406 // Call this function to draw the camera layout into your canvas. 407 // Setup a drawing canvas. Add this object and all child objects 408 // (hexagons, etc) to the current pad. If no pad exists a new one is 409 // created. 410 // 411 void MCamDisplay::Draw(Option_t *option) 412 { 413 // root 3.02: 414 // gPad->SetFixedAspectRatio() 415 416 if (fDrawingPad) 417 return; 418 419 // 420 // if no canvas is yet existing to draw into, create a new one 421 // 454 void MCamDisplay::SetPalette() 455 { 456 for (int i=0; i<kItemsLegend; i++) 457 GetBox(i)->SetFillColor(fColors[i]); 458 } 459 460 void MCamDisplay::DrawPixelNumbers() 461 { 462 for (int i=0; i<kItemsLegend; i++) 463 fColors[i] = 16; 464 422 465 if (!gPad) 423 {424 fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 750, 600);425 fIsAllocated = kTRUE;426 }427 else428 {429 fDrawingPad = gPad;430 fIsAllocated = kFALSE;431 }432 433 //434 // Setup the correct environment435 //436 fDrawingPad->SetBorderMode(0);437 fDrawingPad->SetFillColor(22);438 439 //440 // Set the initial coordinate range441 //442 Paint();443 444 /*445 //446 // Create and draw the buttons which allows changing the447 // color palette of the display448 //449 TButton *but;450 char txt[100];451 sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(1,0);", this);452 but = new TButton("Pretty", txt, 0.01, 0.95, 0.15, 0.99);453 but->Draw();454 sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(51,0);", this);455 but = new TButton("Deap Sea", txt, 0.16, 0.95, 0.30, 0.99);456 but->Draw();457 sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(52,0);", this);458 but = new TButton("Blue Inv", txt, 0.31, 0.95, 0.45, 0.99);459 but->Draw();460 */461 462 //463 // Draw all pixels of the camera464 // (means apend all pixelobjects to the current pad)465 //466 for (UInt_t i=0; i<fNumPixels; i++)467 {468 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)469 (*this)[i].SetBit(/*kNoContextMenu|*/kCannotPick);470 #endif471 (*this)[i].SetFillColor(22);472 (*this)[i].Draw();473 }474 475 fArrowX->Draw();476 fArrowY->Draw();477 478 fLegRadius->Draw();479 fLegDegree->Draw();480 481 //482 // initialize and draw legend483 //484 const Float_t H = 0.9*fRange;485 const Float_t h = 2./kItemsLegend;486 487 const Float_t w = fRange/sqrt(fNumPixels);488 489 for (Int_t i=0; i<kItemsLegend; i++)490 {491 TBox *box = GetBox(i);492 box->SetX1(fRange);493 box->SetX2(fRange+w);494 box->SetY1(H*( i *h - 1.));495 box->SetY2(H*((i+1)*h - 1.));496 box->SetFillColor(22);497 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)498 box->SetBit(/*kNoContextMenu|*/kCannotPick);499 #endif500 box->Draw();501 502 TText *txt = GetText(i);503 txt->SetX(fRange+1.5*w);504 txt->SetY(H*((i+0.5)*h - 1.));505 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)506 txt->SetBit(/*kNoContextMenu|*/kCannotPick);507 #endif508 txt->Draw();509 }510 511 //512 // Append this object, so that the aspect ratio is maintained513 // (Paint-function is called)514 // Add it here so that root will have it first in the internal list:515 // This means, that root 'sees' the whole camera instead of all the516 // single hexagons.517 //518 AppendPad(option);519 520 //fDrawingPad->SetEditable(kFALSE);521 }522 523 void MCamDisplay::DrawPixelNumbers()524 {525 if (!fDrawingPad)526 466 Draw(); 527 528 fDrawingPad->cd();529 467 530 468 TText txt; … … 545 483 // ------------------------------------------------------------------------ 546 484 // 547 // Call this function to drawthe number of photo electron into the485 // Call this function to fill the number of photo electron into the 548 486 // camera. 549 487 // 550 void MCamDisplay::DrawPhotNum(const MCerPhotEvt *event) 551 { 552 if (!event) 553 return; 554 555 Draw(); 556 557 fDrawingPad->cd(); 558 559 for (int i=0; i<kItemsLegend; i++) 560 GetBox(i)->SetFillColor(fColors[i]); 561 488 void MCamDisplay::FillPhotNum(const MCerPhotEvt &event) 489 { 562 490 // 563 491 // Reset pixel colors to default value … … 573 501 if (fAutoScale) 574 502 { 575 min = event ->GetNumPhotonsMin(fGeomCam);576 max = event ->GetNumPhotonsMax(fGeomCam);577 578 if (max < 20.)579 max = 20.;503 min = event.GetNumPhotonsMin(fGeomCam); 504 max = event.GetNumPhotonsMax(fGeomCam); 505 506 if (max < 1.) 507 max = 1.; 580 508 581 509 UpdateLegend(min, max); … … 585 513 // update the colors in the picture 586 514 // 587 const Int_t entries = event ->GetNumPixels();515 const Int_t entries = event.GetNumPixels(); 588 516 589 517 for (Int_t i=0; i<entries; i++) 590 518 { 591 const MCerPhotPix &pix = (*event)[i];519 const MCerPhotPix &pix = event[i]; 592 520 593 521 if (!pix.IsPixelUsed()) … … 596 524 SetPixColor(pix, i, min, max); 597 525 } 598 599 // 600 // Update display physically 601 // 602 fDrawingPad->Modified(); 603 fDrawingPad->Update(); 604 } 605 606 // ------------------------------------------------------------------------ 607 // 608 // Call this function to draw the number of photo electron into the 526 } 527 528 // ------------------------------------------------------------------------ 529 // 530 // Call this function to fill the number of photo electron into the 609 531 // camera. 610 532 // 611 void MCamDisplay::DrawPedestals(const MPedestalCam *event) 612 { 613 if (!event) 614 return; 615 616 Draw(); 617 618 fDrawingPad->cd(); 619 620 for (int i=0; i<kItemsLegend; i++) 621 GetBox(i)->SetFillColor(fColors[i]); 622 533 void MCamDisplay::FillPedestals(const MPedestalCam &event) 534 { 623 535 // 624 536 // Reset pixel colors to default value … … 634 546 if (fAutoScale) 635 547 { 636 min = event ->GetMeanMin(fGeomCam);637 max = event ->GetMeanMax(fGeomCam);548 min = event.GetMeanMin(fGeomCam); 549 max = event.GetMeanMax(fGeomCam); 638 550 639 551 if (max < 20.) … … 646 558 // update the colors in the picture 647 559 // 648 const Int_t entries = event ->GetSize();560 const Int_t entries = event.GetSize(); 649 561 650 562 for (Int_t i=0; i<entries; i++) 651 SetPixColorPedestal((*event)[i], i, min, max); 652 653 // 654 // Update display physically 655 // 656 fDrawingPad->Modified(); 657 fDrawingPad->Update(); 658 } 659 660 // ------------------------------------------------------------------------ 661 // 662 // Call this function to draw the error of number of photo electron 563 SetPixColorPedestal(event[i], i, min, max); 564 } 565 566 // ------------------------------------------------------------------------ 567 // 568 // Call this function to fill the error of number of photo electron 663 569 // into the camera. 664 570 // 665 void MCamDisplay::DrawErrorPhot(const MCerPhotEvt *event) 666 { 667 if (!event) 668 return; 669 670 if (!fDrawingPad) 671 Draw(); 672 673 fDrawingPad->cd(); 674 675 for (int i=0; i<kItemsLegend; i++) 676 GetBox(i)->SetFillColor(fColors[i]); 677 571 void MCamDisplay::FillErrorPhot(const MCerPhotEvt &event) 572 { 678 573 // 679 574 // Reset pixel colors to default value … … 689 584 if (fAutoScale) 690 585 { 691 min = event ->GetErrorPhotMin(fGeomCam);692 max = event ->GetErrorPhotMax(fGeomCam);586 min = event.GetErrorPhotMin(fGeomCam); 587 max = event.GetErrorPhotMax(fGeomCam); 693 588 694 589 if (max < 20.) … … 701 596 // update the colors in the picture 702 597 // 703 const Int_t entries = event ->GetNumPixels();598 const Int_t entries = event.GetNumPixels(); 704 599 705 600 for (Int_t i=0; i<entries; i++) 706 601 { 707 const MCerPhotPix &pix = (*event)[i];602 const MCerPhotPix &pix = event[i]; 708 603 709 604 if (!pix.IsPixelUsed()) … … 712 607 SetPixColorError(pix, i, min, max); 713 608 } 714 715 // 716 // Update display physically 717 // 718 fDrawingPad->Modified(); 719 fDrawingPad->Update(); 720 } 721 722 // ------------------------------------------------------------------------ 723 // 724 // Call this function to draw the ratio of the number of photons 609 } 610 611 // ------------------------------------------------------------------------ 612 // 613 // Call this function to fill the ratio of the number of photons 725 614 // divided by its error 726 615 // 727 void MCamDisplay::DrawRatio(const MCerPhotEvt *event) 728 { 729 if (!event) 730 return; 731 732 if (!fDrawingPad) 733 Draw(); 734 735 fDrawingPad->cd(); 736 737 for (int i=0; i<kItemsLegend; i++) 738 GetBox(i)->SetFillColor(fColors[i]); 739 616 void MCamDisplay::FillRatio(const MCerPhotEvt &event) 617 { 740 618 // 741 619 // Reset pixel colors to default value … … 751 629 if (fAutoScale) 752 630 { 753 min = event ->GetRatioMin();754 max = event ->GetRatioMax();631 min = event.GetRatioMin(); 632 max = event.GetRatioMax(); 755 633 756 634 UpdateLegend(min, max); … … 760 638 // update the colors in the picture 761 639 // 762 const Int_t entries = event ->GetNumPixels();640 const Int_t entries = event.GetNumPixels(); 763 641 764 642 for (Int_t i=0; i<entries; i++) 765 643 { 766 const MCerPhotPix &pix = (*event)[i];644 const MCerPhotPix &pix = event[i]; 767 645 768 646 if (!pix.IsPixelUsed()) … … 771 649 SetPixColorRatio(pix, min, max); 772 650 } 773 774 // 775 // Update display physically 776 // 777 fDrawingPad->Modified(); 778 fDrawingPad->Update(); 779 } 780 781 // ------------------------------------------------------------------------ 782 // 783 // Draw the colors in respect to the cleaning levels 784 // 785 void MCamDisplay::DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2) 786 { 787 if (!event) 788 return; 789 790 if (!fDrawingPad) 791 Draw(); 792 793 fDrawingPad->cd(); 794 795 for (int i=0; i<kItemsLegend; i++) 796 GetBox(i)->SetFillColor(fColors[i]); 797 651 } 652 653 // ------------------------------------------------------------------------ 654 // 655 // Fill the colors in respect to the cleaning levels 656 // 657 void MCamDisplay::FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2) 658 { 798 659 // 799 660 // Reset pixel colors to default value … … 804 665 // update the colors in the picture 805 666 // 806 const Int_t entries = event ->GetNumPixels();667 const Int_t entries = event.GetNumPixels(); 807 668 808 669 for (Int_t i=0; i<entries; i++) 809 670 { 810 const MCerPhotPix &pix = (*event)[i];671 const MCerPhotPix &pix = event[i]; 811 672 812 673 if (!pix.IsPixelUsed()) … … 815 676 SetPixColorLevel(pix, lvl1, lvl2); 816 677 } 817 818 // 819 // Update display physically 820 // 821 fDrawingPad->Modified(); 822 fDrawingPad->Update(); 823 } 824 825 // ------------------------------------------------------------------------ 826 // 827 // Draw the colors in respect to the cleaning levels 828 // 829 void MCamDisplay::DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean) 830 { 831 DrawLevels(event, clean.GetCleanLvl1(), clean.GetCleanLvl2()); 832 } 833 834 // ------------------------------------------------------------------------ 835 // 836 // reset the all pixel colors to a default value 678 } 679 680 // ------------------------------------------------------------------------ 681 // 682 // Fill the colors in respect to the cleaning levels 683 // 684 void MCamDisplay::FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean) 685 { 686 FillLevels(event, clean.GetCleanLvl1(), clean.GetCleanLvl2()); 687 } 688 689 // ------------------------------------------------------------------------ 690 // 691 // Reset the all pixel colors to a default value 837 692 // 838 693 void MCamDisplay::Reset() … … 844 699 // ------------------------------------------------------------------------ 845 700 // 846 // 847 // 848 // 849 // 850 // 851 // 852 // 853 // 701 // Here we calculate the color index for the current value. 702 // The color index is defined with the class TStyle and the 703 // Color palette inside. We use the command gStyle->SetPalette(1,0) 704 // for the display. So we have to convert the value "wert" into 705 // a color index that fits the color palette. 706 // The range of the color palette is defined by the values fMinPhe 707 // and fMaxRange. Between this values we have 50 color index, starting 708 // with 0 up to 49. 854 709 // 855 710 Int_t MCamDisplay::GetColor(Float_t val, Float_t min, Float_t max) … … 877 732 // ------------------------------------------------------------------------ 878 733 // 879 // change the text on the legend according to the range of the 880 // Display 734 // Change the text on the legend according to the range of the Display 881 735 // 882 736 void MCamDisplay::UpdateLegend(Float_t minphe, Float_t maxphe) 883 737 { 884 char text[10];885 886 738 for (Int_t i=0; i<kItemsLegend; i+=3) 887 739 { 888 740 const Float_t val = minphe + (Float_t)i/kItemsLegend * (maxphe-minphe) ; 889 741 890 sprintf(text, "%5.1f", val);891 892 742 TText &txt = *GetText(i); 893 894 txt.SetText(txt.GetX(), txt.GetY(), text); 743 txt.SetText(txt.GetX(), txt.GetY(), Form("%5.1f", val)); 895 744 } 896 745 } … … 902 751 void MCamDisplay::SavePrimitive(ofstream &out, Option_t *opt) 903 752 { 753 cout << "MCamDisplay::SavePrimitive: Must be rewritten!" << endl; 754 /* 904 755 if (!gROOT->ClassSaved(TCanvas::Class())) 905 756 fDrawingPad->SavePrimitive(out, opt); … … 907 758 out << " " << fDrawingPad->GetName() << "->SetWindowSize("; 908 759 out << fDrawingPad->GetWw() << "," << fDrawingPad->GetWh() << ");" << endl; 760 */ 909 761 } 910 762 … … 951 803 { 952 804 (*this)[pixnum].SetFillColor(GetColor(color, min, max)); 953 954 } 805 } 806
Note:
See TracChangeset
for help on using the changeset viewer.