TEveDigitSetGL.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveDigitSetGL.cxx 33124 2010-04-21 20:04:42Z matevz $
00002 // Author: Matevz Tadel 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveDigitSetGL.h"
00013 
00014 #include "TGLRnrCtx.h"
00015 #include "TGLSelectRecord.h"
00016 #include "TGLIncludes.h"
00017 
00018 //______________________________________________________________________________
00019 // OpenGL renderer class for TEveDigitSet.
00020 //
00021 
00022 ClassImp(TEveDigitSetGL);
00023 
00024 //______________________________________________________________________________
00025 TEveDigitSetGL::TEveDigitSetGL() :
00026    TGLObject(), fHighlightSet(0)
00027 {
00028    // Constructor.
00029 }
00030 
00031 //______________________________________________________________________________
00032 Bool_t TEveDigitSetGL::SetupColor(const TEveDigitSet::DigitBase_t& q) const
00033 {
00034    // Set color for rendering of the specified digit.
00035 
00036    TEveDigitSet& DS = * (TEveDigitSet*)fExternalObj;
00037 
00038    if (DS.fSingleColor)
00039    {
00040       return kTRUE;
00041    }
00042    else if (DS.fValueIsColor)
00043    {
00044       if (q.fValue != 0)
00045       {
00046          TGLUtil::Color4ubv((UChar_t*) & q.fValue);
00047          return kTRUE;
00048       } else {
00049          return kFALSE;
00050       }
00051    }
00052    else
00053    {
00054       UChar_t c[4];
00055       Bool_t visible = DS.fPalette->ColorFromValue(q.fValue, DS.fDefaultValue, c);
00056       if (visible)
00057          TGLUtil::Color3ubv(c);
00058       return visible;
00059    }
00060 }
00061 
00062 //______________________________________________________________________________
00063 void TEveDigitSetGL::SetBBox()
00064 {
00065    // Set bounding box.
00066 
00067    SetAxisAlignedBBox(((TEveDigitSet*)fExternalObj)->AssertBBox());
00068 }
00069 
00070 //______________________________________________________________________________
00071 void TEveDigitSetGL::DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t /*lvl*/) const
00072 {
00073    // Draw the quad-set in highlight mode.
00074    // Incoming lvl is ignored -- physical shape always calls it with -1.
00075 
00076    TEveDigitSet& DS = * (TEveDigitSet*)fExternalObj;
00077 
00078    if (AlwaysSecondarySelect())
00079    {
00080       Float_t dr[2];
00081       glGetFloatv(GL_DEPTH_RANGE,dr);
00082 
00083       if ( ! DS.RefHighlightedSet().empty())
00084       {
00085          fHighlightSet = & DS.RefHighlightedSet();
00086          TGLObject::DrawHighlight(rnrCtx, pshp, 3);
00087       }
00088       if ( ! DS.RefSelectedSet().empty())
00089       {
00090          glDepthRange(dr[0], 0.8*dr[1]);
00091          fHighlightSet = & DS.RefSelectedSet();
00092          TGLObject::DrawHighlight(rnrCtx, pshp, 1);
00093          glDepthRange(dr[0], dr[1]);
00094       }
00095       fHighlightSet = 0;
00096    }
00097    else
00098    {
00099       TGLObject::DrawHighlight(rnrCtx, pshp);
00100    }
00101 }
00102 
00103 //______________________________________________________________________________
00104 void TEveDigitSetGL::ProcessSelection(TGLRnrCtx& /*rnrCtx*/, TGLSelectRecord& rec)
00105 {
00106    // Processes secondary selection from TGLViewer.
00107    // Calls DigitSelected(Int_t) in the model object with index of
00108    // selected point as the argument.
00109 
00110    TEveDigitSet& DS = * (TEveDigitSet*)fExternalObj;
00111 
00112    if (AlwaysSecondarySelect())
00113    {
00114       DS.ProcessGLSelection(rec);
00115    }
00116    else
00117    {
00118       if (rec.GetN() < 2) return;
00119       DS.DigitSelected(rec.GetItem(1));
00120    }
00121 }

Generated on Tue Jul 5 14:16:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1