8 #include "StCheckQtEnv.h"
10 #include "TApplication.h"
11 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,00,0)
19 gEnv->SetValue(
"Gui.Backend",
"qt");
20 gEnv->SetValue(
"Gui.Factory",
"qtgui");
21 gApplication->NeedGraphicsLibs();
22 gApplication->InitializeGraphics();
28 FILE *StCheckQtEnv::OpeFileName(
const char *fileNamePrototype)
31 return fopen( (
const char*)GetNewFileName(fileNamePrototype),
"w");
34 TString StCheckQtEnv::GetNewFileName(
const char *fileNamePrototype)
37 TString fileName = fileNamePrototype;
38 gSystem->ExpandPathName(fileName);
40 Ssiz_t fileExtension = fileName.Last(
'.');
41 TString fileNameHold = fileName;
42 if ((fileExtension==0) || (fileExtension == -1)) {
43 fileExtension = fileName.Length();
46 while (gSystem->AccessPathName(fileName.Data())==0) {
47 fileName = fileNameHold;
48 fileName.Insert(fileExtension,Form(
".%d",counter++));
56 Int_t StCheckQtEnv::SetRootResource(FILE *file,
const char *plugin,
57 const char *lib,
const char *full,Bool_t append)
59 fprintf(stderr,
" Testing the plugin <%s> from the lib = <%s>\n", plugin, lib);
65 fullName = Form(
"lib%s",lib);
66 fullValue = Form(full,lib);
71 if ( !full || gSystem->DynamicPathName(fullName.Data(),kTRUE) ) {
74 TString currentPlugin = gEnv->GetValue(plugin,
"none");
75 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,00,0)
76 TPRegexp exp(Form(
"\\b%s\\b",lib));
78 TString exp(Form(
" %s ",lib));
80 if ( !currentPlugin.Contains(exp) )
88 gEnv->SetValue(plugin,fullValue);
90 fputs(Form(
"%s %s\n",plugin,fullValue.Data()), file);
100 Long_t StCheckQtEnv::SetQtEnv(
bool checkCoin) {
108 static InitGraph init_graph;
109 const char *plugins[] = {
112 ,
" qt TGQt %s \"TGQt(const char*,const char*)\""
114 ,
"Gui.Backend",
"qt", 0
116 ,
"Plugin.TGuiFactory"
118 ,
" qtgui TQtGUIFactory %s \"TQtGUIFactory()\""
120 ,
"Gui.Factory",
"qtgui", 0
122 ,
"Gui.Factory",
"qt" , 0
124 ,
"Plugin.TVirtualPadEditor"
126 ,
" Ged TQtGedEditor %s \"TQtGedEditor(TCanvas*)\""
128 ,
"Plugin.TVirtualViewer3D"
130 ,
" ogl TQtRootViewer3D %s \"TQtRootViewer3D(TVirtualPad*)\""
132 ,
"Plugin.TVirtualViewer3D"
134 ,
" oiv TQtRootCoinViewer3D %s \"TQtRootCoinViewer3D(TVirtualPad*)\""
139 TString fileName = GetNewFileName(
"rootrc");
140 FILE *f = fopen((
const char *)fileName,
"w");
143 if ((c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2]))) {
145 c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2]);
148 if ((c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2]))) {
150 if ((c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2]))) {
158 c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2]);
163 c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2]);
167 if ((c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2]))) {
172 if (gSystem->DynamicPathName(
"libCoin",kTRUE)) {
174 c+=SetRootResource(f,plugins[iPlugin],plugins[iPlugin+1],plugins[iPlugin+2],kTRUE);
176 fprintf(stderr,
" ----------------------------------------------------------\n");
177 fprintf(stderr,
" ATTENTION : \n");
178 fprintf(stderr,
"\"Coin3d\" shared libraries has not beed detected\n");
179 fprintf(stderr,
" Please, run:\n\n");
180 fprintf(stderr,
"===== \"source $STAR/QtRoot/qtgl/qtcoin/setup.csh\" =====\n\n");
181 fprintf(stderr,
" script to activated the advanced (recommended) Coin3D env.\n");
182 fprintf(stderr,
" ----------------------------------------------------------\n");
183 fprintf(stderr,
" and re-start your application\n");
184 fprintf(stderr,
" ----------------------------------------------------------\n");
186 gSystem->Sleep(5000);
195 fprintf(stderr,
" No shared library to activate the Qt-layer has been detected.\n");
196 fprintf(stderr,
" Please talk to your SysAdmin\n");
197 gSystem->Unlink(fileName.Data());
200 Long_t id; Long_t size; Long_t flags; Long_t modtime;
201 gSystem->GetPathInfo(fileName.Data(), &id, &size, &flags, &modtime);
204 fprintf(stderr,
" ----------------------------------------------------------\n");
205 fprintf(stderr,
" The correct Qt/Root env has been detected.\n");
206 fprintf(stderr,
" ----------------------------------------------------------\n");
207 gSystem->Unlink(fileName.Data());
209 fprintf(stderr,
" ----------------------------------------------------------\n");
210 fprintf(stderr,
" ATTENTION : \n");
211 fprintf(stderr,
" The new version of ROOT resource file has been created: <%s>.\n",fileName.Data());
212 if (gSystem->AccessPathName(
".rootrc")) {
213 fprintf(stderr,
" To active the Qt-layer - create a symlink:\n");
214 fprintf(stderr,
"============ \"ln -s %s .rootrc \" ====================\n", fileName.Data());
216 fprintf(stderr,
" To active the Qt-layer - **merge** the existen \".rootrc\" file with \"%s\" \n", fileName.Data());
218 fprintf(stderr,
" and re-start your application\n");
219 fprintf(stderr,
" ----------------------------------------------------------\n");