Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
window_manager.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage of EVE window-manager.
4///
5/// \image html eve_window_manager.png
6/// \macro_code
7///
8/// \author Matevz Tadel
9
10#include "TEveWindow.h"
11#include "TEveViewer.h"
12#include "TEveManager.h"
13#include "TEveBrowser.h"
14#include "TEveGedEditor.h"
15#include "TGLEmbeddedViewer.h"
16#include "TCanvas.h"
17#include "TGTab.h"
18
19void PackTest();
20void DetailTest();
21void TabsTest();
22
23void window_manager()
24{
26
27 TEveUtil::Macro("pointset.C");
28
29 PackTest();
30 DetailTest();
31 TabsTest();
32
33 gEve->GetBrowser()->GetTabRight()->SetTab(1);
34 gDebug = 1;
35}
36
37void PackTest()
38{
39 TEveWindowSlot *slot = 0;
40 TEveWindowFrame *frame = 0;
41 TEveViewer *v = 0;
42
43 slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
44 TEveWindowPack *pack1 = slot->MakePack();
45 pack1->SetShowTitleBar(kFALSE);
46 pack1->SetHorizontal();
47
48 // Embedded viewer.
49 slot = pack1->NewSlot();
50 v = new TEveViewer("BarViewer");
51 v->SpawnGLEmbeddedViewer(gEve->GetEditor());
52 slot->ReplaceWindow(v);
53 v->SetElementName("Bar Embedded Viewer");
54
55 gEve->GetViewers()->AddElement(v);
56 v->AddScene(gEve->GetEventScene());
57
58 slot = pack1->NewSlot();
59 TEveWindowPack *pack2 = slot->MakePack();
60 pack2->SetShowTitleBar(kFALSE);
61
62 slot = pack2->NewSlot();
63 slot->StartEmbedding();
64 TCanvas *can = new TCanvas("Root Canvas");
65 can->ToggleEditor();
66 slot->StopEmbedding();
67
68 // SA viewer.
69 slot = pack2->NewSlot();
70 v = new TEveViewer("FooViewer");
71 v->SpawnGLViewer(gEve->GetEditor());
72 slot->ReplaceWindow(v);
73 gEve->GetViewers()->AddElement(v);
74 v->AddScene(gEve->GetEventScene());
75}
76
77void DetailTest()
78{
79 TEveWindowFrame *frame = 0;
80
81 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
82 TEveWindowPack *pack1 = slot->MakePack();
83 pack1->SetShowTitleBar(kFALSE);
84 pack1->SetElementName("Detail");
85 pack1->SetHorizontal();
86
87 // left slot
88 slot = pack1->NewSlot();
89 frame = slot->MakeFrame();
90 frame->SetElementName("Latex Frame");
91 frame->SetShowTitleBar(kFALSE);
96 {
97 TGVerticalFrame *guiFrame = new TGVerticalFrame(hf);
98 hf->AddFrame(guiFrame, new TGLayoutHints(kLHintsExpandX));
99 guiFrame->SetCleanup(kDeepCleanup);
100
101 guiFrame->AddFrame(new TGLabel(guiFrame, "Press Button:"), new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
102 TGTextButton *b = new TGTextButton(guiFrame, "TestButton");
103 guiFrame->AddFrame(b, new TGLayoutHints(kLHintsExpandX));
104 TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Embeddedcanvas", hf, 220);
106 double fontsize = 0.07;
107 double x = 0.02;
108 double y = 1 - 1 * fontsize;
109 TLatex *latex = new TLatex(x, y, "Legend:");
110 latex->SetTextSize(fontsize);
111 latex->Draw();
112 y -= 2 * fontsize;
113 // legend
114 latex->DrawLatex(x, y, "greek letter #Delta#eta_{out}");
115 y -= fontsize;
116 latex->DrawLatex(x, y, "#color[5]{+} marker");
117 y -= fontsize;
118 latex->DrawLatex(x, y, "#color[5]{+} marker");
119 y -= fontsize;
120 latex->DrawLatex(x, y, "#color[4]{+} marker");
121 y -= fontsize;
122 latex->DrawLatex(x, y, "#color[5]{#bullet} marker");
123 y -= fontsize;
124 latex->DrawLatex(x, y, "#color[4]{#bullet} marker some text");
125 y -= fontsize;
126 latex->DrawLatex(x, y, "#color[2]{#Box} square");
127 y -= fontsize;
128 latex->DrawLatex(x, y, "#color[5]{#Box} color");
129 }
130
131 cf->MapSubwindows();
132 cf->Layout();
133 cf->MapWindow();
134
135 // viewer slot
136 TEveWindowSlot *slot2 = pack1->NewSlotWithWeight(3);
137 TEveViewer *viewer = new TEveViewer("DetailView", "DetailView");
138 TGLEmbeddedViewer *embeddedViewer = viewer->SpawnGLEmbeddedViewer();
139 slot2->ReplaceWindow(viewer);
140 gEve->GetViewers()->AddElement(viewer);
141 viewer->AddScene(gEve->GetEventScene());
142}
143
144void TabsTest()
145{
146 TRandom r(0);
147 TEveWindowSlot *slot = 0;
148 TEveWindowFrame *frame = 0;
149 TEveViewer *v = 0;
150
151 slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
152 TEveWindowTab *tab1 = slot->MakeTab();
153 tab1->SetElementName("Tabs");
154 tab1->SetShowTitleBar(kFALSE);
155
156 // horizontal text views
157 slot = tab1->NewSlot();
158 TEveWindowPack *pack1 = slot->MakePack();
159 for (int i = 0; i < 4; ++i) {
160 Int_t weight = r.Uniform(3, 7);
161 slot = pack1->NewSlotWithWeight(weight);
162 frame = slot->MakeFrame();
163 frame->SetElementName(Form("FrameInPack %d", i));
165 TGTextView *text_view = new TGTextView(cf, 200, 400);
167
168 for (Int_t l = 0; l < weight; l++) {
169 text_view->AddLine(Form("slot[%d] add line %d here ", i, l));
170 }
171 text_view->Update();
172 text_view->SetWidth(text_view->ReturnLongestLineWidth() + 20);
173 text_view->Layout();
174
175 cf->MapSubwindows();
176 cf->Layout();
177 cf->MapWindow();
178 }
179
180 // canvas tab
181 slot = tab1->NewSlot();
182 frame = slot->MakeFrame(new TRootEmbeddedCanvas());
183 frame->SetElementName("Embedded Canvas");
184
185 // neseted 2nd leveltabs
186 slot = tab1->NewSlot();
187 slot->SetShowTitleBar(kFALSE);
188 TEveWindowTab *tab2 = slot->MakeTab();
189 tab2->SetElementName("Nested");
190 tab2->SetShowTitleBar(kFALSE);
191 slot = tab2->NewSlot();
192 slot->SetShowTitleBar(kFALSE);
193 slot = tab2->NewSlot();
194 slot->SetShowTitleBar(kFALSE);
195}
ROOT::R::TRInterface & r
Definition Object.C:4
#define b(i)
Definition RSha256.hxx:100
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
externTEveManager * gEve
@ kLocalCleanup
Definition TGFrame.h:41
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsExpandX
Definition TGLayout.h:30
Int_t gDebug
Definition TROOT.cxx:777
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
const char * tab1
const char * tab2
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:53
The Canvas class.
Definition TCanvas.h:23
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2448
void SetElementName(const char *name) override
Virtual function for setting of name of an element.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
static void Macro(const char *mac)
Execute macro 'mac'. Do not reload the macro.
Definition TEveUtil.cxx:163
Eve representation of TGLViewer.
Definition TEveViewer.h:31
TGLEmbeddedViewer * SpawnGLEmbeddedViewer(TGedEditor *ged=nullptr, Int_t border=0)
Spawn new GLViewer and adopt it.
virtual void AddScene(TEveScene *scene)
Add 'scene' to the list of scenes.
Encapsulates TGFrame into an eve-window.
Definition TEveWindow.h:336
TGCompositeFrame * GetGUICompositeFrame()
Returns the registered top-frame of this eve-window dynamic-casted to composite-frame.
Encapsulates TGPack into an eve-window.
Definition TEveWindow.h:361
void SetHorizontal()
Definition TEveWindow.h:381
virtual TEveWindowSlot * NewSlotWithWeight(Float_t w)
Create a new weighted frame-slot at the last position of the pack.
TEveWindowSlot * NewSlot() override
Create a new frame-slot at the last position of the pack.
Description of TEveWindowSlot.
Definition TEveWindow.h:302
TEveWindowFrame * MakeFrame(TGFrame *frame=nullptr)
An eve-window-frame is created and frame is passed into it.
TEveWindowFrame * StopEmbedding(const char *name=nullptr)
An embedded window is created in place of this window-slot.
TGCompositeFrame * StartEmbedding()
Start embedding a window that will replace the current slot.
TEveWindowTab * MakeTab()
A tab is created in place of this window-slot.
TEveWindowPack * MakePack()
A pack is created in place of this window-slot.
Encapsulates TGTab into an eve-window.
Definition TEveWindow.h:396
void ReplaceWindow(TEveWindow *w)
Replace this window with the passed one.
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.
void SetShowTitleBar(Bool_t x)
Set display state of the title-bar.
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
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
void MapWindow() override
map window
Definition TGFrame.h:206
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:248
Minimal GL-viewer that can be embedded in a standard ROOT frames.
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextView is a text viewer widget.
Definition TGTextView.h:22
virtual void Update()
update the whole window of text view
virtual Long_t ReturnLongestLineWidth()
Return width of longest line.
void Layout() override
Layout the components of view.
virtual void AddLine(const char *string)
Add a line of text to the view widget.
A composite frame that layout their children in vertical way.
Definition TGFrame.h:376
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:293
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
This class creates a TGCanvas in which a TCanvas is created.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TLine l
Definition textangle.C:4