Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:41

0001 // @(#)root/eve:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TEveGValuators
0013 #define ROOT_TEveGValuators
0014 
0015 #include "TGNumberEntry.h"
0016 
0017 class TGLabel;
0018 class TGHSlider;
0019 class TGDoubleHSlider;
0020 
0021 class TEveGValuatorBase: public TGCompositeFrame, public TGWidget
0022 {
0023    TEveGValuatorBase(const TEveGValuatorBase&);            // Not implemented
0024    TEveGValuatorBase& operator=(const TEveGValuatorBase&); // Not implemented
0025 
0026 protected:
0027    UInt_t      fLabelWidth;
0028    Bool_t      fAlignRight;
0029    Bool_t      fShowSlider;
0030 
0031    Int_t       fNELength; // Number-entry length (in characters)
0032    Int_t       fNEHeight; // Number-entry height (in pixels)
0033 
0034    TGLabel*    fLabel;
0035 
0036 public:
0037    TEveGValuatorBase(const TGWindow *p, const char* title, UInt_t w, UInt_t h, Int_t widgetId=-1);
0038    ~TEveGValuatorBase() override {}
0039 
0040    virtual void Build(Bool_t connect=kTRUE) = 0;
0041 
0042    void SetLabelWidth(Int_t w)        { fLabelWidth = w; }
0043    void SetAlignRight(Bool_t a)       { fAlignRight = a; }
0044    void SetShowSlider(Bool_t s=kTRUE) { fShowSlider = s; }
0045 
0046    void SetNELength(Int_t l)          { fNELength = l; }
0047    void SetNEHeight(Int_t h)          { fNEHeight = h; }
0048 
0049    TGLabel* GetLabel() {return fLabel;}
0050 
0051    ClassDefOverride(TEveGValuatorBase, 0); // Base class for composite GUI elements for setting of numeric values.
0052 };
0053 
0054 
0055 /******************************************************************************/
0056 
0057 class TEveGValuator: public TEveGValuatorBase
0058 {
0059    TEveGValuator(const TEveGValuator&);            // Not implemented
0060    TEveGValuator& operator=(const TEveGValuator&); // Not implemented
0061 
0062 protected:
0063    Float_t        fValue;
0064    Float_t        fMin;
0065    Float_t        fMax;
0066 
0067    Bool_t         fSliderNewLine;
0068    Int_t          fSliderDivs;
0069    TGNumberEntry* fEntry;
0070    TGHSlider*     fSlider;
0071 
0072    Int_t CalcSliderPos(Float_t v);
0073 
0074 public:
0075    TEveGValuator(const TGWindow *p, const char* title, UInt_t w, UInt_t h, Int_t widgetId=-1);
0076    ~TEveGValuator() override {}
0077 
0078    void Build(Bool_t connect=kTRUE) override;
0079 
0080    Float_t GetValue() const { return fValue; }
0081    virtual void SetValue(Float_t v, Bool_t emit=kFALSE);
0082 
0083    void SliderCallback();
0084    void EntryCallback();
0085    void ValueSet(Double_t); //*SIGNAL*
0086 
0087    TGHSlider*     GetSlider() { return fSlider; }
0088    TGNumberEntry* GetEntry()  { return fEntry; }
0089 
0090    void SetSliderNewLine(Bool_t nl) { fSliderNewLine = nl; }
0091 
0092    void GetLimits(Float_t& min, Float_t& max) const { min = fMin; max = fMax; }
0093    Float_t GetLimitMin() const { return fMin; }
0094    Float_t GetLimitMax() const { return fMax; }
0095    void SetLimits(Int_t min, Int_t max);
0096    void SetLimits(Float_t min, Float_t max, Int_t npos,
0097                   TGNumberFormat::EStyle nef=TGNumberFormat::kNESRealTwo);
0098 
0099    void SetToolTip(const char* tip);
0100    void SetEnabled(Bool_t state);
0101 
0102    ClassDefOverride(TEveGValuator, 0); // Composite GUI element for single value selection (supports label, number-entry and slider).
0103 };
0104 
0105 
0106 /******************************************************************************/
0107 
0108 class TEveGDoubleValuator: public TEveGValuatorBase
0109 {
0110    TEveGDoubleValuator(const TEveGDoubleValuator&);            // Not implemented
0111    TEveGDoubleValuator& operator=(const TEveGDoubleValuator&); // Not implemented
0112 
0113 protected:
0114    TGNumberEntry*    fMinEntry;
0115    TGNumberEntry*    fMaxEntry;
0116    TGDoubleHSlider*  fSlider;
0117 
0118 public:
0119    TEveGDoubleValuator(const TGWindow *p, const char* title, UInt_t w, UInt_t h, Int_t widgetId=-1);
0120    ~TEveGDoubleValuator() override {}
0121 
0122    void Build(Bool_t connect=kTRUE) override;
0123 
0124    void MinEntryCallback();
0125    void MaxEntryCallback();
0126    void SliderCallback();
0127    void ValueSet(); //*SIGNAL*
0128 
0129    TGDoubleHSlider* GetSlider()   { return fSlider; }
0130    TGNumberEntry*   GetMinEntry() { return fMinEntry; }
0131    TGNumberEntry*   GetMaxEntry() { return fMaxEntry; }
0132 
0133    void SetLimits(Int_t min, Int_t max);
0134    void SetLimits(Float_t min, Float_t max, TGNumberFormat::EStyle nef=TGNumberFormat::kNESRealTwo);
0135    void SetValues(Float_t min, Float_t max, Bool_t emit=kFALSE);
0136 
0137    void GetValues(Float_t& min, Float_t& max) const
0138    { min = fMinEntry->GetNumber(); max = fMaxEntry->GetNumber(); }
0139    Float_t GetMin() const { return fMinEntry->GetNumber(); }
0140    Float_t GetMax() const { return fMaxEntry->GetNumber(); }
0141    Float_t GetLimitMin() const { return fMinEntry->GetNumMin(); }
0142    Float_t GetLimitMax() const { return fMaxEntry->GetNumMax(); }
0143 
0144    ClassDefOverride(TEveGDoubleValuator, 0); // Composite GUI element for selection of range (label, two number-entries and double-slider).
0145 };
0146 
0147 
0148 /******************************************************************************/
0149 
0150 class TEveGTriVecValuator : public TGCompositeFrame, public TGWidget
0151 {
0152    TEveGTriVecValuator(const TEveGTriVecValuator&);            // Not implemented
0153    TEveGTriVecValuator& operator=(const TEveGTriVecValuator&); // Not implemented
0154 
0155 protected:
0156    TEveGValuator* fVal[3];
0157 
0158    // Weed-size vars from TEveGValuator; copied.
0159    UInt_t      fLabelWidth;
0160    Int_t       fNELength; // Number-entry length (in characters)
0161    Int_t       fNEHeight; // Number-entry height (in pixels)
0162 
0163 public:
0164    TEveGTriVecValuator(const TGWindow *p, const char* name, UInt_t w, UInt_t h, Int_t widgetId=-1);
0165    ~TEveGTriVecValuator() override {}
0166 
0167    void Build(Bool_t vertical, const char* lab0, const char* lab1, const char* lab2);
0168 
0169    TEveGValuator* GetValuator(Int_t i) const { return fVal[i]; }
0170 
0171    Float_t GetValue(Int_t i) const   { return fVal[i]->GetValue(); }
0172    void SetValue(Int_t i, Float_t v) { fVal[i]->SetValue(v); }
0173 
0174    void GetValues(Float_t& v0, Float_t& v1, Float_t& v2) const
0175    { v0 = GetValue(0); v1 = GetValue(1); v2 = GetValue(2); }
0176    void GetValues(Float_t v[3]) const
0177    { v[0] = GetValue(0); v[1] = GetValue(1); v[2] = GetValue(2); }
0178    void GetValues(Double_t v[3]) const
0179    { v[0] = GetValue(0); v[1] = GetValue(1); v[2] = GetValue(2); }
0180 
0181    void SetValues(Float_t v0, Float_t v1, Float_t v2)
0182    { SetValue(0, v0); SetValue(1, v1); SetValue(2, v2); }
0183    void SetValues(Float_t v[3])
0184    { SetValue(0, v[0]); SetValue(1, v[1]); SetValue(2, v[2]); }
0185    void SetValues(Double_t v[3])
0186    { SetValue(0, v[0]); SetValue(1, v[1]); SetValue(2, v[2]); }
0187 
0188    void ValueSet(); //*SIGNAL*
0189 
0190                       // Weed-size vars from TEveGValuator; copied.
0191    void SetLabelWidth(Int_t w) { fLabelWidth = w; }
0192    void SetNELength(Int_t l)   { fNELength   = l; }
0193    void SetNEHeight(Int_t h)   { fNEHeight   = h; }
0194 
0195    void SetLimits(Int_t min, Int_t max);
0196    void SetLimits(Float_t min, Float_t max,
0197                   TGNumberFormat::EStyle nef=TGNumberFormat::kNESRealTwo);
0198 
0199    ClassDefOverride(TEveGTriVecValuator, 0); // Composite GUI element for setting three numerical values (label, three number-entries).
0200 };
0201 
0202 #endif