ROOT logo
// @(#)root/gl:$Id$
// Author:  Timur Pocheptsov  31/08/2006

/*************************************************************************
 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGLTF3Painter
#define ROOT_TGLTF3Painter

#include <vector>
#include <list>

#ifndef ROOT_TGLPlotPainter
#include "TGLPlotPainter.h"
#endif
#ifndef ROOT_TGLIsoMesh
#include "TGLIsoMesh.h"
#endif
#ifndef ROOT_TGLUtil
#include "TGLUtil.h"
#endif

class TGLPlotCamera;
class TF3;

/*
Draw TF3 using marching cubes.
*/

class TGLTF3Painter : public TGLPlotPainter {
private:
   enum ETF3Style {
      kDefault,
      kMaple0,
      kMaple1,
      kMaple2
   };

   ETF3Style fStyle;

   Rgl::Mc::TIsoMesh<Double_t> fMesh;
   TF3 *fF3;

   TGLTH3Slice fXOZSlice;
   TGLTH3Slice fYOZSlice;
   TGLTH3Slice fXOYSlice;

public:
   TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);

   char   *GetPlotInfo(Int_t px, Int_t py);
   Bool_t  InitGeometry();
   void    StartPan(Int_t px, Int_t py);
   void    Pan(Int_t px, Int_t py);
   void    AddOption(const TString &stringOption);
   void    ProcessEvent(Int_t event, Int_t px, Int_t py);

private:
   void    InitGL()const;
   void    DeInitGL()const;
   
   void    DrawPlot()const;
   //
   void    DrawToSelectionBuffer()const;
   void    DrawDefaultPlot()const;
   void    DrawMaplePlot()const;
   //

   void    SetSurfaceColor()const;
   Bool_t  HasSections()const;

   void    DrawSectionXOZ()const;
   void    DrawSectionYOZ()const;
   void    DrawSectionXOY()const;

   ClassDef(TGLTF3Painter, 0) // GL TF3 painter.
};

/*
   Iso painter draws iso surfaces - "gliso" option for TH3XXX::Draw.
   Can be one-level iso (as standard non-gl "iso" option),
   or multi-level iso: equidistant contours (if you only specify
   number of contours, or at user defined levels).
*/

class TGLIsoPainter : public TGLPlotPainter {
private:
   typedef Rgl::Mc::TIsoMesh<Float_t>        Mesh_t;
   typedef std::list<Mesh_t>                 MeshList_t;
   typedef std::list<Mesh_t>::iterator       MeshIter_t;
   typedef std::list<Mesh_t>::const_iterator ConstMeshIter_t;

   TGLTH3Slice           fXOZSlice;
   TGLTH3Slice           fYOZSlice;
   TGLTH3Slice           fXOYSlice;

   Mesh_t                fDummyMesh;
   //List of meshes.
   MeshList_t            fIsos;
   //Cached meshes (will be used if geometry must be rebuilt
   //after TPad::PaintModified)
   MeshList_t            fCache;
   //Min and max bin contents.
   Rgl::Range_t          fMinMax;
   //Palette. One color per iso-surface.
   TGLLevelPalette       fPalette;
   //Iso levels. Equidistant or user-defined.
   std::vector<Double_t> fColorLevels;
   //Now meshes are initialized only once.
   //To be changed in future.
   Bool_t                fInit;

public:
   TGLIsoPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);

   //TGLPlotPainter final-overriders.
   char    *GetPlotInfo(Int_t px, Int_t py);
   Bool_t   InitGeometry();
   void     StartPan(Int_t px, Int_t py);
   void     Pan(Int_t px, Int_t py);
   void     AddOption(const TString &option);
   void     ProcessEvent(Int_t event, Int_t px, Int_t py);

private:
   //TGLPlotPainter final-overriders.
   void     InitGL()const;
   void     DeInitGL()const;
   
   void     DrawPlot()const;
   void     DrawSectionXOZ()const;
   void     DrawSectionYOZ()const;
   void     DrawSectionXOY()const;
   //Auxiliary methods.
   Bool_t   HasSections()const;
   void     SetSurfaceColor(Int_t ind)const;
   void     SetMesh(Mesh_t &mesh, Double_t isoValue);
   void     DrawMesh(const Mesh_t &mesh, Int_t level)const;
   void     FindMinMax();

   TGLIsoPainter(const TGLIsoPainter &);
   TGLIsoPainter &operator = (const TGLIsoPainter &);

   ClassDef(TGLIsoPainter, 0) // Iso option for TH3.
};

