ROOT logo
// @(#)root/gl:$Id: TGLSelectRecord.h 30886 2009-10-27 13:37:11Z matevz $
// Author:  Matevz Tadel, Jun 2007

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGLSelectRecord
#define ROOT_TGLSelectRecord

#include <Rtypes.h>

class TObject;
class TGLSceneInfo;
class TGLPhysicalShape;
class TGLOverlayElement;

/**************************************************************************/
// TGLSelectRecordBase
/**************************************************************************/

class TGLSelectRecordBase
{
protected:
   // Primary data - coming from GL.
   Int_t    fN;
   UInt_t  *fItems;
   Float_t  fMinZ;
   Float_t  fMaxZ;

   // Current position (for name resolutin in hierachies of unknown depth).
   Int_t    fPos;

   void CopyItems(UInt_t* items);

public:
   TGLSelectRecordBase();
   TGLSelectRecordBase(UInt_t* data);
   TGLSelectRecordBase(const TGLSelectRecordBase& rec);
   virtual ~TGLSelectRecordBase();

   TGLSelectRecordBase& operator=(const TGLSelectRecordBase& rec);

   void SetRawOnly(UInt_t* data);

   virtual void Set(UInt_t* data);
   virtual void Reset();

   Int_t   GetN()           const { return fN; }
   UInt_t* GetItems()       const { return fItems; }
   UInt_t  GetItem(Int_t i) const { return fItems[i]; }
   Float_t GetMinZ()        const { return fMinZ; }
   Float_t GetMaxZ()        const { return fMaxZ; }

   UInt_t  GetCurrItem() const { return fPos < fN ? fItems[fPos] : 0; }
   Int_t   GetNLeft()    const { return fN - fPos; }
   void    NextPos()           { ++fPos; }
   void    PrevPos()           { --fPos; }
   void    ResetPos()          { fPos = 0; }

   ClassDef(TGLSelectRecordBase, 0) // Base class for GL selection records.
};


/**************************************************************************/
// TGLSelectRecord
/**************************************************************************/

class TGLSelectRecord : public TGLSelectRecordBase
{
public:
   enum ESecSelResult { kNone, kEnteringSelection, kLeavingSelection, kModifyingInternalSelection };

protected:
   // Secondary data (scene dependent) - use
   // TGLSceneBase::ResolveSelectRecord to fill.
   Bool_t            fTransparent;
   TGLSceneInfo     *fSceneInfo; // SceneInfo
   TGLPhysicalShape *fPhysShape; // PhysicalShape, if applicable
   TObject          *fObject;    // Master TObject, if applicable
   void             *fSpecific;  // Scene specific, if applicable
   Bool_t            fMultiple;  // Mutliple selection, requested by event handler

   ESecSelResult     fSecSelRes; // Result of ProcessSelection;

public:
   TGLSelectRecord();
   TGLSelectRecord(UInt_t* data);
   TGLSelectRecord(const TGLSelectRecord& rec);
   virtual ~TGLSelectRecord();

   TGLSelectRecord& operator=(const TGLSelectRecord& rec);

   virtual void Set(UInt_t* data);
   virtual void Reset();

   Bool_t             GetTransparent() const { return fTransparent; }
   TGLSceneInfo     * GetSceneInfo()   const { return fSceneInfo; }
   TGLPhysicalShape * GetPhysShape()   const { return fPhysShape; }
   TObject          * GetObject()      const { return fObject; }
   void             * GetSpecific()    const { return fSpecific; }
   Bool_t             GetMultiple()    const { return fMultiple; }

   ESecSelResult      GetSecSelResult() const { return fSecSelRes; }

   void SetTransparent(Bool_t t)               { fTransparent = t; }
   void SetSceneInfo  (TGLSceneInfo* si)       { fSceneInfo = si; }
   void SetPhysShape  (TGLPhysicalShape* pshp) { fPhysShape = pshp; }
   void SetObject     (TObject* obj)           { fObject = obj; }
   void SetSpecific   (void* spec)             { fSpecific = spec; }
   void SetMultiple   (Bool_t multi)           { fMultiple = multi; }

   void SetSecSelResult(ESecSelResult r)       { fSecSelRes = r; }

   void Print();

   static Bool_t AreSameSelectionWise(const TGLSelectRecord& r1,
                                      const TGLSelectRecord& r2);

   ClassDef(TGLSelectRecord, 0) // Standard GL selection record.
};


/**************************************************************************/
// TGLOvlSelectRecord
/**************************************************************************/

class TGLOvlSelectRecord : public TGLSelectRecordBase
{
protected:
   // Secondary data (overlay dependent).
   TGLOverlayElement* fOvlElement;

public:
   TGLOvlSelectRecord();
   TGLOvlSelectRecord(UInt_t* data);
   TGLOvlSelectRecord(const TGLOvlSelectRecord& rec);
   virtual ~TGLOvlSelectRecord();

   TGLOvlSelectRecord& operator=(const TGLOvlSelectRecord& rec);

   virtual void Set(UInt_t* data);
   virtual void Reset();

   TGLOverlayElement* GetOvlElement() const { return fOvlElement; }
   void SetOvlElement(TGLOverlayElement* e) { fOvlElement = e; }

   ClassDef(TGLOvlSelectRecord, 0) // Standard GL overlay-selection record.
};

