#include "Riostream.h"
#include "TROOT.h"
#include "TPavesText.h"
#include "TVirtualPad.h"
#include "TBufferFile.h"
#include "TError.h"
ClassImp(TPavesText)
/*
<img src="gif/pavestext.gif">
*/
//End_Html
TPavesText::TPavesText(): TPaveText()
{
fNpaves = 5;
}
TPavesText::TPavesText(Double_t x1, Double_t y1,Double_t x2, Double_t y2, Int_t npaves,Option_t *option)
:TPaveText(x1,y1,x2,y2,option)
{
fNpaves = npaves;
SetBorderSize(1);
}
TPavesText::~TPavesText()
{
}
TPavesText::TPavesText(const TPavesText &pavestext) : TPaveText()
{
TBufferFile b(TBuffer::kWrite);
TPavesText *p = (TPavesText*)(&pavestext);
p->Streamer(b);
b.SetReadMode();
b.SetBufferOffset(0);
Streamer(b);
}
void TPavesText::Draw(Option_t *option)
{
AppendPad(option);
}
void TPavesText::Paint(Option_t *option)
{
Int_t bordersize = GetBorderSize();
const char *opt = GetOption();
Double_t signx, signy;
if (strstr(opt,"l")) signx = -1;
else signx = 1;
if (strstr(opt,"b")) signy = -1;
else signy = 1;
Double_t dx = 3*signx*(gPad->PixeltoX(bordersize) - gPad->PixeltoX(0));
Double_t dy = 3*signy*(gPad->PixeltoY(bordersize) - gPad->PixeltoY(0));
TPave::ConvertNDCtoPad();
for (Int_t ipave=fNpaves;ipave>1;ipave--) {
Double_t x1 = fX1 + dx*Double_t(ipave-1);
Double_t y1 = fY1 - dy*Double_t(ipave-1);
Double_t x2 = fX2 + dx*Double_t(ipave-1);
Double_t y2 = fY2 - dy*Double_t(ipave-1);
TPave::PaintPave(x1,y1,x2,y2,bordersize,option);
}
TPaveText::Paint(option);
}
void TPavesText::SavePrimitive(ostream &out, Option_t * )
{
if (!strcmp(GetName(),"stats")) return;
if (!strcmp(GetName(),"title")) return;
char quote = '"';
out<<" "<<endl;
if (gROOT->ClassSaved(TPavesText::Class())) {
out<<" ";
} else {
out<<" TPavesText *";
}
out<<"pst = new TPavesText("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
<<","<<fNpaves<<","<<quote<<fOption<<quote<<");"<<endl;
if (strcmp(GetName(),"TPave")) {
out<<" pst->SetName("<<quote<<GetName()<<quote<<");"<<endl;
}
if (fLabel.Length() > 0) {
out<<" pst->SetLabel("<<quote<<fLabel<<quote<<");"<<endl;
}
if (fBorderSize != 4) {
out<<" pst->SetBorderSize("<<fBorderSize<<");"<<endl;
}
SaveFillAttributes(out,"pst",0,1001);
SaveLineAttributes(out,"pst",1,1,1);
SaveTextAttributes(out,"pst",22,0,1,62,0);
TPaveText::SaveLines(out,"pst");
out<<" pst->Draw();"<<endl;
}