Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TEveBrowser.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveBrowser.h"
13
14#include "TEveUtil.h"
15#include "TEveElement.h"
16#include "TEveManager.h"
17#include "TEveSelection.h"
18#include "TEveGedEditor.h"
19#include "TEveWindow.h"
20#include "TEveWindowManager.h"
21
22#include "TGFileBrowser.h"
23#include "TBrowser.h"
24
25#include "TClass.h"
26#include "TROOT.h"
27#include "TSystem.h"
28#include "TVirtualX.h"
29
30#include "TClassMenuItem.h"
31
32#include "TColor.h"
33
34#include "TGCanvas.h"
35#include "TGMenu.h"
36#include "TGSplitter.h"
37#include "TGTab.h"
38#include <KeySymbols.h>
39#include "TGLSAViewer.h"
40
41#include "TGeoVolume.h"
42#include "TGeoNode.h"
43
44/** \class TEveListTreeItem
45\ingroup TEve
46Special list-tree-item for Eve.
47
48Most state is picked directly from TEveElement, no need to store it
49locally nor to manage its consistency.
50
51Handles also selected/highlighted colors and, in the future, drag-n-drop.
52*/
53
54
55////////////////////////////////////////////////////////////////////////////////
56/// Warn about access to function members that should never be called.
57/// TGListTree calls them in cases that are not used by Eve.
58
59void TEveListTreeItem::NotSupported(const char* func) const
60{
61 Warning(Form("TEveListTreeItem::%s()", func), "not supported.");
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Return highlight color corresponding to current state of TEveElement.
66
68{
69 switch (fElement->GetSelectedLevel())
70 {
71 case 1: return TColor::Number2Pixel(kBlue - 2);
72 case 2: return TColor::Number2Pixel(kBlue - 6);
73 case 3: return TColor::Number2Pixel(kCyan - 2);
74 case 4: return TColor::Number2Pixel(kCyan - 6);
75 }
77}
78
79////////////////////////////////////////////////////////////////////////////////
80/// Item's check-box state has been toggled ... forward to element's
81/// render-state.
82
84{
85 fElement->SetRnrState(!IsChecked());
86 fElement->ElementChanged(kTRUE, kTRUE);
87}
88
89/** \class TEveGListTreeEditorFrame
90\ingroup TEve
91Composite GUI frame for parallel display of a TGListTree and TEveGedEditor.
92*/
93
94
96
97////////////////////////////////////////////////////////////////////////////////
98/// Constructor.
99
101 TGMainFrame (p ? p : gClient->GetRoot(), width, height),
102 fFrame (nullptr),
103 fLTFrame (nullptr),
104 fListTree (nullptr),
105 fSplitter (nullptr),
106 fEditor (nullptr),
107 fCtxMenu (nullptr),
109{
111
112 fFrame = new TGCompositeFrame(this, width, height, kVerticalFrame);
113
114 // List-tree
115 fLTFrame = new TGCompositeFrame(fFrame, width, 3*height/7, kVerticalFrame);
117 fListTree = new TGListTree(fLTCanvas->GetViewPort(), 10, 10, kHorizontalFrame);
118 fListTree->SetCanvas(fLTCanvas);
119 fListTree->Associate(fFrame);
121 fListTree->SetAutoCheckBoxPic(kFALSE);
122 fListTree->SetUserControl(kTRUE);
123 fLTCanvas->SetContainer(fListTree);
124 fLTFrame->AddFrame(fLTCanvas, new TGLayoutHints
126 fFrame ->AddFrame(fLTFrame, new TGLayoutHints
128
129 // Splitter
131 fFrame->AddFrame(fSplitter, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1,1,2,2));
132
133 // Editor
134 fFrame->SetEditDisabled(kEditEnable);
135 fFrame->SetEditable();
136 fEditor = (TEveGedEditor*) gROOT->GetClass(fgEditorClass)->New();
137 fEditor->SetGlobal(kFALSE);
138 fEditor->ChangeOptions(fEditor->GetOptions() | kFixedHeight);
139 fFrame->SetEditable(kEditDisable);
140 fFrame->SetEditable(kFALSE);
141 {
142 TGFrameElement *el = nullptr;
143 TIter next(fFrame->GetList());
144 while ((el = (TGFrameElement *) next())) {
145 if (el->fFrame == fEditor)
146 if (el->fLayout) {
148 el->fLayout->SetPadLeft(0); el->fLayout->SetPadRight(1);
149 el->fLayout->SetPadTop(2); el->fLayout->SetPadBottom(1);
150 break;
151 }
152 }
153 }
154 fSplitter->SetFrame(fEditor, kFALSE);
155
157
158 fCtxMenu = new TContextMenu("", "");
159
160 Layout();
162 MapWindow();
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Destructor.
167
169{
171
172 delete fCtxMenu;
173
174 // Should un-register editor, all items and list-tree from gEve ... eventually.
175
176 delete fEditor;
177 delete fSplitter;
178 delete fListTree;
179 delete fLTCanvas;
180 delete fLTFrame;
181 delete fFrame;
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Set GED editor class.
186
188{
189 fgEditorClass = edclass;
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Connect list-tree signals.
194
196{
197 fListTree->Connect("MouseOver(TGListTreeItem*, UInt_t)", "TEveGListTreeEditorFrame",
198 this, "ItemBelowMouse(TGListTreeItem*, UInt_t)");
199 fListTree->Connect("Clicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)", "TEveGListTreeEditorFrame",
200 this, "ItemClicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)");
201 fListTree->Connect("DoubleClicked(TGListTreeItem*, Int_t)", "TEveGListTreeEditorFrame",
202 this, "ItemDblClicked(TGListTreeItem*, Int_t)");
203 fListTree->Connect("KeyPressed(TGListTreeItem*, ULong_t, ULong_t)", "TEveGListTreeEditorFrame",
204 this, "ItemKeyPress(TGListTreeItem*, UInt_t, UInt_t)");
205
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Disconnect list-tree signals.
211
213{
214 if (!fSignalsConnected) return;
215
216 fListTree->Disconnect("MouseOver(TGListTreeItem*, UInt_t)",
217 this, "ItemBelowMouse(TGListTreeItem*, UInt_t)");
218 fListTree->Disconnect("Clicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)",
219 this, "ItemClicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)");
220 fListTree->Disconnect("DoubleClicked(TGListTreeItem*, Int_t)",
221 this, "ItemDblClicked(TGListTreeItem*, Int_t)");
222 fListTree->Disconnect("KeyPressed(TGListTreeItem*, ULong_t, ULong_t)",
223 this, "ItemKeyPress(TGListTreeItem*, UInt_t, UInt_t)");
224
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Reconfigure to horizontal layout, list-tree and editor side by side.
230
232{
233 UnmapWindow();
234
235 fFrame->ChangeOptions(kHorizontalFrame);
236 fLTFrame->ChangeOptions(kHorizontalFrame);
237 fListTree->ChangeOptions(kVerticalFrame);
238
239 TGFrameElement *el = nullptr;
240 TIter next(fFrame->GetList());
241 while ((el = (TGFrameElement *) next()))
242 {
243 if (el->fFrame == fSplitter)
244 {
245 // This is needed so that splitter window gets destroyed on server.
246 fSplitter->ReparentWindow(fClient->GetDefaultRoot());
247 delete fSplitter;
248 el->fFrame = fSplitter = new TGVSplitter(fFrame);
250 el->fLayout->SetPadLeft(2); el->fLayout->SetPadRight (2);
251 el->fLayout->SetPadTop (1); el->fLayout->SetPadBottom(1);
252 }
253 else if (el->fFrame == fEditor)
254 {
255 fEditor->ChangeOptions(fEditor->GetOptions() & (~kFixedHeight));
256 fEditor->ChangeOptions(fEditor->GetOptions() | kFixedWidth);
258 }
259 }
260
261 fEditor->Resize(fEditor->GetWidth() / 2 - 1, fEditor->GetHeight());
262 fSplitter->SetFrame(fEditor, kFALSE);
263
264 Layout();
266 MapWindow();
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Reconfigure to vertical layout, list-tree above the editor.
271
273{
274 UnmapWindow();
275
276 fFrame->ChangeOptions(kVerticalFrame);
277 fLTFrame->ChangeOptions(kVerticalFrame);
278 fListTree->ChangeOptions(kHorizontalFrame);
279
280 TGFrameElement *el = nullptr;
281 TIter next(fFrame->GetList());
282 while ((el = (TGFrameElement *) next()))
283 {
284 if (el->fFrame == fSplitter)
285 {
286 // This is needed so that splitter window gets destroyed on server.
287 fSplitter->ReparentWindow(fClient->GetDefaultRoot());
288 delete fSplitter;
289 el->fFrame = fSplitter = new TGHSplitter(fFrame);
291 el->fLayout->SetPadLeft(2); el->fLayout->SetPadRight (2);
292 el->fLayout->SetPadTop (1); el->fLayout->SetPadBottom(1);
293 }
294 else if (el->fFrame == fEditor)
295 {
296 fEditor->ChangeOptions(fEditor->GetOptions() & (~kFixedWidth));
297 fEditor->ChangeOptions(fEditor->GetOptions() | kFixedHeight);
299 }
300 }
301
302 fEditor->Resize(fEditor->GetWidth(), fEditor->GetHeight() / 2 - 1);
303 fSplitter->SetFrame(fEditor, kFALSE);
304
305 Layout();
307 MapWindow();
308}
309
310////////////////////////////////////////////////////////////////////////////////
311/// Different item is below mouse.
312
314{
315 TEveElement* el = entry ? (TEveElement*) entry->GetUserData() : nullptr;
316 gEve->GetHighlight()->UserPickedElement(el, kFALSE);
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Item has been clicked, based on mouse button do:
321/// - M1 - select, show in editor;
322/// - M2 - paste (call gEve->ElementPaste();
323/// - M3 - popup context menu.
324
326{
327 //printf("ItemClicked item %s List %d btn=%d, x=%d, y=%d\n",
328 // item->GetText(),fDisplayFrame->GetList()->GetEntries(), btn, x, y);
329
330 static const TEveException eh("TEveGListTreeEditorFrame::ItemClicked ");
331
332 TEveElement* el = (TEveElement*) item->GetUserData();
333 if (el == nullptr) return;
334 TObject* obj = el->GetObject(eh);
335
336 switch (btn)
337 {
338 case 1:
339 gEve->GetSelection()->UserPickedElement(el, mask & kKeyControlMask);
340 break;
341
342 case 2:
343 if (gEve->ElementPaste(el))
344 gEve->Redraw3D();
345 break;
346
347 case 3:
348 // If control pressed, show menu for render-element itself.
349 // event->fState & kKeyControlMask
350 // ??? how do i get current event?
351 // !!!!! Have this now ... fix.
352 if (obj) fCtxMenu->Popup(x, y, obj);
353 break;
354
355 default:
356 break;
357 }
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Item has been double-clicked, potentially expand the children.
362
364{
365 static const TEveException eh("TEveGListTreeEditorFrame::ItemDblClicked ");
366
367 if (btn != 1) return;
368
369 TEveElement* el = (TEveElement*) item->GetUserData();
370 if (el == nullptr) return;
371
372 el->ExpandIntoListTree(fListTree, item);
373
374 TObject* obj = el->GetObject(eh);
375 if (obj)
376 {
377 // Browse geonodes.
378 if (obj->IsA()->InheritsFrom(TGeoNode::Class()))
379 {
380 TGeoNode* n = dynamic_cast<TGeoNode*>(obj);
381 if (item->GetFirstChild() == nullptr && n->GetNdaughters())
382 {
383 fListTree->DeleteChildren(item);
384 for (Int_t i=0; i< n->GetNdaughters(); i++)
385 {
386 TString title;
387 title.Form("%d : %s[%d]", i,
388 n->GetDaughter(i)->GetVolume()->GetName(),
389 n->GetDaughter(i)->GetNdaughters());
390
391 TGListTreeItem* child = fListTree->AddItem(item, title.Data());
392 child->SetUserData(n->GetDaughter(i));
393 }
394 }
395 }
396 }
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// A key has been pressed for an item.
401///
402/// Only `<Delete>`, `<Enter>` and `<Return>` keys are handled here,
403/// otherwise the control is passed back to TGListTree.
404
406{
407 static const TEveException eh("TEveGListTreeEditorFrame::ItemKeyPress ");
408
409 entry = fListTree->GetCurrent();
410 if (entry == nullptr) return;
411
412 TEveElement* el = (TEveElement*) entry->GetUserData();
413
414 fListTree->SetEventHandled(); // Reset back to false in default case.
415
416 switch (keysym)
417 {
418 case kKey_Delete:
419 {
420 if (entry->GetParent())
421 {
422 if (el->GetDenyDestroy() > 0 && el->GetNItems() == 1)
423 throw(eh + "DestroyDenied set for this item.");
424
425 TEveElement* parent = (TEveElement*) entry->GetParent()->GetUserData();
426
427 if (parent)
428 {
429 gEve->RemoveElement(el, parent);
430 gEve->Redraw3D();
431 }
432 }
433 else
434 {
435 if (el->GetDenyDestroy() > 0)
436 throw(eh + "DestroyDenied set for this top-level item.");
437 gEve->RemoveFromListTree(el, fListTree, entry);
438 gEve->Redraw3D();
439 }
440 break;
441 }
442
443 case kKey_Enter:
444 case kKey_Return:
445 {
446 gEve->GetSelection()->UserPickedElement(el, mask & kKeyControlMask);
447 break;
448 }
449
450 default:
451 {
452 fListTree->SetEventHandled(kFALSE);
453 break;
454 }
455 }
456}
457
458
459/** \class TEveBrowser
460\ingroup TEve
461Specialization of TRootBrowser for Eve.
462*/
463
464
465////////////////////////////////////////////////////////////////////////////////
466/// Add "Export to CINT" into context-menu for class cl.
467
469{
470 TList* l = cl->GetMenuList();
472 "Export to CINT", "ExportToCINT", this, "const char*,TObject*", 1);
473
474 l->AddFirst(n);
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Calculate position of a widget for reparenting into parent.
479
481{
482 UInt_t w, h;
483 Window_t childdum;
484 gVirtualX->GetWindowSize(parent->GetId(), x, y, w, h);
485 gVirtualX->TranslateCoordinates(parent->GetId(),
486 gClient->GetDefaultRoot()->GetId(),
487 0, 0, x, y, childdum);
488}
489
490namespace
491{
492enum EEveMenu_e {
493 kNewMainFrameSlot, kNewTabSlot,
494 kNewViewer, kNewScene,
495 kNewBrowser, kNewCanvas, kNewCanvasExt, kNewTextEditor, kNewHtmlBrowser,
496 kSel_PS_Ignore, kSel_PS_Element, kSel_PS_Projectable, kSel_PS_Compound,
497 kSel_PS_PableCompound, kSel_PS_Master, kSel_PS_END,
498 kHil_PS_Ignore, kHil_PS_Element, kHil_PS_Projectable, kHil_PS_Compound,
499 kHil_PS_PableCompound, kHil_PS_Master, kHil_PS_END,
500 kVerticalBrowser,
501 kWinDecorNormal, kWinDecorHide, kWinDecorTitleBar, kWinDecorMiniBar
502};
503
504}
505
506////////////////////////////////////////////////////////////////////////////////
507/// Constructor.
508
510 TRootBrowser(nullptr, "Eve Main Window", w, h, "", kFALSE),
511 fFileBrowser(nullptr),
512 fEvePopup (nullptr),
513 fSelPopup (nullptr),
514 fHilPopup (nullptr)
515{
516 // Construct Eve menu.
517
518 fEvePopup = new TGPopupMenu(gClient->GetRoot());
519 fEvePopup->AddEntry("New &MainFrame Slot", kNewMainFrameSlot);
520 fEvePopup->AddEntry("New &Tab Slot", kNewTabSlot);
521 fEvePopup->AddSeparator();
522 fEvePopup->AddEntry("New &Viewer", kNewViewer);
523 fEvePopup->AddEntry("New &Scene", kNewScene);
524 fEvePopup->AddSeparator();
525 fEvePopup->AddEntry("New &Browser", kNewBrowser);
526 fEvePopup->AddEntry("New &Canvas", kNewCanvas);
527 fEvePopup->AddEntry("New Canvas Ext", kNewCanvasExt);
528 fEvePopup->AddEntry("New Text &Editor", kNewTextEditor);
529 // fEvePopup->AddEntry("New HTML Browser", kNewHtmlBrowser);
530 fEvePopup->AddSeparator();
531
532 {
533 fSelPopup = new TGPopupMenu(gClient->GetRoot());
534 fSelPopup->AddEntry("Ignore", kSel_PS_Ignore);
535 fSelPopup->AddEntry("Element", kSel_PS_Element);
536 fSelPopup->AddEntry("Projectable", kSel_PS_Projectable);
537 fSelPopup->AddEntry("Compound", kSel_PS_Compound);
538 fSelPopup->AddEntry("Projectable and Compound",
539 kSel_PS_PableCompound);
540 fSelPopup->AddEntry("Master", kSel_PS_Master);
541 fSelPopup->RCheckEntry(kSel_PS_Ignore + gEve->GetSelection()->GetPickToSelect(),
542 kSel_PS_Ignore, kSel_PS_END - 1);
543 fEvePopup->AddPopup("Selection", fSelPopup);
544 }
545 {
546 fHilPopup = new TGPopupMenu(gClient->GetRoot());
547 fHilPopup->AddEntry("Ignore", kHil_PS_Ignore);
548 fHilPopup->AddEntry("Element", kHil_PS_Element);
549 fHilPopup->AddEntry("Projectable", kHil_PS_Projectable);
550 fHilPopup->AddEntry("Compound", kHil_PS_Compound);
551 fHilPopup->AddEntry("Projectable and Compound",
552 kHil_PS_PableCompound);
553 fHilPopup->AddEntry("Master", kHil_PS_Master);
554 fHilPopup->RCheckEntry(kHil_PS_Ignore + gEve->GetHighlight()->GetPickToSelect(),
555 kHil_PS_Ignore, kHil_PS_END - 1);
556 fEvePopup->AddPopup("Highlight", fHilPopup);
557 }
558
559 fEvePopup->AddSeparator();
560 fEvePopup->AddEntry("Vertical browser", kVerticalBrowser);
561 fEvePopup->CheckEntry(kVerticalBrowser);
562 {
563 TGPopupMenu *wd = new TGPopupMenu(gClient->GetRoot());
564 wd->AddEntry("Normal", kWinDecorNormal);
565 wd->AddEntry("Hide", kWinDecorHide);
566 wd->AddEntry("Title bars", kWinDecorTitleBar);
567 wd->AddEntry("Mini bars", kWinDecorMiniBar);
568 fEvePopup->AddPopup("Window decorations", wd);
569 }
570
571 fEvePopup->Connect("Activated(Int_t)", "TEveBrowser",
572 this, "EveMenu(Int_t)");
573
574 fMenuBar->AddPopup("&Eve", fEvePopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
575
576 fPreMenuFrame->ChangeOptions(fPreMenuFrame->GetOptions() | kRaisedFrame);
577 fTopMenuFrame->Layout();
578 fTopMenuFrame->MapSubwindows();
579
580 // Rename "Close Window" to "Close Eve"
581 fMenuFile->GetEntry(kCloseWindow)->GetLabel()->SetString("Close Eve");
582}
583
584////////////////////////////////////////////////////////////////////////////////
585/// Handle events from Eve menu.
586
588{
589 switch (id)
590 {
591 case kNewMainFrameSlot: {
593 gEve->GetWindowManager()->SelectWindow(ew_slot);
594 break;
595 }
596 case kNewTabSlot: {
598 gEve->GetWindowManager()->SelectWindow(ew_slot);
599 break;
600 }
601 case kNewViewer: {
602 gEve->SpawnNewViewer("Viewer Pepe");
603 break;
604 }
605 case kNewScene: {
606 gEve->SpawnNewScene("Scena Mica");
607 break;
608 }
609 case kNewBrowser: {
610 gROOT->ProcessLineFast("new TBrowser");
611 break;
612 }
613 case kNewCanvas: {
615 gROOT->ProcessLineFast("new TCanvas");
617 SetTabTitle("Canvas", 1);
618 break;
619 }
620 case kNewCanvasExt: {
621 gROOT->ProcessLineFast("new TCanvas");
622 break;
623 }
624 case kNewTextEditor: {
626 gROOT->ProcessLineFast(Form("new TGTextEditor((const char *)0, (const TGWindow *)0x%zx)", (size_t)gClient->GetRoot()));
628 SetTabTitle("Editor", 1);
629 break;
630 }
631 case kNewHtmlBrowser: {
632 gSystem->Load("libGuiHtml");
633 if (gSystem->Load("libRHtml") >= 0)
634 {
636 gROOT->ProcessLine(Form("new TGHtmlBrowser(\"https://root.cern/doc/master/classes.html\", \
637 (const TGWindow *)0x%zx)", (size_t)gClient->GetRoot()));
639 SetTabTitle("HTML", 1);
640 }
641 break;
642 }
643 case kSel_PS_Ignore:
644 case kSel_PS_Element:
645 case kSel_PS_Projectable:
646 case kSel_PS_Compound:
647 case kSel_PS_PableCompound:
648 case kSel_PS_Master: {
649 gEve->GetSelection()->SetPickToSelect(id - kSel_PS_Ignore);
650 fSelPopup->RCheckEntry(kSel_PS_Ignore + gEve->GetSelection()->GetPickToSelect(),
651 kSel_PS_Ignore, kSel_PS_END - 1);
652 break;
653 }
654 case kHil_PS_Ignore:
655 case kHil_PS_Element:
656 case kHil_PS_Projectable:
657 case kHil_PS_Compound:
658 case kHil_PS_PableCompound:
659 case kHil_PS_Master: {
660 gEve->GetHighlight()->SetPickToSelect(id - kHil_PS_Ignore);
661 fHilPopup->RCheckEntry(kHil_PS_Ignore + gEve->GetHighlight()->GetPickToSelect(),
662 kHil_PS_Ignore, kHil_PS_END - 1);
663 break;
664 }
665 case kVerticalBrowser: {
666 if (fEvePopup->IsEntryChecked(kVerticalBrowser)) {
667 gEve->GetLTEFrame()->ReconfToHorizontal();
668 fEvePopup->UnCheckEntry(kVerticalBrowser);
669 } else {
670 gEve->GetLTEFrame()->ReconfToVertical();
671 fEvePopup->CheckEntry(kVerticalBrowser);
672 }
673 break;
674 }
675 case kWinDecorNormal: {
676 gEve->GetWindowManager()->ShowNormalEveDecorations();
677 break;
678 }
679 case kWinDecorHide: {
680 gEve->GetWindowManager()->HideAllEveDecorations();
681 break;
682 }
683 case kWinDecorTitleBar: {
684 gEve->GetWindowManager()->SetShowTitleBars(kTRUE);
685 break;
686 }
687 case kWinDecorMiniBar: {
688 gEve->GetWindowManager()->SetShowTitleBars(kFALSE);
689 break;
690 }
691
692 default: {
693 break;
694 }
695 }
696}
697
698////////////////////////////////////////////////////////////////////////////////
699/// Initialize standard plugins.
700
702{
703 TString o(opt);
704
705 // File Browser plugin ... we have to process it here.
706 if (o.Contains('F'))
707 {
710 fb->BrowseObj(gROOT);
711 fb->Show();
712 fFileBrowser = fb;
713 StopEmbedding("Files");
714 o.ReplaceAll("F", ".");
715 }
716
718}
719
720////////////////////////////////////////////////////////////////////////////////
721/// Create a file-browser. Caller should provide Start/StopEmbedding() calls
722/// and populate the new browser.
723///
724/// If flag make_default is kTRUE, the default file-browser is set to the
725/// newly created browser.
726
728{
729 TBrowserImp imp;
730 TBrowser *tb = new TBrowser("Pipi", "Strel", &imp);
731 TGFileBrowser *fb = new TGFileBrowser(gClient->GetRoot(), tb, 200, 500);
732 tb->SetBrowserImp((TBrowserImp *)this);
733 fb->SetBrowser(tb);
734 fb->SetNewBrowser(this);
735 gROOT->GetListOfBrowsers()->Remove(tb);
736 // This guy is never used and stays in list-of-cleanups after destruction.
737 // So let's just delete it now.
738 delete tb->GetContextMenu();
739
740 if (make_default)
741 fFileBrowser = fb;
742
743 return fb;
744}
745
746////////////////////////////////////////////////////////////////////////////////
747/// Returns the default file-browser.
748
753
754////////////////////////////////////////////////////////////////////////////////
755/// Set the default file browser.
756
761
762////////////////////////////////////////////////////////////////////////////////
763/// Override from TRootBrowser. We need to be more brutal as fBrowser is
764/// not set in Eve case.
765
767{
768 delete this;
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Virtual from TRootBrowser. Need to intercept closing of Eve tabs.
773
775{
776 // Check if this is an Eve window and destroy accordingly.
777 TGCompositeFrame *pcf = fTabRight->GetTabContainer(id);
778 if (pcf)
779 {
780 TGFrameElement *fe = (TGFrameElement *) pcf->GetList()->First();
781 if (fe)
782 {
783 TEveCompositeFrame *ecf = dynamic_cast<TEveCompositeFrame*>(fe->fFrame);
784 if (ecf)
785 {
787 return;
788 }
789 }
790 }
791
792 // Fallback to standard tab destruction
794}
795
796////////////////////////////////////////////////////////////////////////////////
797/// Virtual from TGMainFrame. Calls TEveManager::Terminate().
798
803
804////////////////////////////////////////////////////////////////////////////////
805/// Hide the bottom tab (usually holding command-line widget).
806
808{
809 fV2->HideFrame(fHSplitter);
810 fV2->HideFrame(fH2);
811}
812
813////////////////////////////////////////////////////////////////////////////////
814/// TRootBrowser keeps (somewhat unnecessarily) counters for number ob tabs
815/// on each position. Eve bastardizes the right tab so we have to fix the counters
816/// when a new window is added ... it doesn't seem to be needed when it is removed.
817
819{
820 fNbTab[TRootBrowser::kRight] = fTabRight->GetNumberOfTabs();
821 fCrTab[TRootBrowser::kRight] = fTabRight->GetNumberOfTabs() - 1;
822}
@ kRaisedFrame
Definition GuiTypes.h:385
@ kSunkenFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:382
@ kDoubleBorder
Definition GuiTypes.h:386
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kFixedHeight
Definition GuiTypes.h:390
const Mask_t kKeyControlMask
Definition GuiTypes.h:198
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_Delete
Definition KeySymbols.h:33
@ kKey_Enter
Definition KeySymbols.h:31
#define b(i)
Definition RSha256.hxx:100
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
@ kCyan
Definition Rtypes.h:67
@ kBlue
Definition Rtypes.h:67
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
externTEveManager * gEve
#define gClient
Definition TGClient.h:157
@ kNoCleanup
Definition TGFrame.h:40
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
externTSystem * gSystem
Definition TSystem.h:582
#define gVirtualX
Definition TVirtualX.h:375
virtual void SetBrowser(TBrowser *b)
Definition TBrowserImp.h:68
TBrowserImp(const TBrowserImp &)=delete
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
TContextMenu * GetContextMenu() const
Definition TBrowser.h:97
void SetBrowserImp(TBrowserImp *i)
Definition TBrowser.h:96
Describes one element of the context menu associated to a class The menu item may describe.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition TClass.cxx:4399
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4932
static ULong_t Number2Pixel(Int_t ci)
This class provides an interface to context sensitive popup menus.
TEveBrowser(const TEveBrowser &)
void CalculateReparentXY(TGObject *parent, Int_t &x, Int_t &y)
Calculate position of a widget for reparenting into parent.
TGFileBrowser * GetFileBrowser() const
Returns the default file-browser.
void SanitizeTabCounts()
TRootBrowser keeps (somewhat unnecessarily) counters for number ob tabs on each position.
void EveMenu(Int_t id)
Handle events from Eve menu.
void SetupCintExport(TClass *cl)
Add "Export to CINT" into context-menu for class cl.
void CloseTab(Int_t id) override
Virtual from TRootBrowser. Need to intercept closing of Eve tabs.
void CloseWindow() override
Virtual from TGMainFrame. Calls TEveManager::Terminate().
void ReallyDelete() override
Override from TRootBrowser.
TGPopupMenu * fSelPopup
TGPopupMenu * fHilPopup
TGFileBrowser * MakeFileBrowser(Bool_t make_default=kFALSE)
Create a file-browser.
void SetFileBrowser(TGFileBrowser *b)
Set the default file browser.
void InitPlugins(Option_t *opt="FI")
Initialize standard plugins.
TGPopupMenu * fEvePopup
void HideBottomTab()
Hide the bottom tab (usually holding command-line widget).
TGFileBrowser * fFileBrowser
Abstract base-class for frame-slots that encompass EVE-windows (sub-classes of TEveWindow).
Definition TEveWindow.h:40
TEveWindow * GetEveWindow() const
Definition TEveWindow.h:86
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
virtual Int_t GetNItems() const
virtual void ExpandIntoListTree(TGListTree *ltree, TGListTreeItem *parent)
Populates parent with elements.
Int_t GetDenyDestroy() const
Returns the number of times deny-destroy has been requested on the element.
virtual TObject * GetObject(const TEveException &eh) const
Get a TObject associated with this render-element.
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
static TString fgEditorClass
static void SetEditorClass(const char *edclass)
Set GED editor class.
void ItemClicked(TGListTreeItem *entry, Int_t btn, UInt_t mask, Int_t x, Int_t y)
Item has been clicked, based on mouse button do:
void DisconnectSignals()
Disconnect list-tree signals.
TEveGListTreeEditorFrame(const TEveGListTreeEditorFrame &)
void ReconfToVertical()
Reconfigure to vertical layout, list-tree above the editor.
void ItemBelowMouse(TGListTreeItem *entry, UInt_t mask)
Different item is below mouse.
~TEveGListTreeEditorFrame() override
Destructor.
TEveGedEditor * fEditor
Definition TEveBrowser.h:96
TGCompositeFrame * fLTFrame
Definition TEveBrowser.h:91
void ItemDblClicked(TGListTreeItem *item, Int_t btn)
Item has been double-clicked, potentially expand the children.
TContextMenu * fCtxMenu
Definition TEveBrowser.h:98
TGCompositeFrame * fFrame
Definition TEveBrowser.h:90
void ItemKeyPress(TGListTreeItem *entry, UInt_t keysym, UInt_t mask)
A key has been pressed for an item.
void ReconfToHorizontal()
Reconfigure to horizontal layout, list-tree and editor side by side.
void ConnectSignals()
Connect list-tree signals.
Specialization of TGedEditor for proper update propagation to TEveManager.
Pixel_t GetActiveColor() const override
Return highlight color corresponding to current state of TEveElement.
TEveElement * fElement
Definition TEveBrowser.h:36
void Toggle() override
Item's check-box state has been toggled ... forward to element's render-state.
void NotSupported(const char *func) const
Warn about access to function members that should never be called.
Bool_t IsChecked() const override
Definition TEveBrowser.h:68
static void Terminate()
Properly terminate global TEveManager.
Description of TEveWindowSlot.
Definition TEveWindow.h:302
virtual void DestroyWindowAndSlot()
Destroy eve-window and its frame-slot.
static TEveWindowSlot * CreateWindowMainFrame(TEveWindow *eve_parent=nullptr)
Create a new main-frame and populate it with a default window-slot.
static TEveWindowSlot * CreateWindowInTab(TGTab *tab, TEveWindow *eve_parent=nullptr)
Create a new tab in a given tab-widget and populate it with a default window-slot.
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1064
System file browser, used as TRootBrowser plug-in.
void BrowseObj(TObject *obj) override
Browse object.
void SetNewBrowser(TRootBrowser *b)
void Show() override
TGLayoutHints * fLayout
Definition TGLayout.h:114
TGFrame * fFrame
Definition TGLayout.h:112
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition TGFrame.cxx:688
void MapWindow() override
map window
Definition TGFrame.h:206
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
virtual void SetPadRight(Int_t v)
Definition TGLayout.h:92
virtual void SetPadLeft(Int_t v)
Definition TGLayout.h:91
virtual void SetPadTop(Int_t v)
Definition TGLayout.h:89
virtual void SetPadBottom(Int_t v)
Definition TGLayout.h:90
virtual void SetLayoutHints(ULong_t lh)
Definition TGLayout.h:88
TGListTreeItem * GetFirstChild() const
Definition TGListTree.h:61
TGListTreeItem * GetParent() const
Definition TGListTree.h:60
virtual void * GetUserData() const =0
virtual void SetUserData(void *, Bool_t=kFALSE)
Definition TGListTree.h:81
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:197
TGMainFrame(const TGMainFrame &)=delete
This class is the baseclass for all ROOT GUI widgets.
Definition TGObject.h:21
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
This class creates a popup menu object.
Definition TGMenu.h:110
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:986
ROOT GUI Window base class.
Definition TGWindow.h:23
@ kEditEnable
allow edit of this window
Definition TGWindow.h:56
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
static TClass * Class()
A doubly linked list.
Definition TList.h:38
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
Mother of all ROOT objects.
Definition TObject.h:42
virtual TClass * IsA() const
Definition TObject.h:248
void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1) override
Start embedding external frame in the tab "pos" and tab element "subpos".
void SetTabTitle(const char *title, Int_t pos=kRight, Int_t subpos=-1)
Set text "title" of Tab "subpos" in TGTab "pos".
Int_t fCrTab[3]
Actual (active) tab elements (for each Tab).
TRootBrowser(const TRootBrowser &)=delete
TGHorizontalFrame * fH2
Horizontal frame.
Int_t fNbTab[3]
Number of tab elements (for each Tab).
TGHSplitter * fHSplitter
Horizontal splitter.
virtual void CloseTab(Int_t id)
Remove tab element id from right tab.
void StopEmbedding(const char *name=nullptr) override
TGHorizontalFrame * fPreMenuFrame
First (owned) menu frame.
TGTab * fTabRight
Right Tab.
TGPopupMenu * fMenuFile
"File" popup menu
TGTab * GetTabRight() const
TGHorizontalFrame * fTopMenuFrame
Top menu frame.
TGMenuBar * fMenuBar
Main (owned) menu bar.
void InitPlugins(Option_t *opt="")
Initialize default plugins.
TGVerticalFrame * fV2
Vertical frame.
Basic string class.
Definition TString.h:138
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:713
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TLine l
Definition textangle.C:4