GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GRootGuiFactory.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 15/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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 "GRootGuiFactory.h"
13#include "TRootApplication.h"
14
15#include "GRootCanvas.h"
16
17#include "TRootBrowserLite.h"
18#include "TRootContextMenu.h"
19#include "TRootControlBar.h"
20#include "TROOT.h"
21#include "TPluginManager.h"
22#include "TEnv.h"
23
24#include "GCanvas.h"
25
27{
28 if(gROOT->IsBatch()) {
29 return;
30 }
31 gROOT->LoadClass("TCanvas", "Gpad");
32 gGuiFactory = new GRootGuiFactory();
33}
34
35//______________________________________________________________________________
36GRootGuiFactory::GRootGuiFactory(const char* name, const char* title) : TGuiFactory(name, title)
37{
38 // GRootGuiFactory ctor.
39}
40
41//______________________________________________________________________________
42TApplicationImp* GRootGuiFactory::CreateApplicationImp(const char* classname, int* argc, char** argv)
43{
44 // Create a ROOT native GUI version of TApplicationImp
45
46 auto* app = new TRootApplication(classname, argc, argv);
47 if(app->Client() == nullptr) {
48 delete app;
49 app = nullptr;
50 }
51 return app;
52}
53
54//______________________________________________________________________________
55TCanvasImp* GRootGuiFactory::CreateCanvasImp(TCanvas* c, const char* title, UInt_t width, UInt_t height)
56{
57 // Create a ROOT native GUI version of TCanvasImp
58 // return new GRootCanvas(c, title, width, height);i
59 auto* grc = new GRootCanvas(static_cast<GCanvas*>(c), title, width, height);
60
61 return grc;
62}
63
64//______________________________________________________________________________
65TCanvasImp* GRootGuiFactory::CreateCanvasImp(TCanvas* c, const char* title, Int_t x, Int_t y, UInt_t width,
66 UInt_t height)
67{
68 // Create a ROOT native GUI version of TCanvasImp
69 // return new GRootCanvas(c, title, x, y, width, height);
70 auto* grc = new GRootCanvas(static_cast<GCanvas*>(c), title, x, y, width, height);
71
72 return grc;
73}
74
75//______________________________________________________________________________
76TBrowserImp* GRootGuiFactory::CreateBrowserImp(TBrowser* b, const char* title, UInt_t width, UInt_t height,
77 Option_t* opt)
78{
79 // Create a ROOT native GUI version of TBrowserImp
80
81 // TString browserVersion(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
82 TString browserVersion(gEnv->GetValue("Browser.Name", "GRootBrowser"));
83 TPluginHandler* pluginHandler = gROOT->GetPluginManager()->FindHandler("TBrowserImp", browserVersion);
84 // gROOT->GetPluginManager()->Print();
85
86 TString browserOptions(gEnv->GetValue("Browser.Options", "FECI"));
87 // TString browserOptions(gEnv->GetValue("Browser.Options", "FEI"));
88 if((opt != nullptr) && (strlen(opt) != 0u)) {
89 browserOptions = opt;
90 }
91
92 // browserOptions = "FCI";
93
94 browserOptions.ToUpper();
95 if(browserOptions.Contains("LITE")) {
96 return new TRootBrowserLite(b, title, width, height);
97 }
98 if(pluginHandler != nullptr && pluginHandler->LoadPlugin() != -1) {
99 auto* imp = reinterpret_cast<TBrowserImp*>(pluginHandler->ExecPlugin(5, b, title, width, height, browserOptions.Data())); // NOLINT(performance-no-int-to-ptr)
100 if(imp != nullptr) {
101
102 return imp;
103 }
104 }
105 return new TRootBrowserLite(b, title, width, height);
106}
107
108//______________________________________________________________________________
109TBrowserImp* GRootGuiFactory::CreateBrowserImp(TBrowser* b, const char* title, Int_t x, Int_t y, UInt_t width,
110 UInt_t height, Option_t* opt)
111{
112 // Create a ROOT native GUI version of TBrowserImp
113
114 TString browserVersion(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
115 TPluginHandler* pluginHandler = gROOT->GetPluginManager()->FindHandler("TBrowserImp", browserVersion);
116 TString browserOptions(gEnv->GetValue("Browser.Options", "FECI"));
117 if((opt != nullptr) && (strlen(opt) != 0u)) {
118 browserOptions = opt;
119 }
120 browserOptions.ToUpper();
121 if(browserOptions.Contains("LITE")) {
122 return new TRootBrowserLite(b, title, width, height);
123 }
124 if(pluginHandler != nullptr && pluginHandler->LoadPlugin() != -1) {
125 auto* imp = reinterpret_cast<TBrowserImp*>(pluginHandler->ExecPlugin(7, b, title, x, y, width, height, browserOptions.Data())); // NOLINT(performance-no-int-to-ptr)
126 if(imp != nullptr) {
127 return imp;
128 }
129 }
130 return new TRootBrowserLite(b, title, x, y, width, height);
131}
132
133//______________________________________________________________________________
134TContextMenuImp* GRootGuiFactory::CreateContextMenuImp(TContextMenu* c, const char* name, const char*)
135{
136 // Create a ROOT native GUI version of TContextMenuImp
137
138 return new TRootContextMenu(c, name);
139}
140
141//______________________________________________________________________________
142TControlBarImp* GRootGuiFactory::CreateControlBarImp(TControlBar* c, const char* title)
143{
144 // Create a ROOT native GUI version of TControlBarImp
145
146 return new TRootControlBar(c, title);
147}
148
149//______________________________________________________________________________
150TControlBarImp* GRootGuiFactory::CreateControlBarImp(TControlBar* c, const char* title, Int_t x, Int_t y)
151{
152 // Create a ROOT native GUI version of TControlBarImp
153
154 return new TRootControlBar(c, title, x, y);
155}
TBrowserImp * CreateBrowserImp(TBrowser *b, const char *title, UInt_t width, UInt_t height, Option_t *opt="") override
GRootGuiFactory(const char *name="Root", const char *title="GRUT GUI Factory")
TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height) override
TApplicationImp * CreateApplicationImp(const char *classname, int *argc, char **argv) override
static void Init()
TControlBarImp * CreateControlBarImp(TControlBar *c, const char *title) override
TContextMenuImp * CreateContextMenuImp(TContextMenu *c, const char *name, const char *title) override