/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/EventDisplay/BesVisLib/BesVisLib-00-04-04/src/BesPaveText.cxx

Go to the documentation of this file.
00001 
00002 #include <TPad.h>
00003 #include "BesVisLib/BesPaveText.h"
00004 #include <iostream>
00005 
00006 using namespace std;
00007 
00008 #ifndef __CINT__
00009 ClassImp(BesPaveText)
00010 #endif
00011 
00012 //______________________________________________________________________________
00013 BesPaveText::BesPaveText(): TPaveText()
00014 {
00015 }
00016 
00017 //______________________________________________________________________________
00018 BesPaveText::BesPaveText(Double_t x1, Double_t y1,Double_t x2, Double_t  y2, Option_t *option)
00019         :TPaveText(x1,y1,x2,y2,option)
00020 {
00021     SetFillColor(1001);
00022     SetBorderSize(1);
00023     SetCornerRadius(0.2);
00024 
00025     fTextSize = 0.025;
00026 }
00027 
00028 //______________________________________________________________________________
00029 BesPaveText::BesPaveText(const BesPaveText &pavetext) : TPaveText()
00030 {
00031 
00032 }
00033 
00034 //______________________________________________________________________________
00035 void BesPaveText::SetText(vector<TString> infoCon)
00036 {
00037     Int_t n = infoCon.size();
00038     Double_t margin = GetMargin();
00039     Double_t dy = (1.0-margin*2)/n;
00040 
00041     Double_t coordx = 0.0;
00042     Double_t coordy = 0.0;
00043     for (Int_t i = 0; i < n; i++) {
00044         coordy = 1.0 - (i+1)*dy;
00045         if (n == 1) coordy = 1.0;
00046 
00047         TText* tdata = AddText(coordx, coordy, infoCon[i].Data());
00048         tdata->SetTextSize(fTextSize/1.2);
00049         tdata->SetTextFont(42);
00050         if (i == 0 && n > 4) {
00051             tdata->SetTextSize(fTextSize);
00052             tdata->SetTextFont(62);
00053         }
00054         tdata->SetTextColor(1);
00055         tdata->SetTextAlign(12);
00056 
00057         if (infoCon[i] == TString("Fired")) {
00058             tdata->SetTextColor(kRed);
00059             //tdata->SetTextSize(fTextSize);
00060             tdata->SetTextFont(72);
00061         }
00062     }
00063 
00064     fdxNDC = fTextSize * fLongest / 2.2;
00065     fdyNDC = fTextSize * n * 1.2; //fLines->GetSize() * 1.2;
00066 
00067     ConvertNDCtoPad();
00068     // This is necessary, or when fTip was drawn the first time, it will in center, as its fX1 fX2 fY1 fY2 have not been changed.
00069     SetX1NDC(0.0);
00070     SetY1NDC(0.0);
00071     SetX2NDC(fdxNDC);
00072     SetY2NDC(fdyNDC);
00073 }
00074 
00075 //______________________________________________________________________________
00076 void BesPaveText::SetPos(Int_t px, Int_t py)
00077 {
00078     if (!gPad) {
00079         cout << "BesPaveText::SetPos, gPad does not exist" << endl;
00080         return;
00081     }
00082 
00083     Double_t x = gPad->AbsPixeltoX(px+10);
00084     Double_t y = gPad->AbsPixeltoY(py-10);
00085     Double_t x1, y1, x2, y2, xNDC, yNDC;
00086     gPad->GetRange(x1, y1, x2, y2);
00087     xNDC = (x-x1)/(x2-x1);
00088     yNDC = (y-y1)/(y2-y1);
00089     //cout << xNDC << " " << yNDC << endl;
00090 
00091     x1 = xNDC;
00092     y1 = yNDC;
00093     x2 = xNDC + fdxNDC;
00094     y2 = yNDC + fdyNDC;
00095 
00096     Double_t delta = 0.02;
00097     if (x2 > 1.0 && y2 > 1.0) {
00098         x1 -= (fdxNDC+delta);
00099         x2 -= (fdxNDC+delta);
00100         y1 -= (fdyNDC+delta);
00101         y2 -= (fdyNDC+delta);
00102     }
00103     else if (x2 > 1.0) {
00104         x1 -= fdxNDC;
00105         x2 -= fdxNDC;
00106     }
00107     if (y2 > 1.0) {
00108         y1 -= fdyNDC;
00109         y2 -= fdyNDC;
00110     }
00111 
00112     SetX1NDC(x1);
00113     SetY1NDC(y1);
00114     SetX2NDC(x2);
00115     SetY2NDC(y2);
00116     ConvertNDCtoPad();
00117 }

Generated on Tue Nov 29 23:12:04 2016 for BOSS_7.0.2 by  doxygen 1.4.7