#endif
 TGLTF3Painter.h:1
 TGLTF3Painter.h:2
 TGLTF3Painter.h:3
 TGLTF3Painter.h:4
 TGLTF3Painter.h:5
 TGLTF3Painter.h:6
 TGLTF3Painter.h:7
 TGLTF3Painter.h:8
 TGLTF3Painter.h:9
 TGLTF3Painter.h:10
 TGLTF3Painter.h:11
 TGLTF3Painter.h:12
 TGLTF3Painter.h:13
 TGLTF3Painter.h:14
 TGLTF3Painter.h:15
 TGLTF3Painter.h:16
 TGLTF3Painter.h:17
 TGLTF3Painter.h:18
 TGLTF3Painter.h:19
 TGLTF3Painter.h:20
 TGLTF3Painter.h:21
 TGLTF3Painter.h:22
 TGLTF3Painter.h:23
 TGLTF3Painter.h:24
 TGLTF3Painter.h:25
 TGLTF3Painter.h:26
 TGLTF3Painter.h:27
 TGLTF3Painter.h:28
 TGLTF3Painter.h:29
 TGLTF3Painter.h:30
 TGLTF3Painter.h:31
 TGLTF3Painter.h:32
 TGLTF3Painter.h:33
 TGLTF3Painter.h:34
 TGLTF3Painter.h:35
 TGLTF3Painter.h:36
 TGLTF3Painter.h:37
 TGLTF3Painter.h:38
 TGLTF3Painter.h:39
 TGLTF3Painter.h:40
 TGLTF3Painter.h:41
 TGLTF3Painter.h:42
 TGLTF3Painter.h:43
 TGLTF3Painter.h:44
 TGLTF3Painter.h:45
 TGLTF3Painter.h:46
 TGLTF3Painter.h:47
 TGLTF3Painter.h:48
 TGLTF3Painter.h:49
 TGLTF3Painter.h:50
 TGLTF3Painter.h:51
 TGLTF3Painter.h:52
 TGLTF3Painter.h:53
 TGLTF3Painter.h:54
 TGLTF3Painter.h:55
 TGLTF3Painter.h:56
 TGLTF3Painter.h:57
 TGLTF3Painter.h:58
 TGLTF3Painter.h:59
 TGLTF3Painter.h:60
 TGLTF3Painter.h:61
 TGLTF3Painter.h:62
 TGLTF3Painter.h:63
 TGLTF3Painter.h:64
 TGLTF3Painter.h:65
 TGLTF3Painter.h:66
 TGLTF3Painter.h:67
 TGLTF3Painter.h:68
 TGLTF3Painter.h:69
 TGLTF3Painter.h:70
 TGLTF3Painter.h:71
 TGLTF3Painter.h:72
 TGLTF3Painter.h:73
 TGLTF3Painter.h:74
 TGLTF3Painter.h:75
 TGLTF3Painter.h:76
 TGLTF3Painter.h:77
 TGLTF3Painter.h:78
 TGLTF3Painter.h:79
 TGLTF3Painter.h:80
 TGLTF3Painter.h:81
 TGLTF3Painter.h:82
 TGLTF3Painter.h:83
 TGLTF3Painter.h:84
 TGLTF3Painter.h:85
 TGLTF3Painter.h:86
 TGLTF3Painter.h:87
 TGLTF3Painter.h:88
 TGLTF3Painter.h:89
 TGLTF3Painter.h:90
 TGLTF3Painter.h:91
 TGLTF3Painter.h:92
 TGLTF3Painter.h:93
 TGLTF3Painter.h:94
 TGLTF3Painter.h:95
 TGLTF3Painter.h:96
 TGLTF3Painter.h:97
 TGLTF3Painter.h:98
 TGLTF3Painter.h:99
 TGLTF3Painter.h:100
 TGLTF3Painter.h:101
 TGLTF3Painter.h:102
 TGLTF3Painter.h:103
 TGLTF3Painter.h:104
 TGLTF3Painter.h:105
 TGLTF3Painter.h:106
 TGLTF3Painter.h:107
 TGLTF3Painter.h:108
 TGLTF3Painter.h:109
 TGLTF3Painter.h:110
 TGLTF3Painter.h:111
 TGLTF3Painter.h:112
 TGLTF3Painter.h:113
 TGLTF3Painter.h:114
 TGLTF3Painter.h:115
 TGLTF3Painter.h:116
 TGLTF3Painter.h:117
 TGLTF3Painter.h:118
 TGLTF3Painter.h:119
 TGLTF3Painter.h:120
 TGLTF3Painter.h:121
 TGLTF3Painter.h:122
 TGLTF3Painter.h:123
 TGLTF3Painter.h:124
 TGLTF3Painter.h:125
 TGLTF3Painter.h:126
 TGLTF3Painter.h:127
 TGLTF3Painter.h:128
 TGLTF3Painter.h:129
 TGLTF3Painter.h:130
 TGLTF3Painter.h:131
 TGLTF3Painter.h:132
 TGLTF3Painter.h:133
 TGLTF3Painter.h:134
 TGLTF3Painter.h:135
 TGLTF3Painter.h:136
 TGLTF3Painter.h:137
 TGLTF3Painter.h:138
 TGLTF3Painter.h:139
 TGLTF3Painter.h:140
 TGLTF3Painter.h:141
 TGLTF3Painter.h:142
 TGLTF3Painter.h:143
 TGLTF3Painter.h:144
 TGLTF3Painter.h:145
 TGLTF3Painter.h:146
 TGLTF3Painter.h:147
 TGLTF3Painter.h:148
 TGLTF3Painter.h:149
 TGLTF3Painter.h:150
 TGLTF3Painter.h:151