Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TVirtualHistPainter.cxx
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 30/08/99
3 /*************************************************************************
4  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #include "TROOT.h"
12 #include "TVirtualHistPainter.h"
13 #include "TPluginManager.h"
14 #include "TClass.h"
15 
16 TClass *TVirtualHistPainter::fgPainter = 0;
17 
18 
19 ClassImp(TVirtualHistPainter);
20 
21 /** \class TVirtualHistPainter
22  \ingroup Hist
23  Abstract interface to a histogram painter
24 */
25 
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// Static function returning a pointer to the current histogram painter.
29 /// The painter will paint the specified obj. If the histogram painter
30 /// does not exist a default painter is created.
31 
32 TVirtualHistPainter *TVirtualHistPainter::HistPainter(TH1 *obj)
33 {
34  // if no painter set yet, create a default painter via the PluginManager
35  if (!fgPainter) {
36  TPluginHandler *h;
37  if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualHistPainter"))) {
38  if (h->LoadPlugin() == -1)
39  return 0;
40  TVirtualHistPainter::SetPainter(h->GetClass());
41  if (!fgPainter) return 0;
42  } else {
43  // fgPainter is still null
44  return 0;
45  }
46  }
47 
48  //create an instance of the histogram painter
49  TVirtualHistPainter *p = (TVirtualHistPainter*)fgPainter->New();
50  if (p) p->SetHistogram(obj);
51  return p;
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Static function to set an alternative histogram painter.
56 
57 void TVirtualHistPainter::SetPainter(const char *painter)
58 {
59  fgPainter = TClass::GetClass(painter);
60 }