]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 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 | ||
d8b49185 | 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 | ||
5a5a1232 | 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 | ||
907e69dc | 146 | void RGBrowser::SetupClassicLook(RGEditor*& editor, TCanvas* glpad) |
5a5a1232 | 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(); | |
d8b49185 | 155 | |
907e69dc | 156 | editor = new RGEditor(glpad); |
157 | editor->GetCan()->ChangeOptions(0); | |
158 | editor->SetWindowName("Reve Editor"); | |
159 | } | |
d8b49185 | 160 | |
907e69dc | 161 | void RGBrowser::SetupEditorLook(RGEditor*& editor, TCanvas* glpad) |
5a5a1232 | 162 | { |
907e69dc | 163 | fClient->SetRoot(fV2); |
164 | editor = new RGEditor(glpad); | |
165 | editor->GetCan()->ChangeOptions(0); | |
166 | fV2->RemoveFrame(editor); | |
167 | fV2->AddFrame(editor, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2)); | |
168 | fClient->SetRoot(); | |
169 | ||
170 | /* | |
171 | editor->UnmapWindow(); | |
172 | fV2->AddFrame(editor, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2)); | |
173 | Int_t x, y; | |
174 | CalculateReparentXY(fV2, x, y); | |
175 | editor->ReparentWindow(fV2, x, y); | |
176 | */ | |
5a5a1232 | 177 | |
178 | fV2->MapSubwindows(); | |
179 | } | |
180 | ||
907e69dc | 181 | void RGBrowser::SetupGLViewerLook(RGEditor*& editor, TCanvas* glpad) |
5a5a1232 | 182 | { |
183 | TGLayoutHints *lo; | |
184 | ||
185 | TGLSAViewer* v = new TGLSAViewer(fV2, glpad); | |
186 | v->GetFrame()->SetMinWidth(200); | |
187 | lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY); | |
188 | fV2->AddFrame(v->GetFrame(), lo); | |
189 | glpad->SetViewer3D(v); | |
190 | ||
191 | fSelectionFrame->Resize(fSelectionFrame->GetWidth(), fSelectionFrame->GetHeight()/2); | |
192 | ||
193 | TGHSplitter *splitter = new TGHSplitter(fV1); | |
194 | lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 2, 2, 0); | |
195 | fSelectionFrame->AddFrame(splitter, lo); | |
907e69dc | 196 | |
197 | fClient->SetRoot(fV1); | |
198 | editor = new RGEditor(glpad); | |
199 | editor->GetCan()->ChangeOptions(0); | |
5a5a1232 | 200 | editor->ChangeOptions(editor->GetOptions() | kFixedHeight); |
907e69dc | 201 | fV1->RemoveFrame(editor); |
202 | fV1->AddFrame(editor, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,2,2,2)); | |
203 | fClient->SetRoot(); | |
204 | ||
205 | /* | |
206 | editor->UnmapWindow(); | |
207 | editor->ChangeOptions(editor->GetOptions() | kFixedHeight); | |
208 | lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,2,2,2); | |
209 | fV1->AddFrame(editor, lo); | |
210 | Int_t x, y; | |
211 | CalculateReparentXY(fV1, x, y); | |
212 | editor->ReparentWindow(fV1, x, y); | |
213 | */ | |
5a5a1232 | 214 | |
215 | splitter->SetFrame(editor, kFALSE); | |
216 | ||
217 | fV1->MapSubwindows(); | |
218 | v->GetFrame()->MapWindow(); | |
219 | } | |
220 | ||
221 | ||
222 | /**************************************************************************/ | |
223 | /**************************************************************************/ | |
224 | ||
225 | void RGBrowser::RedrawListTree() | |
226 | { | |
227 | gClient->NeedRedraw(fListTree); | |
228 | } | |
229 | ||
230 | /**************************************************************************/ | |
231 | ||
232 | void RGBrowser::ItemClicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y) | |
233 | { | |
234 | //printf("ItemClicked item %s List %d btn=%d, x=%d, y=%d\n", | |
235 | // item->GetText(),fDisplayFrame->GetList()->GetEntries(), btn, x, y); | |
236 | ||
092578a7 | 237 | RenderElement* re = (RenderElement*)item->GetUserData(); |
238 | if(re == 0) return; | |
239 | TObject* obj = re->GetObject(); | |
240 | ||
241 | // A pathetic hack to get at least a bit of color coordination | |
242 | // for RenderElementObjPtr. | |
243 | if(item->GetColor() != re->GetMainColor()) { | |
244 | item->SetColor(re->GetMainColor()); | |
245 | fListTree->GetClient()->NeedRedraw(fListTree); | |
246 | } | |
5a5a1232 | 247 | |
248 | if(btn == 3) { | |
249 | if (obj) { | |
250 | fCtxMenu->Popup(x, y, obj); | |
251 | } | |
252 | return; | |
253 | } | |
254 | ||
092578a7 | 255 | gReve->EditRenderElement(re); |
5a5a1232 | 256 | |
257 | // This only available in classic look. | |
258 | // Still working but slowly drifting towards obscurity (4.2006). | |
259 | DisplayChildren(item, btn); | |
260 | } | |
261 | ||
262 | void RGBrowser::DbClickListItem(TGListTreeItem* item, Int_t btn) | |
263 | { | |
264 | static const Exc_t eH("RGBrowser::DbClickListItem "); | |
265 | ||
907e69dc | 266 | // printf("dbclick item %s\n", item->GetText()); |
092578a7 | 267 | RenderElement* re = (RenderElement*)item->GetUserData(); |
268 | if(re == 0) return; | |
269 | TObject* obj = re->GetObject(); | |
5a5a1232 | 270 | |
271 | if (obj) { | |
272 | // ListTreeHighlight(item); | |
273 | ||
274 | { | |
092578a7 | 275 | RenderElementListBase* rel = dynamic_cast<RenderElementListBase*>(re); |
5a5a1232 | 276 | if(rel != 0) { |
73ecdbca | 277 | //Int_t ni = |
278 | rel->ExpandIntoListTree(fListTree, item); | |
279 | // printf("%s expanded by %d\n", eH.Data(), ni); | |
5a5a1232 | 280 | } |
281 | } | |
282 | ||
283 | // browse geonodes | |
284 | if(obj->IsA()->InheritsFrom("TGeoNode")){ | |
285 | TGeoNode* n = (TGeoNode*) obj->IsA()->DynamicCast( TGeoNode::Class(), obj ); | |
286 | // initialization | |
287 | if(item->GetFirstChild() == 0 && n->GetNdaughters()){ | |
288 | UpdateListItems(item, btn); | |
289 | } | |
290 | } | |
291 | } | |
292 | DisplayChildren(item,0); | |
293 | } | |
294 | ||
295 | /**************************************************************************/ | |
296 | ||
297 | void RGBrowser::ExportToCINT(Text_t* var_name, TObject* obj) | |
298 | { | |
299 | const char* cname = obj->IsA()->GetName(); | |
300 | gROOT->ProcessLine(Form("%s* %s = (%s*) %p;", cname, var_name, cname, obj)); | |
301 | } | |
302 | ||
303 | void RGBrowser::DisplayChildren(TGListTreeItem *item, Int_t btn) | |
304 | { | |
907e69dc | 305 | // Display widgets for children of clicked item in a tabular format. |
5a5a1232 | 306 | // Only classic mode provides direct children editing. |
907e69dc | 307 | |
5a5a1232 | 308 | if(fDisplayFrame == 0) |
309 | return; | |
310 | ||
907e69dc | 311 | if(btn > 1) |
312 | return; | |
313 | ||
5a5a1232 | 314 | fDisplayFrame->DestroySubwindows(); |
315 | fDisplayFrame->Cleanup(); | |
907e69dc | 316 | // printf("DisplayChildren item %s List %d btn=%d\n", item->GetText(),fDisplayFrame->GetList()->GetEntries(), btn); |
5a5a1232 | 317 | |
318 | if(item->GetFirstChild() == 0) return; | |
319 | ||
320 | UInt_t wH = 2; | |
321 | UInt_t wW = 7; | |
322 | ||
323 | UInt_t fw, fh; | |
324 | Int_t nc = 0; | |
325 | TGListTreeItem *child = item->GetFirstChild(); | |
326 | do { | |
327 | child = child->GetNextSibling(); | |
328 | nc ++; | |
329 | } while(child); | |
330 | fw = 70; | |
331 | fh = UInt_t(nc*2); | |
332 | fDisplayFrame->Resize(fw, fh); | |
333 | TGXYLayout* xyl = new TGXYLayout(fDisplayFrame); | |
334 | fDisplayFrame->SetLayoutManager(xyl); | |
335 | xyl->Layout(); | |
336 | ||
337 | TGXYLayoutHints* lh; | |
338 | Float_t x,y; | |
339 | y = 0.; | |
340 | nc = 0; | |
341 | child = item->GetFirstChild(); | |
342 | do { | |
343 | // generic info | |
344 | wW = 24; | |
345 | x = 0.; | |
346 | TGTextButton* b1 = new TGTextButton( fDisplayFrame, Form("%s",child->GetText())); | |
347 | b1->Resize(wW,wH); | |
348 | b1->SetTextJustify(kTextLeft | kTextCenterY); | |
349 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
350 | fDisplayFrame->AddFrame(b1,lh); | |
351 | x += wW; | |
352 | wW = 8; | |
353 | TGCheckButton* b2 = new TGCheckButton(fDisplayFrame, "Draw"); | |
354 | b2->Resize(wW,wH); | |
355 | b2->SetTextJustify(kTextLeft | kTextCenterY); | |
356 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
357 | fDisplayFrame->AddFrame(b2, lh); | |
358 | x += wW; | |
359 | ||
092578a7 | 360 | RenderElement* re = (RenderElement*)child->GetUserData(); |
361 | TObject* obj = re->GetObject(); | |
5a5a1232 | 362 | if(obj != 0) { |
363 | TGXYLayoutHints* lh; | |
364 | ||
365 | Track* track = dynamic_cast<Track*>(obj); // (Track*) obj->IsA()->DynamicCast(Track::Class(), obj ); | |
366 | PointSet* hcont = dynamic_cast<PointSet*>(obj); | |
367 | TrackList* tcont = dynamic_cast<TrackList*>(obj); | |
368 | TGeoNode* gnode = dynamic_cast<TGeoNode*>(obj); | |
369 | ||
370 | // Track | |
371 | //--------- | |
372 | ||
373 | if(track) { | |
374 | // printf("display children track \n"); | |
375 | b2->SetOn(track->GetRnrElement()); | |
376 | b2->Connect("Toggled(Bool_t)", "Reve::Track", track, "SetRnrElement(Bool_t)"); | |
377 | } | |
378 | ||
379 | // PointSet | |
380 | //------------------ | |
381 | ||
382 | if (hcont) { | |
383 | // connect to toggle signal | |
384 | wW = 8; | |
385 | //printf("add label to %s %d\n", cont->GetName(), cont->GetNPoints()); | |
386 | TGLabel* b3 = new TGLabel(fDisplayFrame, Form("%d", hcont->GetN())); | |
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 | ||
393 | wW = 5; | |
394 | TGColorSelect* b4 = new TGColorSelect(fDisplayFrame, TColor::Number2Pixel(hcont->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::PointSet", hcont, "SetMainColor(Pixel_t)"); | |
400 | ||
401 | x += wW; | |
402 | wW = 8; | |
403 | ReveValuator* ne = new ReveValuator(fDisplayFrame, hcont->GetMarkerStyle()); | |
404 | ne->Resize(wW,wH); | |
405 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
406 | ne->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMarkerStyle(Long_t)"); | |
407 | ne->SetUserData(hcont); | |
408 | fDisplayFrame->AddFrame(ne,lh); | |
409 | ||
410 | //connect to container | |
411 | b2->SetUserData(hcont); | |
412 | b2->SetOn(hcont->GetRnrElement()); | |
413 | b2->Connect("Toggled(Bool_t)", "Reve::PointSet", hcont, "SetRnrElement(Bool_t)"); | |
414 | } | |
415 | ||
416 | // TrackList | |
417 | //------------------ | |
418 | ||
419 | if (tcont) { | |
420 | wW = 8; | |
421 | //printf("add label to %s %d\n", cont->GetName(), cont->GetNPoints()); | |
422 | TGLabel* b3 = new TGLabel(fDisplayFrame, Form("%d", tcont->GetNTracks())); | |
423 | b3->SetTextJustify(kTextLeft | kTextCenterY); | |
424 | b3->Resize(wW,wH); | |
425 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
426 | fDisplayFrame->AddFrame(b3, lh); | |
427 | x += wW; | |
428 | // track color | |
429 | wW = 5; | |
430 | TGColorSelect* b4 = new TGColorSelect(fDisplayFrame, TColor::Number2Pixel(tcont->GetMainColor())); | |
431 | b4->Resize(); | |
432 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
433 | fDisplayFrame->AddFrame(b4,lh); | |
434 | b4->Connect("ColorSelected(Pixel_t)", | |
435 | "Reve::TrackList", tcont, "SetMainColor(Pixel_t)"); | |
436 | x += wW; | |
437 | wW = 8; | |
438 | ReveValuator* ne1 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxR); | |
439 | ne1->SetUserData(tcont); | |
440 | ne1->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxR(Long_t)"); | |
441 | // ne1->SetToolTipText("Maximum radius [cm]"); | |
442 | ne1->Resize(wW,wH); | |
443 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
444 | fDisplayFrame->AddFrame(ne1,lh); | |
445 | ||
446 | x += wW; | |
447 | wW = 8; | |
448 | ReveValuator* ne2 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxZ); | |
449 | ne2->SetUserData(tcont); | |
450 | ne2->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxZ(Long_t)"); | |
451 | // ne2->SetToolTipText("Maximum z [cm]"); | |
452 | ne2->Resize(wW,wH); | |
453 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
454 | fDisplayFrame->AddFrame(ne2,lh); | |
455 | ||
456 | x += wW; | |
457 | wW = 8; | |
458 | ReveValuator* ne3 = new ReveValuator(fDisplayFrame, tcont->GetRnrStyle()->fMaxOrbs); | |
459 | ne3->SetUserData(tcont); | |
460 | ne3->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetMaxOrbs(Long_t)"); | |
461 | // ne3->SetToolTipText("Maximum number of orbits"); | |
462 | ne3->Resize(wW,wH); | |
463 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
464 | fDisplayFrame->AddFrame(ne3,lh); | |
465 | ||
466 | x += wW; | |
467 | wW = 8; | |
468 | TGCheckButton* dau = new TGCheckButton(fDisplayFrame, "Daughters"); | |
469 | dau->SetOn(tcont->GetRnrStyle()->fFitDaughters); | |
470 | dau->SetUserData(tcont); | |
471 | dau->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetFitDaughters(Bool_t)"); | |
472 | dau->Resize(wW,wH); | |
473 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
474 | fDisplayFrame->AddFrame(dau,lh); | |
475 | ||
476 | x += wW; | |
477 | wW = 8; | |
478 | TGCheckButton* dec = new TGCheckButton(fDisplayFrame, "Decay"); | |
479 | dec->SetOn(tcont->GetRnrStyle()->fFitDaughters); | |
480 | dec->SetUserData(tcont); | |
481 | dec->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetFitDecay(Bool_t)"); | |
482 | dec->Resize(wW,wH); | |
483 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
484 | fDisplayFrame->AddFrame(dec,lh); | |
485 | ||
486 | //connect to container | |
487 | b2->SetUserData(tcont); | |
488 | //b2->SetOn(tcont->GetRnrTracks()); | |
489 | //b2->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetRnrTracks(Bool_t)"); | |
490 | b2->SetOn(tcont->GetRnrElement()); | |
491 | b2->Connect("Toggled(Bool_t)", "Reve::TrackList", tcont, "SetRnrElement(Bool_t)"); | |
492 | } | |
493 | ||
494 | // TGeoNode | |
495 | //--------- | |
496 | ||
497 | if(gnode) { | |
498 | TGeoVolume* vol = gnode->GetVolume(); | |
499 | b2->SetOn(gnode->IsVisible()); | |
500 | b2->Connect("Toggled(Bool_t)", "Reve::RGBrowser", this,"NodeVis(Bool_t)"); | |
501 | b2->SetUserData(gnode); | |
502 | ||
503 | wW = 11; | |
504 | TGCheckButton* b3 = new TGCheckButton(fDisplayFrame, "VisibleDaughters"); | |
505 | b3->SetTextJustify(kTextLeft | kTextCenterY); | |
506 | b3->Resize(wW,wH); | |
507 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
508 | fDisplayFrame->AddFrame(b3,lh); | |
509 | b3->SetOn(vol->IsVisibleDaughters()); | |
510 | b3->Connect("Toggled(Bool_t)", "Reve::RGBrowser", this, "VolumeDaughterVis(Bool_t)"); | |
511 | b3->SetUserData(vol); | |
512 | x += wW; | |
513 | ||
514 | wW = 5; | |
515 | ReveColorSelect* b4 = new ReveColorSelect(fDisplayFrame, TColor::Number2Pixel(vol->GetLineColor())); | |
516 | b4->Resize(); | |
517 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
518 | fDisplayFrame->AddFrame(b4,lh); | |
519 | b4->Connect("ColorSelected(Pixel_t)", "Reve::RGBrowser", this, "SetVolumeColor(UInt_t)"); | |
520 | b4->SetUserData(vol); | |
521 | x += wW; | |
522 | ||
523 | wW = 11; | |
524 | ReveValuator* ne = new ReveValuator(fDisplayFrame, vol->GetTransparency()); | |
525 | ne->Connect("ValueSet(Long_t)", "Reve::RGBrowser", this, "SetTransparency(Long_t)"); | |
526 | ne->SetUserData(vol); | |
527 | ||
528 | ne->Resize(wW,wH); | |
529 | lh = new TGXYLayoutHints(x, y, wW, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
530 | fDisplayFrame->AddFrame(ne,lh); | |
531 | x += wW; | |
532 | } | |
533 | ||
534 | } | |
535 | y += wH; | |
536 | nc++; | |
537 | child = child->GetNextSibling(); | |
538 | } while(child); | |
539 | fDisplayFrame->MapSubwindows(); | |
540 | fDisplayFrame->MapWindow(); | |
541 | MapSubwindows(); | |
542 | } | |
543 | ||
544 | /**************************************************************************/ | |
545 | // Slots | |
546 | /**************************************************************************/ | |
547 | ||
548 | void RGBrowser::SetTransparency(Long_t ) | |
549 | { | |
550 | ReveValuator& rv = *(ReveValuator*)gTQSender; | |
551 | // printf("VSet idx=%d, double value=%lf, part=%p\n", val, rv.GetNumber(), rv.GetUserData()); | |
552 | TGeoVolume* vol = (TGeoVolume*) rv.GetUserData(); | |
553 | if(vol) { | |
554 | // printf("set volume user data %d \n",val); | |
555 | vol->SetTransparency(char(rv.GetNumber())); | |
556 | } | |
557 | ||
5a5a1232 | 558 | TGFrameElement* fel; |
559 | TList* list = fDisplayFrame->GetList(); | |
560 | TIter nextin(list); | |
561 | ReveValuator* cw; | |
562 | while ((fel = (TGFrameElement*)nextin())){ | |
563 | // printf("RGBrowser::SetTransparency %s in fDisplayFrame\n", fel->fFrame->GetName()); | |
564 | cw = dynamic_cast<ReveValuator*>(fel->fFrame); | |
565 | if(cw) { | |
092578a7 | 566 | |
567 | TGeoVolume* v = dynamic_cast<TGeoVolume*>((RenderElement*)cw->GetUserData()); | |
5a5a1232 | 568 | if(v) { |
569 | cw->SetNumber(v->GetTransparency()); | |
570 | } | |
571 | } | |
572 | } | |
573 | gReve->Redraw3D(); | |
574 | } | |
575 | ||
576 | /**************************************************************************/ | |
577 | ||
578 | void RGBrowser::SetVolumeColor(UInt_t pixel) | |
579 | { | |
580 | Int_t r, g, b; | |
581 | TColor::Pixel2RGB(pixel, r, g, b); | |
582 | ||
583 | TGColorSelect* w = (TGColorSelect*) gTQSender; | |
584 | TGeoVolume* vol = (TGeoVolume*) w->GetUserData(); | |
585 | Int_t col = TColor::GetColor(pixel); | |
586 | vol->SetLineColor(col); | |
587 | ||
588 | ReveColorSelect* cw; | |
589 | TGFrameElement* fel; | |
590 | TList* list = fDisplayFrame->GetList(); | |
591 | TIter nextin(list); | |
592 | while ((fel = (TGFrameElement*)nextin())){ | |
593 | // printf("%s in fDisplayFrame\n", fel->fFrame->GetName()); | |
594 | cw = dynamic_cast<ReveColorSelect*>(fel->fFrame); | |
595 | if(cw) { | |
596 | TGeoVolume* cv = dynamic_cast<TGeoVolume*>((TObject*)cw->GetUserData()); | |
597 | if(cv) { | |
598 | // printf("TGColorSelect %d %d\n",pixel, cv->GetLineColor()); | |
599 | cw->UpdateColor(TColor::Number2Pixel(cv->GetLineColor())); | |
600 | } | |
601 | } | |
602 | } | |
603 | gClient->NeedRedraw(fDisplayFrame); | |
604 | gReve->Redraw3D(); | |
605 | } | |
606 | ||
607 | void RGBrowser::NodeVis(Bool_t vis) | |
608 | { | |
609 | TGCheckButton& rv = *(TGCheckButton*)gTQSender; | |
610 | TGeoNode* node = (TGeoNode*) rv.GetUserData(); | |
611 | if(node) { | |
612 | Reve::PadHolder pHolder(false, gReve->GetCC()); | |
613 | node->SetVisibility(vis); | |
614 | gReve->Redraw3D(); | |
615 | } | |
616 | } | |
617 | ||
618 | void RGBrowser::VolumeDaughterVis(Bool_t vis) | |
619 | { | |
620 | TGCheckButton& rv = *(TGCheckButton*)gTQSender; | |
621 | // printf("VSet idx=%d, double value=%lf, part=%p\n", val, rv.GetNumber(), rv.GetUserData()); | |
622 | TGeoVolume* vol = (TGeoVolume*) rv.GetUserData(); | |
623 | if(vol) { | |
624 | Reve::PadHolder pHolder(false, gReve->GetCC()); | |
625 | vol->VisibleDaughters(vis); | |
626 | gReve->Redraw3D(); | |
627 | } | |
628 | } | |
629 | ||
630 | /**************************************************************************/ | |
631 | /**************************************************************************/ | |
632 | ||
633 | void RGBrowser::SetMaxR(Long_t ) | |
634 | { | |
635 | ReveValuator* rv = (ReveValuator*) gTQSender; | |
636 | TrackList* tc = (TrackList*) rv->GetUserData(); | |
637 | if(tc) { | |
638 | tc->SetMaxR(rv->GetNumber()); | |
639 | } | |
640 | } | |
641 | ||
642 | void RGBrowser::SetMaxZ(Long_t ) | |
643 | { | |
644 | ReveValuator* rv = (ReveValuator*) gTQSender; | |
645 | TrackList* tc = (TrackList*) rv->GetUserData(); | |
646 | if(tc) { | |
647 | tc->SetMaxZ(rv->GetNumber()); | |
648 | } | |
649 | } | |
650 | ||
651 | void RGBrowser::SetMaxOrbs(Long_t ) | |
652 | { | |
653 | ReveValuator* rv = (ReveValuator*) gTQSender; | |
654 | TrackList* tc = (TrackList*) rv->GetUserData(); | |
655 | if(tc) { | |
656 | tc->SetMaxOrbs(rv->GetNumber()); | |
657 | } | |
658 | } | |
659 | ||
660 | /**************************************************************************/ | |
661 | /**************************************************************************/ | |
662 | ||
663 | void RGBrowser::SetMarkerStyle(Long_t ) | |
664 | { | |
665 | ReveValuator* rv = (ReveValuator*) gTQSender; | |
666 | PointSet* pc = (PointSet*) rv->GetUserData(); | |
667 | if(pc) { | |
668 | Reve::PadHolder pHolder(false, gReve->GetCC()); | |
669 | pc->SetMarkerStyle(short(rv->GetNumber())); | |
670 | gReve->Redraw3D(); | |
671 | } | |
672 | } | |
673 | ||
674 | /**************************************************************************/ | |
675 | /**************************************************************************/ | |
676 | ||
677 | void RGBrowser::UpdateListItems(TGListTreeItem* item, Int_t ) | |
678 | { | |
679 | if (item->GetUserData()) { | |
680 | // ListTreeHighlight(item); | |
092578a7 | 681 | RenderElement* re = (RenderElement*)item->GetUserData(); |
682 | TObject* obj = re->GetObject(); | |
5a5a1232 | 683 | |
684 | // geometry tree | |
685 | if(obj->IsA()->InheritsFrom("TGeoNode")){ | |
686 | // delete exisiting | |
687 | fListTree->DeleteChildren(item); | |
688 | TGeoNode* n = (TGeoNode*) obj->IsA()->DynamicCast( TGeoNode::Class(), obj ); | |
689 | //printf("adding items\n"); | |
690 | if (n->GetNdaughters()) { | |
691 | for (Int_t i=0; i< n->GetNdaughters(); i++) { | |
692 | TString title; | |
693 | title.Form("%d : %s[%d]", i, | |
694 | n->GetDaughter(i)->GetVolume()->GetName(), | |
695 | n->GetDaughter(i)->GetNdaughters()); | |
696 | ||
697 | TGListTreeItem* child = fListTree->AddItem( item, title.Data()); | |
698 | child->SetUserData( n->GetDaughter(i)); | |
699 | } | |
700 | } | |
701 | } | |
702 | } | |
703 | } | |
704 | ||
705 | ||
706 | /**************************************************************************/ | |
707 | /**************************************************************************/ | |
708 | /**************************************************************************/ | |
709 | /**************************************************************************/ | |
710 | ||
711 | /**************************************************************************/ | |
712 | // ReveValuator | |
713 | /**************************************************************************/ | |
714 | ||
715 | ReveValuator::~ReveValuator() | |
716 | {} |