本文整理汇总了C++中TText类的典型用法代码示例。如果您正苦于以下问题:C++ TText类的具体用法?C++ TText怎么用?C++ TText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetChildWindow
void TMainMenu::SetWelcomeName()
{
if(TSettings::GetInstance()->GetNumUsers() == 0)
{
TWindow *window = GetChildWindow("welcome", -1);
if (window)
{
window->SetFlags(window->GetFlags() & ~kEnabled);
}
window = GetChildWindow("changeplayer", -1);
if (window)
{
window->SetFlags(window->GetFlags() & ~kEnabled);
}
}
else
{
TWindow *window = GetChildWindow("welcome", -1);
if (window)
{
TText *text = window->GetCast<TText>();
text->SetText(TPlatform::GetInstance()->GetStringTable()->GetString("welcome", TSettings::GetInstance()->GetCurrentUserName()));
}
}
}
示例2: PaintOverflow
void PaintOverflow(TH1 *h)
{
// This function paint the histogram h with an extra bin for overflows
char* name = h->GetName();
char* title = h->GetTitle();
Int_t nx = h->GetNbinsX()+1;
Double_t x1 = h->GetBinLowEdge(1);
Double_t bw = h->GetBinWidth(nx);
Double_t x2 = h->GetBinLowEdge(nx)+bw;
// Book a temporary histogram having ab extra bin for overflows
TH1F *htmp = new TH1F(name, title, nx, x1, x2);
// Fill the new hitogram including the extra bin for overflows
for (Int_t i=1; i<=nx; i++) {
htmp->Fill(htmp->GetBinCenter(i), h->GetBinContent(i));
}
// Fill the underflows
htmp->Fill(x1-1, h->GetBinContent(0));
// Restore the number of entries
htmp->SetEntries(h->GetEntries());
// Draw the temporary histogram
htmp->Draw();
TText *t = new TText(x2-bw/2,h->GetBinContent(nx),"Overflow");
t->SetTextAngle(90);
t->SetTextAlign(12);
t->SetTextSize(0.03);;
t->Draw();
}
示例3: greyscale
void greyscale()
{
TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
c->SetBorderMode(0);
Int_t n = 200; // tunable parameter
Float_t n1 = 1./n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
Float_t grey = Float_t(i*n+j)/(n*n);
b->SetFillColor(TColor::GetColor(grey, grey, grey));
b->Draw();
}
}
TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
p->SetFillColor(TColor::GetColor(guibackground));
p->Draw();
p->cd();
TText *t = new TText(0.5, 0.5, "GUI Background Color");
t->SetTextAlign(22);
t->SetTextSize(.09);
t->Draw();
c->SetEditable(kFALSE);
}
示例4: highlight1
void highlight1()
{
TCanvas *ch = new TCanvas("ch", "ch", 0, 0, 700, 500);
const Int_t n = 500;
Double_t x[n], y[n];
TH1F *h[n];
for (Int_t i = 0; i < n; i++) {
h[i] = new TH1F(TString::Format("h_%02d", i), "", 100, -3.0, 3.0);
// in practice gaus need reset parameters
h[i]->FillRandom("gaus", 1000);
h[i]->Fit("gaus", "Q");
h[i]->SetMaximum(250); // for n > 200
x[i] = i;
y[i] = h[i]->GetFunction("gaus")->GetParameter(2);
}
TGraph *g = new TGraph(n, x, y);
g->SetMarkerStyle(6);
for (Int_t i = 0; i < n; i++) g->AddHighlight(i, h[i]);
g->Draw("AP");
g->SetHighlight();
TPad *ph = new TPad("ph", "ph", 0.3, 0.4, 1.0, 1.0);
ph->SetFillColor(kBlue - 10);
ph->Draw();
ph->cd();
TText *info = new TText(0.5, 0.5, "please move the mouse over the graph");
info->SetTextAlign(22);
info->Draw();
ch->cd();
TGraph::SetHighlightPad(ph);
}
示例5: ratioPlots
void ratioPlots( TCanvas* c1, TH1* h_r, TH1* h_i,
string xTitle, string yTitle, string savePath,
double fitMin=-100000, double fitMax=100000, bool doubleColFit=0 ){
double xMaximum = h_r->GetXaxis()->GetBinUpEdge(h_r->GetXaxis()->GetLast());
double xMinimum = h_r->GetXaxis()->GetBinLowEdge(h_r->GetXaxis()->GetFirst());
double yMaximum;
double yMinimum;
h_i->Sumw2();
h_r->Sumw2();
TLine* line1 = new TLine(xMinimum,1,xMaximum,1);
line1->SetLineColor(1);
line1->SetLineWidth(2);
line1->SetLineStyle(7);
TF1* fpol1 = new TF1("fpol1", "pol1", fitMin, fitMax);
fpol1->SetLineColor(2);
fpol1->SetLineWidth(3);
fpol1->SetLineStyle(7);
TH1* hRatio = (TH1*)h_r->Clone("clone_record");
hRatio->Divide(h_i);
yMaximum = hRatio->GetMaximum();
yMinimum = hRatio->GetMinimum(0);
hRatio->GetYaxis()->SetRangeUser(yMinimum/2.5,yMaximum+yMaximum/5);
hRatio->SetXTitle(xTitle.c_str());
hRatio->SetYTitle(yTitle.c_str());
hRatio->SetLineColor(9);
hRatio->SetLineWidth(2);
hRatio->SetMarkerStyle(8);
hRatio->Draw("e");
hRatio->Fit("fpol1", "L");
line1->Draw("SAME");
if(doubleColFit){
double p0=fpol1->GetParameter(0);
double p1=fpol1->GetParameter(1);
double endPoint=double(fitMax*p1)+p0;
double p1new=(endPoint-1)/(fitMax-fitMin);
char fun[100], text[100];
sprintf(fun,"x*(%f)+1",p1new);
sprintf(text,"Tangent: %f",p1new);
TF1* fnew = new TF1("fnew", fun, fitMin, fitMax);
fnew->SetLineColor(2);
fnew->SetLineWidth(3);
fnew->Draw("SAME");
TText* Title = new TText( fitMax/12, yMinimum, text);
Title->SetTextColor(2);
Title->SetTextSize(0.035);
Title->Draw("SAME");
}
c1->SaveAs(savePath.c_str());
c1->cd();
}
示例6: Draw_KL_Test
void Draw_KL_Test(){
TChain* ch = new TChain("Tree");
TChain* ch1 = new TChain("Tree");
TH1D* his = new TH1D("Klong6g","Klong6g",20,450,550);
TH1D* his1 = new TH1D("Klong4g","Klong4g",20,450,550);
TH1D* his2 = new TH1D("Klong4gAll","Klong4gAll",60,250,550);
for( int i = 0; i< 68; i++){
ch->Add(Form("klongRootFile/kl%d.root" ,4162+i));
ch1->Add(Form("klongRootFile/ks%d.root",4162+i));
}
ch->Project(his->GetName() ,"KlongMass[0]","CutCondition==0");
ch1->Project(his1->GetName(),"KlongMass[0]","CutCondition==0");
ch1->Project(his2->GetName(),"KlongMass[0]","CutCondition==0");
TF1* func = new TF1("func","gaus(0)+expo(3)",0,550);
func->SetParameter(1,498);
func->SetParameter(2,5);
TF1* func2 = new TF1("func2","gaus(0)",0,550);
func2->SetParameter(1,498);
func2->SetParameter(2,5);
TCanvas* can = new TCanvas("can","",1200,600);
can->Divide(2,1);
can->cd(1);
his2->Fit(func->GetName(),"","",450,550);
his2->Draw();
TF1* func1 = new TF1("Test","gaus",450,550);
func1->SetParameter(0,func->GetParameter(0));
func1->SetParameter(1,func->GetParameter(1));
func1->SetParameter(2,func->GetParameter(2));
can->cd(2);
his1->SetLineColor(2);
his->Draw();
his->Fit(func2->GetName(),"","",450,550);
func->Draw("same");
his1->Draw("same");
std::cout<< func2->GetParameter(0) << " "
<< func->GetParameter(0) << " "
<< func->GetParameter(0)/func2->GetParameter(0)<< std::endl;
std::cout<< func2->Integral(450,550) << " "
<< func1->Integral(450,550) << " "
<< func1->Integral(450,550)/func2->Integral(450,550)
<< std::endl;
//ch->Draw("KlongPt[0]:KlongMass[0]>>(400,200,600,50,0,20)","(CutCondition&(1|2|4|8))==0","colz");
gPad->SetLogz();
TText* text = new TText(0.5,0.5,"");
TText* text1 = new TText(0.5,0.5,"");
text->DrawTextNDC(0.5,0.5,Form("Integral:%2.3lf",func1->Integral(450,550)));
text1->DrawTextNDC(0.5,0.6,Form("Integral:%2.3lf",func2->Integral(450,550)));
}
示例7: s_intersection
void s_intersection()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c = new TCanvas("composite shape", "Intersection boolean operation", 700, 1000);
c->Divide(1,2,0,0);
c->cd(2);
gPad->SetPad(0,0,1,0.4);
c->cd(1);
gPad->SetPad(0,0.4,1,1);
if (gGeoManager) delete gGeoManager;
new TGeoManager("xtru", "poza12");
TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *med = new TGeoMedium("MED",1,mat);
TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
gGeoManager->SetTopVolume(top);
// define shape components with names
TGeoBBox *box = new TGeoBBox("bx", 40., 40., 40.);
TGeoSphere *sph = new TGeoSphere("sph", 40., 45.);
// define named geometrical transformations with names
TGeoTranslation *tr = new TGeoTranslation(0., 0., 45.);
tr->SetName("tr");
// register all used transformations
tr->RegisterYourself();
// create the composite shape based on a Boolean expression
TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph:tr * bx");
TGeoVolume *vol = new TGeoVolume("COMP2",cs);
top->AddNode(vol,1);
gGeoManager->CloseGeometry();
gGeoManager->SetNsegments(100);
top->Draw();
MakePicture();
c->cd(2);
TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
pt->SetLineColor(1);
TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
text->SetTextColor(2);
pt->AddText("----- Here is an example of boolean intersection operation : A * B");
pt->AddText("----- A == sphere (with inner radius non-zero), B == box");
pt->AddText(" ");
pt->SetAllWith("-----","color",4);
pt->SetAllWith("-----","font",72);
pt->SetAllWith("-----","size",0.04);
pt->SetTextAlign(12);
pt->SetTextSize(0.044);
pt->Draw();
c->cd(1);
}
示例8: do2DPlots
void do2DPlots(bool muon, TString variable, TString ytitle){
TString leptonFolder;
if(muon == true){
leptonFolder = "MuonMET/";
}else{
leptonFolder = "ElectronMET/";
}
setTDRStyle();
gStyle->SetPalette(1);
TString dir = "rootFilesV4/central/";
TFile* tt_file = new TFile(dir + sample+"_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root");
cout << "Getting histo: " << "Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET"<<endl;
TH2D* tt_2d = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_2btags");
TH2D* tt_2d_3b = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_3btags");
TH2D* tt_2d_4b = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_4orMoreBtags");
tt_2d->Add(tt_2d_3b);
tt_2d->Add(tt_2d_4b);
tt_2d->Rebin2D(5,5);
tt_2d->GetYaxis()->SetTitle(ytitle);
tt_2d->GetXaxis()->SetTitle("Gen MET (GeV)");
tt_2d->GetYaxis()->SetTitleOffset(1.8);
tt_2d->GetXaxis()->SetTitleOffset(1.5);
TCanvas *c= new TCanvas("c","c",10,10,800,600);
tt_2d->Draw("COLZ");
int bin[5] = {25, 45, 70, 100, 150};//MET
for(int i = 0; i < 5; i++){
TLine *line = new TLine(bin[i],0,bin[i],300);
TLine *liney = new TLine(0,bin[i],300,bin[i]);
//TLine *line = new TLine(bin[i],0,bin[i],500);
//TLine *liney = new TLine(0,bin[i],500,bin[i]);
line->SetLineWidth(2);
liney->SetLineWidth(2);
liney->Draw();
line->Draw();
}
TText* textPrelim = doPrelim(0.2,0.96);
textPrelim->Draw();
TString plotName("plots/"+leptonFolder);
plotName += sample+"_"+variable;
plotName += "_2btags.pdf";
c->SaveAs(plotName);
delete c;
}
示例9: compareHistos
void compareHistos( char *Current, char *Reference=0 ) {
TText* te = new TText();
te->SetTextSize(0.1);
TFile * curfile = new TFile( TString(Current)+".root" );
TFile * reffile = curfile;
if (Reference) reffile = new TFile(TString(Reference)+".root");
char * prefix="DQMData/MixingV/Mixing";
//1-Dimension Histogram
TDirectory * refDir=reffile->GetDirectory(prefix);
TDirectory * curDir=curfile->GetDirectory(prefix);
TList* list = refDir->GetListOfKeys();
TObject* object = list->First();
int iHisto = 0;
char title[50];
while (object) {
// find histo objects
std::cout << " object :" << object->GetName() << std::endl;
TProfile * h1 = dynamic_cast<TProfile*>( refDir->Get(object->GetName()));
TProfile * h2 = dynamic_cast<TProfile*>( curDir->Get(object->GetName()));
bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TProfile");
std::cout << " isHisto = " << isHisto << std::endl;
if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
iHisto++;
char title[50];
// draw and compare
std::cout << " Start draw and compare" << std::endl;
TCanvas c1;
TProfile htemp2;
h2->Copy(htemp2);// to keep 2 distinct histos
h1->SetLineColor(2);
htemp2.SetLineColor(3);
h1->SetLineStyle(3);
h1->SetMarkerColor(3);
htemp2.SetLineStyle(5);
htemp2.SetMarkerColor(5);
TLegend leg(0.1, 0.15, 0.2, 0.25);
leg.AddEntry(h1, "Reference", "l");
leg.AddEntry(&htemp2, "New ", "l");
h1->Draw();
htemp2.Draw("Same");
leg.Draw();
sprintf(title,"%s%s", object->GetName(),".gif");
c1.Print(title);
}
// go to next object
object = list->After(object);
}
}
示例10: DrawPeriod
//______________________________________________________________________________
void DrawPeriod(int runmin, int runmax, int run1, int run2, double ymin, double ymax, const char* label)
{
if ( run1 < runmin || run1 > runmax || run2 < runmin || run2 > runmax ) return;
TBox* b = new TBox(run1,ymin,run2,ymax);
b->SetFillColor(5);
b->Draw();
TText* text = new TText((run1+run2)/2.0,ymax*0.6,label);
text->SetTextAlign(22);
text->SetTextSize(0.02);
text->Draw();
}
示例11: s_difference
void s_difference()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c = new TCanvas("composite shape", "Difference boolean operation", 700, 1000);
c->Divide(1,2,0,0);
c->cd(2);
gPad->SetPad(0,0,1,0.4);
c->cd(1);
gPad->SetPad(0,0.4,1,1);
if (gGeoManager) delete gGeoManager;
new TGeoManager("xtru", "poza12");
TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *med = new TGeoMedium("MED",1,mat);
TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
gGeoManager->SetTopVolume(top);
// define shape components with names
TGeoTorus *tor = new TGeoTorus("tor", 45., 15., 20., 45., 145.);
TGeoSphere *sph = new TGeoSphere("sph", 20., 45., 0., 180., 0., 270.);
// create the composite shape based on a Boolean expression
TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph - tor");
TGeoVolume *vol = new TGeoVolume("COMP3",cs);
top->AddNode(vol,1);
gGeoManager->CloseGeometry();
gGeoManager->SetNsegments(60);
top->Draw();
MakePicture();
c->cd(2);
TPaveText *pt = new TPaveText(.01, .01, .99, .99);
pt->SetLineColor(1);
TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
text->SetTextColor(2);
pt->AddText("----- It's an example of boolean difference: A - B");
pt->AddText("----- A == part of sphere (0-180, 0-270), B == partial torus (45-145)");
pt->AddText(" ");
pt->SetAllWith("-----","color",4);
pt->SetAllWith("-----","font",72);
pt->SetAllWith("-----","size",0.04);
pt->SetTextAlign(12);
pt->SetTextSize(0.044);
pt->Draw();
c->cd(1);
}
示例12: DoCompare
void DoCompare( char *Current, char *Reference=0 ){
TText* te = new TText();
te->SetTextSize(0.1);
gROOT->ProcessLine(".x HistoCompare.C");
HistoCompare * myPV = new HistoCompare();
TFile * curfile = new TFile( TString(Current)+".root" );
TFile * reffile = curfile;
if (Reference) reffile = new TFile(TString(Reference)+".root");
char * prefix="DQMData/MixingV/";
//1-Dimension Histogram
TDirectory * refDir=reffile->GetDirectory(prefix);
TDirectory * curDir=curfile->GetDirectory(prefix);
TList* list = refDir->GetListOfKeys();
TObject* object = list->First();
int iHisto = 0; char title[50];
while (object) {
// find histo objects
TH1F * h1 = dynamic_cast<TH1F*>( refDir->Get(object->GetName()));
TH1F * h2 = dynamic_cast<TH1F*>( curDir->Get(object->GetName()));
bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TH1F");
if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
iHisto++;
char title[50];
// draw and compare
TCanvas c1;
TH1F htemp2;
h2->Copy(htemp2);// to keep 2 distinct histos
h1->SetLineColor(2);
htemp2.SetLineColor(3);
h1->SetLineStyle(3);
htemp2.SetLineStyle(5);
TLegend leg(0.1, 0.15, 0.2, 0.25);
leg.AddEntry(h1, "Reference", "l");
leg.AddEntry(&htemp2, "New ", "l");
h1->Draw();
htemp2.Draw("Same");
leg.Draw();
myPV->PVCompute(h1,&htemp2, te);
sprintf(title,"%s%s", object->GetName(),".eps");
c1.Print(title);
}
// go to next object
object = list->After(object);
}
}
示例13: test
void test(void){
TCanvas *c = new TCanvas("c","font test");
TH1D *h = new TH1D("h","h",10,0,10);
TText *t = new TText();
h->SetTitle("Title");
h->GetXaxis()->SetTitle("X axis daze");
h->GetYaxis()->SetTitle("Y axis yade");
h->Draw();
t->DrawTextNDC(0.4, 0.4 ,"abcdef");
}
示例14: overlayFrame
//--------------------------------------------------------------------------------------------------
void overlayFrame(TString text, bool align)
{
// Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text
// Create new transparent pad for the text
TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1);
transPad->SetFillStyle(4000);
transPad->Draw();
transPad->cd();
// Overlay the text in a well defined frame
TText *plotText = new TText();
plotText->SetTextColor(kBlue);
plotText->SetTextSize(0.04);
plotText->SetNDC();
// Draw text at top right
if (align) {
plotText->SetTextColor(kBlack);
plotText->SetTextAlign(33);
plotText->DrawText(0.92,0.95,text.Data());
}
// Draw text at bottom left
else
plotText->DrawText(0.01,0.01,text.Data());
return;
}
示例15: postprocess
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance) {
if (rPerformance){
TLatex *alice = new TLatex(0.65,0.47,"Performance");
alice->SetNDC();
alice->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice->SetTextSize(0.05);
alice->SetLineWidth(2);
alice->Draw();
TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2");
alice2->SetNDC();
alice2->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice2->SetTextSize(0.05);
alice2->SetLineWidth(2);
alice2->Draw();
TText *date = new TText(0.68,0.35,cStamp2);
date->SetNDC();
date->SetTextFont(42);
date->SetTextSize(0.04);
date->Draw();
//Acquire canvas proportions
Double_t AliLogo_LowX = 0.67;
Double_t AliLogo_LowY = 0.53;
Double_t AliLogo_Height = 0.22;
//ALICE logo is a png file that is 821x798 pixels->should be wider than a square
Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();
TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
// myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
myPadSetUp(myPadLogo,0,0,0,0);
//myPadLogo->SetFixedAspectRatio(1);
myPadLogo->Draw();
myPadLogo->cd();
TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
myAliceLogo->Draw();
}
if (rWrite == 1)
c2->SaveAs(Form("%s.png",name));
if (rWrite == 2)
c2->SaveAs(Form("%s.eps",name));
}