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 337 of file computils.h.

Constructor & Destructor Documentation

◆ Legend() [1/3]

Legend::Legend ( )
inline

Definition at line 341 of file computils.h.

341 : m_leg(nullptr){
342 m_x[0]=0.0;
343 m_y[0]=0.0;
344 m_x[1]=0.0;
345 m_y[1]=0.0;
346 }
TLegend * m_leg
Definition computils.h:418
double m_y[2]
Definition computils.h:421
double m_x[2]
Definition computils.h:420

◆ Legend() [2/3]

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

Definition at line 348 of file computils.h.

◆ Legend() [3/3]

Legend::Legend ( const Legend & legend)
inline

Definition at line 358 of file computils.h.

358 : m_leg(legend.m_leg),
359 m_x{legend.m_x[0], legend.m_x[1]},
360 m_y{legend.m_y[0], legend.m_y[1]} { }
TLegend * legend()
Definition computils.h:364

◆ ~Legend()

Legend::~Legend ( )
inline

Definition at line 362 of file computils.h.

362{ }

Member Function Documentation

◆ AddEntry()

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

Definition at line 378 of file computils.h.

378 {
379 m_obj.push_back( tobj );
380 m_entries.push_back( s );
381 m_type.push_back( type );
382 }
std::vector< TObject * > m_obj
Definition computils.h:423
std::vector< std::string > m_entries
Definition computils.h:424
std::vector< std::string > m_type
Definition computils.h:425

◆ 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 384 of file computils.h.

384 {
385
388
389 double y0 = 0;
390
391 if ( m_y[0]>0.5 ) {
392 y0 = m_y[1] - m_entries.size()*0.05;
393 }
394 else {
395 y0 = m_y[0];
396 m_y[1] = y0 + m_entries.size()*0.05;
397 }
398
399 m_leg = new TLegend( m_x[0], y0, m_x[1], m_y[1] );
400
401 m_leg->SetBorderSize(0);
402 m_leg->SetTextFont(42);
403 m_leg->SetTextSize(0.04);
404 m_leg->SetFillStyle(3000);
405 m_leg->SetFillColor(0);
406 m_leg->SetLineColor(0);
407
408 for ( size_t i=0 ; i<m_entries.size() ; i++ ) {
409 m_leg->AddEntry( m_obj[i], m_entries[i].c_str(), m_type[i].c_str() );
410 }
411
412 m_leg->Draw();
413 }

◆ height()

double Legend::height ( ) const
inline

Definition at line 374 of file computils.h.

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

◆ legend()

TLegend * Legend::legend ( )
inline

Definition at line 364 of file computils.h.

364{ return m_leg; }

◆ size()

size_t Legend::size ( ) const
inline

Definition at line 366 of file computils.h.

366 {
367 return m_entries.size();
368 }

◆ TextFont()

int Legend::TextFont ( ) const
inline

Definition at line 372 of file computils.h.

372{ return m_leg->GetTextFont(); }

◆ TextSize()

double Legend::TextSize ( ) const
inline

Definition at line 370 of file computils.h.

370{ return m_leg->GetTextSize(); }

◆ width()

double Legend::width ( ) const
inline

Definition at line 376 of file computils.h.

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

Member Data Documentation

◆ m_entries

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

Definition at line 424 of file computils.h.

◆ m_leg

TLegend* Legend::m_leg
private

Definition at line 418 of file computils.h.

◆ m_obj

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

Definition at line 423 of file computils.h.

◆ m_type

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

Definition at line 425 of file computils.h.

◆ m_x

double Legend::m_x[2]
private

Definition at line 420 of file computils.h.

◆ m_y

double Legend::m_y[2]
private

Definition at line 421 of file computils.h.


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