Logo ROOT   6.07/09
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 
19 void window_manager()
20 {
22 
23  TEveUtil::Macro("pointset.C");
24 
25  PackTest();
26  DetailTest();
27  TabsTest();
28 
30  gDebug = 1;
31 }
32 
33 void PackTest()
34 {
35  TEveWindowSlot *slot = 0;
36  TEveWindowFrame *frame = 0;
37  TEveViewer *v = 0;
38 
40  TEveWindowPack* pack1 = slot->MakePack();
41  pack1->SetShowTitleBar(kFALSE);
42  pack1->SetHorizontal();
43 
44  // Embedded viewer.
45  slot = pack1->NewSlot();
46  v = new TEveViewer("BarViewer");
48  slot->ReplaceWindow(v);
49  v->SetElementName("Bar Embedded Viewer");
50 
51  gEve->GetViewers()->AddElement(v);
53 
54  slot = pack1->NewSlot();
55  TEveWindowPack* pack2 = slot->MakePack();
56  pack2->SetShowTitleBar(kFALSE);
57 
58  slot = pack2->NewSlot();
59  slot->StartEmbedding();
60  TCanvas* can = new TCanvas("Root Canvas");
61  can->ToggleEditor();
62  slot->StopEmbedding();
63 
64  // SA viewer.
65  slot = pack2->NewSlot();
66  v = new TEveViewer("FooViewer");
68  slot->ReplaceWindow(v);
69  gEve->GetViewers()->AddElement(v);
71 }
72 
73 
74 void DetailTest()
75 {
76  TEveWindowSlot* slot =
78  pack1 = slot->MakePack();
79  pack1->SetShowTitleBar(kFALSE);
80  pack1->SetElementName("Detail");
81  pack1->SetHorizontal();
82 
83  // left slot
84  slot = pack1->NewSlot();
85  frame = slot->MakeFrame();
86  frame->SetElementName("Latex Frame");
87  frame->SetShowTitleBar(kFALSE);
89  TGCompositeFrame* hf = new TGVerticalFrame(cf);
92  {
93  TGVerticalFrame* guiFrame = new TGVerticalFrame(hf);
94  hf->AddFrame(guiFrame, new TGLayoutHints(kLHintsExpandX));
95  guiFrame->SetCleanup(kDeepCleanup);
96 
97  guiFrame->AddFrame(new TGLabel(guiFrame, "Press Button:"),
98  new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
99  TGTextButton *b = new TGTextButton(guiFrame, "TestButton");
100  guiFrame->AddFrame(b, new TGLayoutHints(kLHintsExpandX));
101  TRootEmbeddedCanvas* ec =
102  new TRootEmbeddedCanvas("Embeddedcanvas", hf, 220);
104  double fontsize = 0.07;
105  double x = 0.02;
106  double y = 1 -1*fontsize;
107  TLatex* latex = new TLatex(x, y, "Legend:");
108  latex->SetTextSize(fontsize);
109  latex->Draw();
110  y -= 2*fontsize;
111  // legend
112  latex->DrawLatex(x, y, "greek letter #Delta#eta_{out}");
113  y -= fontsize;
114  latex->DrawLatex(x, y, "#color[5]{+} marker");
115  y -= fontsize;
116  latex->DrawLatex(x, y, "#color[5]{+} marker");
117  y -= fontsize;
118  latex->DrawLatex(x, y, "#color[4]{+} marker");
119  y -= fontsize;
120  latex->DrawLatex(x, y, "#color[5]{#bullet} marker");
121  y -= fontsize;
122  latex->DrawLatex(x, y, "#color[4]{#bullet} marker some text");
123  y -= fontsize;
124  latex->DrawLatex(x, y, "#color[2]{#Box} square");
125  y -= fontsize;
126  latex->DrawLatex(x, y, "#color[5]{#Box} color");
127  }
128 
129  cf->MapSubwindows();
130  cf->Layout();
131  cf->MapWindow();
132 
133  // viewer slot
134  TEveWindowSlot* slot2 = pack1->NewSlotWithWeight(3);
135  TEveViewer* viewer = new TEveViewer("DetailView", "DetailView");
136  TGLEmbeddedViewer* embeddedViewer = viewer->SpawnGLEmbeddedViewer();
137  slot2->ReplaceWindow(viewer);
138  gEve->GetViewers()->AddElement(viewer);
139  viewer->AddScene(gEve->GetEventScene());
140 }
141 
142 void TabsTest()
143 {
144  TRandom r(0);
145  TEveWindowSlot *slot = 0;
146  TEveWindowFrame *frame = 0;
147  TEveViewer *v = 0;
148 
150  TEveWindowTab* tab1 = slot->MakeTab();
151  tab1->SetElementName("Tabs");
152  tab1->SetShowTitleBar(kFALSE);
153 
154  // horizontal text views
155  slot = tab1->NewSlot();
156  TEveWindowPack* pack1 = slot->MakePack();
157  for(int i = 0; i<4;++i)
158  {
159  Int_t weight = r.Uniform(3, 7);
160  slot = pack1->NewSlotWithWeight(weight);
161  frame = slot->MakeFrame();
162  frame->SetElementName(Form("FrameInPack %d", i));
163  TGCompositeFrame* cf = frame->GetGUICompositeFrame();
164  TGTextView* text_view = new TGTextView(cf, 200, 400);
165  cf->AddFrame(text_view, new TGLayoutHints(kLHintsLeft |
167  kLHintsExpandY));
168 
169  for(Int_t l =0; l<weight; l++)
170  {
171  text_view->AddLine(Form("slot[%d] add line %d here ", i, l));
172  }
173  text_view->Update();
174  text_view->SetWidth(text_view->ReturnLongestLineWidth()+20);
175  text_view->Layout();
176 
177  cf->MapSubwindows();
178  cf->Layout();
179  cf->MapWindow();
180  }
181 
182  // canvas tab
183  slot = tab1->NewSlot();
184  frame = slot->MakeFrame(new TRootEmbeddedCanvas());
185  frame->SetElementName("Embedded Canvas");
186 
187  // neseted 2nd leveltabs
188  slot = tab1->NewSlot();
189  slot->SetShowTitleBar(kFALSE);
190  TEveWindowTab* tab2 = slot->MakeTab();
191  tab2->SetElementName("Nested");
192  tab2->SetShowTitleBar(kFALSE);
193  slot = tab2->NewSlot();
194  slot->SetShowTitleBar(kFALSE);
195  slot = tab2->NewSlot();
196  slot->SetShowTitleBar(kFALSE);
197 }
virtual TEveWindowSlot * NewSlot()
Create new frame-slot - a new tab.
virtual TEveWindowSlot * NewSlot()
Create a new frame-slot at the last position of the pack.
TEveViewerList * GetViewers() const
Definition: TEveManager.h:145
virtual TEveWindowSlot * NewSlot()
Definition: TEveWindow.h:242
Encapsulates TGPack into an eve-window.
Definition: TEveWindow.h:360
TEveWindowFrame * StopEmbedding(const char *name=0)
An embedded window is created in place of this window-slot.
const char * tab1
Definition: TXMLPlayer.cxx:123
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.
Description of TEveWindowSlot.
Definition: TEveWindow.h:301
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
TEveWindowTab * MakeTab()
A tab is created in place of this window-slot.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:255
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
TEveWindowFrame * MakeFrame(TGFrame *frame=0)
An eve-window-frame is created and frame is passed into it.
Minimal GL-viewer that can be embedded in a standard ROOT frames.
Double_t x[n]
Definition: legend1.C:17
virtual Long_t ReturnLongestLineWidth()
Return width of longest line.
Definition: TGTextView.cxx:270
void ReplaceWindow(TEveWindow *w)
Replace this window with the passed one.
Definition: TEveWindow.cxx:819
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:31
To draw Mathematical Formula.
Definition: TLatex.h:25
virtual void AddLine(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:227
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
TGCompositeFrame * GetGUICompositeFrame()
Returns the registered top-frame of this eve-window dynamic-casted to composite-frame.
virtual void Update()
update the whole window of text view
Definition: TGTextView.cxx:260
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
virtual void SetElementName(const char *name)
Virtual function for setting of name of an element.
Definition: TEveElement.h:484
const char * tab2
Definition: TXMLPlayer.cxx:124
TEveGedEditor * GetEditor() const
Returns main object editor.
virtual void Layout()
Layout the components of view.
TRandom2 r(17)
SVector< double, 2 > v
Definition: Dict.h:5
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
TGLEmbeddedViewer * SpawnGLEmbeddedViewer(TGedEditor *ged=0, Int_t border=0)
Spawn new GLViewer and adopt it.
Definition: TEveViewer.cxx:200
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
char * Form(const char *fmt,...)
TLine * l
Definition: textangle.C:4
Encapsulates TGTab into an eve-window.
Definition: TEveWindow.h:395
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2147
The Canvas class.
Definition: TCanvas.h:41
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:309
TEveWindowPack * MakePack()
A pack is created in place of this window-slot.
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
static void Macro(const char *mac)
Execute macro &#39;mac&#39;. Do not reload the macro.
Definition: TEveUtil.cxx:168
TEveScene * GetEventScene() const
Definition: TEveManager.h:148
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
Double_t y[n]
Definition: legend1.C:17
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition: TRandom.cxx:606
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 MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
virtual void MapWindow()
Definition: TGFrame.h:267
virtual void AddElement(TEveElement *el)
Call base-class implementation.
Definition: TEveViewer.cxx:358
virtual TEveWindowSlot * NewSlotWithWeight(Float_t w)
Create a new weighted frame-slot at the last position of the pack.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
void SetShowTitleBar(Bool_t x)
Set display state of the title-bar.
Definition: TEveWindow.cxx:898
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:52
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
TGCompositeFrame * StartEmbedding()
Start embedding a window that will replace the current slot.
Encapsulates TGFrame into an eve-window.
Definition: TEveWindow.h:335
Eve representation of TGLViewer.
Definition: TEveViewer.h:30
TGLSAViewer * SpawnGLViewer(TGedEditor *ged=0, Bool_t stereo=kFALSE, Bool_t quad_buf=kTRUE)
Spawn new GLViewer and adopt it.
Definition: TEveViewer.cxx:155
virtual void AddScene(TEveScene *scene)
Add &#39;scene&#39; to the list of scenes.
Definition: TEveViewer.cxx:261