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