TGLTF3Painter.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id$
00002 // Author:  Timur Pocheptsov  31/08/2006
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2006, 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_TGLTF3Painter
00013 #define ROOT_TGLTF3Painter
00014 
00015 #include <vector>
00016 #include <list>
00017 
00018 #ifndef ROOT_TGLPlotPainter
00019 #include "TGLPlotPainter.h"
00020 #endif
00021 #ifndef ROOT_TGLIsoMesh
00022 #include "TGLIsoMesh.h"
00023 #endif
00024 #ifndef ROOT_TGLUtil
00025 #include "TGLUtil.h"
00026 #endif
00027 
00028 class TGLPlotCamera;
00029 class TF3;
00030 
00031 /*
00032 Draw TF3 using marching cubes.
00033 */
00034 
00035 class TGLTF3Painter : public TGLPlotPainter {
00036 private:
00037    enum ETF3Style {
00038       kDefault,
00039       kMaple0,
00040       kMaple1,
00041       kMaple2
00042    };
00043 
00044    ETF3Style fStyle;
00045 
00046    Rgl::Mc::TIsoMesh<Double_t> fMesh;
00047    TF3 *fF3;
00048 
00049    TGLTH3Slice fXOZSlice;
00050    TGLTH3Slice fYOZSlice;
00051    TGLTH3Slice fXOYSlice;
00052 
00053 public:
00054    TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
00055 
00056    char   *GetPlotInfo(Int_t px, Int_t py);
00057    Bool_t  InitGeometry();
00058    void    StartPan(Int_t px, Int_t py);
00059    void    Pan(Int_t px, Int_t py);
00060    void    AddOption(const TString &stringOption);
00061    void    ProcessEvent(Int_t event, Int_t px, Int_t py);
00062 
00063 private:
00064    void    InitGL()const;
00065    void    DeInitGL()const;
00066    
00067    void    DrawPlot()const;
00068    //
00069    void    DrawToSelectionBuffer()const;
00070    void    DrawDefaultPlot()const;
00071    void    DrawMaplePlot()const;
00072    //
00073 
00074    void    SetSurfaceColor()const;
00075    Bool_t  HasSections()const;
00076 
00077    void    DrawSectionXOZ()const;
00078    void    DrawSectionYOZ()const;
00079    void    DrawSectionXOY()const;
00080 
00081    ClassDef(TGLTF3Painter, 0) // GL TF3 painter.
00082 };
00083 
00084 /*
00085    Iso painter draws iso surfaces - "gliso" option for TH3XXX::Draw.
00086    Can be one-level iso (as standard non-gl "iso" option),
00087    or multi-level iso: equidistant contours (if you only specify
00088    number of contours, or at user defined levels).
00089 */
00090 
00091 class TGLIsoPainter : public TGLPlotPainter {
00092 private:
00093    typedef Rgl::Mc::TIsoMesh<Float_t>        Mesh_t;
00094    typedef std::list<Mesh_t>                 MeshList_t;
00095    typedef std::list<Mesh_t>::iterator       MeshIter_t;
00096    typedef std::list<Mesh_t>::const_iterator ConstMeshIter_t;
00097 
00098    TGLTH3Slice           fXOZSlice;
00099    TGLTH3Slice           fYOZSlice;
00100    TGLTH3Slice           fXOYSlice;
00101 
00102    Mesh_t                fDummyMesh;
00103    //List of meshes.
00104    MeshList_t            fIsos;
00105    //Cached meshes (will be used if geometry must be rebuilt
00106    //after TPad::PaintModified)
00107    MeshList_t            fCache;
00108    //Min and max bin contents.
00109    Rgl::Range_t          fMinMax;
00110    //Palette. One color per iso-surface.
00111    TGLLevelPalette       fPalette;
00112    //Iso levels. Equidistant or user-defined.
00113    std::vector<Double_t> fColorLevels;
00114    //Now meshes are initialized only once.
00115    //To be changed in future.
00116    Bool_t                fInit;
00117 
00118 public:
00119    TGLIsoPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
00120 
00121    //TGLPlotPainter final-overriders.
00122    char    *GetPlotInfo(Int_t px, Int_t py);
00123    Bool_t   InitGeometry();
00124    void     StartPan(Int_t px, Int_t py);
00125    void     Pan(Int_t px, Int_t py);
00126    void     AddOption(const TString &option);
00127    void     ProcessEvent(Int_t event, Int_t px, Int_t py);
00128 
00129 private:
00130    //TGLPlotPainter final-overriders.
00131    void     InitGL()const;
00132    void     DeInitGL()const;
00133    
00134    void     DrawPlot()const;
00135    void     DrawSectionXOZ()const;
00136    void     DrawSectionYOZ()const;
00137    void     DrawSectionXOY()const;
00138    //Auxiliary methods.
00139    Bool_t   HasSections()const;
00140    void     SetSurfaceColor(Int_t ind)const;
00141    void     SetMesh(Mesh_t &mesh, Double_t isoValue);
00142    void     DrawMesh(const Mesh_t &mesh, Int_t level)const;
00143    void     FindMinMax();
00144 
00145    TGLIsoPainter(const TGLIsoPainter &);
00146    TGLIsoPainter &operator = (const TGLIsoPainter &);
00147 
00148    ClassDef(TGLIsoPainter, 0) // Iso option for TH3.
00149 };
00150 
00151 #endif

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