ROOT » CORE » BASE » TExec

class TExec: public TNamed


   TExec is a utility class that can be used to execute a CINT command
   when some event happens in a pad.
   The command in turn can invoke a CINT macro to paint graphics objects
   at positions depending on the histogram or graph contents.

 Case 1:

 The TExec object is in the list of pad primitives (after exec.Draw()).
 When the pad is drawn, the TExec::Paint function is called. This function
 will execute the specified command.
 The following example uses the services of the class Aclock created
 in $ROOTSYS/test/Aclock.cxx.
 This examples uses a TTimer to redraw a pad at regular intervals (clock).
 When the clock is updated, a string with the current date&time is drawn.
{
   gSystem->Load("$ROOTSYS/test/Aclock");
   Aclock ck(400);
   gPad->SetFillColor(5);
   TDatime dt;
   TText t(.5,.3,"t");
   t.SetTextAlign(22);
   t.SetTextSize(.07);
   t.SetTextColor(4);
   t.Draw();
   TExec ex("ex","dt.Set();t.SetTitle(dt.AsString())");
   ex.Draw();
}

 Case 2:

 The TExec object may be added to the list of functions of a TH1 or TGraph
 object via hist->GetListOfFunctions()->Add(exec).
 When the histogram (or graph) is drawn, the TExec will be executed.
 If the histogram is made persistent on a file, the TExec object
 is also saved with the histogram. When redrawing the histogram in a
 new session, the TExec will be executed.
 Example:
     Assume an histogram TH1F *h already filled.
     TExec *ex1 = new TExec("ex1","DoSomething()");
     TExec *ex2 = new TExec("ex2",".x macro.C");
     h->GetListOfFunctions()->Add(ex1);
     h->GetListOfFunctions()->Add(ex2);
     h->Draw();
  When the Paint function for the histogram will be called, the "DoSomething"
  function will be called (interpreted or compiled) and also the macro.C.

 Case 3:

 A TExec object is automatically generated when invoking TPad::AddExec.
 Each pad contains a TList of TExecs (0, 1 or more). When a mouse event
 (motion, click, etc) happens, the pad object executes sequentially
 this list of TExecs. In the code (interpreted or compiled) executed
 by the TExec referenced command, one can call the pad service functions
 such as TPad::GetEvent, TPad::GetEventX, TPad::GetEventY to find
 which type of event and the X,Y position of the mouse.
 By default, the list of TExecs is executed. This can be disabled
 via the canvas menu "Option".
 See $ROOTSYS/tutorials/hist/exec2.C for an example.
    Root > TFile f("hsimple.root");
    Root > hpxpy.Draw();
    Root > c1.AddExec("ex2",".x exec2.C");
    When moving the mouse in the canvas, a second canvas shows the
    projection along X of the bin corresponding to the Y position
    of the mouse. The resulting histogram is fitted with a gaussian.
    A "dynamic" line shows the current bin position in Y.
    This more elaborated example can be used as a starting point
    to develop more powerful interactive applications exploiting CINT
    as a development engine.

 The 3 options above can be combined.

Function Members (Methods)

public:
virtual~TExec()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidExec(const char* command = "")
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TExec&operator=(const TExec&)
virtual voidPaint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTNamed::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidSavePrimitive(ostream& out, Option_t* option = "")
virtual voidSetAction(const char* action)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp) const
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
TExec()
TExec(const TExec& text)
TExec(const char* name, const char* command)
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()

Data Members

public:
static TObject::<anonymous>TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::<anonymous>TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::<anonymous>TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::<anonymous>TObject::kOverwrite
static TObject::<anonymous>TObject::kSingleKey
static TObject::<anonymous>TObject::kWriteDelete
static TObject::<anonymous>TObject::kZombie
protected:
TStringTNamed::fNameobject identifier
TStringTNamed::fTitleobject title

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TExec()
 Exec default constructor.
TExec(const char* name, const char* command)
 Exec normal constructor.
~TExec()
 Exec default destructor.
TExec(const TExec& text)
 Copy constructor.
void Exec(const char* command = "")
 Execute the command referenced by this object.

  if command is given, this command is executed
 otherwise the default command of the object is executed

 if the default command (in the exec title) is empty, an attemp is made
 to execute the exec name if it contains a "." or a "(", otherwise
 the command ".x execname.C" is executed.
 The function returns the result of the user function/script.
void Paint(Option_t* option = "")
 Execute the command referenced by this object.
void SavePrimitive(ostream& out, Option_t* option = "")
 Save primitive as a C++ statement(s) on output stream out.
void SetAction(const char* action)
{SetTitle(action);}