]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added per-quad TRef, implemented virtual callback QuadSelected() for secondary select...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 13 Dec 2006 12:10:12 +0000 (12:10 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 13 Dec 2006 12:10:12 +0000 (12:10 +0000)
EVE/Reve/QuadSet.cxx
EVE/Reve/QuadSet.h

index 9b9776e7c468035b850d04b53cc90819f433634c..dd64a7d7ebfb4bf034b35af957712c27ddef7d25 100644 (file)
@@ -181,8 +181,9 @@ QuadSet::QuadSet(const Text_t* n, const Text_t* t) :
   TNamed(n, t),
 
   fQuadType(QT_Undef),
-  fValueIsColor(kFALSE),
   fDefaultValue(kMinInt),
+  fValueIsColor(kFALSE),
+  fOwnIds      (kFALSE),
   fPlex(),
   fLastQuad(0),
 
@@ -201,8 +202,9 @@ QuadSet::QuadSet(QuadType_e quadType, Bool_t valIsCol, Int_t chunkSize,
   TNamed(n, t),
 
   fQuadType(quadType),
-  fValueIsColor(valIsCol),
   fDefaultValue(valIsCol ? 0 : kMinInt),
+  fValueIsColor(valIsCol),
+  fOwnIds      (kFALSE),
   fPlex(SizeofAtom(quadType), chunkSize),
   fLastQuad(0),
 
@@ -219,6 +221,20 @@ QuadSet::~QuadSet()
 {
   SetFrame(0);
   SetPalette(0);
+  if (fOwnIds)
+    ReleaseIds();
+}
+
+void QuadSet::ReleaseIds()
+{
+  VoidCPlex::iterator qi(fPlex);
+  while (qi.next()) {
+    QuadBase& q = * (QuadBase*) qi();
+    if (q.fId.GetObject()) {
+      delete q.fId.GetObject();
+      q.fId = 0;
+    }
+  }
 }
 
 /**************************************************************************/
@@ -252,6 +268,7 @@ void QuadSet::Reset(QuadSet::QuadType_e quadType, Bool_t valIsCol, Int_t chunkSi
   fQuadType     = quadType;
   fValueIsColor = valIsCol;
   fDefaultValue = valIsCol ? 0 : kMinInt;
+  ReleaseIds();
   fPlex.Reset(SizeofAtom(fQuadType), chunkSize);
 }
 
@@ -446,6 +463,25 @@ void QuadSet::QuadColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a)
   x[0] = r; x[1] = g; x[2] = b; x[3] = a;
 }
 
+/**************************************************************************/
+
+void QuadSet::QuadId(TObject* id)
+{
+  fLastQuad->fId = id;
+}
+
+/**************************************************************************/
+
+void QuadSet::QuadSelected(Int_t idx)
+{
+  QuadBase* qb = GetQuad(idx);
+  TObject* obj = qb->fId.GetObject();
+  printf("QuadSet::QuadSelected idx=%d, value=%d, obj=0x%lx\n",
+        idx, qb->fValue, (ULong_t)obj);
+  if (obj)
+    obj->Print();
+}
+
 /**************************************************************************/
 /**************************************************************************/
 
index 7ea8d1bed6eaf40f505bc8ee1e003daf2bf44ef8..88c7398930b35c0efa8c32a5af3581f23fc9d2a9 100644 (file)
@@ -117,6 +117,8 @@ protected:
   struct QuadBase
   {
     Int_t fValue;
+    TRef  fId;
+
     // Here could have additional integer (like time, second threshold).
 
     QuadBase(Int_t v=0) : fValue(v) {}
@@ -140,8 +142,9 @@ protected:
 
 protected:
   QuadType_e        fQuadType;
-  Bool_t            fValueIsColor;
   Int_t             fDefaultValue;
+  Bool_t            fValueIsColor;
+  Bool_t            fOwnIds;       //Flag specifying if id-objects are owned by the QuadSet
   VoidCPlex         fPlex;
   QuadBase*         fLastQuad;     //!
 
@@ -158,6 +161,8 @@ protected:
   static Int_t SizeofAtom(QuadType_e qt);
   QuadBase*    NewQuad();
 
+  void ReleaseIds();
+
 public:
   QuadSet(const Text_t* n="QuadSet", const Text_t* t="");
   QuadSet(QuadType_e quadType, Bool_t valIsCol, Int_t chunkSize,
@@ -212,6 +217,15 @@ public:
   void QuadColor(Color_t ci);
   void QuadColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
 
+  void QuadId(TObject* id);
+  Bool_t GetOwnIds() const    { return fOwnIds; }
+  void   SetOwnIds(Bool_t o)  { fOwnIds = o; }
+
+  QuadBase* GetQuad(Int_t n) { return (QuadBase*) fPlex.Atom(n);   }
+  TObject*  GetId(Int_t n)   { return GetQuad(n)->fId.GetObject(); }
+
+  virtual void QuadSelected(Int_t idx);
+
   // --------------------------------
 
   // void Test(Int_t nquads);