#include "TEveDigitSetGL.h"
#include "TGLRnrCtx.h"
#include "TGLSelectRecord.h"
#include "TGLIncludes.h"
ClassImp(TEveDigitSetGL);
TEveDigitSetGL::TEveDigitSetGL() :
TGLObject(), fHighlightSet(0)
{
}
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;
}
}
void TEveDigitSetGL::SetBBox()
{
SetAxisAlignedBBox(((TEveDigitSet*)fExternalObj)->AssertBBox());
}
void TEveDigitSetGL::DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t ) const
{
TEveDigitSet& DS = * (TEveDigitSet*)fExternalObj;
if (AlwaysSecondarySelect())
{
Float_t dr[2];
glGetFloatv(GL_DEPTH_RANGE,dr);
if ( ! DS.RefHighlightedSet().empty())
{
fHighlightSet = & DS.RefHighlightedSet();
TGLObject::DrawHighlight(rnrCtx, pshp, 3);
}
if ( ! DS.RefSelectedSet().empty())
{
glDepthRange(dr[0], 0.8*dr[1]);
fHighlightSet = & DS.RefSelectedSet();
TGLObject::DrawHighlight(rnrCtx, pshp, 1);
glDepthRange(dr[0], dr[1]);
}
fHighlightSet = 0;
}
else
{
TGLObject::DrawHighlight(rnrCtx, pshp);
}
}
void TEveDigitSetGL::ProcessSelection(TGLRnrCtx& , TGLSelectRecord& rec)
{
TEveDigitSet& DS = * (TEveDigitSet*)fExternalObj;
if (AlwaysSecondarySelect())
{
DS.ProcessGLSelection(rec);
}
else
{
if (rec.GetN() < 2) return;
DS.DigitSelected(rec.GetItem(1));
}
}