Logo ROOT   6.12/07
Reference Guide
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 
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Set model.
32 
34 {
36 }
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Set bounding-box.
40 
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 
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 
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 
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());
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 
93 {
94  if (rec.GetN() < 2) return;
96  q.PointSelected(rec.GetItem(1));
97 }
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
Int_t GetPickRadius()
Return pick radius. If selection is not active it returns 0.
Definition: TGLRnrCtx.cxx:257
const char Option_t
Definition: RtypesCore.h:62
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
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
bool Bool_t
Definition: RtypesCore.h:59
static void RenderPolyMarkers(const TAttMarker &marker, Char_t transp, Float_t *p, Int_t n, Int_t pick_radius=0, Bool_t selection=kFALSE, Bool_t sec_selection=kFALSE)
Render polymarkers at points specified by p-array.
Definition: TGLUtil.cxx:1941
Bool_t IsDrawPassOutlineLine() const
Definition: TGLRnrCtx.h:207
virtual void SetBBox()
Set bounding-box.
void Class()
Definition: Class.C:29
virtual void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
Processes secondary selection from TGLViewer.
static UInt_t LockColor()
Prevent further color changes.
Definition: TGLUtil.cxx:1630
static UInt_t UnlockColor()
Allow color changes.
Definition: TGLUtil.cxx:1638
TObject * fExternalObj
first replica
Bool_t SetModelCheckClass(TObject *obj, TClass *cls)
Checks if obj is of proper class and sets the model.
Definition: TGLObject.cxx:71
virtual void PointSelected(Int_t n)
This virtual method is called from TPointSet3DGL when a point is selected.
Standard selection record including information about containing scene and details ob out selected ob...
virtual Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const
Override from TGLLogicalShape.
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model.
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const
Decide if display-list should be used for this pass rendering, as determined by rnrCtx.
Definition: TGLObject.cxx:41
#define ClassImp(name)
Definition: Rtypes.h:359
UInt_t GetItem(Int_t i) const
Mother of all ROOT objects.
Definition: TObject.h:37
Direct OpenGL renderer for TPointSet3D.
Definition: TPointSet3DGL.h:20
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
Int_t GetN() const
virtual Float_t * GetP() const
Definition: TPolyMarker3D.h:59
TPolyMarker3D using TPointSet3DGL for direct OpenGL rendering.
Definition: TPointSet3D.h:21
float * q
Definition: THbookFile.cxx:87
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw function for TPointSet3D. Skips line-pass of outline mode.
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Direct GL rendering for TPointSet3D.
virtual Int_t Size() const
Definition: TPolyMarker3D.h:73