Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLSurfacePainter.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov 31/08/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGLSurfacePainter
13 #define ROOT_TGLSurfacePainter
14 
15 #include <vector>
16 #include <list>
17 
18 #include "TGLPlotPainter.h"
19 #include "TString.h"
20 #include "TGLUtil.h"
21 
22 class TRandom;
23 
24 class TGLSurfacePainter : public TGLPlotPainter {
25 private:
26  enum ESurfaceType {
27  kSurf,
28  kSurf1,
29  kSurf2,
30  kSurf3,
31  kSurf4,
32  kSurf5
33  };
34 
35  mutable ESurfaceType fType;
36 
37  TGL2DArray<TGLVertex3> fMesh;
38  mutable TGL2DArray<Double_t> fTexMap;
39  TGL2DArray<std::pair<TGLVector3, TGLVector3> > fFaceNormals;
40  TGL2DArray<TGLVector3> fAverageNormals;
41 
42  mutable TString fObjectInfo;
43 
44  struct Projection_t {
45  UChar_t fRGBA[4];
46  std::vector<TGLVertex3> fVertices;
47  void Swap(Projection_t &rhs);
48  };
49 
50  mutable Projection_t fProj;
51 
52  mutable std::list<Projection_t> fXOZProj;
53  mutable std::list<Projection_t> fYOZProj;
54  mutable std::list<Projection_t> fXOYProj;
55 
56  mutable TGLLevelPalette fPalette;
57  mutable std::vector<Double_t> fColorLevels;
58  Rgl::Range_t fMinMaxVal;
59 
60  Bool_t fSectionPass;
61  mutable Bool_t fUpdateTexMap;
62 
63 public:
64  TGLSurfacePainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
65 
66  //TGLPlotPainter's final-overriders.
67  char *GetPlotInfo(Int_t px, Int_t py);
68  Bool_t InitGeometry();
69  void StartPan(Int_t px, Int_t py);
70  void Pan(Int_t px, Int_t py);
71  void AddOption(const TString &stringOption);
72  void ProcessEvent(Int_t event, Int_t px, Int_t py);
73 
74 private:
75  void InitGL()const;
76  void DeInitGL()const;
77 
78  void DrawPlot()const;
79 
80  void SetNormals();
81  void SetSurfaceColor()const;
82 
83  Bool_t InitGeometryCartesian();
84  Bool_t InitGeometryPolar();
85  Bool_t InitGeometryCylindrical();
86  Bool_t InitGeometrySpherical();
87 
88  void DrawProjections()const;
89  void DrawSectionXOZ()const;
90  void DrawSectionYOZ()const;
91  void DrawSectionXOY()const;
92 
93  void ClampZ(Double_t &zVal)const;
94 
95  char *WindowPointTo3DPoint(Int_t px, Int_t py)const;
96 
97  Bool_t PreparePalette()const;
98  void GenTexMap()const;
99  void DrawContoursProjection()const;
100 
101  Bool_t Textured()const;
102  Bool_t HasSections()const;
103  Bool_t HasProjections()const;
104 
105  void DrawPalette()const;
106  void DrawPaletteAxis()const;
107 
108  static TRandom *fgRandom;
109 
110  ClassDef(TGLSurfacePainter, 0)//Surface painter.
111 };
112 
113 #endif