]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Proper management of dependent render-elements, renamed FullUpdate() to UpdateItems...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jul 2006 17:36:04 +0000 (17:36 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jul 2006 17:36:04 +0000 (17:36 +0000)
EVE/Reve/GeoNode.cxx
EVE/Reve/GeoNode.h
EVE/Reve/PointSet.cxx
EVE/Reve/PointSet.h
EVE/Reve/RGeoNodeEditors.cxx
EVE/Reve/Track.cxx
EVE/Reve/Track.h

index cdea130e8787321d32f9be02fa1e501e6c34b848..96b251988f8c6d0ab2019d9529bf35ebad43b803 100644 (file)
@@ -20,7 +20,8 @@ using namespace Reve;
 ClassImp(GeoNodeRnrEl)
 
 GeoNodeRnrEl::GeoNodeRnrEl(TGeoNode* node) :
-  RenderElementListBase(), 
+  RenderElementListBase(),
+  TObject(),
   fNode(node)
 {
   // Hack!! Should use cint to retrieve TAttLine::fLineColor offset.
@@ -41,7 +42,7 @@ Int_t GeoNodeRnrEl::ExpandIntoListTree(TGListTree* ltree,
   // Checks if child-nodes have been imported ... imports them if not.
   // Then calls RenderElementListBase::ExpandIntoListTree.
 
-  if(fList.empty() && fNode->GetVolume()->GetNdaughters() > 0) {
+  if(fChildren.empty() && fNode->GetVolume()->GetNdaughters() > 0) {
     TIter next(fNode->GetVolume()->GetNodes());
     TGeoNode* dnode;
     while((dnode = (TGeoNode*) next()) != 0) {
@@ -54,10 +55,10 @@ Int_t GeoNodeRnrEl::ExpandIntoListTree(TGListTree* ltree,
 
 /**************************************************************************/
 
-void GeoNodeRnrEl::FullUpdate()
+void GeoNodeRnrEl::UpdateItems()
 {
   fRnrElement      = fNode->TGeoAtt::IsVisible(); 
-  RenderElementListBase::FullUpdate();
+  RenderElementListBase::UpdateItems();
 }
 
 /**************************************************************************/
@@ -65,7 +66,7 @@ void GeoNodeRnrEl::FullUpdate()
 void GeoNodeRnrEl::SetRnrElement(Bool_t rnr)
 {
   fNode->SetVisibility(rnr);
-  FullUpdate();
+  UpdateItems();
 }
 
 /**************************************************************************/
@@ -73,7 +74,7 @@ void GeoNodeRnrEl::SetRnrElement(Bool_t rnr)
 void GeoNodeRnrEl::SetMainColor(Color_t color)
 {
   fNode->GetVolume()->SetLineColor(color);
-  FullUpdate();
+  UpdateItems();
 }
 
 void GeoNodeRnrEl::SetMainColor(Pixel_t pixel)
@@ -99,9 +100,9 @@ void GeoNodeRnrEl::UpdateNode(TGeoNode* node)
   // printf("%s node %s %p\n", eH.Data(), node->GetName(), node);
 
   if(fNode == node)
-    FullUpdate();
+    UpdateItems();
 
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((GeoNodeRnrEl*)(*i))->UpdateNode(node);
   }
 
@@ -121,9 +122,9 @@ void GeoNodeRnrEl::UpdateVolume(TGeoVolume* volume)
   // printf("%s volume %s %p\n", eH.Data(), volume->GetName(), volume);
 
   if(fNode->GetVolume() == volume)
-    FullUpdate();
+    UpdateItems();
 
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((GeoNodeRnrEl*)(*i))->UpdateVolume(volume);
   }
 }
@@ -192,9 +193,9 @@ void GeoTopNodeRnrEl::SetVisLevel(Int_t vislvl)
 
 /**************************************************************************/
 
-void GeoTopNodeRnrEl::FullUpdate()
+void GeoTopNodeRnrEl::UpdateItems()
 {
-  RenderElementListBase::FullUpdate();
+  RenderElementListBase::UpdateItems();
 }
 
 /**************************************************************************/
@@ -225,7 +226,7 @@ void GeoTopNodeRnrEl::Paint(Option_t* option)
     gPad = pad;
     TVirtualGeoPainter* vgp = fManager->GetGeomPainter();
     if(vgp != 0) {
-#if ROOT_VERSION_CODE > ROOT_VERSION(5,11,7)
+#if ROOT_VERSION_CODE > ROOT_VERSION(5,11,6)
       vgp->PaintNode(fNode, option, fUseNodeTrans ? fNode->GetMatrix() : fGlobalTrans);
 #else
       vgp->PaintNode(fNode, option);
index a3864b9faa58be812d575ecf1981b455cb1fc031..f0687d2648f0cbbbf972ac4250bd6185add322ca 100644 (file)
@@ -12,7 +12,8 @@ class TGeoManager;
 
 namespace Reve {
 
-class GeoNodeRnrEl : public TObject, public RenderElementListBase
+class GeoNodeRnrEl : public RenderElementListBase,
+                     public TObject
 {
   friend class GeoNodeRnrElEditor;
 
@@ -29,7 +30,7 @@ public:
 
   virtual Int_t ExpandIntoListTree(TGListTree* ltree, TGListTreeItem* parent);
 
-  virtual void FullUpdate();
+  virtual void UpdateItems();
 
   virtual Bool_t CanEditRnrElement() { return false; }
   virtual void SetRnrElement(Bool_t rnr);
@@ -71,7 +72,7 @@ public:
   Int_t GetVisLevel()  const { return fVisLevel; }
   void  SetVisLevel(Int_t vislvl);
 
-  virtual void FullUpdate();
+  virtual void UpdateItems();
 
   virtual Bool_t CanEditRnrElement() { return true; }
   virtual void SetRnrElement(Bool_t rnr);
index 89f5da9af5fdf0ec858b26ac067ffb5988715b3c..e6cb5c33eec9b8fac1924e45bed768f5336e1534 100644 (file)
@@ -20,16 +20,16 @@ using namespace Reve;
 ClassImp(PointSet)
 
 PointSet::PointSet(Int_t n_points, TreeVarType_e tv_type) :
-  TPointSet3D(n_points),
   RenderElement(fMarkerColor),
+  TPointSet3D(n_points),
   TPointSelectorConsumer(tv_type)  
 {
   fMarkerStyle = 20;
 }
 
 PointSet::PointSet(const Text_t* name, Int_t n_points, TreeVarType_e tv_type) :
-  TPointSet3D(n_points),
   RenderElement(fMarkerColor),
+  TPointSet3D(n_points),
   TPointSelectorConsumer(tv_type)
 {
   fMarkerStyle = 20;
@@ -37,8 +37,8 @@ PointSet::PointSet(const Text_t* name, Int_t n_points, TreeVarType_e tv_type) :
 }
 
 PointSet::PointSet(const Text_t* name, TTree* tree, TreeVarType_e tv_type) :
-  TPointSet3D(tree->GetSelectedRows()),
   RenderElement(fMarkerColor),
+  TPointSet3D(tree->GetSelectedRows()),
   TPointSelectorConsumer(tv_type)
 {
   static const Exc_t eH("PointSet::PointSet ");
@@ -132,20 +132,39 @@ ClassImp(PointSetArray)
 
 PointSetArray::PointSetArray(const Text_t* name,
                             const Text_t* title) :
-  TNamed(name, title), RenderElementListBase(fMarkerColor),
+  RenderElementListBase(fMarkerColor),
+  TNamed(name, title),
   fBins(0), fDefPointSetCapacity(128), fNBins(0)
 {}
 
 PointSetArray::~PointSetArray()
 {
-  DeleteBins();
+  printf("PointSetArray::~PointSetArray()\n");
+  delete [] fBins; fBins = 0;
+}
+
+void PointSetArray::RemoveElementLocal(RenderElement* el)
+{
+  for(Int_t i=0; i<fNBins; ++i) {
+    if(fBins[i] == el) {
+      fBins[i] = 0;
+      break;
+    }
+  }
+  RenderElementListBase::RemoveElementLocal(el);
+}
+
+void PointSetArray::RemoveElements()
+{
+  delete [] fBins; fBins = 0;
+  RenderElementListBase::RemoveElements();
 }
 
 /**************************************************************************/
 
 void PointSetArray::SetMarkerColor(Color_t tcolor)
 {
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject());
     if(m && m->GetMarkerColor() == fMarkerColor)
       m->SetMarkerColor(tcolor);
@@ -155,7 +174,7 @@ void PointSetArray::SetMarkerColor(Color_t tcolor)
 
 void PointSetArray::SetMarkerStyle(Style_t mstyle)
 {
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject());
     if(m && m->GetMarkerStyle() == fMarkerStyle)
       m->SetMarkerStyle(mstyle);
@@ -165,7 +184,7 @@ void PointSetArray::SetMarkerStyle(Style_t mstyle)
 
 void PointSetArray::SetMarkerSize(Size_t msize)
 {
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject());
     if(m && m->GetMarkerSize() == fMarkerSize)
       m->SetMarkerSize(msize);
@@ -212,15 +231,16 @@ void PointSetArray::TakeAction(TSelectorDraw* sel)
 
 /**************************************************************************/
 
-void PointSetArray::InitBins(TGListTreeItem* tree_item, const Text_t* quant_name,
-                            Int_t nbins, Double_t min, Double_t max)
+void PointSetArray::InitBins(const Text_t* quant_name,
+                            Int_t nbins, Double_t min, Double_t max,
+                            Bool_t addRe)
 {
   static const Exc_t eH("PointSetArray::InitBins ");
 
   if(nbins < 1) throw(eH + "nbins < 1.");
   if(min > max) throw(eH + "min > max.");
 
-  DeleteBins();
+  RemoveElements();
 
   fQuantName = quant_name;
   fNBins     = nbins;
@@ -236,38 +256,31 @@ void PointSetArray::InitBins(TGListTreeItem* tree_item, const Text_t* quant_name
     fBins[i]->SetMarkerColor(fMarkerColor);
     fBins[i]->SetMarkerStyle(fMarkerStyle);
     fBins[i]->SetMarkerSize(fMarkerSize);
-    AddElement(fBins[i]);
-    if(tree_item)
-      gReve->AddRenderElement(tree_item, fBins[i]);
+    if(addRe)
+      gReve->AddRenderElement(this, fBins[i]);
+    else
+      AddElement(fBins[i]);
   }
 }
 
-void PointSetArray::DeleteBins()
-{
-  if(fBins) {
-    for(Int_t i=0; i<fNBins; ++i)
-      delete fBins[i];
-    delete [] fBins;
-    fBins = 0; fNBins = 0;
-  }
-  RemoveElements();
-}
-
 void PointSetArray::Fill(Double_t x, Double_t y, Double_t z, Double_t quant)
 {
   Int_t bin    = Int_t( (quant - fMin)/fBinWidth );
-  if(bin >= 0 && bin < fNBins)
+  if(bin >= 0 && bin < fNBins && fBins[bin] != 0)
     fBins[bin]->SetNextPoint(x, y, z);
 }
 
 void PointSetArray::CloseBins()
 {
   for(Int_t i=0; i<fNBins; ++i) {
-    // HACK! PolyMarker3D does half-management of array size.
-    // In fact, the error is mine, in pointset3d(gl) i use fN instead of Size().
-    // Fixed in my root, but not elsewhere.
-    fBins[i]->fN = fBins[i]->fLastPoint;
-    fBins[i]->ComputeBBox();
+    if(fBins[i] != 0) {
+      // HACK! PolyMarker3D does half-management of array size.
+      // In fact, the error is mine, in pointset3d(gl) i use fN instead of Size().
+      // Fixed in my root, but not elsewhere.
+      fBins[i]->fN = fBins[i]->fLastPoint;
+
+      fBins[i]->ComputeBBox();
+    }
   }
 }
 
@@ -281,6 +294,7 @@ void PointSetArray::SetRange(Double_t min, Double_t max)
   Int_t  low_b = (Int_t) Max(Double_t(0),       Floor((min-fMin)/fBinWidth));
   Int_t high_b = (Int_t) Min(Double_t(fNBins-1), Ceil((max-fMin)/fBinWidth));
   for(Int_t i=0; i<fNBins; ++i) {
-    fBins[i]->SetRnrElement(i>=low_b && i<=high_b);
+    if(fBins[i] != 0)
+      fBins[i]->SetRnrElement(i>=low_b && i<=high_b);
   }
 }
index fc764dace79957338bd603943c83e03f9afcd6d7..db194fa006097a0709711a73e3abab27a626b05a 100644 (file)
@@ -15,8 +15,8 @@ class TGListTreeItem;
 
 namespace Reve {
 
-class PointSet : public TPointSet3D,
-                 public RenderElement,
+class PointSet : public RenderElement,
+                 public TPointSet3D,
                  public TPointSelectorConsumer
 {
   friend class PointSetArray;
@@ -49,9 +49,10 @@ public:
 
 /**************************************************************************/
 
-class PointSetArray : public TNamed, public TAttMarker,
-                     public RenderElementListBase,
-                     public TPointSelectorConsumer
+class PointSetArray : public RenderElementListBase,
+                      public TNamed,
+                      public TAttMarker,
+                      public TPointSelectorConsumer
 {
   friend class PointSetArrayEditor;
 
@@ -68,6 +69,9 @@ public:
   PointSetArray(const Text_t* name="PointSetArray", const Text_t* title="");
   virtual ~PointSetArray();
 
+  virtual void RemoveElementLocal(RenderElement* el);
+  virtual void RemoveElements();
+
   virtual void Paint(Option_t* option="") { PaintElements(option); }
 
   virtual void SetMarkerColor(Color_t tcolor=1);
@@ -77,9 +81,8 @@ public:
   virtual void TakeAction(TSelectorDraw*);
 
 
-  void InitBins(TGListTreeItem* tree_item, const Text_t* quant_name,
-               Int_t nbins, Double_t min, Double_t max);
-  void DeleteBins();
+  void InitBins(const Text_t* quant_name, Int_t nbins, Double_t min, Double_t max,
+               Bool_t addRe=kTRUE);
   void Fill(Double_t x, Double_t y, Double_t z, Double_t quant);
 
   void CloseBins();
index a55a5e3debfdd571b540614c0b0c7e2aa63dd955..823beb385b6d51ee2307a09e501b17b03c325e38 100644 (file)
@@ -116,7 +116,7 @@ void GeoNodeRnrElEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
 void GeoNodeRnrElEditor::DoVizNode()
 {
   fNodeRE->fNode->SetVisibility(fVizNode->IsOn());
-  fNodeRE->FullUpdate();
+  fNodeRE->UpdateItems();
 }
 
 void GeoNodeRnrElEditor::DoVizNodeDaughters()
index 79e41890624d2d1d2f18beeed202b197e77ecd44..e9e317014f1f5d0df496245c6f66454728c09b39 100644 (file)
@@ -245,15 +245,15 @@ void TrackList::Init()
 }
 
 TrackList::TrackList(Int_t n_tracks) :
-  TPolyMarker3D(n_tracks),
-  RenderElementListBase()
+  RenderElementListBase(),
+  TPolyMarker3D(n_tracks)
 {
   Init();
 }
 
 TrackList::TrackList(const Text_t* name, Int_t n_tracks) :
-  TPolyMarker3D(n_tracks),
-  RenderElementListBase()
+  RenderElementListBase(),
+  TPolyMarker3D(n_tracks)
 {
   Init();
   SetName(name);
@@ -277,7 +277,7 @@ void TrackList::Paint(Option_t* option)
       TPolyMarker3D::Paint(option);
     }
     if(fRnrTracks) {
-      for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+      for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
        if((*i)->GetRnrElement())
          (*i)->GetObject()->Paint(option);
       }
@@ -314,7 +314,7 @@ void TrackList::SetRnrTracks(Bool_t rnr)
 
 void TrackList::MakeTracks()
 {
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((Track*)(*i))->MakeTrack();
   }
   gReve->Redraw3D();
@@ -323,8 +323,8 @@ void TrackList::MakeTracks()
 
 void TrackList::MakeMarkers()
 {
-  Reset(fList.size());
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  Reset(fChildren.size());
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     Track& t = *((Track*)(*i));
     if(t.GetN() > 0)
       SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
@@ -388,7 +388,7 @@ void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
   Float_t maxptsq = max_pt*max_pt;
   Float_t ptsq;
 
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ptsq = ((Track*)(*i))->fP.Perp2();
     (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
   }
@@ -398,14 +398,14 @@ void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
 
 void TrackList::ImportHits()
 {
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((Track*)(*i))->ImportHits();
   }
 }
 
 void TrackList::ImportClusters()
 {
-  for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
+  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((Track*)(*i))->ImportClusters();
   }
 }
index 0d29daa8d2d854d02b7d7cbc32d8eddc8bccd448..e7b60bac6194868515bde4f56d4bd3a3edf6386d 100644 (file)
@@ -14,7 +14,8 @@ namespace Reve {
 class TrackRnrStyle;
 class TrackList;
 
-class Track : public TPolyLine3D, public RenderElement
+class Track : public RenderElement,
+             public TPolyLine3D
 {
   friend class TrackList;
 
@@ -121,7 +122,8 @@ public:
 // TrackList
 /**************************************************************************/
 
-class TrackList : public TPolyMarker3D, public RenderElementListBase
+class TrackList : public RenderElementListBase,
+                 public TPolyMarker3D
 {
 private:
   void  Init();