]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/RGBrowser.cxx
c2272ec268ecdb647798c253ffadcb6f3622ce23
[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   TObject* obj = (TObject*)item->GetUserData();
217
218   if(btn == 3) {
219     if (obj) {
220       fCtxMenu->Popup(x, y, obj);
221     }
222     return;
223   }
224
225   {
226     RenderElement* re = dynamic_cast<RenderElement*>(obj);
227     gReve->EditRenderElement(re);
228   }
229
230   // This only available in classic look.
231   // Still working but slowly drifting towards obscurity (4.2006).
232   DisplayChildren(item, btn);
233 }
234
235 void RGBrowser::DbClickListItem(TGListTreeItem* item, Int_t btn)
236 {
237   static const Exc_t eH("RGBrowser::DbClickListItem ");
238
239   printf("dbclick item %s\n", item->GetText());
240   TObject* obj = (TObject*)item->GetUserData();
241
242   if (obj) {
243     //  ListTreeHighlight(item);
244
245     {
246       RenderElementListBase* rel = dynamic_cast<RenderElementListBase*>(obj);
247       if(rel != 0) {
248         Int_t ni = rel->ExpandIntoListTree(fListTree, item);
249         printf("%s expanded by %d\n", eH.Data(), ni);
250       }
251     }
252     
253     // browse geonodes
254     if(obj->IsA()->InheritsFrom("TGeoNode")){
255       TGeoNode* n = (TGeoNode*) obj->IsA()->DynamicCast( TGeoNode::Class(), obj );
256       // initialization
257       if(item->GetFirstChild() == 0 && n->GetNdaughters()){
258         UpdateListItems(item, btn);
259       }
260     }
261   }
262   DisplayChildren(item,0);
263 }
264
265 /**************************************************************************/
266
267 void RGBrowser::ExportToCINT(Text_t* var_name, TObject* obj)
268 {
269   const char* cname = obj->IsA()->GetName();
270   gROOT->ProcessLine(Form("%s* %s = (%s*) %p;", cname, var_name, cname, obj));
271 }
272
273 void RGBrowser::DisplayChildren(TGListTreeItem *item, Int_t btn)
274 {
275   // Only classic mode provides direct children editing.
276   if(fDisplayFrame == 0)
277     return;
278
279   fDisplayFrame->DestroySubwindows();
280   fDisplayFrame->Cleanup();
281   printf("DisplayChildren item %s List %d btn=%d\n", item->GetText(),fDisplayFrame->GetList()->GetEntries(), btn);
282
283   if(item->GetFirstChild() == 0) return;
284
285   UInt_t wH = 2;
286   UInt_t wW = 7;
287
288   UInt_t fw, fh;
289   Int_t nc = 0;  
290   TGListTreeItem *child = item->GetFirstChild();
291   do {
292     child = child->GetNextSibling();
293     nc ++;
294   } while(child);
295   fw = 70;
296   fh = UInt_t(nc*2);
297   fDisplayFrame->Resize(fw, fh);
298   TGXYLayout* xyl = new TGXYLayout(fDisplayFrame);
299   fDisplayFrame->SetLayoutManager(xyl);
300   xyl->Layout();
301
302   TGXYLayoutHints* lh;
303   Float_t x,y;
304   y  = 0.;
305   nc = 0;
306   child = item->GetFirstChild();
307   do {
308     // generic info 
309     wW = 24;
310     x = 0.;
311     TGTextButton* b1 = new TGTextButton( fDisplayFrame, Form("%s",child->GetText()));
312     b1->Resize(wW,wH);
313     b1->SetTextJustify(kTextLeft | kTextCenterY);
314     lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
315     fDisplayFrame->AddFrame(b1,lh);
316     x += wW;
317     wW = 8;
318     TGCheckButton* b2 = new TGCheckButton(fDisplayFrame, "Draw");
319     b2->Resize(wW,wH);
320     b2->SetTextJustify(kTextLeft | kTextCenterY);
321     lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
322     fDisplayFrame->AddFrame(b2, lh);
323     x += wW;
324
325     TObject* obj = reinterpret_cast<TObject*>(child->GetUserData());
326     if(obj != 0) {
327       TGXYLayoutHints* lh;
328
329       Track*          track = dynamic_cast<Track*>(obj); // (Track*) obj->IsA()->DynamicCast(Track::Class(), obj );
330       PointSet* hcont = dynamic_cast<PointSet*>(obj);
331       TrackList* tcont = dynamic_cast<TrackList*>(obj);
332       TGeoNode*          gnode = dynamic_cast<TGeoNode*>(obj);
333       
334       // Track
335       //---------
336
337       if(track) {       
338         // printf("display children track \n");
339         b2->SetOn(track->GetRnrElement());
340         b2->Connect("Toggled(Bool_t)", "Reve::Track", track, "SetRnrElement(Bool_t)"); 
341       }
342
343       // PointSet
344       //------------------
345
346       if (hcont) { 
347         // connect to toggle signal
348         wW = 8;
349         //printf("add label to %s %d\n", cont->GetName(), cont->GetNPoints());
350         TGLabel* b3 = new TGLabel(fDisplayFrame, Form("%d", hcont->GetN()));
351         b3->SetTextJustify(kTextLeft | kTextCenterY);
352         b3->Resize(wW,wH);
353         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
354         fDisplayFrame->AddFrame(b3, lh);
355         x += wW;
356
357         wW = 5; 
358         TGColorSelect* b4 = new TGColorSelect(fDisplayFrame, TColor::Number2Pixel(hcont->GetMainColor()));
359         b4->Resize();
360         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
361         fDisplayFrame->AddFrame(b4,lh);
362         b4->Connect("ColorSelected(Pixel_t)",
363                     "Reve::PointSet", hcont, "SetMainColor(Pixel_t)");  
364         
365         x += wW;        
366         wW = 8;
367         ReveValuator* ne = new ReveValuator(fDisplayFrame, hcont->GetMarkerStyle());
368         ne->Resize(wW,wH);
369         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
370         ne->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMarkerStyle(Long_t)");
371         ne->SetUserData(hcont);
372         fDisplayFrame->AddFrame(ne,lh);
373
374         //connect to container
375         b2->SetUserData(hcont);
376         b2->SetOn(hcont->GetRnrElement());
377         b2->Connect("Toggled(Bool_t)", "Reve::PointSet", hcont, "SetRnrElement(Bool_t)");  
378       }
379
380       // TrackList
381       //------------------
382
383       if (tcont) {
384         wW = 8;
385         //printf("add label to %s %d\n", cont->GetName(), cont->GetNPoints());
386         TGLabel* b3 = new TGLabel(fDisplayFrame, Form("%d", tcont->GetNTracks()));
387         b3->SetTextJustify(kTextLeft | kTextCenterY);
388         b3->Resize(wW,wH);
389         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
390         fDisplayFrame->AddFrame(b3, lh);
391         x += wW;
392         // track color
393         wW = 5; 
394         TGColorSelect* b4 = new TGColorSelect(fDisplayFrame, TColor::Number2Pixel(tcont->GetMainColor()));
395         b4->Resize();
396         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
397         fDisplayFrame->AddFrame(b4,lh);
398         b4->Connect("ColorSelected(Pixel_t)",
399                     "Reve::TrackList", tcont, "SetMainColor(Pixel_t)");  
400         x += wW;
401         wW = 8;
402         ReveValuator* ne1 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxR);
403         ne1->SetUserData(tcont);
404         ne1->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxR(Long_t)");
405         // ne1->SetToolTipText("Maximum radius [cm]");
406         ne1->Resize(wW,wH);
407         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
408         fDisplayFrame->AddFrame(ne1,lh);
409  
410         x += wW;        
411         wW = 8;
412         ReveValuator* ne2 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxZ);
413         ne2->SetUserData(tcont);
414         ne2->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxZ(Long_t)");
415         // ne2->SetToolTipText("Maximum z [cm]");
416         ne2->Resize(wW,wH);
417         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
418         fDisplayFrame->AddFrame(ne2,lh);
419
420         x += wW;        
421         wW = 8;
422         ReveValuator* ne3 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxOrbs);
423         ne3->SetUserData(tcont);
424         ne3->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxOrbs(Long_t)");
425         // ne3->SetToolTipText("Maximum number of orbits");
426         ne3->Resize(wW,wH);
427         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
428         fDisplayFrame->AddFrame(ne3,lh);
429
430         x += wW;        
431         wW = 8;
432         TGCheckButton*  dau  = new TGCheckButton(fDisplayFrame, "Daughters");
433         dau->SetOn(tcont->GetRnrStyle()->fFitDaughters);
434         dau->SetUserData(tcont);
435         dau->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetFitDaughters(Bool_t)");
436         dau->Resize(wW,wH);
437         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
438         fDisplayFrame->AddFrame(dau,lh);
439
440         x += wW;        
441         wW = 8;
442         TGCheckButton* dec = new TGCheckButton(fDisplayFrame, "Decay");
443         dec->SetOn(tcont->GetRnrStyle()->fFitDaughters);
444         dec->SetUserData(tcont);
445         dec->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetFitDecay(Bool_t)");
446         dec->Resize(wW,wH);
447         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
448         fDisplayFrame->AddFrame(dec,lh);
449
450         //connect to container
451         b2->SetUserData(tcont);
452         //b2->SetOn(tcont->GetRnrTracks());
453         //b2->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetRnrTracks(Bool_t)");  
454         b2->SetOn(tcont->GetRnrElement());
455         b2->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetRnrElement(Bool_t)");  
456       }
457
458       // TGeoNode
459       //---------
460
461       if(gnode) {
462         TGeoVolume* vol = gnode->GetVolume();
463         b2->SetOn(gnode->IsVisible());
464         b2->Connect("Toggled(Bool_t)", "Reve::RGBrowser", this,"NodeVis(Bool_t)");  
465         b2->SetUserData(gnode);
466
467         wW = 11;
468         TGCheckButton* b3 = new TGCheckButton(fDisplayFrame, "VisibleDaughters");
469         b3->SetTextJustify(kTextLeft | kTextCenterY);
470         b3->Resize(wW,wH);
471         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
472         fDisplayFrame->AddFrame(b3,lh);
473         b3->SetOn(vol->IsVisibleDaughters());
474         b3->Connect("Toggled(Bool_t)", "Reve::RGBrowser", this, "VolumeDaughterVis(Bool_t)");  
475         b3->SetUserData(vol);
476         x += wW;
477
478         wW = 5; 
479         ReveColorSelect* b4 = new ReveColorSelect(fDisplayFrame, TColor::Number2Pixel(vol->GetLineColor()));
480         b4->Resize();
481         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
482         fDisplayFrame->AddFrame(b4,lh);
483         b4->Connect("ColorSelected(Pixel_t)", "Reve::RGBrowser", this, "SetVolumeColor(UInt_t)");  
484         b4->SetUserData(vol);
485         x += wW;
486
487         wW = 11;
488         ReveValuator* ne = new ReveValuator(fDisplayFrame, vol->GetTransparency());
489         ne->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetTransparency(Long_t)");
490         ne->SetUserData(vol);
491
492         ne->Resize(wW,wH);
493         lh = new TGXYLayoutHints(x, y, wW, wH,0);  lh->SetPadLeft(2); lh->SetPadRight(2);
494         fDisplayFrame->AddFrame(ne,lh);
495         x += wW;
496       }
497
498     }
499     y += wH; 
500     nc++;
501     child = child->GetNextSibling();
502   } while(child);
503   fDisplayFrame->MapSubwindows();
504   fDisplayFrame->MapWindow();
505   MapSubwindows();
506 }
507
508 /**************************************************************************/
509 // Slots
510 /**************************************************************************/
511
512 void RGBrowser::SetTransparency(Long_t )
513 {
514   ReveValuator& rv = *(ReveValuator*)gTQSender;
515   // printf("VSet idx=%d, double value=%lf, part=%p\n", val, rv.GetNumber(), rv.GetUserData());
516   TGeoVolume* vol = (TGeoVolume*) rv.GetUserData();
517   if(vol) {
518     //    printf("set volume user data %d \n",val);
519     vol->SetTransparency(char(rv.GetNumber()));
520   }
521
522  
523   TGFrameElement* fel;
524   TList* list = fDisplayFrame->GetList();
525   TIter nextin(list);
526   ReveValuator* cw;
527   while ((fel = (TGFrameElement*)nextin())){
528     // printf("RGBrowser::SetTransparency %s  in fDisplayFrame\n", fel->fFrame->GetName());
529     cw = dynamic_cast<ReveValuator*>(fel->fFrame);
530     if(cw) {
531       TGeoVolume* v = dynamic_cast<TGeoVolume*>((TObject*)cw->GetUserData());
532       if(v) {
533         cw->SetNumber(v->GetTransparency());
534       }
535     }
536   }
537   gReve->Redraw3D();
538 }
539
540 /**************************************************************************/
541
542 void RGBrowser::SetVolumeColor(UInt_t pixel)
543 {
544   Int_t r, g, b;
545   TColor::Pixel2RGB(pixel, r, g, b);
546
547   TGColorSelect* w = (TGColorSelect*) gTQSender;
548   TGeoVolume* vol = (TGeoVolume*) w->GetUserData();
549   Int_t col = TColor::GetColor(pixel);
550   vol->SetLineColor(col);
551
552   ReveColorSelect* cw;
553   TGFrameElement* fel;
554   TList* list = fDisplayFrame->GetList();
555   TIter nextin(list);
556   while ((fel = (TGFrameElement*)nextin())){
557     // printf("%s  in fDisplayFrame\n", fel->fFrame->GetName());
558     cw = dynamic_cast<ReveColorSelect*>(fel->fFrame);
559     if(cw) {
560       TGeoVolume* cv = dynamic_cast<TGeoVolume*>((TObject*)cw->GetUserData());
561       if(cv) {
562         // printf("TGColorSelect  %d %d\n",pixel, cv->GetLineColor());
563         cw->UpdateColor(TColor::Number2Pixel(cv->GetLineColor())); 
564       }
565     }
566   }
567   gClient->NeedRedraw(fDisplayFrame);
568   gReve->Redraw3D();
569 }
570
571 void RGBrowser::NodeVis(Bool_t vis)
572 {
573   TGCheckButton& rv = *(TGCheckButton*)gTQSender;
574   TGeoNode* node = (TGeoNode*) rv.GetUserData();
575   if(node) {
576     Reve::PadHolder pHolder(false, gReve->GetCC());
577     node->SetVisibility(vis);
578     gReve->Redraw3D();
579   }
580 }
581
582 void RGBrowser::VolumeDaughterVis(Bool_t vis)
583 {
584   TGCheckButton& rv = *(TGCheckButton*)gTQSender;
585   // printf("VSet idx=%d, double value=%lf, part=%p\n", val, rv.GetNumber(), rv.GetUserData());
586   TGeoVolume* vol = (TGeoVolume*) rv.GetUserData();
587   if(vol) {
588     Reve::PadHolder pHolder(false, gReve->GetCC());
589     vol->VisibleDaughters(vis);
590     gReve->Redraw3D();
591   }
592 }
593
594 /**************************************************************************/
595 /**************************************************************************/
596
597 void RGBrowser::SetMaxR(Long_t )
598 {
599   ReveValuator*      rv = (ReveValuator*) gTQSender;
600   TrackList* tc = (TrackList*) rv->GetUserData();
601   if(tc) {
602     tc->SetMaxR(rv->GetNumber());
603   }
604 }
605
606 void RGBrowser::SetMaxZ(Long_t )
607 {
608   ReveValuator*      rv = (ReveValuator*) gTQSender;
609   TrackList* tc = (TrackList*) rv->GetUserData();
610   if(tc) {
611     tc->SetMaxZ(rv->GetNumber());
612   }
613 }
614
615 void RGBrowser::SetMaxOrbs(Long_t )
616 {
617   ReveValuator*      rv = (ReveValuator*) gTQSender;
618   TrackList* tc = (TrackList*) rv->GetUserData();
619   if(tc) {
620     tc->SetMaxOrbs(rv->GetNumber());
621   }
622 }
623
624 /**************************************************************************/
625 /**************************************************************************/
626
627 void RGBrowser::SetMarkerStyle(Long_t )
628
629   ReveValuator*   rv = (ReveValuator*) gTQSender;
630   PointSet* pc = (PointSet*) rv->GetUserData();
631   if(pc) {
632     Reve::PadHolder pHolder(false, gReve->GetCC());
633     pc->SetMarkerStyle(short(rv->GetNumber()));
634     gReve->Redraw3D();
635   }
636 }
637
638 /**************************************************************************/
639 /**************************************************************************/
640
641 void RGBrowser::UpdateListItems(TGListTreeItem* item, Int_t )
642 {
643   if (item->GetUserData()) {
644     //  ListTreeHighlight(item);
645     TObject* obj = (TObject *) item->GetUserData();
646
647     // geometry tree
648     if(obj->IsA()->InheritsFrom("TGeoNode")){
649       // delete exisiting
650       fListTree->DeleteChildren(item);
651       TGeoNode* n = (TGeoNode*) obj->IsA()->DynamicCast( TGeoNode::Class(), obj );
652       //printf("adding items\n");
653       if (n->GetNdaughters()) {
654         for (Int_t i=0; i< n->GetNdaughters(); i++) { 
655           TString title;
656           title.Form("%d : %s[%d]", i,
657                      n->GetDaughter(i)->GetVolume()->GetName(),
658                      n->GetDaughter(i)->GetNdaughters());
659
660           TGListTreeItem* child = fListTree->AddItem( item, title.Data());
661           child->SetUserData( n->GetDaughter(i));
662         }
663       }
664     }
665   }
666 }
667
668
669 /**************************************************************************/
670 /**************************************************************************/
671 /**************************************************************************/
672 /**************************************************************************/
673
674 /**************************************************************************/
675 // ReveValuator
676 /**************************************************************************/
677
678 ReveValuator::~ReveValuator()
679 {}