TEveProjections.h

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveProjections.h 35221 2010-09-10 11:46:37Z matevz $
00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TEveProjections
00013 #define ROOT_TEveProjections
00014 
00015 #include "TEveVector.h"
00016 #include "TString.h"
00017 
00018 #include <vector>
00019 
00020 class TEveTrans;
00021 
00022 //==============================================================================
00023 // TEveProjection
00024 //==============================================================================
00025 
00026 class TEveProjection
00027 {
00028 public:
00029    enum EPType_e   { kPT_Unknown, kPT_RPhi, kPT_RhoZ, kPT_3D, kPT_End }; // projection type
00030    enum EPProc_e   { kPP_Plane, kPP_Distort, kPP_Full };                 // projection procedure
00031    enum EGeoMode_e { kGM_Unknown, kGM_Polygons, kGM_Segments };          // strategy for geometry projections
00032 
00033    struct PreScaleEntry_t
00034    {
00035       Float_t fMin, fMax;
00036       Float_t fOffset;
00037       Float_t fScale;
00038 
00039       PreScaleEntry_t() :
00040          fMin(0), fMax(0), fOffset(0), fScale(1) {}
00041       PreScaleEntry_t(Float_t min, Float_t max, Float_t off, Float_t scale) :
00042          fMin(min), fMax(max), fOffset(off), fScale(scale) {}
00043 
00044       virtual ~PreScaleEntry_t() {}
00045 
00046       ClassDef(PreScaleEntry_t, 0);
00047    };
00048 
00049    typedef std::vector<PreScaleEntry_t>           vPreScale_t;
00050    typedef std::vector<PreScaleEntry_t>::iterator vPreScale_i;
00051 
00052 protected:
00053    EPType_e            fType;          // type
00054    EGeoMode_e          fGeoMode;       // strategy of polygon projection (what to try first)
00055    TString             fName;          // name
00056 
00057    TEveVector          fCenter;        // center of distortion
00058    TEveVector          fZeroPosVal;    // projected origin (0, 0, 0)
00059 
00060    Bool_t              fUsePreScale;   // use pre-scaling
00061    vPreScale_t         fPreScales[3];  // scaling before the distortion
00062 
00063    Float_t             fDistortion;    // distortion
00064    Float_t             fFixR;          // radius from which scaling remains constant
00065    Float_t             fFixZ;          // z-coordinate from which scaling remains constant
00066    Float_t             fPastFixRFac;   // relative scaling factor beyond fFixR as 10^x
00067    Float_t             fPastFixZFac;   // relative scaling factor beyond fFixZ as 10^x
00068    Float_t             fScaleR;        // scale factor to keep projected radius at fFixR fixed
00069    Float_t             fScaleZ;        // scale factor to keep projected z-coordinate at fFixZ fixed
00070    Float_t             fPastFixRScale; // relative scaling beyond fFixR
00071    Float_t             fPastFixZScale; // relative scaling beyond fFixZ
00072    Float_t             fMaxTrackStep;  // maximum distance between two points on a track
00073 
00074    TEveVector          fLowLimit;      // convergence of point +infinity
00075    TEveVector          fUpLimit;       // convergence of point -infinity
00076 
00077    void PreScaleVariable(Int_t dim, Float_t& v);
00078 
00079 public:
00080    TEveProjection();
00081    virtual ~TEveProjection() {}
00082 
00083    virtual Bool_t      Is2D() const = 0;
00084    virtual Bool_t      Is3D() const = 0;
00085 
00086    virtual void        ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e p = kPP_Full) = 0;
00087 
00088    void                ProjectPointfv(Float_t* v, Float_t d);
00089    void                ProjectPointdv(Double_t* v, Float_t d);
00090    void                ProjectVector(TEveVector& v, Float_t d);
00091 
00092    void                ProjectPointfv(const TEveTrans* t, const Float_t*  p, Float_t* v, Float_t d);
00093    void                ProjectPointdv(const TEveTrans* t, const Double_t* p, Double_t* v, Float_t d);
00094    void                ProjectVector(const TEveTrans* t, TEveVector& v, Float_t d);
00095 
00096    const   Char_t*     GetName() const            { return fName.Data(); }
00097    void                SetName(const Char_t* txt) { fName = txt; }
00098 
00099    virtual void        SetCenter(TEveVector& v)   { fCenter = v; UpdateLimit(); }
00100    virtual Float_t*    GetProjectedCenter()       { return fCenter.Arr(); }
00101 
00102    void                SetType(EPType_e t)        { fType = t; }
00103    EPType_e            GetType() const            { return fType; }
00104 
00105    void                SetGeoMode(EGeoMode_e m)   { fGeoMode = m; }
00106    EGeoMode_e          GetGeoMode() const         { return fGeoMode; }
00107 
00108    virtual void        UpdateLimit();
00109 
00110    Bool_t   GetUsePreScale() const   { return fUsePreScale; }
00111    void     SetUsePreScale(Bool_t x) { fUsePreScale = x; }
00112 
00113    void     PreScalePoint(Float_t& x, Float_t& y);
00114    void     PreScalePoint(Float_t& x, Float_t& y, Float_t& z);
00115    void     AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale);
00116    void     ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale);
00117    void     ClearPreScales();
00118 
00119    void     SetDistortion(Float_t d);
00120    Float_t  GetDistortion() const { return fDistortion; }
00121    Float_t  GetFixR() const { return fFixR; }
00122    Float_t  GetFixZ() const { return fFixZ; }
00123    void     SetFixR(Float_t x);
00124    void     SetFixZ(Float_t x);
00125    Float_t  GetPastFixRFac() const { return fPastFixRFac; }
00126    Float_t  GetPastFixZFac() const { return fPastFixZFac; }
00127    void     SetPastFixRFac(Float_t x);
00128    void     SetPastFixZFac(Float_t x);
00129    Float_t  GetMaxTrackStep() const    { return fMaxTrackStep; }
00130    void     SetMaxTrackStep(Float_t x) { fMaxTrackStep = TMath::Max(x, 1.0f); }
00131 
00132    virtual Bool_t      HasSeveralSubSpaces() const { return kFALSE; }
00133    virtual Bool_t      AcceptSegment(TEveVector&, TEveVector&, Float_t /*tolerance*/) const { return kTRUE; }
00134    virtual Int_t       SubSpaceId(const TEveVector&) const { return 0; }
00135    virtual Bool_t      IsOnSubSpaceBoundrary(const TEveVector&) const { return kFALSE; }
00136    virtual void        BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t eps_sqr=1e-10f);
00137    virtual void        SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
00138 
00139    // utils to draw axis
00140    virtual Float_t     GetValForScreenPos(Int_t ax, Float_t value);
00141    virtual Float_t     GetScreenVal(Int_t ax, Float_t value);
00142    Float_t             GetLimit(Int_t i, Bool_t pos) { return pos ? fUpLimit[i] : fLowLimit[i]; }
00143 
00144    static   Float_t    fgEps;    // resolution of projected points
00145    static   Float_t    fgEpsSqr; // square of resolution of projected points
00146 
00147    ClassDef(TEveProjection, 0); // Base for specific classes that implement non-linear projections.
00148 };
00149 
00150 
00151 //==============================================================================
00152 // TEveRhoZProjection
00153 //==============================================================================
00154 
00155 class TEveRhoZProjection: public TEveProjection
00156 {
00157 private:
00158    TEveVector   fProjectedCenter; // projected center of distortion.
00159 
00160 public:
00161    TEveRhoZProjection();
00162    virtual ~TEveRhoZProjection() {}
00163 
00164    virtual Bool_t      Is2D() const { return kTRUE;  }
00165    virtual Bool_t      Is3D() const { return kFALSE; }
00166 
00167    virtual void        ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
00168 
00169    virtual void        SetCenter(TEveVector& center);
00170    virtual Float_t*    GetProjectedCenter() { return fProjectedCenter.Arr(); }
00171 
00172    virtual void        UpdateLimit();
00173 
00174    virtual Bool_t      HasSeveralSubSpaces() const { return kTRUE; }
00175    virtual Bool_t      AcceptSegment(TEveVector& v1, TEveVector& v2, Float_t tolerance) const;
00176    virtual Int_t       SubSpaceId(const TEveVector& v) const;
00177    virtual Bool_t      IsOnSubSpaceBoundrary(const TEveVector& v) const;
00178    virtual void        SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
00179 
00180    ClassDef(TEveRhoZProjection, 0); // Rho/Z non-linear projection.
00181 };
00182 
00183 
00184 //==============================================================================
00185 // TEveRPhiProjection
00186 //==============================================================================
00187 
00188 class TEveRPhiProjection : public TEveProjection
00189 {
00190 public:
00191    TEveRPhiProjection();
00192    virtual ~TEveRPhiProjection() {}
00193 
00194    virtual Bool_t Is2D() const { return kTRUE;  }
00195    virtual Bool_t Is3D() const { return kFALSE; }
00196 
00197    virtual void   ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
00198 
00199    ClassDef(TEveRPhiProjection, 0); // XY non-linear projection.
00200 };
00201 
00202 
00203 //==============================================================================
00204 // TEve3DProjection
00205 //==============================================================================
00206 
00207 class TEve3DProjection : public TEveProjection
00208 {
00209 public:
00210    TEve3DProjection();
00211    virtual ~TEve3DProjection() {}
00212 
00213    virtual Bool_t Is2D() const { return kFALSE; }
00214    virtual Bool_t Is3D() const { return kTRUE;  }
00215 
00216    virtual void   ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
00217 
00218    ClassDef(TEve3DProjection, 0); // 3D scaling "projection"
00219 };
00220 
00221 #endif

Generated on Tue Jul 5 14:14:59 2011 for ROOT_528-00b_version by  doxygen 1.5.1