00001 {
00002
00003
00004
00005
00006
00007
00008 gROOT->Reset();
00009 c1 = new TCanvas("c1","Canvas Example",200,10,600,480);
00010
00011 gBenchmark->Start("canvas");
00012
00013
00014
00015 pad1 = new TPad("pad1","This is pad1",0.05,0.52,0.95,0.97);
00016 pad2 = new TPad("pad2","This is pad2",0.05,0.02,0.95,0.47);
00017 pad1->SetFillColor(11);
00018 pad2->SetFillColor(11);
00019 pad1->Draw();
00020 pad2->Draw();
00021
00022
00023
00024
00025
00026 pad2->cd();
00027 pad21 = new TPad("pad21","First subpad of pad2",0.02,0.05,0.48,0.95,17,3);
00028 pad22 = new TPad("pad22","Second subpad of pad2",0.52,0.05,0.98,0.95,17,3);
00029 pad21->Draw();
00030 pad22->Draw();
00031
00032
00033
00034 pad1->cd();
00035 float xt1 = 0.5;
00036 float yt1 = 0.1;
00037 t1 = new TText(0.5,yt1,"ROOT");
00038 t1->SetTextAlign(22);
00039 t1->SetTextSize(0.05);
00040 t1->Draw();
00041 line1 = new TLine(0.05,0.05,0.80,0.70);
00042 line1->SetLineWidth(8);
00043 line1->SetLineColor(2);
00044 line1->Draw();
00045 line1->DrawLine(0.6,0.1,0.9,0.9);
00046 line2 = new TLine(0.05,0.70,0.50,0.10);
00047 line2->SetLineWidth(4);
00048 line2->SetLineColor(5);
00049 line2->Draw();
00050
00051 pad21->cd();
00052 t21 = new TText(0.05,0.8,"This is pad21");
00053 t21->SetTextSize(0.1);
00054 t21->Draw();
00055 float xp2 = 0.5;
00056 float yp2 = 0.4;
00057 paves = new TPavesText(0.1,0.1,xp2,yp2);
00058 paves->AddText("This is a PavesText");
00059 paves->AddText("You can add new lines");
00060 paves->AddText("Text formatting is automatic");
00061 paves->SetFillColor(43);
00062 paves->Draw();
00063 pad22->cd();
00064 t22 = new TText(0.05,0.8,"This is pad22");
00065 t22->SetTextSize(0.1);
00066 t22->Draw();
00067 float xlc = 0.01;
00068 float ylc = 0.01;
00069 label = new TPaveLabel(xlc, ylc, xlc+0.8, ylc+0.1,"This is a PaveLabel");
00070 label->SetFillColor(24);
00071 label->Draw();
00072
00073
00074 Int_t nloops = 50;
00075 float dxp2 = (0.9-xp2)/nloops;
00076 float dyp2 = (0.7-yp2)/nloops;
00077 float dxlc = (0.1-xlc)/nloops;
00078 float dylc = (0.4-xlc)/nloops;
00079 float dxt1 = (0.5-xt1)/nloops;
00080 float dyt1 = (0.8-yt1)/nloops;
00081 float t10 = t1.GetTextSize();
00082 float t1end = 0.3;
00083 float t1ds = (t1end - t10)/nloops;
00084 Int_t color = 0;
00085 for (int i=0;i<nloops;i++) {
00086 color++;
00087 color %= 8;
00088 line1->SetLineColor(color);
00089 t1->SetTextSize(t10 + t1ds*i);
00090 t1->SetTextColor(color);
00091 t1->SetX(xt1+dxt1*i);
00092 t1->SetY(yt1+dyt1*i);
00093 pad1->Modified();
00094 paves->SetX2NDC(xp2+dxp2*i);
00095 paves->SetY2NDC(yp2+dyp2*i);
00096 pad21->Modified();
00097 label->SetX1NDC(xlc+dxlc*i);
00098 label->SetY1NDC(ylc+dylc*i);
00099 label->SetX2NDC(xlc+dxlc*i+0.8);
00100 label->SetY2NDC(ylc+dylc*i+0.2);
00101 pad22->Modified();
00102 c1->Update();
00103 }
00104 gBenchmark->Show("canvas");
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 }