Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TPointSet3DGL.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel 7/4/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, 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 #ifdef WIN32
13 #include "Windows4root.h"
14 #endif
15 
16 #include "TPointSet3DGL.h"
17 #include "TPointSet3D.h"
18 
19 #include <TGLRnrCtx.h>
20 #include <TGLSelectRecord.h>
21 #include <TGLIncludes.h>
22 
23 /** \class TPointSet3DGL
24 \ingroup opengl
25 Direct OpenGL renderer for TPointSet3D.
26 */
27 
28 ClassImp(TPointSet3DGL);
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Set model.
32 
33 Bool_t TPointSet3DGL::SetModel(TObject* obj, const Option_t*)
34 {
35  return SetModelCheckClass(obj, TPointSet3D::Class());
36 }
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Set bounding-box.
40 
41 void TPointSet3DGL::SetBBox()
42 {
43  SetAxisAlignedBBox(((TPointSet3D*)fExternalObj)->AssertBBox());
44 }
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Override from TGLLogicalShape.
48 /// To account for large point-sizes we modify the projection matrix
49 /// during selection and thus we need a direct draw.
50 
51 Bool_t TPointSet3DGL::ShouldDLCache(const TGLRnrCtx& rnrCtx) const
52 {
53  if (rnrCtx.Selection())
54  return kFALSE;
55  return TGLObject::ShouldDLCache(rnrCtx);
56 }
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Draw function for TPointSet3D. Skips line-pass of outline mode.
60 
61 void TPointSet3DGL::Draw(TGLRnrCtx& rnrCtx) const
62 {
63  if (rnrCtx.IsDrawPassOutlineLine())
64  return;
65 
66  TGLObject::Draw(rnrCtx);
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Direct GL rendering for TPointSet3D.
71 
72 void TPointSet3DGL::DirectDraw(TGLRnrCtx& rnrCtx) const
73 {
74  //printf("TPointSet3DGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
75  //printf(" sel=%d, secsel=%d\n", rnrCtx.Selection(), rnrCtx.SecSelection());
76 
77  TPointSet3D& q = * (TPointSet3D*) fExternalObj;
78 
79  TGLUtil::LockColor(); // Keep color from TGLPhysicalShape.
80  TGLUtil::RenderPolyMarkers(q, 0, q.GetP(), q.Size(),
81  rnrCtx.GetPickRadius(),
82  rnrCtx.Selection(),
83  rnrCtx.SecSelection());
84  TGLUtil::UnlockColor();
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Processes secondary selection from TGLViewer.
89 /// Calls TPointSet3D::PointSelected(Int_t) with index of selected
90 /// point as an argument.
91 
92 void TPointSet3DGL::ProcessSelection(TGLRnrCtx& /*rnrCtx*/, TGLSelectRecord& rec)
93 {
94  if (rec.GetN() < 2) return;
95  TPointSet3D& q = * (TPointSet3D*) fExternalObj;
96  q.PointSelected(rec.GetItem(1));
97 }