本文整理汇总了C++中TPaveText::SetTextAlign方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveText::SetTextAlign方法的具体用法?C++ TPaveText::SetTextAlign怎么用?C++ TPaveText::SetTextAlign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveText
的用法示例。
在下文中一共展示了TPaveText::SetTextAlign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawPrelimLabel
// Draw label for Decay Channel in upper left corner of plot
void DrawPrelimLabel(int cmsprelim, double textSize) {
TPaveText *cms = new TPaveText();
cms->AddText("CMS");
cms->SetX1NDC( gStyle->GetPadLeftMargin() + gStyle->GetTickLength() );
cms->SetY1NDC(1.0 - gStyle->GetPadTopMargin() - gStyle->GetTickLength() - 0.05 );
cms->SetX2NDC( gStyle->GetPadLeftMargin() + gStyle->GetTickLength() + 0.15 );
cms->SetY2NDC(1.0 - gStyle->GetPadTopMargin() - gStyle->GetTickLength() );
cms->SetFillStyle(0);
cms->SetBorderSize(0);
if (textSize!=0) cms->SetTextSize(textSize*1.1);
cms->SetTextAlign(12);
cms->SetTextFont(61);
cms->Draw("same");
if(cmsprelim > 0) {
TPaveText *extra = new TPaveText();
if(cmsprelim == 2) { extra->AddText("Private Work"); }
else { extra->AddText("Preliminary"); }
extra->SetX1NDC( gStyle->GetPadLeftMargin() + gStyle->GetTickLength() );
extra->SetY1NDC(1.0 - gStyle->GetPadTopMargin() - gStyle->GetTickLength() - 0.10 );
extra->SetX2NDC( gStyle->GetPadLeftMargin() + gStyle->GetTickLength() + 0.15 );
extra->SetY2NDC(1.0 - gStyle->GetPadTopMargin() - gStyle->GetTickLength() - 0.05 );
extra->SetFillStyle(0);
extra->SetBorderSize(0);
if (textSize!=0) extra->SetTextSize(textSize);
extra->SetTextAlign(12);
extra->SetTextFont(52);
extra->Draw("same");
}
}
示例2: formatForCmsPublic
void formatForCmsPublic(TPad * c, TLegend *leg, TString title, int nsamp, float legx, float legy, float legw, float legh, TString legopt)
{
if(title.Length()!=0)
{
TPaveText *pave = new TPaveText(0.5,0.96,0.94,0.99,"NDC");
pave->SetBorderSize(0);
pave->SetFillStyle(0);
pave->SetTextAlign(32);
pave->SetTextFont(42);
TObjArray * tokens = title.Tokenize("\\\\");
int nt = tokens->GetEntries();
for(int it=0; it<nt; ++it)
{
TObjString * t = (TObjString *)tokens->At(it);
pave->AddText(t->GetString());
}
pave->Draw("same");
}
float legx1=legx, legx2=legx+legw;
float legy1 = legy, legy2 = legy-legh*(float)(nsamp);
if(leg==0) leg = ((TPad *)c)->BuildLegend(legx1,legy1,legx2,legy2);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetLineWidth(1);
leg->SetTextFont(42);
leg->SetEntryOption(legopt);
leg->SetX1NDC(legx1);
leg->SetY1NDC(legy1);//-nsamp*legh);
leg->SetX2NDC(legx2);
leg->SetY2NDC(legy2);
}
示例3: makeScaleFactorHist
void makeScaleFactorHist(TCanvas* canvas, const std::string& name, const std::string& tag)
{
TMultiGraph* multigraph = NULL;
std::stringstream graphName;
graphName << name << "ScaleFactorMultigraph";
multigraph = (TMultiGraph*)canvas->GetPrimitive(graphName.str().c_str());
if (multigraph == NULL) {
std::cerr << "Error: no object of TCanvas " << canvas->GetName() << " with name ";
std::cerr << graphName.str() << std::endl;
return;
}
multigraph->GetYaxis()->SetRangeUser(0.3, 1.7);
multigraph->GetYaxis()->SetLabelSize(0.03);
canvas->Draw();
canvas->SetCanvasSize(600,600);
canvas->SetWindowSize(610,630);
TPaveText* label = new TPaveText(0.25, 0.8, 0.55, 0.9, "NDC");
label->SetTextFont(62);
label->SetTextSize(0.03);
label->SetBorderSize(0);
label->SetFillColor(0);
label->AddText("CMS 2011");
label->AddText("");
label->AddText("#int L dt = 204 pb^{-1}");
label->SetTextAlign(11);
label->Draw();
std::stringstream file;
file << "/data2/yohay/scaleFactor_" << tag << "_" << name << ".pdf";
canvas->SaveAs(file.str().c_str());
}
示例4: help
void help()
{
new TCanvas("chelp","Help on gldemos",200,10,700,600);
TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98, "These demos show different gl painters.");
title->SetFillColor(32);
title->Draw();
TPaveText *hdemo = new TPaveText(0.04, 0.04, 0.96, 0.8);
hdemo->SetTextAlign(12);
hdemo->SetTextFont(52);
hdemo->SetTextColor(kBlue);
hdemo->AddText("1. Glsurfaces demo shows glsurf4, glsurf1, glsurf3, glsurf1cyl, glsurfpol, gltf3 options.");
hdemo->AddText("2. Glrose demontrates \"glsurf2pol\" drawing option and user-defined palette.");
hdemo->AddText("3. Gltf3 demo shows \"gltf3\" option.");
hdemo->AddText("4. Glbox demo shows \"glbox\" and \"glbox1\" options for TH3.");
hdemo->AddText("5. Glparametric demo shows how to define and display parametric surfaces.");
hdemo->AddText("You can zoom any plot: press 'J', 'K', 'j', 'k' keys, or use mouse wheel.");
hdemo->AddText("Rotate any plot:");
hdemo->AddText(" ---select plot with mouse cursor,");
hdemo->AddText(" ---move mouse cursor, pressing and holding left mouse button ");
hdemo->AddText("Pan plot:");
hdemo->AddText(" ---select with mouse cursor a part of a plot, other than back box planes ,");
hdemo->AddText(" ---move mouse cursor, pressing and holding middle mouse button ");
hdemo->AddText("Selected part of a plot is higlighted (TF3 higlighting is not implemented yet.)");
hdemo->AddText("You can select one of back box planes, press middle mouse button and move cursor-");
hdemo->AddText("this will create \"slice\" (TF does not support yet).");
hdemo->AddText("After the slice was created, you can project it on a back box");
hdemo->AddText(" ---press key 'p' (now implemented only for surf options ).");
hdemo->AddText("Left double click removes all slices/projections.");
hdemo->Draw();
}
示例5: tpcanalspectra
void tpcanalspectra(Int_t isec =1, Int_t r1= 2)
{
AliTPCParam * tpcparam = gtpc->GetParam();
//make window for displaying results
TCanvas * c_occu = new TCanvas("occuhis","Occupancy dependence",700,900);
c_occu->Update();
TPad * pad1 = new TPad("ocpad1","occupancy1",0.05,0.61,0.95,0.95,21);
pad1->Draw();
TPad * pad2 = new TPad("ocpad2","occupancy",0.05,0.61,0.95,0.95,21);
pad2->Draw();
TPad * pad3 = new TPad("ocpad3","occupancy1",0.05,0.25,0.95,0.60,21);
pad3->Draw();
TPad * pad4 = new TPad("ocpad4","occupancy",0.05,0.25,0.95,0.60,21);
pad4->Draw();
//add comments to the histograms
TPaveText * comment = new TPaveText(0.05,0.03,0.95,0.2,"NDC");
comment->SetTextAlign(12);
comment->SetFillColor(42);
comment->ReadFile("comment.txt");
comment->Draw();
TH2F his
//prepare histogram
for (Int_t i=1;i<irow;i+=lstep)
{
tpcanal(isec,i,10,&res[0],kFALSE,tmin);
}
//plot occupancy histogram
pad1->SetGridx();
pad1->SetGridy();
}
示例6: DrawCMSLabels
// Draw statistics info above plot
void DrawCMSLabels(double lumi, double energy, double textSize) {
//const char *text = "%2.1f #times 10^{6} clusters (fiducial) (%1.1f GeV)";
const char *text;
if(lumi > 10000000) {
lumi /= 10000000;
text = "%2.1f #times 10^{7} tracks (%1.1f GeV)";
}
else {
lumi /= 1000000;
text = "%2.1f #times 10^{6} tracks (%1.1f GeV)";
}
TPaveText *label = new TPaveText();
label->SetX1NDC(gStyle->GetPadLeftMargin());
label->SetY1NDC(1.0-gStyle->GetPadTopMargin());
label->SetX2NDC(1.0-gStyle->GetPadRightMargin());
label->SetY2NDC(1.0);
label->SetTextFont(42);
label->AddText(Form(text, lumi, energy));
label->SetFillStyle(0);
label->SetBorderSize(0);
if (textSize!=0) label->SetTextSize(textSize);
label->SetTextAlign(32);
label->Draw("same");
}
示例7: labels1
void labels1()
{
Int_t i;
const Int_t nx = 20;
const char *people[nx] = {"Jean","Pierre","Marie","Odile",
"Sebastien","Fons","Rene","Nicolas","Xavier","Greg",
"Bjarne","Anton","Otto","Eddy","Peter","Pasha",
"Philippe","Suzanne","Jeff","Valery"};
TCanvas *c1 = new TCanvas("c1","demo bin labels",10,10,900,500);
c1->SetGrid();
c1->SetBottomMargin(0.15);
TH1F *h = new TH1F("h","test",nx,0,nx);
h->SetFillColor(38);
for (i=0;i<5000;i++) h->Fill(gRandom->Gaus(0.5*nx,0.2*nx));
h->SetStats(0);
for (i=1;i<=nx;i++) h->GetXaxis()->SetBinLabel(i,people[i-1]);
h->Draw();
TPaveText *pt = new TPaveText(0.6,0.7,0.98,0.98,"brNDC");
pt->SetFillColor(18);
pt->SetTextAlign(12);
pt->AddText("Use the axis Context Menu LabelsOption");
pt->AddText(" \"a\" to sort by alphabetic order");
pt->AddText(" \">\" to sort by decreasing values");
pt->AddText(" \"<\" to sort by increasing values");
pt->Draw();
}
示例8: DrawStatBox
void DrawStatBox(TObject** Histos, std::vector<char*> legend, bool Mean, double X, double Y, double W, double H)
{
int N = legend.size();
char buffer[255];
if(Mean)H*=3;
for(int i=0;i<N;i++){
TPaveText* stat = new TPaveText(X,Y-(i*H), X+W, Y-(i+1)*H, "NDC");
TH1* Histo = (TH1*)Histos[i];
sprintf(buffer,"Entries : %i\n",(int)Histo->GetEntries());
stat->AddText(buffer);
if(Mean){
sprintf(buffer,"Mean : %6.2f\n",Histo->GetMean());
stat->AddText(buffer);
sprintf(buffer,"RMS : %6.2f\n",Histo->GetRMS());
stat->AddText(buffer);
}
stat->SetFillColor(0);
stat->SetLineColor(Color[i]);
stat->SetTextColor(Color[i]);
stat->SetBorderSize(0);
stat->SetMargin(0.05);
stat->SetTextAlign(12);
stat->Draw();
}
}
示例9: TCanvas
// 1-D histograms with alphanumeric labels
// author; Rene Brun
TCanvas *hlabels1()
{
const Int_t nx = 20;
const char *people[nx] = {"Jean","Pierre","Marie","Odile","Sebastien",
"Fons","Rene","Nicolas","Xavier","Greg","Bjarne","Anton","Otto",
"Eddy","Peter","Pasha","Philippe","Suzanne","Jeff","Valery"};
TCanvas *c1 = new TCanvas("c1","demo bin labels",10,10,900,500);
c1->SetGrid();
c1->SetTopMargin(0.15);
TH1F *h = new TH1F("h","test",3,0,3);
h->SetStats(0);
h->SetFillColor(38);
h->SetCanExtend(TH1::kAllAxes);
for (Int_t i=0;i<5000;i++) {
Int_t r = gRandom->Rndm()*20;
h->Fill(people[r],1);
}
h->LabelsDeflate();
h->Draw();
TPaveText *pt = new TPaveText(0.7,0.85,0.98,0.98,"brNDC");
pt->SetFillColor(18);
pt->SetTextAlign(12);
pt->AddText("Use the axis Context Menu LabelsOption");
pt->AddText(" \"a\" to sort by alphabetic order");
pt->AddText(" \">\" to sort by decreasing values");
pt->AddText(" \"<\" to sort by increasing values");
pt->Draw();
return c1;
}
示例10: 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);
}
示例11: CreateDrawAndSaveHistogramFWHM
void CreateDrawAndSaveHistogramFWHM(TH1* &histo, TString outputdir, TString outputname, bool saveoutput, bool close, bool log=false){
/** @brief saves Histogramm as *.root and *.png and if wanted closes the histograms at the end
* @details This mehtod create a histogramm and save it as root and png file. If you choose close, the canvas is closed after the histogram was saved
*/
setPandaStyle();
// gStyle->SetOptStat(1111);
TString name = TString(histo->GetName());
TString title = TString(histo->GetTitle());
TCanvas * canvas = new TCanvas("c_"+name, title, 0,0,1500,1000);
histo->Draw();
//***** FWHM ******
double max = histo->GetMaximum();
int bin1 = histo->FindFirstBinAbove(max/2);
int bin2 = histo->FindLastBinAbove(max/2);
double lowerbin = histo->GetBinCenter(bin1);
double upperbin = histo->GetBinCenter(bin2) ;
double FWHM = upperbin - lowerbin;
TPaveText * text = new TPaveText(0.2,1500,1,3500);
TString name = TString::Format("FWHM %.4f", FWHM);
text->InsertText(name);
text->SetFillColor(kWhite);
text->SetTextFont(4);
text->SetTextSize(30);
text->SetTextAlign(12);
text->Draw("SAME");
if(log) canvas->SetLogy();
PandaSmartLabel("L");
if (saveoutput){
canvas->Print(outputdir + "root-files/" + outputname + ".root");
canvas->Print(outputdir + "png-files/" + outputname + ".png");
canvas->Print(outputdir + "pdf-files/" + outputname + ".pdf");
}
if (close) canvas->Close();
}
示例12: TPaveText
TPaveText *text(const char *txt, float x1, float y1, float x2, float y2) {
TPaveText *text = new TPaveText(x1,y1,x2,y2,"brNDC");
text->AddText(txt);
text->SetBorderSize(0);
text->SetFillStyle(0);
text->SetTextAlign(12);
text->SetTextFont(42);
text->SetTextSize(0.05);
return text;
}
示例13: plot
TCanvas * plot (TH1F* histoDataIn, TString legendData, TH1F* histoSimulationIn, TString legendSimulation,
TString & canvasName, Float_t maximum = 0.15, TString xAxisTitle = "#eta",
TString yAxisTitle = "Number of Clusters", TString error = "", bool useLegend = true,
TString text = "", Float_t textX = 0.7, Float_t textY = 0.4, Float_t rebin = 0 ) {
TH1F * histoData = (TH1F*)histoDataIn->Clone();
TH1F * histoSimulation = (TH1F*)histoSimulationIn->Clone();
// histoData->Sumw2();
histoData->Scale(1/(histoData->Integral()));
histoSimulation->Scale(1/(histoSimulation->Integral()));
// Create also the legend and add the histograms
TLegend * legend = new TLegend( 0.55, 0.65, 0.76, 0.82 );
legend->AddEntry( histoData, xAxisTitle );
legend->AddEntry( histoSimulation, yAxisTitle, "F" );
cout << "histoData = " << histoData << endl;
cout << "histoSimulation = " << histoSimulation << endl;
TCanvas * c = new TCanvas( canvasName, canvasName, 1000, 800 );
c->Draw();
histoSimulation->SetMaximum(maximum);
histoSimulation->SetFillColor(kRed);
// histoSimulation->SetLineWidth(0);
histoSimulation->SetLineColor(kRed);
histoSimulation->SetXTitle(xAxisTitle);
histoSimulation->SetYTitle(yAxisTitle);
histoSimulation->SetTitleOffset(1.6,"Y");
histoSimulation->SetTitle();
histoData->SetLineStyle(1);
histoData->SetLineWidth(2.5);
histoSimulation->Draw();
histoData->Draw("same");
legend->SetFillColor(kWhite);
if (useLegend) legend->Draw("same");
if ( text != "" ) {
TPaveText * pt = new TPaveText(textX, textY, textX+0.2, textY+0.17, "NDC" ); // "NDC" option sets coords relative to pad dimensions
pt->SetFillColor(0); // text is black on white
pt->SetTextSize(0.08);
pt->SetBorderSize(0);
pt->SetTextAlign(12);
pt->AddText(text);
pt->Draw("same"); //to draw your text object
}
return c;
};
示例14: 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);
}
示例15: TPaveText
void
CMSPrelim(const char* dataset, const char* channel,const char* cat)
{
double lowX=0.16;
double lowY=0.835;
int color=1; int font = 62;
TPaveText* cmsprel = new TPaveText(lowX, lowY+0.06, lowX+0.30, lowY+0.16, "NDC");
cmsprel->SetBorderSize( 0 );
cmsprel->SetFillStyle( 0 );
cmsprel->SetTextAlign( 12 );
cmsprel->SetTextColor( color );
cmsprel->SetTextFont ( font );
//cmsprel->SetTextSize ( 0.035 );
//cmsprel->SetTextSize ( 0.027 );
cmsprel->SetTextSize ( 0.030 );
cmsprel->AddText(dataset);
cmsprel->Draw();
TPaveText* chan = new TPaveText(lowX+0.05, lowY-0.002, lowX+0.45, lowY+0.028, "NDC");
chan->SetBorderSize( 0 );
chan->SetFillStyle( 0 );
chan->SetTextAlign( 12 );
chan->SetTextSize ( 0.035 );
chan->SetTextColor( color );
chan->SetTextFont ( font );
chan->AddText(channel);
chan->Draw();
TPaveText* category = new TPaveText(lowX+0.05, lowY-0.002-0.06, lowX+0.45, lowY+0.028-0.06, "NDC");
category->SetBorderSize( 0 );
category->SetFillStyle( 0 );
category->SetTextAlign( 12 );
category->SetTextSize ( 0.035 );
category->SetTextColor( color );
category->SetTextFont ( font );
category->AddText(cat);
category->Draw();
}