From 7d42b6c2f72e5a18db2b9de9bd6d41a668769b30 Mon Sep 17 00:00:00 2001 From: mtadel Date: Mon, 10 Jul 2006 17:36:04 +0000 Subject: [PATCH] Proper management of dependent render-elements, renamed FullUpdate() to UpdateItems() and changed inheritance order (derive RenderElement first). --- EVE/Reve/GeoNode.cxx | 27 +++++++------ EVE/Reve/GeoNode.h | 7 ++-- EVE/Reve/PointSet.cxx | 78 +++++++++++++++++++++--------------- EVE/Reve/PointSet.h | 19 +++++---- EVE/Reve/RGeoNodeEditors.cxx | 2 +- EVE/Reve/Track.cxx | 22 +++++----- EVE/Reve/Track.h | 6 ++- 7 files changed, 91 insertions(+), 70 deletions(-) diff --git a/EVE/Reve/GeoNode.cxx b/EVE/Reve/GeoNode.cxx index cdea130e878..96b251988f8 100644 --- a/EVE/Reve/GeoNode.cxx +++ b/EVE/Reve/GeoNode.cxx @@ -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); diff --git a/EVE/Reve/GeoNode.h b/EVE/Reve/GeoNode.h index a3864b9faa5..f0687d2648f 100644 --- a/EVE/Reve/GeoNode.h +++ b/EVE/Reve/GeoNode.h @@ -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); diff --git a/EVE/Reve/PointSet.cxx b/EVE/Reve/PointSet.cxx index 89f5da9af5f..e6cb5c33eec 100644 --- a/EVE/Reve/PointSet.cxx +++ b/EVE/Reve/PointSet.cxx @@ -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((*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((*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((*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= 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; ifN = 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; iSetRnrElement(i>=low_b && i<=high_b); + if(fBins[i] != 0) + fBins[i]->SetRnrElement(i>=low_b && i<=high_b); } } diff --git a/EVE/Reve/PointSet.h b/EVE/Reve/PointSet.h index fc764dace79..db194fa0060 100644 --- a/EVE/Reve/PointSet.h +++ b/EVE/Reve/PointSet.h @@ -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(); diff --git a/EVE/Reve/RGeoNodeEditors.cxx b/EVE/Reve/RGeoNodeEditors.cxx index a55a5e3debf..823beb385b6 100644 --- a/EVE/Reve/RGeoNodeEditors.cxx +++ b/EVE/Reve/RGeoNodeEditors.cxx @@ -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() diff --git a/EVE/Reve/Track.cxx b/EVE/Reve/Track.cxx index 79e41890624..e9e317014f1 100644 --- a/EVE/Reve/Track.cxx +++ b/EVE/Reve/Track.cxx @@ -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(); } } diff --git a/EVE/Reve/Track.h b/EVE/Reve/Track.h index 0d29daa8d2d..e7b60bac619 100644 --- a/EVE/Reve/Track.h +++ b/EVE/Reve/Track.h @@ -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(); -- 2.43.0