ATLAS Offline Software
Loading...
Searching...
No Matches
Legend Class Reference

slightly more convenient legend class More...

#include <computils.h>

Collaboration diagram for Legend:

Public Member Functions

 Legend ()
 Legend (double x1, double x2, double y1, double y2)
 Legend (const Legend &legend)
 ~Legend ()
TLegend * legend ()
size_t size () const
double TextSize () const
int TextFont () const
double height () const
double width () const
void AddEntry (TObject *tobj, const std::string &s, const std::string &type="p")
void Draw ()

Private Attributes

TLegend * m_leg
double m_x [2]
double m_y [2]
std::vector< TObject * > m_obj
std::vector< std::string > m_entries
std::vector< std::string > m_type

Detailed Description

slightly more convenient legend class

Definition at line 350 of file computils.h.

Constructor & Destructor Documentation

◆ Legend() [1/3]

Legend::Legend ( )
inline

Definition at line 354 of file computils.h.

354 : m_leg(nullptr){
355 m_x[0]=0.0;
356 m_y[0]=0.0;
357 m_x[1]=0.0;
358 m_y[1]=0.0;
359 }
TLegend * m_leg
Definition computils.h:433
double m_y[2]
Definition computils.h:436
double m_x[2]
Definition computils.h:435

◆ Legend() [2/3]

Legend::Legend ( double x1,
double x2,
double y1,
double y2 )
inline

Definition at line 361 of file computils.h.

◆ Legend() [3/3]

Legend::Legend ( const Legend & legend)
inline

Definition at line 371 of file computils.h.

371 : m_leg(legend.m_leg),
372 m_x{legend.m_x[0], legend.m_x[1]},
373 m_y{legend.m_y[0], legend.m_y[1]} { }
TLegend * legend()
Definition computils.h:377

◆ ~Legend()

Legend::~Legend ( )
inline

Definition at line 375 of file computils.h.

375{ }

Member Function Documentation

◆ AddEntry()

void Legend::AddEntry ( TObject * tobj,
const std::string & s,
const std::string & type = "p" )
inline

Definition at line 391 of file computils.h.

391 {
392 m_obj.push_back( tobj );
393 m_entries.push_back( s );
394 m_type.push_back( type );
395 }
std::vector< TObject * > m_obj
Definition computils.h:438
std::vector< std::string > m_entries
Definition computils.h:439
std::vector< std::string > m_type
Definition computils.h:440

◆ Draw()

void Legend::Draw ( )
inline

ha ! don't actually create the legend until we want to draw it, then we can determine the size etc automatically

Definition at line 397 of file computils.h.

397 {
398
401
402 double y0 = 0;
403
404 if ( m_y[0]>0.5 ) {
405 y0 = m_y[1] - m_entries.size()*0.05;
406 }
407 else {
408 y0 = m_y[0];
409 m_y[1] = y0 + m_entries.size()*0.05;
410 }
411
412 m_leg = new TLegend( m_x[0], y0, m_x[1], m_y[1] );
413
414#if 1
415 m_leg->SetBorderSize(0);
416 m_leg->SetTextFont(42);
417 m_leg->SetTextSize(0.04);
418 m_leg->SetFillStyle(3000);
419 m_leg->SetFillColor(0);
420 m_leg->SetLineColor(0);
421#endif
422
423 for ( size_t i=0 ; i<m_entries.size() ; i++ ) {
424 m_leg->AddEntry( m_obj[i], m_entries[i].c_str(), m_type[i].c_str() );
425 }
426
427 m_leg->Draw();
428 }

◆ height()

double Legend::height ( ) const
inline

Definition at line 387 of file computils.h.

387{ return m_y[1]-m_y[0]; }

◆ legend()

TLegend * Legend::legend ( )
inline

Definition at line 377 of file computils.h.

377{ return m_leg; }

◆ size()

size_t Legend::size ( ) const
inline

Definition at line 379 of file computils.h.

379 {
380 return m_entries.size();
381 }

◆ TextFont()

int Legend::TextFont ( ) const
inline

Definition at line 385 of file computils.h.

385{ return m_leg->GetTextFont(); }

◆ TextSize()

double Legend::TextSize ( ) const
inline

Definition at line 383 of file computils.h.

383{ return m_leg->GetTextSize(); }

◆ width()

double Legend::width ( ) const
inline

Definition at line 389 of file computils.h.

389{ return m_x[1]-m_x[0]; }

Member Data Documentation

◆ m_entries

std::vector<std::string> Legend::m_entries
private

Definition at line 439 of file computils.h.

◆ m_leg

TLegend* Legend::m_leg
private

Definition at line 433 of file computils.h.

◆ m_obj

std::vector<TObject*> Legend::m_obj
private

Definition at line 438 of file computils.h.

◆ m_type

std::vector<std::string> Legend::m_type
private

Definition at line 440 of file computils.h.

◆ m_x

double Legend::m_x[2]
private

Definition at line 435 of file computils.h.

◆ m_y

double Legend::m_y[2]
private

Definition at line 436 of file computils.h.


The documentation for this class was generated from the following file: