]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/GeoNode.cxx
Proper management of dependent render-elements, renamed FullUpdate() to UpdateItems...
[u/mrichter/AliRoot.git] / EVE / Reve / GeoNode.cxx
CommitLineData
5a5a1232 1// $Header$
2
3#include "GeoNode.h"
4#include <Reve/RGTopFrame.h>
5
6#include <TPad.h>
7#include <TColor.h>
8
9#include <TGeoVolume.h>
10#include <TGeoNode.h>
11#include <TGeoManager.h>
24e2ff4a 12#include <TVirtualGeoPainter.h>
5a5a1232 13
14using namespace Reve;
15
16//______________________________________________________________________
17// GeoNodeRnrEl
18//
19
20ClassImp(GeoNodeRnrEl)
21
22GeoNodeRnrEl::GeoNodeRnrEl(TGeoNode* node) :
7d42b6c2 23 RenderElementListBase(),
24 TObject(),
5a5a1232 25 fNode(node)
26{
27 // Hack!! Should use cint to retrieve TAttLine::fLineColor offset.
28 char* l = (char*) dynamic_cast<TAttLine*>(node->GetVolume());
29 SetMainColorPtr((Color_t*)(l + sizeof(void*)));
30
31 fRnrElement = fNode->TGeoAtt::IsVisible();
32}
33
34const Text_t* GeoNodeRnrEl::GetName() const { return fNode->GetName(); }
35const Text_t* GeoNodeRnrEl::GetTitle() const { return fNode->GetTitle(); }
36
37/**************************************************************************/
38
39Int_t GeoNodeRnrEl::ExpandIntoListTree(TGListTree* ltree,
40 TGListTreeItem* parent)
41{
42 // Checks if child-nodes have been imported ... imports them if not.
43 // Then calls RenderElementListBase::ExpandIntoListTree.
44
7d42b6c2 45 if(fChildren.empty() && fNode->GetVolume()->GetNdaughters() > 0) {
5a5a1232 46 TIter next(fNode->GetVolume()->GetNodes());
47 TGeoNode* dnode;
48 while((dnode = (TGeoNode*) next()) != 0) {
49 GeoNodeRnrEl* node_re = new GeoNodeRnrEl(dnode);
50 AddElement(node_re);
51 }
52 }
53 return RenderElementListBase::ExpandIntoListTree(ltree, parent);
54}
55
56/**************************************************************************/
57
7d42b6c2 58void GeoNodeRnrEl::UpdateItems()
5a5a1232 59{
60 fRnrElement = fNode->TGeoAtt::IsVisible();
7d42b6c2 61 RenderElementListBase::UpdateItems();
5a5a1232 62}
63
64/**************************************************************************/
65
66void GeoNodeRnrEl::SetRnrElement(Bool_t rnr)
67{
68 fNode->SetVisibility(rnr);
7d42b6c2 69 UpdateItems();
5a5a1232 70}
71
72/**************************************************************************/
73
74void GeoNodeRnrEl::SetMainColor(Color_t color)
75{
76 fNode->GetVolume()->SetLineColor(color);
7d42b6c2 77 UpdateItems();
5a5a1232 78}
79
80void GeoNodeRnrEl::SetMainColor(Pixel_t pixel)
81{
82 // This one needed for proper calling via CINT (signals).
83
84 SetMainColor(Color_t(TColor::GetColor(pixel)));
85}
86
87/**************************************************************************/
88
89void GeoNodeRnrEl::UpdateNode(TGeoNode* node)
90{
91 // Updates all reve-browsers having the node in their contents.
92 // All 3D-pads updated if any change found.
93 //
94 // Should (could?) be optimized with some assumptions about
95 // volume/node structure (search for parent, know the same node can not
96 // reoccur on lower level once found).
97
98 static const Exc_t eH("GeoNodeRnrEl::UpdateNode ");
99
100 // printf("%s node %s %p\n", eH.Data(), node->GetName(), node);
101
102 if(fNode == node)
7d42b6c2 103 UpdateItems();
5a5a1232 104
7d42b6c2 105 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 106 ((GeoNodeRnrEl*)(*i))->UpdateNode(node);
107 }
108
109}
110
111void GeoNodeRnrEl::UpdateVolume(TGeoVolume* volume)
112{
113 // Updates all reve-browsers having the volume in their contents.
114 // All 3D-pads updated if any change found.
115 //
116 // Should (could?) be optimized with some assumptions about
117 // volume/node structure (search for parent, know the same node can not
118 // reoccur on lower level once found).
119
120 static const Exc_t eH("GeoNodeRnrEl::UpdateVolume ");
121
122 // printf("%s volume %s %p\n", eH.Data(), volume->GetName(), volume);
123
124 if(fNode->GetVolume() == volume)
7d42b6c2 125 UpdateItems();
5a5a1232 126
7d42b6c2 127 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 128 ((GeoNodeRnrEl*)(*i))->UpdateVolume(volume);
129 }
130}
131
132/**************************************************************************/
133
134void GeoNodeRnrEl::Draw(Option_t* option)
135{
136 TString opt("SAME");
137 opt += option;
138 fNode->GetVolume()->Draw(opt);
139}
140
141/**************************************************************************/
142//______________________________________________________________________
143// GeoTopNodeRnrEl
144//
24e2ff4a 145// A wrapper over a TGeoNode, possibly displaced with a global
146// trasformation fGlobalTrans (the matrix is owned by this class).
5a5a1232 147/**************************************************************************/
148
149ClassImp(GeoTopNodeRnrEl)
150
151GeoTopNodeRnrEl::GeoTopNodeRnrEl(TGeoManager* manager, TGeoNode* node,
152 Int_t visopt, Int_t vislvl) :
153 GeoNodeRnrEl(node),
154 fManager(manager),
24e2ff4a 155 fGlobalTrans(0),
156 fUseNodeTrans(kFALSE),
5a5a1232 157 fVisOption(visopt), fVisLevel(vislvl)
158{
159 fRnrElement = true;
160}
161
24e2ff4a 162GeoTopNodeRnrEl::~GeoTopNodeRnrEl()
163{
164 delete fGlobalTrans;
165}
166
167/**************************************************************************/
168
169void GeoTopNodeRnrEl::SetGlobalTrans(TGeoHMatrix* m)
170{
171 delete fGlobalTrans;
172 fGlobalTrans = m;
173}
174
175void GeoTopNodeRnrEl::SetUseNodeTrans(Bool_t u)
176{
177 fUseNodeTrans = u;
178}
179
5a5a1232 180/**************************************************************************/
181
182void GeoTopNodeRnrEl::SetVisOption(Int_t visopt)
183{
184 fVisOption = visopt;
185 gReve->Redraw3D();
186}
187
188void GeoTopNodeRnrEl::SetVisLevel(Int_t vislvl)
189{
190 fVisLevel = vislvl;
191 gReve->Redraw3D();
192}
193
194/**************************************************************************/
195
7d42b6c2 196void GeoTopNodeRnrEl::UpdateItems()
5a5a1232 197{
7d42b6c2 198 RenderElementListBase::UpdateItems();
5a5a1232 199}
200
201/**************************************************************************/
202
203void GeoTopNodeRnrEl::SetRnrElement(Bool_t rnr)
204{
205 // Revert from GeoNode to back to standard behaviour.
206 RenderElementListBase::SetRnrElement(rnr);
207}
208
209/**************************************************************************/
210
211void GeoTopNodeRnrEl::Draw(Option_t* option)
212{
213 AppendPad(option);
214}
215
216void GeoTopNodeRnrEl::Paint(Option_t* option)
217{
218 if(fRnrElement) {
219 gGeoManager = fManager;
220 TVirtualPad* pad = gPad;
221 gPad = 0;
222 TGeoVolume* top_volume = fManager->GetTopVolume();
223 fManager->SetVisOption(fVisOption);
224 fManager->SetVisLevel(fVisLevel);
225 fManager->SetTopVolume(fNode->GetVolume());
226 gPad = pad;
24e2ff4a 227 TVirtualGeoPainter* vgp = fManager->GetGeomPainter();
228 if(vgp != 0) {
7d42b6c2 229#if ROOT_VERSION_CODE > ROOT_VERSION(5,11,6)
24e2ff4a 230 vgp->PaintNode(fNode, option, fUseNodeTrans ? fNode->GetMatrix() : fGlobalTrans);
231#else
232 vgp->PaintNode(fNode, option);
233#endif
234 }
5a5a1232 235 fManager->SetTopVolume(top_volume);
236 }
237}
238
239/**************************************************************************/
240
241void GeoTopNodeRnrEl::VolumeVisChanged(TGeoVolume* volume)
242{
243 static const Exc_t eH("GeoTopNodeRnrEl::VolumeVisChanged ");
244 printf("%s volume %s %p\n", eH.Data(), volume->GetName(), (void*)volume);
245 UpdateVolume(volume);
246}
247
248void GeoTopNodeRnrEl::VolumeColChanged(TGeoVolume* volume)
249{
250 static const Exc_t eH("GeoTopNodeRnrEl::VolumeColChanged ");
251 printf("%s volume %s %p\n", eH.Data(), volume->GetName(), (void*)volume);
252 UpdateVolume(volume);
253}
254
255void GeoTopNodeRnrEl::NodeVisChanged(TGeoNode* node)
256{
257 static const Exc_t eH("GeoTopNodeRnrEl::NodeVisChanged ");
258 printf("%s node %s %p\n", eH.Data(), node->GetName(), (void*)node);
259 UpdateNode(node);
260}