Logo ROOT   6.10/09
Reference Guide
TEveDigitSetGL.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 #include "TEveDigitSetGL.h"
13 #include "TEveFrameBoxGL.h"
14 
15 #include "TGLRnrCtx.h"
16 #include "TGLSelectRecord.h"
17 #include "TGLIncludes.h"
18 
19 /** \class TEveDigitSetGL
20 \ingroup TEve
21 OpenGL renderer class for TEveDigitSet.
22 */
23 
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Constructor.
28 
30  TGLObject(), fHighlightSet(0)
31 {
32 }
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Set color for rendering of the specified digit.
36 
38 {
40 
41  if (DS.fSingleColor)
42  {
43  return kTRUE;
44  }
45  else if (DS.fValueIsColor)
46  {
47  if (q.fValue != 0)
48  {
50  return kTRUE;
51  } else {
52  return kFALSE;
53  }
54  }
55  else
56  {
57  UChar_t c[4];
58  Bool_t visible = DS.fPalette->ColorFromValue(q.fValue, DS.fDefaultValue, c);
59  if (visible)
61  return visible;
62  }
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Make a decision if the frame should be drawn.
67 /// This depends on the render state (selection / highligt) and
68 /// on values of members fSelectViaFrame and fHighlightFrame.
69 
71 {
73 
74  if (DS.fFrame != 0 && ! rnrCtx.SecSelection() &&
75  ! (rnrCtx.Selection() && ! DS.fSelectViaFrame) &&
76  ! (rnrCtx.Highlight() && ! DS.fHighlightFrame))
77  {
79  }
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Set bounding box.
84 
86 {
87  SetAxisAlignedBBox(((TEveDigitSet*)fExternalObj)->AssertBBox());
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// Draw the quad-set in highlight mode.
92 /// Incoming lvl is ignored -- physical shape always calls it with -1.
93 
94 void TEveDigitSetGL::DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t /*lvl*/) const
95 {
97 
99  {
100  if ( ! DS.RefHighlightedSet().empty())
101  {
103  TGLObject::DrawHighlight(rnrCtx, pshp, 3);
104  }
105  if ( ! DS.RefSelectedSet().empty())
106  {
107  fHighlightSet = & DS.RefSelectedSet();
108  TGLObject::DrawHighlight(rnrCtx, pshp, 1);
109  }
110  fHighlightSet = 0;
111  }
112  else
113  {
114  TGLObject::DrawHighlight(rnrCtx, pshp);
115  }
116 }
117 
118 ////////////////////////////////////////////////////////////////////////////////
119 /// Processes secondary selection from TGLViewer.
120 /// Calls DigitSelected(Int_t) in the model object with index of
121 /// selected point as the argument.
122 
124 {
126 
127  if (AlwaysSecondarySelect())
128  {
129  DS.ProcessGLSelection(rec);
130  }
131  else
132  {
133  if (rec.GetN() < 2) return;
134  DS.DigitSelected(rec.GetItem(1));
135  }
136 }
Bool_t Highlight() const
Definition: TGLRnrCtx.h:218
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
Bool_t SecSelection() const
Definition: TGLRnrCtx.h:224
Bool_t fSingleColor
Definition: TEveDigitSet.h:62
const std::set< Int_t > * fHighlightSet
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
Bool_t fSelectViaFrame
Definition: TEveDigitSet.h:73
Int_t fDefaultValue
Definition: TEveDigitSet.h:60
virtual void DigitSelected(Int_t idx)
Called from renderer when a digit with index idx is selected.
void SetAxisAlignedBBox(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
Set axis-aligned bounding-box.
Definition: TGLObject.cxx:86
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static void Render(const TEveFrameBox *box)
Render the frame-box with GL.
Concrete physical shape - a GL drawable.
virtual void SetBBox()
Set bounding box.
Base-class for direct OpenGL renderers.
Definition: TGLObject.h:21
const UChar_t * ColorFromValue(Int_t val) const
OpenGL renderer class for TEveDigitSet.
TObject * fExternalObj
first replica
virtual void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *pshp, Int_t lvl=-1) const
Draw the quad-set in highlight mode.
TEveFrameBox * fFrame
Definition: TEveDigitSet.h:70
virtual void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *pshp, Int_t lvl=-1) const
Draw the logical shape in highlight mode.
Standard selection record including information about containing scene and details ob out selected ob...
virtual Bool_t AlwaysSecondarySelect() const
Bool_t fValueIsColor
Definition: TEveDigitSet.h:61
TEveRGBAPalette * fPalette
Definition: TEveDigitSet.h:71
TEveDigitSetGL()
Constructor.
Bool_t fHighlightFrame
Definition: TEveDigitSet.h:74
virtual void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
Processes secondary selection from TGLViewer.
const Bool_t kFALSE
Definition: RtypesCore.h:92
#define ClassImp(name)
Definition: Rtypes.h:336
const SelectionSet_t & RefHighlightedSet() const
UInt_t GetItem(Int_t i) const
Int_t GetN() const
void DrawFrameIfNeeded(TGLRnrCtx &rnrCtx) const
Make a decision if the frame should be drawn.
unsigned char UChar_t
Definition: RtypesCore.h:34
void ProcessGLSelection(TGLSelectRecord &rec)
Process secondary GL selection and populate selected set accordingly.
float * q
Definition: THbookFile.cxx:87
const Bool_t kTRUE
Definition: RtypesCore.h:91
Bool_t SetupColor(const TEveDigitSet::DigitBase_t &q) const
Set color for rendering of the specified digit.
Base-class for storage of digit collections; provides transformation matrix (TEveTrans), signal to color mapping (TEveRGBAPalette) and visual grouping (TEveFrameBox).
Definition: TEveDigitSet.h:29
static void Color4ubv(const UChar_t *rgba)
Wrapper for glColor4ubv.
Definition: TGLUtil.cxx:1740
static void Color3ubv(const UChar_t *rgb)
Wrapper for glColor3ubv.
Definition: TGLUtil.cxx:1732
const SelectionSet_t & RefSelectedSet() const