Re: How do I make my object "browsable"

From: Christian Holm Christensen <cholm_at_nbi.dk>
Date: Wed, 26 Mar 2008 09:55:52 +0100


Hi Toby,

On Tue, 2008-03-25 at 16:13 +0100, Axel Naumann wrote:
> Hi Tobias,
>
> you would need to implement your own version of TParameter with its own
> Browse method that e.g. creates a histo, fills it, and draws it. You can
> also call Inspect() from your object's Browse() methods - just give it a
> try, maybe it does what you want.

What you need is something like

        template <typename T>
        class MyParameter : public TParameter<T>
        {
        public:
          void Browse(TBrowser*) { 
            if (!fHisto) 
              fHisto = new TH1D(GetName(), GetName(), 1, GetVal()-.5,GetVal()+.5);
            fHisto->SetBinContent(1, GetVal());
            fHisto->Draw();
          }
          MyParameter(const char* name, const T& val) 
            TParameter<T>(name, val),
            fHisto(0)
          {}
          virtual ~MyParameter() { if (fHisto) delete fHisto; }
        private:
          TH1D* fHisto; //! Transient
        };
        

and then you have to remember to make dictionaries for the specialisations you need

        #pragma link C++ class MyParameter<double>+;
        #pragma link C++ class MyParameter<int>+;
        
        

Kind of round-about way of doing it, but I'm afraid it's the only way.

Yours,

-- 
 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 447
 ____|   Email:   cholm_at_nbi.dk               Web:    www.nbi.dk/~cholm
 | |
Received on Wed Mar 26 2008 - 09:54:28 CET

This archive was generated by hypermail 2.2.0 : Wed Mar 26 2008 - 17:50:01 CET