ROOT logo
// @(#)root/graf:$Id: TPavesText.cxx 20882 2007-11-19 11:31:26Z rdm $
// Author: Rene Brun   19/11/95

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "Riostream.h"
#include "TROOT.h"
#include "TPavesText.h"
#include "TVirtualPad.h"
#include "TBufferFile.h"
#include "TError.h"

ClassImp(TPavesText)


//______________________________________________________________________________
//  A PavesText is a PaveText (see TPaveText) with several stacked paves.
//Begin_Html
/*
<img src="gif/pavestext.gif">
*/
//End_Html
//


//______________________________________________________________________________
TPavesText::TPavesText(): TPaveText()
{
   // Pavestext default constructor.

   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)
{
   // Pavestext normal constructor.
   //
   // The PavesText is by default defined bith bordersize=1 and option ="br".
   //  option = "T" Top frame
   //  option = "B" Bottom frame
   //  option = "R" Right frame
   //  option = "L" Left frame
   //  option = "NDC" x1,y1,x2,y2 are given in NDC
   //  option = "ARC" corners are rounded
   //
   //  IMPORTANT NOTE:
   //  Because TPave objects (and objects deriving from TPave) have their
   //  master coordinate system in NDC, one cannot use the TBox functions
   //  SetX1,SetY1,SetX2,SetY2 to change the corner coordinates. One should use
   //  instead SetX1NDC, SetY1NDC, SetX2NDC, SetY2NDC.

   fNpaves = npaves;
   SetBorderSize(1);
}


//______________________________________________________________________________
TPavesText::~TPavesText()
{
   // Pavestext default destructor.
}


//______________________________________________________________________________
TPavesText::TPavesText(const TPavesText &pavestext) : TPaveText()
{
   // Pavestext copy constructor.

   TBufferFile b(TBuffer::kWrite);
   TPavesText *p = (TPavesText*)(&pavestext);
   p->Streamer(b);
   b.SetReadMode();
   b.SetBufferOffset(0);
   Streamer(b);
}


//______________________________________________________________________________
void TPavesText::Draw(Option_t *option)
{
   // Draw this pavestext with its current attributes.

   AppendPad(option);
}


//______________________________________________________________________________
void TPavesText::Paint(Option_t *option)
{
   // Paint this pavestext with its current attributes.

   // Draw the fNpaves-1 stacked paves
   // The spacing between paves is set to 3 times the bordersize
   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);
   }

   // Draw the top pavetext
   TPaveText::Paint(option);
}


