Logo ROOT  
Reference Guide
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
34 gDebug = 1;
35}
36
37void PackTest()
38{
39 TEveWindowSlot *slot = 0;
40 TEveWindowFrame *frame = 0;
41 TEveViewer *v = 0;
42
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
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);
74 v->AddScene(gEve->GetEventScene());
75}
76
77
78void DetailTest()
79{
80 TEveWindowFrame *frame = 0;
81
82 TEveWindowSlot* slot =
84 TEveWindowPack* pack1 = slot->MakePack();
85 pack1->SetShowTitleBar(kFALSE);
86 pack1->SetElementName("Detail");
87 pack1->SetHorizontal();
88
89 // left slot
90 slot = pack1->NewSlot();
91 frame = slot->MakeFrame();
92 frame->SetElementName("Latex Frame");
93 frame->SetShowTitleBar(kFALSE);
98 {
99 TGVerticalFrame* guiFrame = new TGVerticalFrame(hf);
100 hf->AddFrame(guiFrame, new TGLayoutHints(kLHintsExpandX));
101 guiFrame->SetCleanup(kDeepCleanup);
102
103 guiFrame->AddFrame(new TGLabel(guiFrame, "Press Button:"),
104 new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
105 TGTextButton *b = new TGTextButton(guiFrame, "TestButton");
106 guiFrame->AddFrame(b, new TGLayoutHints(kLHintsExpandX));
108 new TRootEmbeddedCanvas("Embeddedcanvas", hf, 220);
110 double fontsize = 0.07;
111 double x = 0.02;
112 double y = 1 -1*fontsize;
113 TLatex* latex = new TLatex(x, y, "Legend:");
114 latex->SetTextSize(fontsize);
115 latex->Draw();
116 y -= 2*fontsize;
117 // legend
118 latex->DrawLatex(x, y, "greek letter #Delta#eta_{out}");
119 y -= fontsize;
120 latex->DrawLatex(x, y, "#color[5]{+} marker");
121 y -= fontsize;
122 latex->DrawLatex(x, y, "#color[5]{+} marker");
123 y -= fontsize;
124 latex->DrawLatex(x, y, "#color[4]{+} marker");
125 y -= fontsize;
126 latex->DrawLatex(x, y, "#color[5]{#bullet} marker");
127 y -= fontsize;
128 latex->DrawLatex(x, y, "#color[4]{#bullet} marker some text");
129 y -= fontsize;
130 latex->DrawLatex(x, y, "#color[2]{#Box} square");
131 y -= fontsize;
132 latex->DrawLatex(x, y, "#color[5]{#Box} color");
133 }
134
135 cf->MapSubwindows();
136 cf->Layout();
137 cf->MapWindow();
138
139 // viewer slot
140 TEveWindowSlot* slot2 = pack1->NewSlotWithWeight(3);
141 TEveViewer* viewer = new TEveViewer("DetailView", "DetailView");
142 TGLEmbeddedViewer* embeddedViewer = viewer->SpawnGLEmbeddedViewer();
143 slot2->ReplaceWindow(viewer);
144 gEve->GetViewers()->AddElement(viewer);
145 viewer->AddScene(gEve->GetEventScene());
146}
147
148void TabsTest()
149{
150 TRandom r(0);
151 TEveWindowSlot *slot = 0;
152 TEveWindowFrame *frame = 0;
153 TEveViewer *v = 0;
154
156 TEveWindowTab* tab1 = slot->MakeTab();
157 tab1->SetElementName("Tabs");
158 tab1->SetShowTitleBar(kFALSE);
159
160 // horizontal text views
161 slot = tab1->NewSlot();
162 TEveWindowPack* pack1 = slot->MakePack();
163 for(int i = 0; i<4;++i)
164 {
165 Int_t weight = r.Uniform(3, 7);
166 slot = pack1->NewSlotWithWeight(weight);
167 frame = slot->MakeFrame();
168 frame->SetElementName(Form("FrameInPack %d", i));
170 TGTextView* text_view = new TGTextView(cf, 200, 400);
171 cf->AddFrame(text_view, new TGLayoutHints(kLHintsLeft |
174
175 for(Int_t l =0; l<weight; l++)
176 {
177 text_view->AddLine(Form("slot[%d] add line %d here ", i, l));
178 }
179 text_view->Update();
180 text_view->SetWidth(text_view->ReturnLongestLineWidth()+20);
181 text_view->Layout();
182
183 cf->MapSubwindows();
184 cf->Layout();
185 cf->MapWindow();
186 }
187
188 // canvas tab
189 slot = tab1->NewSlot();
190 frame = slot->MakeFrame(new TRootEmbeddedCanvas());
191 frame->SetElementName("Embedded Canvas");
192
193 // neseted 2nd leveltabs
194 slot = tab1->NewSlot();
195 slot->SetShowTitleBar(kFALSE);
196 TEveWindowTab* tab2 = slot->MakeTab();
197 tab2->SetElementName("Nested");
198 tab2->SetShowTitleBar(kFALSE);
199 slot = tab2->NewSlot();
200 slot->SetShowTitleBar(kFALSE);
201 slot = tab2->NewSlot();
202 slot->SetShowTitleBar(kFALSE);
203}
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
R__EXTERN Int_t gDebug
Definition: Rtypes.h:91
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
@ kLocalCleanup
Definition: TGFrame.h:50
@ kDeepCleanup
Definition: TGFrame.h:51
@ kLHintsExpandY
Definition: TGLayout.h:38
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsExpandX
Definition: TGLayout.h:37
char * Form(const char *fmt,...)
const char * tab1
Definition: TXMLPlayer.cxx:122
const char * tab2
Definition: TXMLPlayer.cxx:123
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
The Canvas class.
Definition: TCanvas.h:31
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2303
virtual void SetElementName(const char *name)
Virtual function for setting of name of an element.
Definition: TEveElement.h:453
TEveViewerList * GetViewers() const
Definition: TEveManager.h:145
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
TEveGedEditor * GetEditor() const
Returns main object editor.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
TEveScene * GetEventScene() const
Definition: TEveManager.h:148
static void Macro(const char *mac)
Execute macro 'mac'. Do not reload the macro.
Definition: TEveUtil.cxx:168
virtual void AddElement(TEveElement *el)
Call base-class implementation.
Definition: TEveViewer.cxx:358
Eve representation of TGLViewer.
Definition: TEveViewer.h:31
virtual void AddScene(TEveScene *scene)
Add 'scene' to the list of scenes.
Definition: TEveViewer.cxx:261
TGLEmbeddedViewer * SpawnGLEmbeddedViewer(TGedEditor *ged=0, Int_t border=0)
Spawn new GLViewer and adopt it.
Definition: TEveViewer.cxx:200
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.
virtual TEveWindowSlot * NewSlot()
Create a new frame-slot at the last position of the pack.
Description of TEveWindowSlot.
Definition: TEveWindow.h:302
TEveWindowFrame * StopEmbedding(const char *name=0)
An embedded window is created in place of this window-slot.
TGCompositeFrame * StartEmbedding()
Start embedding a window that will replace the current slot.
TEveWindowFrame * MakeFrame(TGFrame *frame=0)
An eve-window-frame is created and frame is passed into it.
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.
Definition: TEveWindow.cxx:819
static TEveWindowSlot * CreateWindowInTab(TGTab *tab, TEveWindow *eve_parent=0)
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.
Definition: TEveWindow.cxx:898
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:293
virtual void MapWindow()
Definition: TGFrame.h:251
Minimal GL-viewer that can be embedded in a standard ROOT frames.
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition: TGTab.cxx:507
virtual void Update()
update the whole window of text view
Definition: TGTextView.cxx:260
virtual Long_t ReturnLongestLineWidth()
Return width of longest line.
Definition: TGTextView.cxx:270
virtual void AddLine(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:227
virtual void Layout()
Layout the components of view.
To draw Mathematical Formula.
Definition: TLatex.h:18
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
Definition: TLatex.cxx:1914
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TGTab * GetTabRight() const
Definition: TRootBrowser.h:141
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
auto * l
Definition: textangle.C:4