00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "Riostream.h"
00013 #include "TROOT.h"
00014 #include "TPavesText.h"
00015 #include "TVirtualPad.h"
00016 #include "TBufferFile.h"
00017 #include "TError.h"
00018
00019 ClassImp(TPavesText)
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 TPavesText::TPavesText(): TPaveText()
00034 {
00035
00036
00037 fNpaves = 5;
00038 }
00039
00040
00041
00042 TPavesText::TPavesText(Double_t x1, Double_t y1,Double_t x2, Double_t y2, Int_t npaves,Option_t *option)
00043 :TPaveText(x1,y1,x2,y2,option)
00044 {
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 fNpaves = npaves;
00062 SetBorderSize(1);
00063 }
00064
00065
00066
00067 TPavesText::~TPavesText()
00068 {
00069
00070 }
00071
00072
00073
00074 TPavesText::TPavesText(const TPavesText &pavestext) : TPaveText()
00075 {
00076
00077
00078 TBufferFile b(TBuffer::kWrite);
00079 TPavesText *p = (TPavesText*)(&pavestext);
00080 p->Streamer(b);
00081 b.SetReadMode();
00082 b.SetBufferOffset(0);
00083 Streamer(b);
00084 }
00085
00086
00087
00088 void TPavesText::Draw(Option_t *option)
00089 {
00090
00091
00092 AppendPad(option);
00093 }
00094
00095
00096
00097 void TPavesText::Paint(Option_t *option)
00098 {
00099
00100
00101
00102
00103 Int_t bordersize = GetBorderSize();
00104 const char *opt = GetOption();
00105 Double_t signx, signy;
00106 if (strstr(opt,"l")) signx = -1;
00107 else signx = 1;
00108 if (strstr(opt,"b")) signy = -1;
00109 else signy = 1;
00110 Double_t dx = 3*signx*(gPad->PixeltoX(bordersize) - gPad->PixeltoX(0));
00111 Double_t dy = 3*signy*(gPad->PixeltoY(bordersize) - gPad->PixeltoY(0));
00112
00113 TPave::ConvertNDCtoPad();
00114
00115 for (Int_t ipave=fNpaves;ipave>1;ipave--) {
00116 Double_t x1 = fX1 + dx*Double_t(ipave-1);
00117 Double_t y1 = fY1 - dy*Double_t(ipave-1);
00118 Double_t x2 = fX2 + dx*Double_t(ipave-1);
00119 Double_t y2 = fY2 - dy*Double_t(ipave-1);
00120 TPave::PaintPave(x1,y1,x2,y2,bordersize,option);
00121 }
00122
00123
00124 TPaveText::Paint(option);
00125 }
00126
00127
00128
00129 void TPavesText::SavePrimitive(ostream &out, Option_t * )
00130 {
00131
00132
00133 if (!strcmp(GetName(),"stats")) return;
00134 if (!strcmp(GetName(),"title")) return;
00135 char quote = '"';
00136 out<<" "<<endl;
00137 if (gROOT->ClassSaved(TPavesText::Class())) {
00138 out<<" ";
00139 } else {
00140 out<<" TPavesText *";
00141 }
00142 out<<"pst = new TPavesText("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
00143 <<","<<fNpaves<<","<<quote<<fOption<<quote<<");"<<endl;
00144
00145 if (strcmp(GetName(),"TPave")) {
00146 out<<" pst->SetName("<<quote<<GetName()<<quote<<");"<<endl;
00147 }
00148 if (fLabel.Length() > 0) {
00149 out<<" pst->SetLabel("<<quote<<fLabel<<quote<<");"<<endl;
00150 }
00151 if (fBorderSize != 4) {
00152 out<<" pst->SetBorderSize("<<fBorderSize<<");"<<endl;
00153 }
00154 SaveFillAttributes(out,"pst",0,1001);
00155 SaveLineAttributes(out,"pst",1,1,1);
00156 SaveTextAttributes(out,"pst",22,0,1,62,0);
00157 TPaveText::SaveLines(out,"pst");
00158 out<<" pst->Draw();"<<endl;
00159 }