//______________________________________________________________________________
void TPavesText::SavePrimitive(ostream &out, Option_t * /*= ""*/)
{
   // Save primitive as a C++ statement(s) on output stream out

   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;
}
 TPavesText.cxx:1
 TPavesText.cxx:2
 TPavesText.cxx:3
 TPavesText.cxx:4
 TPavesText.cxx:5
 TPavesText.cxx:6
 TPavesText.cxx:7
 TPavesText.cxx:8
 TPavesText.cxx:9
 TPavesText.cxx:10
 TPavesText.cxx:11
 TPavesText.cxx:12
 TPavesText.cxx:13
 TPavesText.cxx:14
 TPavesText.cxx:15
 TPavesText.cxx:16
 TPavesText.cxx:17
 TPavesText.cxx:18
 TPavesText.cxx:19
 TPavesText.cxx:20
 TPavesText.cxx:21
 TPavesText.cxx:22
 TPavesText.cxx:23
 TPavesText.cxx:24
 TPavesText.cxx:25
 TPavesText.cxx:26
 TPavesText.cxx:27
 TPavesText.cxx:28
 TPavesText.cxx:29
 TPavesText.cxx:30
 TPavesText.cxx:31
 TPavesText.cxx:32
 TPavesText.cxx:33
 TPavesText.cxx:34
 TPavesText.cxx:35
 TPavesText.cxx:36
 TPavesText.cxx:37
 TPavesText.cxx:38
 TPavesText.cxx:39
 TPavesText.cxx:40
 TPavesText.cxx:41
 TPavesText.cxx:42
 TPavesText.cxx:43
 TPavesText.cxx:44
 TPavesText.cxx:45
 TPavesText.cxx:46
 TPavesText.cxx:47
 TPavesText.cxx:48
 TPavesText.cxx:49
 TPavesText.cxx:50
 TPavesText.cxx:51
 TPavesText.cxx:52
 TPavesText.cxx:53
 TPavesText.cxx:54
 TPavesText.cxx:55
 TPavesText.cxx:56
 TPavesText.cxx:57
 TPavesText.cxx:58
 TPavesText.cxx:59
 TPavesText.cxx:60
 TPavesText.cxx:61
 TPavesText.cxx:62
 TPavesText.cxx:63
 TPavesText.cxx:64
 TPavesText.cxx:65
 TPavesText.cxx:66
 TPavesText.cxx:67
 TPavesText.cxx:68
 TPavesText.cxx:69
 TPavesText.cxx:70
 TPavesText.cxx:71
 TPavesText.cxx:72
 TPavesText.cxx:73
 TPavesText.cxx:74
 TPavesText.cxx:75
 TPavesText.cxx:76
 TPavesText.cxx:77
 TPavesText.cxx:78
 TPavesText.cxx:79
 TPavesText.cxx:80
 TPavesText.cxx:81
 TPavesText.cxx:82
 TPavesText.cxx:83
 TPavesText.cxx:84
 TPavesText.cxx:85
 TPavesText.cxx:86
 TPavesText.cxx:87
 TPavesText.cxx:88
 TPavesText.cxx:89
 TPavesText.cxx:90
 TPavesText.cxx:91
 TPavesText.cxx:92
 TPavesText.cxx:93
 TPavesText.cxx:94
 TPavesText.cxx:95
 TPavesText.cxx:96
 TPavesText.cxx:97
 TPavesText.cxx:98
 TPavesText.cxx:99
 TPavesText.cxx:100
 TPavesText.cxx:101
 TPavesText.cxx:102
 TPavesText.cxx:103
 TPavesText.cxx:104
 TPavesText.cxx:105
 TPavesText.cxx:106
 TPavesText.cxx:107
 TPavesText.cxx:108
 TPavesText.cxx:109
 TPavesText.cxx:110
 TPavesText.cxx:111
 TPavesText.cxx:112
 TPavesText.cxx:113
 TPavesText.cxx:114
 TPavesText.cxx:115
 TPavesText.cxx:116
 TPavesText.cxx:117
 TPavesText.cxx:118
 TPavesText.cxx:119
 TPavesText.cxx:120
 TPavesText.cxx:121
 TPavesText.cxx:122
 TPavesText.cxx:123
 TPavesText.cxx:124
 TPavesText.cxx:125
 TPavesText.cxx:126
 TPavesText.cxx:127
 TPavesText.cxx:128
 TPavesText.cxx:129
 TPavesText.cxx:130
 TPavesText.cxx:131
 TPavesText.cxx:132
 TPavesText.cxx:133
 TPavesText.cxx:134
 TPavesText.cxx:135
 TPavesText.cxx:136
 TPavesText.cxx:137
 TPavesText.cxx:138
 TPavesText.cxx:139
 TPavesText.cxx:140
 TPavesText.cxx:141
 TPavesText.cxx:142
 TPavesText.cxx:143
 TPavesText.cxx:144
 TPavesText.cxx:145
 TPavesText.cxx:146
 TPavesText.cxx:147
 TPavesText.cxx:148
 TPavesText.cxx:149
 TPavesText.cxx:150
 TPavesText.cxx:151
 TPavesText.cxx:152
 TPavesText.cxx:153
 TPavesText.cxx:154
 TPavesText.cxx:155
 TPavesText.cxx:156
 TPavesText.cxx:157
 TPavesText.cxx:158
 TPavesText.cxx:159