// @(#)root/graf:$Name: $:$Id: TLegendEntry.cxx,v 1.2 2000/06/27 06:43:48 brun Exp $
// Author: Matthew.Adam.Dobbs 06/09/99
/*************************************************************************
* 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 "TLegendEntry.h"
#include "TVirtualPad.h"
#include "TROOT.h"
#include <fstream.h>
#include <stdio.h>
#include <iostream.h>
ClassImp(TLegendEntry)
//____________________________________________________________________________
// TLegendEntry Matthew.Adam.Dobbs@Cern.CH, September 1999
// Storage class for one entry of a TLegend
//
//____________________________________________________________________________
TLegendEntry::TLegendEntry(): TAttText(), TAttLine(), TAttFill(), TAttMarker()
{
// TLegendEntry do-nothing default constructor
fObject = 0;
}
//____________________________________________________________________________
TLegendEntry::TLegendEntry(TObject* obj, const char* label, Option_t* option )
:TAttText(12,0,1,62,0), TAttLine(1,1,1), TAttFill(0,0), TAttMarker(1,21,1)
{
//___________________________________
// TLegendEntry normal constructor for one entry in a TLegend
// obj is the object this entry will represent. If obj has
// line/fill/marker attributes, then the TLegendEntry will display
// these attributes.
// label is the text that will describe the entry, it is displayed using
// TLatex, so may have a complex format.
// option may have values
// L draw line associated w/ TAttLine if obj inherits from TAttLine
// P draw polymarker assoc. w/ TAttMarker if obj inherits from TAttMarker
// F draw a box with fill associated w/ TAttFill if obj inherits TAttFill
// default is object = "LPF"
//
fObject = obj;
if ( !label && obj ) fLabel = obj->GetTitle();
else fLabel = label;
fOption = option;
}
//____________________________________________________________________________
TLegendEntry::TLegendEntry( const TLegendEntry &entry )
{
// TLegendEntry copy constructor
((TLegendEntry&)entry).Copy(*this);
}
//____________________________________________________________________________
TLegendEntry::~TLegendEntry()
{
// TLegendEntry default destructor
fObject = 0;
}
//____________________________________________________________________________
void TLegendEntry::Copy( TObject &obj )
{
// copy this TLegendEntry into obj
TObject::Copy(obj);
TAttText::Copy((TLegendEntry&)obj);
TAttLine::Copy((TLegendEntry&)obj);
TAttFill::Copy((TLegendEntry&)obj);
TAttMarker::Copy((TLegendEntry&)obj);
((TLegendEntry&)obj).fObject = fObject;
((TLegendEntry&)obj).fLabel = fLabel;
((TLegendEntry&)obj).fOption = fOption;
}
//____________________________________________________________________________
void TLegendEntry::Print( Option_t *)
{
// dump this TLegendEntry to cout
TString output;
cout << "TLegendEntry: Object ";
if ( fObject ) output = fObject->GetName();
else output = "NULL";
cout << output << " Label ";
if ( fLabel ) output = fLabel.Data();
else output = "NULL";
cout << output << " Option ";
if (fOption ) output = fOption.Data();
else output = "NULL";
cout << output << endl;
}
//____________________________________________________________________________
void TLegendEntry::SaveEntry( ofstream &out, const char* name )
{
// Save this TLegendEntry as C++ statements on output stream out
// to be used with the SaveAs .C option
char quote = '"';
if ( gROOT->ClassSaved( TLegendEntry::Class() ) ) {
out << " ";
} else {
out << " TLegendEntry *";
}
TString objname = "NULL";
if ( fObject ) objname = fObject->GetName();
out << name << "->AddEntry("<<quote<<objname<<quote<<","<<quote<<
fLabel.Data()<<quote<<","<<quote<<fOption.Data()<<quote<<");"<<endl;
SaveFillAttributes(out,"entry",0,0);
SaveLineAttributes(out,"entry",0,0,0);
SaveMarkerAttributes(out,"entry",0,0,0);
SaveTextAttributes(out,"entry",0,0,0,0,0);
}
//____________________________________________________________________________
void TLegendEntry::SetObject(TObject* obj )
{
// (re)set the obj pointed to by this entry
if ( ( fObject && fLabel == fObject->GetTitle() ) || !fLabel ) {
fLabel = obj->GetTitle();
}
fObject = obj;
}
//____________________________________________________________________________
void TLegendEntry::SetObject( const char* objectName)
{
// (re)set the obj pointed to by this entry
TObject* obj = 0;
TList* padprimitives = gPad->GetListOfPrimitives();
if ( padprimitives ) obj = padprimitives->FindObject( objectName );
SetObject( obj );
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.