#endif
 TGLSelectRecord.h:1
 TGLSelectRecord.h:2
 TGLSelectRecord.h:3
 TGLSelectRecord.h:4
 TGLSelectRecord.h:5
 TGLSelectRecord.h:6
 TGLSelectRecord.h:7
 TGLSelectRecord.h:8
 TGLSelectRecord.h:9
 TGLSelectRecord.h:10
 TGLSelectRecord.h:11
 TGLSelectRecord.h:12
 TGLSelectRecord.h:13
 TGLSelectRecord.h:14
 TGLSelectRecord.h:15
 TGLSelectRecord.h:16
 TGLSelectRecord.h:17
 TGLSelectRecord.h:18
 TGLSelectRecord.h:19
 TGLSelectRecord.h:20
 TGLSelectRecord.h:21
 TGLSelectRecord.h:22
 TGLSelectRecord.h:23
 TGLSelectRecord.h:24
 TGLSelectRecord.h:25
 TGLSelectRecord.h:26
 TGLSelectRecord.h:27
 TGLSelectRecord.h:28
 TGLSelectRecord.h:29
 TGLSelectRecord.h:30
 TGLSelectRecord.h:31
 TGLSelectRecord.h:32
 TGLSelectRecord.h:33
 TGLSelectRecord.h:34
 TGLSelectRecord.h:35
 TGLSelectRecord.h:36
 TGLSelectRecord.h:37
 TGLSelectRecord.h:38
 TGLSelectRecord.h:39
 TGLSelectRecord.h:40
 TGLSelectRecord.h:41
 TGLSelectRecord.h:42
 TGLSelectRecord.h:43
 TGLSelectRecord.h:44
 TGLSelectRecord.h:45
 TGLSelectRecord.h:46
 TGLSelectRecord.h:47
 TGLSelectRecord.h:48
 TGLSelectRecord.h:49
 TGLSelectRecord.h:50
 TGLSelectRecord.h:51
 TGLSelectRecord.h:52
 TGLSelectRecord.h:53
 TGLSelectRecord.h:54
 TGLSelectRecord.h:55
 TGLSelectRecord.h:56
 TGLSelectRecord.h:57
 TGLSelectRecord.h:58
 TGLSelectRecord.h:59
 TGLSelectRecord.h:60
 TGLSelectRecord.h:61
 TGLSelectRecord.h:62
 TGLSelectRecord.h:63
 TGLSelectRecord.h:64
 TGLSelectRecord.h:65
 TGLSelectRecord.h:66
 TGLSelectRecord.h:67
 TGLSelectRecord.h:68
 TGLSelectRecord.h:69
 TGLSelectRecord.h:70
 TGLSelectRecord.h:71
 TGLSelectRecord.h:72
 TGLSelectRecord.h:73
 TGLSelectRecord.h:74
 TGLSelectRecord.h:75
 TGLSelectRecord.h:76
 TGLSelectRecord.h:77
 TGLSelectRecord.h:78
 TGLSelectRecord.h:79
 TGLSelectRecord.h:80
 TGLSelectRecord.h:81
 TGLSelectRecord.h:82
 TGLSelectRecord.h:83
 TGLSelectRecord.h:84
 TGLSelectRecord.h:85
 TGLSelectRecord.h:86
 TGLSelectRecord.h:87
 TGLSelectRecord.h:88
 TGLSelectRecord.h:89
 TGLSelectRecord.h:90
 TGLSelectRecord.h:91
 TGLSelectRecord.h:92
 TGLSelectRecord.h:93
 TGLSelectRecord.h:94
 TGLSelectRecord.h:95
 TGLSelectRecord.h:96
 TGLSelectRecord.h:97
 TGLSelectRecord.h:98
 TGLSelectRecord.h:99
 TGLSelectRecord.h:100
 TGLSelectRecord.h:101
 TGLSelectRecord.h:102
 TGLSelectRecord.h:103
 TGLSelectRecord.h:104
 TGLSelectRecord.h:105
 TGLSelectRecord.h:106
 TGLSelectRecord.h:107
 TGLSelectRecord.h:108
 TGLSelectRecord.h:109
 TGLSelectRecord.h:110
 TGLSelectRecord.h:111
 TGLSelectRecord.h:112
 TGLSelectRecord.h:113
 TGLSelectRecord.h:114
 TGLSelectRecord.h:115
 TGLSelectRecord.h:116
 TGLSelectRecord.h:117
 TGLSelectRecord.h:118
 TGLSelectRecord.h:119
 TGLSelectRecord.h:120
 TGLSelectRecord.h:121
 TGLSelectRecord.h:122
 TGLSelectRecord.h:123
 TGLSelectRecord.h:124
 TGLSelectRecord.h:125
 TGLSelectRecord.h:126
 TGLSelectRecord.h:127
 TGLSelectRecord.h:128
 TGLSelectRecord.h:129
 TGLSelectRecord.h:130
 TGLSelectRecord.h:131
 TGLSelectRecord.h:132
 TGLSelectRecord.h:133
 TGLSelectRecord.h:134
 TGLSelectRecord.h:135
 TGLSelectRecord.h:136
 TGLSelectRecord.h:137
 TGLSelectRecord.h:138
 TGLSelectRecord.h:139
 TGLSelectRecord.h:140
 TGLSelectRecord.h:141
 TGLSelectRecord.h:142
 TGLSelectRecord.h:143
 TGLSelectRecord.h:144
 TGLSelectRecord.h:145
 TGLSelectRecord.h:146
 TGLSelectRecord.h:147
 TGLSelectRecord.h:148
 TGLSelectRecord.h:149
 TGLSelectRecord.h:150
 TGLSelectRecord.h:151
 TGLSelectRecord.h:152
 TGLSelectRecord.h:153
 TGLSelectRecord.h:154
 TGLSelectRecord.h:155