TEveCaloLegoGL.h

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveCaloLegoGL.h 37345 2010-12-06 16:53:39Z matevz $
00002 // Author: Alja Mrak-Tadel 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_TEveCaloLegoGL
00013 #define ROOT_TEveCaloLegoGL
00014 
00015 #include "TGLObject.h"
00016 #include "TGLAxisPainter.h"
00017 
00018 #include "TEveCaloData.h"
00019 #include "TEveVector.h"
00020 #include "TEveCalo.h"
00021 
00022 #include <map>
00023 
00024 class TEveCaloLego;
00025 
00026 class TEveCaloLegoGL : public TGLObject
00027 {
00028    friend class TEveCaloLegoOverlay;
00029 
00030 private:
00031    struct Cell2D_t
00032    {
00033       Int_t   fId;
00034       Float_t fSumVal;
00035       Int_t   fMaxSlice;
00036 
00037       Float_t  fX0, fX1, fY0, fY1;
00038 
00039       Cell2D_t(Int_t id, Float_t sumVal, Int_t maxSlice)
00040       {
00041          fId       = id;
00042          fSumVal   = sumVal;
00043          fMaxSlice = maxSlice;
00044          fX0 = fX1 = fY0 = fY1 = 0;
00045       }
00046 
00047       void SetGeom(Float_t x0, Float_t x1, Float_t y0, Float_t y1)
00048       {
00049          fX0 = x0; fX1 = x1;
00050          fY0 = y0; fY1 = y1;
00051       }
00052 
00053       Float_t MinSize() { return TMath::Min(fX1- fX0, fY1 - fY0); }
00054       Float_t X()       { return 0.5*(fX0 + fX1); }
00055       Float_t Y()       { return 0.5*(fY0 + fY1); }
00056    };
00057 
00058    typedef std::vector<Cell2D_t>             vCell2D_t;
00059    typedef std::vector<Cell2D_t>::iterator   vCell2D_i;
00060 
00061    typedef std::map<Int_t, UInt_t>           SliceDLMap_t;
00062    typedef std::map<Int_t, UInt_t>::iterator SliceDLMap_i;
00063 
00064    // histogram base
00065    mutable Color_t                   fGridColor;
00066    mutable Color_t                   fFontColor;
00067 
00068    mutable TAxis      *fEtaAxis;
00069    mutable TAxis      *fPhiAxis;
00070    mutable TAxis      *fZAxis;
00071    mutable TEveVector  fXAxisTitlePos;
00072    mutable TEveVector  fYAxisTitlePos;
00073    mutable TEveVector  fZAxisTitlePos;
00074    mutable TEveVector  fBackPlaneXConst[2];
00075    mutable TEveVector  fBackPlaneYConst[2];
00076 
00077    mutable TGLAxisPainter fAxisPainter;
00078 
00079    // cached
00080    TEveCaloLego                     *fM;
00081    mutable Bool_t                    fDLCacheOK;
00082    mutable vCell2D_t                 fCells2D;
00083 
00084    mutable TEveCaloData::RebinData_t fRebinData;
00085    mutable Float_t                   fMaxVal;
00086    mutable Float_t                   fValToPixel; // top logaritmic viewview
00087    mutable Int_t                     fCurrentPixelsPerBin;
00088 
00089    mutable SliceDLMap_t              fDLMap;
00090    mutable Bool_t                    fCells3D;
00091 
00092    mutable Int_t                     fBinStep;
00093 
00094    TEveCaloLegoGL(const TEveCaloLegoGL&);            // Stop default
00095    TEveCaloLegoGL& operator=(const TEveCaloLegoGL&); // Stop default
00096 
00097 private:
00098    void    GetScaleForMatrix(Float_t& sx, Float_t& sy, Float_t& sz) const;
00099    Int_t   GetGridStep(TGLRnrCtx &rnrCtx) const;
00100    void    RebinAxis(TAxis *orig, TAxis *curr) const;
00101 
00102    void    SetAxis3DTitlePos(TGLRnrCtx &rnrCtx, Float_t x0, Float_t x1, Float_t y0, Float_t y1) const;
00103    void    DrawAxis3D(TGLRnrCtx &rnrCtx) const;
00104    void    DrawAxis2D(TGLRnrCtx &rnrCtx) const;
00105    void    DrawHistBase(TGLRnrCtx &rnrCtx) const;
00106 
00107    // highlight 
00108    void    DrawSelectedCells(TGLRnrCtx & rnrCtx, TEveCaloData::vCellId_t cells) const;
00109 
00110    // top view
00111    void    PrepareCell2DData(TEveCaloData::vCellId_t& cellList, vCell2D_t& cells2D) const;
00112    void    PrepareCell2DDataRebin(TEveCaloData::RebinData_t& rebinData, vCell2D_t& cells2D) const;
00113    void    DrawCells2D(TGLRnrCtx & rnrCtx, vCell2D_t& cells2D) const;
00114 
00115    // 3D view
00116    void    DrawCells3D(TGLRnrCtx & rnrCtx) const;
00117    void    MakeQuad(Float_t x, Float_t y, Float_t z, Float_t xw, Float_t yw, Float_t zh) const;
00118    void    Make3DDisplayList(TEveCaloData::vCellId_t& cellList, SliceDLMap_t& map, Bool_t select) const;
00119    void    Make3DDisplayListRebin(TEveCaloData::RebinData_t& rebinData, SliceDLMap_t& map, Bool_t select) const;
00120 
00121    void    WrapTwoPi(Float_t &min, Float_t &max) const;
00122 
00123 public:
00124    TEveCaloLegoGL();
00125    virtual ~TEveCaloLegoGL();
00126 
00127    virtual Bool_t SetModel(TObject* obj, const Option_t* opt = 0);
00128 
00129    virtual void   SetBBox();
00130 
00131    virtual void   DLCacheDrop();
00132    virtual void   DLCachePurge();
00133 
00134    virtual void   DirectDraw(TGLRnrCtx & rnrCtx) const;
00135    virtual void   DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* ps, Int_t lvl=-1) const;
00136 
00137    virtual Bool_t SupportsSecondarySelect() const { return kTRUE; }
00138    virtual Bool_t AlwaysSecondarySelect()   const { return kTRUE; }
00139    virtual void   ProcessSelection(TGLRnrCtx & rnrCtx, TGLSelectRecord & rec);
00140 
00141    ClassDef(TEveCaloLegoGL, 0); // GL renderer class for TEveCaloLego.
00142 };
00143 
00144 //______________________________________________________________________________
00145 inline void TEveCaloLegoGL::WrapTwoPi(Float_t &min, Float_t &max) const
00146 {
00147    if (fM->GetData()->GetWrapTwoPi())
00148    {
00149       if (fM->GetPhiMax()>TMath::Pi() && max<=fM->GetPhiMin())
00150       {
00151          min += TMath::TwoPi();
00152          max += TMath::TwoPi();
00153       }
00154       else if (fM->GetPhiMin()<-TMath::Pi() && min>=fM->GetPhiMax())
00155       {
00156          min -= TMath::TwoPi();
00157          max -= TMath::TwoPi();
00158       }
00159    }
00160 }
00161 #endif

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