forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveDigitSetGL.cxx
136 lines (115 loc) · 3.79 KB
/
TEveDigitSetGL.cxx
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
// @(#)root/eve:$Id$
// Author: Matevz Tadel 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveDigitSetGL.h"
#include "TEveFrameBoxGL.h"
#include "TGLRnrCtx.h"
#include "TGLSelectRecord.h"
#include "TGLIncludes.h"
/** \class TEveDigitSetGL
\ingroup TEve
OpenGL renderer class for TEveDigitSet.
*/
ClassImp(TEveDigitSetGL);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveDigitSetGL::TEveDigitSetGL() :
TGLObject(), fHighlightSet(nullptr)
{
}
////////////////////////////////////////////////////////////////////////////////
/// Set color for rendering of the specified digit.
Bool_t TEveDigitSetGL::SetupColor(const TEveDigitSet::DigitBase_t& q) const
{
TEveDigitSet &DS = * (TEveDigitSet*) fExternalObj;
if (DS.fSingleColor)
{
return kTRUE;
}
else if (DS.fValueIsColor)
{
if (q.fValue != 0)
{
TGLUtil::Color4ubv((UChar_t*) & q.fValue);
return kTRUE;
} else {
return kFALSE;
}
}
else
{
UChar_t c[4];
Bool_t visible = DS.fPalette->ColorFromValue(q.fValue, DS.fDefaultValue, c);
if (visible)
TGLUtil::Color3ubv(c);
return visible;
}
}
////////////////////////////////////////////////////////////////////////////////
/// Make a decision if the frame should be drawn.
/// This depends on the render state (selection / highligt) and
/// on values of members fSelectViaFrame and fHighlightFrame.
void TEveDigitSetGL::DrawFrameIfNeeded(TGLRnrCtx& rnrCtx) const
{
TEveDigitSet &DS = * (TEveDigitSet*)fExternalObj;
if (DS.fFrame != nullptr && ! rnrCtx.SecSelection() &&
! (rnrCtx.Selection() && ! DS.fSelectViaFrame) &&
! (rnrCtx.Highlight() && ! DS.fHighlightFrame))
{
TEveFrameBoxGL::Render(DS.fFrame);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set bounding box.
void TEveDigitSetGL::SetBBox()
{
SetAxisAlignedBBox(((TEveDigitSet*)fExternalObj)->AssertBBox());
}
////////////////////////////////////////////////////////////////////////////////
/// Draw the quad-set in highlight mode.
/// Incoming lvl is ignored -- physical shape always calls it with -1.
void TEveDigitSetGL::DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t /*lvl*/) const
{
TEveDigitSet &DS = * (TEveDigitSet*)fExternalObj;
if (AlwaysSecondarySelect())
{
if ( ! DS.RefHighlightedSet().empty())
{
fHighlightSet = & DS.RefHighlightedSet();
TGLObject::DrawHighlight(rnrCtx, pshp, 3);
}
if ( ! DS.RefSelectedSet().empty())
{
fHighlightSet = & DS.RefSelectedSet();
TGLObject::DrawHighlight(rnrCtx, pshp, 1);
}
fHighlightSet = nullptr;
}
else
{
TGLObject::DrawHighlight(rnrCtx, pshp);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Processes secondary selection from TGLViewer.
/// Calls DigitSelected(Int_t) in the model object with index of
/// selected point as the argument.
void TEveDigitSetGL::ProcessSelection(TGLRnrCtx& /*rnrCtx*/, TGLSelectRecord& rec)
{
TEveDigitSet &DS = * (TEveDigitSet*)fExternalObj;
if (AlwaysSecondarySelect())
{
DS.ProcessGLSelection(rec);
}
else
{
if (rec.GetN() < 2) return;
DS.DigitSelected(rec.GetItem(1));
}
}