Changeset 3471 for trunk/MagicSoft/Mars/mhist/MHCamera.cc
- Timestamp:
- 03/11/04 15:25:44 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r3400 r3471 188 188 Int_t MHCamera::Fill(Axis_t x) 189 189 { 190 191 190 #if ROOT_VERSION_CODE > ROOT_VERSION(3,05,00) 192 191 if (fBuffer) return BufferFill(x,1); … … 397 396 // GeMinimum() ((val-min)/(max-min)) 398 397 // 'proj' Display the y-projection of the histogram 398 // 'same' Draw trandparent pixels on top of an existing pad. This 399 // makes it possible to draw the camera image on top of an 400 // existing TH2, but also allows for distorted camera images 399 401 // 400 402 void MHCamera::Draw(Option_t *option) 401 403 { 404 const Bool_t hassame = TString(option).Contains("same", TString::kIgnoreCase) && gPad; 405 402 406 // root 3.02: 403 407 // gPad->SetFixedAspectRatio() 404 408 const Color_t col = gPad ? gPad->GetFillColor() : 16; 405 409 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 656, 600); 406 pad->SetBorderMode(0); 407 pad->SetFillColor(col); 408 409 // 410 // Create an own pad for the MHCamera-Object which can be 411 // resized in paint to keep the correct aspect ratio 412 // 413 pad->Divide(1, 1, 0, 0, col); 414 pad->cd(1); 415 gPad->SetBorderMode(0); 416 417 TString opt(option); 418 opt.ToLower(); 410 411 if (!hassame) 412 { 413 pad->SetBorderMode(0); 414 pad->SetFillColor(col); 415 416 // 417 // Create an own pad for the MHCamera-Object which can be 418 // resized in paint to keep the correct aspect ratio 419 // 420 pad->Divide(1, 1, 0, 0, col); 421 pad->cd(1); 422 gPad->SetBorderMode(0); 423 } 419 424 420 425 AppendPad(option); 426 //fGeomCam->AppendPad(); 421 427 422 428 // … … 424 430 // changes gPad... 425 431 // 426 pad->cd(); 432 if (!hassame) 433 pad->cd(); 427 434 } 428 435 … … 600 607 // Updates the pixel colors and paints the pixels 601 608 // 602 void MHCamera::Update(Bool_t islog, Bool_t isbox, Bool_t iscol )609 void MHCamera::Update(Bool_t islog, Bool_t isbox, Bool_t iscol, Bool_t issame) 603 610 { 604 611 Double_t min = GetMinimum(kFALSE); … … 613 620 max += 1; 614 621 615 UpdateLegend(min, max, islog); 622 if (!issame) 623 UpdateLegend(min, max, islog); 624 625 // Try to estimate the units of the current display. This is only 626 // necessary for 'same' option and allows distorted images of the camera! 627 const Float_t maxr = (1-fGeomCam->GetConvMm2Deg())*fGeomCam->GetMaxRadius()/2; 628 const Float_t conv = issame || 629 gPad->GetX1()<-maxr || gPad->GetY1()<-maxr || 630 gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg(); 616 631 617 632 MHexagon hex; 618 633 for (Int_t i=0; i<fNcells-2; i++) 619 634 { 620 if (IsUsed(i) && iscol) 635 hex.SetFillStyle(issame ? 4000 : 1001); 636 637 if (!issame) 621 638 { 622 if (TMath::IsNaN(fArray[i+1])) 623 gLog << warn << "MHCamera::Update: " << GetName() << " <" << GetTitle() << "> - Pixel Index #" << i << " contents is NaN (Not a Number)..." << endl; 624 625 hex.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog)); 639 if (IsUsed(i) && iscol) 640 { 641 if (TMath::IsNaN(fArray[i+1])) 642 gLog << warn << "MHCamera::Update: " << GetName() << " <" << GetTitle() << "> - Pixel Index #" << i << " contents is NaN (Not a Number)..." << endl; 643 644 hex.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog)); 645 } 646 else 647 hex.SetFillColor(10); 626 648 } 627 else 628 hex.SetFillColor(10); 629 630 MGeomPix &pix = (*fGeomCam)[i]; 649 650 const MGeomPix &pix = (*fGeomCam)[i]; 651 652 const Float_t x = pix.GetX()*conv; 653 const Float_t y = pix.GetY()*conv; 654 const Float_t d = pix.GetD()*conv; 655 631 656 if (!isbox) 632 hex.PaintHexagon( pix.GetX(), pix.GetY(), pix.GetD());657 hex.PaintHexagon(x, y, d); 633 658 else 634 659 if (IsUsed(i) && !TMath::IsNaN(fArray[i+1])) 635 660 { 636 Float_t size = pix.GetD()*(GetBinContent(i+1)-min)/(max-min);637 if (size> pix.GetD())638 size= pix.GetD();639 hex.PaintHexagon( pix.GetX(), pix.GetY(), size);661 Float_t size = d*(GetBinContent(i+1)-min)/(max-min); 662 if (size>d) 663 size=d; 664 hex.PaintHexagon(x, y, size); 640 665 } 641 666 } … … 705 730 return; 706 731 } 707 708 gPad->Clear(); 709 710 // Maintain aspect ratio 711 SetRange(); 712 713 Bool_t isbox = opt.Contains("box"); 714 Bool_t iscol = isbox ? !opt.Contains("nocol") : 1; 715 716 if (GetPainter()) 717 { 718 // Paint statistics 719 if (!TestBit(TH1::kNoStats)) 720 fPainter->PaintStat(gStyle->GetOptStat(), NULL); 721 722 // Paint primitives (pixels, color legend, photons, ...) 723 if (fPainter->InheritsFrom(THistPainter::Class())) 732 733 const Bool_t hassame = opt.Contains("same"); 734 const Bool_t hasbox = opt.Contains("box"); 735 const Bool_t hascol = hasbox ? !opt.Contains("nocol") : kTRUE; 736 737 if (!hassame) 738 { 739 gPad->Clear(); 740 741 // Maintain aspect ratio 742 SetRange(); 743 744 if (GetPainter()) 724 745 { 725 static_cast<THistPainter*>(fPainter)->MakeChopt(""); 726 static_cast<THistPainter*>(fPainter)->PaintTitle(); 746 // Paint statistics 747 if (!TestBit(TH1::kNoStats)) 748 fPainter->PaintStat(gStyle->GetOptStat(), NULL); 749 750 // Paint primitives (pixels, color legend, photons, ...) 751 if (fPainter->InheritsFrom(THistPainter::Class())) 752 { 753 static_cast<THistPainter*>(fPainter)->MakeChopt(""); 754 static_cast<THistPainter*>(fPainter)->PaintTitle(); 755 } 727 756 } 728 757 } 729 758 730 759 // Update Contents of the pixels and paint legend 731 Update(gPad->GetLogy(), isbox, iscol); 732 PaintAxisTitle(); 760 Update(gPad->GetLogy(), hasbox, hascol, hassame); 761 762 if (!hassame) 763 PaintAxisTitle(); 733 764 734 765 if (opt.Contains("pixelindex"))
Note:
See TracChangeset
for help on using the changeset viewer.