forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TGLParametric.h
142 lines (102 loc) · 4.38 KB
/
TGLParametric.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
// @(#)root/gl:$Id$
// Author: Timur Pocheptsov 26/01/2007
/*************************************************************************
* Copyright (C) 1995-2000, 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_TGLParametric
#define ROOT_TGLParametric
#include "TGLHistPainter.h"
#include "TGLUtil.h"
#include "TAxis.h"
#include "TF2.h"
#include <memory>
class TString;
//////////////////////////////////////////////////////////////////////////
// //
// TGLParametricEquation //
// //
// Parametric equations drawing with GL. //
// //
//////////////////////////////////////////////////////////////////////////
typedef void (*ParametricEquation_t)(TGLVertex3 &, Double_t u, Double_t v);
class TGLParametricEquation : public TNamed {
private:
typedef std::unique_ptr<TF2> Ptr_t;
Ptr_t fXEquation;
Ptr_t fYEquation;
Ptr_t fZEquation;
ParametricEquation_t fEquation;
Rgl::Range_t fURange;
Rgl::Range_t fVRange;
Bool_t fConstrained;
Bool_t fModified;
typedef std::unique_ptr<TGLHistPainter> Painter_t;
//C++ compiler do not need TGLhistPainter definition here, but I'm not sure about CINT,
//so I've included TGLHistPainter definition.
Painter_t fPainter;
public:
TGLParametricEquation(const TString &name, const TString &xEquation,
const TString &yEquation, const TString &zEquation,
Double_t uMin, Double_t uMax,
Double_t vMin, Double_t vMax);
TGLParametricEquation(const TString &name, ParametricEquation_t equation,
Double_t uMin, Double_t uMax, Double_t vMin, Double_t vMax);
Rgl::Range_t GetURange()const;
Rgl::Range_t GetVRange()const;
Bool_t IsConstrained()const;
void SetConstrained(Bool_t c);
Bool_t IsModified()const;
void SetModified(Bool_t m);
void EvalVertex(TGLVertex3 &newVertex, Double_t u, Double_t v)const;
Int_t DistancetoPrimitive(Int_t px, Int_t py);
void ExecuteEvent(Int_t event, Int_t px, Int_t py);
char *GetObjectInfo(Int_t px, Int_t py) const;
void Paint(Option_t *option);
private:
TGLParametricEquation(const TGLParametricEquation &);
TGLParametricEquation &operator = (const TGLParametricEquation &);
ClassDef(TGLParametricEquation, 0)//Equation of parametric surface.
};
class TGLParametricPlot : public TGLPlotPainter {
private:
struct Vertex_t {
TGLVertex3 fPos;
TGLVector3 fNormal;
Float_t fRGBA[4];
};
enum EMeshSize {kLow = 30, kHigh = 150};
Int_t fMeshSize;
TGL2DArray<Vertex_t> fMesh;
Bool_t fShowMesh;
Int_t fColorScheme;
TGLParametricEquation *fEquation;
TAxis fCartesianXAxis;
TAxis fCartesianYAxis;
TAxis fCartesianZAxis;
TGLPlotCoordinates fCartesianCoord;
public:
TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera);
Bool_t InitGeometry();
void StartPan(Int_t px, Int_t py);
void Pan(Int_t px, Int_t py);
char *GetPlotInfo(Int_t px, Int_t py);
void AddOption(const TString &option);
void ProcessEvent(Int_t event, Int_t px, Int_t py);
private:
void InitGL()const;
void DeInitGL()const;
void DrawPlot()const;
void InitColors();
void DrawSectionXOZ()const;
void DrawSectionYOZ()const;
void DrawSectionXOY()const;
void SetSurfaceColor()const;
TGLParametricPlot(const TGLParametricPlot &);
TGLParametricPlot &operator = (const TGLParametricPlot &);
ClassDef(TGLParametricPlot, 0)//Parametric plot's painter.
};
#endif