TPavesText.cxx

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TPavesText.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Rene Brun   19/11/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 //  A PavesText is a PaveText (see TPaveText) with several stacked paves.
00024 //Begin_Html
00025 /*
00026 <img src="gif/pavestext.gif">
00027 */
00028 //End_Html
00029 //
00030 
00031 
00032 //______________________________________________________________________________
00033 TPavesText::TPavesText(): TPaveText()
00034 {
00035    // Pavestext default constructor.
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    // Pavestext normal constructor.
00046    //
00047    // The PavesText is by default defined bith bordersize=1 and option ="br".
00048    //  option = "T" Top frame
00049    //  option = "B" Bottom frame
00050    //  option = "R" Right frame
00051    //  option = "L" Left frame
00052    //  option = "NDC" x1,y1,x2,y2 are given in NDC
00053    //  option = "ARC" corners are rounded
00054    //
00055    //  IMPORTANT NOTE:
00056    //  Because TPave objects (and objects deriving from TPave) have their
00057    //  master coordinate system in NDC, one cannot use the TBox functions
00058    //  SetX1,SetY1,SetX2,SetY2 to change the corner coordinates. One should use
00059    //  instead SetX1NDC, SetY1NDC, SetX2NDC, SetY2NDC.
00060 
00061    fNpaves = npaves;
00062    SetBorderSize(1);
00063 }
00064 
00065 
00066 //______________________________________________________________________________
00067 TPavesText::~TPavesText()
00068 {
00069    // Pavestext default destructor.
00070 }
00071 
00072 
00073 //______________________________________________________________________________
00074 TPavesText::TPavesText(const TPavesText &pavestext) : TPaveText()
00075 {
00076    // Pavestext copy constructor.
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    // Draw this pavestext with its current attributes.
00091 
00092    AppendPad(option);
00093 }
00094 
00095 
00096 //______________________________________________________________________________
00097 void TPavesText::Paint(Option_t *option)
00098 {
00099    // Paint this pavestext with its current attributes.
00100 
00101    // Draw the fNpaves-1 stacked paves
00102    // The spacing between paves is set to 3 times the bordersize
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    // Draw the top pavetext
00124    TPaveText::Paint(option);
00125 }
00126 
00127 
00128 //______________________________________________________________________________
00129 void TPavesText::SavePrimitive(ostream &out, Option_t * /*= ""*/)
00130 {
00131    // Save primitive as a C++ statement(s) on output stream out
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 }

Generated on Tue Jul 5 14:14:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1