#include <stdio.h>
#include "TLegendEntry.h"
#include "TVirtualPad.h"
#include "TROOT.h"
#include "Riostream.h"
ClassImp(TLegendEntry)
TLegendEntry::TLegendEntry(): TAttText(), TAttLine(), TAttFill(), TAttMarker()
{
fObject = 0;
}
TLegendEntry::TLegendEntry(const TObject* obj, const char* label, Option_t* option )
:TAttText(0,0,0,0,0), TAttLine(1,1,1), TAttFill(0,0), TAttMarker(1,21,1)
{
fObject = 0;
if ( !label && obj ) fLabel = obj->GetTitle();
else fLabel = label;
fOption = option;
SetObject((TObject*)obj);
}
TLegendEntry::TLegendEntry( const TLegendEntry &entry ) : TObject(entry), TAttText(entry), TAttLine(entry), TAttFill(entry), TAttMarker(entry)
{
((TLegendEntry&)entry).Copy(*this);
}
TLegendEntry::~TLegendEntry()
{
fObject = 0;
}
void TLegendEntry::Copy( TObject &obj ) const
{
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 *) const
{
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(ostream &out, const char* name )
{
char quote = '"';
if ( gROOT->ClassSaved( TLegendEntry::Class() ) ) {
out << " entry=";
} else {
out << " TLegendEntry *entry=";
}
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 )
{
if ( ( fObject && fLabel == fObject->GetTitle() ) || !fLabel ) {
fLabel = obj->GetTitle();
}
fObject = obj;
}
void TLegendEntry::SetObject( const char* objectName)
{
TObject* obj = 0;
TList* padprimitives = gPad->GetListOfPrimitives();
if ( padprimitives ) obj = padprimitives->FindObject( objectName );
SetObject( obj );
}
Last change: Mon Dec 8 10:00:42 2008
Last generated: 2008-12-08 10:00
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.