]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/GeoNode.cxx
Missing initialization; fiddle with the track marker-style a bit more.
[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) :
5b457dfa 23 RenderElement(),
7d42b6c2 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
5b457dfa 31 fRnrSelf = fNode->TGeoAtt::IsVisible();
5a5a1232 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.
5b457dfa 43 // Then calls RenderElement::ExpandIntoListTree.
5a5a1232 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 }
5b457dfa 53 return RenderElement::ExpandIntoListTree(ltree, parent);
5a5a1232 54}
55
56/**************************************************************************/
57
7d42b6c2 58void GeoNodeRnrEl::UpdateItems()
5a5a1232 59{
5b457dfa 60 fRnrSelf = fNode->TGeoAtt::IsVisible();
61 RenderElement::UpdateItems();
5a5a1232 62}
63
64/**************************************************************************/
65
5b457dfa 66void GeoNodeRnrEl::SetRnrSelf(Bool_t rnr)
5a5a1232 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
e6ac3950 105 for(List_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
e6ac3950 127 for(List_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{
5b457dfa 159 fRnrSelf = true;
5a5a1232 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{
5b457dfa 198 RenderElement::UpdateItems();
5a5a1232 199}
200
201/**************************************************************************/
5b457dfa 202void GeoTopNodeRnrEl::SetRnrSelf(Bool_t rnr)
5a5a1232 203{
204 // Revert from GeoNode to back to standard behaviour.
5b457dfa 205 RenderElement::SetRnrSelf(rnr);
5a5a1232 206}
5a5a1232 207/**************************************************************************/
208
209void GeoTopNodeRnrEl::Draw(Option_t* option)
210{
211 AppendPad(option);
212}
213
214void GeoTopNodeRnrEl::Paint(Option_t* option)
215{
5b457dfa 216 if(fRnrSelf) {
5a5a1232 217 gGeoManager = fManager;
218 TVirtualPad* pad = gPad;
219 gPad = 0;
220 TGeoVolume* top_volume = fManager->GetTopVolume();
221 fManager->SetVisOption(fVisOption);
222 fManager->SetVisLevel(fVisLevel);
223 fManager->SetTopVolume(fNode->GetVolume());
224 gPad = pad;
24e2ff4a 225 TVirtualGeoPainter* vgp = fManager->GetGeomPainter();
226 if(vgp != 0) {
7d42b6c2 227#if ROOT_VERSION_CODE > ROOT_VERSION(5,11,6)
24e2ff4a 228 vgp->PaintNode(fNode, option, fUseNodeTrans ? fNode->GetMatrix() : fGlobalTrans);
229#else
230 vgp->PaintNode(fNode, option);
231#endif
232 }
5a5a1232 233 fManager->SetTopVolume(top_volume);
234 }
235}
236
237/**************************************************************************/
238
239void GeoTopNodeRnrEl::VolumeVisChanged(TGeoVolume* volume)
240{
241 static const Exc_t eH("GeoTopNodeRnrEl::VolumeVisChanged ");
242 printf("%s volume %s %p\n", eH.Data(), volume->GetName(), (void*)volume);
243 UpdateVolume(volume);
244}
245
246void GeoTopNodeRnrEl::VolumeColChanged(TGeoVolume* volume)
247{
248 static const Exc_t eH("GeoTopNodeRnrEl::VolumeColChanged ");
249 printf("%s volume %s %p\n", eH.Data(), volume->GetName(), (void*)volume);
250 UpdateVolume(volume);
251}
252
253void GeoTopNodeRnrEl::NodeVisChanged(TGeoNode* node)
254{
255 static const Exc_t eH("GeoTopNodeRnrEl::NodeVisChanged ");
256 printf("%s node %s %p\n", eH.Data(), node->GetName(), (void*)node);
257 UpdateNode(node);
258}