00001 // @(#)root/hist:$Id: TVirtualHistPainter.cxx 21346 2007-12-12 16:18:29Z couet $ 00002 // Author: Rene Brun 30/08/99 00003 /************************************************************************* 00004 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00005 * All rights reserved. * 00006 * * 00007 * For the licensing terms see $ROOTSYS/LICENSE. * 00008 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00009 *************************************************************************/ 00010 00011 #include "TROOT.h" 00012 #include "TVirtualHistPainter.h" 00013 #include "TPluginManager.h" 00014 #include "TClass.h" 00015 00016 TClass *TVirtualHistPainter::fgPainter = 0; 00017 00018 00019 ClassImp(TVirtualHistPainter) 00020 00021 //______________________________________________________________________________ 00022 // 00023 // TVirtualHistPainter is an abstract interface to a histogram painter. 00024 // 00025 00026 00027 //______________________________________________________________________________ 00028 TVirtualHistPainter *TVirtualHistPainter::HistPainter(TH1 *obj) 00029 { 00030 // Static function returning a pointer to the current histogram painter. 00031 // The painter will paint the specified obj. If the histogram painter 00032 // does not exist a default painter is created. 00033 00034 // if no painter set yet, create a default painter via the PluginManager 00035 if (!fgPainter) { 00036 TPluginHandler *h; 00037 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualHistPainter"))) { 00038 if (h->LoadPlugin() == -1) 00039 return 0; 00040 TVirtualHistPainter::SetPainter(h->GetClass()); 00041 if (!fgPainter) return 0; 00042 } 00043 } 00044 00045 //create an instance of the histogram painter 00046 TVirtualHistPainter *p = (TVirtualHistPainter*)fgPainter->New(); 00047 if (p) p->SetHistogram(obj); 00048 return p; 00049 } 00050 00051 //______________________________________________________________________________ 00052 void TVirtualHistPainter::SetPainter(const char *painter) 00053 { 00054 // Static function to set an alternative histogram painter. 00055 00056 fgPainter = TClass::GetClass(painter); 00057 }