Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/gl:$Id$
0002 // Author:  Timur Pocheptsov  28/07/2009
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2009, 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_TGL5DPainter
0013 #define ROOT_TGL5DPainter
0014 
0015 #include <vector>
0016 #include <list>
0017 
0018 #include "TGLMarchingCubes.h"
0019 #include "TGLPlotPainter.h"
0020 #include "TGLIsoMesh.h"
0021 #include "TKDEFGT.h"
0022 #include "TGLUtil.h"
0023 
0024 
0025 class TGLPlotCamera;
0026 class TGL5DDataSet;
0027 
0028 //
0029 //Painter to draw TGL5DDataSet ("gl5d" option for TTree).
0030 //
0031 
0032 class TGL5DPainter : public TGLPlotPainter {
0033 public:
0034    enum EDefaults {
0035       kNContours = 4,
0036       kNLowPts   = 50
0037    };
0038 
0039    typedef Rgl::Mc::TIsoMesh<Float_t> Mesh_t;
0040 
0041    //Iso surface.
0042    struct Surf_t {
0043       Surf_t()
0044          : f4D(0.), fRange(0.), fShowCloud(kFALSE), fHide(kFALSE),
0045            fColor(0), fHighlight(kFALSE), fAlpha(100)
0046       {
0047       }
0048 
0049       Mesh_t                fMesh;     //Mesh.
0050       Double_t              f4D;       //Iso-level.
0051       Double_t              fRange;    //Selection critera (f4D +- fRange).
0052       Bool_t                fShowCloud;//Show/Hide original cloud.
0053       Bool_t                fHide;     //Show/Hide surface.
0054       Color_t               fColor;    //Color.
0055       std::vector<Double_t> fPreds;    //Predictions for 5-th variable.
0056       Bool_t                fHighlight;//If surface was selected via GUI - highlight it.
0057       Int_t                 fAlpha;    //Opacity percentage of a surface.
0058    };
0059 
0060    typedef std::list<Surf_t>          SurfList_t;
0061    typedef SurfList_t::iterator       SurfIter_t;
0062    typedef SurfList_t::const_iterator ConstSurfIter_t;
0063 
0064 private:
0065    TKDEFGT                  fKDE;                        //Density estimator.
0066    Rgl::Mc::TMeshBuilder<TKDEFGT, Float_t> fMeshBuilder; //Mesh builder.
0067 
0068    const Surf_t             fDummy; //Empty surface (for effective insertion into list).
0069    Bool_t                   fInit;  //Geometry was set.
0070 
0071    SurfList_t               fIsos;  //List of iso-surfaces.
0072    TGL5DDataSet            *fData;  //Dataset to visualize.
0073 
0074    typedef std::vector<Double_t>::size_type size_type;
0075 
0076    Rgl::Range_t             fV5PredictedRange; //For future.
0077    Rgl::Range_t             fV5SliderRange;    //For future.
0078    Bool_t                   fShowSlider;       //For future.
0079 
0080    Double_t                 fAlpha;     //Parameter to define selection range.
0081    Int_t                    fNContours; //Number of "pre-defined" contours.
0082 
0083 public:
0084    TGL5DPainter(TGL5DDataSet *data, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
0085 
0086    //Add new iso for selected value of v4. +- range
0087    SurfIter_t AddSurface(Double_t v4, Color_t ci, Double_t isoVal = 1., Double_t sigma = 1.,
0088                          Double_t range = 1e-3, Int_t lowNumOfPoints = kNLowPts);
0089 
0090    void       AddSurface(Double_t v4);
0091    void       RemoveSurface(SurfIter_t surf);
0092 
0093    //TGLPlotPainter final-overriders.
0094    char      *GetPlotInfo(Int_t px, Int_t py) override;
0095    Bool_t     InitGeometry() override;
0096    void       StartPan(Int_t px, Int_t py) override;
0097    void       Pan(Int_t px, Int_t py) override;
0098    void       AddOption(const TString &option) override;
0099    void       ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0100 
0101    //Methods for ged.
0102    void       ShowBoxCut(Bool_t show) {fBoxCut.SetActive(show);}
0103    Bool_t     IsBoxCutShown()const{return fBoxCut.IsActive();}
0104 
0105    void       SetAlpha(Double_t newAlpha);
0106    Double_t   GetAlpha()const{return fAlpha;}
0107 
0108    void       SetNContours(Int_t num);
0109    Int_t      GetNContours()const{return fNContours;}
0110 
0111    void       ResetGeometryRanges();
0112 
0113    SurfIter_t SurfacesBegin();
0114    SurfIter_t SurfacesEnd();
0115 
0116 private:
0117    //TGLPlotPainter final-overriders.
0118    void       InitGL()const override;
0119    void       DeInitGL()const override;
0120 
0121    void       DrawPlot()const override;
0122 
0123    //Empty overriders.
0124    void       DrawSectionXOZ()const override{}
0125    void       DrawSectionYOZ()const override{}
0126    void       DrawSectionXOY()const override{}
0127 
0128    //Auxiliary functions.
0129    void       SetSurfaceColor(ConstSurfIter_t surf)const;
0130    void       DrawCloud()const;
0131    void       DrawSubCloud(Double_t v4, Double_t range, Color_t ci)const;
0132    void       DrawMesh(ConstSurfIter_t surf)const;
0133 
0134    TGL5DPainter(const TGL5DPainter &);
0135    TGL5DPainter &operator = (const TGL5DPainter &);
0136 };
0137 
0138 #endif