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