Logo ROOT   6.12/07
Reference Guide
TObjectDrawable.hxx
Go to the documentation of this file.
1 /// \file ROOT/TDisplayItem.h
2 /// \ingroup Base ROOT7
3 /// \author Sergey Linev
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 #ifndef ROOT7_TObjectDrawable
17 #define ROOT7_TObjectDrawable
18 
19 #include <ROOT/TDrawable.hxx>
20 #include "RStringView.h"
21 #include <memory>
22 
23 class TObject;
24 
25 namespace ROOT {
26 namespace Experimental {
27 
28 class TPadBase;
29 
30 /// \class ROOT::Experimental::Internal::TObjectDrawable
31 /// Provides v7 drawing facilities for TObject types (TGraph etc).
32 class TObjectDrawable: public TDrawable {
33  const std::shared_ptr<TObject> fObj; ///< The object to be painted
34  std::string fOpts; ///< The drawing options
35 
36 public:
37 
38  TObjectDrawable() = default;
39 
40  TObjectDrawable(const std::shared_ptr<TObject> &obj): fObj(obj) {}
41 
42  /// Paint the histogram
43  void Paint(Internal::TVirtualCanvasPainter &canv) final;
44 
45  /// Fill menu items for the object
46  void PopulateMenu(TMenuItems &) final;
47 
48  /// Get the options - a string!
49  std::string &Options() { return fOpts; }
50 
51  /// Executes menu item
52  void Execute(const std::string &) final;
53 };
54 } // namespace Experimental
55 } // namespace ROOT
56 
57 /// Interface to graphics taking a shared_ptr<TObject>.
58 /// Must be on global scope, else lookup cannot find it (no ADL for TObject).
59 inline std::unique_ptr<ROOT::Experimental::TDrawable>
60 GetDrawable(const std::shared_ptr<TObject> &obj, ROOT::Experimental::TPadBase & /* parent */)
61 {
62  return std::make_unique<ROOT::Experimental::TObjectDrawable>(obj);
63 }
64 
65 #endif
Base class for drawable entities: objects that can be painted on a TPad.
Definition: TDrawable.hxx:36
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
void PopulateMenu(TMenuItems &) final
Fill menu items for the object.
TObjectDrawable(const std::shared_ptr< TObject > &obj)
Base class for graphic containers for TDrawable-s.
Definition: TPad.hxx:41
std::string & Options()
Get the options - a string!
const std::shared_ptr< TObject > fObj
The object to be painted.
void Execute(const std::string &) final
Executes menu item.
std::string fOpts
The drawing options.
Abstract interface for painting a canvas.
Mother of all ROOT objects.
Definition: TObject.h:37
void Paint(Internal::TVirtualCanvasPainter &canv) final
Paint the histogram.
std::unique_ptr< TPadDrawable > GetDrawable(std::unique_ptr< TPad > &&pad, TPadBase &parent)
Definition: TPad.hxx:237