Logo ROOT   6.08/07
Reference Guide
TGLUtil.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Richard Maunder 25/05/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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_TGLUtil
13 #define ROOT_TGLUtil
14 
15 #ifndef ROOT_Rtypes
16 #include "Rtypes.h"
17 #endif
18 #ifndef ROOT_TError
19 #include "TError.h"
20 #endif
21 
22 #include <vector>
23 #include <cmath>
24 #include <cassert>
25 
26 class TString;
27 class TGLBoundingBox;
28 class TGLCamera;
29 
30 class TAttMarker;
31 class TAttLine;
32 
33 class GLUtesselator;
34 
35 namespace Rgl
36 {
37  enum EOverlap
38  {
39  kInside = 0,
42  };
43 }
44 
46 {
51 };
52 
54 {
66 };
67 
68 
69 // TODO: Split these into own h/cxx files - too long now!
70 
71 //////////////////////////////////////////////////////////////////////////
72 // //
73 // TGLVertex3 //
74 // //
75 // 3 component (x/y/z) vertex class //
76 // //
77 // This is part of collection of utility classes for GL in TGLUtil.h/cxx//
78 // These provide const and non-const accessors Arr() / CArr() to a GL //
79 // compatible internal field - so can be used directly with OpenGL C API//
80 // calls. They are not intended to be fully featured just provide //
81 // minimum required. //
82 //////////////////////////////////////////////////////////////////////////
83 
84 class TGLVector3; // Forward declare for Shift()
85 
87 {
88 protected:
89  // Fields
90  Bool_t ValidIndex(UInt_t index) const { return (index < 3); }
91  Double_t fVals[3];
92 
93 public:
94  TGLVertex3();
97  TGLVertex3(const TGLVertex3 & other);
98  virtual ~TGLVertex3();
99 
100  Bool_t operator == (const TGLVertex3 & rhs) const;
101  TGLVertex3 & operator = (const TGLVertex3 & rhs);
102  TGLVertex3 & operator *= (Double_t f);
103  TGLVertex3 operator - () const;
104  const TGLVertex3 & operator -= (const TGLVector3 & val);
105  const TGLVertex3 & operator += (const TGLVector3 & val);
106 
107  // Manipulators
108  void Fill(Double_t val);
109  void Set(Double_t x, Double_t y, Double_t z);
110  void Set(const Double_t* xyz);
111  void Set(const TGLVertex3 & other);
112  void Shift(TGLVector3 & shift);
113  void Shift(Double_t xDelta, Double_t yDelta, Double_t zDelta);
114  void Negate();
115 
116  void Minimum(const TGLVertex3 & other);
117  void Maximum(const TGLVertex3 & other);
118 
119  // Accessors
120  Double_t & operator [] (Int_t index);
121  const Double_t & operator [] (Int_t index) const;
122  Double_t X() const { return fVals[0]; }
123  Double_t & X() { return fVals[0]; }
124  Double_t Y() const { return fVals[1]; }
125  Double_t & Y() { return fVals[1]; }
126  Double_t Z() const { return fVals[2]; }
127  Double_t & Z() { return fVals[2]; }
128 
129  const Double_t * CArr() const { return fVals; }
130  Double_t * Arr() { return fVals; }
131 
132  void Dump() const;
133 
134  ClassDef(TGLVertex3,1); // GL 3 component vertex helper/wrapper class
135 };
136 
137 //______________________________________________________________________________
139 {
140  return TGLVertex3(f*v.X(), f*v.Y(), f*v.Z());
141 }
142 
143 //______________________________________________________________________________
144 inline void TGLVertex3::Negate()
145 {
146  fVals[0] = -fVals[0];
147  fVals[1] = -fVals[1];
148  fVals[2] = -fVals[2];
149 }
150 
151 //______________________________________________________________________________
152 inline Bool_t TGLVertex3::operator == (const TGLVertex3 & rhs) const
153 {
154  return (fVals[0] == rhs.fVals[0] && fVals[1] == rhs.fVals[1] && fVals[2] == rhs.fVals[2]);
155 }
156 
157 //______________________________________________________________________________
159 {
160  // Check for self-assignment
161  if (this != &rhs) {
162  Set(rhs);
163  }
164  return *this;
165 }
166 
167 // operator -= & operator += inline needs to be defered until full TGLVector3 definition
168 
169 //______________________________________________________________________________
171 {
172  return TGLVertex3(-fVals[0], -fVals[1], -fVals[2]);
173 }
174 
175 //______________________________________________________________________________
177 {
178  fVals[0] *= f;
179  fVals[1] *= f;
180  fVals[2] *= f;
181  return *this;
182 }
183 
184 //______________________________________________________________________________
186 {
187  /*if (!ValidIndex(index)) {
188  assert(kFALSE);
189  return fVals[0];
190  } else {*/
191  return fVals[index];
192  //}
193 }
194 
195 //______________________________________________________________________________
196 inline const Double_t& TGLVertex3::operator [] (Int_t index) const
197 {
198  /*if (!ValidIndex(index)) {
199  assert(kFALSE);
200  return fVals[0];
201  } else {*/
202  return fVals[index];
203  //}
204 }
205 
206 //______________________________________________________________________________
207 inline void TGLVertex3::Fill(Double_t val)
208 {
209  Set(val,val,val);
210 }
211 
212 //______________________________________________________________________________
214 {
215  fVals[0]=x;
216  fVals[1]=y;
217  fVals[2]=z;
218 }
219 
220 //______________________________________________________________________________
221 inline void TGLVertex3::Set(const Double_t* xyz)
222 {
223  fVals[0]=xyz[0];
224  fVals[1]=xyz[1];
225  fVals[2]=xyz[2];
226 }
227 
228 //______________________________________________________________________________
229 inline void TGLVertex3::Set(const TGLVertex3 & other)
230 {
231  fVals[0]=other.fVals[0];
232  fVals[1]=other.fVals[1];
233  fVals[2]=other.fVals[2];
234 }
235 
236 
237 //////////////////////////////////////////////////////////////////////////
238 // //
239 // TGLVector3 //
240 // //
241 // 3 component (x/y/z) vector class //
242 // //
243 // This is part of collection of utility classes for GL in TGLUtil.h/cxx//
244 // These provide const and non-const accessors Arr() / CArr() to a GL //
245 // compatible internal field - so can be used directly with OpenGL C API//
246 // calls. They are not intended to be fully featured just provide //
247 // minimum required. //
248 //////////////////////////////////////////////////////////////////////////
249 
250 class TGLVector3 : public TGLVertex3
251 {
252 public:
253  TGLVector3();
255  TGLVector3(const Double_t *src);
256  TGLVector3(const TGLVector3 & other);
257  virtual ~TGLVector3();
258 
259  TGLVector3& operator = (const TGLVertex3& v)
260  { fVals[0] = v[0]; fVals[1] = v[1]; fVals[2] = v[2]; return *this; }
261 
262  TGLVector3 & operator /= (Double_t val);
263  TGLVector3 operator - () const;
264 
265  Double_t Mag() const;
266  void Normalise();
267 
268  ClassDef(TGLVector3,1); // GL 3 component vector helper/wrapper class
269 };
270 
271 // Inline for TGLVertex3 requiring full TGLVector definition
272 //______________________________________________________________________________
273 inline const TGLVertex3 & TGLVertex3::operator -= (const TGLVector3 & vec)
274 {
275  fVals[0] -= vec[0]; fVals[1] -= vec[1]; fVals[2] -= vec[2];
276  return *this;
277 }
278 
279 // Inline for TGLVertex3 requiring full TGLVector definition
280 //______________________________________________________________________________
281 inline const TGLVertex3 & TGLVertex3::operator += (const TGLVector3 & vec)
282 {
283  fVals[0] += vec[0]; fVals[1] += vec[1]; fVals[2] += vec[2];
284  return *this;
285 }
286 
287 //______________________________________________________________________________
289 {
290  fVals[0] /= val;
291  fVals[1] /= val;
292  fVals[2] /= val;
293  return *this;
294 }
295 
296 //______________________________________________________________________________
298 {
299  return TGLVector3(-fVals[0], -fVals[1], -fVals[2]);
300 }
301 
302 //______________________________________________________________________________
303 inline Double_t TGLVector3::Mag() const
304 {
305  return std::sqrt(fVals[0]*fVals[0] + fVals[1]*fVals[1] + fVals[2]*fVals[2]);
306 }
307 
308 //______________________________________________________________________________
310 {
311  Double_t mag = Mag();
312  if ( mag == 0.0 ) {
313  Error("TGLVector3::Normalise", "vector has zero magnitude");
314  return;
315  }
316  fVals[0] /= mag;
317  fVals[1] /= mag;
318  fVals[2] /= mag;
319 }
320 
321 //______________________________________________________________________________
322 inline Double_t Dot(const TGLVector3 & v1, const TGLVector3 & v2)
323 {
324  return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
325 }
326 
327 //______________________________________________________________________________
328 inline TGLVector3 Cross(const TGLVector3 & v1, const TGLVector3 & v2)
329 {
330  return TGLVector3(v1[1]*v2[2] - v2[1]*v1[2],
331  v1[2]*v2[0] - v2[2]*v1[0],
332  v1[0]*v2[1] - v2[0]*v1[1]);
333 }
334 
335 //______________________________________________________________________________
336 inline const TGLVector3 operator / (const TGLVector3 & vec, Double_t val)
337 {
338  return TGLVector3(vec[0] / val, vec[1] / val, vec[2] / val);
339 }
340 
341 //______________________________________________________________________________
342 inline const TGLVector3 operator * (const TGLVector3 & vec, Double_t val)
343 {
344  return TGLVector3(vec[0] * val, vec[1] * val, vec[2] * val);
345 }
346 
347 //______________________________________________________________________________
348 // Vertex + Vector => Vertex
349 inline TGLVertex3 operator + (const TGLVertex3 & vertex1, const TGLVector3 & vertex2)
350 {
351  return TGLVertex3(vertex1[0] + vertex2[0], vertex1[1] + vertex2[1], vertex1[2] + vertex2[2]);
352 }
353 
354 //______________________________________________________________________________
355 // Vertex - Vertex => Vector
356 inline TGLVector3 operator - (const TGLVertex3 & vertex1, const TGLVertex3 & vertex2)
357 {
358  return TGLVector3(vertex1[0] - vertex2[0], vertex1[1] - vertex2[1], vertex1[2] - vertex2[2]);
359 }
360 
361 //______________________________________________________________________________
362 // Vector + Vector => Vector
363 inline TGLVector3 operator + (const TGLVector3 & vector1, const TGLVector3 & vector2)
364 {
365  return TGLVector3(vector1[0] + vector2[0], vector1[1] + vector2[1], vector1[2] + vector2[2]);
366 }
367 
368 //______________________________________________________________________________
369 // Vector - Vector => Vector
370 inline TGLVector3 operator - (const TGLVector3 & vector1, const TGLVector3 & vector2)
371 {
372  return TGLVector3(vector1[0] - vector2[0], vector1[1] - vector2[1], vector1[2] - vector2[2]);
373 }
374 
375 //______________________________________________________________________________
376 // Dot-product
377 inline Double_t operator * (const TGLVector3 & a, const TGLVector3 & b)
378 {
379  return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
380 }
381 
382 //////////////////////////////////////////////////////////////////////////
383 // //
384 // TGLLine3 //
385 // //
386 // 3D space, fixed length, line class, with direction / length 'vector',//
387 // passing through point 'vertex'. Just wraps a TGLVector3 / TGLVertex3 //
388 // pair. //
389 //////////////////////////////////////////////////////////////////////////
390 
391 class TGLLine3
392 {
393 private:
394  // Fields
395  TGLVertex3 fVertex; //! Start vertex of line
396  TGLVector3 fVector; //! Vector of line from fVertex
397 
398 public:
399  TGLLine3(const TGLVertex3 & start, const TGLVertex3 & end);
400  TGLLine3(const TGLVertex3 & start, const TGLVector3 & vector);
401  virtual ~TGLLine3();
402 
403  void Set(const TGLVertex3 & start, const TGLVertex3 & end);
404  void Set(const TGLVertex3 & start, const TGLVector3 & vector);
405 
406  // Bitwise copy constructor and = operator are fine
407 
408  // Accessors
409  const TGLVertex3 & Start() const { return fVertex; }
410  const TGLVertex3 End() const { return fVertex + fVector; }
411  const TGLVector3 & Vector() const { return fVector; }
412 
413  // Debug
414  void Draw() const;
415 
416  ClassDef(TGLLine3,0); // GL line wrapper class
417 };
418 
419 //////////////////////////////////////////////////////////////////////////
420 // //
421 // TGLRect //
422 // //
423 // Viewport (pixel base) 2D rectangle class //
424 //////////////////////////////////////////////////////////////////////////
425 
426 class TGLRect
427 {
428 private:
429  // Fields
430  Int_t fX, fY; //! Corner
431  Int_t fWidth, fHeight; //! Positive width/height
432 
433 public:
434  TGLRect();
435  TGLRect(Int_t x, Int_t y, Int_t width, Int_t height);
436  TGLRect(Int_t x, Int_t y, UInt_t width, UInt_t height);
437  virtual ~TGLRect();
438 
439  // Bitwise copy const & =op are ok at present
440 
441  // Manipulators
442  void Set(Int_t x, Int_t y, Int_t width, Int_t height);
443  void SetCorner(Int_t x, Int_t y);
444  void Offset(Int_t dX, Int_t dY);
445  void Expand(Int_t x, Int_t y);
446 
447  // Accessors
448  const Int_t* CArr() const { return &fX; }
449  Int_t* CArr() { return &fX; }
450 
451  Int_t X() const { return fX; }
452  Int_t & X() { return fX; }
453  Int_t Y() const { return fY; }
454  Int_t & Y() { return fY; }
455  Int_t Width() const { return fWidth; }
456  Int_t & Width() { return fWidth; }
457  Int_t Height() const { return fHeight; }
458  Int_t & Height() { return fHeight; }
459  Int_t CenterX() const { return fX + fWidth/2; }
460  Int_t CenterY() const { return fY + fHeight/2; }
461  Int_t Left() const { return fX; }
462  Int_t Right() const { return fX + fWidth; }
463  Int_t Top() const { return fY; }
464  Int_t Bottom() const { return fY + fHeight; }
465 
466  Int_t Diagonal() const;
467  Int_t Longest() const;
468 
469  Double_t Aspect() const;
470  Rgl::EOverlap Overlap(const TGLRect & other) const;
471 
472  ClassDef(TGLRect,0); // GL rect helper/wrapper class
473 };
474 
475 //______________________________________________________________________________
476 inline void TGLRect::Set(Int_t x, Int_t y, Int_t width, Int_t height)
477 {
478  fX = x;
479  fY = y;
480  fWidth = width;
481  fHeight = height;
482 }
483 
484 //______________________________________________________________________________
486 {
487  fX = x;
488  fY = y;
489 }
490 
491 //______________________________________________________________________________
492 inline void TGLRect::Offset(Int_t dX, Int_t dY)
493 {
494  fX += dX;
495  fY += dY;
496 }
497 
498 //______________________________________________________________________________
499 inline Int_t TGLRect::Longest() const
500 {
501  return fWidth > fHeight ? fWidth : fHeight;
502 }
503 
504 //______________________________________________________________________________
505 inline Double_t TGLRect::Aspect() const
506 {
507  // Return aspect ratio (width/height)
508  if (fHeight == 0) {
509  return 0.0;
510  } else {
511  return static_cast<Double_t>(fWidth) / static_cast<Double_t>(fHeight);
512  }
513 }
514 
515 //////////////////////////////////////////////////////////////////////////
516 // //
517 // TGLPlane //
518 // //
519 // 3D plane class - of format Ax + By + Cz + D = 0 //
520 // //
521 // This is part of collection of simple utility classes for GL only in //
522 // TGLUtil.h/cxx. These provide const and non-const accessors Arr() & //
523 // CArr() to a GL compatible internal field - so can be used directly //
524 // with OpenGL C API calls - which TVector3 etc cannot (easily). //
525 // They are not intended to be fully featured just provide minimum //
526 // required. //
527 //////////////////////////////////////////////////////////////////////////
528 
529 class TGLPlane
530 {
531 private:
532  // Fields
533  Double_t fVals[4];
534 
535  // Methods
536  void Normalise();
537 
538 public:
539  TGLPlane();
540  TGLPlane(const TGLPlane & other);
542  TGLPlane(Double_t eq[4]);
543  TGLPlane(const TGLVector3 & norm, const TGLVertex3 & point);
544  TGLPlane(const TGLVertex3 & p1, const TGLVertex3 & p2, const TGLVertex3 & p3);
545  virtual ~TGLPlane();
546 
547  // Manipulators
548  void Set(const TGLPlane & other);
549  void Set(Double_t a, Double_t b, Double_t c, Double_t d);
550  void Set(Double_t eq[4]);
551  void Set(const TGLVector3 & norm, const TGLVertex3 & point);
552  void Set(const TGLVertex3 & p1, const TGLVertex3 & p2, const TGLVertex3 & p3);
553  void Negate();
554 
555  // Accessors
556  Double_t A() const { return fVals[0]; }
557  Double_t B() const { return fVals[1]; }
558  Double_t C() const { return fVals[2]; }
559  Double_t D() const { return fVals[3]; }
560 
561  TGLVector3 Norm() const { return TGLVector3( fVals[0], fVals[1], fVals[2]); }
562  Double_t DistanceTo(const TGLVertex3 & vertex) const;
563  TGLVertex3 NearestOn(const TGLVertex3 & point) const;
564 
565  // Internal data accessors - for GL API
566  const Double_t * CArr() const { return fVals; }
567  Double_t * Arr() { return fVals; }
568 
569  void Dump() const;
570 
571  ClassDef(TGLPlane,0); // GL plane helper/wrapper class
572 };
573 
574 typedef std::vector<TGLPlane> TGLPlaneSet_t;
575 typedef std::vector<TGLPlane>::iterator TGLPlaneSet_i;
576 typedef std::vector<TGLPlane>::const_iterator TGLPlaneSet_ci;
577 
578 // Some free functions for planes
579 std::pair<Bool_t, TGLLine3> Intersection(const TGLPlane & p1, const TGLPlane & p2);
580 std::pair<Bool_t, TGLVertex3> Intersection(const TGLPlane & p1, const TGLPlane & p2, const TGLPlane & p3);
581 std::pair<Bool_t, TGLVertex3> Intersection(const TGLPlane & plane, const TGLLine3 & line, Bool_t extend);
582 
583 
584 //////////////////////////////////////////////////////////////////////////
585 // //
586 // TGLMatrix //
587 // //
588 // 16 component (4x4) transform matrix - column MAJOR as per GL. //
589 // Provides limited support for adjusting the translation, scale and //
590 // rotation components. //
591 // //
592 // This is part of collection of simple utility classes for GL only in //
593 // TGLUtil.h/cxx. These provide const and non-const accessors Arr() & //
594 // CArr() to a GL compatible internal field - so can be used directly //
595 // with OpenGL C API calls - which TVector3 etc cannot (easily). //
596 // They are not intended to be fully featured just provide minimum //
597 // required. //
598 //////////////////////////////////////////////////////////////////////////
599 
601 {
602 private:
603  // Fields
604  Double_t fVals[16]; // Column MAJOR as per OGL
605 
606  // Methods
607  Bool_t ValidIndex(UInt_t index) const { return (index < 16); }
608 
609 public:
610  TGLMatrix();
612  TGLMatrix(const TGLVertex3 & translation);
613  TGLMatrix(const TGLVertex3 & origin, const TGLVector3 & zAxis, const TGLVector3 & xAxis);
614  TGLMatrix(const TGLVertex3 & origin, const TGLVector3 & zAxis);
615  TGLMatrix(const Double_t vals[16]);
616  TGLMatrix(const TGLMatrix & other);
617  virtual ~TGLMatrix();
618 
619  // Operators
620  TGLMatrix & operator =(const TGLMatrix & rhs);
621  Double_t & operator [] (Int_t index);
622  Double_t operator [] (Int_t index) const;
623 
624  void MultRight(const TGLMatrix & rhs);
625  void MultLeft (const TGLMatrix & lhs);
626  TGLMatrix & operator*=(const TGLMatrix & rhs) { MultRight(rhs); return *this; }
627 
628  // Manipulators
629  void Set(const TGLVertex3 & origin, const TGLVector3 & zAxis, const TGLVector3 & xAxis = 0);
630  void Set(const Double_t vals[16]);
631  void SetIdentity();
632 
633  void SetTranslation(Double_t x, Double_t y, Double_t z);
634  void SetTranslation(const TGLVertex3 & translation);
635 
636  void Translate(const TGLVector3 & vect);
637  void MoveLF(Int_t ai, Double_t amount);
638  void Move3LF(Double_t x, Double_t y, Double_t z);
639 
640  void Scale(const TGLVector3 & scale);
641  void Rotate(const TGLVertex3 & pivot, const TGLVector3 & axis, Double_t angle);
642  void RotateLF(Int_t i1, Int_t i2, Double_t amount);
643  void RotatePF(Int_t i1, Int_t i2, Double_t amount);
644  void TransformVertex(TGLVertex3 & vertex) const;
645  void Transpose3x3();
646  Double_t Invert();
647 
648  // Accesors
649  TGLVector3 GetTranslation() const;
650  TGLVector3 GetScale() const;
651  Bool_t IsScalingForRender() const;
652 
653  void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
654  void SetBaseVec(Int_t b, const TGLVector3& v);
655  void SetBaseVec(Int_t b, Double_t* x);
656 
657  TGLVector3 GetBaseVec(Int_t b) const;
658  void GetBaseVec(Int_t b, TGLVector3& v) const;
659  void GetBaseVec(Int_t b, Double_t* x) const;
660 
661  TGLVector3 Multiply(const TGLVector3& v, Double_t w=1) const;
662  TGLVector3 Rotate(const TGLVector3& v) const;
663  void MultiplyIP(TGLVector3& v, Double_t w=1) const;
664  void RotateIP(TGLVector3& v) const;
665 
666  // Internal data accessors - for GL API
667  const Double_t * CArr() const { return fVals; }
668  Double_t * Arr() { return fVals; }
669 
670  void Dump() const;
671 
672  ClassDef(TGLMatrix,1); // GL matrix helper/wrapper class
673 };
674 
675 //______________________________________________________________________________
677 {
678  // Check for self-assignment
679  if (this != &rhs) {
680  Set(rhs.fVals);
681  }
682  return *this;
683 }
684 
685 //______________________________________________________________________________
687 {
688  /*if (!ValidIndex(index)) {
689  assert(kFALSE);
690  return fVals[0];
691  } else {*/
692  return fVals[index];
693  //}
694 }
695 
696 //______________________________________________________________________________
698 {
699  /*if (!ValidIndex(index)) {
700  assert(kFALSE);
701  return fVals[0];
702  } else {*/
703  return fVals[index];
704  //}
705 }
706 
707 //______________________________________________________________________________
708 inline TGLMatrix operator * (const TGLMatrix & lhs, const TGLMatrix & rhs)
709 {
710  TGLMatrix res;
711 
712  res[ 0] = rhs[ 0] * lhs[ 0] + rhs[ 1] * lhs[ 4] + rhs[ 2] * lhs[ 8] + rhs[ 3] * lhs[12];
713  res[ 1] = rhs[ 0] * lhs[ 1] + rhs[ 1] * lhs[ 5] + rhs[ 2] * lhs[ 9] + rhs[ 3] * lhs[13];
714  res[ 2] = rhs[ 0] * lhs[ 2] + rhs[ 1] * lhs[ 6] + rhs[ 2] * lhs[10] + rhs[ 3] * lhs[14];
715  res[ 3] = rhs[ 0] * lhs[ 3] + rhs[ 1] * lhs[ 7] + rhs[ 2] * lhs[11] + rhs[ 3] * lhs[15];
716 
717  res[ 4] = rhs[ 4] * lhs[ 0] + rhs[ 5] * lhs[ 4] + rhs[ 6] * lhs[ 8] + rhs[ 7] * lhs[12];
718  res[ 5] = rhs[ 4] * lhs[ 1] + rhs[ 5] * lhs[ 5] + rhs[ 6] * lhs[ 9] + rhs[ 7] * lhs[13];
719  res[ 6] = rhs[ 4] * lhs[ 2] + rhs[ 5] * lhs[ 6] + rhs[ 6] * lhs[10] + rhs[ 7] * lhs[14];
720  res[ 7] = rhs[ 4] * lhs[ 3] + rhs[ 5] * lhs[ 7] + rhs[ 6] * lhs[11] + rhs[ 7] * lhs[15];
721 
722  res[ 8] = rhs[ 8] * lhs[ 0] + rhs[ 9] * lhs[ 4] + rhs[10] * lhs[ 8] + rhs[11] * lhs[12];
723  res[ 9] = rhs[ 8] * lhs[ 1] + rhs[ 9] * lhs[ 5] + rhs[10] * lhs[ 9] + rhs[11] * lhs[13];
724  res[10] = rhs[ 8] * lhs[ 2] + rhs[ 9] * lhs[ 6] + rhs[10] * lhs[10] + rhs[11] * lhs[14];
725  res[11] = rhs[ 8] * lhs[ 3] + rhs[ 9] * lhs[ 7] + rhs[10] * lhs[11] + rhs[11] * lhs[15];
726 
727  res[12] = rhs[12] * lhs[ 0] + rhs[13] * lhs[ 4] + rhs[14] * lhs[ 8] + rhs[15] * lhs[12];
728  res[13] = rhs[12] * lhs[ 1] + rhs[13] * lhs[ 5] + rhs[14] * lhs[ 9] + rhs[15] * lhs[13];
729  res[14] = rhs[12] * lhs[ 2] + rhs[13] * lhs[ 6] + rhs[14] * lhs[10] + rhs[15] * lhs[14];
730  res[15] = rhs[12] * lhs[ 3] + rhs[13] * lhs[ 7] + rhs[14] * lhs[11] + rhs[15] * lhs[15];
731 
732  return res;
733 }
734 
735 //______________________________________________________________________________
737 {
738  Double_t* C = fVals + 4*--b;
739  C[0] = x; C[1] = y; C[2] = z;
740 }
741 
742 //______________________________________________________________________________
744 {
745  Double_t* C = fVals + 4*--b;
746  C[0] = v[0]; C[1] = v[1]; C[2] = v[2];
747 }
748 
749 //______________________________________________________________________________
751 {
752  Double_t* C = fVals + 4*--b;
753  C[0] = x[0]; C[1] = x[1]; C[2] = x[2];
754 }
755 
756 //______________________________________________________________________________
758 {
759  return TGLVector3(&fVals[4*--b]);
760 }
761 
762 //______________________________________________________________________________
764 {
765  const Double_t* C = fVals + 4*--b;
766  v[0] = C[0]; v[1] = C[1]; v[2] = C[2];
767 }
768 
769 //______________________________________________________________________________
770 inline void TGLMatrix::GetBaseVec(Int_t b, Double_t* x) const
771 {
772  const Double_t* C = fVals + 4*--b;
773  x[0] = C[0], x[1] = C[1], x[2] = C[2];
774 }
775 
776 
777 //////////////////////////////////////////////////////////////////////////
778 //
779 // TGLColor
780 //
781 // Encapsulate color in preferred GL format - UChar_t RGBA array.
782 // Color index is also cached for easier interfacing with the
783 // traditional ROOT graphics.
784 //
785 //////////////////////////////////////////////////////////////////////////
786 
787 class TGLColor
788 {
789 protected:
790  UChar_t fRGBA[4];
791  mutable Short_t fIndex;
792 
793 public:
794  TGLColor();
795  TGLColor(Int_t r, Int_t g, Int_t b, Int_t a=255);
797  TGLColor(Color_t color_index, Char_t transparency=0);
798  virtual ~TGLColor();
799 
800  TGLColor& operator=(const TGLColor& c);
801 
802  UChar_t* Arr() { return fRGBA; }
803  const UChar_t* CArr() const { return fRGBA; }
804 
805  UChar_t GetRed() const { return fRGBA[0]; }
806  UChar_t GetGreen() const { return fRGBA[1]; }
807  UChar_t GetBlue() const { return fRGBA[2]; }
808  UChar_t GetAlpha() const { return fRGBA[3]; }
809 
810  Color_t GetColorIndex() const;
811  Char_t GetTransparency() const;
812 
813  void SetRed(Int_t v) { fRGBA[0] = v; }
814  void SetGreen(Int_t v) { fRGBA[1] = v; }
815  void SetBlue(Int_t v) { fRGBA[2] = v; }
816  void SetAlpha(Int_t v) { fRGBA[3] = v; }
817 
818  void SetColor(Int_t r, Int_t g, Int_t b, Int_t a=255);
819  void SetColor(Float_t r, Float_t g, Float_t b, Float_t a=1);
820  void SetColor(Color_t color_index);
821  void SetColor(Color_t color_index, Char_t transparency);
822  void SetTransparency(Char_t transparency);
823 
824  TString AsString() const;
825 
826  ClassDef(TGLColor, 0); // Color in preferred GL format - RGBA.
827 };
828 
829 
830 //////////////////////////////////////////////////////////////////////////
831 //
832 // TGLColorSet
833 //
834 // A collection of colors used for OpenGL rendering.
835 //
836 //////////////////////////////////////////////////////////////////////////
837 
839 {
840 protected:
845  TGLColor fSelection[5]; // Colors for shape-selection-levels
846 
847 public:
848  TGLColorSet();
849  virtual ~TGLColorSet();
850 
851  TGLColorSet& operator=(const TGLColorSet& s);
852 
853  TGLColor& Background() { return fBackground; }
854  TGLColor& Foreground() { return fForeground; }
855  TGLColor& Outline() { return fOutline; }
856  TGLColor& Markup() { return fMarkup; }
857  TGLColor& Selection(Int_t i) { return fSelection[i]; }
858 
859  const TGLColor& Background() const { return fBackground; }
860  const TGLColor& Foreground() const { return fForeground; }
861  const TGLColor& Outline() const { return fOutline; }
862  const TGLColor& Markup() const { return fMarkup; }
863  const TGLColor& Selection(Int_t i) const { return fSelection[i]; }
864 
865  void StdDarkBackground();
866  void StdLightBackground();
867 
868  ClassDef(TGLColorSet, 0); // Collection of colors used for GL rendering.
869 };
870 
871 //////////////////////////////////////////////////////////////////////////
872 // //
873 // TGLUtil //
874 // //
875 // Wrapper class for various misc static functions - error checking, //
876 // draw helpers etc. //
877 // //
878 //////////////////////////////////////////////////////////////////////////
879 
880 class TGLUtil
881 {
882 public:
884  {
885  public:
886  TColorLocker() { LockColor(); }
887  virtual ~TColorLocker() { UnlockColor(); }
888 
889  ClassDef(TColorLocker,0); // Lock/unlock color in constructor/destructor.
890  };
891 
893  {
895  public:
897  fOldQuality(GetDrawQuality()) {SetDrawQuality(dq); }
898 
900  { SetDrawQuality(fOldQuality); }
901 
902  ClassDef(TDrawQualityModifier,0); // Set/restore draw quality in constructor/destructor.
903  };
904 
906  {
908  public:
910  fOldQuality(GetDrawQuality()) {SetDrawQuality((Int_t)(fac*fOldQuality)); }
911 
913  { SetDrawQuality(fOldQuality); }
914 
915  ClassDef(TDrawQualityScaler,0); // Multiply/restore draw quality in constructor/destructor.
916  };
917 
918 private:
921 
923 
928 
932 
933  TGLUtil(const TGLUtil&); // Not implemented.
934  TGLUtil& operator=(const TGLUtil&); // Not implemented.
935 
936 public:
937  virtual ~TGLUtil() {}
938  static void InitializeIfNeeded();
939 
940  // Error checking
941  static Int_t CheckError(const char * loc);
942 
943  // Polygon tesselator for direct drawing
944  static GLUtesselator* GetDrawTesselator3fv();
945  static GLUtesselator* GetDrawTesselator4fv();
946  static GLUtesselator* GetDrawTesselator3dv();
947  static GLUtesselator* GetDrawTesselator4dv();
948 
949  // Some simple shape drawing utils
950  enum ELineHeadShape { kLineHeadNone, kLineHeadArrow, kLineHeadBox };
951  enum EAxesType { kAxesNone, kAxesEdge, kAxesOrigin };
952 
953  static UInt_t GetDrawQuality();
954  static void SetDrawQuality(UInt_t dq);
955  static void ResetDrawQuality();
956  static UInt_t GetDefaultDrawQuality();
957  static void SetDefaultDrawQuality(UInt_t dq);
958 
959  static UInt_t LockColor();
960  static UInt_t UnlockColor();
961  static Bool_t IsColorLocked();
962 
963  static void Color(const TGLColor& color);
964  static void ColorAlpha(const TGLColor& color, UChar_t alpha);
965  static void ColorAlpha(const TGLColor& color, Float_t alpha);
966  static void ColorAlpha(Color_t color_index, Float_t alpha=1);
967  static void ColorTransparency(Color_t color_index, Char_t transparency=0);
968  static void Color3ub(UChar_t r, UChar_t g, UChar_t b);
969  static void Color4ub(UChar_t r, UChar_t g, UChar_t b, UChar_t a);
970  static void Color3ubv(const UChar_t* rgb);
971  static void Color4ubv(const UChar_t* rgba);
972  static void Color3f(Float_t r, Float_t g, Float_t b);
973  static void Color4f(Float_t r, Float_t g, Float_t b, Float_t a);
974  static void Color3fv(const Float_t* rgb);
975  static void Color4fv(const Float_t* rgba);
976 
977  // Coordinate conversion and extra scaling (needed for osx retina)
978  static void PointToViewport(Int_t& x, Int_t& y);
979  static void PointToViewport(Int_t& x, Int_t& y, Int_t& w, Int_t& h);
980  static Float_t GetScreenScalingFactor();
981  static Float_t GetPointLineScalingFactor();
982  static Int_t GetPickingRadius();
983 
984  static Float_t GetPointSizeScale();
985  static void SetPointSizeScale(Float_t scale);
986  static Float_t GetLineWidthScale();
987  static void SetLineWidthScale(Float_t scale);
988 
989  static void PointSize(Float_t point_size);
990  static void LineWidth(Float_t line_width);
991 
992  static Float_t PointSize();
993  static Float_t LineWidth();
994 
995  static void BeginExtendPickRegion(Float_t scale);
996  static void EndExtendPickRegion();
997 
998  static void RenderPolyMarkers(const TAttMarker& marker, Char_t transp,
999  Float_t* p, Int_t n,
1000  Int_t pick_radius=0, Bool_t selection=kFALSE,
1001  Bool_t sec_selection=kFALSE);
1002 
1003  static void RenderPolyMarkers(const TAttMarker &marker, const std::vector<Double_t> &points,
1004  Double_t dX, Double_t dY, Double_t dZ);
1005 
1006  static void RenderPoints(const TAttMarker& marker,
1007  Float_t* p, Int_t n,
1008  Int_t pick_radius=0, Bool_t selection=kFALSE,
1009  Bool_t sec_selection=kFALSE);
1010 
1011  static void RenderPoints(const TAttMarker& marker,
1012  const std::vector<Double_t> &points);
1013 
1014  static void RenderCrosses(const TAttMarker& marker,
1015  Float_t* p, Int_t n,
1016  Bool_t sec_selection=kFALSE);
1017 
1018  static void RenderCrosses(const TAttMarker& marker,
1019  const std::vector<Double_t> &points,
1020  Double_t dX, Double_t dY, Double_t dZ);
1021 
1022  static void RenderPolyLine(const TAttLine& aline, Char_t transp,
1023  Float_t* p, Int_t n,
1024  Int_t pick_radius=0, Bool_t selection=kFALSE);
1025 
1026  static void BeginAttLine(const TAttLine& aline, Char_t transp,
1027  Int_t pick_radius=0, Bool_t selection=kFALSE);
1028  static void EndAttLine(Int_t pick_radius=0, Bool_t selection=kFALSE);
1029 
1030  // TODO: These draw routines should take LOD hints
1031  static void SetDrawColors(const UChar_t rgba[4]);
1032  static void DrawSphere(const TGLVertex3 & position, Double_t radius, const UChar_t rgba[4]);
1033  static void DrawLine(const TGLLine3 & line, ELineHeadShape head, Double_t size, const UChar_t rgba[4]);
1034  static void DrawLine(const TGLVertex3 & start, const TGLVector3 & vector, ELineHeadShape head,
1035  Double_t size, const UChar_t rgba[4]);
1036  static void DrawRing(const TGLVertex3 & center, const TGLVector3 & normal,
1037  Double_t radius, const UChar_t* rgba);
1038 
1039  static void DrawReferenceMarker(const TGLCamera & camera,
1040  const TGLVertex3 & pos,
1041  Float_t radius = 3,
1042  const UChar_t * rgba = 0);
1043  static void DrawSimpleAxes(const TGLCamera & camera,
1044  const TGLBoundingBox & bbox,
1045  Int_t axesType);
1046  static void DrawNumber(const TString & num,
1047  const TGLVertex3 & pos,
1048  Bool_t center = kFALSE);
1049 
1050  // Frequently used colors.
1051  static const UChar_t fgRed[4];
1052  static const UChar_t fgGreen[4];
1053  static const UChar_t fgBlue[4];
1054  static const UChar_t fgYellow[4];
1055  static const UChar_t fgWhite[4];
1056  static const UChar_t fgGrey[4];
1057 
1058  ClassDef(TGLUtil,0); // Wrapper class for misc GL pieces
1059 };
1060 
1061 /**************************************************************************/
1062 
1064 {
1065 private:
1067  TGLCapabilitySwitch &operator = (const TGLCapabilitySwitch &);
1068 
1072 
1073  void SetState(Bool_t s);
1074 
1075 public:
1078 };
1079 
1081 {
1082 private:
1084  TGLCapabilityEnabler &operator = (const TGLCapabilityEnabler &);
1085 
1088 
1089 public:
1092 };
1093 
1095 {
1096  TGLFloatHolder(const TGLFloatHolder&); // Not implemented
1097  TGLFloatHolder& operator=(const TGLFloatHolder&); // Not implemented
1098 
1102  void (*fFoo)(Float_t);
1103 
1104 public:
1105  TGLFloatHolder(Int_t what, Float_t state, void (*foo)(Float_t));
1106  ~TGLFloatHolder();
1107 };
1108 
1110 private:
1112 
1113 public:
1114  TGLEnableGuard(Int_t cap);
1115  ~TGLEnableGuard();
1116 
1117 private:
1118  TGLEnableGuard(const TGLEnableGuard &);
1119  TGLEnableGuard &operator = (const TGLEnableGuard &);
1120 };
1121 
1123 private:
1125 
1126 public:
1127  TGLDisableGuard(Int_t cap);
1128  ~TGLDisableGuard();
1129 
1130 private:
1132  TGLDisableGuard &operator = (const TGLDisableGuard &);
1133 };
1134 
1136  std::vector<UChar_t> fBuffer;
1139 
1140 public:
1142  virtual ~TGLSelectionBuffer();
1143 
1144  void ReadColorBuffer(Int_t width, Int_t height);
1145  void ReadColorBuffer(Int_t x, Int_t y, Int_t width, Int_t height);
1146  const UChar_t *GetPixelColor(Int_t px, Int_t py)const;
1147 
1148 private:
1150  TGLSelectionBuffer &operator = (const TGLSelectionBuffer &);
1151 
1152  ClassDef(TGLSelectionBuffer, 0); //Holds color buffer content for selection
1153 };
1154 
1155 template<class T>
1156 class TGL2DArray : public std::vector<T> {
1157 private:
1160  typedef typename std::vector<T>::size_type size_type;
1161 
1162 public:
1163  TGL2DArray() : fRowLen(0), fMaxRow(0){}
1164  void SetMaxRow(Int_t max)
1165  {
1166  fMaxRow = max;
1167  }
1168  void SetRowLen(Int_t len)
1169  {
1170  fRowLen = len;
1171  }
1172  const T *operator [] (size_type ind)const
1173  {
1174  return &std::vector<T>::operator [](ind * fRowLen);
1175  }
1176  T *operator [] (size_type ind)
1177  {
1178  return &std::vector<T>::operator [] (ind * fRowLen);
1179  }
1180 };
1181 
1182 class TGLPlotCoordinates;
1183 class TGLQuadric;
1184 class TAxis;
1185 
1186 namespace Rgl {
1187 
1188 extern const Float_t gRedEmission[];
1189 extern const Float_t gGreenEmission[];
1190 extern const Float_t gBlueEmission[];
1191 extern const Float_t gOrangeEmission[];
1192 extern const Float_t gWhiteEmission[];
1193 extern const Float_t gGrayEmission[];
1194 extern const Float_t gNullEmission[];
1195 
1196 typedef std::pair<Int_t, Int_t> BinRange_t;
1197 typedef std::pair<Double_t, Double_t> Range_t;
1198 
1199 void ObjectIDToColor(Int_t objectID, Bool_t highColor);
1200 Int_t ColorToObjectID(const UChar_t *color, Bool_t highColor);
1201 void DrawQuadOutline(const TGLVertex3 &v1, const TGLVertex3 &v2,
1202  const TGLVertex3 &v3, const TGLVertex3 &v4);
1203 void DrawQuadFilled(const TGLVertex3 &v0, const TGLVertex3 &v1,
1204  const TGLVertex3 &v2, const TGLVertex3 &v3,
1205  const TGLVector3 &normal);
1206 void DrawQuadFilled(const Double_t *v0, const Double_t *v1,
1207  const Double_t *v2, const Double_t *v3,
1208  const Double_t *normal);
1209 
1210 void DrawSmoothFace(const TGLVertex3 &v1, const TGLVertex3 &v2,
1211  const TGLVertex3 &v3, const TGLVector3 &norm1,
1212  const TGLVector3 &norm2, const TGLVector3 &norm3);
1213 void DrawBoxFront(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax,
1214  Double_t zMin, Double_t zMax, Int_t fp);
1215 
1216 void DrawTransparentBox(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax,
1217  Double_t zMin, Double_t zMax, Int_t fp);
1218 
1219 
1220 void DrawBoxFrontTextured(Double_t xMin, Double_t xMax, Double_t yMin,
1221  Double_t yMax, Double_t zMin, Double_t zMax,
1222  Double_t tMin, Double_t tMax, Int_t front);
1223 
1225  const Double_t *rgba1, const Double_t *rgba2);
1226 
1227 void DrawQuadStripWithRadialGradientFill(unsigned nPoints, const Double_t *inner, const Double_t *innerRGBA,
1228  const Double_t *outer, const Double_t *outerRGBA);
1229 
1230 #ifndef __CINT__
1231 void DrawTrapezoidTextured(const Double_t ver[][2], Double_t zMin, Double_t zMax,
1232  Double_t tMin, Double_t tMax);
1233 void DrawTrapezoidTextured(const Double_t ver[][3], Double_t texMin, Double_t texMax);
1234 void DrawTrapezoidTextured2(const Double_t ver[][2], Double_t zMin, Double_t zMax,
1235  Double_t tMin, Double_t tMax);
1236 #endif
1237 
1238 void DrawCylinder(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin,
1239  Double_t yMax, Double_t zMin, Double_t zMax);
1240 void DrawSphere(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin,
1241  Double_t yMax, Double_t zMin, Double_t zMax);
1242 void DrawError(Double_t xMin, Double_t xMax, Double_t yMin,
1243  Double_t yMax, Double_t zMin, Double_t zMax);
1244 
1245 #ifndef __CINT__
1246 void DrawTrapezoid(const Double_t ver[][2], Double_t zMin, Double_t zMax, Bool_t color = kTRUE);
1247 void DrawTrapezoid(const Double_t ver[][3]);
1248 #endif
1249 
1250 void DrawAxes(Int_t frontPoint, const Int_t *viewport, const TGLVertex3 *box2D,
1251  const TGLPlotCoordinates *plotCoord, TAxis *xAxis, TAxis *yAxis,
1252  TAxis *zAxis);
1253 void SetZLevels(TAxis *zAxis, Double_t zMin, Double_t zMax,
1254  Double_t zScale, std::vector<Double_t> &zLevels);
1255 
1256 void DrawFaceTextured(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3,
1257  Double_t t1, Double_t t2, Double_t t3, const TGLVector3 &norm1,
1258  const TGLVector3 &norm2, const TGLVector3 &norm3);
1259 void DrawFaceTextured(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3,
1260  Double_t t1, Double_t t2, Double_t t3, Double_t z, const TGLVector3 &planeNormal);
1261 void GetColor(Float_t v, Float_t vmin, Float_t vmax, Int_t type, Float_t *rgba);
1262 
1263 class TGuardBase {
1264 private:
1265  mutable Bool_t fActive;
1266 
1267  TGuardBase &operator = (const TGuardBase &rhs);
1268 protected:
1270  : fActive(kTRUE)
1271  {
1272  }
1274  : fActive(kTRUE)
1275  {
1276  rhs.fActive = kFALSE;
1277  }
1278 
1280  {
1281  return fActive;
1282  }
1283 
1284 public:
1285  void Stop()const
1286  {
1287  fActive = kFALSE;
1288  }
1289 };
1290 
1291 template<class Func, class Arg>
1292 class TOneArgGuard : public TGuardBase {
1293 private:
1295  Arg fArg;
1296 public:
1298  : fFunc(f), fArg(a)
1299  {
1300  }
1302  {
1303  if (IsActive())
1304  fFunc(fArg);
1305  }
1306 };
1307 
1308 template<class Func, class Arg1, class Arg2>
1309 class TTwoArgsGuard : public TGuardBase {
1310 private:
1312  Arg1 fArg1;
1313  Arg2 fArg2;
1314 
1315 public:
1316  TTwoArgsGuard(Func f, Arg1 a1, Arg2 a2)
1317  : fFunc(f), fArg1(a1), fArg2(a2)
1318  {
1319  }
1321  {
1322  if (IsActive())
1323  fFunc(fArg1, fArg2);
1324  }
1325 };
1326 
1327 template<class Func, class Arg>
1329 {
1330  return TOneArgGuard<Func, Arg>(f, a);
1331 }
1332 
1333 template<class Func, class Arg1, class Arg2>
1335 {
1336  return TTwoArgsGuard<Func, Arg1, Arg2>(f, a1, a2);
1337 }
1338 
1339 }//namespace Rgl.
1340 
1342 private:
1343  std::vector<UChar_t> fTexels;
1344  const std::vector<Double_t> *fContours;
1346  mutable UInt_t fTexture;
1349 
1350  TGLLevelPalette(const TGLLevelPalette&); // Not implemented
1351  TGLLevelPalette& operator=(const TGLLevelPalette&); // Not implemented
1352 
1353 public:
1354  TGLLevelPalette();
1355 
1356  Bool_t GeneratePalette(UInt_t paletteSize, const Rgl::Range_t &zRange, Bool_t checkSize = kTRUE);
1357 
1358  void SetContours(const std::vector<Double_t> *contours);
1359 
1360  void EnableTexture(Int_t mode)const;
1361  void DisableTexture()const;
1362 
1363  Int_t GetPaletteSize()const;
1364 
1365  Double_t GetTexCoord(Double_t z)const;
1366 
1367  const UChar_t *GetColour(Double_t z)const;
1368  const UChar_t *GetColour(Int_t ind)const;
1369 };
1370 
1371 #endif // ROOT_TGLUtil
Int_t fY
Definition: TGLUtil.h:430
static UInt_t fgDefaultDrawQuality
Definition: TGLUtil.h:919
const TGLColor & Outline() const
Definition: TGLUtil.h:861
std::vector< T >::size_type size_type
Definition: TGLUtil.h:1160
void SetZLevels(TAxis *zAxis, Double_t zMin, Double_t zMax, Double_t zScale, std::vector< Double_t > &zLevels)
Definition: TGLUtil.cxx:3787
RooCmdArg Offset(Bool_t flag=kTRUE)
void SetRowLen(Int_t len)
Definition: TGLUtil.h:1168
std::vector< UChar_t > fTexels
Definition: TGLUtil.h:1343
Int_t fMaxRow
Definition: TGLUtil.h:1159
Double_t & Y()
Definition: TGLUtil.h:125
Class encapsulating a set of colors used throughout standard rendering.
Definition: TGLUtil.h:838
int Invert(LASymMatrix &)
Definition: LaInverse.cxx:22
static UInt_t fgColorLockCount
Definition: TGLUtil.h:922
void DrawFaceTextured(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, Double_t t1, Double_t t2, Double_t t3, const TGLVector3 &norm1, const TGLVector3 &norm2, const TGLVector3 &norm3)
Draw textured triangle.
Definition: TGLUtil.cxx:3803
void DrawQuadFilled(const TGLVertex3 &v0, const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVector3 &normal)
Draw quad face.
Definition: TGLUtil.cxx:2920
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
TGLVertex3 operator*(Double_t f, const TGLVertex3 &v)
Definition: TGLUtil.h:138
UChar_t * Arr()
Definition: TGLUtil.h:802
static double p3(double t, double a, double b, double c, double d)
Wrapper class for various misc static functions - error checking, draw helpers etc.
Definition: TGLUtil.h:880
void SetGreen(Int_t v)
Definition: TGLUtil.h:814
Int_t X() const
Definition: TGLUtil.h:451
Int_t Right() const
Definition: TGLUtil.h:462
Double_t & Z()
Definition: TGLUtil.h:127
UChar_t GetAlpha() const
Definition: TGLUtil.h:808
TLine * line
const Float_t gNullEmission[]
Definition: TGLUtil.cxx:2814
float Float_t
Definition: RtypesCore.h:53
return c
const TGLVertex3 & operator+=(const TGLVector3 &val)
Definition: TGLUtil.h:281
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Definition: TGLUtil.h:736
std::pair< Double_t, Double_t > Range_t
Definition: TGLUtil.h:1197
double T(double x)
Definition: ChebyshevPol.h:34
const TGLVector3 operator/(const TGLVector3 &vec, Double_t val)
Definition: TGLUtil.h:336
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:600
Int_t & Y()
Definition: TGLUtil.h:454
void DrawQuadStripWithRadialGradientFill(unsigned nPoints, const Double_t *inner, const Double_t *innerRGBA, const Double_t *outer, const Double_t *outerRGBA)
TODO: is it possible to use GLdouble to avoid problems with Double_t/GLdouble if they are not the sam...
Definition: TGLUtil.cxx:3184
Class encapsulating color information in preferred GL format - an array of four unsigned bytes...
Definition: TGLUtil.h:787
TH1 * h
Definition: legend2.C:5
Bool_t fActive
Definition: TGLUtil.h:1265
T Mag(const SVector< T, D > &rhs)
Vector magnitude (Euclidian norm) Compute : .
Definition: Functions.h:254
virtual ~TGLUtil()
Definition: TGLUtil.h:937
TGLMatrix & operator*=(const TGLMatrix &rhs)
Definition: TGLUtil.h:626
const TGLColor & Selection(Int_t i) const
Definition: TGLUtil.h:863
std::vector< TGLPlane >::const_iterator TGLPlaneSet_ci
Definition: TGLUtil.h:576
void Fill(Double_t val)
Definition: TGLUtil.h:207
TGLVector3 operator-(const TGLVertex3 &vertex1, const TGLVertex3 &vertex2)
Definition: TGLUtil.h:356
TGL2DArray()
Definition: TGLUtil.h:1163
Double_t fVals[16]
Definition: TGLUtil.h:604
Basic string class.
Definition: TString.h:137
const Float_t gBlueEmission[]
Definition: TGLUtil.cxx:2810
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
Double_t & operator[](Int_t index)
Definition: TGLUtil.h:686
const Bool_t kFALSE
Definition: Rtypes.h:92
void SetRed(Int_t v)
Definition: TGLUtil.h:813
const TGLVertex3 & Start() const
Definition: TGLUtil.h:409
const T Minimum(const T &lhs, const T &rhs)
minimum.
Definition: Functions.h:101
Int_t Y() const
Definition: TGLUtil.h:453
Int_t fMaxPaletteSize
Definition: TGLUtil.h:1347
void DrawBoxWithGradientFill(Double_t y1, Double_t y2, Double_t x1, Double_t x2, const Double_t *rgba1, const Double_t *rgba2)
Definition: TGLUtil.cxx:3164
Double_t B() const
Definition: TGLUtil.h:557
TGLColor & Markup()
Definition: TGLUtil.h:856
Bool_t ValidIndex(UInt_t index) const
Definition: TGLUtil.h:607
Wrapper class for GLU quadric shape drawing object.
Definition: TGLQuadric.h:29
TGLColor fForeground
Definition: TGLUtil.h:842
const T Maximum(const T &lhs, const T &rhs)
maximum.
Definition: Functions.h:87
TGLVector3 operator-() const
Definition: TGLUtil.h:297
Float_t fState
Definition: TGLUtil.h:1100
void Offset(Int_t dX, Int_t dY)
Definition: TGLUtil.h:492
void Set(Double_t x, Double_t y, Double_t z)
Definition: TGLUtil.h:213
TLatex * t1
Definition: textangle.C:20
Double_t Aspect() const
Definition: TGLUtil.h:505
void DrawAxes(Int_t frontPoint, const Int_t *viewport, const TGLVertex3 *box2D, const TGLPlotCoordinates *plotCoord, TAxis *xAxis, TAxis *yAxis, TAxis *zAxis)
Using front point, find, where to draw axes and which labels to use for them gVirtualX->SelectWindow(...
Definition: TGLUtil.cxx:3726
Int_t Longest() const
Definition: TGLUtil.h:499
void DrawQuadOutline(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVertex3 &v4)
Draw quad outline.
Definition: TGLUtil.cxx:2906
TGLVertex3 fVertex
Definition: TGLUtil.h:395
Marker Attributes class.
Definition: TAttMarker.h:24
TGLVertex3 operator-() const
Definition: TGLUtil.h:170
double sqrt(double)
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
const Float_t gWhiteEmission[]
Definition: TGLUtil.cxx:2812
Int_t & Height()
Definition: TGLUtil.h:458
virtual ~TColorLocker()
Definition: TGLUtil.h:887
#define ClassDef(name, id)
Definition: Rtypes.h:254
const TGLVertex3 & operator-=(const TGLVector3 &val)
Definition: TGLUtil.h:273
Double_t D() const
Definition: TGLUtil.h:559
Rgl::Range_t fZRange
Definition: TGLUtil.h:1348
RooCmdArg Color(Color_t color)
TGLVector3 fVector
Start vertex of line.
Definition: TGLUtil.h:396
3 component (x/y/z) vertex class.
Definition: TGLUtil.h:86
TGLVertex3 & operator=(const TGLVertex3 &rhs)
Definition: TGLUtil.h:158
const UChar_t * CArr() const
Definition: TGLUtil.h:803
void DrawTrapezoidTextured2(const Double_t ver[][2], Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax)
In polar coordinates, box became trapezoid.
Definition: TGLUtil.cxx:3462
static double p2(double t, double a, double b, double c)
Bool_t ValidIndex(UInt_t index) const
Definition: TGLUtil.h:90
static Int_t fgPickingRadius
Definition: TGLUtil.h:931
Int_t & Width()
Definition: TGLUtil.h:456
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:426
std::vector< UChar_t > fBuffer
Definition: TGLUtil.h:1136
const TGLVertex3 End() const
Definition: TGLUtil.h:410
Double_t * Arr()
Definition: TGLUtil.h:668
3 component (x/y/z) vector class.
Definition: TGLUtil.h:250
std::vector< TGLPlane >::iterator TGLPlaneSet_i
Definition: TGLUtil.h:575
static UInt_t fgDrawQuality
Definition: TGLUtil.h:920
UChar_t GetBlue() const
Definition: TGLUtil.h:807
void Error(const char *location, const char *msgfmt,...)
TGLColor fMarkup
Definition: TGLUtil.h:844
short Color_t
Definition: RtypesCore.h:79
const Double_t * CArr() const
Definition: TGLUtil.h:566
Int_t ColorToObjectID(const UChar_t *color, Bool_t highColor)
Definition: TGLUtil.cxx:2884
REAL * vertex
Definition: triangle.c:512
static const char * what
Definition: stlLoader.cc:6
point * points
Definition: X3DBuffer.c:20
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
Definition: TGLUtil.cxx:2858
const TGLColor & Markup() const
Definition: TGLUtil.h:862
th1 Draw()
Definition: TGLUtil.h:62
void Stop() const
Definition: TGLUtil.h:1285
static Float_t fgLineWidth
Definition: TGLUtil.h:925
void DrawBoxFront(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax, Int_t fp)
Draws lego&#39;s bar as a 3d box.
Definition: TGLUtil.cxx:2974
static Float_t fgPointSizeScale
Definition: TGLUtil.h:926
Double_t Mag() const
Definition: TGLUtil.h:303
void DrawError(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Definition: TGLUtil.cxx:3265
Int_t Top() const
Definition: TGLUtil.h:463
static double C[]
Bool_t operator==(const TGLVertex3 &rhs) const
Definition: TGLUtil.h:152
void DrawSmoothFace(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVector3 &norm1, const TGLVector3 &norm2, const TGLVector3 &norm3)
Draws triangle face, each vertex has its own averaged normal.
Definition: TGLUtil.cxx:2950
TRandom2 r(17)
Double_t * Arr()
Definition: TGLUtil.h:130
Class to manage histogram axis.
Definition: TAxis.h:36
EGLCoordType
Definition: TGLUtil.h:45
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
const Float_t gGreenEmission[]
Definition: TGLUtil.cxx:2809
const Float_t gRedEmission[]
Definition: TGLUtil.cxx:2808
SVector< double, 2 > v
Definition: Dict.h:5
TOneArgGuard< Func, Arg > make_guard(Func f, Arg a)
Definition: TGLUtil.h:1328
std::pair< Int_t, Int_t > BinRange_t
Definition: TGLUtil.h:1196
TDrawQualityScaler(Float_t fac)
Definition: TGLUtil.h:909
TGLVector3 Norm() const
Definition: TGLUtil.h:561
Int_t CenterX() const
Definition: TGLUtil.h:459
Double_t A() const
Definition: TGLUtil.h:556
const Float_t gGrayEmission[]
Definition: TGLUtil.cxx:2813
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
const Double_t * CArr() const
Definition: TGLUtil.h:667
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t & X()
Definition: TGLUtil.h:452
const TGLColor & Background() const
Definition: TGLUtil.h:859
const TGLVector3 & Vector() const
Definition: TGLUtil.h:411
short Short_t
Definition: RtypesCore.h:35
Double_t C() const
Definition: TGLUtil.h:558
UInt_t fTexture
Definition: TGLUtil.h:1346
3D space, fixed length, line class, with direction / length &#39;vector&#39;, passing through point &#39;vertex&#39;...
Definition: TGLUtil.h:391
static double p1(double t, double a, double b)
UChar_t GetGreen() const
Definition: TGLUtil.h:806
void DrawTransparentBox(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax, Int_t fp)
Draws lego&#39;s bar as a 3d box.
Definition: TGLUtil.cxx:3024
UChar_t GetRed() const
Definition: TGLUtil.h:805
Bool_t fFlip
Definition: TGLUtil.h:1101
TGLColor fOutline
Definition: TGLUtil.h:843
Int_t Left() const
Definition: TGLUtil.h:461
lv DrawLine(0.33, 0.0, 0.33, 1.0)
Int_t Width() const
Definition: TGLUtil.h:455
Vector Rotate(const Vector &v, const RotationMatrix &rot)
rotation on a generic vector using a generic rotation class.
Definition: VectorUtil.h:308
Int_t * CArr()
Definition: TGLUtil.h:449
Double_t Z() const
Definition: TGLUtil.h:126
TGLColor fBackground
Definition: TGLUtil.h:841
Double_t Dot(const TGLVector3 &v1, const TGLVector3 &v2)
Definition: TGLUtil.h:322
static Float_t fgPointLineScalingFactor
Definition: TGLUtil.h:930
static const double x1[5]
double f(double x)
std::vector< TGLPlane > TGLPlaneSet_t
Definition: TGLUtil.h:574
Double_t & operator[](Int_t index)
Definition: TGLUtil.h:185
static Float_t fgScreenScalingFactor
Definition: TGLUtil.h:929
double Double_t
Definition: RtypesCore.h:55
void SetCorner(Int_t x, Int_t y)
Definition: TGLUtil.h:485
void DrawTrapezoidTextured(const Double_t ver[][2], Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax)
In polar coordinates, box became trapezoid.
Definition: TGLUtil.cxx:3385
int type
Definition: TGX11.cxx:120
TGLVertex3 operator+(const TGLVertex3 &vertex1, const TGLVector3 &vertex2)
Definition: TGLUtil.h:349
Int_t Bottom() const
Definition: TGLUtil.h:464
Double_t y[n]
Definition: legend1.C:17
RooCmdArg LineWidth(Width_t width)
Short_t fIndex
Definition: TGLUtil.h:791
Double_t fVals[3]
Definition: TGLUtil.h:91
const TGLColor & Foreground() const
Definition: TGLUtil.h:860
TGLColor & Background()
Definition: TGLUtil.h:853
void Negate()
Definition: TGLUtil.h:144
void DrawTrapezoid(const Double_t ver[][2], Double_t zMin, Double_t zMax, Bool_t color=kTRUE)
Definition: TGLUtil.cxx:3315
void DrawSphere(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Cylinder for lego3.
Definition: TGLUtil.cxx:3242
EGLPlotType
Definition: TGLUtil.h:53
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
void GetColor(Float_t v, Float_t vmin, Float_t vmax, Int_t type, Float_t *rgba)
This function creates color for parametric surface&#39;s vertex, using its &#39;u&#39; value. ...
Definition: TGLUtil.cxx:3844
const Double_t * CArr() const
Definition: TGLUtil.h:129
TTwoArgsGuard(Func f, Arg1 a1, Arg2 a2)
Definition: TGLUtil.h:1316
char Char_t
Definition: RtypesCore.h:29
typedef void((*Func_t)())
TGLColor & Selection(Int_t i)
Definition: TGLUtil.h:857
Bool_t operator==(const TDatime &d1, const TDatime &d2)
Definition: TDatime.h:101
Double_t * Arr()
Definition: TGLUtil.h:567
void Normalise()
Definition: TGLUtil.h:309
TGLVector3 & operator/=(Double_t val)
Definition: TGLUtil.h:288
TGLVertex3 & operator*=(Double_t f)
Definition: TGLUtil.h:176
TGLMatrix & operator=(const TGLMatrix &rhs)
Definition: TGLUtil.h:676
EOverlap
Definition: TGLUtil.h:37
Bool_t IsActive() const
Definition: TGLUtil.h:1279
void SetBlue(Int_t v)
Definition: TGLUtil.h:815
Int_t CenterY() const
Definition: TGLUtil.h:460
static Float_t fgLineWidthScale
Definition: TGLUtil.h:927
TGLColor & Outline()
Definition: TGLUtil.h:855
Int_t fRowLen
Definition: TGLUtil.h:1158
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void SetMaxRow(Int_t max)
Definition: TGLUtil.h:1164
unsigned char UChar_t
Definition: RtypesCore.h:34
TGLVector3 Cross(const TGLVector3 &v1, const TGLVector3 &v2)
Definition: TGLUtil.h:328
void DrawCylinder(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Cylinder for lego3.
Definition: TGLUtil.cxx:3211
def normal(shape, name=None)
Int_t Height() const
Definition: TGLUtil.h:457
static Float_t fgPointSize
Definition: TGLUtil.h:924
void DrawBoxFrontTextured(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax, Int_t front)
Draws lego&#39;s bar as a 3d box LULULULU.
Definition: TGLUtil.cxx:3101
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t fWidth
Corner.
Definition: TGLUtil.h:431
Double_t Y() const
Definition: TGLUtil.h:124
Double_t & X()
Definition: TGLUtil.h:123
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
3D plane class - of format Ax + By + Cz + D = 0
Definition: TGLUtil.h:529
const Float_t gOrangeEmission[]
Definition: TGLUtil.cxx:2811
TGLColor & Foreground()
Definition: TGLUtil.h:854
const Int_t n
Definition: legend1.C:16
Line Attributes class.
Definition: TAttLine.h:24
virtual ~TDrawQualityScaler()
Definition: TGLUtil.h:912
ELineHeadShape
Definition: TGLUtil.h:950
EAxesType
Definition: TGLUtil.h:951
TGuardBase(const TGuardBase &rhs)
Definition: TGLUtil.h:1273
void SetAlpha(Int_t v)
Definition: TGLUtil.h:816
void Set(Int_t x, Int_t y, Int_t width, Int_t height)
Definition: TGLUtil.h:476
TOneArgGuard(Func f, Arg a)
Definition: TGLUtil.h:1297
UInt_t fPaletteSize
Definition: TGLUtil.h:1345
TGLVector3 GetBaseVec(Int_t b) const
Definition: TGLUtil.h:757
const std::vector< Double_t > * fContours
Definition: TGLUtil.h:1344
const Int_t * CArr() const
Definition: TGLUtil.h:448
std::pair< Bool_t, TGLLine3 > Intersection(const TGLPlane &p1, const TGLPlane &p2)
Find 3D line interestion of this plane with &#39;other&#39;.
Definition: TGLUtil.cxx:544
Double_t X() const
Definition: TGLUtil.h:122