Merge from EVE-dev to HEAD.
[u/mrichter/AliRoot.git] / EVE / Reve / RGBrowser.cxx
1 #include "RGBrowser.h"
2 #include "RGTopFrame.h"
3 #include "Reve.h"
4 #include "RGEditor.h"
5 #include "VSDSelector.h"
6 #include <Reve/PointSet.h>
7 #include <Reve/Track.h>
8
9 #include <Riostream.h>
10
11 #include <TROOT.h>
12 #include <TStyle.h>
13 #include <TSystem.h>
14 #include <TRint.h>
15 #include <TVirtualX.h>
16 #include <TEnv.h>
17
18 #include <TApplication.h>
19 #include <TFile.h>
20 #include <TEventList.h>
21 #include <TClassMenuItem.h>
22
23 #include <TColor.h>
24 #include <TPolyMarker3D.h>
25
26 #include <TGCanvas.h>
27 #include <TGSplitter.h>
28 #include <TGStatusBar.h>
29 #include <TGMenu.h>
30 #include <TGToolBar.h>
31 #include <TGLabel.h>
32 #include <TGXYLayout.h>
33 #include <TGNumberEntry.h>
34 #include <KeySymbols.h>
35
36 #include <TGLSAViewer.h>
37 #include <TGLSAFrame.h>
38 #include <TGTab.h>
39
40 #include <TGeoVolume.h>
41 #include <TGeoNode.h>
42
43 using namespace Reve;
44 using namespace Reve;
45
46 /**************************************************************************/
47
48 void RGBrowser::SetupCintExport(TClass* cl)
49 {
50  
51   TList* l = cl->GetMenuList();
52   TClassMenuItem* n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction, cl,
53                                          "Export to CINT", "ExportToCINT", this, "const char*,TObject*", 1);
54
55   l->AddFirst(n);
56 }
57
58 void RGBrowser::CalculateReparentXY(TGObject* parent, Int_t& x, Int_t& y)
59 {
60   UInt_t   w, h;
61   Window_t childdum;
62   gVirtualX->GetWindowSize(parent->GetId(), x, y, w, h);
63   gVirtualX->TranslateCoordinates(parent->GetId(),
64                                   gClient->GetDefaultRoot()->GetId(),
65                                   0, 0, x, y, childdum);
66 }
67
68 /**************************************************************************/
69
70 RGBrowser::RGBrowser(const TGWindow *p, UInt_t w, UInt_t h)
71   : TGCompositeFrame(p, w, h)
72 {
73   fMainFrame = new TGCompositeFrame(this, 100, 10, kHorizontalFrame | kRaisedFrame);
74   fMainFrame->SetCleanup(kDeepCleanup);
75   fV1 = new TGVerticalFrame(fMainFrame, 250, 10, kSunkenFrame | kFixedWidth);
76   fV2 = new TGVerticalFrame(fMainFrame,  50, 10, kSunkenFrame);
77
78   TGLayoutHints *lo;
79   lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY,2,0,2,2);
80   fMainFrame->AddFrame(fV1, lo);
81
82   TGVSplitter *splitter = new TGVSplitter(fMainFrame);
83   splitter->SetFrame(fV1, kTRUE);
84   fMainFrame->AddFrame(splitter,
85                        new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 1,1,2,2));
86    
87   lo = new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY,0,2,2,4);
88   fMainFrame->AddFrame(fV2, lo);
89
90   // selection frame
91   fSelectionFrame = new TGCompositeFrame(fV1, 250, 10, kVerticalFrame);
92   fTreeView = new TGCanvas(fSelectionFrame, 250, 10, kSunkenFrame | kDoubleBorder);
93   fListTree = new TGListTree(fTreeView->GetViewPort(), 250, 10, kHorizontalFrame);
94   fListTree->SetCanvas(fTreeView);
95   fListTree->Associate(this);
96   fListTree->SetColorMode(TGListTree::EColorMarkupMode(TGListTree::kColorUnderline | TGListTree::kColorBox));
97   fTreeView->SetContainer(fListTree);
98
99   lo= new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY,
100                         2, 2, 2, 2);
101   fSelectionFrame->AddFrame(fTreeView, lo);
102
103   lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY);
104   fV1->AddFrame(fSelectionFrame, lo);
105  
106   // Classic look vars:
107   fCanvasWindow = 0;
108   fDisplayFrame = 0;
109  
110   //display frame
111
112   lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
113   AddFrame(fMainFrame, lo);
114
115
116   SetWindowName("Reve List Browser");
117   MapSubwindows();
118   //Resize(GetDefaultSize()); // this is used here to init layout algoritme
119
120   //MapWindow();
121
122   // popup menu
123   
124   fCtxMenu = new TContextMenu("Pepe", "Moroder");
125
126   //-- CINT export now declared in RenderElement with *MENU*
127   // SetupCintExport(PointSet::Class());
128   // SetupCintExport(Track::Class());
129   // SetupCintExport(TrackList::Class());
130   
131   fListTree->Connect("Clicked(TGListTreeItem*, Int_t, Int_t, Int_t)", "Reve::RGBrowser", 
132                      this, "ItemClicked(TGListTreeItem*, Int_t, Int_t, Int_t)");  
133   fListTree->Connect("DoubleClicked(TGListTreeItem*, Int_t)", "Reve::RGBrowser", 
134                      this, "DbClickListItem(TGListTreeItem*,Int_t )"); 
135   //fListTree->Connect("Clicked(TGListTreeItem*, Int_t)", "Reve::RGBrowser", 
136   //                 this, "DisplayChildren(TGListTreeItem*, Int_t)");  
137
138   //---------------------------------------------
139   // WARNING ... this Connect goes to *gReve*!
140   fListTree->Connect("Checked(TObject*,Bool_t)", "Reve::RGTopFrame",
141                      gReve, "RenderElementChecked(TObject*, Bool_t)");
142 }
143
144 /**************************************************************************/
145
146 void RGBrowser::SetupClassicLook()
147 {
148   fCanvasWindow = new TGCanvas(fV2, 25, 250);
149   fDisplayFrame = new TGCompositeFrame(fCanvasWindow->GetViewPort(), 0, 0,kVerticalFrame, TGFrame::GetWhitePixel() );
150   fCanvasWindow->SetContainer(fDisplayFrame);
151   fDisplayFrame->SetCleanup(kDeepCleanup);
152
153   fV2->AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
154   fV2->MapSubwindows();
155 }
156
157
158
159 void RGBrowser::SetupEditorLook(RGEditor* editor)
160 {
161   editor->UnmapWindow();
162   fV2->AddFrame(editor, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
163   Int_t x, y;
164   CalculateReparentXY(fV2, x, y);
165   editor->ReparentWindow(fV2, x, y);
166
167   fV2->MapSubwindows();
168 }
169
170 void RGBrowser::SetupGLViewerLook(RGEditor* editor, TVirtualPad* glpad)
171 {
172   TGLayoutHints *lo;
173
174   TGLSAViewer* v = new TGLSAViewer(fV2, glpad);
175   v->GetFrame()->SetMinWidth(200);
176   lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY);
177   fV2->AddFrame(v->GetFrame(), lo);
178   glpad->SetViewer3D(v);
179
180   fSelectionFrame->Resize(fSelectionFrame->GetWidth(), fSelectionFrame->GetHeight()/2);
181
182   TGHSplitter *splitter = new TGHSplitter(fV1);
183   lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 2, 2, 0);
184   fSelectionFrame->AddFrame(splitter, lo);
185    
186   editor->UnmapWindow();
187   editor->ChangeOptions(editor->GetOptions() | kFixedHeight);
188   lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,2,2,2);
189   fV1->AddFrame(editor, lo);
190   Int_t x, y;
191   CalculateReparentXY(fV1, x, y);
192   editor->ReparentWindow(fV1, x, y);
193
194   splitter->SetFrame(editor, kFALSE);
195
196   fV1->MapSubwindows();
197   v->GetFrame()->MapWindow();
198 }
199
200
201 /**************************************************************************/
202 /**************************************************************************/
203
204 void RGBrowser::RedrawListTree()
205 {
206   gClient->NeedRedraw(fListTree);
207 }
208
209 /**************************************************************************/
210
211 void RGBrowser::ItemClicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y)
212 {
213   //printf("ItemClicked item %s List %d btn=%d, x=%d, y=%d\n",
214   //  item->GetText(),fDisplayFrame->GetList()->GetEntries(), btn, x, y);
215
216   RenderElement* re = (RenderElement*)item->GetUserData();
217   if(re == 0) return;
218   TObject* obj = re->GetObject();
219
220   // A pathetic hack to get at least a bit of color coordination
221   // for RenderElementObjPtr.
222   if(item->GetColor() != re->GetMainColor()) {
223     item->SetColor(re->GetMainColor());
224     fListTree->GetClient()->NeedRedraw(fListTree);
225   }
226
227   if(btn == 3) {
228     if (obj) {
229       fCtxMenu->Popup(x, y, obj);
230     }
231     return;
232   }
233
234   gReve->EditRenderElement(re);
235
236   // This only available in classic look.
237   // Still working but slowly drifting towards obscurity (4.2006).
238   DisplayChildren(item, btn);
239 }
240
241 void RGBrowser::DbClickListItem(TGListTreeItem* item, Int_t btn)
242 {
243   static const Exc_t eH("RGBrowser::DbClickListItem ");
244
245   printf("dbclick item %s\n", item->GetText());
246   RenderElement* re = (RenderElement*)item->GetUserData();
247   if(re == 0) return;
248   TObject* obj = re->GetObject();
249
250   if (obj) {
251     //  ListTreeHighlight(item);
252
253     {
254       RenderElementListBase* rel = dynamic_cast<RenderElementListBase*>(re);
255       if(rel != 0) {
256         Int_t ni = rel->ExpandIntoListTree(fListTree, item);
257         printf("%s expanded by %d\n", eH.Data(), ni);
258       }
259     }
260     
261     // browse geonodes
262     if(obj->IsA()->InheritsFrom("TGeoNode")){
263       TGeoNode* n = (TGeoNode*) obj->IsA()->DynamicCast( TGeoNode::Class(), obj );
264       // initialization
265       if(item->GetFirstChild() == 0 && n->GetNdaughters()){
266         UpdateListItems(item, btn);
267       }
268     }
269   }
270   DisplayChildren(item,0);
271 }
272
273 /**************************************************************************/
274
275 void RGBrowser::ExportToCINT(Text_t* var_name, TObject* obj)
276 {
277   const char* cname = obj->IsA()->GetName();
278   gROOT->ProcessLine(Form("%s* %s = (%s*) %p;", cname, var_name, cname, obj));
279 }
280
281 void RGBrowser::DisplayChildren(TGListTreeItem *item, Int_t btn)
282 {
283   // Only classic mode provides direct children editing.
284   if(fDisplayFrame == 0)
285     return;
286
287   fDisplayFrame->DestroySubwindows();
288   fDisplayFrame->Cleanup();
289   printf("DisplayChildren item %s List %d btn=%d\n", item->GetText(),fDisplayFrame->GetList()->GetEntries(), btn);
290
291   if(item->GetFirstChild() == 0) return;
292
293   UInt_t wH = 2;
294   UInt_t wW = 7;
295
296   UInt_t fw, fh;
297   Int_t nc = 0;  
298   TGListTreeItem *child = item->GetFirstChild();
299   do {
300     child = child->GetNextSibling();
301     nc ++;
302   } while(child);
303   fw = 70;
304   fh = UInt_t(nc*2);
305   fDisplayFrame->Resize(fw, fh);
306   TGXYLayout* xyl = new TGXYLayout(fDisplayFrame);
307   fDisplayFrame->SetLayoutManager(xyl);
308   xyl->Layout();
309
310   TGXYLayoutHints* lh;
311   Float_t x,y;
312   y  = 0.;
313   nc = 0;
314   child = item->GetFirstChild();
315   do {
316     // generic info 
317     wW = 24;
318     x = 0.;
319     TGTextButton* b1 = new TGTextButton( fDisplayFrame, Form("%s",child->GetText()));
320     b1->Resize(wW,wH);
321     b1->SetTextJustify(kTextLeft | kTextCenterY);
322     lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
323     fDisplayFrame->AddFrame(b1,lh);
324     x += wW;
325     wW = 8;
326     TGCheckButton* b2 = new TGCheckButton(fDisplayFrame, "Draw");
327     b2->Resize(wW,wH);
328     b2->SetTextJustify(kTextLeft | kTextCenterY);
329     lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
330     fDisplayFrame->AddFrame(b2, lh);
331     x += wW;
332
333     RenderElement* re = (RenderElement*)child->GetUserData();
334     TObject* obj = re->GetObject();
335     if(obj != 0) {
336       TGXYLayoutHints* lh;
337
338       Track*          track = dynamic_cast<Track*>(obj); // (Track*) obj->IsA()->DynamicCast(Track::Class(), obj );
339       PointSet* hcont = dynamic_cast<PointSet*>(obj);
340       TrackList* tcont = dynamic_cast<TrackList*>(obj);
341       TGeoNode*          gnode = dynamic_cast<TGeoNode*>(obj);
342       
343       // Track
344       //---------
345
346       if(track) {       
347         // printf("display children track \n");
348         b2->SetOn(track->GetRnrElement());
349         b2->Connect("Toggled(Bool_t)", "Reve::Track", track, "SetRnrElement(Bool_t)"); 
350       }
351
352       // PointSet
353       //------------------
354
355       if (hcont) { 
356         // connect to toggle signal
357         wW = 8;
358         //printf("add label to %s %d\n", cont->GetName(), cont->GetNPoints());
359         TGLabel* b3 = new TGLabel(fDisplayFrame, Form("%d", hcont->GetN()));
360         b3->SetTextJustify(kTextLeft | kTextCenterY);
361         b3->Resize(wW,wH);
362         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
363         fDisplayFrame->AddFrame(b3, lh);
364         x += wW;
365
366         wW = 5; 
367         TGColorSelect* b4 = new TGColorSelect(fDisplayFrame, TColor::Number2Pixel(hcont->GetMainColor()));
368         b4->Resize();
369         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
370         fDisplayFrame->AddFrame(b4,lh);
371         b4->Connect("ColorSelected(Pixel_t)",
372                     "Reve::PointSet", hcont, "SetMainColor(Pixel_t)");  
373         
374         x += wW;        
375         wW = 8;
376         ReveValuator* ne = new ReveValuator(fDisplayFrame, hcont->GetMarkerStyle());
377         ne->Resize(wW,wH);
378         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
379         ne->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMarkerStyle(Long_t)");
380         ne->SetUserData(hcont);
381         fDisplayFrame->AddFrame(ne,lh);
382
383         //connect to container
384         b2->SetUserData(hcont);
385         b2->SetOn(hcont->GetRnrElement());
386         b2->Connect("Toggled(Bool_t)", "Reve::PointSet", hcont, "SetRnrElement(Bool_t)");  
387       }
388
389       // TrackList
390       //------------------
391
392       if (tcont) {
393         wW = 8;
394         //printf("add label to %s %d\n", cont->GetName(), cont->GetNPoints());
395         TGLabel* b3 = new TGLabel(fDisplayFrame, Form("%d", tcont->GetNTracks()));
396         b3->SetTextJustify(kTextLeft | kTextCenterY);
397         b3->Resize(wW,wH);
398         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
399         fDisplayFrame->AddFrame(b3, lh);
400         x += wW;
401         // track color
402         wW = 5; 
403         TGColorSelect* b4 = new TGColorSelect(fDisplayFrame, TColor::Number2Pixel(tcont->GetMainColor()));
404         b4->Resize();
405         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
406         fDisplayFrame->AddFrame(b4,lh);
407         b4->Connect("ColorSelected(Pixel_t)",
408                     "Reve::TrackList", tcont, "SetMainColor(Pixel_t)");  
409         x += wW;
410         wW = 8;
411         ReveValuator* ne1 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxR);
412         ne1->SetUserData(tcont);
413         ne1->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxR(Long_t)");
414         // ne1->SetToolTipText("Maximum radius [cm]");
415         ne1->Resize(wW,wH);
416         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
417         fDisplayFrame->AddFrame(ne1,lh);
418  
419         x += wW;        
420         wW = 8;
421         ReveValuator* ne2 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxZ);
422         ne2->SetUserData(tcont);
423         ne2->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxZ(Long_t)");
424         // ne2->SetToolTipText("Maximum z [cm]");
425         ne2->Resize(wW,wH);
426         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
427         fDisplayFrame->AddFrame(ne2,lh);
428
429         x += wW;        
430         wW = 8;
431         ReveValuator* ne3 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxOrbs);
432         ne3->SetUserData(tcont);
433         ne3->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxOrbs(Long_t)");
434         // ne3->SetToolTipText("Maximum number of orbits");
435         ne3->Resize(wW,wH);
436         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
437         fDisplayFrame->AddFrame(ne3,lh);
438
439         x += wW;        
440         wW = 8;
441         TGCheckButton*  dau  = new TGCheckButton(fDisplayFrame, "Daughters");
442         dau->SetOn(tcont->GetRnrStyle()->fFitDaughters);
443         dau->SetUserData(tcont);
444         dau->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetFitDaughters(Bool_t)");
445         dau->Resize(wW,wH);
446         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
447         fDisplayFrame->AddFrame(dau,lh);
448
449         x += wW;        
450         wW = 8;
451         TGCheckButton* dec = new TGCheckButton(fDisplayFrame, "Decay");
452         dec->SetOn(tcont->GetRnrStyle()->fFitDaughters);
453         dec->SetUserData(tcont);
454         dec->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetFitDecay(Bool_t)");
455         dec->Resize(wW,wH);
456         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
457         fDisplayFrame->AddFrame(dec,lh);
458
459         //connect to container
460         b2->SetUserData(tcont);
461         //b2->SetOn(tcont->GetRnrTracks());
462         //b2->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetRnrTracks(Bool_t)");  
463         b2->SetOn(tcont->GetRnrElement());
464         b2->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetRnrElement(Bool_t)");  
465       }
466
467       // TGeoNode
468       //---------
469
470       if(gnode) {
471         TGeoVolume* vol = gnode->GetVolume();
472         b2->SetOn(gnode->IsVisible());
473         b2->Connect("Toggled(Bool_t)", "Reve::RGBrowser", this,"NodeVis(Bool_t)");  
474         b2->SetUserData(gnode);
475
476         wW = 11;
477         TGCheckButton* b3 = new TGCheckButton(fDisplayFrame, "VisibleDaughters");
478         b3->SetTextJustify(kTextLeft | kTextCenterY);
479         b3->Resize(wW,wH);
480         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
481         fDisplayFrame->AddFrame(b3,lh);
482         b3->SetOn(vol->IsVisibleDaughters());
483         b3->Connect("Toggled(Bool_t)", "Reve::RGBrowser", this, "VolumeDaughterVis(Bool_t)");  
484         b3->SetUserData(vol);
485         x += wW;
486
487         wW = 5; 
488         ReveColorSelect* b4 = new ReveColorSelect(fDisplayFrame, TColor::Number2Pixel(vol->GetLineColor()));
489         b4->Resize();
490         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
491         fDisplayFrame->AddFrame(b4,lh);
492         b4->Connect("ColorSelected(Pixel_t)", "Reve::RGBrowser", this, "SetVolumeColor(UInt_t)");  
493         b4->SetUserData(vol);
494         x += wW;
495
496         wW = 11;
497         ReveValuator* ne = new ReveValuator(fDisplayFrame, vol->GetTransparency());
498         ne->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetTransparency(Long_t)");
499         ne->SetUserData(vol);
500
501         ne->Resize(wW,wH);
502         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
503         fDisplayFrame->AddFrame(ne,lh);
504         x += wW;
505       }
506
507     }
508     y += wH; 
509     nc++;
510     child = child->GetNextSibling();
511   } while(child);
512   fDisplayFrame->MapSubwindows();
513   fDisplayFrame->MapWindow();
514   MapSubwindows();
515 }
516
517 /**************************************************************************/
518 // Slots
519 /**************************************************************************/
520
521 void RGBrowser::SetTransparency(Long_t )
522 {
523   ReveValuator& rv = *(ReveValuator*)gTQSender;
524   // printf("VSet idx=%d, double value=%lf, part=%p\n", val, rv.GetNumber(), rv.GetUserData());
525   TGeoVolume* vol = (TGeoVolume*) rv.GetUserData();
526   if(vol) {
527     //    printf("set volume user data %d \n",val);
528     vol->SetTransparency(char(rv.GetNumber()));
529   }
530
531   TGFrameElement* fel;
532   TList* list = fDisplayFrame->GetList();
533   TIter nextin(list);
534   ReveValuator* cw;
535   while ((fel = (TGFrameElement*)nextin())){
536     // printf("RGBrowser::SetTransparency %s  in fDisplayFrame\n", fel->fFrame->GetName());
537     cw = dynamic_cast<ReveValuator*>(fel->fFrame);
538     if(cw) {
539
540       TGeoVolume* v = dynamic_cast<TGeoVolume*>((RenderElement*)cw->GetUserData());
541       if(v) {
542         cw->SetNumber(v->GetTransparency());
543       }
544     }
545   }
546   gReve->Redraw3D();
547 }
548
549 /**************************************************************************/
550
551 void RGBrowser::SetVolumeColor(UInt_t pixel)
552 {
553   Int_t r, g, b;
554   TColor::Pixel2RGB(pixel, r, g, b);
555
556   TGColorSelect* w = (TGColorSelect*) gTQSender;
557   TGeoVolume* vol = (TGeoVolume*) w->GetUserData();
558   Int_t col = TColor::GetColor(pixel);
559   vol->SetLineColor(col);
560
561   ReveColorSelect* cw;
562   TGFrameElement* fel;
563   TList* list = fDisplayFrame->GetList();
564   TIter nextin(list);
565   while ((fel = (TGFrameElement*)nextin())){
566     // printf("%s  in fDisplayFrame\n", fel->fFrame->GetName());
567     cw = dynamic_cast<ReveColorSelect*>(fel->fFrame);
568     if(cw) {
569       TGeoVolume* cv = dynamic_cast<TGeoVolume*>((TObject*)cw->GetUserData());
570       if(cv) {
571         // printf("TGColorSelect  %d %d\n",pixel, cv->GetLineColor());
572         cw->UpdateColor(TColor::Number2Pixel(cv->GetLineColor())); 
573       }
574     }
575   }
576   gClient->NeedRedraw(fDisplayFrame);
577   gReve->Redraw3D();
578 }
579
580 void RGBrowser::NodeVis(Bool_t vis)
581 {
582   TGCheckButton& rv = *(TGCheckButton*)gTQSender;
583   TGeoNode* node = (TGeoNode*) rv.GetUserData();
584   if(node) {
585     Reve::PadHolder pHolder(false, gReve->GetCC());
586     node->SetVisibility(vis);
587     gReve->Redraw3D();
588   }
589 }
590
591 void RGBrowser::VolumeDaughterVis(Bool_t vis)
592 {
593   TGCheckButton& rv = *(TGCheckButton*)gTQSender;
594   // printf("VSet idx=%d, double value=%lf, part=%p\n", val, rv.GetNumber(), rv.GetUserData());
595   TGeoVolume* vol = (TGeoVolume*) rv.GetUserData();
596   if(vol) {
597     Reve::PadHolder pHolder(false, gReve->GetCC());
598     vol->VisibleDaughters(vis);
599     gReve->Redraw3D();
600   }
601 }
602
603 /**************************************************************************/
604 /**************************************************************************/
605
606 void RGBrowser::SetMaxR(Long_t )
607 {
608   ReveValuator*      rv = (ReveValuator*) gTQSender;
609   TrackList* tc = (TrackList*) rv->GetUserData();
610   if(tc) {
611     tc->SetMaxR(rv->GetNumber());
612   }
613 }
614
615 void RGBrowser::SetMaxZ(Long_t )
616 {
617   ReveValuator*      rv = (ReveValuator*) gTQSender;
618   TrackList* tc = (TrackList*) rv->GetUserData();
619   if(tc) {
620     tc->SetMaxZ(rv->GetNumber());
621   }
622 }
623
624 void RGBrowser::SetMaxOrbs(Long_t )
625 {
626   ReveValuator*      rv = (ReveValuator*) gTQSender;
627   TrackList* tc = (TrackList*) rv->GetUserData();
628   if(tc) {
629     tc->SetMaxOrbs(rv->GetNumber());
630   }
631 }
632
633 /**************************************************************************/
634 /**************************************************************************/
635
636 void RGBrowser::SetMarkerStyle(Long_t )
637
638   ReveValuator*   rv = (ReveValuator*) gTQSender;
639   PointSet* pc = (PointSet*) rv->GetUserData();
640   if(pc) {
641     Reve::PadHolder pHolder(false, gReve->GetCC());
642     pc->SetMarkerStyle(short(rv->GetNumber()));
643     gReve->Redraw3D();
644   }
645 }
646
647 /**************************************************************************/
648 /**************************************************************************/
649
650 void RGBrowser::UpdateListItems(TGListTreeItem* item, Int_t )
651 {
652   if (item->GetUserData()) {
653     //  ListTreeHighlight(item);
654     RenderElement* re = (RenderElement*)item->GetUserData();
655     TObject* obj = re->GetObject();
656
657     // geometry tree
658     if(obj->IsA()->InheritsFrom("TGeoNode")){
659       // delete exisiting
660       fListTree->DeleteChildren(item);
661       TGeoNode* n = (TGeoNode*) obj->IsA()->DynamicCast( TGeoNode::Class(), obj );
662       //printf("adding items\n");
663       if (n->GetNdaughters()) {
664         for (Int_t i=0; i< n->GetNdaughters(); i++) { 
665           TString title;
666           title.Form("%d : %s[%d]", i,
667                      n->GetDaughter(i)->GetVolume()->GetName(),
668                      n->GetDaughter(i)->GetNdaughters());
669
670           TGListTreeItem* child = fListTree->AddItem( item, title.Data());
671           child->SetUserData( n->GetDaughter(i));
672         }
673       }
674     }
675   }
676 }
677
678
679 /**************************************************************************/
680 /**************************************************************************/
681 /**************************************************************************/
682 /**************************************************************************/
683
684 /**************************************************************************/
685 // ReveValuator
686 /**************************************************************************/
687
688 ReveValuator::~ReveValuator()
689 {}