Logo ROOT  
Reference Guide
window_manager.C File Reference

Detailed Description

Demonstrates usage of EVE window-manager.

#include "TEveWindow.h"
#include "TEveViewer.h"
#include "TEveManager.h"
#include "TEveBrowser.h"
#include "TEveGedEditor.h"
#include "TCanvas.h"
#include "TGTab.h"
void PackTest();
void DetailTest();
void TabsTest();
void window_manager()
{
TEveUtil::Macro("pointset.C");
PackTest();
DetailTest();
TabsTest();
gDebug = 1;
}
void PackTest()
{
TEveWindowSlot *slot = 0;
TEveWindowFrame *frame = 0;
TEveViewer *v = 0;
TEveWindowPack* pack1 = slot->MakePack();
pack1->SetHorizontal();
// Embedded viewer.
slot = pack1->NewSlot();
v = new TEveViewer("BarViewer");
v->SpawnGLEmbeddedViewer(gEve->GetEditor());
slot->ReplaceWindow(v);
v->SetElementName("Bar Embedded Viewer");
v->AddScene(gEve->GetEventScene());
slot = pack1->NewSlot();
TEveWindowPack* pack2 = slot->MakePack();
slot = pack2->NewSlot();
slot->StartEmbedding();
TCanvas* can = new TCanvas("Root Canvas");
can->ToggleEditor();
slot->StopEmbedding();
// SA viewer.
slot = pack2->NewSlot();
v = new TEveViewer("FooViewer");
v->SpawnGLViewer(gEve->GetEditor());
slot->ReplaceWindow(v);
v->AddScene(gEve->GetEventScene());
}
void DetailTest()
{
TEveWindowFrame *frame = 0;
TEveWindowPack* pack1 = slot->MakePack();
pack1->SetElementName("Detail");
pack1->SetHorizontal();
// left slot
slot = pack1->NewSlot();
frame = slot->MakeFrame();
frame->SetElementName("Latex Frame");
{
TGVerticalFrame* guiFrame = new TGVerticalFrame(hf);
hf->AddFrame(guiFrame, new TGLayoutHints(kLHintsExpandX));
guiFrame->AddFrame(new TGLabel(guiFrame, "Press Button:"),
new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
TGTextButton *b = new TGTextButton(guiFrame, "TestButton");
new TRootEmbeddedCanvas("Embeddedcanvas", hf, 220);
double fontsize = 0.07;
double x = 0.02;
double y = 1 -1*fontsize;
TLatex* latex = new TLatex(x, y, "Legend:");
latex->SetTextSize(fontsize);
latex->Draw();
y -= 2*fontsize;
// legend
latex->DrawLatex(x, y, "greek letter #Delta#eta_{out}");
y -= fontsize;
latex->DrawLatex(x, y, "#color[5]{+} marker");
y -= fontsize;
latex->DrawLatex(x, y, "#color[5]{+} marker");
y -= fontsize;
latex->DrawLatex(x, y, "#color[4]{+} marker");
y -= fontsize;
latex->DrawLatex(x, y, "#color[5]{#bullet} marker");
y -= fontsize;
latex->DrawLatex(x, y, "#color[4]{#bullet} marker some text");
y -= fontsize;
latex->DrawLatex(x, y, "#color[2]{#Box} square");
y -= fontsize;
latex->DrawLatex(x, y, "#color[5]{#Box} color");
}
cf->Layout();
cf->MapWindow();
// viewer slot
TEveWindowSlot* slot2 = pack1->NewSlotWithWeight(3);
TEveViewer* viewer = new TEveViewer("DetailView", "DetailView");
TGLEmbeddedViewer* embeddedViewer = viewer->SpawnGLEmbeddedViewer();
slot2->ReplaceWindow(viewer);
gEve->GetViewers()->AddElement(viewer);
}
void TabsTest()
{
TRandom r(0);
TEveWindowSlot *slot = 0;
TEveWindowFrame *frame = 0;
TEveViewer *v = 0;
tab1->SetElementName("Tabs");
tab1->SetShowTitleBar(kFALSE);
// horizontal text views
slot = tab1->NewSlot();
TEveWindowPack* pack1 = slot->MakePack();
for(int i = 0; i<4;++i)
{
Int_t weight = r.Uniform(3, 7);
slot = pack1->NewSlotWithWeight(weight);
frame = slot->MakeFrame();
frame->SetElementName(Form("FrameInPack %d", i));
TGTextView* text_view = new TGTextView(cf, 200, 400);
cf->AddFrame(text_view, new TGLayoutHints(kLHintsLeft |
for(Int_t l =0; l<weight; l++)
{
text_view->AddLine(Form("slot[%d] add line %d here ", i, l));
}
text_view->Update();
text_view->SetWidth(text_view->ReturnLongestLineWidth()+20);
text_view->Layout();
cf->Layout();
cf->MapWindow();
}
// canvas tab
slot = tab1->NewSlot();
frame = slot->MakeFrame(new TRootEmbeddedCanvas());
frame->SetElementName("Embedded Canvas");
// neseted 2nd leveltabs
slot = tab1->NewSlot();
tab2->SetElementName("Nested");
tab2->SetShowTitleBar(kFALSE);
slot = tab2->NewSlot();
slot = tab2->NewSlot();
}
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
R__EXTERN Int_t gDebug
Definition: RtypesCore.h:117
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:121
const char * tab2
Definition: TXMLPlayer.cxx:122
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
The Canvas class.
Definition: TCanvas.h:27
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2397
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:359
Eve representation of TGLViewer.
Definition: TEveViewer.h:31
virtual void AddScene(TEveScene *scene)
Add 'scene' to the list of scenes.
Definition: TEveViewer.cxx:262
TGLEmbeddedViewer * SpawnGLEmbeddedViewer(TGedEditor *ged=0, Int_t border=0)
Spawn new GLViewer and adopt it.
Definition: TEveViewer.cxx:201
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:820
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:899
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1241
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1056
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1148
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:271
virtual void MapWindow()
map window
Definition: TGFrame.h:229
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:508
virtual void Update()
update the whole window of text view
Definition: TGTextView.cxx:261
virtual Long_t ReturnLongestLineWidth()
Return width of longest line.
Definition: TGTextView.cxx:271
virtual void AddLine(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:228
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:1926
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
Author
Matevz Tadel

Definition in file window_manager.C.