Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLSelectRecord.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel, Jun 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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 #ifndef ROOT_TGLSelectRecord
13 #define ROOT_TGLSelectRecord
14 
15 #include <Rtypes.h>
16 
17 class TObject;
18 class TGLSceneInfo;
19 class TGLPhysicalShape;
20 class TGLLogicalShape;
21 class TGLOverlayElement;
22 
23 /**************************************************************************/
24 // TGLSelectRecordBase
25 /**************************************************************************/
26 
27 class TGLSelectRecordBase
28 {
29 protected:
30  // Primary data - coming from GL.
31  Int_t fN;
32  UInt_t *fItems;
33  Float_t fMinZ;
34  Float_t fMaxZ;
35 
36  // Current position (for name resolutin in hierachies of unknown depth).
37  Int_t fPos;
38 
39  void CopyItems(UInt_t* items);
40 
41 public:
42  TGLSelectRecordBase();
43  TGLSelectRecordBase(UInt_t* data);
44  TGLSelectRecordBase(const TGLSelectRecordBase& rec);
45  virtual ~TGLSelectRecordBase();
46 
47  TGLSelectRecordBase& operator=(const TGLSelectRecordBase& rec);
48 
49  void SetRawOnly(UInt_t* data);
50 
51  virtual void Set(UInt_t* data);
52  virtual void Reset();
53 
54  Int_t GetN() const { return fN; }
55  UInt_t* GetItems() const { return fItems; }
56  UInt_t GetItem(Int_t i) const { return fItems[i]; }
57  Float_t GetMinZ() const { return fMinZ; }
58  Float_t GetMaxZ() const { return fMaxZ; }
59 
60  UInt_t GetCurrItem() const { return fPos < fN ? fItems[fPos] : 0; }
61  Int_t GetNLeft() const { return fN - fPos; }
62  void NextPos() { ++fPos; }
63  void PrevPos() { --fPos; }
64  void ResetPos() { fPos = 0; }
65 
66  ClassDef(TGLSelectRecordBase, 0) // Base class for GL selection records.
67 };
68 
69 
70 /**************************************************************************/
71 // TGLSelectRecord
72 /**************************************************************************/
73 
74 class TGLSelectRecord : public TGLSelectRecordBase
75 {
76 public:
77  enum ESecSelResult { kNone, kEnteringSelection, kLeavingSelection, kModifyingInternalSelection };
78 
79 protected:
80  // Secondary data (scene dependent) - use
81  // TGLSceneBase::ResolveSelectRecord() to fill.
82  Bool_t fTransparent;
83  TGLSceneInfo *fSceneInfo; // SceneInfo
84  TGLPhysicalShape *fPhysShape; // PhysicalShape, if applicable
85  TGLLogicalShape *fLogShape; // LogicalShape, if applicable
86  TObject *fObject; // Master TObject, if applicable
87  void *fSpecific; // Scene specific, if applicable
88  Bool_t fMultiple; // Mutliple selection requested (set by event-handler).
89  Bool_t fHighlight; // Requested for highlight (set by event-handler).
90 
91  ESecSelResult fSecSelRes; // Result of ProcessSelection;
92 
93 public:
94  TGLSelectRecord();
95  TGLSelectRecord(UInt_t* data);
96  TGLSelectRecord(const TGLSelectRecord& rec);
97  virtual ~TGLSelectRecord();
98 
99  TGLSelectRecord& operator=(const TGLSelectRecord& rec);
100 
101  virtual void Set(UInt_t* data);
102  virtual void Reset();
103 
104  Bool_t GetTransparent() const { return fTransparent; }
105  TGLSceneInfo * GetSceneInfo() const { return fSceneInfo; }
106  TGLPhysicalShape * GetPhysShape() const { return fPhysShape; }
107  TGLLogicalShape * GetLogShape() const { return fLogShape; }
108  TObject * GetObject() const { return fObject; }
109  void * GetSpecific() const { return fSpecific; }
110  Bool_t GetMultiple() const { return fMultiple; }
111  Bool_t GetHighlight() const { return fHighlight; }
112 
113  ESecSelResult GetSecSelResult() const { return fSecSelRes; }
114 
115  void SetTransparent(Bool_t t) { fTransparent = t; }
116  void SetSceneInfo (TGLSceneInfo* si) { fSceneInfo = si; }
117  void SetPhysShape (TGLPhysicalShape* pshp) { fPhysShape = pshp; }
118  void SetLogShape (TGLLogicalShape* lshp) { fLogShape = lshp; }
119  void SetObject (TObject* obj) { fObject = obj; }
120  void SetSpecific (void* spec) { fSpecific = spec; }
121  void SetMultiple (Bool_t multi) { fMultiple = multi; }
122  void SetHighlight (Bool_t hlt) { fHighlight = hlt; }
123 
124  void SetSecSelResult(ESecSelResult r) { fSecSelRes = r; }
125 
126  void Print();
127 
128  static Bool_t AreSameSelectionWise(const TGLSelectRecord& r1,
129  const TGLSelectRecord& r2);
130 
131  ClassDef(TGLSelectRecord, 0) // Standard GL selection record.
132 };
133 
134 
135 /**************************************************************************/
136 // TGLOvlSelectRecord
137 /**************************************************************************/
138 
139 class TGLOvlSelectRecord : public TGLSelectRecordBase
140 {
141 protected:
142  // Secondary data (overlay dependent).
143  TGLOverlayElement* fOvlElement;
144 
145 public:
146  TGLOvlSelectRecord();
147  TGLOvlSelectRecord(UInt_t* data);
148  TGLOvlSelectRecord(const TGLOvlSelectRecord& rec);
149  virtual ~TGLOvlSelectRecord();
150 
151  TGLOvlSelectRecord& operator=(const TGLOvlSelectRecord& rec);
152 
153  virtual void Set(UInt_t* data);
154  virtual void Reset();
155 
156  TGLOverlayElement* GetOvlElement() const { return fOvlElement; }
157  void SetOvlElement(TGLOverlayElement* e) { fOvlElement = e; }
158 
159  ClassDef(TGLOvlSelectRecord, 0) // Standard GL overlay-selection record.
160 };
161 
162 #endif