Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLParametric.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov 26/01/2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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_TGLParametric
13 #define ROOT_TGLParametric
14 
15 #include "TGLHistPainter.h"
16 #include "TGLUtil.h"
17 #include "TAxis.h"
18 #include "TF2.h"
19 
20 #include <memory>
21 
22 class TString;
23 
24 //////////////////////////////////////////////////////////////////////////
25 // //
26 // TGLParametricEquation //
27 // //
28 // Parametric equations drawing with GL. //
29 // //
30 //////////////////////////////////////////////////////////////////////////
31 
32 
33 typedef void (*ParametricEquation_t)(TGLVertex3 &, Double_t u, Double_t v);
34 
35 class TGLParametricEquation : public TNamed {
36 private:
37  typedef std::unique_ptr<TF2> Ptr_t;
38 
39  Ptr_t fXEquation;
40  Ptr_t fYEquation;
41  Ptr_t fZEquation;
42 
43  ParametricEquation_t fEquation;
44 
45  Rgl::Range_t fURange;
46  Rgl::Range_t fVRange;
47 
48  Bool_t fConstrained;
49  Bool_t fModified;
50 
51  typedef std::unique_ptr<TGLHistPainter> Painter_t;
52  //C++ compiler do not need TGLhistPainter definition here, but I'm not sure about CINT,
53  //so I've included TGLHistPainter definition.
54  Painter_t fPainter;
55 
56 public:
57  TGLParametricEquation(const TString &name, const TString &xEquation,
58  const TString &yEquation, const TString &zEquation,
59  Double_t uMin, Double_t uMax,
60  Double_t vMin, Double_t vMax);
61  TGLParametricEquation(const TString &name, ParametricEquation_t equation,
62  Double_t uMin, Double_t uMax, Double_t vMin, Double_t vMax);
63 
64  Rgl::Range_t GetURange()const;
65  Rgl::Range_t GetVRange()const;
66 
67  Bool_t IsConstrained()const;
68  void SetConstrained(Bool_t c);
69 
70  Bool_t IsModified()const;
71  void SetModified(Bool_t m);
72 
73  void EvalVertex(TGLVertex3 &newVertex, Double_t u, Double_t v)const;
74 
75  Int_t DistancetoPrimitive(Int_t px, Int_t py);
76  void ExecuteEvent(Int_t event, Int_t px, Int_t py);
77  char *GetObjectInfo(Int_t px, Int_t py) const;
78  void Paint(Option_t *option);
79 
80 private:
81 
82  TGLParametricEquation(const TGLParametricEquation &);
83  TGLParametricEquation &operator = (const TGLParametricEquation &);
84 
85  ClassDef(TGLParametricEquation, 0)//Equation of parametric surface.
86 };
87 
88 class TGLParametricPlot : public TGLPlotPainter {
89 private:
90  struct Vertex_t {
91  TGLVertex3 fPos;
92  TGLVector3 fNormal;
93  Float_t fRGBA[4];
94  };
95 
96  enum EMeshSize {kLow = 30, kHigh = 150};
97 
98  Int_t fMeshSize;
99  TGL2DArray<Vertex_t> fMesh;
100 
101  Bool_t fShowMesh;
102  Int_t fColorScheme;
103 
104  TGLParametricEquation *fEquation;
105 
106  TAxis fCartesianXAxis;
107  TAxis fCartesianYAxis;
108  TAxis fCartesianZAxis;
109 
110  TGLPlotCoordinates fCartesianCoord;
111 
112 public:
113  TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera);
114 
115  Bool_t InitGeometry();
116  void StartPan(Int_t px, Int_t py);
117  void Pan(Int_t px, Int_t py);
118  char *GetPlotInfo(Int_t px, Int_t py);
119  void AddOption(const TString &option);
120  void ProcessEvent(Int_t event, Int_t px, Int_t py);
121 
122 private:
123  void InitGL()const;
124  void DeInitGL()const;
125 
126  void DrawPlot()const;
127 
128  void InitColors();
129 
130  void DrawSectionXOZ()const;
131  void DrawSectionYOZ()const;
132  void DrawSectionXOY()const;
133 
134  void SetSurfaceColor()const;
135 
136  TGLParametricPlot(const TGLParametricPlot &);
137  TGLParametricPlot &operator = (const TGLParametricPlot &);
138 
139  ClassDef(TGLParametricPlot, 0)//Parametric plot's painter.
140 };
141 
142 #endif