Logo ROOT   6.18/05
Reference Guide
RObjectDrawable.hxx
Go to the documentation of this file.
1/// \file ROOT/RObjectDrawable.hxx
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_RObjectDrawable
17#define ROOT7_RObjectDrawable
18
19#include <ROOT/RDrawable.hxx>
21#include "ROOT/RStringView.hxx"
22#include "ROOT/RDisplayItem.hxx"
23
24#include <memory>
25#include <string>
26#include <vector>
27
28class TObject;
29
30namespace ROOT {
31namespace Experimental {
32
33class RPadBase;
34
35/// \class ROOT::Experimental::Internal::RObjectDrawingOpts Drawing options for TObject.
37 std::string fOpts; ///< The drawing options
38
39public:
40 RObjectDrawingOpts(const std::string &opts = "") : fOpts(opts) {}
41
42 const std::string &GetOptionString() const { return fOpts; }
43};
44
45/// \class ROOT::Experimental::Internal::RObjectDrawable
46/// Provides v7 drawing facilities for TObject types (TGraph etc).
47class RObjectDrawable : public RDrawableBase<RObjectDrawable> {
48 const std::shared_ptr<TObject> fObj; ///< The object to be painted
50
51public:
52 RObjectDrawable() = default;
53
54 RObjectDrawable(const std::shared_ptr<TObject> &obj, const std::string &opt) : fObj(obj), fOpts(opt) {}
55
56 /// Paint the object
57 void Paint(Internal::RPadPainter &canv) final;
58
59 /// Fill menu items for the object
60 void PopulateMenu(RMenuItems &) final;
61
62 /// Get the options - a string!
63 const RObjectDrawingOpts &GetOptions() const { return fOpts; }
64
66
67 /// Executes menu item
68 void Execute(const std::string &) final;
69};
70
72protected:
73 const TObject *fObject; ///< object to draw
74 std::string fOption; ///< v6 draw options
75public:
76 RObjectDisplayItem(TObject *obj, const std::string &opt) : fObject(obj), fOption(opt) {}
77};
78
79} // namespace Experimental
80} // namespace ROOT
81
82/// Interface to graphics taking a shared_ptr<TObject>.
83/// Must be on global scope, else lookup cannot find it (no ADL for TObject).
84inline std::shared_ptr<ROOT::Experimental::RObjectDrawable>
85GetDrawable(const std::shared_ptr<TObject> &obj, const std::string &opt = "")
86{
87 return std::make_shared<ROOT::Experimental::RObjectDrawable>(obj, opt);
88}
89
90#endif
std::shared_ptr< ROOT::Experimental::RObjectDrawable > GetDrawable(const std::shared_ptr< TObject > &obj, const std::string &opt="")
Interface to graphics taking a shared_ptr<TObject>.
Abstract interface for object painting on the pad/canvas.
Definition: RPadPainter.hxx:37
Base class for painting data for JS.
std::string fOption
v6 draw options
RObjectDisplayItem(TObject *obj, const std::string &opt)
const TObject * fObject
object to draw
void Paint(Internal::RPadPainter &canv) final
Paint the object.
const RObjectDrawingOpts & GetOptions() const
Get the options - a string!
void Execute(const std::string &) final
Executes menu item.
void PopulateMenu(RMenuItems &) final
Fill menu items for the object.
RObjectDrawable(const std::shared_ptr< TObject > &obj, const std::string &opt)
const std::shared_ptr< TObject > fObj
The object to be painted.
const std::string & GetOptionString() const
RObjectDrawingOpts(const std::string &opts="")
std::string fOpts
The drawing options.
Mother of all ROOT objects.
Definition: TObject.h:37
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21