TGL5DPainter.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGL5DPainter.h 33600 2010-05-21 09:24:32Z rdm $
00002 // Author:  Timur Pocheptsov  28/07/2009
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2009, 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_TGL5DPainter
00013 #define ROOT_TGL5DPainter
00014 
00015 #include <vector>
00016 #include <list>
00017 
00018 #ifndef ROOT_TGLMarchingCubes
00019 #include "TGLMarchingCubes.h"
00020 #endif
00021 #ifndef ROOT_TGLPlotPainter
00022 #include "TGLPlotPainter.h"
00023 #endif
00024 #ifndef ROOT_TGLIsoMesh
00025 #include "TGLIsoMesh.h"
00026 #endif
00027 #ifndef ROOT_TKDEFGT
00028 #include "TKDEFGT.h"
00029 #endif
00030 #ifndef ROOT_TGLUtil
00031 #include "TGLUtil.h"
00032 #endif
00033 
00034 
00035 class TGLPlotCamera;
00036 class TGL5DDataSet;
00037 
00038 //
00039 //Painter to draw TGL5DDataSet ("gl5d" option for TTree).
00040 //
00041 
00042 class TGL5DPainter : public TGLPlotPainter {
00043 public:
00044    enum EDefaults {
00045       kNContours = 4,
00046       kNLowPts   = 50
00047    };
00048 
00049    typedef Rgl::Mc::TIsoMesh<Float_t> Mesh_t;
00050    
00051    //Iso surface.
00052    struct Surf_t {
00053       Surf_t() 
00054          : f4D(0.), fRange(0.), fShowCloud(kFALSE), fHide(kFALSE), 
00055            fColor(0), fHighlight(kFALSE), fAlpha(100)
00056       {
00057       }
00058       
00059       Mesh_t                fMesh;     //Mesh.
00060       Double_t              f4D;       //Iso-level.
00061       Double_t              fRange;    //Selection critera (f4D +- fRange).
00062       Bool_t                fShowCloud;//Show/Hide original cloud.
00063       Bool_t                fHide;     //Show/Hide surface.
00064       Color_t               fColor;    //Color.
00065       std::vector<Double_t> fPreds;    //Predictions for 5-th variable.
00066       Bool_t                fHighlight;//If surface was selected via GUI - highlight it.
00067       Int_t                 fAlpha;    //Opacity percentage of a surface.
00068    };
00069    
00070    typedef std::list<Surf_t>          SurfList_t;
00071    typedef SurfList_t::iterator       SurfIter_t;
00072    typedef SurfList_t::const_iterator ConstSurfIter_t;
00073 
00074 private:
00075    TKDEFGT                  fKDE;                        //Density estimator.
00076    Rgl::Mc::TMeshBuilder<TKDEFGT, Float_t> fMeshBuilder; //Mesh builder.
00077 
00078    const Surf_t             fDummy; //Empty surface (for effective insertion into list).
00079    Bool_t                   fInit;  //Geometry was set.
00080    
00081    SurfList_t               fIsos;  //List of iso-surfaces.
00082    TGL5DDataSet            *fData;  //Dataset to visualize.
00083    
00084    typedef std::vector<Double_t>::size_type size_type;
00085 
00086    Rgl::Range_t             fV5PredictedRange; //For future.
00087    Rgl::Range_t             fV5SliderRange;    //For future.
00088    Bool_t                   fShowSlider;       //For future.
00089    
00090    Double_t                 fAlpha;     //Parameter to define selection range.
00091    Int_t                    fNContours; //Number of "pre-defined" contours.
00092    
00093 public:
00094    TGL5DPainter(TGL5DDataSet *data, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
00095 
00096    //Add new iso for selected value of v4. +- range
00097    SurfIter_t AddSurface(Double_t v4, Color_t ci, Double_t isoVal = 1., Double_t sigma = 1., 
00098                          Double_t range = 1e-3, Int_t lowNumOfPoints = kNLowPts);
00099 
00100    void       AddSurface(Double_t v4);
00101    void       RemoveSurface(SurfIter_t surf);
00102 
00103    //TGLPlotPainter final-overriders.
00104    char      *GetPlotInfo(Int_t px, Int_t py);
00105    Bool_t     InitGeometry();
00106    void       StartPan(Int_t px, Int_t py);
00107    void       Pan(Int_t px, Int_t py);
00108    void       AddOption(const TString &option);
00109    void       ProcessEvent(Int_t event, Int_t px, Int_t py);
00110 
00111    //Methods for ged.
00112    void       ShowBoxCut(Bool_t show) {fBoxCut.SetActive(show);}
00113    Bool_t     IsBoxCutShown()const{return fBoxCut.IsActive();}
00114    
00115    void       SetAlpha(Double_t newAlpha);
00116    Double_t   GetAlpha()const{return fAlpha;}
00117    
00118    void       SetNContours(Int_t num);
00119    Int_t      GetNContours()const{return fNContours;}
00120 
00121    void       ResetGeometryRanges();
00122    
00123    SurfIter_t SurfacesBegin();
00124    SurfIter_t SurfacesEnd();
00125 
00126 private:
00127    //TGLPlotPainter final-overriders.
00128    void       InitGL()const;
00129    void       DeInitGL()const;
00130    
00131    void       DrawPlot()const;
00132    
00133    //Empty overriders.
00134    void       DrawSectionXOZ()const{}
00135    void       DrawSectionYOZ()const{}
00136    void       DrawSectionXOY()const{}
00137    
00138    //Auxiliary functions.
00139    void       SetSurfaceColor(ConstSurfIter_t surf)const;
00140    void       DrawCloud()const;
00141    void       DrawSubCloud(Double_t v4, Double_t range, Color_t ci)const;
00142    void       DrawMesh(ConstSurfIter_t surf)const;
00143    
00144    TGL5DPainter(const TGL5DPainter &);
00145    TGL5DPainter &operator = (const TGL5DPainter &);
00146 };
00147 
00148 #endif

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