Logo ROOT   6.14/05
Reference Guide
TObjectDrawable.cxx
Go to the documentation of this file.
1 /// \file TObjectDrawable.cxx
2 /// \ingroup CanvasPainter ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2017-05-31
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #include <ROOT/TObjectDrawable.hxx>
17 
18 #include <ROOT/TDisplayItem.hxx>
19 #include <ROOT/TLogger.hxx>
20 #include <ROOT/TMenuItem.hxx>
21 #include <ROOT/TPadPainter.hxx>
22 
23 #include "TClass.h"
24 #include "TROOT.h"
25 
26 #include <exception>
27 
29 {
30  pad.AddDisplayItem(std::make_unique<TObjectDisplayItem>(fObj.get(), fOpts.GetOptionString()));
31 }
32 
34 {
35  TObject *obj = fObj.get();
36 
37  // fill context menu items for the ROOT class
38  items.PopulateObjectMenu(obj, obj->IsA());
39 }
40 
41 void ROOT::Experimental::TObjectDrawable::Execute(const std::string &exec)
42 {
43  TObject *obj = fObj.get();
44 
45  TString cmd;
46  cmd.Form("((%s*) %p)->%s;", obj->ClassName(), obj, exec.c_str());
47  printf("TObjectDrawable::Execute Obj %s Cmd %s\n", obj->GetName(), cmd.Data());
48  gROOT->ProcessLine(cmd);
49 }
#define gROOT
Definition: TROOT.h:410
void PopulateMenu(TMenuItems &) final
Fill menu items for the object.
Basic string class.
Definition: TString.h:131
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
const std::shared_ptr< TObject > fObj
The object to be painted.
void Execute(const std::string &) final
Executes menu item.
const std::string & GetOptionString() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2264
void PopulateObjectMenu(void *obj, TClass *cl)
Definition: TMenuItem.cxx:33
Abstract interface for object painting on the pad/canvas.
Definition: TPadPainter.hxx:37
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void AddDisplayItem(std::unique_ptr< TDisplayItem > &&item)
add display item to the canvas
Definition: TPadPainter.cxx:21
void Paint(Internal::TPadPainter &canv) final
Paint the object.
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
const char * Data() const
Definition: TString.h:364