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