Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
exec_macro.C File Reference

Detailed Description

This utility macro executes the macro "macro" given as first argument and save a capture in a png file.

This macro is used by stressGUI to execute and compare the output of the GUI tutorials.

#include "TSystem.h"
#include "TString.h"
#include "TGClient.h"
#include "TGWindow.h"
#include "TClass.h"
#include "THashList.h"
#include "TROOT.h"
#include "TInterpreter.h"
#include "TEnv.h"
#include "TVirtualX.h"
#include "TImage.h"
//______________________________________________________________________________
{
enum EErrorCodes {
kSuccess,
};
if (gROOT->IsBatch() || !(gClient))
TString pwd(gSystem->pwd());
Int_t err = 0;
TString cmd(".x ");
if (comp)
cmd += "+";
gVirtualX->Sync(1);
gROOT->ProcessLine(cmd, &err);
gSystem->cd(pwd);
TGWindow *win = nullptr;
TIter iWin(gClient->GetListOfWindows());
while ((win = (TGWindow *)iWin())) {
const TObject *winGetParent = win->GetParent();
if (winGetParent == gClient->GetDefaultRoot())
winIsMapped = kTRUE; // win->IsMapped();
if (winIsMapped && win->InheritsFrom(clGMainFrame)) {
win->MapRaised();
if (save) {
outfile.ReplaceAll(".C", TString::Format("_%d.png", ++nMainFrames));
win->RaiseWindow();
img->FromWindow(win->GetId());
img->WriteImage(outfile.Data());
delete img;
}
}
}
if (!gEnv->GetValue("X11.Sync", 0))
gVirtualX->Sync(0);
return kSuccess;
}
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
#define gClient
Definition TGClient.h:157
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
#define gROOT
Definition TROOT.h:406
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:3069
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
ROOT GUI Window base class.
Definition TGWindow.h:23
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Create()
Create an image.
Definition TImage.cxx:35
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t cd(const char *path)
Definition TSystem.h:433
const char * pwd()
Definition TSystem.h:434
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:934
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1032
Author
Bertrand Bellenot

Definition in file exec_macro.C.